简体   繁体   中英

Metal functions failing to compile with Xcode 8

Since moving to Xcode 8 and iOS10, my metal based app fails to run at all. On launch I get the error: "Compiler failed with XPC_ERROR_CONNECTION_INTERRUPTED"

This appears two to three times in the console before crashing due to a MTLComputePipelineState not being successfully created and throwing an error when calling the MTLDevice function makeComputePipelineState(function:) . The only changes I have made to the project is to update to Swift 3.0, but the console seems to imply a compiler error, which due to the crash I'm assuming is down to some metal code not compiling properly.

Any help would be appreciated, this is ageing me prematurely.

UPDATE:

I've located the line causing the trouble in the .metal file:

int gi1 = permMod12[ii+i1+perm[jj+j1+perm[kk+k1]]];

permMod12 is a static constant array declared as:

static constant int permMod12 [512] = {7,4,5,7...}

perm is similarly static and constant:

static constant int perm [512] = {151,160...}

The variables ii , i1 , jj , j1 , kk and k1 are all integers calculated in the same kernel.

The kernel is quite large so I'll post a link to the GitHub location. It's the functions called simplex3D and simplex4D that are causing the issue. These are very similar so only focus on one of them, they are carbon copies but 4D has another stretch of variables running ( ll , l1 , l etc).

The issue certainly seems to be with looking up these arrays with calculated variables as when I change the variables to simple literals there is no error.

The kernel needs to be executed in order to get the error to occur.

Any help with this new info would be great.

I've encountered this situation, and it seems that there is no unique solution to solve this problem. In my case, the problem was occurred when a texture that uses a normalized coordinate sampler also uses read() function. When I switch read() function to sample() this weird error was removed. I hope your problem were solved already.

I also encountered the same error: "Compiler failed with XPC_ERROR_CONNECTION_INTERRUPTED". The issue was resolved. It stemmed from attempted use of 'threadgroup bool' type variables. Refactoring the code to use 'threadgroup short' variables in place of the boolean resolved the error. (Could not find in the Metal Version 2 specification if bool type is or is not a valid threadgroup type.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM