![]() |
Vireo
0.0
Vireo 3D Rendering Hardware Interface
|
The graphics pipeline is the sequence of operations that take the vertices and textures of your meshes all the way to the pixels in the render targets.
The different stages of the pipeline operations are roughly the same in Vulkan and DirectX but sometime with different names :
Creation of a graphic pipeline involve a lot of parameters. Most notable parameters are the format of the attachment (an attachment or render target is an image where the shaders will write), the color blending for each attachment, the format of the vertices, and the shaders.
The GraphicPipelineConfiguration structure is used to specify all the creation parameter.
resources
: the resources for the shaders created with vireo::Vireo::createPipelineResourcesvertexInputLayout
: description of the format of a vertex created with created with vireo::Vireo::createVertexLayout from a vireo::VertexAttributeDesc descriptionFor vireo::Vireo::createVertexLayout each field of the vertex data structure must be described with the following parameters :
binding
: Binding name which this attribute takes its data from for the HLSL style binding. For the Vulkan style the binding number will be calculated from the index of the field.format
: Type for dataoffset
: Byte offset of this attribute relative to the start of an element in the data structure.For example, if the vertex structure is, for each vertex :
The input layout description will be the following array :
and the corresponding structure in the shader in the Slang shader language (must be in the same order) :
vertexShader
, fragmentShader
: the shader modules. Must have at least a vertex shader.colorRenderFormats
: an array of vireo::ImageFormat for each color attachmentcolorBlendDesc
: an array (with the same number of entries as colorRenderFormats
) of vireo::ColorBlendDesc for each color attachmentlogicOpEnable
: controls whether to apply Logical Operations.logicOp
: which logical operation to apply.For each value of colorBlendDesc
:
blendEnable
: Controls whether blending is enabled for the corresponding color attachment. If blending is not enabled, the source fragment’s color for that attachment is passed through unmodified.srcColorBlendFactor
: Selects which blend factor is used to determine the source factors (Sr,Sg,Sb).dstColorBlendFactor
: Selects which blend factor is used to determine the destination factors (Dr,Dg,Db).colorBlendOp
: Selects which blend operation is used to calculate the RGB values to write to the color attachment.srcAlphaBlendFactor
: Selects which blend factor is used to determine the source factor Sa.dstAlphaBlendFactor
: Selects which blend factor is used to determine the destination factor Da.alphaBlendOp
: Selects which blend operation is used to calculate the alpha values to write to the color attachment.colorWriteMask
: Is a bitmask specifying which of the R, G, B, and/or A components are enabled for writingmsaa
: the number of samples used in rasterizationalphaToCoverageEnable
: Controls whether a temporary coverage value is generated based on the alpha component of the fragment’s first color outputprimitiveTopology
: the primitive topologycullMode
: the triangle facing direction used for primitive cullingpolygonMode
: the the triangle rendering modefrontFaceCounterClockwise
: true
if a triangle with positive area is considered front-facing.depthStencilImageFormat
: format of the depth and stencil attachmentdepthTestEnable
: controls whether depth testing is enabled.depthWriteEnable
: controls whether depth writes are enabled .depthCompareOp
: the comparison operator to usedepthBiasEnable
: Controls whether to bias fragment depth values.depthBiasConstantFactor
: A scalar factor controlling the constant depth value added to each fragment.depthBiasClamp
: The maximum (or minimum) depth bias of a fragment.depthBiasSlopeFactor
: A scalar factor applied to a fragment’s slope in depth bias calculations.stencilTestEnable
: Controls whether stencil testing is enabledfrontStencilOpState
: value controlling the corresponding parameters of the stencil test.backStencilOpState
: value controlling the corresponding parameters of the stencil test.The stencil reference value is set in the render pass with vireo::CommandList::setStencilReference.
After populating the GraphicPipelineConfiguration structure the pipeline creation with vireo::Vireo::createGraphicPipeline is straightforward :
Since the GraphicPipelineConfiguration structure is only used at creation time, you can use it for multiple pipelines creation :
To execute the shaders, bind the compute pipeline with vireo::CommandList::bindPipeline and its descriptor sets with vireo::CommandList::bindDescriptors, then issue draw calls with vireo::CommandList::draw or vireo::CommandList::drawIndexed :
If you need to select specific data in the descriptor set you can use dynamic uniform buffer descriptor set :
Or push constants :