|
enum | Flag {
UsesBlendConstants = 1 << 0
, UsesStencilRef = 1 << 1
, UsesScissor = 1 << 2
, CompileShadersWithDebugInfo = 1 << 3
,
UsesShadingRate = 1 << 4
} |
| Flag values for describing the dynamic state of the pipeline, and other options. More...
|
enum | Topology {
Triangles
, TriangleStrip
, TriangleFan
, Lines
,
LineStrip
, Points
, Patches
} |
| Specifies the primitive topology. More...
|
enum | CullMode { None
, Front
, Back
} |
| Specifies the culling mode. More...
|
enum | FrontFace { CCW
, CW
} |
| Specifies the front face winding order. More...
|
enum | ColorMaskComponent { R = 1 << 0
, G = 1 << 1
, B = 1 << 2
, A = 1 << 3
} |
| Flag values for specifying the color write mask. More...
|
enum | BlendFactor {
Zero
, One
, SrcColor
, OneMinusSrcColor
,
DstColor
, OneMinusDstColor
, SrcAlpha
, OneMinusSrcAlpha
,
DstAlpha
, OneMinusDstAlpha
, ConstantColor
, OneMinusConstantColor
,
ConstantAlpha
, OneMinusConstantAlpha
, SrcAlphaSaturate
, Src1Color
,
OneMinusSrc1Color
, Src1Alpha
, OneMinusSrc1Alpha
} |
| Specifies the blend factor. More...
|
enum | BlendOp {
Add
, Subtract
, ReverseSubtract
, Min
,
Max
} |
| Specifies the blend operation. More...
|
enum | CompareOp {
Never
, Less
, Equal
, LessOrEqual
,
Greater
, NotEqual
, GreaterOrEqual
, Always
} |
| Specifies the depth or stencil comparison function. More...
|
enum | StencilOp {
StencilZero
, Keep
, Replace
, IncrementAndClamp
,
DecrementAndClamp
, Invert
, IncrementAndWrap
, DecrementAndWrap
} |
| Specifies the stencil operation. More...
|
enum | PolygonMode { Fill
, Line
} |
| Specifies the polygon rasterization mode. More...
|
enum | Type {
Buffer
, Texture
, Sampler
, RenderBuffer
,
RenderPassDescriptor
, SwapChainRenderTarget
, TextureRenderTarget
, ShaderResourceBindings
,
GraphicsPipeline
, SwapChain
, ComputePipeline
, CommandBuffer
,
ShadingRateMap
} |
| Specifies type of the resource. More...
|
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
- Since
- 6.6
Graphics pipeline state resource.
Represents a graphics pipeline. What exactly this map to in the underlying native graphics API, varies. Where there is a concept of pipeline objects, for example with Vulkan, the QRhi backend will create such an object upon calling create(). Elsewhere, for example with OpenGL, the QRhiGraphicsPipeline may merely collect the various state, and create()'s main task is to set up the corresponding shader program, but deferring looking at any of the requested state to a later point.
As with all QRhiResource subclasses, the two-phased initialization pattern applies: setting any values via the setters, for example setDepthTest(), is only effective after calling create(). Avoid changing any values once the QRhiGraphicsPipeline has been initialized via create(). To change some state, set the new value and call create() again. However, that will effectively release all underlying native resources and create new ones. As a result, it may be a heavy, expensive operation. Rather, prefer creating multiple pipelines with the different states, and \l{QRhiCommandBuffer::setGraphicsPipeline()}{switch between them} when recording the render pass.
- Note
- Setting the shader stages is mandatory. There must be at least one stage, and there must be a vertex stage.
-
Setting the shader resource bindings is mandatory. The referenced QRhiShaderResourceBindings must already have create() called on it by the time create() is called. Associating with a QRhiShaderResourceBindings that has no bindings is also valid, as long as no shader in any stage expects any resources. Using a QRhiShaderResourceBindings object that does not specify any actual resources (i.e., the buffers, textures, etc. for the binding points are set to \nullptr) is valid as well, as long as a \l{QRhiShaderResourceBindings::isLayoutCompatible()}{layout-compatible} QRhiShaderResourceBindings, that specifies resources for all the bindings, is going to be set via \l{QRhiCommandBuffer::setShaderResources()}{setShaderResources()} when recording the render pass.
-
Setting the render pass descriptor is mandatory. To obtain a QRhiRenderPassDescriptor that can be passed to setRenderPassDescriptor(), use either QRhiTextureRenderTarget::newCompatibleRenderPassDescriptor() or QRhiSwapChain::newCompatibleRenderPassDescriptor().
-
Setting the vertex input layout is mandatory.
-
sampleCount() defaults to 1 and must match the sample count of the render target's color and depth stencil attachments.
-
The depth test, depth write, and stencil test are disabled by default. The face culling mode defaults to no culling.
-
stencilReadMask() and stencilWriteMask() apply to both faces. They both default to 0xFF.
Definition at line 1308 of file qrhi.h.
Flag values for describing the dynamic state of the pipeline, and other options.
The viewport is always dynamic.
\value UsesBlendConstants Indicates that a blend color constant will be set via QRhiCommandBuffer::setBlendConstants()
\value UsesStencilRef Indicates that a stencil reference value will be set via QRhiCommandBuffer::setStencilRef()
\value UsesScissor Indicates that a scissor rectangle will be set via QRhiCommandBuffer::setScissor()
\value CompileShadersWithDebugInfo Requests compiling shaders with debug information enabled. This is relevant only when runtime shader compilation from source code is involved, and only when the underlying infrastructure supports this. With concrete examples, this is not relevant with Vulkan and SPIR-V, because the GLSL-to-SPIR-V compilation does not happen at run time. On the other hand, consider Direct3D and HLSL, where there are multiple options: when the QShader packages ship with pre-compiled bytecode (DXBC
), debug information is to be requested through the tool that generates the
{.qsb} file, similarly to the case of Vulkan and SPIR-V. However, when having HLSL source code in the pre- or runtime-generated QShader packages, the first phase of compilation (HLSL source to intermediate format) happens at run time too, with this flag taken into account. Debug information is relevant in particular with tools like RenderDoc since it allows seeing the original source code when investigating the pipeline and when performing vertex or fragment shader debugging.
\value UsesShadingRate Indicates that a per-draw (per-pipeline) shading rate value will be set via QRhiCommandBuffer::setShadingRate(). Not specifying this flag and still calling setShadingRate() may lead to varying, unexpected results depending on the underlying graphics API.
Enumerator |
---|
UsesBlendConstants | |
UsesStencilRef | |
UsesScissor | |
CompileShadersWithDebugInfo | |
UsesShadingRate | |
Definition at line 1311 of file qrhi.h.
Specifies the polygon rasterization mode.
Polygon Mode (Triangle Fill Mode in Metal, Fill Mode in D3D) specifies the fill mode used when rasterizing polygons. Polygons may be drawn as solids (Fill), or as a wire mesh (Line).
Support for non-fill polygon modes is optional and is indicated by the QRhi::NonFillPolygonMode feature. With OpenGL ES and some Vulkan implementations the feature will likely be reported as unsupported, which then means values other than Fill cannot be used.
\value Fill The interior of the polygon is filled (default) \value Line Boundary edges of the polygon are drawn as line segments.
Definition at line 1419 of file qrhi.h.
virtual bool QRhiGraphicsPipeline::create |
( |
| ) |
|
|
pure virtual |
Creates the corresponding native graphics resources.
If there are already resources present due to an earlier create() with no corresponding destroy(), then destroy() is called implicitly first.
- Returns
true
when successful, false
when a graphics operation failed. Regardless of the return value, calling destroy() is always safe.
- Note
- This may be, depending on the underlying graphics API, an expensive operation, especially when shaders get compiled/optimized from source or from an intermediate bytecode format to the GPU's own instruction set. Where applicable, the QRhi backend automatically sets up the relevant non-persistent facilities to accelerate this, for example the Vulkan backend automatically creates a
VkPipelineCache
to improve data reuse during the lifetime of the application.
-
Drivers may also employ various persistent (disk-based) caching strategies for shader and pipeline data, which is hidden to and is outside of Qt's control. In some cases, depending on the graphics API and the QRhi backend, there are facilities within QRhi for manually managing such a cache, allowing the retrieval of a serializable blob that can then be reloaded in the future runs of the application to ensure faster pipeline creation times. See QRhi::pipelineCacheData() and QRhi::setPipelineCacheData() for details. Note also that when working with a QRhi instance managed by a higher level Qt framework, such as Qt Quick, it is possible that such disk-based caching is taken care of automatically, for example QQuickWindow uses a disk-based pipeline cache by default (which comes in addition to any driver-level caching).
Implemented in QD3D11GraphicsPipeline, QGles2GraphicsPipeline, QMetalGraphicsPipeline, QNullGraphicsPipeline, and QVkGraphicsPipeline.
void QRhiGraphicsPipeline::setMultiViewCount |
( |
int | count | ) |
|
|
inline |