Пример #1
0
        public void PushConstants <T>(PipelineLayout layout, VkShaderStageFlags stageFlags, uint offset, T[] data) where T : struct
        {
            GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);

            Device.Commands.cmdPushConstants(commandBuffer, layout.Native, stageFlags, offset, (uint)(data.Length * Interop.SizeOf <T>()), handle.AddrOfPinnedObject());
            handle.Free();
        }
Пример #2
0
 public void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, PipelineLayout layout, uint firstSet, DescriptorSet descriptorSet)
 {
     unsafe {
         VkDescriptorSet set = descriptorSet.Native;
         Device.Commands.cmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout.Native, firstSet, 1, (IntPtr)(&set), 0, IntPtr.Zero);
     }
 }
Пример #3
0
        public void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, PipelineLayout layout, uint firstSet, List <DescriptorSet> descriptorSets, List <uint> dynamicOffsets)
        {
            unsafe
            {
                int dynamicOffsetCount = 0;
                if (dynamicOffsets != null)
                {
                    dynamicOffsetCount = dynamicOffsets.Count;
                }

                var sets    = stackalloc VkDescriptorSet[descriptorSets.Count];
                var offsets = stackalloc uint[dynamicOffsetCount];

                for (int i = 0; i < descriptorSets.Count; i++)
                {
                    sets[i] = descriptorSets[i].Native;
                }

                for (int i = 0; i < dynamicOffsetCount; i++)
                {
                    offsets[i] = dynamicOffsets[i];
                }

                Device.Commands.cmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout.Native,
                                                      firstSet, (uint)descriptorSets.Count, (IntPtr)sets,
                                                      (uint)dynamicOffsetCount, (IntPtr)offsets);
            }
        }
Пример #4
0
 public void PushConstants <T>(PipelineLayout layout, VkShaderStageFlags stageFlags, uint offset, T data) where T : struct
 {
     unsafe
     {
         //can't take address of generic variable in c#
         IntPtr native = (IntPtr)Unsafe.AsPointer(ref data);
         Device.Commands.cmdPushConstants(commandBuffer, layout.Native, stageFlags, offset, (uint)Interop.SizeOf <T>(), native);
     }
 }
Пример #5
0
 public void PushConstants <T>(PipelineLayout layout, VkShaderStageFlags stageFlags, uint offset, List <T> data) where T : struct
 {
     unsafe
     {
         int   size   = (int)Interop.SizeOf <T>();
         byte *native = stackalloc byte[size * data.Count];
         Interop.Copy(data, (IntPtr)native);
         Device.Commands.cmdPushConstants(commandBuffer, layout.Native, stageFlags, offset, (uint)(size * data.Count), (IntPtr)native);
     }
 }
Пример #6
0
 public void PushConstants(PipelineLayout layout, VkShaderStageFlags stageFlags, uint offset, byte[] data)
 {
     unsafe
     {
         fixed(byte *ptr = data)
         {
             Device.Commands.cmdPushConstants(commandBuffer, layout.Native, stageFlags, offset, (uint)data.Length, (IntPtr)ptr);
         }
     }
 }
Пример #7
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);
            }
        }
Пример #8
0
        public void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, PipelineLayout layout, uint firstSet, DescriptorSet[] descriptorSets, uint[] dynamicOffsets)
        {
            unsafe
            {
                var sets = stackalloc VkDescriptorSet[descriptorSets.Length];

                for (int i = 0; i < descriptorSets.Length; i++)
                {
                    sets[i] = descriptorSets[i].Native;
                }

                int dynamicOffsetCount = 0;
                if (dynamicOffsets != null)
                {
                    dynamicOffsetCount = dynamicOffsets.Length;

                    fixed(uint *ptr = dynamicOffsets)
                    {
                        Device.Commands.cmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout.Native,
                                                              firstSet, (uint)descriptorSets.Length, (IntPtr)sets,
                                                              (uint)dynamicOffsetCount, (IntPtr)ptr);
                    }
            }
        }
Пример #9
0
 public void PushConstants(PipelineLayout layout, VkShaderStageFlags stageFlags, uint offset, uint size, IntPtr data)
 {
     Device.Commands.cmdPushConstants(commandBuffer, layout.Native, stageFlags, offset, size, data);
 }
Пример #10
0
 public void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, PipelineLayout layout, uint firstSet, List <DescriptorSet> descriptorSets)
 {
     BindDescriptorSets(pipelineBindPoint, layout, firstSet, descriptorSets, null);
 }