Esempio n. 1
0
        public DescriptorSet CreateDescriptorSet(int setIndex, int binding, BufferviewWithMemory bufferviewWithMemory)
        {
            ValidateDiscriporPool();

            DescriptorSetLayout descriptorSetLayout = DescriptorSetLayouts[setIndex];
            ShaderUniformSet    shaderUniformSet    = ShaderUniformSets[setIndex];

            DescriptorSet descriptorSet = VContext.Instance.device.AllocateDescriptorSets(
                new DescriptorSetAllocateInfo()
            {
                DescriptorPool = VContext.Instance.descriptorPool,
                SetLayouts     = new DescriptorSetLayout[]
                {
                    descriptorSetLayout
                }
            }
                ).First();

            ShaderUniform shaderUniformWithCorrectBinding = shaderUniformSet.ShaderUniforms.Where(su => su.Binding == binding).First();

            VContext.Instance.device.UpdateDescriptorSet
            (
                new WriteDescriptorSet()
            {
                DescriptorType = shaderUniformWithCorrectBinding.DescriptorType,
                DstBinding     = (uint)shaderUniformWithCorrectBinding.Binding,
                DstSet         = descriptorSet,
                BufferInfo     = new DescriptorBufferInfo[]
                {
                    new DescriptorBufferInfo()
                    {
                        Buffer = bufferviewWithMemory.Buffer,
                        Offset = 0,
                        Range  = bufferviewWithMemory.Size,
                    }
                },
                TexelBufferView = new BufferView[]
                {
                    bufferviewWithMemory.Bufferview
                },
            },
                null
            );

            return(descriptorSet);
        }
Esempio n. 2
0
        public DescriptorSet CreateDescriptorSet(int setIndex, int binding, ImageView imageView, ImageLayout imageLayout = ImageLayout.ColorAttachmentOptimal)
        {
            ValidateDiscriporPool();

            DescriptorSetLayout descriptorSetLayout = DescriptorSetLayouts[setIndex];
            ShaderUniformSet    shaderUniformSet    = ShaderUniformSets[setIndex];

            DescriptorSet descriptorSet = VContext.Instance.device.AllocateDescriptorSets
                                          (
                new DescriptorSetAllocateInfo()
            {
                DescriptorPool     = VContext.Instance.descriptorPool,
                DescriptorSetCount = 1,
                SetLayouts         = new DescriptorSetLayout[]
                {
                    descriptorSetLayout
                }
            }
                                          ).First();


            ShaderUniform shaderUniformWithCorrectBinding = shaderUniformSet.ShaderUniforms.Where(su => su.Binding == binding).First();

            VContext.Instance.device.UpdateDescriptorSet(
                new WriteDescriptorSet()
            {
                DescriptorType = shaderUniformWithCorrectBinding.DescriptorType,
                DstBinding     = (uint)shaderUniformWithCorrectBinding.Binding,
                DstSet         = descriptorSet,

                ImageInfo = new DescriptorImageInfo[]
                {
                    new DescriptorImageInfo()
                    {
                        ImageLayout = imageLayout,
                        ImageView   = imageView,
                        Sampler     = VContext.Instance.sampler
                    }
                }
            },
                null
                );

            return(descriptorSet);
        }