|
KiCad PCB EDA Suite
|
Owns the shaders, pipelines and bind group layouts for 2D GAL rendering. More...
#include <rhi_gal_pipelines.h>
Classes | |
| struct | ShaderPair |
Public Member Functions | |
| RHI_GAL_PIPELINES (RHI_DEVICE &aDevice) | |
| ~RHI_GAL_PIPELINES () | |
| RHI_GAL_PIPELINES (const RHI_GAL_PIPELINES &)=delete | |
| RHI_GAL_PIPELINES & | operator= (const RHI_GAL_PIPELINES &)=delete |
| bool | Initialize () |
| Create all shader modules and pipeline objects. | |
| void | Destroy () |
| Release all GPU resources. | |
| bool | IsInitialized () const |
| RHI_PipelineHandle | GetShapePipeline (KIGFX::RHI_SHAPE aShape, KIGFX::LAYER_DRAW_MODE aMode) const |
| The pipeline drawing a shape in a draw mode. | |
| RHI_PipelineHandle | GetWirePipeline () const |
| RHI_PipelineHandle | GetWireOncePipeline () const |
| RHI_PipelineHandle | GetGridPipeline () const |
| RHI_PipelineHandle | GetCursorCompositePipeline () const |
| The cursor drawn straight into the composite, whose target has no depth. | |
| RHI_PipelineHandle | GetCompositorPipeline () const |
| RHI_PipelineHandle | GetInlineCompositorPipeline () const |
| RHI_PipelineHandle | GetDifferencePipeline () const |
| Replaces a target's colour with its difference from a diff layer, see LAYER_RANGE::difference. | |
| RHI_BindGroupLayoutHandle | GetDifferenceLayout () const |
| RHI_PipelineHandle | GetBitmapPipeline () const |
| RHI_PipelineHandle | GetOverlayVariant (RHI_PipelineHandle aPipeline) const |
| The variant of a pipeline for content drawn into the overlay target. | |
| RHI_PipelineHandle | GetPremultipliedVariant (RHI_PipelineHandle aPipeline) const |
| The variant of a pipeline for a cached layer that the legacy canvas draws on its overlay. | |
| RHI_BindGroupLayoutHandle | GetGlyphLayout () const |
| The bind group layout of the font atlas and glyph table the track pipelines read at set 1. | |
| bool | UsesGlyphAtlas (RHI_PipelineHandle aPipeline) const |
| True for a pipeline that expects the glyph bind group at set 1. | |
| RHI_BindGroupLayoutHandle | GetFrameUBOLayout () const |
| RHI_BindGroupLayoutHandle | GetFullscreenUBOLayout () const |
| RHI_BindGroupLayoutHandle | GetTextureSamplerLayout () const |
Private Member Functions | |
| ShaderPair | loadShaderPair (const RHI_SHADER_BLOB &aVert, const RHI_SHADER_BLOB &aFrag) |
| RHI_PipelineHandle | createInstancedPipeline (const ShaderPair &aShaders, bool aNegativeBlend=false, bool aHasInstanceBinding=true, bool aSingleCoverage=false, bool aKnockoutMark=false, bool aSquareAlpha=false, bool aPremultiplied=false) |
Build a pipeline reading RHI_VERTEX from slot 0 and, with aHasInstanceBinding, RHI_INSTANCE from slot 1. | |
| RHI_PipelineHandle | createFullscreenPipeline (const ShaderPair &aShaders, bool aBlendEnabled, const std::vector< RHI_BIND_GROUP_LAYOUT_DESC > &aBindGroupLayouts={}, bool aPremultipliedAlpha=false, bool aRenderPassHasDepthStencil=false, bool aSquareAlpha=false) |
Static Private Attributes | |
| static constexpr int | DRAW_MODES = static_cast<int>( KIGFX::LAYER_DRAW_MODE::MARK ) + 1 |
Owns the shaders, pipelines and bind group layouts for 2D GAL rendering.
Instanced pipelines read RHI_VERTEX from slot 0 and RHI_INSTANCE from slot 1 and differ only in their shaders. Fullscreen pipelines such as the compositor read only slot 0.
Definition at line 39 of file rhi_gal_pipelines.h.
|
explicit |
Definition at line 34 of file rhi_gal_pipelines.cpp.
References m_device.
Referenced by operator=(), and RHI_GAL_PIPELINES().
| RHI_GAL_PIPELINES::~RHI_GAL_PIPELINES | ( | ) |
Definition at line 40 of file rhi_gal_pipelines.cpp.
References Destroy().
|
delete |
References RHI_GAL_PIPELINES().
|
private |
Definition at line 187 of file rhi_gal_pipelines.cpp.
References ADD, RHI_BLEND_STATE::alphaOp, RHI_PIPELINE_DESC::bindGroupLayouts, RHI_PIPELINE_DESC::blendStates, RHI_PIPELINE_DESC::colorFormat, RHI_BLEND_STATE::colorOp, RHI_PIPELINE_DESC::depthStencil, RHI_DEPTH_STENCIL_STATE::depthTestEnable, RHI_DEPTH_STENCIL_STATE::depthWriteEnable, RHI_BLEND_STATE::dstAlpha, RHI_BLEND_STATE::dstColor, RHI_PIPELINE_DESC::dynamicStates, RHI_BLEND_STATE::enabled, RHI_GAL_PIPELINES::ShaderPair::frag, RHI_PIPELINE_DESC::fragmentShader, m_device, ONE, ONE_MINUS_SRC_ALPHA, RHI_PIPELINE_DESC::renderPassHasDepthStencil, RGBA8, RhiStandardVertexLayout(), SCISSOR, SRC_ALPHA, RHI_BLEND_STATE::srcAlpha, RHI_BLEND_STATE::srcColor, RHI_PIPELINE_DESC::topology, TRIANGLE_LIST, RHI_GAL_PIPELINES::ShaderPair::vert, RHI_PIPELINE_DESC::vertexBuffers, RHI_PIPELINE_DESC::vertexShader, and VIEWPORT.
Referenced by Initialize().
|
private |
Build a pipeline reading RHI_VERTEX from slot 0 and, with aHasInstanceBinding, RHI_INSTANCE from slot 1.
The polygon shader reads only slot 0 and must be built without the instance binding, or validation flags every polygon draw for the unbound slot.
Definition at line 65 of file rhi_gal_pipelines.cpp.
References ADD, RHI_BLEND_STATE::alphaOp, RHI_PIPELINE_DESC::bindGroupLayouts, RHI_PIPELINE_DESC::blendStates, RHI_PIPELINE_DESC::colorFormat, RHI_BLEND_STATE::colorOp, RHI_DEPTH_STENCIL_STATE::depthCompareOp, RHI_PIPELINE_DESC::depthStencil, RHI_DEPTH_STENCIL_STATE::depthTestEnable, RHI_DEPTH_STENCIL_STATE::depthWriteEnable, RHI_BLEND_STATE::dstAlpha, RHI_BLEND_STATE::dstColor, RHI_PIPELINE_DESC::dynamicStates, RHI_BLEND_STATE::enabled, RHI_GAL_PIPELINES::ShaderPair::frag, RHI_PIPELINE_DESC::fragmentShader, LESS, LESS_EQUAL, m_device, m_frameUBOLayout, m_frameUBOLayoutDesc, m_glyphLayoutDesc, m_glyphPipelines, m_shaderPairs, ONE, ONE_MINUS_SRC_ALPHA, RHI_PIPELINE_DESC::renderPassHasDepthStencil, RGBA8, RhiInstanceLayout(), RhiStandardVertexLayout(), SCISSOR, SRC_ALPHA, RHI_BLEND_STATE::srcAlpha, RHI_BLEND_STATE::srcColor, RHI_PIPELINE_DESC::topology, TRIANGLE_LIST, RHI_GAL_PIPELINES::ShaderPair::vert, RHI_PIPELINE_DESC::vertexBuffers, RHI_PIPELINE_DESC::vertexShader, VIEWPORT, and ZERO.
Referenced by Initialize().
| void RHI_GAL_PIPELINES::Destroy | ( | ) |
Release all GPU resources.
Safe to call multiple times.
Definition at line 506 of file rhi_gal_pipelines.cpp.
References m_bitmapPipeline, m_compositorPipeline, m_cursorCompositePipeline, m_device, m_differenceLayout, m_differencePipeline, m_frameUBOLayout, m_fullscreenUBOLayout, m_glyphLayout, m_glyphPipelines, m_gridPipeline, m_initialized, m_inlineCompositorPipeline, m_overlayVariants, m_premultipliedVariants, m_shaderPairs, m_shapePipelines, m_textureSamplerLayout, m_wireOncePipeline, and m_wirePipeline.
Referenced by Initialize(), and ~RHI_GAL_PIPELINES().
|
inline |
Definition at line 90 of file rhi_gal_pipelines.h.
References m_bitmapPipeline.
|
inline |
Definition at line 79 of file rhi_gal_pipelines.h.
References m_compositorPipeline.
|
inline |
The cursor drawn straight into the composite, whose target has no depth.
Definition at line 78 of file rhi_gal_pipelines.h.
References m_cursorCompositePipeline.
|
inline |
Definition at line 88 of file rhi_gal_pipelines.h.
References m_differenceLayout.
|
inline |
Replaces a target's colour with its difference from a diff layer, see LAYER_RANGE::difference.
It takes GetDifferenceLayout() at set 0 with the layer at binding 0 and a copy of the target at binding 1, and does not blend.
Definition at line 87 of file rhi_gal_pipelines.h.
References m_differencePipeline.
|
inline |
Definition at line 120 of file rhi_gal_pipelines.h.
References m_frameUBOLayout.
|
inline |
Definition at line 121 of file rhi_gal_pipelines.h.
References m_fullscreenUBOLayout.
|
inline |
The bind group layout of the font atlas and glyph table the track pipelines read at set 1.
Definition at line 113 of file rhi_gal_pipelines.h.
References m_glyphLayout.
|
inline |
Definition at line 73 of file rhi_gal_pipelines.h.
References m_gridPipeline.
|
inline |
Definition at line 80 of file rhi_gal_pipelines.h.
References m_inlineCompositorPipeline.
| RHI_PipelineHandle RHI_GAL_PIPELINES::GetOverlayVariant | ( | RHI_PipelineHandle | aPipeline | ) | const |
The variant of a pipeline for content drawn into the overlay target.
The legacy canvas blends alpha by alpha on its transparent overlay, so an element of alpha a covers what is under the overlay by a*a. The variant blends alpha the same way. A pipeline whose alpha blending would not differ, such as a knockout or mark, is its own variant.
Definition at line 163 of file rhi_gal_pipelines.cpp.
References m_overlayVariants.
| RHI_PipelineHandle RHI_GAL_PIPELINES::GetPremultipliedVariant | ( | RHI_PipelineHandle | aPipeline | ) | const |
The variant of a pipeline for a cached layer that the legacy canvas draws on its overlay.
Its elements are flagged RHI_INSTANCE_OVERLAY_ALPHA and leave colour c*a with alpha a*a, which the variant adds over what is below to give c*a + d*(1 - a*a) as the legacy overlay does. A pipeline without such a variant is returned unchanged.
Definition at line 175 of file rhi_gal_pipelines.cpp.
References m_premultipliedVariants.
|
inline |
The pipeline drawing a shape in a draw mode.
ONCE fails the depth test for a second fragment at the layer's own depth so a pixel takes the layer once. MARK writes depth but no colour so what is later drawn behind it in the same layer stays open. Polygons have no MARK pipeline.
Definition at line 66 of file rhi_gal_pipelines.h.
References m_shapePipelines.
|
inline |
Definition at line 122 of file rhi_gal_pipelines.h.
References m_textureSamplerLayout.
|
inline |
Definition at line 72 of file rhi_gal_pipelines.h.
References m_wireOncePipeline.
|
inline |
Definition at line 71 of file rhi_gal_pipelines.h.
References m_wirePipeline.
| bool RHI_GAL_PIPELINES::Initialize | ( | ) |
Create all shader modules and pipeline objects.
Definition at line 236 of file rhi_gal_pipelines.cpp.
References ADD, ALL, RHI_BLEND_STATE::alphaOp, RHI_PIPELINE_DESC::bindGroupLayouts, RHI_PIPELINE_DESC::blendStates, RHI_PIPELINE_DESC::colorFormat, RHI_BLEND_STATE::colorOp, COMBINED_TEXTURE_SAMPLER, createFullscreenPipeline(), createInstancedPipeline(), RHI_DEPTH_STENCIL_STATE::depthCompareOp, RHI_PIPELINE_DESC::depthStencil, RHI_DEPTH_STENCIL_STATE::depthTestEnable, RHI_DEPTH_STENCIL_STATE::depthWriteEnable, Destroy(), DRAW_MODES, RHI_BLEND_STATE::dstAlpha, RHI_BLEND_STATE::dstColor, RHI_PIPELINE_DESC::dynamicStates, RHI_BLEND_STATE::enabled, RHI_BIND_GROUP_LAYOUT_DESC::entries, RHI_GAL_PIPELINES::ShaderPair::frag, FRAGMENT, RHI_PIPELINE_DESC::fragmentShader, RHI_BIND_GROUP_LAYOUT_DESC::frequency, LESS_EQUAL, loadShaderPair(), m_bitmapPipeline, m_compositorPipeline, m_cursorCompositePipeline, m_device, m_differenceLayout, m_differencePipeline, m_frameUBOLayout, m_frameUBOLayoutDesc, m_fullscreenUBOLayout, m_glyphLayout, m_glyphLayoutDesc, m_gridPipeline, m_initialized, m_inlineCompositorPipeline, m_overlayVariants, m_premultipliedVariants, m_shaderPairs, m_shapePipelines, m_textureSamplerLayout, m_wireOncePipeline, m_wirePipeline, KIGFX::MARK, NEGATIVE, ONE, ONE_MINUS_SRC_ALPHA, PER_FRAME, PER_PASS, RHI_PIPELINE_DESC::renderPassHasDepthStencil, RGBA8, RHI_GLYPH_TABLE_BINDING, KIGFX::RHI_SHAPE_POLYGON, KIGFX::RHI_SHAPES, RHI_UBO_BINDING, RhiStandardVertexLayout(), SCISSOR, SRC_ALPHA, RHI_BLEND_STATE::srcAlpha, RHI_BLEND_STATE::srcColor, RHI_PIPELINE_DESC::topology, TRIANGLE_LIST, UNIFORM_BUFFER, RHI_GAL_PIPELINES::ShaderPair::vert, VERTEX, RHI_PIPELINE_DESC::vertexBuffers, RHI_PIPELINE_DESC::vertexShader, and VIEWPORT.
|
inline |
Definition at line 59 of file rhi_gal_pipelines.h.
References m_initialized.
|
private |
Definition at line 46 of file rhi_gal_pipelines.cpp.
References RHI_SHADER_DESC::bytecode, FRAGMENT, m_device, RHI_SHADER_BLOB::msl, RHI_SHADER_DESC::sizeBytes, RHI_SHADER_DESC::type, VERTEX, and VULKAN.
Referenced by Initialize().
|
delete |
References RHI_GAL_PIPELINES().
| bool RHI_GAL_PIPELINES::UsesGlyphAtlas | ( | RHI_PipelineHandle | aPipeline | ) | const |
True for a pipeline that expects the glyph bind group at set 1.
Definition at line 157 of file rhi_gal_pipelines.cpp.
References m_glyphPipelines.
|
staticconstexprprivate |
Definition at line 166 of file rhi_gal_pipelines.h.
Referenced by Initialize().
|
private |
Definition at line 177 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetBitmapPipeline(), and Initialize().
|
private |
Definition at line 174 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetCompositorPipeline(), and Initialize().
|
private |
Definition at line 173 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetCursorCompositePipeline(), and Initialize().
|
private |
Definition at line 152 of file rhi_gal_pipelines.h.
Referenced by createFullscreenPipeline(), createInstancedPipeline(), Destroy(), Initialize(), loadShaderPair(), and RHI_GAL_PIPELINES().
|
private |
Definition at line 164 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetDifferenceLayout(), and Initialize().
|
private |
Definition at line 176 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetDifferencePipeline(), and Initialize().
|
private |
Definition at line 155 of file rhi_gal_pipelines.h.
Referenced by createInstancedPipeline(), Destroy(), GetFrameUBOLayout(), and Initialize().
|
private |
Definition at line 156 of file rhi_gal_pipelines.h.
Referenced by createInstancedPipeline(), and Initialize().
|
private |
Definition at line 162 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetFullscreenUBOLayout(), and Initialize().
|
private |
Definition at line 158 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetGlyphLayout(), and Initialize().
|
private |
Definition at line 159 of file rhi_gal_pipelines.h.
Referenced by createInstancedPipeline(), and Initialize().
|
private |
Definition at line 160 of file rhi_gal_pipelines.h.
Referenced by createInstancedPipeline(), Destroy(), and UsesGlyphAtlas().
|
private |
Definition at line 172 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetGridPipeline(), and Initialize().
|
private |
Definition at line 153 of file rhi_gal_pipelines.h.
Referenced by Destroy(), Initialize(), and IsInitialized().
|
private |
Definition at line 175 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetInlineCompositorPipeline(), and Initialize().
|
private |
Each pipeline that has an overlay variant, paired with it.
Definition at line 187 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetOverlayVariant(), and Initialize().
|
private |
Definition at line 188 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetPremultipliedVariant(), and Initialize().
|
private |
Shader modules kept alive for the lifetime of the pipelines.
Definition at line 182 of file rhi_gal_pipelines.h.
Referenced by createInstancedPipeline(), Destroy(), and Initialize().
|
private |
Definition at line 168 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetShapePipeline(), and Initialize().
|
private |
Definition at line 163 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetTextureSamplerLayout(), and Initialize().
|
private |
Definition at line 171 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetWireOncePipeline(), and Initialize().
|
private |
Definition at line 170 of file rhi_gal_pipelines.h.
Referenced by Destroy(), GetWirePipeline(), and Initialize().