I am working on an app that uses some Metal compute shaders and trying to get this to work on the simulator. I am having an issue where the simulator freezes the entire OS (which eventually results in either a panic or WindowServer being killed and dumping me on the login screen). After some trial and error, and many reboots, I isolated the problem to a combination of 2 things:
- Using an
atomic_fetch_add_explicit
on an MTLBuffer from a compute kernel. - Having the simulator set to prefer the discrete GPU.
Without the atomic operation, everything runs fine on either GPU. With the atomic operation, it runs fine on the integrated GPU, but if I select the discrete GPU it freezes WindowServer, the GUI is completely unresponsive and frozen, but I can SSH into the machine (until it decides to panic). When it's frozen there aren't any processes using significant amounts of CPU time. I can reproduce this 100% of the time.
I'm using a MacBook Pro 15" (2018, radeon 560X 4GB). It doesn't matter wether or not the discrete GPU is used by the OS.