Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qssgrenderer.cpp File Reference
#include <QtQuick3DRuntimeRender/private/qssgrenderitem2d_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrenderimage_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrendereffect_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrhicustommaterialsystem_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrendershadercodegenerator_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterialshadergenerator_p.h>
#include <QtQuick3DRuntimeRender/private/qssgperframeallocator_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrhiquadrenderer_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrendertexturedata_p.h>
#include <QtQuick3DRuntimeRender/private/qssglayerrenderdata_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrhiparticles_p.h>
#include <QtQuick3DUtils/private/qquick3dprofiler_p.h>
#include <QtQuick3DUtils/private/qssgdataref_p.h>
#include <QtQuick3DUtils/private/qssgutils_p.h>
#include <QtQuick3DUtils/private/qssgassert_p.h>
#include <qtquick3d_tracepoints_p.h>
#include <QtCore/QMutexLocker>
#include <QtCore/QBitArray>
#include <cstdlib>
#include <algorithm>
#include <limits>
+ Include dependency graph for qssgrenderer.cpp:

Go to the source code of this file.

Typedefs

using RenderableList = QVarLengthArray< const QSSGRenderNode * >
 

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 QSSGRenderCamera &camera, const QVector2D *depthAdjust, const QMatrix4x4 *alteredModelViewProjection)
 
template<typename Container >
static void cleanupResourcesImpl (const QSSGRenderContextInterface &rci, const Container &resources)
 
static QByteArray logPrefix ()
 
static void dfs (const QSSGRenderNode &node, RenderableList &renderables)
 
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 QVector< QSSGRenderableObjectHandle > &sortedOpaqueObjects, QSSGRenderCamera &inCamera, QSSGRenderer &renderer, int cubeFace)
 
static void addDepthTextureBindings (QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRhiShaderResourceBindingList &bindings)
 
static void rhiPrepareResourcesForShadowMap (QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, QSSGPassKey passKey, const QSSGLayerGlobalRenderProperties &globalRenderProperties, QSSGShadowMapEntry *pEntry, QSSGRhiGraphicsPipelineState *ps, const QVector2D *depthAdjust, const QVector< QSSGRenderableObjectHandle > &sortedOpaqueObjects, QSSGRenderCamera &inCamera, bool orthographic, int cubeFace)
 
static void fillTargetBlend (QRhiGraphicsPipeline::TargetBlend *targetBlend, QSSGRenderDefaultMaterial::MaterialBlendMode materialBlend)
 

Variables

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

Typedef Documentation

◆ RenderableList

Definition at line 427 of file qssgrenderer.cpp.

Function Documentation

◆ addDepthTextureBindings()

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

Definition at line 1076 of file qssgrenderer.cpp.

References QSSGRhiShaderResourceBindingList::addTexture(), AoTexture, QSSGRhiShaderPipeline::bindingForTexture(), QRhiSampler::ClampToEdge, DepthTexture, QSSGRhiShaderPipeline::depthTexture(), 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

Definition at line 871 of file qssgrenderer.cpp.

References QSSGRhiShaderResourceBindingList::addTexture(), QList< T >::append(), QSSGRhiShaderPipeline::bindingForTexture(), QList< T >::cbegin(), QList< T >::cend(), QRhiSampler::ClampToEdge, QShaderDescription::combinedImageSamplers(), QSSGRhiContext::commandBuffer(), QRhiTexture::CubeMap, QShader::description(), QSSGRhiContext::dummyTexture(), QSSGRhiShaderPipeline::extraTextureAt(), QSSGRhiShaderPipeline::extraTextureCount(), QRhiTexture::flags(), QSSGRhiShaderPipeline::fragmentStage(), QSSGMaterialShaderGenerator::getSamplerName(), i, it, QSSGRenderImage::m_horizontalTilingMode, QSSGRenderableImage::m_imageNode, QSSGRenderImage::m_magFilterType, QSSGRenderableImage::m_mapType, QSSGRenderImage::m_minFilterType, QSSGRenderImage::m_mipFilterType, QSSGRenderableImage::m_nextImage, QSSGRenderableImage::m_texture, QSSGRenderImageTexture::m_texture, QSSGRenderImage::m_verticalTilingMode, QRhiTexture::MipMapped, QRhiSampler::Nearest, QRhi::nextResourceUpdateBatch(), QRhiSampler::None, qMax(), RENDERER_VISIBILITY_ALL, QRhiSampler::Repeat, QRhiCommandBuffer::resourceUpdate(), QSSGRhiContext::rhi(), QSSGRhiContext::sampler(), QShaderDescription::SamplerCube, QBitArray::setBit(), QRhiShaderStage::shader(), QBitArray::testBit(), toRhi(), var, and QSSGRhiShaderPipeline::vertexStage().

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

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

◆ calcCenter()

static QVector3D calcCenter ( const QSSGBoxPoints vertices)
static

