KiCad PCB EDA Suite
Loading...
Searching...
No Matches
RHI_GAL_PIPELINES Class Reference

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)
 

Private Attributes

RHI_DEVICE & m_device
 
bool m_initialized = false
 
RHI_BindGroupLayoutHandle m_frameUBOLayout
 
RHI_BIND_GROUP_LAYOUT_DESC m_frameUBOLayoutDesc
 
RHI_BindGroupLayoutHandle m_glyphLayout
 
RHI_BIND_GROUP_LAYOUT_DESC m_glyphLayoutDesc
 
std::vector< RHI_PipelineHandle > m_glyphPipelines
 
RHI_BindGroupLayoutHandle m_fullscreenUBOLayout
 
RHI_BindGroupLayoutHandle m_textureSamplerLayout
 
RHI_BindGroupLayoutHandle m_differenceLayout
 
std::array< std::array< RHI_PipelineHandle, DRAW_MODES >, KIGFX::RHI_SHAPES > m_shapePipelines
 
RHI_PipelineHandle m_wirePipeline
 
RHI_PipelineHandle m_wireOncePipeline
 
RHI_PipelineHandle m_gridPipeline
 
RHI_PipelineHandle m_cursorCompositePipeline
 
RHI_PipelineHandle m_compositorPipeline
 
RHI_PipelineHandle m_inlineCompositorPipeline
 
RHI_PipelineHandle m_differencePipeline
 
RHI_PipelineHandle m_bitmapPipeline
 
std::vector< ShaderPair > m_shaderPairs
 Shader modules kept alive for the lifetime of the pipelines.
 
std::vector< std::pair< RHI_PipelineHandle, RHI_PipelineHandle > > m_overlayVariants
 Each pipeline that has an overlay variant, paired with it.
 
std::vector< std::pair< RHI_PipelineHandle, RHI_PipelineHandle > > m_premultipliedVariants
 

Static Private Attributes

static constexpr int DRAW_MODES = static_cast<int>( KIGFX::LAYER_DRAW_MODE::MARK ) + 1
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ RHI_GAL_PIPELINES() [1/2]

RHI_GAL_PIPELINES::RHI_GAL_PIPELINES ( RHI_DEVICE & aDevice)
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::~RHI_GAL_PIPELINES ( )

Definition at line 40 of file rhi_gal_pipelines.cpp.

References Destroy().

◆ RHI_GAL_PIPELINES() [2/2]

RHI_GAL_PIPELINES::RHI_GAL_PIPELINES ( const RHI_GAL_PIPELINES & )
delete

References RHI_GAL_PIPELINES().

Member Function Documentation

◆ createFullscreenPipeline()

◆ createInstancedPipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::createInstancedPipeline ( const ShaderPair & aShaders,
bool aNegativeBlend = false,
bool aHasInstanceBinding = true,
bool aSingleCoverage = false,
bool aKnockoutMark = false,
bool aSquareAlpha = false,
bool aPremultiplied = false )
private

◆ Destroy()

◆ GetBitmapPipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetBitmapPipeline ( ) const
inline

Definition at line 90 of file rhi_gal_pipelines.h.

References m_bitmapPipeline.

◆ GetCompositorPipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetCompositorPipeline ( ) const
inline

Definition at line 79 of file rhi_gal_pipelines.h.

References m_compositorPipeline.

◆ GetCursorCompositePipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetCursorCompositePipeline ( ) const
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.

◆ GetDifferenceLayout()

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::GetDifferenceLayout ( ) const
inline

Definition at line 88 of file rhi_gal_pipelines.h.

References m_differenceLayout.

◆ GetDifferencePipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetDifferencePipeline ( ) const
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.

◆ GetFrameUBOLayout()

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::GetFrameUBOLayout ( ) const
inline

Definition at line 120 of file rhi_gal_pipelines.h.

References m_frameUBOLayout.

◆ GetFullscreenUBOLayout()

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::GetFullscreenUBOLayout ( ) const
inline

Definition at line 121 of file rhi_gal_pipelines.h.

References m_fullscreenUBOLayout.

◆ GetGlyphLayout()

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::GetGlyphLayout ( ) const
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.

◆ GetGridPipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetGridPipeline ( ) const
inline

Definition at line 73 of file rhi_gal_pipelines.h.

References m_gridPipeline.

◆ GetInlineCompositorPipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetInlineCompositorPipeline ( ) const
inline

Definition at line 80 of file rhi_gal_pipelines.h.

References m_inlineCompositorPipeline.

◆ GetOverlayVariant()

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.

◆ GetPremultipliedVariant()

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.

◆ GetShapePipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetShapePipeline ( KIGFX::RHI_SHAPE aShape,
KIGFX::LAYER_DRAW_MODE aMode ) const
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.

◆ GetTextureSamplerLayout()

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::GetTextureSamplerLayout ( ) const
inline

Definition at line 122 of file rhi_gal_pipelines.h.

References m_textureSamplerLayout.

◆ GetWireOncePipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetWireOncePipeline ( ) const
inline

Definition at line 72 of file rhi_gal_pipelines.h.

References m_wireOncePipeline.

◆ GetWirePipeline()

RHI_PipelineHandle RHI_GAL_PIPELINES::GetWirePipeline ( ) const
inline

