5#include <QtQuick3DRuntimeRender/private/qssgrenderitem2d_p.h>
6#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
7#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
8#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h>
9#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
10#include <QtQuick3DRuntimeRender/private/qssgrenderimage_p.h>
11#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
12#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
13#include <QtQuick3DRuntimeRender/private/qssgrendereffect_p.h>
14#include <QtQuick3DRuntimeRender/private/qssgrhicustommaterialsystem_p.h>
15#include <QtQuick3DRuntimeRender/private/qssgrendershadercodegenerator_p.h>
16#include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterialshadergenerator_p.h>
17#include <QtQuick3DRuntimeRender/private/qssgperframeallocator_p.h>
18#include <QtQuick3DRuntimeRender/private/qssgrhiquadrenderer_p.h>
19#include <QtQuick3DRuntimeRender/private/qssgrendertexturedata_p.h>
20#include <QtQuick3DRuntimeRender/private/qssglayerrenderdata_p.h>
21#include <QtQuick3DRuntimeRender/private/qssgrhiparticles_p.h>
23#include <QtQuick3DUtils/private/qquick3dprofiler_p.h>
24#include <QtQuick3DUtils/private/qssgdataref_p.h>
25#include <QtQuick3DUtils/private/qssgutils_p.h>
26#include <QtQuick3DUtils/private/qssgassert_p.h>
27#include <qtquick3d_tracepoints_p.h>
29#include <QtCore/QMutexLocker>
30#include <QtCore/QBitArray>
52 const auto &shaderPipeline =
renderer->getShaderPipelineForDefaultMaterial(subsetRenderable, featureSet);
55 return shaderPipeline;
63 const auto &shaderPipeline =
renderer->getRhiParticleShader(featureLevel);
66 return shaderPipeline;
81 const QMatrix4x4 &mvp(alteredModelViewProjection ? *alteredModelViewProjection
87 const QMatrix4x4 &localInstanceTransform(modelNode.localInstanceTransform);
88 const QMatrix4x4 &globalInstanceTransform(modelNode.globalInstanceTransform);
97 renderer->defaultMaterialShaderKeyProperties(),
103 localInstanceTransform,
104 globalInstanceTransform,
108 renderer->getLayerGlobalRenderProperties(),
117void QSSGRenderer::releaseCachedResources()
119 delete m_rhiQuadRenderer;
120 m_rhiQuadRenderer =
nullptr;
121 delete m_rhiCubeRenderer;
122 m_rhiCubeRenderer =
nullptr;
129 m_contextInterface =
nullptr;
130 releaseCachedResources();
135 m_contextInterface =
ctx;
156 if (layerPrepResult->isLayerVisible()) {
167 for (
const auto &pass : activePasses) {
168 pass->renderPrep(*
this, *theRenderData);
169 if (pass->passType() == QSSGRenderPass::Type::Standalone)
170 pass->renderPass(*
this);
186 for (
const auto &pass : activePasses) {
187 if (pass->passType() == QSSGRenderPass::Type::Main || pass->passType() == QSSGRenderPass::Type::Extension)
188 pass->renderPass(*
this);
194template<
typename Container>
203 for (
const auto &resource : resources) {
204 if (resource->type == QSSGRenderGraphObject::Type::Geometry) {
206 bufferManager->releaseGeometry(geometry);
207 }
else if (resource->type == QSSGRenderGraphObject::Type::Model) {
209 rhi->cleanupDrawCallData(
model);
210 }
else if (resource->type == QSSGRenderGraphObject::Type::TextureData) {
212 bufferManager->releaseTextureData(textureData);
235 if (
layer.renderData ==
nullptr)
238 return layer.renderData;
243 m_materialClearDirty.
insert(material);
264 theKey.
toString(shaderString, shaderKeyProperties);
271 return maybePipeline;
276 if (!pregenEntries.
isEmpty()) {
278 if (foundIt != pregenEntries.
cend())
284 return maybePipeline;
300 shaderLibraryManager,
307 const auto &theCache = m_contextInterface->
shaderCache();
310 return generateRhiShaderPipelineImpl(inRenderable, *shaderLibraryManager, *theCache, *shaderProgramGenerator, m_defaultMaterialShaderKeyProperties, inFeatureSet, m_generatedShaderString);
321 for (
auto *matObj : std::as_const(m_materialClearDirty)) {
322 if (matObj->type == QSSGRenderGraphObject::Type::CustomMaterial) {
324 }
else if (matObj->type == QSSGRenderGraphObject::Type::DefaultMaterial ||
325 matObj->type == QSSGRenderGraphObject::Type::PrincipledMaterial ||
326 matObj->type == QSSGRenderGraphObject::Type::SpecularGlossyMaterial) {
330 m_materialClearDirty.
clear();
344 return lhs.m_distanceSq < rhs.m_distanceSq;
354 static const auto processResults = [](
PickResultList &pickResults) {
355 if (pickResults.empty())
359 return lhs.m_distanceSq < rhs.m_distanceSq;
369 return processResults(pickResults);
382 return m_globalPickingEnabled;
387 m_globalPickingEnabled = isEnabled;
392 if (!m_contextInterface->
rhiContext()->isValid())
395 if (!m_rhiQuadRenderer)
398 return m_rhiQuadRenderer;
403 if (!m_contextInterface->
rhiContext()->isValid())
406 if (!m_rhiCubeRenderer)
409 return m_rhiCubeRenderer;
415 m_currentLayer = &inLayer;
419 m_currentLayer =
nullptr;
424 return m_progressiveAARenderRequest;
440 bool inPickEverything,
444 for (
const auto &childNode :
layer.children)
445 dfs(childNode, renderables);
447 for (
int idx = renderables.
size() - 1; idx >= 0; --idx) {
448 const auto &pickableObject = renderables.
at(idx);
460 if (node.
type == QSSGRenderGraphObject::Type::Item2D) {
466 if (node.
type != QSSGRenderGraphObject::Type::Model)
481 const auto &subMeshes = mesh->
subsets;
483 for (
const auto &subMesh : subMeshes)
484 modelBounds.
include(subMesh.bounds);
489 const bool instancing =
model.instancing();
492 for (
int instanceIndex = 0; instanceIndex <
instanceCount; ++instanceIndex) {
496 modelTransform =
model.globalInstanceTransform *
model.instanceTable->getTransform(instanceIndex) *
model.localInstanceTransform;
498 modelTransform =
model.globalTransform;
505 if (!hit.intersects())
509 float minRayLength = std::numeric_limits<float>::max();
514 int resultSubset = 0;
515 for (
const auto &subMesh : subMeshes) {
517 if (subMesh.bvhRoot) {
519 if (hit.intersects()) {
522 float subMeshMinRayLength = std::numeric_limits<float>::max();
523 for (
const auto &subMeshResult : std::as_const(
results)) {
524 if (subMeshResult.rayLengthSquared < subMeshMinRayLength) {
526 subMeshMinRayLength =
result.rayLengthSquared;
532 if (hit.intersects())
535 if (
result.intersects &&
result.rayLengthSquared < minRayLength) {
536 intersectionResult =
result;
538 resultSubset = subset;
546 intersectionResult.
relXY,
563 float intersectionTime = 0;
567 if (intersectionTime >= 0) {
572 const QVector2D qmlCoordinate(localIntersectionPoint.
x(), -localIntersectionPoint.
y());
574 intersectionTime * intersectionTime,
577 localIntersectionPoint,
609 auto it = m_shaderMap.
find(skey);
610 if (
it == m_shaderMap.
end()) {
613 shaderPipeline = generateRhiShaderPipeline(inRenderable, inFeatureSet);
618 m_shaderMap.
insert(skey, shaderPipeline);
620 shaderPipeline =
it.value();
623 if (shaderPipeline !=
nullptr) {
624 if (m_currentLayer && m_currentLayer->
camera) {
626 [[maybe_unused]]
const auto cd = m_currentLayer->getCachedCameraData();
630 m_contextInterface->
rhiContext()->stats().registerMaterialShaderGenerationTime(
timer.elapsed());
632 return shaderPipeline;
640 [[maybe_unused]]
const auto cd = theData.getCachedCameraData();
642 bool isYUpInFramebuffer =
true;
643 bool isYUpInNDC =
true;
644 bool isClipDepthZeroToOne =
true;
645 if (m_contextInterface->
rhiContext()->isValid()) {
665 isClipDepthZeroToOne};
687 for (
const auto handles : { &sortedOpaqueObjects, &sortedTransparentObjects }) {
694 if (
obj.renderableFlags.castsShadows())
696 if (
obj.renderableFlags.receivesShadows())
706 for (
int i = 1;
i < 8; ++
i) {
707 center += vertices[
i];
709 return center * 0.125f;
715 for (
int i = 0;
i < 8; ++
i) {
729 bool invertible =
false;
744 QRectF theViewport(0.0f, 0.0f, (
float)mapRes, (
float)mapRes);
757 for (
int i = 0;
i < 6; ++
i) {
760 inCameras[
i].
clipFar = qMax<float>(2.0f, 10000.0f);
778 QRectF theViewport(0.0f, 0.0f, (
float)mapRes, (
float)mapRes);
786 inLightPos -= inLightDir * inCamera.
clipNear;
788 theCamera.
parent =
nullptr;
790 if (inLight->
type == QSSGRenderLight::Type::DirectionalLight) {
791 Q_ASSERT(theCamera.
type == QSSGRenderCamera::Type::OrthographicCamera);
808 && sceneCastingBounds.
extents().lengthSquared() < frustumBounds.
extents().lengthSquared()) {
819 const float aLength = sceneCastingBounds.
dimensions().
z();
820 const float bLength = boundsReceiving.
dimensions().
z();
827 const float d = bCenter - aCenter;
830 const float a0 = 0.f;
831 const float a1 = aLength;
832 const float b0 = (aLength * 0.5f) +
d - (bLength * 0.5f);
833 const float b1 = (aLength * 0.5f) +
d + (bLength * 0.5f);
836 const float ap0 =
qMin(
a0, b0);
837 const float ap1 =
qMax(
a1, b1);
839 const float length = ap1 - ap0;
841 const float c = (ap1 + ap0) * 0.5f;
844 const float move =
c - aLength * 0.5f;
846 center = center + forward * move;
861 theCamera.
clipNear = -0.5f * finalDims.
z();
862 theCamera.
clipFar = 0.5f * finalDims.
z();
864 }
else if (inLight->
type == QSSGRenderLight::Type::PointLight) {
875 bool isCustomMaterialMeshSubset =
false)
878 return mapType == QSSGRenderableImage::Type::BaseColor ||
879 mapType == QSSGRenderableImage::Type::Diffuse ||
880 mapType == QSSGRenderableImage::Type::Translucency ||
881 mapType == QSSGRenderableImage::Type::Opacity;
884 while (renderableImage) {
885 const auto mapType = renderableImage->
m_mapType;
886 if (imageAffectsAlpha(mapType)) {
888 const int samplerHint = int(mapType);
889 int samplerBinding = shaderPipeline->
bindingForTexture(samplerName, samplerHint);
890 if (samplerBinding >= 0) {
892 if (samplerBinding >= 0 &&
texture) {
908 if (isCustomMaterialMeshSubset) {
912 auto it = std::find_if(samplerVars.
cbegin(), samplerVars.
cend(),
914 if (
it == samplerVars.
cend())
918 int maxSamplerBinding = -1;
920 maxSamplerBinding =
qMax(maxSamplerBinding,
var.binding);
929 QBitArray samplerBindingsSpecified(maxSamplerBinding + 1);
931 if (maxSamplerBinding >= 0) {
934 for (
int i = 0;
i < customTexCount; ++
i) {
937 if (samplerBinding >= 0) {
938 samplerBindingsSpecified.
setBit(samplerBinding);
957 if (!samplerBindingsSpecified.
testBit(
var.binding)) {
968 Q_ASSERT(inLight->
type != QSSGRenderLight::Type::DirectionalLight);
972 QRectF theViewport(0.0f, 0.0f, (
float)mapRes, (
float)mapRes);
985 for (
int i = 0;
i < 6; ++
i) {
1029 int instanceBufferBinding = 0;
1036 instanceBufferBinding = bindings.
size() - 1;
1039 return instanceBufferBinding;
1056 rhiPrepareSkyBoxForReflectionMap(rhiCtx, passKey, inData.
layer, inCamera,
renderer, pEntry, cubeFace);
1060 for (
const auto &
handle : sortedOpaqueObjects) {
1064 if (inObject.
type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset || inObject.
type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
1066 const bool hasSkinning =
renderer.defaultMaterialShaderKeyProperties().m_boneCount.getValue(renderable.
shaderDescription) > 0;
1071 rhiPrepareRenderable(rhiCtx, passKey, inData, inObject, pEntry->
m_rhiRenderPassDesc, ps, features, 1,
1072 &inCamera, &modelViewProjection, cubeFace, pEntry);
1120 for (
const auto &
handle : sortedOpaqueObjects) {
1126 if (isOpaqueDepthPrePass)
1133 if (theObject->
type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset || theObject->
type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
1134 const bool hasSkinning =
renderer->defaultMaterialShaderKeyProperties().m_boneCount.getValue(renderable.
shaderDescription) > 0;
1135 modelViewProjection = hasSkinning ? pEntry->
m_lightVP
1144 if (theObject->
type == QSSGSubsetRenderable::Type::DefaultMaterialMeshSubset) {
1149 if (!shaderPipeline)
1151 shaderPipeline->ensureCombinedMainLightsUniformBuffer(&dcd->
ubuf);
1159 }
else if (theObject->
type == QSSGSubsetRenderable::Type::CustomMaterialMeshSubset) {
1164 if (!shaderPipeline)
1166 shaderPipeline->ensureCombinedMainLightsUniformBuffer(&dcd->
ubuf);
1170 inCamera, depthAdjust, &modelViewProjection);
1174 if (theObject->
type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset || theObject->
type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
1187 if (isOpaqueDepthPrePass) {
1189 shaderPipeline.get(),
1192 (theObject->
type == QSSGRenderableObject::Type::CustomMaterialMeshSubset));
1223 switch (materialBlend) {
1263 switch (inObject.
type) {
1264 case QSSGRenderableObject::Type::DefaultMaterialMeshSubset:
1271 if (cubeFace >= 0) {
1280 if (shaderPipeline) {
1293 entry, cubeFace + int(subsetRenderable.subset.offset << 3),
1294 QSSGRhiDrawCallDataKey::Reflection })
1298 shaderPipeline->ensureCombinedMainLightsUniformBuffer(&dcd.
ubuf);
1310 int binding = shaderPipeline->bindingForTexture(
"qt_boneTexture");
1327 if (targetsTexture) {
1328 int binding = shaderPipeline->bindingForTexture(
"qt_morphTargetTexture");
1353 int instanceBufferBinding =
setupInstancing(&subsetRenderable, ps, rhiCtx, cameraDirection, cameraPosition);
1358 if (shaderPipeline->isLightingEnabled()) {
1360 shaderPipeline->ub0LightDataOffset(),
1361 shaderPipeline->ub0LightDataSize());
1366 while (renderableImage) {
1368 const int samplerHint = int(renderableImage->
m_mapType);
1369 int samplerBinding = shaderPipeline->bindingForTexture(samplerName, samplerHint);
1370 if (samplerBinding >= 0) {
1372 if (samplerBinding >= 0 &&
texture) {
1390 if (shaderPipeline->isLightingEnabled()) {
1392 const int shadowMapCount = shaderPipeline->shadowMapCount();
1393 for (
int i = 0;
i < shadowMapCount; ++
i) {
1403 qWarning(
"No combined image sampler for shadow map texture '%s'",
name.data());
1414 int reflectionSampler = shaderPipeline->bindingForTexture(
"qt_reflectionMap");
1418 if (reflectionSampler >= 0 && reflectionTexture)
1420 }
else if (shaderPipeline->lightProbeTexture()) {
1423 auto tiling = shaderPipeline->lightProbeTiling();
1427 shaderPipeline->lightProbeTexture(),
sampler);
1429 qWarning(
"Could not find sampler for lightprobe");
1434 if (shaderPipeline->screenTexture()) {
1447 shaderPipeline->screenTexture(),
sampler);
1451 if (shaderPipeline->lightmapTexture()) {
1458 shaderPipeline->lightmapTexture(),
sampler);
1474 bool srbChanged =
false;
1476 srb = rhiCtx->
srb(bindings);
1498 if (cubeFace >= 0) {
1500 renderPassDescriptor,
1505 renderPassDescriptor,
1516 case QSSGRenderableObject::Type::CustomMaterialMeshSubset:
1527 if (cubeFace >= 0) {
1537 inCamera, cubeFace, alteredModelViewProjection,
entry);
1540 case QSSGRenderableObject::Type::Particles:
1544 if (shaderPipeline) {
1546 inCamera, cubeFace,
entry);
1556 bool *needsSetViewport,
1559 switch (
object.
type) {
1560 case QSSGRenderableObject::Type::DefaultMaterialMeshSubset:
1567 if (cubeFace >= 0) {
1580 cb->setGraphicsPipeline(ps);
1581 cb->setShaderResources(
srb);
1583 if (*needsSetViewport) {
1584 cb->setViewport(
state.viewport);
1585 if (
state.scissorEnable)
1586 cb->setScissor(
state.scissor);
1587 *needsSetViewport =
false;
1606 if (
state.usesStencilRef)
1607 cb->setStencilRef(
state.stencilRef);
1619 subsetRenderable.
material.profilingId}));
1622 case QSSGRenderableObject::Type::CustomMaterialMeshSubset:
1629 case QSSGRenderableObject::Type::Particles:
1653 static const auto rhiRenderOneShadowMap = [](
QSSGRhiContext *rhiCtx,
1658 bool needsSetViewport =
true;
1660 for (
const auto &
handle : sortedOpaqueObjects) {
1663 if (theObject->
type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset || theObject->
type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
1680 cb->setShaderResources(
srb);
1682 if (needsSetViewport) {
1684 needsSetViewport =
false;
1707 renderable->
material.profilingId}));
1717 bool orthographic) {
1721 if (!pEntry->m_rhiBlurRenderTarget0 || !pEntry->m_rhiBlurRenderTarget1)
1726 QRhiTexture *
map = orthographic ? pEntry->m_rhiDepthMap : pEntry->m_rhiDepthCube;
1727 QRhiTexture *workMap = orthographic ? pEntry->m_rhiDepthCopy : pEntry->m_rhiCubeCopy;
1731 const auto &blurXPipeline = orthographic ?
renderer.getRhiOrthographicShadowBlurXShader()
1732 :
renderer.getRhiCubemapShadowBlurXShader();
1756 flipY.
data()[5] = -1.0f;
1757 float cameraProperties[2] = { shadowFilter, shadowMapFar };
1759 memcpy(ubufData, flipY.
constData(), 64);
1760 memcpy(ubufData + 64, cameraProperties, 8);
1772 QSSGRhiQuadRenderer::Flags quadFlags;
1775 renderer.rhiQuadRenderer()->prepareQuad(rhiCtx,
nullptr);
1776 renderer.rhiQuadRenderer()->recordRenderQuadPass(rhiCtx, &ps,
srb, pEntry->m_rhiBlurRenderTarget0, quadFlags);
1780 const auto &blurYPipeline = orthographic ?
renderer.getRhiOrthographicShadowBlurYShader()
1781 :
renderer.getRhiCubemapShadowBlurYShader();
1789 srb = rhiCtx->
srb(bindings);
1791 renderer.rhiQuadRenderer()->prepareQuad(rhiCtx,
nullptr);
1792 renderer.rhiQuadRenderer()->recordRenderQuadPass(rhiCtx, &ps,
srb, pEntry->m_rhiBlurRenderTarget1, quadFlags);
1803 depthAdjust[0] = 0.0f;
1804 depthAdjust[1] = 1.0f;
1807 depthAdjust[0] = 1.0f;
1808 depthAdjust[1] = 0.5f;
1812 for (
int i = 0, ie = globalLights.
size();
i != ie; ++
i) {
1813 if (!globalLights[
i].shadows || globalLights[
i].light->m_fullyBaked)
1826 const auto &light = globalLights[
i].light;
1827 const auto cameraType = (light->type == QSSGRenderLight::Type::DirectionalLight) ? QSSGRenderCamera::Type::OrthographicCamera : QSSGRenderCamera::Type::CustomCamera;
1834 sortedOpaqueObjects, theCamera,
true, 0);
1842 rhiRenderOneShadowMap(rhiCtx, &ps, sortedOpaqueObjects, 0);
1848 rhiBlurShadowMap(rhiCtx, pEntry,
renderer, globalLights[
i].light->m_shadowFilter, globalLights[
i].light->m_shadowMapFar,
true);
1904 rhiRenderOneShadowMap(rhiCtx, &ps, sortedOpaqueObjects,
quint8(
face));
1911 rhiBlurShadowMap(rhiCtx, pEntry,
renderer, globalLights[
i].light->m_shadowFilter, globalLights[
i].light->m_shadowMapFar,
false);
1933 for (
int i = 0, ie = reflectionProbes.
size();
i != ie; ++
i) {
1989 :
renderer.getRhiSkyBoxCubeShader();
1993 if (!renderPassDesc)
1996 isSkyBox ?
renderer.rhiQuadRenderer()->recordRenderQuad(rhiCtx, ps,
srb, renderPassDesc, {})
1997 :
renderer.rhiCubeRenderer()->recordRenderCube(rhiCtx, ps,
srb, renderPassDesc, {});
2000 bool needsSetViewport =
true;
2001 for (
const auto &
handle : reflectionPassObjects)
2022 reflectionProbes[
i]->hasScheduledUpdate =
false;
2030 bool needsBuild =
false;
2032 if (!renderableTex->
texture) {
2043 qWarning(
"Failed to build ambient occlusion texture (size %dx%d)",
size.width(),
size.height());
2044 renderableTex->
reset();
2052 if (!renderableTex->
rt->
create()) {
2053 qWarning(
"Failed to build render target for ambient occlusion texture");
2054 renderableTex->
reset();
2087 const float rw = float(textureSize.
width());
2088 const float rh = float(textureSize.
height());
2089 const float fov =
camera.verticalFov(rw / rh);
2090 const float tanHalfFovY = tanf(0.5f * fov * (rh / rw));
2091 const float invFocalLenX = tanHalfFovY * (rw / rh);
2095 const QVector4D aoScreenConst(1.0f / R2, rh / (2.0f * tanHalfFovY), 1.0f / rw, 1.0f / rh);
2096 const QVector4D uvToEyeConst(2.0f * invFocalLenX, -2.0f * tanHalfFovY, -invFocalLenX, tanHalfFovY);
2114 memcpy(ubufData, &aoProps, 16);
2115 memcpy(ubufData + 16, &aoProps2, 16);
2116 memcpy(ubufData + 32, &aoScreenConst, 16);
2117 memcpy(ubufData + 48, &uvToEyeConst, 16);
2118 memcpy(ubufData + 64, &cameraProps, 8);
2128 renderer.rhiQuadRenderer()->prepareQuad(rhiCtx,
nullptr);
2129 renderer.rhiQuadRenderer()->recordRenderQuadPass(rhiCtx, &ps,
srb, rhiAoTexture.
rt, {});
2135 bool needsBuild =
false;
2140 if (!renderableTex->
texture) {
2159 qWarning(
"Failed to build screen texture (size %dx%d)",
size.width(),
size.height());
2160 renderableTex->
reset();
2164 qWarning(
"Failed to build depth-stencil buffer for screen texture (size %dx%d)",
2166 renderableTex->
reset();
2177 if (!renderableTex->
rt->
create()) {
2178 qWarning(
"Failed to build render target for screen texture");
2179 renderableTex->
reset();
2194 int uniformBinding = 0;
2195 const int ubufSize = 64 * 2 *
sizeof(float) + 4 *
sizeof(
float) + 4 *
sizeof(
quint32);
2206 const float nearF = inCamera.
clipNear;
2207 const float farF = inCamera.
clipFar;
2211 const float yFactor = rhi->
isYUpInNDC() ? 1.0f : -1.0f;
2218 memcpy(ubufData + 64 * 0, viewProj.
constData(), 64);
2219 memcpy(ubufData + 64 * 1, invViewProj.
constData(), 64);
2220 memcpy(ubufData + 64 * 2 + 0, &nearF, 4);
2221 memcpy(ubufData + 64 * 2 + 4 * 1, &farF, 4);
2222 memcpy(ubufData + 64 * 2 + 4 * 2, &
scale, 4);
2223 memcpy(ubufData + 64 * 2 + 4 * 3, &yFactor, 4);
2224 memcpy(ubufData + 64 * 2 + 4 * 4, &gridFlags, 4);
2229 layer.gridSrb = rhiCtx->
srb(bindings);
2230 renderer.rhiQuadRenderer()->prepareQuad(rhiCtx,
nullptr);
2248 const bool hasValidTexture = lightProbeTexture.
m_texture !=
nullptr;
2249 if (hasValidTexture) {
2261 int samplerBinding = 1;
2262 const int ubufSize = 2 * 4 * 3 *
sizeof(float) + 2 * 4 * 4 *
sizeof(
float) + 2 *
sizeof(float);
2281 float adjustY = rhi->
isYUpInNDC() ? 1.0f : -1.0f;
2282 const float exposure =
layer.probeExposure;
2285 const float blurAmount =
layer.skyboxBlurAmount;
2286 const float maxMipLevel = float(lightProbeTexture.
m_mipmapCount - 2);
2295 char *ubufData = dcd.ubuf->beginFullDynamicBufferUpdateForCurrentFrame();
2296 memcpy(ubufData, viewMatrix.
constData(), 44);
2297 memcpy(ubufData + 48, inverseProjection.
constData(), 64);
2298 memcpy(ubufData + 112, rotationMatrix.constData(), 12);
2299 memcpy(ubufData + 128, (
char *)rotationMatrix.constData() + 12, 12);
2300 memcpy(ubufData + 144, (
char *)rotationMatrix.constData() + 24, 12);
2301 memcpy(ubufData + 160, &skyboxProperties, 16);
2302 memcpy(ubufData + 176, viewProjection.constData(), 64);
2303 dcd.ubuf->endFullDynamicBufferUpdateForCurrentFrame();
2308 entry->m_skyBoxSrbs[cubeFace] = rhiCtx->
srb(bindings);
2310 layer.skyBoxSrb = rhiCtx->
srb(bindings);
2329 rhiPrepareSkyBox_helper(rhiCtx, passKey,
layer, inCamera,
renderer);
2345 rhiPrepareSkyBox_helper(rhiCtx, passKey,
layer, inCamera,
renderer,
entry, cubeFace);
2360 static const auto rhiPrepareDepthPassForObject = [](
QSSGRhiContext *rhiCtx,
2372 if (isOpaqueDepthPrePass)
2376 if (
obj->type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset ||
obj->type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
2382 if (
obj->type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset) {
2387 if (shaderPipeline) {
2388 shaderPipeline->ensureCombinedMainLightsUniformBuffer(&dcd->
ubuf);
2395 }
else if (
obj->type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
2402 if (shaderPipeline) {
2403 shaderPipeline->ensureCombinedMainLightsUniformBuffer(&dcd->
ubuf);
2406 *inData.
camera,
nullptr,
nullptr);
2414 if (
obj->type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset ||
obj->type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
2419 ps->ia.bakeVertexInputLocations(*shaderPipeline, instanceBufferBinding);
2427 if (isOpaqueDepthPrePass) {
2429 shaderPipeline.get(),
2432 (
obj->type == QSSGRenderableObject::Type::CustomMaterialMeshSubset));
2457 ps.depthTestEnable =
true;
2458 ps.depthWriteEnable =
true;
2459 ps.targetBlend.colorWrite = {};
2462 if (!rhiPrepareDepthPassForObject(rhiCtx, passKey, inData,
handle.obj, rpDesc, &ps, ubufSel))
2467 if (!rhiPrepareDepthPassForObject(rhiCtx, passKey, inData,
handle.obj, rpDesc, &ps, ubufSel))
2478 bool *needsSetViewport)
2480 static const auto rhiRenderDepthPassForImp = [](
QSSGRhiContext *rhiCtx,
2483 bool *needsSetViewport) {
2484 for (
const auto &oh : objects) {
2488 if (
obj->type == QSSGRenderableObject::Type::DefaultMaterialMeshSubset ||
obj->type == QSSGRenderableObject::Type::CustomMaterialMeshSubset) {
2506 cb->setGraphicsPipeline(ps);
2507 cb->setShaderResources(srb);
2509 if (*needsSetViewport) {
2511 *needsSetViewport =
false;
2535 subsetRenderable->
material.profilingId}));
2540 rhiRenderDepthPassForImp(rhiCtx, pipelineState, sortedOpaqueObjects, needsSetViewport);
2541 rhiRenderDepthPassForImp(rhiCtx, pipelineState, sortedTransparentObjects, needsSetViewport);
2547 bool needsBuild =
false;
2549 if (!renderableTex->
texture) {
2554 qWarning(
"Depth texture not supported");
2565 qWarning(
"Failed to build depth texture (size %dx%d, format %d)",
2567 renderableTex->
reset();
2577 if (!renderableTex->
rt->
create()) {
2578 qWarning(
"Failed to build render target for depth texture");
2579 renderableTex->
reset();
QSSGRhiRenderableTexture rhiDepthTexture
bool testBit(qsizetype i) const
Returns true if the bit at index position i is 1; otherwise returns false.
void setBit(qsizetype i)
Sets the bit at index position i to 1.
constexpr bool testFlag(Enum flag) const noexcept
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
qsizetype size() const noexcept
const_iterator cend() const noexcept
void append(parameter_type t)
const_iterator cbegin() const noexcept
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
float * data()
Returns a pointer to the raw data of this matrix.
QMatrix4x4 inverted(bool *invertible=nullptr) const
Returns the inverse of this matrix.
QPoint map(const QPoint &point) const
Maps point by multiplying this matrix by point.
const float * constData() const
Returns a constant pointer to the raw data of this matrix.
static FeatureSet toFeatureSet(const T &ssgFeatureSet)
The QQuaternion class represents a quaternion consisting of a vector and scalar.
static QQuaternion fromEulerAngles(const QVector3D &eulerAngles)
static QQuaternion fromDirection(const QVector3D &direction, const QVector3D &up)
\inmodule QtCore\reentrant
constexpr void setWidth(qreal w) noexcept
Sets the width of the rectangle to the given finite width.
constexpr void setHeight(qreal h) noexcept
Sets the height of the rectangle to the given finite height.
virtual char * beginFullDynamicBufferUpdateForCurrentFrame()
virtual void endFullDynamicBufferUpdateForCurrentFrame()
To be called when the entire contents of the buffer data has been updated in the memory block returne...
virtual bool create()=0
Creates the corresponding native graphics resources.
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
void resourceUpdate(QRhiResourceUpdateBatch *resourceUpdates)
Sometimes committing resource updates is necessary or just more convenient without starting a render ...
void setPixelSize(const QSize &sz)
Sets the size (in pixels) to sz.
virtual bool create()=0
Creates the corresponding native graphics resources.
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Sets the QRhiRenderPassDescriptor desc for use with this render target.
void setName(const QByteArray &name)
Sets a name for the object.
void deleteLater()
When called without a frame being recorded, this function is equivalent to deleting the object.
Filter
Specifies the minification, magnification, or mipmap filtering.
void setDepthTexture(QRhiTexture *texture)
Sets the texture for depth-stencil.
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
virtual bool create()=0
Creates the corresponding native graphics resources.
virtual bool create()=0
Creates the corresponding native graphics resources.
Format
Specifies the texture format.
void setPixelSize(const QSize &sz)
Sets the texture size, specified in pixels, to sz.
QRhiBuffer * newBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size)
bool isClipDepthZeroToOne() const
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags={}) const
QMatrix4x4 clipSpaceCorrMatrix() const
bool isYUpInFramebuffer() const
bool isFeatureSupported(QRhi::Feature feature) const
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
bool isRecordingFrame() const
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
static constexpr QSSGRenderTextureCubeFace next(QSSGRenderTextureCubeFace face)
Class representing 3D range or axis aligned bounding box.
Q_ALWAYS_INLINE QVector3D dimensions() const
returns the dimensions (width/height/depth) of this axis aligned box.
Q_ALWAYS_INLINE float extents(quint32 axis) const
get component of the box's extents along a given axis
Q_ALWAYS_INLINE QSSGBoxPoints toQSSGBoxPointsNoEmptyCheck() const
void include(const QVector3D &v)
expands the volume to include v
Q_ALWAYS_INLINE bool isEmpty() const
QSSGRenderMesh * getMeshForPicking(const QSSGRenderModel &model) const
QMutex * meshUpdateMutex()
void rhiRenderRenderable(QSSGRhiContext *rhiCtx, QSSGSubsetRenderable &renderable, bool *needsSetViewport, int cubeFace, const QSSGRhiGraphicsPipelineState &state)
void updateUniformsForCustomMaterial(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, char *ubufData, QSSGRhiGraphicsPipelineState *ps, const QSSGRenderCustomMaterial &material, QSSGSubsetRenderable &renderable, const QSSGRenderCamera &camera, const QVector2D *depthAdjust, const QMatrix4x4 *alteredModelViewProjection)
void rhiPrepareRenderable(QSSGRhiGraphicsPipelineState *ps, QSSGPassKey passKey, QSSGSubsetRenderable &renderable, const QSSGShaderFeatures &featureSet, const QSSGRenderCustomMaterial &material, const QSSGLayerRenderData &layerData, QRhiRenderPassDescriptor *renderPassDescriptor, int samples, QSSGRenderCamera *camera=nullptr, int cubeFace=-1, QMatrix4x4 *modelViewProjection=nullptr, QSSGReflectionMapEntry *entry=nullptr)
QSSGRhiShaderPipelinePtr shadersForCustomMaterial(QSSGRhiGraphicsPipelineState *ps, const QSSGRenderCustomMaterial &material, QSSGSubsetRenderable &renderable, const QSSGShaderFeatures &featureSet)
QRhiTexture * getLightmapTexture(const QSSGModelContext &modelContext) const
QSSGShaderFeatures getShaderFeatures() const
const QSSGRenderReflectionMapPtr & getReflectionMapManager() const
QSSGRenderCamera * camera
QVarLengthArray< QSSGRenderPass *, 12 > activePasses
QRhiTexture * getBonemapTexture(const QSSGModelContext &modelContext) const
std::optional< QSSGLayerRenderPreparationResult > layerPrepResult
ScreenMapPass screenMapPass
DepthMapPass depthMapPass
const QSSGRenderShadowMapPtr & getShadowMapManager() const
std::optional< QSSGCameraRenderData > cameraData
static void rhiRenderRenderable(QSSGRhiContext *rhiCtx, QSSGParticlesRenderable &renderable, bool *needsSetViewport, int cubeFace, const QSSGRhiGraphicsPipelineState &state)
static void updateUniformsForParticleModel(QSSGRhiShaderPipeline &shaderPipeline, char *ubufData, const QSSGRenderModel *model, quint32 offset)
static void prepareParticlesForModel(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, QSSGRhiShaderResourceBindingList &bindings, const QSSGRenderModel *model)
static void rhiPrepareRenderable(QSSGRhiShaderPipeline &shaderPipeline, QSSGPassKey passKey, QSSGRhiContext *rhiCtx, QSSGRhiGraphicsPipelineState *ps, QSSGParticlesRenderable &renderable, const QSSGLayerRenderData &inData, QRhiRenderPassDescriptor *renderPassDescriptor, int samples, QSSGRenderCamera *camera=nullptr, int cubeFace=-1, QSSGReflectionMapEntry *entry=nullptr)
const std::unique_ptr< QSSGRhiContext > & rhiContext() const
const std::unique_ptr< QSSGProgramGenerator > & shaderProgramGenerator() const
const std::unique_ptr< QSSGCustomMaterialSystem > & customMaterialSystem() const
const std::shared_ptr< QSSGShaderLibraryManager > & shaderLibraryManager() const
const std::unique_ptr< QSSGBufferManager > & bufferManager() const
const std::unique_ptr< QSSGShaderCache > & shaderCache() const
QSSGReflectionMapEntry * reflectionMapEntry(int probeIdx)
QSSGShadowMapEntry * shadowMapEntry(int lightIdx)
void beginFrame(QSSGRenderLayer *layer)
bool prepareLayerForRender(QSSGRenderLayer &inLayer)
void endFrame(QSSGRenderLayer *layer)
void rhiRender(QSSGRenderLayer &inLayer)
static void setTonemapFeatures(QSSGShaderFeatures &features, QSSGRenderLayer::TonemapMode tonemapMode)
friend class QSSGLayerRenderData
bool isGlobalPickingEnabled() const
QSSGRhiShaderPipelinePtr getShaderPipelineForDefaultMaterial(QSSGSubsetRenderable &inRenderable, const QSSGShaderFeatures &inFeatureSet)
void beginLayerRender(QSSGLayerRenderData &inLayer)
static QSSGRhiShaderPipelinePtr generateRhiShaderPipelineImpl(QSSGSubsetRenderable &renderable, QSSGShaderLibraryManager &shaderLibraryManager, QSSGShaderCache &shaderCache, QSSGProgramGenerator &shaderProgramGenerator, QSSGShaderDefaultMaterialKeyProperties &shaderKeyProperties, const QSSGShaderFeatures &featureSet, QByteArray &shaderString)
void setRenderContextInterface(QSSGRenderContextInterface *ctx)
static void intersectRayWithSubsetRenderable(QSSGBufferManager &bufferManager, const QSSGRenderRay &inRay, const QSSGRenderNode &node, PickResultList &outIntersectionResultList)
bool rendererRequestsFrames() const
void setGlobalPickingEnabled(bool isEnabled)
QSSGShaderDefaultMaterialKeyProperties & defaultMaterialShaderKeyProperties()
PickResultList syncPickAll(const QSSGRenderLayer &layer, QSSGBufferManager &bufferManager, const QSSGRenderRay &ray)
void addMaterialDirtyClear(QSSGRenderGraphObject *material)
QSSGRhiCubeRenderer * rhiCubeRenderer()
static void getLayerHitObjectList(const QSSGRenderLayer &layer, QSSGBufferManager &bufferManager, const QSSGRenderRay &ray, bool inPickEverything, PickResultList &outIntersectionResult)
void rhiPrepare(QSSGRenderLayer &inLayer)
void cleanupResources(QList< QSSGRenderGraphObject * > &resources)
QSSGLayerGlobalRenderProperties getLayerGlobalRenderProperties()
QSSGLayerRenderData * getOrCreateLayerRenderData(QSSGRenderLayer &layer)
QSSGRenderPickResult syncPick(const QSSGRenderLayer &layer, QSSGBufferManager &bufferManager, const QSSGRenderRay &ray, QSSGRenderNode *target=nullptr)
QSSGRhiQuadRenderer * rhiQuadRenderer()
QSSGRenderContextInterface * contextInterface() const
static void intersectRayWithItem2D(const QSSGRenderRay &inRay, const QSSGRenderItem2D &item2D, PickResultList &outIntersectionResultList)
QRhiTexture * dummyTexture(QRhiTexture::Flags flags, QRhiResourceUpdateBatch *rub, const QSize &size=QSize(64, 64), const QColor &fillColor=Qt::black)
QRhiCommandBuffer * commandBuffer() const
static QRhiCommandBuffer::BeginPassFlags commonPassFlags()
QSSGRhiDrawCallData & drawCallData(const QSSGRhiDrawCallDataKey &key)
void checkAndAdjustForNPoT(QRhiTexture *texture, QSSGRhiSamplerDescription *samplerDescription)
QRhiShaderResourceBindings * srb(const QSSGRhiShaderResourceBindingList &bindings)
QRhiGraphicsPipeline * pipeline(const QSSGGraphicsPipelineStateKey &key, QRhiRenderPassDescriptor *rpDesc, QRhiShaderResourceBindings *srb)
QRhiSampler * sampler(const QSSGRhiSamplerDescription &samplerDescription)
void prepareCube(QSSGRhiContext *rhiCtx, QRhiResourceUpdateBatch *maybeRub)
void prepareQuad(QSSGRhiContext *rhiCtx, QRhiResourceUpdateBatch *maybeRub)
QRhiTexture * ssaoTexture() const
const QRhiShaderStage * fragmentStage() const
QRhiTexture * depthTexture() const
int bindingForTexture(const char *name, int hint=-1)
int extraTextureCount() const
const QRhiShaderStage * vertexStage() const
const QSSGRhiTexture & extraTextureAt(int index) const
QSSGRhiShaderPipelinePtr tryGetRhiShaderPipeline(const QByteArray &inKey, const QSSGShaderFeatures &inFeatures)
QSSGRhiShaderPipelinePtr newPipelineFromPregenerated(const QByteArray &inKey, const QSSGShaderFeatures &inFeatures, QQsbCollection::Entry entry, const QSSGRenderGraphObject &obj, QSSGRhiShaderPipeline::StageFlags stageFlags={})
QSSGRhiShaderPipelinePtr tryNewPipelineFromPersistentCache(const QByteArray &qsbcKey, const QByteArray &inKey, const QSSGShaderFeatures &inFeatures, QSSGRhiShaderPipeline::StageFlags stageFlags={})
QQsbCollection::EntryMap m_preGeneratedShaderEntries
const_iterator cend() const noexcept
const_iterator constFind(const T &value) const
iterator insert(const T &value)
QList< InOutVariable > combinedImageSamplers() const
QShaderDescription description() const
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
constexpr size_type size() const noexcept
const T & at(qsizetype idx) const
const_iterator cbegin() const noexcept
const_iterator cend() const noexcept
void push_back(const T &t)
iterator begin() noexcept
The QVector2D class represents a vector or vertex in 2D space.
The QVector3D class represents a vector or vertex in 3D space.
QVector3D normalized() const noexcept
Returns the normalized unit vector form of this vector.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr void setZ(float z) noexcept
Sets the z coordinate of this point to the given finite z coordinate.
static constexpr float dotProduct(QVector3D v1, QVector3D v2) noexcept
Returns the dot product of v1 and v2.
static constexpr QVector3D crossProduct(QVector3D v1, QVector3D v2) noexcept
Returns the cross-product of vectors v1 and v2, which is normal to the plane spanned by v1 and v2.
constexpr float z() const noexcept
Returns the z coordinate of this point.
The QVector4D class represents a vector or vertex in 4D space.
QSSGRhiRenderableTexture rhiAoTexture
QSSGRhiRenderableTexture rhiScreenTexture
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
void rhiRenderDepthPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps, const QVector< QSSGRenderableObjectHandle > &sortedOpaqueObjects, const QVector< QSSGRenderableObjectHandle > &sortedTransparentObjects, bool *needsSetViewport)
Q_QUICK3DRUNTIMERENDER_EXPORT void rhiRenderRenderable(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &state, QSSGRenderableObject &object, bool *needsSetViewport, int cubeFace=-1)
bool rhiPrepareScreenTexture(QSSGRhiContext *rhiCtx, const QSize &size, bool wantsMips, QSSGRhiRenderableTexture *renderableTex)
void rhiRenderShadowMap(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRhiGraphicsPipelineState &ps, QSSGRenderShadowMap &shadowMapManager, const QSSGRenderCamera &camera, const QSSGShaderLightList &globalLights, const QVector< QSSGRenderableObjectHandle > &sortedOpaqueObjects, QSSGRenderer &renderer, const QSSGBoxPoints &castingObjectsBox, const QSSGBoxPoints &receivingObjectsBox)
void rhiRenderReflectionMap(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGRhiGraphicsPipelineState *ps, QSSGRenderReflectionMap &reflectionMapManager, const QVector< QSSGRenderReflectionProbe * > &reflectionProbes, const QVector< QSSGRenderableObjectHandle > &reflectionPassObjects, QSSGRenderer &renderer)
bool rhiPrepareAoTexture(QSSGRhiContext *rhiCtx, const QSize &size, QSSGRhiRenderableTexture *renderableTex)
void rhiPrepareSkyBoxForReflectionMap(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderLayer &layer, QSSGRenderCamera &inCamera, QSSGRenderer &renderer, QSSGReflectionMapEntry *entry, int cubeFace)
Q_QUICK3DRUNTIMERENDER_EXPORT void rhiPrepareRenderable(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGRenderableObject &inObject, QRhiRenderPassDescriptor *renderPassDescriptor, QSSGRhiGraphicsPipelineState *ps, QSSGShaderFeatures featureSet, int samples, QSSGRenderCamera *inCamera=nullptr, QMatrix4x4 *alteredModelViewProjection=nullptr, int cubeFace=-1, QSSGReflectionMapEntry *entry=nullptr)
bool rhiPrepareDepthTexture(QSSGRhiContext *rhiCtx, const QSize &size, QSSGRhiRenderableTexture *renderableTex)
void rhiRenderAoTexture(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderer &renderer, QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiGraphicsPipelineState &ps, const SSAOMapPass::AmbientOcclusion &ao, const QSSGRhiRenderableTexture &rhiAoTexture, const QSSGRhiRenderableTexture &rhiDepthTexture, const QSSGRenderCamera &camera)
std::pair< QSSGBoxPoints, QSSGBoxPoints > calculateSortedObjectBounds(const QVector< QSSGRenderableObjectHandle > &sortedOpaqueObjects, const QVector< QSSGRenderableObjectHandle > &sortedTransparentObjects)
void rhiPrepareSkyBox(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderLayer &layer, QSSGRenderCamera &inCamera, QSSGRenderer &renderer)
bool rhiPrepareDepthPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, QSSGLayerRenderData &inData, const QVector< QSSGRenderableObjectHandle > &sortedOpaqueObjects, const QVector< QSSGRenderableObjectHandle > &sortedTransparentObjects, QSSGRhiDrawCallDataKey::Selector ubufSel, int samples)
void rhiPrepareGrid(QSSGRhiContext *rhiCtx, QSSGRenderLayer &layer, QSSGRenderCamera &inCamera, QSSGRenderer &renderer)
QVector3D Q_QUICK3DUTILS_EXPORT transform(const QMatrix4x4 &m, const QVector3D &v)
static const int UBUF_SIZE
#define QByteArrayLiteral(str)
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
constexpr float qRadiansToDegrees(float radians)
constexpr float qDegreesToRadians(float degrees)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLsizei const GLfloat * v
[13]
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
const void GLsizei GLsizei stride
GLint GLsizei GLsizei GLenum format
GLfixed GLfixed GLint GLint GLfixed points
GLenum GLenum GLenum GLenum GLenum scale
const void GLsizei GLsizei GLint vertexBufferCount
#define Q_QUICK3D_PROFILE_START(Type)
#define Q_QUICK3D_PROFILE_END_WITH_ID(Type, Payload, POID)
#define QSSG_RENDERPASS_NAME(passName, level, face)
#define Q_QUICK3D_PROFILE_END_WITH_STRING(Type, Payload, Str)
#define Q_QUICK3D_PROFILE_END_WITH_IDS(Type, Payload, POIDs)
#define QSSG_ASSERT(cond, action)
std::array< QVector3D, 8 > QSSGBoxPoints
QSSGDataView< T > toDataView(const T &type)
static constexpr QSSGRenderTextureCubeFace QSSGRenderTextureCubeFaces[]
QSSGRenderTextureCubeFace
static void cleanupResourcesImpl(const QSSGRenderContextInterface &rci, const Container &resources)
static QSSGBounds3 calculateShadowCameraBoundingBox(const QSSGBoxPoints &points, const QVector3D &forward, const QVector3D &up, const QVector3D &right)
static const QRhiShaderResourceBinding::StageFlags RENDERER_VISIBILITY_ALL
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 setupCameraForShadowMap(const QSSGRenderCamera &inCamera, const QSSGRenderLight *inLight, QSSGRenderCamera &theCamera, const QSSGBoxPoints &castingBox, const QSSGBoxPoints &receivingBox)
static void dfs(const QSSGRenderNode &node, RenderableList &renderables)
static void setupCubeReflectionCameras(const QSSGRenderReflectionProbe *inProbe, QSSGRenderCamera inCameras[6])
static QVector3D calcCenter(const QSSGBoxPoints &vertices)
static void addDepthTextureBindings(QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRhiShaderResourceBindingList &bindings)
static void addOpaqueDepthPrePassBindings(QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRenderableImage *renderableImage, QSSGRhiShaderResourceBindingList &bindings, bool isCustomMaterialMeshSubset=false)
static constexpr float QSSG_HALFPI
static QSSGRhiShaderPipelinePtr shadersForDefaultMaterial(QSSGRhiGraphicsPipelineState *ps, QSSGSubsetRenderable &subsetRenderable, const QSSGShaderFeatures &featureSet)
static QSSGRhiShaderPipelinePtr shadersForParticleMaterial(QSSGRhiGraphicsPipelineState *ps, QSSGParticlesRenderable &particleRenderable)
static void setupCubeShadowCameras(const QSSGRenderLight *inLight, QSSGRenderCamera inCameras[6])
static QSSGBoxPoints computeFrustumBounds(const QSSGRenderCamera &inCamera)
static constexpr float QSSG_PI
static QByteArray logPrefix()
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 updateUniformsForDefaultMaterial(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, char *ubufData, QSSGRhiGraphicsPipelineState *ps, QSSGSubsetRenderable &subsetRenderable, const QSSGRenderCamera &camera, const QVector2D *depthAdjust, const QMatrix4x4 *alteredModelViewProjection)
static void fillTargetBlend(QRhiGraphicsPipeline::TargetBlend *targetBlend, QSSGRenderDefaultMaterial::MaterialBlendMode materialBlend)
#define QSSGRHICTX_STAT(ctx, f)
std::shared_ptr< QSSGRhiShaderPipeline > QSSGRhiShaderPipelinePtr
QRhiSampler::Filter toRhi(QSSGRenderTextureFilterOp op)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define Q_TRACE_SCOPE(x,...)
unsigned long long quint64
QSqlQueryModel * model
[16]
myFilter draw(painter, QPoint(0, 0), originalPixmap)
QSvgRenderer * renderer
[0]
QByteArray generateSha() const
static QSSGGraphicsPipelineStateKey create(const QSSGRhiGraphicsPipelineState &state, const QRhiRenderPassDescriptor *rpDesc, const QRhiShaderResourceBindings *srb)
struct QSSGGraphicsPipelineStateKey::@759 extra
QVector< quint32 > renderTargetDescription
size_t renderTargetDescriptionHash
const QSSGCameraRenderData & cameraData
const QSSGRenderLayer & layer
static QSSGRhiShaderPipelinePtr generateMaterialRhiShader(const QByteArray &inShaderKeyPrefix, QSSGMaterialVertexPipeline &vertexGenerator, const QSSGShaderDefaultMaterialKey &key, QSSGShaderDefaultMaterialKeyProperties &inProperties, const QSSGShaderFeatures &inFeatureSet, const QSSGRenderGraphObject &inMaterial, const QSSGShaderLightListView &inLights, QSSGRenderableImage *inFirstImage, QSSGShaderLibraryManager &shaderLibraryManager, QSSGShaderCache &theCache)
static const char * getSamplerName(QSSGRenderableImage::Type type)
static void setRhiMaterialProperties(const QSSGRenderContextInterface &, QSSGRhiShaderPipeline &shaders, char *ubufData, QSSGRhiGraphicsPipelineState *inPipelineState, const QSSGRenderGraphObject &inMaterial, const QSSGShaderDefaultMaterialKey &inKey, QSSGShaderDefaultMaterialKeyProperties &inProperties, const QSSGRenderCamera &inCamera, const QMatrix4x4 &inModelViewProjection, const QMatrix3x3 &inNormalMatrix, const QMatrix4x4 &inGlobalTransform, const QMatrix4x4 &clipSpaceCorrMatrix, const QMatrix4x4 &localInstanceTransform, const QMatrix4x4 &globalInstanceTransform, const QSSGDataView< float > &inMorphWeights, QSSGRenderableImage *inFirstImage, float inOpacity, const QSSGLayerGlobalRenderProperties &inRenderProperties, const QSSGShaderLightListView &inLights, const QSSGShaderReflectionProbe &reflectionProbe, bool receivesShadows, bool receivesReflections, const QVector2D *shadowDepthAdjust, QRhiTexture *lightmapTexture)
QMatrix4x4 modelViewProjection
const QSSGRenderModel & model
const QSSGRenderParticles & particles
QVarLengthArray< QRhiTextureRenderTarget *, 6 > m_rhiRenderTargets
QSSGRenderReflectionProbe::ReflectionTimeSlicing m_timeSlicing
QVarLengthArray< QRhiShaderResourceBindings *, 6 > m_skyBoxSrbs
QRhiRenderPassDescriptor * m_rhiRenderPassDesc
void renderMips(QSSGRhiContext *context)
QMatrix4x4 m_viewProjection
QRhiRenderBuffer * m_rhiDepthStencil
QSSGRenderTextureCubeFace m_timeSliceFace
void calculateViewProjectionMatrix(QMatrix4x4 &outMatrix) const
void calculateViewProjectionWithoutTranslation(float near, float far, QMatrix4x4 &outMatrix) const
QSSGCameraGlobalCalculationResult calculateGlobalVariables(const QRectF &inViewport)
void lookAt(const QVector3D &inCameraPos, const QVector3D &inUpDir, const QVector3D &inTargetPos, const QVector3D &pivot)
QSSGCullFaceMode m_cullMode
QSSGShaderMaterialAdapter * adapter
QSSGCullFaceMode cullMode
QSSGRenderDefaultMaterial::MaterialBlendMode blendMode
static Q_REQUIRED_RESULT constexpr bool isRenderable(Type type) Q_DECL_NOTHROW
QSSGRenderImageTextureFlags m_flags
QSSGRenderTextureFilterOp m_mipFilterType
QSSGRenderTextureCoordOp m_horizontalTilingMode
QSSGRenderTextureFilterOp m_minFilterType
QSSGRenderTextureCoordOp m_verticalTilingMode
QSSGRenderTextureFilterOp m_magFilterType
QMatrix3x3 probeOrientation
QSSGRenderImage * lightProbe
QSSGLayerRenderData * renderData
QSSGRenderLayer::Background background
QVector< QSSGRenderSubset > subsets
int instanceCount() const
QSSGRenderInstanceTable * instanceTable
static constexpr QVector3D initScale
QVector3D getDirection() const
QMatrix4x4 globalTransform
QVector3D getScalingCorrectDirection() const
static QMatrix4x4 calculateTransformMatrix(QVector3D position, QVector3D scale, QVector3D pivot, QQuaternion rotation)
QMatrix4x4 localTransform
QVector3D getGlobalPos() const
QSSGRenderParticles::FeatureLevel m_featureLevel
static void intersectWithBVH(const RayData &data, const QSSGMeshBVHNode *bvh, const QSSGRenderMesh *mesh, QVector< IntersectionResult > &intersections, int depth=0)
static IntersectionResult createIntersectionResult(const RayData &data, const HitResult &hit)
static RayData createRayData(const QMatrix4x4 &globalTransform, const QSSGRenderRay &ray)
static HitResult intersectWithAABBv2(const RayData &data, const QSSGBounds3 &bounds)
QSSGRhiBufferPtr indexBuffer
QSSGRhiInputAssemblerState ia
quint32 lodOffset(int lodLevel) const
quint32 lodCount(int lodLevel) const
QRhiTexture * targetsTexture
QSSGRhiBufferPtr vertexBuffer
struct QSSGRenderSubset::@751 rhi
QSSGRenderImageTexture m_texture
QSSGRenderableImage * m_nextImage
const QSSGRenderImage & m_imageNode
bool receivesReflections() const
bool receivesShadows() const
bool castsShadows() const
bool rendersWithLightmap() const
const QSSGBounds3 & bounds
const QMatrix4x4 & globalTransform
QSSGRenderableObjectFlags renderableFlags
QSSGDepthDrawMode depthWriteMode
QSSGRhiShaderResourceBindingList bindings
QSSGRhiGraphicsPipelineState ps
QRhiShaderResourceBindings * srb
QVector< quint32 > renderTargetDescription
QRhiGraphicsPipeline * pipeline
size_t renderTargetDescriptionHash
QSSGRhiInputAssemblerState ia
QRhiGraphicsPipeline::CullMode cullMode
static QRhiGraphicsPipeline::CullMode toCullMode(QSSGCullFaceMode cullFaceMode)
QRhiGraphicsPipeline::TargetBlend targetBlend
const QSSGRhiShaderPipeline * shaderPipeline
QRhiTextureRenderTarget * rt
QRhiRenderPassDescriptor * rpDesc
QRhiRenderBuffer * depthStencil
void addUniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size)
void addTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
QRhiTexture * shadowMapTexture
QByteArray shadowMapTextureUniformName
QSSGShaderKeyBoolean m_blendParticles
void toString(QByteArray &ioString, const QSSGShaderDefaultMaterialKeyProperties &inProperties) const
constexpr bool isSet(Feature feature) const
void set(Feature feature, bool val)
void disableTonemapping()
bool getValue(QSSGDataView< quint32 > inDataStore) const
QMatrix4x4 m_lightVP
light view projection matrix
QRhiTexture * m_rhiDepthCopy
QRhiTexture * m_rhiCubeCopy
QRhiTexture * m_rhiDepthMap
QRhiRenderPassDescriptor * m_rhiRenderPassDesc
QVarLengthArray< QRhiTextureRenderTarget *, 6 > m_rhiRenderTargets
QRhiRenderBuffer * m_rhiDepthStencil
QMatrix4x4 m_lightCubeView[6]
light cubemap view matrices
QRhiTexture * m_rhiDepthCube
QMatrix4x4 m_lightView
light view transform
QRhiGraphicsPipeline * pipeline
bool prepareInstancing(QSSGRhiContext *rhiCtx, const QVector3D &cameraDirection, const QVector3D &cameraPosition, float minThreshold, float maxThreshold)
quint32 subsetLevelOfDetail
const QSSGShaderLightListView & lights
struct QSSGSubsetRenderable::@762 rhiRenderData
QSSGShaderReflectionProbe reflectionProbe
struct QSSGSubsetRenderable::@762::@763 mainPass
const QSSGRenderSubset & subset
struct QSSGSubsetRenderable::@762::@764 depthPrePass
struct QSSGSubsetRenderable::@762::@766 reflectionPass
struct QSSGSubsetRenderable::@762::@765 shadowPass
QRhiShaderResourceBindings * srb
QRhiBuffer * instanceBuffer
const QSSGRenderCustomMaterial & customMaterial() const
QSSGShaderDefaultMaterialKey shaderDescription
QSSGRenderableImage * firstImage
const QSSGRenderDefaultMaterial & defaultMaterial() const
const QSSGModelContext & modelContext
const QSSGRenderGraphObject & material