コード例 #1
0
        void SetupDescriptorSet(Pipeline pipeline, GraphicsDevice device, UniformBuffer uniformBuffer, Texture2D texture_colorMap)
        {
            var dsl = pipeline.descriptorSetLayout;
            VkDescriptorSetAllocateInfo allocInfo =
                Initializers.descriptorSetAllocateInfo(
                    pipeline.descriptorPool,
                    &dsl,
                    1);

            Util.CheckResult(vkAllocateDescriptorSets(device.device, &allocInfo, out pipeline.descriptorSet));

            VkDescriptorImageInfo texDescriptor =
                Initializers.descriptorImageInfo(
                    texture_colorMap.sampler,
                    texture_colorMap.view,
                    VkImageLayout.General);

            VkDescriptorBufferInfo temp = uniformBuffer.GetVkDescriptor();

            FixedArray2 <VkWriteDescriptorSet> writeDescriptorSets = new FixedArray2 <VkWriteDescriptorSet>(
                // Binding 0 : Vertex shader uniform buffer
                Initializers.writeDescriptorSet(
                    pipeline.descriptorSet,
                    VkDescriptorType.UniformBuffer,
                    uniformBuffer.location,
                    &temp),
                // Binding 1 : Color map
                Initializers.writeDescriptorSet(
                    pipeline.descriptorSet,
                    VkDescriptorType.CombinedImageSampler,
                    1,
                    &texDescriptor));

            vkUpdateDescriptorSets(device.device, (writeDescriptorSets.Count), ref writeDescriptorSets.First, 0, null);
        }