示例#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);
        }
示例#2
0
 internal Material(GraphicsDevice device, UniformBuffer uniformBuffer, ShaderPair shaders, Texture2D mainTexture = null)
 {
     this.device        = device;
     this.uniformBuffer = uniformBuffer;
     this.shaderPair    = shaders;
     this.mainColor     = Color.white;
     this.mainTexture   = mainTexture ?? Texture2D.White;
 }
示例#3
0
        public Pipeline CreatePipeline(GraphicsDevice device, RenderPass renderPass, Material material, UniformBuffer uniformBuffer)
        {
            Pipeline pipeline = new Pipeline(device);

            if (material.shaderPair.shaderType == ShaderType.Normal)
            {
                SetupNormalVertexDescriptions();
                pipeline.instanced = false;
            }
            else
            {
                SetupInstancedVertexDescriptions();
                pipeline.instanced = true;
            }

            SetupDescriptorSetLayout(pipeline, device);
            PreparePipelines(pipeline, device, renderPass, material);
            SetupDescriptorPool(pipeline, device);
            if (material.mainTexture != null)
            {
                SetupDescriptorSet(pipeline, device, uniformBuffer, material.mainTexture);
            }
            return(pipeline);
        }