From c4f083cfba41244c33eaff5c074dcf5ea07e04c8 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 5 Sep 2025 13:31:03 -0700 Subject: [PATCH] matc and MaterialBuilder workaround options NONE by default The workaround option is now set to none by default. Use ``` matc -Wall ``` if you want to restore the previous behavior. Current material workarounds: - remove MergeReturnPass (except on Metal) - remove SimplificationPass (except on Metal) There are reason to believe these workarounds are no longer needed, due to changes in spirv-opt. It's possible that older devices might still need them. These workaround affect *all* devices, this is why it is important to disable them if not needed. --- NEW_RELEASE_NOTES.md | 1 + libs/filamat/include/filamat/MaterialBuilder.h | 2 +- libs/filamat/src/GLSLPostProcessor.cpp | 17 ++++++++++++++++- .../include/filament-matp/Config.h | 2 +- tools/matc/src/matc/CommandlineConfig.cpp | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/NEW_RELEASE_NOTES.md b/NEW_RELEASE_NOTES.md index 68a3814f05..50e3b97e93 100644 --- a/NEW_RELEASE_NOTES.md +++ b/NEW_RELEASE_NOTES.md @@ -12,3 +12,4 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md). available on Metal). Non-Metal backends can use the callback to be notified when Filament has finished processing a frame on the CPU. - materials: added `getEyeFromViewMatrix()` for vertex shader [⚠️ **Recompile Materials**] +- matc: make `--workarounds=none` the default [**Recompile Materials to take effect**] diff --git a/libs/filamat/include/filamat/MaterialBuilder.h b/libs/filamat/include/filamat/MaterialBuilder.h index 7b0ca3c111..004b16dca0 100644 --- a/libs/filamat/include/filamat/MaterialBuilder.h +++ b/libs/filamat/include/filamat/MaterialBuilder.h @@ -146,7 +146,7 @@ protected: Platform mPlatform = Platform::DESKTOP; TargetApi mTargetApi = (TargetApi) 0; Optimization mOptimization = Optimization::PERFORMANCE; - Workarounds mWorkarounds = Workarounds::ALL; + Workarounds mWorkarounds = Workarounds::NONE; bool mPrintShaders = false; bool mSaveRawVariants = false; bool mGenerateDebugInfo = false; diff --git a/libs/filamat/src/GLSLPostProcessor.cpp b/libs/filamat/src/GLSLPostProcessor.cpp index f8745a464d..06ea410673 100644 --- a/libs/filamat/src/GLSLPostProcessor.cpp +++ b/libs/filamat/src/GLSLPostProcessor.cpp @@ -1051,7 +1051,6 @@ void GLSLPostProcessor::fixupClipDistance( void GLSLPostProcessor::registerPerformancePasses(Optimizer& optimizer, Config const& config) { auto RegisterPass = [&](Optimizer::PassToken&& pass, MaterialBuilder::TargetApi apiFilter = MaterialBuilder::TargetApi::ALL) { - // Workaround management is currently very simple, only two values are possible // ALL and NONE. If the value is anything but NONE, we apply all workarounds. if (config.workarounds != MaterialBuilderBase::Workarounds::NONE) { @@ -1060,6 +1059,22 @@ void GLSLPostProcessor::registerPerformancePasses(Optimizer& optimizer, Config c } } + // FIXME: Workaround within a workaround!!! We IGNORE config.workarounds for WEBGPU + // because Tint doesn't even compile with MergeReturn/Simplification pass + // active: + // Tint Reader Error: warning: code is unreachable + // error: no matching overload for 'operator << (i32, i32)' + // 2 candidate operators: + // • 'operator << (T ✓ , u32 ✗ ) -> T' where: + // ✓ 'T' is 'abstract-int', 'i32' or 'u32' + // • 'operator << (vecN ✗ , vecN ✗ ) -> vecN' where: + // ✗ 'T' is 'abstract-int', 'i32' or 'u32' + if (any(config.targetApi & MaterialBuilder::TargetApi::WEBGPU)) { + if (!(config.targetApi & apiFilter)) { + return; + } + } + optimizer.RegisterPass(std::move(pass)); }; diff --git a/libs/filament-matp/include/filament-matp/Config.h b/libs/filament-matp/include/filament-matp/Config.h index 7a8f1941e5..b40e113d61 100644 --- a/libs/filament-matp/include/filament-matp/Config.h +++ b/libs/filament-matp/include/filament-matp/Config.h @@ -171,7 +171,7 @@ protected: StringReplacementMap mTemplateMap; StringReplacementMap mMaterialParameters; filament::UserVariantFilterMask mVariantFilter = 0; - Workarounds mWorkarounds = Workarounds::ALL; + Workarounds mWorkarounds = Workarounds::NONE; bool mIncludeEssl1 = true; }; diff --git a/tools/matc/src/matc/CommandlineConfig.cpp b/tools/matc/src/matc/CommandlineConfig.cpp index 6bc3d30465..b77f4e4d73 100644 --- a/tools/matc/src/matc/CommandlineConfig.cpp +++ b/tools/matc/src/matc/CommandlineConfig.cpp @@ -146,7 +146,7 @@ static void usage(char* name) { " ssr (screen-space reflections), stereo\n" " This variant filter is merged with the filter from the material, if any\n\n" " --workarounds, -W\n" - " Workarounds to apply: all or none. (default is all).\n\n" + " Workarounds to apply: all or none. (default is none).\n\n" " --version, -v\n" " Print the material version number\n\n" "Internal use and debugging only:\n"