google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.76k stars 1.89k forks source link

METAL backend visual corruption with ClearOptions::clear=false #8229

Open emezeske opened 5 hours ago

emezeske commented 5 hours ago

Describe the bug On the METAL backend, various weird screen corruption occurs if ClearOptions::clear = false.

For whatever reason, it is very easy to reproduce in my app, but it is also possible to get gltf_viewer to do weird things.

Here's a video showing the corruption in my app: https://youtu.be/1Nca9RJ3Ucg.

To Reproduce Steps to reproduce the behavior:

  1. On MacOS with the METAL backend
  2. Edit filament/libs/viewer/src/Settings.cpp, change renderer->setClearOptions() to set .clear = false (line 640)
  3. Build and run gltf_viewer
  4. Play around with settings until corruption happens.
  5. For me, I found I could reliably get corruption with Dithering=true Bloom=true Screen-space-guard=true BloomThreshold=false
  6. Also cranking up the bloom amount, you can sometimes then rotate the camera until weird corruption occurs

Expected behavior There should not be any visual corruption, particularly when there's a skybox.

I understand that there is corruption behind the imgui menus -- that's not what I'm talking about. It's corruption in the 3D view, with white boxes appearing, or with the bloom flickering in weird ways.

Screenshots If applicable, add screenshots to help explain your problem.

Here's an example of what it looks like with .clear=true: Image

And here it is with .clear=false: Image

Logs I1024 23:17:40.172563 0x1709cf000.1 model_renderer.cc:99] [Filament I]: FEngine (64 bits) created at 0x133839800 (threading is enabled) I1024 23:17:40.172622 0x170da3000.0 model_renderer.cc:99] [Filament I]: FEngine resolved backend: Metal I1024 23:17:40.176935 0x170da3000.0 model_renderer.cc:99] [Filament I]: Selected physical device 'Apple M1' I1024 23:17:40.177008 0x170da3000.0 model_renderer.cc:104] [Filament V]: Supported GPU families: I1024 23:17:40.177010 0x170da3000.0 model_renderer.cc:104] [Filament V]: MTLGPUFamilyCommon3 I1024 23:17:40.177011 0x170da3000.0 model_renderer.cc:104] [Filament V]: MTLGPUFamilyApple7 I1024 23:17:40.177012 0x170da3000.0 model_renderer.cc:104] [Filament V]: MTLGPUFamilyMac2 I1024 23:17:40.177013 0x170da3000.0 model_renderer.cc:104] [Filament V]: Features: I1024 23:17:40.177016 0x170da3000.0 model_renderer.cc:104] [Filament V]: readWriteTextureSupport: true I1024 23:17:40.177276 0x1709cf000.1 model_renderer.cc:99] [Filament I]: Backend feature level: 3 I1024 23:17:40.177281 0x1709cf000.1 model_renderer.cc:99] [Filament I]: FEngine feature level: 1

Desktop (please complete the following information):

Smartphone (please complete the following information): N/A

Additional context N/A

emezeske commented 5 hours ago

It would perhaps be helpful to mention that I've seen a bunch of other visual corruptions, which I didn't reproduce for the video, but none of which have occurred since I changed to clear=true: