MoonWorks-docs/content/Graphics/Resources/GraphicsPipeline/GraphicsPipeline.md

1.5 KiB

title date weight
Graphics Pipeline 2021-01-28T13:30:11-08:00 10

Finally, we have everything we need to build the graphics pipeline. We just need to pass our various structures into a GraphicsPipelineCreateInfo object.

var myGraphicsPipelineCreateInfo = new GraphicsPipelineCreateInfo
{
    ColorBlendState = myColorBlendState,
    DepthStencilState = myDepthStencilState,
    VertexShaderState = myVertexShaderState,
    FragmentShaderState = myFragmentShaderState,
    MultisampleState = myMultisampleState,
    PipelineLayoutInfo = myPipelineLayoutInfo,
    RasterizerState = myRasterizerState,
    PrimitiveType = PrimitiveType.TriangleList,
    VertexInputState = myVertexInputState,
    ViewportState = myViewportState,
    RenderPass = myRenderPass
};

var myGraphicsPipeline = new GraphicsPipeline(
    GraphicsDevice,
    myGraphicsPipelineCreateInfo
);

Finally! That's it! You might have noticed that a lot of this structure can be reused across pipelines. I strongly recommend creating individual container objects for the various states your renderer uses so you don't have to repeat yourself a whole bunch.

Graphics pipelines are unique from our other resources so far because they have two methods that are used to push uniforms. These methods return offset values that are used with draw commands.

var vertUniformOffset = myGraphicsPipeline.PushVertexShaderUniforms(myVertUniforms);
var fragUniformOffset = myGraphicsPipeline.PushFragmentShaderUniforms(myFragUniforms);