bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.13k stars 1.95k forks source link

Metal: example-01-helloworld corrupted render when MSAA is enabled #3228

Open rogual opened 11 months ago

rogual commented 11 months ago

Describe the bug With MSAA on, the Hello World example renders with a bright pink background on my M2 Mac, and the imgui window disappears. Strangely enough, if I capture a frame with the Metal graphics debugger, it shows as normal in there. No errors are reported either.

To Reproduce Steps to reproduce the behavior:

  1. Run Hello World example
  2. Press F8 to turn on MSAA

Expected behavior The example should display as normal

Screenshots

Screenshot 2023-12-20 at 21 52 09 Screenshot 2023-12-20 at 21 55 37

Additional context MacBook Pro Apple M2 Max OS: 13.5 (22G74)

Chipset Model: Apple M2 Max Type: GPU Bus: Built-In Total Number of Cores: 30 Vendor: Apple (0x106b) Metal Support: Metal 3

rogual commented 11 months ago
Screenshot 2023-12-21 at 09 24 32 Screenshot 2023-12-21 at 09 22 54

Hm, this is suspicious. That's a non-MSAA frame on the left, and MSAA (pink frame) on the right.

I notice the dependency between submit and blitRender is a dashed line in the MSAA frame, which means synchronization only (no data transfer). So the frame isn't being transferred between submit and blitRender passes? I hope I have that right.

rogual commented 11 months ago
Screenshot 2023-12-21 at 09 26 00

It looks like bgfx is storing to "Color 0 Resolve" in the submit pass, but trying to load from "Color 0" in the blitRender pass.

ul commented 3 months ago

Can confirm it's reproducible on a Mac mini with M1 and macOS 14.5.