public override void Bind(Device device, RenderPass renderPass, CommandBuffer commandBuffer, Extent2D targetExtent) { this.aspectRatio = (float)targetExtent.Width / (float)targetExtent.Height; this.projectionMatrix = mat4.Translate(0, -1, 0) * mat4.Scale(256f / targetExtent.Width, 256f / targetExtent.Height, 1); this.renderStateBuffer.Update(new RenderState { Projection = mat4.Identity, View = mat4.Identity }); this.pipeline = device.CreateGraphicsPipeline(null, new[] { new PipelineShaderStageCreateInfo { Stage = ShaderStageFlags.Vertex, Module = this.vertexShader, Name = "main" }, new PipelineShaderStageCreateInfo { Stage = ShaderStageFlags.Fragment, Module = this.fragmentShader, Name = "main" } }, new PipelineVertexInputStateCreateInfo() { VertexBindingDescriptions = new[] { Vertex.GetBindingDescription(), SpriteData.GetBindingDescription() }, VertexAttributeDescriptions = Vertex.GetAttributeDescriptions().Concat(SpriteData.GetAttributeDescriptions()).ToArray() }, new PipelineInputAssemblyStateCreateInfo { Topology = PrimitiveTopology.TriangleList }, new PipelineRasterizationStateCreateInfo { PolygonMode = PolygonMode.Fill, LineWidth = 1, CullMode = CullModeFlags.Back, FrontFace = FrontFace.CounterClockwise }, this.pipelineLayout, renderPass, 0, null, 0, viewportState: new PipelineViewportStateCreateInfo { Viewports = new[] { new Viewport { X = 0f, Y = 0f, Width = targetExtent.Width, Height = targetExtent.Height, MaxDepth = 1, MinDepth = 0 } }, Scissors = new[] { new Rect2D(targetExtent) } }, multisampleState: new PipelineMultisampleStateCreateInfo { SampleShadingEnable = false, RasterizationSamples = SampleCountFlags.SampleCount1, MinSampleShading = 1 }, depthStencilState: new PipelineDepthStencilStateCreateInfo { DepthTestEnable = false, DepthWriteEnable = true, DepthCompareOp = CompareOp.Less, MinDepthBounds = 0, MaxDepthBounds = 1 }, colorBlendState: new PipelineColorBlendStateCreateInfo { Attachments = new[] { new PipelineColorBlendAttachmentState { ColorWriteMask = ColorComponentFlags.R | ColorComponentFlags.G | ColorComponentFlags.B | ColorComponentFlags.A, BlendEnable = true, SourceColorBlendFactor = BlendFactor.SourceAlpha, DestinationColorBlendFactor = BlendFactor.OneMinusSourceAlpha, ColorBlendOp = BlendOp.Add, SourceAlphaBlendFactor = BlendFactor.One, DestinationAlphaBlendFactor = BlendFactor.One, AlphaBlendOp = BlendOp.Max } }, BlendConstants = new float[] { 0, 0, 0, 0 } }); commandBuffer.BindPipeline(PipelineBindPoint.Graphics, this.pipeline); commandBuffer.BindVertexBuffers(0, new[] { this.vertexBuffer.Buffer, this.spriteDataBuffer.Buffer }, new DeviceSize[] { 0, 0 }); commandBuffer.BindIndexBuffer(this.indexBuffer.Buffer, 0, IndexType.Uint32); commandBuffer.BindDescriptorSets(PipelineBindPoint.Graphics, pipelineLayout, 0, this.descriptorSet, null); commandBuffer.DrawIndexedIndirect(this.indirectCommandBuffer.Buffer, 0, 1, 0); }