aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInho Lee <inho.lee@qt.io>2024-03-15 10:47:44 +0100
committerInho Lee <inho.lee@qt.io>2024-03-25 15:56:20 +0100
commita6f23f40534d796ca549ca179a02bd4906d60f44 (patch)
tree2bc4d0729535f6542d196b6e874fb5a05a8723a4
parent9a930be878be4bfafee6b7961f77087ea6232f43 (diff)
Skinning: check the type of the joint indices6.6
Joint indices are normally used as integer, Qt just defined it as float only if the rhi backend could not support integer attributes. However now it will be followed by the model definition. Instead, if the rhi backend could not support it, a warning will be generated. Fixes: QTBUG-123316 Pick-to: 6.5 Change-Id: I6dc8b6ef863e8601d2874feaa05c21cb7b9e4a86 Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io> (cherry picked from commit 1c981cd280189d099f01973900cec27f77921100) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit a694e036cc15a938e6782933cde65d0eedb4db98) Reviewed-by: Inho Lee <inho.lee@qt.io>
-rw-r--r--src/runtimerender/rendererimpl/qssglayerrenderdata.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp b/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp
index 5f972a6e..5ae54457 100644
--- a/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp
+++ b/src/runtimerender/rendererimpl/qssglayerrenderdata.cpp
@@ -1243,6 +1243,18 @@ bool QSSGLayerRenderData::prepareModelsForRender(const RenderableNodeEntries &re
if (maybeDebugDraw && debugDrawSystem->isEnabled(QSSGDebugDrawSystem::Mode::MeshLodNormal))
debugDrawSystem->debugNormals(*bufferManager, theModelContext, theSubset, subsetLevelOfDetail, (theModelCenter - camera->getGlobalPos()).length() * 0.01);
+ static auto checkF32TypeIndex = [&rhiCtx](QRhiVertexInputAttribute::Format f) {
+ if ((f == QRhiVertexInputAttribute::Format::Float4)
+ || (f == QRhiVertexInputAttribute::Format::Float3)
+ || (f == QRhiVertexInputAttribute::Format::Float2)
+ || (f == QRhiVertexInputAttribute::Format::Float)) {
+ return true;
+ }
+ if (!rhiCtx->rhi()->isFeatureSupported(QRhi::IntAttributes))
+ qWarning() << "WARN: Model has non-integer type indices for skinning but current RHI backend doesn't support it!";
+ return false;
+ };
+
if (theMaterialObject->type == QSSGRenderGraphObject::Type::DefaultMaterial ||
theMaterialObject->type == QSSGRenderGraphObject::Type::PrincipledMaterial ||
theMaterialObject->type == QSSGRenderGraphObject::Type::SpecularGlossyMaterial) {
@@ -1261,8 +1273,11 @@ bool QSSGLayerRenderData::prepareModelsForRender(const RenderableNodeEntries &re
const auto boneCount = model.skin ? model.skin->boneCount :
model.skeleton ? model.skeleton->boneCount : 0;
renderer->defaultMaterialShaderKeyProperties().m_boneCount.setValue(theGeneratedKey, boneCount);
- renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue(
- theGeneratedKey, !rhiCtx->rhi()->isFeatureSupported(QRhi::IntAttributes));
+ if (auto idJoint = theSubset.rhi.ia.inputs.indexOf(QSSGRhiInputAssemblerState::JointSemantic); idJoint != -1) {
+ const auto attr = theSubset.rhi.ia.inputLayout.attributeAt(idJoint);
+ renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue(theGeneratedKey, checkF32TypeIndex(attr->format()));
+ }
+
// Instancing
renderer->defaultMaterialShaderKeyProperties().m_usesInstancing.setValue(theGeneratedKey, usesInstancing);
// Morphing
@@ -1319,8 +1334,10 @@ bool QSSGLayerRenderData::prepareModelsForRender(const RenderableNodeEntries &re
const auto boneCount = model.skin ? model.skin->boneCount :
model.skeleton ? model.skeleton->boneCount : 0;
renderer->defaultMaterialShaderKeyProperties().m_boneCount.setValue(theGeneratedKey, boneCount);
- renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue(
- theGeneratedKey, !rhiCtx->rhi()->isFeatureSupported(QRhi::IntAttributes));
+ if (auto idJoint = theSubset.rhi.ia.inputs.indexOf(QSSGRhiInputAssemblerState::JointSemantic); idJoint != -1) {
+ const auto attr = theSubset.rhi.ia.inputLayout.attributeAt(idJoint);
+ renderer->defaultMaterialShaderKeyProperties().m_usesFloatJointIndices.setValue(theGeneratedKey, checkF32TypeIndex(attr->format()));
+ }
// Instancing
bool usesInstancing = theModelContext.model.instancing()