I am trying to use Metal to speed up the display of parts of my app. It works great on the 15'' TouchBar MacBook Pro, the first-generation retina MacBook Pro, as well as on the current Macbook. However, when trying to run the exact same code on a 27'' retina iMac (late 2014), the call to newComputePipelineStateWithDescriptor fails like so:
Compiler failed with XPC_ERROR_CONNECTION_INTERRUPTED
Error when compiling simulation pipeline state: Error Domain=CompilerError Code=1 "Compiler encountered an internal error" UserInfo={NSLocalizedDescription=Compiler encountered an internal error}
How could this even happen, given that the shader is bundled in precompiled form? I assume that newComputePipelineStateWithDescriptor would just translate whatever Bytecode the metallib file is using to actual machine code for the current GPU. If this fails, does this mean that this translator contains a bug? I've tried playing around a bit on the iMac and it is not clear at all what causes the problem. My shader file is not very long (about 150 lines of code), but the problem goes away if I make it shorter (except that then of course the shader doesn't do what it's supposed to do anymore). It doesn't seem to be any specific piece of the code that causes the problem: I can make it go away by commenting out either one of several disjoint sections of code. So it almost looks like code length / complexity is the problem, but given that my compiled shader is only 17kB in size, this also seems rather implausible...
Given the "internal error" message, it does sound like a bug, but then I would have expected it to go away by making some changes to the code. My shader function contained a rather large conditional, so I broke it up into two distinct functions which are then chosen by the CPU depending on context. Unfortunately, this didn't solve the problem either, so I am a bit at a loss...