Definition at line 71 of file rhi_gal_pipelines.h.

References m_wirePipeline.

◆ Initialize()

bool RHI_GAL_PIPELINES::Initialize ( )

Create all shader modules and pipeline objects.

Returns
true if all pipelines were created successfully.

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.

◆ IsInitialized()

bool RHI_GAL_PIPELINES::IsInitialized ( ) const
inline

Definition at line 59 of file rhi_gal_pipelines.h.

References m_initialized.

◆ loadShaderPair()

RHI_GAL_PIPELINES::ShaderPair RHI_GAL_PIPELINES::loadShaderPair ( const RHI_SHADER_BLOB & aVert,
const RHI_SHADER_BLOB & aFrag )
private

◆ operator=()

RHI_GAL_PIPELINES & RHI_GAL_PIPELINES::operator= ( const RHI_GAL_PIPELINES & )
delete

References RHI_GAL_PIPELINES().

◆ UsesGlyphAtlas()

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.

Member Data Documentation

◆ DRAW_MODES

int RHI_GAL_PIPELINES::DRAW_MODES = static_cast<int>( KIGFX::LAYER_DRAW_MODE::MARK ) + 1
staticconstexprprivate

Definition at line 166 of file rhi_gal_pipelines.h.

Referenced by Initialize().

◆ m_bitmapPipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_bitmapPipeline
private

Definition at line 177 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetBitmapPipeline(), and Initialize().

◆ m_compositorPipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_compositorPipeline
private

Definition at line 174 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetCompositorPipeline(), and Initialize().

◆ m_cursorCompositePipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_cursorCompositePipeline
private

Definition at line 173 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetCursorCompositePipeline(), and Initialize().

◆ m_device

RHI_DEVICE& RHI_GAL_PIPELINES::m_device
private

◆ m_differenceLayout

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::m_differenceLayout
private

Definition at line 164 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetDifferenceLayout(), and Initialize().

◆ m_differencePipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_differencePipeline
private

Definition at line 176 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetDifferencePipeline(), and Initialize().

◆ m_frameUBOLayout

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::m_frameUBOLayout
private

◆ m_frameUBOLayoutDesc

RHI_BIND_GROUP_LAYOUT_DESC RHI_GAL_PIPELINES::m_frameUBOLayoutDesc
private

Definition at line 156 of file rhi_gal_pipelines.h.

Referenced by createInstancedPipeline(), and Initialize().

◆ m_fullscreenUBOLayout

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::m_fullscreenUBOLayout
private

Definition at line 162 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetFullscreenUBOLayout(), and Initialize().

◆ m_glyphLayout

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::m_glyphLayout
private

Definition at line 158 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetGlyphLayout(), and Initialize().

◆ m_glyphLayoutDesc

RHI_BIND_GROUP_LAYOUT_DESC RHI_GAL_PIPELINES::m_glyphLayoutDesc
private

Definition at line 159 of file rhi_gal_pipelines.h.

Referenced by createInstancedPipeline(), and Initialize().

◆ m_glyphPipelines

std::vector<RHI_PipelineHandle> RHI_GAL_PIPELINES::m_glyphPipelines
private

Definition at line 160 of file rhi_gal_pipelines.h.

Referenced by createInstancedPipeline(), Destroy(), and UsesGlyphAtlas().

◆ m_gridPipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_gridPipeline
private

Definition at line 172 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetGridPipeline(), and Initialize().

◆ m_initialized

bool RHI_GAL_PIPELINES::m_initialized = false
private

Definition at line 153 of file rhi_gal_pipelines.h.

Referenced by Destroy(), Initialize(), and IsInitialized().

◆ m_inlineCompositorPipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_inlineCompositorPipeline
private

Definition at line 175 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetInlineCompositorPipeline(), and Initialize().

◆ m_overlayVariants

std::vector<std::pair<RHI_PipelineHandle, RHI_PipelineHandle> > RHI_GAL_PIPELINES::m_overlayVariants
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().

◆ m_premultipliedVariants

std::vector<std::pair<RHI_PipelineHandle, RHI_PipelineHandle> > RHI_GAL_PIPELINES::m_premultipliedVariants
private

Definition at line 188 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetPremultipliedVariant(), and Initialize().

◆ m_shaderPairs

std::vector<ShaderPair> RHI_GAL_PIPELINES::m_shaderPairs
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().

◆ m_shapePipelines

std::array<std::array<RHI_PipelineHandle, DRAW_MODES>, KIGFX::RHI_SHAPES> RHI_GAL_PIPELINES::m_shapePipelines
private

Definition at line 168 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetShapePipeline(), and Initialize().

◆ m_textureSamplerLayout

RHI_BindGroupLayoutHandle RHI_GAL_PIPELINES::m_textureSamplerLayout
private

Definition at line 163 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetTextureSamplerLayout(), and Initialize().

◆ m_wireOncePipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_wireOncePipeline
private

Definition at line 171 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetWireOncePipeline(), and Initialize().

◆ m_wirePipeline

RHI_PipelineHandle RHI_GAL_PIPELINES::m_wirePipeline
private

Definition at line 170 of file rhi_gal_pipelines.h.

Referenced by Destroy(), GetWirePipeline(), and Initialize().


The documentation for this class was generated from the following files: