Add preferredShaderLanguage option to Engine::Config (#7816)

This commit is contained in:
Ben Doherty
2024-05-06 12:12:38 -07:00
committed by GitHub
parent e855f4aafb
commit a1752b363c
3 changed files with 27 additions and 0 deletions
+1
View File
@@ -8,5 +8,6 @@ appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
## Release notes for next branch cut
- filagui: Fix regression which broke WebGL
- Add a new Engine::Config setting to control preferred shader language
- Add `getEyeIndex` vertex API
- ios: Remove bitcode from iOS builds
+22
View File
@@ -340,6 +340,28 @@ public:
* Disable backend handles use-after-free checks.
*/
bool disableHandleUseAfterFreeCheck = false;
/*
* Sets a preferred shader language for Filament to use.
*
* The Metal backend supports two shader languages: MSL (Metal Shading Language) and
* METAL_LIBRARY (precompiled .metallib). This option controls which shader language is
* used when materials contain both.
*
* By default, when preferredShaderLanguage is unset, Filament will prefer METAL_LIBRARY
* shaders if present within a material, falling back to MSL. Setting
* preferredShaderLanguage to ShaderLanguage::MSL will instead instruct Filament to check
* for the presence of MSL in a material first, falling back to METAL_LIBRARY if MSL is not
* present.
*
* When using a non-Metal backend, setting this has no effect.
*/
enum class ShaderLanguage {
DEFAULT = 0,
MSL = 1,
METAL_LIBRARY = 2,
};
ShaderLanguage preferredShaderLanguage = ShaderLanguage::DEFAULT;
};
+4
View File
@@ -246,6 +246,10 @@ public:
case Backend::VULKAN:
return { backend::ShaderLanguage::SPIRV };
case Backend::METAL:
const auto& lang = mConfig.preferredShaderLanguage;
if (lang == Config::ShaderLanguage::MSL) {
return { backend::ShaderLanguage::MSL, backend::ShaderLanguage::METAL_LIBRARY };
}
return { backend::ShaderLanguage::METAL_LIBRARY, backend::ShaderLanguage::MSL };
}
}