| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSSGRENDERHELPERS_P_H |
| 5 | #define QSSGRENDERHELPERS_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuick3DRuntimeRender/qtquick3druntimerenderglobal.h> |
| 19 | |
| 20 | #include <QtQuick3DUtils/private/qssgaosettings_p.h> |
| 21 | #include <QtQuick3DRuntimeRender/private/qssgrenderableobjects_p.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QSSGRhiContext; |
| 26 | class QSSGRenderShadowMap; |
| 27 | class QRhiRenderPassDescriptor; |
| 28 | class QSSGRenderReflectionMap; |
| 29 | class QSSGLayerRenderData; |
| 30 | struct QSSGReflectionMapEntry; |
| 31 | class QSSGRhiShaderPipeline; |
| 32 | |
| 33 | namespace RenderHelpers |
| 34 | { |
| 35 | |
| 36 | std::pair<QSSGBounds3, QSSGBounds3> calculateSortedObjectBounds(const QSSGRenderableObjectList &sortedOpaqueObjects, |
| 37 | const QSSGRenderableObjectList &sortedTransparentObjects); |
| 38 | |
| 39 | void rhiRenderShadowMap(QSSGRhiContext *rhiCtx, |
| 40 | QSSGPassKey passKey, |
| 41 | QSSGRhiGraphicsPipelineState &ps, |
| 42 | QSSGRenderShadowMap &shadowMapManager, |
| 43 | const QSSGRenderCamera &camera, |
| 44 | QSSGRenderCamera *debugCamera, |
| 45 | const QSSGShaderLightList &globalLights, |
| 46 | const QSSGRenderableObjectList &sortedOpaqueObjects, |
| 47 | QSSGRenderer &renderer, |
| 48 | const QSSGBounds3 &castingObjectsBox, |
| 49 | const QSSGBounds3 &receivingObjectsBox); |
| 50 | |
| 51 | void rhiRenderReflectionMap(QSSGRhiContext *rhiCtx, |
| 52 | QSSGPassKey passKey, |
| 53 | const QSSGLayerRenderData &inData, |
| 54 | QSSGRhiGraphicsPipelineState *ps, |
| 55 | QSSGRenderReflectionMap &reflectionMapManager, |
| 56 | const QVector<QSSGRenderReflectionProbe *> &reflectionProbes, |
| 57 | const QSSGRenderableObjectList &reflectionPassObjects, |
| 58 | QSSGRenderer &renderer); |
| 59 | |
| 60 | bool rhiPrepareDepthPass(QSSGRhiContext *rhiCtx, |
| 61 | QSSGPassKey passKey, |
| 62 | const QSSGRhiGraphicsPipelineState &basePipelineState, |
| 63 | QRhiRenderPassDescriptor *rpDesc, |
| 64 | QSSGLayerRenderData &inData, |
| 65 | const QSSGRenderableObjectList &sortedOpaqueObjects, |
| 66 | const QSSGRenderableObjectList &sortedTransparentObjects, |
| 67 | int samples, |
| 68 | int viewCount); |
| 69 | |
| 70 | void rhiRenderDepthPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps, |
| 71 | const QSSGRenderableObjectList &sortedOpaqueObjects, |
| 72 | const QSSGRenderableObjectList &sortedTransparentObjects, |
| 73 | bool *needsSetViewport); |
| 74 | |
| 75 | bool rhiPrepareAoTexture(QSSGRhiContext *rhiCtx, |
| 76 | const QSize &size, |
| 77 | QSSGRhiRenderableTexture *renderableTex, |
| 78 | quint8 viewCount); |
| 79 | |
| 80 | void rhiRenderAoTexture(QSSGRhiContext *rhiCtx, |
| 81 | QSSGPassKey passKey, |
| 82 | QSSGRenderer &renderer, |
| 83 | QSSGRhiShaderPipeline &shaderPipeline, |
| 84 | QSSGRhiGraphicsPipelineState &ps, |
| 85 | const QSSGAmbientOcclusionSettings &ao, |
| 86 | const QSSGRhiRenderableTexture &rhiAoTexture, |
| 87 | const QSSGRhiRenderableTexture &rhiDepthTexture, |
| 88 | const QSSGRenderCamera &camera); |
| 89 | |
| 90 | bool rhiPrepareScreenTexture(QSSGRhiContext *rhiCtx, |
| 91 | const QSize &size, |
| 92 | bool wantsMips, |
| 93 | QSSGRhiRenderableTexture *renderableTex, |
| 94 | quint8 viewCount); |
| 95 | |
| 96 | void rhiPrepareGrid(QSSGRhiContext *rhiCtx, |
| 97 | QSSGPassKey passKey, |
| 98 | QSSGRenderLayer &layer, |
| 99 | QSSGRenderCameraList &cameras, |
| 100 | QSSGRenderer &renderer); |
| 101 | |
| 102 | |
| 103 | void rhiPrepareSkyBox(QSSGRhiContext *rhiCtx, |
| 104 | QSSGPassKey passKey, |
| 105 | QSSGRenderLayer &layer, |
| 106 | QSSGRenderCameraList &cameras, |
| 107 | QSSGRenderer &renderer); |
| 108 | |
| 109 | void rhiPrepareSkyBoxForReflectionMap(QSSGRhiContext *rhiCtx, |
| 110 | QSSGPassKey passKey, |
| 111 | QSSGRenderLayer &layer, |
| 112 | QSSGRenderCamera &inCamera, |
| 113 | QSSGRenderer &renderer, |
| 114 | QSSGReflectionMapEntry *entry, |
| 115 | QSSGRenderTextureCubeFace cubeFace); |
| 116 | |
| 117 | Q_QUICK3DRUNTIMERENDER_EXPORT void rhiPrepareRenderable(QSSGRhiContext *rhiCtx, |
| 118 | QSSGPassKey passKey, |
| 119 | const QSSGLayerRenderData &inData, |
| 120 | QSSGRenderableObject &inObject, |
| 121 | QRhiRenderPassDescriptor *renderPassDescriptor, |
| 122 | QSSGRhiGraphicsPipelineState *ps, |
| 123 | QSSGShaderFeatures featureSet, |
| 124 | int samples, |
| 125 | int viewCount, |
| 126 | QSSGRenderCamera *alteredCamera = nullptr, |
| 127 | QMatrix4x4 *alteredModelViewProjection = nullptr, |
| 128 | QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone, |
| 129 | QSSGReflectionMapEntry *entry = nullptr); |
| 130 | |
| 131 | Q_QUICK3DRUNTIMERENDER_EXPORT void rhiRenderRenderable(QSSGRhiContext *rhiCtx, |
| 132 | const QSSGRhiGraphicsPipelineState &state, |
| 133 | QSSGRenderableObject &object, |
| 134 | bool *needsSetViewport, |
| 135 | QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone); |
| 136 | |
| 137 | bool rhiPrepareDepthTexture(QSSGRhiContext *rhiCtx, |
| 138 | const QSize &size, |
| 139 | QSSGRhiRenderableTexture *renderableTex, |
| 140 | quint8 viewCount); |
| 141 | |
| 142 | inline QRect correctViewportCoordinates(const QRectF &layerViewport, const QRect &deviceRect) |
| 143 | { |
| 144 | const int y = deviceRect.bottom() - layerViewport.bottom() + 1; |
| 145 | return QRect(layerViewport.x(), y, layerViewport.width(), layerViewport.height()); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | QT_END_NAMESPACE |
| 150 | |
| 151 | |
| 152 | #endif // QSSGRENDERHELPERS_P_H |
| 153 | |