コード例 #1
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));
        }