Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qssgrenderhelpers.cpp File Reference

(6584ceefab6a2e891d20d2fe35bb10b2365c7fff)

#include "qssgdebugdrawsystem_p.h"
#include "qssgrenderhelpers_p.h"
#include "qssgrenderer_p.h"
#include "qssglayerrenderdata_p.h"
#include "qssgrhiparticles_p.h"
#include "qssgrhiquadrenderer_p.h"
#include "../qssgrendercontextcore.h"
#include "../qssgrhicustommaterialsystem_p.h"
#include "../resourcemanager/qssgrenderbuffermanager_p.h"
#include "../qssgrenderdefaultmaterialshadergenerator_p.h"
#include "rendererimpl/qssgshadowmaphelpers_p.h"
#include <QtQuick3DUtils/private/qssgassert_p.h>
#include <QtCore/qbitarray.h>
+ Include dependency graph for qssgrenderhelpers.cpp:

Go to the source code of this file.

Functions

static QSSGRhiShaderPipelinePtr shadersForDefaultMaterial (QSSGRhiGraphicsPipelineState *ps, QSSGSubsetRenderable &subsetRenderable, const QSSGShaderFeatures &featureSet)
 
static QSSGRhiShaderPipelinePtr shadersForParticleMaterial (QSSGRhiGraphicsPipelineState *ps, QSSGParticlesRenderable &particleRenderable)
 
static void updateUniformsForDefaultMaterial (QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, char *ubufData, QSSGRhiGraphicsPipelineState *ps, QSSGSubsetRenderable &subsetRenderable, const QSSGRenderCameraList &cameras, const QVector2D *depthAdjust, const QMatrix4x4 *alteredModelViewProjection)
 
static QSSGBoxPoints computeFrustumBounds (const QSSGRenderCamera &inCamera)
 
static QSSGBoxPoints computeFrustumBoundsWithNearFar (const QSSGRenderCamera &inCamera, float clipNear, float clipFar)
 
static std::unique_ptr< QSSGRenderCameracomputeShadowCameraFromFrustum (const QSSGRenderCamera &inCamera, const QMatrix4x4 &lightMatrix, const QMatrix4x4 &lightMatrixInverted, const QVector3D &lightPivot, const QVector3D &lightForward, const QVector3D &lightUp, float clipRange, float frustumStartT, float frustumEndT, const QSSGBounds3 &castingBox, const QSSGBounds3 &receivingBox, QSSGDebugDrawSystem *debugDrawSystem, const bool drawCascades, const bool drawSceneCascadeIntersection)
 
static QVarLengthArray< std::unique_ptr< QSSGRenderCamera >, 4 > setupCascadingCamerasForShadowMap (const QSSGRenderCamera &inCamera, const QSSGRenderLight *inLight, const QSSGBounds3 &castingObjectsBox, const QSSGBounds3 &receivingObjectsBox, QSSGDebugDrawSystem *debugDrawSystem, bool drawCascades, bool drawSceneCascadeIntersection)
 
static void setupCubeReflectionCameras (const QSSGRenderReflectionProbe *inProbe, QSSGRenderCamera inCameras[6])
 
static void addOpaqueDepthPrePassBindings (QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRenderableImage *renderableImage, QSSGRhiShaderResourceBindingList &bindings, bool isCustomMaterialMeshSubset=false)
 
static void setupCubeShadowCameras (const QSSGRenderLight *inLight, float shadowMapFar, QSSGRenderCamera inCameras[6])
 
static int setupInstancing (QSSGSubsetRenderable *renderable, QSSGRhiGraphicsPipelineState *ps, QSSGRhiContext *rhiCtx, const QVector3D &cameraDirection, const QVector3D &cameraPosition)
 
static void rhiPrepareResourcesForReflectionMap (QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGReflectionMapEntry *pEntry, QSSGRhiGraphicsPipelineState *ps, const QSSGRenderableObjectList &sortedOpaqueObjects, QSSGRenderCamera &inCamera, QSSGRenderer &renderer, QSSGRenderTextureCubeFace cubeFace)
 
static void addDepthTextureBindings (QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRhiShaderResourceBindingList &bindings)
 
static void rhiPrepareResourcesForShadowMap (QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, QSSGPassKey passKey, QSSGShadowMapEntry *pEntry, QSSGRhiGraphicsPipelineState *ps, const QVector2D *depthAdjust, const QSSGRenderableObjectList &sortedOpaqueObjects, QSSGRenderCamera &inCamera, bool orthographic, QSSGRenderTextureCubeFace cubeFace, quint32 cascadeIndex)
 
