コード例 #1
0
        public DescriptorSet[] Allocate(DescriptorSetAllocateInfo info)
        {
            var infoNative = new VkDescriptorSetAllocateInfo();

            infoNative.sType              = VkStructureType.DescriptorSetAllocateInfo;
            infoNative.descriptorPool     = descriptorPool;
            infoNative.descriptorSetCount = info.descriptorSetCount;

            var layoutsMarshalled = new NativeArray <VkDescriptorSetLayout>(info.setLayouts.Count);

            for (int i = 0; i < info.setLayouts.Count; i++)
            {
                layoutsMarshalled[i] = info.setLayouts[i].Native;
            }
            infoNative.pSetLayouts = layoutsMarshalled.Address;

            var descriptorSetsMarshalled = new NativeArray <VkDescriptorSet>((int)info.descriptorSetCount);

            using (layoutsMarshalled)
                using (descriptorSetsMarshalled) {
                    var result = Device.Commands.allocateDescriptorSets(Device.Native, ref infoNative, descriptorSetsMarshalled.Address);
                    if (result != VkResult.Success)
                    {
                        throw new DescriptorPoolException(string.Format("Error allocating descriptor sets: {0}", result));
                    }

                    var results = new DescriptorSet[(int)info.descriptorSetCount];

                    for (int i = 0; i < info.descriptorSetCount; i++)
                    {
                        results[i] = new DescriptorSet(Device, this, descriptorSetsMarshalled[i]);
                    }

                    return(results);
                }
        }
コード例 #2
0
 public void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, PipelineLayout layout, uint firstSet, DescriptorSet descriptorSet, uint dynamicOffset)
 {
     unsafe
     {
         VkDescriptorSet setNative = descriptorSet.Native;
         Device.Commands.cmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout.Native,
                                               firstSet, 1, (IntPtr)(&setNative),
                                               1, (IntPtr)(&dynamicOffset));
     }
 }
コード例 #3
0
        public void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, PipelineLayout layout, uint firstSet, DescriptorSet descriptorSet, List <uint> dynamicOffsets)
        {
            unsafe
            {
                int dynamicOffsetCount = 0;
                if (dynamicOffsets != null)
                {
                    dynamicOffsetCount = dynamicOffsets.Count;
                }

                var offsets = stackalloc uint[dynamicOffsetCount];

                VkDescriptorSet setNative = descriptorSet.Native;
                Interop.Copy(dynamicOffsets, (IntPtr)offsets);

                Device.Commands.cmdBindDescriptorSets(commandBuffer, VkPipelineBindPoint.Graphics, layout.Native,
                                                      firstSet, 1, (IntPtr)(&setNative),
                                                      (uint)dynamicOffsetCount, (IntPtr)offsets);
            }
        }