void setupDescriptorSetLayout()
        {
            FixedArray2<VkDescriptorSetLayoutBinding> setLayoutBindings = new FixedArray2<VkDescriptorSetLayoutBinding>(
                // Binding 0 : Vertex shader uniform buffer
                Initializers.descriptorSetLayoutBinding(
                    VkDescriptorType.UniformBuffer,
                    VkShaderStageFlags.Vertex,
                    0),
                // Binding 1 : Fragment shader image sampler
                Initializers.descriptorSetLayoutBinding(
                    VkDescriptorType.CombinedImageSampler,
                    VkShaderStageFlags.Fragment,
                    1));

            VkDescriptorSetLayoutCreateInfo descriptorLayout =
                Initializers.descriptorSetLayoutCreateInfo(
                    &setLayoutBindings.First,
                    setLayoutBindings.Count);

            Util.CheckResult(vkCreateDescriptorSetLayout(device, &descriptorLayout, null, out descriptorSetLayout));

            var dsl = descriptorSetLayout;
            VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo =
                Initializers.pipelineLayoutCreateInfo(
                    &dsl,
                    1);

            Util.CheckResult(vkCreatePipelineLayout(device, &pPipelineLayoutCreateInfo, null, out pipelineLayout));
        }
Exemple #2
0
        void setupDescriptorSetLayout()
        {
            NativeList <VkDescriptorSetLayoutBinding> setLayoutBindings;
            VkDescriptorSetLayoutCreateInfo           descriptorLayout;
            VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo;

            // Scene rendering
            setLayoutBindings = new NativeList <VkDescriptorSetLayoutBinding>
            {
                // Binding 0: Vertex shader uniform buffer
                Initializers.descriptorSetLayoutBinding(
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    VK_SHADER_STAGE_VERTEX_BIT,
                    0),
                // Binding 1: Fragment shader image sampler
                Initializers.descriptorSetLayoutBinding(
                    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                    VK_SHADER_STAGE_FRAGMENT_BIT,
                    1),
                // Binding 2: Fragment shader uniform buffer
                Initializers.descriptorSetLayoutBinding(
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    VK_SHADER_STAGE_FRAGMENT_BIT,
                    2)
            };

            descriptorLayout = Initializers.descriptorSetLayoutCreateInfo((VkDescriptorSetLayoutBinding *)setLayoutBindings.Data, setLayoutBindings.Count);
            Util.CheckResult(vkCreateDescriptorSetLayout(device, &descriptorLayout, null, out descriptorSetLayouts_scene));
            var dsl = descriptorSetLayouts_scene;

            pPipelineLayoutCreateInfo = Initializers.pipelineLayoutCreateInfo(&dsl, 1);
            Util.CheckResult(vkCreatePipelineLayout(device, &pPipelineLayoutCreateInfo, null, out pipelineLayouts_scene));

            // Fullscreen radial blur
            setLayoutBindings = new NativeList <VkDescriptorSetLayoutBinding>
            {
                // Binding 0 : Vertex shader uniform buffer
                Initializers.descriptorSetLayoutBinding(
                    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                    VK_SHADER_STAGE_FRAGMENT_BIT,
                    0),
                // Binding 0: Fragment shader image sampler
                Initializers.descriptorSetLayoutBinding(
                    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                    VK_SHADER_STAGE_FRAGMENT_BIT,
                    1)
            };
            descriptorLayout = Initializers.descriptorSetLayoutCreateInfo((VkDescriptorSetLayoutBinding *)setLayoutBindings.Data, setLayoutBindings.Count);
            Util.CheckResult(vkCreateDescriptorSetLayout(device, &descriptorLayout, null, out descriptorSetLayouts_radialBlur));
            dsl = descriptorSetLayouts_radialBlur;
            pPipelineLayoutCreateInfo = Initializers.pipelineLayoutCreateInfo(&dsl, 1);
            Util.CheckResult(vkCreatePipelineLayout(device, &pPipelineLayoutCreateInfo, null, out pipelineLayouts_radialBlur));
        }
