Uniform buffer loads fail on Metal backend on Intel GPUs #7588
Labels
gpu specific
This bug occurs only with a single GPU vendor.
macos
Issue/feature request for macOS only
Describe the bug
There are visible shadow artifacts when using the Metal backend with Intel GPUs. Based on our investigations the root cause is that uniform buffer loads sometimes fail. I could repro it on tag v1.49.0 but on current
main
too.To Reproduce
Just run gltf_viewer sample with
FILAMENT_FORCE_INTEGRATED_GPU=1
on a device which has Intel GPU (default view settings).Expected behavior
No visual artifacts.
Screenshots
https://github.com/google/filament/assets/12460850/8783e405-9dd4-4d4f-91c4-4a4cd0a91dfd
Logs
The actual log is spammed with warnings because SPIRV-Cross generates unused variables in Metal shaders. I hope this is enough:
Desktop (please complete the following information):
Additional context
Here's a screenshot of an Xcode frame capture of gltf_viewer sample with the DamagedHelmet model. This is a draw call from the shadow pass.
initObjectUniforms()
can see the per-renderable UBO (see highlighted variables at the bottom) but the thread local variables (e.g.object_uniforms_worldFromModelNormalMatrix
) contain zeros at the end of the function. This is not the only affected draw call, only the first of them. Here it's related to the UBO containing an array, so settingFILAMENT_HAS_FEATURE_INSTANCING
to false fixes this particular draw call, but the issue reappears around SSAO.The currently accessible Metal Feature Set Tables says Mac2 family GPUs use 32 byte alignment (see Minimum constant buffer offset alignment) but Apple originally recommended 256, they just changed it ~2 years ago (I can attach the old Metal Feature Set Tables.pdf, if interested). Filament uses 32 bytes too for Mac2 GPUs. We were suspecting UBO alignment issues but setting
METAL_CONSTANT_BUFFER_OFFSET_ALIGNMENT
to 256 doesn't help.Any ideas what could this be?
The text was updated successfully, but these errors were encountered: