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

(a22a94a3363ce1907fb39c4bd1990b8542da7f61)

#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 <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 QVector3D calcCenter (const QSSGBoxPoints &vertices)
 
static QSSGBounds3 calculateShadowCameraBoundingBox (const QSSGBoxPoints &points, const QVector3D &forward, const QVector3D &up, const QVector3D &right)
 
static QSSGBoxPoints computeFrustumBounds (const QSSGRenderCamera &inCamera)
 
static void setupCubeReflectionCameras (const QSSGRenderReflectionProbe *inProbe, QSSGRenderCamera inCameras[6])
 
static void setupCameraForShadowMap (const QSSGRenderCamera &inCamera, const QSSGRenderLight *inLight, QSSGRenderCamera &theCamera, const QSSGBoxPoints &castingBox, const QSSGBoxPoints &receivingBox)
 
static void addOpaqueDepthPrePassBindings (QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRenderableImage *renderableImage, QSSGRhiShaderResourceBindingList &bindings, bool isCustomMaterialMeshSubset=false)
 
static void setupCubeShadowCameras (const QSSGRenderLight *inLight, 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)
 
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 498 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

◆ calcCenter()

static QVector3D calcCenter ( const QSSGBoxPoints & vertices)
static

Definition at line 119 of file qssgrenderhelpers.cpp.

References i.

Referenced by setupCameraForShadowMap().

+ Here is the caller graph for this function:

◆ calculateShadowCameraBoundingBox()

static QSSGBounds3 calculateShadowCameraBoundingBox ( const QSSGBoxPoints & points,
const QVector3D & forward,
const QVector3D & up,
const QVector3D & right )
static

Definition at line 128 of file qssgrenderhelpers.cpp.

References QVector3D::dotProduct(), i, and QSSGBounds3::include().

Referenced by setupCameraForShadowMap().

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

◆ computeFrustumBounds()

static QSSGBoxPoints computeFrustumBounds ( const QSSGRenderCamera & inCamera)
static

Definition at line 140 of file qssgrenderhelpers.cpp.

References QMatrix4x4::inverted(), and Q_ASSERT.

Referenced by setupCameraForShadowMap().

+ 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 459 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 )
static

Definition at line 538 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

◆ setupCameraForShadowMap()

static void setupCameraForShadowMap ( const QSSGRenderCamera & inCamera,
const QSSGRenderLight * inLight,
QSSGRenderCamera & theCamera,
const QSSGBoxPoints & castingBox,
const QSSGBoxPoints & receivingBox )
static

Definition at line 184 of file qssgrenderhelpers.cpp.

References a0, a1, calcCenter(), calculateShadowCameraBoundingBox(), QSSGRenderNode::calculateTransformMatrix(), computeFrustumBounds(), QVector3D::crossProduct(), d, QVector3D::dotProduct(), QSSGRenderNode::initScale, QVector3D::normalized(), Q_ASSERT, qAbs(), qDegreesToRadians(), qFuzzyCompare(), qMax(), qMin(), 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 154 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,
QSSGRenderCamera inCameras[6] )
static

Definition at line 381 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 441 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 26 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 37 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 49 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 21 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 20 of file qssgrenderhelpers.cpp.

Referenced by setupCubeReflectionCameras(), and setupCubeShadowCameras().

◆ RENDERER_VISIBILITY_ALL