| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSSGRENDERERIMPLSHADERS_P_H |
| 5 | #define QSSGRENDERERIMPLSHADERS_P_H |
| 6 | |
| 7 | #include <QtCore/qbytearray.h> |
| 8 | |
| 9 | #include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h> |
| 10 | |
| 11 | #include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h> |
| 12 | #include <QtQuick3DRuntimeRender/private/qssgrenderlayer_p.h> |
| 13 | #include <QtQuick3DRuntimeRender/private/qssgrenderparticles_p.h> |
| 14 | |
| 15 | // |
| 16 | // W A R N I N G |
| 17 | // ------------- |
| 18 | // |
| 19 | // This file is not part of the Qt API. It exists purely as an |
| 20 | // implementation detail. This header file may change from version to |
| 21 | // version without notice, or even be removed. |
| 22 | // |
| 23 | // We mean it. |
| 24 | // |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QSSGShaderCache; |
| 29 | |
| 30 | class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGBuiltInRhiShaderCache |
| 31 | { |
| 32 | public: |
| 33 | explicit QSSGBuiltInRhiShaderCache(QSSGShaderCache &shaderCache) |
| 34 | : m_shaderCache(shaderCache) {} |
| 35 | |
| 36 | void releaseCachedResources(); |
| 37 | |
| 38 | enum class LightmapUVRasterizationShaderMode { |
| 39 | Default, |
| 40 | Uv, |
| 41 | UvTangent |
| 42 | }; |
| 43 | |
| 44 | QSSGRhiShaderPipelinePtr getRhiGridShader(int viewCount); |
| 45 | QSSGRhiShaderPipelinePtr getRhiSsaoShader(int viewCount); |
| 46 | QSSGRhiShaderPipelinePtr getRhiSkyBoxCubeShader(int viewCount); |
| 47 | QSSGRhiShaderPipelinePtr getRhiSkyBoxShader(QSSGRenderLayer::TonemapMode tonemapMode, bool isRGBE, int viewCount); |
| 48 | QSSGRhiShaderPipelinePtr getRhiSupersampleResolveShader(int viewCount); |
| 49 | QSSGRhiShaderPipelinePtr getRhiProgressiveAAShader(); |
| 50 | QSSGRhiShaderPipelinePtr getRhiParticleShader(QSSGRenderParticles::FeatureLevel featureLevel, int viewCount, QSSGRenderLayer::OITMethod method); |
| 51 | QSSGRhiShaderPipelinePtr getRhiSimpleQuadShader(int viewCount); |
| 52 | QSSGRhiShaderPipelinePtr getRhiLightmapUVRasterizationShader(LightmapUVRasterizationShaderMode mode); |
| 53 | QSSGRhiShaderPipelinePtr getRhiLightmapDilateShader(); |
| 54 | QSSGRhiShaderPipelinePtr getRhiDebugObjectShader(int viewCount); |
| 55 | QSSGRhiShaderPipelinePtr getRhiReflectionprobePreFilterShader(); |
| 56 | QSSGRhiShaderPipelinePtr getRhienvironmentmapPreFilterShader(bool isRGBE); |
| 57 | QSSGRhiShaderPipelinePtr getRhiEnvironmentmapShader(); |
| 58 | QSSGRhiShaderPipelinePtr getRhiClearMRTShader(); |
| 59 | QSSGRhiShaderPipelinePtr getRhiOitCompositeShader(QSSGRenderLayer::OITMethod method, bool multisample); |
| 60 | |
| 61 | private: |
| 62 | QSSGShaderCache &m_shaderCache; // We're owned by the shadercache |
| 63 | |
| 64 | struct BuiltinShader { |
| 65 | // The shader refs are non-null if we have attempted to generate the |
| 66 | // shader. This does not mean we were successul, however. |
| 67 | QSSGRhiShaderPipelinePtr shaderPipeline; |
| 68 | int viewCount = 1; |
| 69 | }; |
| 70 | |
| 71 | QSSGRhiShaderPipelinePtr getBuiltinRhiShader(const QByteArray &name, |
| 72 | BuiltinShader &storage, |
| 73 | int viewCount = 1); |
| 74 | static constexpr int particleShaderCount = 2; |
| 75 | static constexpr int compositeShaderCount = 2; |
| 76 | struct { |
| 77 | BuiltinShader gridShader; |
| 78 | BuiltinShader ssaoRhiShader; |
| 79 | BuiltinShader skyBoxRhiShader[QSSGRenderLayer::TonemapModeCount * 2 /* rgbe+hdr */]; |
| 80 | BuiltinShader skyBoxCubeRhiShader; |
| 81 | BuiltinShader supersampleResolveRhiShader; |
| 82 | BuiltinShader progressiveAARhiShader; |
| 83 | BuiltinShader texturedQuadRhiShader; |
| 84 | BuiltinShader simpleQuadRhiShader; |
| 85 | BuiltinShader lightmapUVRasterShader; |
| 86 | BuiltinShader lightmapUVRasterShader_uv; |
| 87 | BuiltinShader lightmapUVRasterShader_uv_tangent; |
| 88 | BuiltinShader lightmapDilateShader; |
| 89 | BuiltinShader debugObjectShader; |
| 90 | |
| 91 | BuiltinShader reflectionprobePreFilterShader; |
| 92 | BuiltinShader environmentmapPreFilterShader[2]; |
| 93 | BuiltinShader environmentmapShader; |
| 94 | |
| 95 | BuiltinShader particlesNoLightingSimpleRhiShader[particleShaderCount]; |
| 96 | BuiltinShader particlesNoLightingMappedRhiShader[particleShaderCount]; |
| 97 | BuiltinShader particlesNoLightingAnimatedRhiShader[particleShaderCount]; |
| 98 | BuiltinShader particlesVLightingSimpleRhiShader[particleShaderCount]; |
| 99 | BuiltinShader particlesVLightingMappedRhiShader[particleShaderCount]; |
| 100 | BuiltinShader particlesVLightingAnimatedRhiShader[particleShaderCount]; |
| 101 | BuiltinShader lineParticlesRhiShader[particleShaderCount]; |
| 102 | BuiltinShader lineParticlesMappedRhiShader[particleShaderCount]; |
| 103 | BuiltinShader lineParticlesAnimatedRhiShader[particleShaderCount]; |
| 104 | BuiltinShader lineParticlesVLightRhiShader[particleShaderCount]; |
| 105 | BuiltinShader lineParticlesMappedVLightRhiShader[particleShaderCount]; |
| 106 | BuiltinShader lineParticlesAnimatedVLightRhiShader[particleShaderCount]; |
| 107 | |
| 108 | BuiltinShader clearMRTShader; |
| 109 | BuiltinShader oitCompositeShader[compositeShaderCount]; |
| 110 | } m_cache; |
| 111 | }; |
| 112 | |
| 113 | QT_END_NAMESPACE |
| 114 | |
| 115 | #endif // QSSGRENDERERIMPLSHADERS_P_H |
| 116 | |