Definition at line 703 of file qssgrenderer.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 712 of file qssgrenderer.cpp.

References QSSGRenderableObject::bounds, 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:

◆ cleanupResourcesImpl()

template<typename Container >
static void cleanupResourcesImpl ( const QSSGRenderContextInterface rci,
const Container &  resources 
)
static

Definition at line 195 of file qssgrenderer.cpp.

References QSSGRenderContextInterface::bufferManager(), model, and QSSGRenderContextInterface::rhiContext().

Referenced by QSSGRenderer::cleanupResources(), and QSSGRenderer::cleanupResources().

+ 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 724 of file qssgrenderer.cpp.

References QSSGRenderCamera::calculateViewProjectionMatrix(), QMatrix4x4::inverted(), QMatrix4x4::map(), and Q_ASSERT.

Referenced by setupCameraForShadowMap().

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

◆ dfs()

static void dfs ( const QSSGRenderNode node,
RenderableList renderables 
)
static

Definition at line 428 of file qssgrenderer.cpp.

References child, QSSGRenderNode::children, dfs(), QSSGRenderGraphObject::isRenderable(), QVarLengthArray< T, Prealloc >::push_back(), and QSSGRenderGraphObject::type.

Referenced by dfs(), and QSSGRenderer::getLayerHitObjectList().

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

◆ fillTargetBlend()

◆ logPrefix()

static QByteArray logPrefix ( )
static

Definition at line 246 of file qssgrenderer.cpp.

References QByteArrayLiteral.

Referenced by QSSGRenderer::generateRhiShaderPipelineImpl().

+ Here is the caller graph for this function:

◆ rhiPrepareResourcesForReflectionMap()

static void rhiPrepareResourcesForReflectionMap ( QSSGRhiContext rhiCtx,
QSSGPassKey  passKey,
const QSSGLayerRenderData inData,
QSSGReflectionMapEntry pEntry,
QSSGRhiGraphicsPipelineState ps,
const QVector< QSSGRenderableObjectHandle > &  sortedOpaqueObjects,
QSSGRenderCamera inCamera,
QSSGRenderer renderer,
int  cubeFace 
)
static

Definition at line 1042 of file qssgrenderer.cpp.

References QSSGRenderLayer::background, QSSGLayerRenderData::getShaderFeatures(), QSSGRenderableObject::globalTransform, QSSGLayerRenderData::layer, QSSGRenderLayer::lightProbe, QSSGReflectionMapEntry::m_rhiRenderPassDesc, QSSGReflectionMapEntry::m_viewProjection, renderer, QSSGSubsetRenderable::shaderDescription, QSSGRenderLayer::SkyBox, QSSGRenderLayer::SkyBoxCubeMap, and QSSGRenderableObject::type.

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,
const QSSGLayerGlobalRenderProperties globalRenderProperties,
QSSGShadowMapEntry pEntry,
QSSGRhiGraphicsPipelineState ps,
const QVector2D depthAdjust,
const QVector< QSSGRenderableObjectHandle > &  sortedOpaqueObjects,
QSSGRenderCamera inCamera,
bool  orthographic,
int  cubeFace 
)
static

Definition at line 1102 of file qssgrenderer.cpp.

References addDepthTextureBindings(), addOpaqueDepthPrePassBindings(), QSSGRhiShaderResourceBindingList::addTexture(), QSSGRhiShaderResourceBindingList::addUniformBuffer(), QSSGRhiInputAssemblerState::bakeVertexInputLocations(), QRhiBuffer::beginFullDynamicBufferUpdateForCurrentFrame(), QSSGLayerGlobalRenderProperties::cameraData, QSSGRenderableObjectFlags::castsShadows(), QSSGRhiContext::commandBuffer(), QSSGRenderer::contextInterface(), QSSGGraphicsPipelineStateKey::create(), QSSGShaderFeatures::CubeShadowPass, QSSGRenderDefaultMaterial::cullMode, QSSGRhiGraphicsPipelineState::cullMode, QSSGSubsetRenderable::customMaterial(), QSSGRenderContextInterface::customMaterialSystem(), QSSGSubsetRenderable::defaultMaterial(), QSSGRenderer::defaultMaterialShaderKeyProperties(), QSSGRenderableObject::depthWriteMode, QSSGCameraRenderData::direction, QSSGRhiContext::drawCallData(), QSSGRhiContext::dummyTexture(), QRhiBuffer::endFullDynamicBufferUpdateForCurrentFrame(), QSSGSubsetRenderable::firstImage, QRhiShaderResourceBinding::FragmentStage, QSSGShaderKeyBoolean::getValue(), QSSGRenderableObject::globalTransform, QSSGRenderSubset::ia, QSSGRhiGraphicsPipelineState::ia, QSSGShaderDefaultMaterialKeyProperties::m_blendParticles, QSSGRenderCustomMaterial::m_cullMode, QSSGShadowMapEntry::m_lightVP, QSSGShadowMapEntry::m_rhiRenderPassDesc, QSSGModelContext::model, QSSGSubsetRenderable::modelContext, QRhiSampler::Nearest, QRhi::nextResourceUpdateBatch(), QRhiSampler::None, QSSGRenderSubset::offset, QSSGShaderFeatures::OpaqueDepthPrePass, OpaquePrePass, QSSGShaderFeatures::OrthoShadowPass, QSSGRhiContext::pipeline(), QSSGSubsetRenderable::pipeline, QSSGCameraRenderData::position, QSSGParticleRenderer::prepareParticlesForModel(), QSSG_ASSERT, QSSGRenderableObject::renderableFlags, QSSGSubsetRenderable::renderer, renderer, RENDERER_VISIBILITY_ALL, QRhiSampler::Repeat, QRhiCommandBuffer::resourceUpdate(), QSSGRenderSubset::rhi, QSSGRhiContext::rhi(), QSSGSubsetRenderable::rhiRenderData, QSSGRhiContext::sampler(), ScreenTexture, QSSGShaderFeatures::set(), setupInstancing(), QSSGSubsetRenderable::shaderDescription, QSSGRhiGraphicsPipelineState::shaderPipeline, QSSGCustomMaterialSystem::shadersForCustomMaterial(), shadersForDefaultMaterial(), QSSGRhiDrawCallDataKey::Shadow, QSSGSubsetRenderable::shadowPass, QSSGRhiContext::srb(), QSSGSubsetRenderable::srb, QSSGSubsetRenderable::subset, QSSGRhiGraphicsPipelineState::toCullMode(), QSSGRenderableObject::type, QSSGRhiDrawCallData::ubuf, 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:

