From 58aa74b4aee3ac87dcfe52ec151c3f9c3cb510ec Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 4 Oct 2024 11:14:24 -0700 Subject: [PATCH] cleanup code so it's easier to understand this should make it clearer how we set the per primitive variant when SSR and shadowin is involved --- filament/src/RenderPass.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/filament/src/RenderPass.cpp b/filament/src/RenderPass.cpp index bec8e313275..dd0dd262617 100644 --- a/filament/src/RenderPass.cpp +++ b/filament/src/RenderPass.cpp @@ -655,12 +655,18 @@ RenderPass::Command* RenderPass::generateCommandsImpl(RenderPass::CommandTypeFla bool const hasSkinning = soaVisibility[i].skinning; bool const hasSkinningOrMorphing = hasSkinning || hasMorphing; - // if we are already an SSR variant, the SRE bit is already set, - // there is no harm setting it again + // if we are already an SSR variant, the SRE bit is already set static_assert(Variant::SPECIAL_SSR & Variant::SRE); - Variant renderableVariant = variant; - renderableVariant.setShadowReceiver( - Variant::isSSRVariant(variant) || (soaVisibility[i].receiveShadows & hasShadowing)); + Variant renderableVariant{ variant }; + + // we can't have SSR and shadowing together by construction + bool const isSsrVariant = Variant::isSSRVariant(variant); + assert_invariant((isSsrVariant && !hasShadowing) || !isSsrVariant); + if (!isSsrVariant) { + // set the SRE variant, unless we're in SSR mode + renderableVariant.setShadowReceiver(soaVisibility[i].receiveShadows && hasShadowing); + } + renderableVariant.setSkinning(hasSkinningOrMorphing); FRenderableManager::SkinningBindingInfo const& skinning = soaSkinning[i];