static void fillTargetBlend (QRhiGraphicsPipeline::TargetBlend *targetBlend, QSSGRenderDefaultMaterial::MaterialBlendMode materialBlend)
 
static void rhiPrepareSkyBox_helper (QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderLayer &layer, QSSGRenderCameraList &cameras, QSSGRenderer &renderer, QSSGReflectionMapEntry *entry=nullptr, QSSGRenderTextureCubeFace cubeFace=QSSGRenderTextureCubeFaceNone)
 

Variables

static QT_BEGIN_NAMESPACE constexpr float QSSG_PI = float(M_PI)
 
static constexpr float QSSG_HALFPI = float(M_PI_2)
 
static const QRhiShaderResourceBinding::StageFlags RENDERER_VISIBILITY_ALL
 

Function Documentation

◆ addDepthTextureBindings()

static void addDepthTextureBindings ( QSSGRhiContext * rhiCtx,
QSSGRhiShaderPipeline * shaderPipeline,
QSSGRhiShaderResourceBindingList & bindings )
inlinestatic

Definition at line 575 of file qssgrenderhelpers.cpp.

References QSSGRhiShaderResourceBindingList::addTexture(), AoTexture, AoTextureArray, QSSGRhiShaderPipeline::bindingForTexture(), QRhiSampler::ClampToEdge, DepthTexture, QSSGRhiShaderPipeline::depthTexture(), DepthTextureArray, QRhiShaderResourceBinding::FragmentStage, QRhiSampler::Linear, QRhiSampler::Nearest, QRhiSampler::None, QRhiSampler::Repeat, QSSGRhiContext::sampler(), and QSSGRhiShaderPipeline::ssaoTexture().

Referenced by RenderHelpers::rhiPrepareDepthPass(), RenderHelpers::rhiPrepareRenderable(), and rhiPrepareResourcesForShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addOpaqueDepthPrePassBindings()

static void addOpaqueDepthPrePassBindings ( QSSGRhiContext * rhiCtx,
QSSGRhiShaderPipeline * shaderPipeline,
QSSGRenderableImage * renderableImage,
QSSGRhiShaderResourceBindingList & bindings,
bool isCustomMaterialMeshSubset = false )
static

◆ computeFrustumBounds()

static QSSGBoxPoints computeFrustumBounds ( const QSSGRenderCamera & inCamera)
static

Definition at line 129 of file qssgrenderhelpers.cpp.

References QMatrix4x4::inverted(), and Q_ASSERT.

Referenced by RenderHelpers::rhiRenderShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeFrustumBoundsWithNearFar()

static QSSGBoxPoints computeFrustumBoundsWithNearFar ( const QSSGRenderCamera & inCamera,
float clipNear,
float clipFar )
static

Definition at line 143 of file qssgrenderhelpers.cpp.

References QMatrix4x4::inverted(), and Q_ASSERT.

Referenced by computeShadowCameraFromFrustum().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ computeShadowCameraFromFrustum()

static std::unique_ptr< QSSGRenderCamera > computeShadowCameraFromFrustum ( const QSSGRenderCamera & inCamera,
const QMatrix4x4 & lightMatrix,
const QMatrix4x4 & lightMatrixInverted,
const QVector3D & lightPivot,
const QVector3D & lightForward,
const QVector3D & lightUp,
float clipRange,
float frustumStartT,
float frustumEndT,
const QSSGBounds3 & castingBox,
const QSSGBounds3 & receivingBox,
QSSGDebugDrawSystem * debugDrawSystem,
const bool drawCascades,
const bool drawSceneCascadeIntersection )
static

Definition at line 159 of file qssgrenderhelpers.cpp.

References ShadowmapHelpers::addDebugFrustum(), QColorConstants::Black, QSSGRenderNode::calculateTransformMatrix(), camera, computeFrustumBoundsWithNearFar(), QColorConstants::DarkGray, i, QSSGBounds3::include(), QSSGRenderNode::initScale, ShadowmapHelpers::intersectBoxByBox(), ShadowmapHelpers::intersectBoxByFrustum(), QObject::parent(), Q_ASSERT, qDegreesToRadians(), qMax(), and qMin().

Referenced by setupCascadingCamerasForShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillTargetBlend()

◆ rhiPrepareResourcesForReflectionMap()

