コード例 #1
0
        /// <summary>
        /// Adds the given binding descriptor
        /// </summary>
        /// <param name="binding">Binding to add</param>
        /// <param name="type">Binding type</param>
        /// <param name="arraySize">Binding's array size</param>
        /// <param name="flags">Shader stages</param>
        /// <param name="immutableSamplers">Immutable samplers for the binding</param>
        /// <returns>this</returns>
        public DescriptorSetLayoutBuilder Add(uint binding, VkDescriptorType type, uint arraySize,
                                              VkShaderStageFlag flags, params Sampler[] immutableSamplers)
        {
            Debug.Assert(immutableSamplers.Length == 0 || type == VkDescriptorType.CombinedImageSampler ||
                         type == VkDescriptorType.Sampler, "Can't use immutable samplers on non-sampler type");
            var samplersRewrite = immutableSamplers.Select(x =>
            {
                x.AssertValid();
                return(x.Handle);
            }).ToArray();

            if (samplersRewrite.Length > 0)
            {
                _pins.Add(GCHandle.Alloc(samplersRewrite, GCHandleType.Pinned));
            }
            unsafe
            {
                _bindings.Add(binding, new VkDescriptorSetLayoutBinding()
                {
                    Binding            = binding,
                    DescriptorType     = type,
                    DescriptorCount    = arraySize,
                    StageFlags         = flags,
                    PImmutableSamplers =
                        (VkSampler *)(samplersRewrite.Length > 0
                            ? Marshal.UnsafeAddrOfPinnedArrayElement(samplersRewrite, 0)
                            : IntPtr.Zero).ToPointer()
                });
            }
            return(this);
        }
コード例 #2
0
 public VkPipelineShaderStageCreateInfo(VkShaderModule module, string entryPoint, VkShaderStageFlag stage)
 {
     this.module        = module;
     name               = entryPoint;
     flags              = VkPipelineShaderStageCreateFlag.NONE;
     this.stage         = stage;
     specializationInfo = null;
 }
コード例 #3
0
 public PipelineLayoutBuilder WithPushConstant(VkShaderStageFlag flags, uint offset, uint size)
 {
     _pushConstants.Add(new VkPushConstantRange()
     {
         StageFlags = flags,
         Offset     = offset,
         Size       = size
     });
     return(this);
 }
コード例 #4
0
            internal ShaderStageBuilder(GraphicsPipelineBuilder builder, VkShaderModule handle,
                                        VkShaderStageFlag stage, string entryPoint)
            {
                _builder = builder;
                unsafe
                {
                    _shaderInfo = new VkPipelineShaderStageCreateInfo()
                    {
                        SType  = VkStructureType.PipelineShaderStageCreateInfo,
                        PNext  = IntPtr.Zero,
                        Module = handle,
                        Flags  = 0,
                        Stage  = stage,
                        PSpecializationInfo = (VkSpecializationInfo *)0
                    };
                }

                _entryPoint = entryPoint;
            }
コード例 #5
0
 /// <summary>
 /// Adds the given single element binding descriptor
 /// </summary>
 /// <param name="binding">Binding to add</param>
 /// <param name="type">Binding type</param>
 /// <param name="flags">Shader stages</param>
 /// <param name="immutableSampler">Immutable sampler for the binding</param>
 /// <returns>this</returns>
 public DescriptorSetLayoutBuilder Add(uint binding, VkDescriptorType type, VkShaderStageFlag flags,
                                       Sampler immutableSampler = null)
 {
     return(Add(binding, type, 1, flags, immutableSampler != null ? new[] { immutableSampler } : new Sampler[0]));
 }
コード例 #6
0
 internal DescriptorData(VkDescriptorSetLayoutBinding b)
 {
     Type   = b.DescriptorType;
     Count  = b.DescriptorCount;
     Stages = b.StageFlags;
 }
コード例 #7
0
 public ShaderStageBuilder ShaderStage(ShaderModule shader, VkShaderStageFlag flags, string entryPoint)
 {
     return(new ShaderStageBuilder(this, shader.Handle, flags, entryPoint));
 }