Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qssgrendererimplshaders_rhi.cpp
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
5#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
6#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
7#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
8#include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h>
9#include <QtQuick3DRuntimeRender/private/qssgrendershaderlibrarymanager_p.h>
10#include <QtQuick3DRuntimeRender/private/qssgrendershadercodegenerator_p.h>
11#include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterialshadergenerator_p.h>
12#include <QtQuick3DRuntimeRender/private/qssgvertexpipelineimpl_p.h>
13
14// this file contains the getXxxxShader implementations suitable for the QRhi-based rendering path
15
17
18QSSGRhiShaderPipelinePtr QSSGRenderer::getBuiltinRhiShader(const QByteArray &name,
20{
22 if (!result) {
23 // loadBuiltin must always return a valid QSSGRhiShaderPipeline.
24 // There will just be no stages if loading fails.
25 result = m_contextInterface->shaderCache()->loadBuiltinForRhi(name);
26 }
27 return result;
28}
29
31{
32 return getBuiltinRhiShader(QByteArrayLiteral("cubeshadowblurx"), m_cubemapShadowBlurXRhiShader);
33}
34
36{
37 return getBuiltinRhiShader(QByteArrayLiteral("cubeshadowblury"), m_cubemapShadowBlurYRhiShader);
38}
39
41{
42 return getBuiltinRhiShader(QByteArrayLiteral("grid"), m_gridShader);
43}
44
46{
47 return getBuiltinRhiShader(QByteArrayLiteral("orthoshadowblurx"), m_orthographicShadowBlurXRhiShader);
48}
49
51{
52 return getBuiltinRhiShader(QByteArrayLiteral("orthoshadowblury"), m_orthographicShadowBlurYRhiShader);
53}
54
56{
57 return getBuiltinRhiShader(QByteArrayLiteral("ssao"), m_ssaoRhiShader);
58}
59
61{
62 return getBuiltinRhiShader(QByteArrayLiteral("skyboxcube"), m_skyBoxCubeRhiShader);
63}
64
66{
67 // Skybox shader is special and has multiple possible shaders so we have to do
68 // a bit of manual work here.
69
70 QSSGRhiShaderPipelinePtr &result = m_skyBoxRhiShader;
71 if (!result || tonemapMode != m_skyboxTonemapMode || isRGBE != m_isSkyboxRGBE) {
73 if (isRGBE)
74 name.append(QByteArrayLiteral("_rgbe"));
75 else
76 name.append(QByteArrayLiteral("_hdr"));
77
78 switch (tonemapMode) {
80 name.append(QByteArrayLiteral("_none"));
81 break;
83 name.append(QByteArrayLiteral("_aces"));
84 break;
86 name.append(QByteArrayLiteral("_hejldawson"));
87 break;
89 name.append(QByteArrayLiteral("_filmic"));
90 break;
92 default:
93 name.append(QByteArrayLiteral("_linear"));
94 }
95
96 result = m_contextInterface->shaderCache()->loadBuiltinForRhi(name);
97 m_skyboxTonemapMode = tonemapMode;
98 m_isSkyboxRGBE = isRGBE;
99 }
100 return result;
101}
102
104{
105 return getBuiltinRhiShader(QByteArrayLiteral("ssaaresolve"), m_supersampleResolveRhiShader);
106}
107
109{
110 return getBuiltinRhiShader(QByteArrayLiteral("progressiveaa"), m_progressiveAARhiShader);
111}
112
114{
115 return getBuiltinRhiShader(QByteArrayLiteral("texturedquad"), m_texturedQuadRhiShader);
116}
117
119{
120 switch (featureLevel) {
122 return getBuiltinRhiShader(QByteArrayLiteral("particlesnolightsimple"), m_particlesNoLightingSimpleRhiShader);
123 break;
125 return getBuiltinRhiShader(QByteArrayLiteral("particlesnolightmapped"), m_particlesNoLightingMappedRhiShader);
126 break;
128 return getBuiltinRhiShader(QByteArrayLiteral("particlesnolightanimated"), m_particlesNoLightingAnimatedRhiShader);
129 break;
131 return getBuiltinRhiShader(QByteArrayLiteral("particlesvlightsimple"), m_particlesVLightingSimpleRhiShader);
132 break;
134 return getBuiltinRhiShader(QByteArrayLiteral("particlesvlightmapped"), m_particlesVLightingMappedRhiShader);
135 break;
137 return getBuiltinRhiShader(QByteArrayLiteral("particlesvlightanimated"), m_particlesVLightingAnimatedRhiShader);
138 break;
140 return getBuiltinRhiShader(QByteArrayLiteral("lineparticles"), m_lineParticlesRhiShader);
141 break;
143 return getBuiltinRhiShader(QByteArrayLiteral("lineparticlesmapped"), m_lineParticlesMappedRhiShader);
144 break;
146 return getBuiltinRhiShader(QByteArrayLiteral("lineparticlesanimated"), m_lineParticlesAnimatedRhiShader);
147 break;
149 return getBuiltinRhiShader(QByteArrayLiteral("lineparticlesvlightsimple"), m_lineParticlesVLightRhiShader);
150 break;
152 return getBuiltinRhiShader(QByteArrayLiteral("lineparticlesvlightmapped"), m_lineParticlesMappedVLightRhiShader);
153 break;
155 return getBuiltinRhiShader(QByteArrayLiteral("lineparticlesvlightanimated"), m_lineParticlesAnimatedVLightRhiShader);
156 break;
157 }
158 return getBuiltinRhiShader(QByteArrayLiteral("particlesnolightanimated"), m_particlesNoLightingAnimatedRhiShader);
159}
160
162{
163 return getBuiltinRhiShader(QByteArrayLiteral("simplequad"), m_simpleQuadRhiShader);
164}
165
167{
168 switch (mode) {
170 return getBuiltinRhiShader(QByteArrayLiteral("lightmapuvraster_uv"), m_lightmapUVRasterShader_uv);
172 return getBuiltinRhiShader(QByteArrayLiteral("lightmapuvraster_uv_tangent"), m_lightmapUVRasterShader_uv_tangent);
173 default:
174 break;
175 }
176 return getBuiltinRhiShader(QByteArrayLiteral("lightmapuvraster"), m_lightmapUVRasterShader);
177}
178
180{
181 return getBuiltinRhiShader(QByteArrayLiteral("lightmapdilate"), m_lightmapDilateShader);
182}
183
185{
186 return getBuiltinRhiShader(QByteArrayLiteral("debugobject"), m_debugObjectShader);
187}
188
\inmodule QtCore
Definition qbytearray.h:57
const std::unique_ptr< QSSGShaderCache > & shaderCache() const
QSSGRhiShaderPipelinePtr getRhiGridShader()
QSSGRhiShaderPipelinePtr getRhiSkyBoxCubeShader()
QSSGRhiShaderPipelinePtr getRhiSsaoShader()
QSSGRhiShaderPipelinePtr getRhiSimpleQuadShader()
QSSGRhiShaderPipelinePtr getRhiTexturedQuadShader()
QSSGRhiShaderPipelinePtr getRhiOrthographicShadowBlurXShader()
QSSGRhiShaderPipelinePtr getRhiOrthographicShadowBlurYShader()
QSSGRhiShaderPipelinePtr getRhiSkyBoxShader(QSSGRenderLayer::TonemapMode tonemapMode, bool isRGBE)
QSSGRhiShaderPipelinePtr getRhiLightmapUVRasterizationShader(LightmapUVRasterizationShaderMode mode)
QSSGRhiShaderPipelinePtr getRhiSupersampleResolveShader()
QSSGRhiShaderPipelinePtr getRhiParticleShader(QSSGRenderParticles::FeatureLevel featureLevel)
QSSGRhiShaderPipelinePtr getRhiProgressiveAAShader()
QSSGRhiShaderPipelinePtr getRhiCubemapShadowBlurXShader()
QSSGRhiShaderPipelinePtr getRhiCubemapShadowBlurYShader()
QSSGRhiShaderPipelinePtr getRhiDebugObjectShader()
QSSGRhiShaderPipelinePtr getRhiLightmapDilateShader()
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
GLenum mode
GLuint name
GLuint64EXT * result
[6]
std::shared_ptr< QSSGRhiShaderPipeline > QSSGRhiShaderPipelinePtr
QStorageInfo storage
[1]