Exemple #1
0
        void setupDescriptorSetLayout()
        {
            var bindings = VkDescriptorSetLayoutBinding.Alloc(2);
            {
                // Binding 0 : Vertex shader uniform buffer
                bindings[0].binding         = 0;
                bindings[0].descriptorType  = VkDescriptorType.UniformBuffer;
                bindings[0].descriptorCount = 1;
                bindings[0].stageFlags      = VkShaderStageFlagBits.Vertex;
                // Binding 1 : Fragment shader image sampler
                bindings[1].binding         = 1;
                bindings[1].descriptorType  = VkDescriptorType.CombinedImageSampler;
                bindings[1].descriptorCount = 1;
                bindings[1].stageFlags      = VkShaderStageFlagBits.Fragment;
            }

            {
                var info = VkDescriptorSetLayoutCreateInfo.Alloc();
                info[0].bindings.count   = 2;
                info[0].bindings.pointer = bindings;
                VkDescriptorSetLayout layout;
                vkCreateDescriptorSetLayout(device, info, null, &layout);
                this.layout = layout;
            }

            {
                VkDescriptorSetLayout layout = this.layout;
                var info = VkPipelineLayoutCreateInfo.Alloc();
                info[0].setLayouts = layout;
                VkPipelineLayout pipelineLayout;
                vkCreatePipelineLayout(device, info, null, &pipelineLayout);
                this.pipelineLayout = pipelineLayout;
            }
        }
Exemple #2
0
        void setupDescriptorSetLayout()
        {
            var bindings = new VkDescriptorSetLayoutBinding[2];

            // Binding 0 : Vertex shader uniform buffer
            bindings[0] = new VkDescriptorSetLayoutBinding();
            bindings[0].descriptorType  = VkDescriptorType.UniformBuffer;
            bindings[0].stageFlags      = VkShaderStageFlagBits.Vertex;
            bindings[0].binding         = 0;
            bindings[0].descriptorCount = 1;
            // Binding 1 : Fragment shader combined sampler
            bindings[1] = new VkDescriptorSetLayoutBinding();
            bindings[1].descriptorType  = VkDescriptorType.CombinedImageSampler;
            bindings[1].stageFlags      = VkShaderStageFlagBits.Fragment;
            bindings[1].binding         = 1;
            bindings[1].descriptorCount = 1;

            var descriptorLayout = VkDescriptorSetLayoutCreateInfo.Alloc();

            descriptorLayout->bindings = bindings;

            VkDescriptorSetLayout dsl;

            vkCreateDescriptorSetLayout(device, descriptorLayout, null, &dsl);
            this.descriptorSetLayout = dsl;

            var info = new VkPipelineLayoutCreateInfo();

            info.sType      = PipelineLayoutCreateInfo;
            info.setLayouts = dsl;

            {
                VkPipelineLayout layout;
                vkCreatePipelineLayout(device, &info, null, &layout);
                this.pipelineLayout = layout;
            }
        }
        void setupDescriptorSetLayout()
        {
            // Scene rendering
            {
                var bindings = new VkDescriptorSetLayoutBinding[]
                {
                    // Binding 0: Vertex shader uniform buffer
                    new VkDescriptorSetLayoutBinding {
                        binding        = 0,
                        descriptorType = VkDescriptorType.UniformBuffer, descriptorCount = 1,
                        stageFlags     = VkShaderStageFlagBits.Vertex
                    },
                    // Binding 1: Fragment shader image sampler
                    new VkDescriptorSetLayoutBinding {
                        binding        = 1,
                        descriptorType = VkDescriptorType.CombinedImageSampler, descriptorCount = 1,
                        stageFlags     = VkShaderStageFlagBits.Fragment
                    },
                    // Binding 2: Fragment shader uniform buffer
                    new VkDescriptorSetLayoutBinding {
                        binding        = 2,
                        descriptorType = VkDescriptorType.UniformBuffer, descriptorCount = 1,
                        stageFlags     = VkShaderStageFlagBits.Fragment
                    },
                };

                var layoutInfo = VkDescriptorSetLayoutCreateInfo.Alloc();
                layoutInfo->bindings = bindings;
                {
                    VkDescriptorSetLayout layout;
                    vkCreateDescriptorSetLayout(device, layoutInfo, null, &layout);
                    this.setLayoutScene = layout;
                }
                {
                    var dsl = setLayoutScene;
                    var pPipelineLayoutCreateInfo = VkPipelineLayoutCreateInfo.Alloc();
                    pPipelineLayoutCreateInfo[0].setLayouts = dsl;
                    VkPipelineLayout pipelineLayout;
                    vkCreatePipelineLayout(device, pPipelineLayoutCreateInfo, null, &pipelineLayout);
                    this.pipelineLayoutScene = pipelineLayout;
                }
            }
            // Fullscreen radial blur
            {
                var bindings = new VkDescriptorSetLayoutBinding[]
                {
                    // Binding 0 : Vertex shader uniform buffer
                    new VkDescriptorSetLayoutBinding {
                        binding        = 0,
                        descriptorType = VkDescriptorType.UniformBuffer, descriptorCount = 1,
                        stageFlags     = VkShaderStageFlagBits.Fragment
                    },
                    // Binding 0: Fragment shader image sampler
                    new VkDescriptorSetLayoutBinding {
                        binding        = 1,
                        descriptorType = VkDescriptorType.CombinedImageSampler, descriptorCount = 1,
                        stageFlags     = VkShaderStageFlagBits.Fragment
                    },
                };
                var layoutInfo = VkDescriptorSetLayoutCreateInfo.Alloc();
                layoutInfo->bindings = bindings;
                {
                    VkDescriptorSetLayout layout;
                    vkCreateDescriptorSetLayout(device, layoutInfo, null, &layout);
                    this.setLayoutRadialBlur = layout;
                }
                {
                    var dsl = setLayoutRadialBlur;
                    var pPipelineLayoutCreateInfo = VkPipelineLayoutCreateInfo.Alloc();
                    pPipelineLayoutCreateInfo[0].setLayouts = dsl;
                    VkPipelineLayout pipelineLayout;
                    vkCreatePipelineLayout(device, pPipelineLayoutCreateInfo, null, &pipelineLayout);
                    this.pipelineLayoutRadialBlur = pipelineLayout;
                }
            }
        }