From 60cebec51a421b7c880e2659d8203227d9a6d2f6 Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Thu, 17 Oct 2024 22:15:09 +0000 Subject: [PATCH 1/2] Add a warning for FRenderableManager In some cases, users set materials first without providing render primitives, which has incurred the attribute mismatching warning. This isn't helpful because users don't know what action they should take to remove the warning. Add a more specific warning for this case with which users know the direct cause and what to do to remove the warning. BUGS=[372755205] --- filament/src/components/RenderableManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/filament/src/components/RenderableManager.cpp b/filament/src/components/RenderableManager.cpp index 35abe8d947d..68b649ced9b 100644 --- a/filament/src/components/RenderableManager.cpp +++ b/filament/src/components/RenderableManager.cpp @@ -807,7 +807,11 @@ void FRenderableManager::setMaterialInstanceAt(Instance instance, uint8_t level, primitives[primitiveIndex].setMaterialInstance(mi); AttributeBitset const required = material->getRequiredAttributes(); AttributeBitset const declared = primitives[primitiveIndex].getEnabledAttributes(); - if (UTILS_UNLIKELY((declared & required) != required)) { + if (!primitives[primitiveIndex].getHwHandle()) { + slog.w << "[instance=" << instance.asValue() << ", primitive @ " << primitiveIndex + << "] render primitive doesn't exist for material \"" + << material->getName().c_str_safe() << "\"" << io::endl; + } else if (UTILS_UNLIKELY((declared & required) != required)) { slog.w << "[instance=" << instance.asValue() << ", primitive @ " << primitiveIndex << "] missing required attributes (" << required << "), declared=" << declared << io::endl; From 726dfa9724f9f84bd406580c366ecce7985fe002 Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Fri, 18 Oct 2024 09:11:21 -0700 Subject: [PATCH 2/2] feedback --- filament/src/components/RenderableManager.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/filament/src/components/RenderableManager.cpp b/filament/src/components/RenderableManager.cpp index 68b649ced9b..8dfd56b449c 100644 --- a/filament/src/components/RenderableManager.cpp +++ b/filament/src/components/RenderableManager.cpp @@ -807,11 +807,10 @@ void FRenderableManager::setMaterialInstanceAt(Instance instance, uint8_t level, primitives[primitiveIndex].setMaterialInstance(mi); AttributeBitset const required = material->getRequiredAttributes(); AttributeBitset const declared = primitives[primitiveIndex].getEnabledAttributes(); - if (!primitives[primitiveIndex].getHwHandle()) { - slog.w << "[instance=" << instance.asValue() << ", primitive @ " << primitiveIndex - << "] render primitive doesn't exist for material \"" - << material->getName().c_str_safe() << "\"" << io::endl; - } else if (UTILS_UNLIKELY((declared & required) != required)) { + // Print the warning only when the handle is available. Otherwise this may end up + // emitting many invalid warnings as the `declared` bitset is not populated yet. + bool const isPrimitiveInitialized = !!primitives[primitiveIndex].getHwHandle(); + if (UTILS_UNLIKELY(isPrimitiveInitialized && (declared & required) != required)) { slog.w << "[instance=" << instance.asValue() << ", primitive @ " << primitiveIndex << "] missing required attributes (" << required << "), declared=" << declared << io::endl;