KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rhi_gal_pipelines.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef RHI_GAL_PIPELINES_H
21#define RHI_GAL_PIPELINES_H
22
23#include <rhi/rhi_handle.h>
24#include <rhi/rhi_bind_group.h>
25#include <rhi/layer_draw_plan.h>
26
27#include <array>
28
29class RHI_DEVICE;
30struct RHI_SHADER_BLOB;
31
32
40{
41public:
42 explicit RHI_GAL_PIPELINES( RHI_DEVICE& aDevice );
44
47
52 bool Initialize();
53
57 void Destroy();
58
59 bool IsInitialized() const { return m_initialized; }
60
67 {
68 return m_shapePipelines[aShape][static_cast<int>( aMode )];
69 }
70
74
81
89
91
100
109
114
118 bool UsesGlyphAtlas( RHI_PipelineHandle aPipeline ) const;
119
123
124private:
130
131 ShaderPair loadShaderPair( const RHI_SHADER_BLOB& aVert, const RHI_SHADER_BLOB& aFrag );
132
139 bool aNegativeBlend = false,
140 bool aHasInstanceBinding = true,
141 bool aSingleCoverage = false,
142 bool aKnockoutMark = false,
143 bool aSquareAlpha = false,
144 bool aPremultiplied = false );
146 const ShaderPair& aShaders, bool aBlendEnabled,
147 const std::vector<RHI_BIND_GROUP_LAYOUT_DESC>& aBindGroupLayouts = {},
148 bool aPremultipliedAlpha = false,
149 bool aRenderPassHasDepthStencil = false,
150 bool aSquareAlpha = false );
151
153 bool m_initialized = false;
154
157
160 std::vector<RHI_PipelineHandle> m_glyphPipelines;
161
165
166 static constexpr int DRAW_MODES = static_cast<int>( KIGFX::LAYER_DRAW_MODE::MARK ) + 1;
167
168 std::array<std::array<RHI_PipelineHandle, DRAW_MODES>, KIGFX::RHI_SHAPES> m_shapePipelines;
169
178
182 std::vector<ShaderPair> m_shaderPairs;
183
187 std::vector<std::pair<RHI_PipelineHandle, RHI_PipelineHandle>> m_overlayVariants;
188 std::vector<std::pair<RHI_PipelineHandle, RHI_PipelineHandle>> m_premultipliedVariants;
189};
190
191
192#endif // RHI_GAL_PIPELINES_H
Creates, uses and destroys GPU resources through one graphics API backend.
Definition rhi_device.h:66
RHI_BindGroupLayoutHandle m_differenceLayout
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_BindGroupLayoutHandle GetFullscreenUBOLayout() const
bool Initialize()
Create all shader modules and pipeline objects.
ShaderPair loadShaderPair(const RHI_SHADER_BLOB &aVert, const RHI_SHADER_BLOB &aFrag)
RHI_BindGroupLayoutHandle m_textureSamplerLayout
RHI_BindGroupLayoutHandle m_fullscreenUBOLayout
RHI_PipelineHandle m_compositorPipeline
RHI_GAL_PIPELINES(RHI_DEVICE &aDevice)
RHI_BindGroupLayoutHandle GetDifferenceLayout() const
RHI_BindGroupLayoutHandle GetFrameUBOLayout() const
std::vector< std::pair< RHI_PipelineHandle, RHI_PipelineHandle > > m_premultipliedVariants
RHI_PipelineHandle GetWireOncePipeline() const
RHI_BindGroupLayoutHandle m_frameUBOLayout
RHI_PipelineHandle m_gridPipeline
RHI_PipelineHandle m_bitmapPipeline
std::vector< ShaderPair > m_shaderPairs
Shader modules kept alive for the lifetime of the pipelines.
RHI_GAL_PIPELINES & operator=(const RHI_GAL_PIPELINES &)=delete
RHI_PipelineHandle GetCursorCompositePipeline() const
The cursor drawn straight into the composite, whose target has no depth.
RHI_PipelineHandle GetGridPipeline() const
RHI_GAL_PIPELINES(const RHI_GAL_PIPELINES &)=delete
RHI_BindGroupLayoutHandle GetGlyphLayout() const
The bind group layout of the font atlas and glyph table the track pipelines read at set 1.
RHI_PipelineHandle GetBitmapPipeline() const
RHI_PipelineHandle GetPremultipliedVariant(RHI_PipelineHandle aPipeline) const
The variant of a pipeline for a cached layer that the legacy canvas draws on its overlay.
static constexpr int DRAW_MODES
void Destroy()
Release all GPU resources.
RHI_BIND_GROUP_LAYOUT_DESC m_glyphLayoutDesc
RHI_PipelineHandle GetInlineCompositorPipeline() const
std::vector< RHI_PipelineHandle > m_glyphPipelines
RHI_BIND_GROUP_LAYOUT_DESC m_frameUBOLayoutDesc
RHI_PipelineHandle GetOverlayVariant(RHI_PipelineHandle aPipeline) const
The variant of a pipeline for content drawn into the overlay target.
RHI_PipelineHandle GetCompositorPipeline() const
RHI_BindGroupLayoutHandle m_glyphLayout
RHI_BindGroupLayoutHandle GetTextureSamplerLayout() const
std::array< std::array< RHI_PipelineHandle, DRAW_MODES >, KIGFX::RHI_SHAPES > m_shapePipelines
RHI_PipelineHandle GetWirePipeline() const
RHI_PipelineHandle m_wirePipeline
RHI_PipelineHandle GetDifferencePipeline() const
Replaces a target's colour with its difference from a diff layer, see LAYER_RANGE::difference.
RHI_PipelineHandle m_differencePipeline
bool UsesGlyphAtlas(RHI_PipelineHandle aPipeline) const
True for a pipeline that expects the glyph bind group at set 1.
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...
RHI_PipelineHandle m_inlineCompositorPipeline
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)
RHI_PipelineHandle m_wireOncePipeline
std::vector< std::pair< RHI_PipelineHandle, RHI_PipelineHandle > > m_overlayVariants
Each pipeline that has an overlay variant, paired with it.
RHI_PipelineHandle m_cursorCompositePipeline
RHI_SHAPE
Shapes a frame draws, each with its own array and pipelines.
@ MARK
write depth only, so the layer's later draws stay out of these pixels
constexpr int RHI_SHAPES
RHI_HANDLE< RHI_TAG_PIPELINE > RHI_PipelineHandle
Definition rhi_handle.h:86
RHI_HANDLE< RHI_TAG_BIND_GROUP_LAYOUT > RHI_BindGroupLayoutHandle
Definition rhi_handle.h:89
RHI_HANDLE< RHI_TAG_SHADER > RHI_ShaderHandle
Definition rhi_handle.h:85
One shader stage as GenerateShaderHeader.cmake embeds it.
Definition rhi_shader.h:46