static void rhiPrepareResourcesForReflectionMap ( QSSGRhiContext * rhiCtx,
QSSGPassKey passKey,
const QSSGLayerRenderData & inData,
QSSGReflectionMapEntry * pEntry,
QSSGRhiGraphicsPipelineState * ps,
const QSSGRenderableObjectList & sortedOpaqueObjects,
QSSGRenderCamera & inCamera,
QSSGRenderer & renderer,
QSSGRenderTextureCubeFace cubeFace )
static

Definition at line 536 of file qssgrenderhelpers.cpp.

References QSSGShaderFeatures::DisableMultiView, renderer, QSSGShaderFeatures::set(), QSSGRenderLayer::SkyBox, and QSSGRenderLayer::SkyBoxCubeMap.

Referenced by RenderHelpers::rhiRenderReflectionMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rhiPrepareResourcesForShadowMap()

static void rhiPrepareResourcesForShadowMap ( QSSGRhiContext * rhiCtx,
const QSSGLayerRenderData & inData,
QSSGPassKey passKey,
QSSGShadowMapEntry * pEntry,
QSSGRhiGraphicsPipelineState * ps,
const QVector2D * depthAdjust,
const QSSGRenderableObjectList & sortedOpaqueObjects,
QSSGRenderCamera & inCamera,
bool orthographic,
QSSGRenderTextureCubeFace cubeFace,
quint32 cascadeIndex )
static

Definition at line 615 of file qssgrenderhelpers.cpp.

References addDepthTextureBindings(), addOpaqueDepthPrePassBindings(), QSSGRhiShaderResourceBindingList::addTexture(), QSSGRhiShaderResourceBindingList::addUniformBuffer(), QSSGRhiHelpers::bakeVertexInputLocations(), Qt::black, QSSGRhiContext::commandBuffer(), QSSGShaderFeatures::CubeShadowPass, QSSGRhiGraphicsPipelineState::cullMode, direction, QSSGShaderFeatures::DisableMultiView, QSSGRhiContext::dummyTexture(), QRhiShaderResourceBinding::FragmentStage, QSSGRhiInputAssemblerStatePrivate::get(), QSSGRhiContextPrivate::get(), QSSGBaseTypeHelpers::indexOfCubeFace(), QSSGRhiContext::mainPassViewCount(), QRhiSampler::Nearest, QRhi::nextResourceUpdateBatch(), QRhiSampler::None, QSSGShaderFeatures::OpaqueDepthPrePass, OpaquePrePass, QSSGShaderFeatures::OrthoShadowPass, position(), QSSGParticleRenderer::prepareParticlesForModel(), QSSG_ASSERT, QSSGRenderTextureCubeFaceNone, RENDERER_VISIBILITY_ALL, QRhiSampler::Repeat, QRhiCommandBuffer::resourceUpdate(), QSSGRhiContext::rhi(), QSSGRhiContext::sampler(), ScreenTexture, ScreenTextureArray, QSSGShaderFeatures::set(), QSSGRhiGraphicsPipelineStatePrivate::setShaderPipeline(), setupInstancing(), QSSGCustomMaterialSystem::shadersForCustomMaterial(), shadersForDefaultMaterial(), QSSGRhiHelpers::toCullMode(), QSSGCustomMaterialSystem::updateUniformsForCustomMaterial(), updateUniformsForDefaultMaterial(), and QSSGParticleRenderer::updateUniformsForParticleModel().

Referenced by RenderHelpers::rhiRenderShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rhiPrepareSkyBox_helper()

static void rhiPrepareSkyBox_helper ( QSSGRhiContext * rhiCtx,
QSSGPassKey passKey,
QSSGRenderLayer & layer,
QSSGRenderCameraList & cameras,
QSSGRenderer & renderer,
QSSGReflectionMapEntry * entry = nullptr,
QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone )
static

◆ setupCascadingCamerasForShadowMap()

static QVarLengthArray< std::unique_ptr< QSSGRenderCamera >, 4 > setupCascadingCamerasForShadowMap ( const QSSGRenderCamera & inCamera,
const QSSGRenderLight * inLight,
const QSSGBounds3 & castingObjectsBox,
const QSSGBounds3 & receivingObjectsBox,
QSSGDebugDrawSystem * debugDrawSystem,
bool drawCascades,
bool drawSceneCascadeIntersection )
static

Definition at line 247 of file qssgrenderhelpers.cpp.

References camera, computeShadowCameraFromFrustum(), QVector3D::crossProduct(), i, QMatrix4x4::inverted(), QVector3D::normalized(), Q_ASSERT, qAbs(), qBound(), qFuzzyCompare(), qMax(), qMin(), QMatrix4x4::setRow(), and QVector3D::y().

