Skip to content

Commit

Permalink
Add preferredShaderLanguage option to Engine::Config (#7816)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed May 6, 2024
1 parent e855f4a commit a1752b3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEW_RELEASE_NOTES.md
Expand Up @@ -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 changes: 22 additions & 0 deletions filament/include/filament/Engine.h
Expand Up @@ -340,6 +340,28 @@ class UTILS_PUBLIC Engine {
* 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;
};


Expand Down
4 changes: 4 additions & 0 deletions filament/src/details/Engine.h
Expand Up @@ -246,6 +246,10 @@ class FEngine : public Engine {
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 };
}
}
Expand Down

0 comments on commit a1752b3

Please sign in to comment.