Exemple #3
0
        void setupDescriptorSetLayout()
        {
            VkDescriptorSetLayoutBinding setLayoutBindings =
                // Binding 0 : Vertex shader uniform buffer
                Initializers.descriptorSetLayoutBinding(
                    VkDescriptorType.UniformBuffer,
                    VkShaderStageFlags.Vertex,
                    0);

            VkDescriptorSetLayoutCreateInfo descriptorLayout =
                Initializers.descriptorSetLayoutCreateInfo(
                    &setLayoutBindings,
                    1);

            Util.CheckResult(vkCreateDescriptorSetLayout(device, &descriptorLayout, null, out descriptorSetLayout));

            var dsl = descriptorSetLayout;
            VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo =
                Initializers.pipelineLayoutCreateInfo(
                    &dsl,
                    1);

            // Define push constant
            // Example uses six light positions as push constants
            // 6 * 4 * 4 = 96 bytes
            // Spec requires a minimum of 128 bytes, bigger values
            // need to be checked against maxPushConstantsSize
            // But even at only 128 bytes, lots of stuff can fit
            // inside push constants
            VkPushConstantRange pushConstantRange =
                Initializers.pushConstantRange(
                    VkShaderStageFlags.Vertex,
                    pushConstants.Count * (uint)sizeof(Vector4),
                    0);

            // Push constant ranges are part of the pipeline layout
            pipelineLayoutCreateInfo.pushConstantRangeCount = 1;
            pipelineLayoutCreateInfo.pPushConstantRanges    = &pushConstantRange;

            Util.CheckResult(vkCreatePipelineLayout(device, &pipelineLayoutCreateInfo, null, out pipelineLayout));
        }
        void setupDescriptorSetLayout()
        {
            FixedArray2 <VkDescriptorSetLayoutBinding> setLayoutBindings = new FixedArray2 <VkDescriptorSetLayoutBinding>(
                Initializers.descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT, 0),
                Initializers.descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 1));

            VkDescriptorSetLayoutCreateInfo descriptorLayout =
                Initializers.descriptorSetLayoutCreateInfo(
                    &setLayoutBindings.First,
                    setLayoutBindings.Count);

            Util.CheckResult(vkCreateDescriptorSetLayout(device, &descriptorLayout, null, out descriptorSetLayout));

            var dsl = descriptorSetLayout;
            VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo =
                Initializers.pipelineLayoutCreateInfo(
                    &dsl,
                    1);

            Util.CheckResult(vkCreatePipelineLayout(device, &pPipelineLayoutCreateInfo, null, out pipelineLayout));
        }
Exemple #5
0
        void setupDescriptorSetLayout()
        {
            NativeList<VkDescriptorSetLayoutBinding> setLayoutBindings = new NativeList<VkDescriptorSetLayoutBinding>();
            VkDescriptorSetLayoutCreateInfo descriptorLayoutInfo;
            VkPipelineLayoutCreateInfo pipelineLayoutInfo;

            // Binding 0 : Vertex shader uniform buffer
            setLayoutBindings.Add(Initializers.descriptorSetLayoutBinding(
                VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
                VK_SHADER_STAGE_VERTEX_BIT,
                0));
            // Binding 1 : Fragment shader image sampler
            setLayoutBindings.Add(Initializers.descriptorSetLayoutBinding(
                VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                VK_SHADER_STAGE_FRAGMENT_BIT,
                1));
            // Binding 2 : Fragment shader image sampler
            setLayoutBindings.Add(Initializers.descriptorSetLayoutBinding(
                VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
                VK_SHADER_STAGE_FRAGMENT_BIT,
                2));

            // Shaded layouts (only use first layout binding)
            descriptorLayoutInfo = Initializers.descriptorSetLayoutCreateInfo((VkDescriptorSetLayoutBinding*)setLayoutBindings.Data, 1);
            Util.CheckResult(vkCreateDescriptorSetLayout(device, &descriptorLayoutInfo, null, out descriptorSetLayouts_shaded));

            var dsl = descriptorSetLayouts_shaded;
            pipelineLayoutInfo = Initializers.pipelineLayoutCreateInfo(&dsl, 1);

            Util.CheckResult(vkCreatePipelineLayout(device, &pipelineLayoutInfo, null, out pipelineLayouts_shaded));

            // Textured layouts (use all layout bindings)
            descriptorLayoutInfo = Initializers.descriptorSetLayoutCreateInfo((VkDescriptorSetLayoutBinding*)setLayoutBindings.Data, (uint)(setLayoutBindings.Count));
            Util.CheckResult(vkCreateDescriptorSetLayout(device, &descriptorLayoutInfo, null, out descriptorSetLayouts_textured));

            dsl = descriptorSetLayouts_textured;
            pipelineLayoutInfo = Initializers.pipelineLayoutCreateInfo(&dsl, 1);
            Util.CheckResult(vkCreatePipelineLayout(device, &pipelineLayoutInfo, null, out pipelineLayouts_textured));
        }