Referenced by RenderHelpers::rhiRenderShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setupCubeReflectionCameras()

static void setupCubeReflectionCameras ( const QSSGRenderReflectionProbe * inProbe,
QSSGRenderCamera inCameras[6] )
static

Definition at line 334 of file qssgrenderhelpers.cpp.

References QSSGRenderNode::calculateTransformMatrix(), i, QSSGRenderNode::initScale, Q_ASSERT, qDegreesToRadians(), qRadiansToDegrees(), QSSG_HALFPI, and QSSG_PI.

Referenced by RenderHelpers::rhiRenderReflectionMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setupCubeShadowCameras()

static void setupCubeShadowCameras ( const QSSGRenderLight * inLight,
float shadowMapFar,
QSSGRenderCamera inCameras[6] )
static

Definition at line 458 of file qssgrenderhelpers.cpp.

References QSSGRenderNode::calculateTransformMatrix(), i, QSSGRenderNode::initScale, Q_ASSERT, qDegreesToRadians(), qRadiansToDegrees(), QSSG_HALFPI, and QSSG_PI.

Referenced by RenderHelpers::rhiRenderShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setupInstancing()

static int setupInstancing ( QSSGSubsetRenderable * renderable,
QSSGRhiGraphicsPipelineState * ps,
QSSGRhiContext * rhiCtx,
const QVector3D & cameraDirection,
const QVector3D & cameraPosition )
static

Definition at line 518 of file qssgrenderhelpers.cpp.

References QSSGRhiInputAssemblerStatePrivate::get(), QRhiVertexInputBinding::PerInstance, and QSSGLayerRenderData::prepareInstancing().

Referenced by RenderHelpers::rhiPrepareDepthPass(), RenderHelpers::rhiPrepareRenderable(), and rhiPrepareResourcesForShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shadersForDefaultMaterial()

static QSSGRhiShaderPipelinePtr shadersForDefaultMaterial ( QSSGRhiGraphicsPipelineState * ps,
QSSGSubsetRenderable & subsetRenderable,
const QSSGShaderFeatures & featureSet )
static

Definition at line 28 of file qssgrenderhelpers.cpp.

References QSSGRendererPrivate::getShaderPipelineForDefaultMaterial(), renderer, and QSSGRhiGraphicsPipelineStatePrivate::setShaderPipeline().

Referenced by RenderHelpers::rhiPrepareDepthPass(), RenderHelpers::rhiPrepareRenderable(), and rhiPrepareResourcesForShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shadersForParticleMaterial()

static QSSGRhiShaderPipelinePtr shadersForParticleMaterial ( QSSGRhiGraphicsPipelineState * ps,
QSSGParticlesRenderable & particleRenderable )
static

Definition at line 39 of file qssgrenderhelpers.cpp.

References renderer, QSSGRhiGraphicsPipelineStatePrivate::setShaderPipeline(), and QSSGRhiGraphicsPipelineState::viewCount.

Referenced by RenderHelpers::rhiPrepareRenderable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateUniformsForDefaultMaterial()

static void updateUniformsForDefaultMaterial ( QSSGRhiShaderPipeline & shaderPipeline,
QSSGRhiContext * rhiCtx,
const QSSGLayerRenderData & inData,
char * ubufData,
QSSGRhiGraphicsPipelineState * ps,
QSSGSubsetRenderable & subsetRenderable,
const QSSGRenderCameraList & cameras,
const QVector2D * depthAdjust,
const QMatrix4x4 * alteredModelViewProjection )
static

Definition at line 51 of file qssgrenderhelpers.cpp.

References QRhi::clipSpaceCorrMatrix(), renderer, QSSGRhiContext::rhi(), QSSGMaterialShaderGenerator::setRhiMaterialProperties(), and toDataView().

Referenced by RenderHelpers::rhiPrepareDepthPass(), RenderHelpers::rhiPrepareRenderable(), and rhiPrepareResourcesForShadowMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ QSSG_HALFPI

constexpr float QSSG_HALFPI = float(M_PI_2)
staticconstexpr

Definition at line 23 of file qssgrenderhelpers.cpp.

Referenced by setupCubeReflectionCameras(), and setupCubeShadowCameras().

◆ QSSG_PI

QT_BEGIN_NAMESPACE constexpr float QSSG_PI = float(M_PI)
staticconstexpr

Definition at line 22 of file qssgrenderhelpers.cpp.

Referenced by setupCubeReflectionCameras(), and setupCubeShadowCameras().

◆ RENDERER_VISIBILITY_ALL