◆ setupCameraForShadowMap()

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

◆ setupCubeReflectionCameras()

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

Definition at line 738 of file qssgrenderer.cpp.

References QSSGRenderCamera::calculateGlobalVariables(), QSSGRenderNode::calculateTransformMatrix(), QSSGRenderCamera::clipFar, QSSGRenderCamera::clipNear, QSSGRenderCamera::fov, QQuaternion::fromEulerAngles(), QSSGRenderNode::getGlobalPos(), i, QSSGRenderNode::initScale, QSSGRenderNode::localTransform, QSSGRenderNode::parent, QSSGRenderNode::pivot, Q_ASSERT, qDegreesToRadians(), qRadiansToDegrees(), QSSG_HALFPI, QSSG_PI, and QSSGRenderReflectionProbe::reflectionMapRes.

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 965 of file qssgrenderer.cpp.

References QSSGRenderCamera::calculateGlobalVariables(), QSSGRenderNode::calculateTransformMatrix(), QSSGRenderCamera::clipFar, QSSGRenderCamera::clipNear, QSSGRenderCamera::fov, QQuaternion::fromEulerAngles(), QSSGRenderNode::getGlobalPos(), i, QSSGRenderNode::initScale, QSSGRenderNode::localTransform, QSSGRenderLight::m_shadowMapFar, QSSGRenderLight::m_shadowMapRes, QSSGRenderNode::parent, QSSGRenderNode::pivot, Q_ASSERT, qDegreesToRadians(), qRadiansToDegrees(), QSSG_HALFPI, QSSG_PI, and QSSGRenderGraphObject::type.

Referenced by RenderHelpers::rhiRenderShadowMap().

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

◆ setupInstancing()

◆ shadersForDefaultMaterial()

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

Definition at line 47 of file qssgrenderer.cpp.

References QSSGSubsetRenderable::renderer, renderer, and QSSGRhiGraphicsPipelineState::shaderPipeline.

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

+ Here is the caller graph for this function:

◆ shadersForParticleMaterial()

static QSSGRhiShaderPipelinePtr shadersForParticleMaterial ( QSSGRhiGraphicsPipelineState ps,
QSSGParticlesRenderable particleRenderable 
)
static

Definition at line 58 of file qssgrenderer.cpp.

References QSSGRenderParticles::m_featureLevel, QSSGParticlesRenderable::particles, QSSGParticlesRenderable::renderer, renderer, and QSSGRhiGraphicsPipelineState::shaderPipeline.

Referenced by RenderHelpers::rhiPrepareRenderable().

+ 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 QSSGRenderCamera camera,
const QVector2D depthAdjust,
const QMatrix4x4 alteredModelViewProjection 
)
static

Variable Documentation

◆ QSSG_HALFPI

constexpr float QSSG_HALFPI = float(M_PI_2)
staticconstexpr

Definition at line 42 of file qssgrenderer.cpp.

Referenced by setupCubeReflectionCameras(), and setupCubeShadowCameras().

◆ QSSG_PI

constexpr float QSSG_PI = float(M_PI)
staticconstexpr

Definition at line 41 of file qssgrenderer.cpp.

Referenced by setupCubeReflectionCameras(), and setupCubeShadowCameras().

◆ RENDERER_VISIBILITY_ALL