From 2456299337f2205db5c1dd038213a46679b4cd77 Mon Sep 17 00:00:00 2001 From: Sungun Park Date: Sun, 20 Oct 2024 08:08:13 -0700 Subject: [PATCH] Add a warning for FRenderableManager (#8210) 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. Emit the warning only when the primitive handle is initialized so the AttributeBitset is properly populated. BUGS=[372755205] --- filament/src/components/RenderableManager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/filament/src/components/RenderableManager.cpp b/filament/src/components/RenderableManager.cpp index 35abe8d947d..8dfd56b449c 100644 --- a/filament/src/components/RenderableManager.cpp +++ b/filament/src/components/RenderableManager.cpp @@ -807,7 +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 (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;