3
votes

I started receiving the following error today after adding some complexity to my shader:

Execution of the command buffer was aborted due to an error during execution. Discarded (victim of GPU error/recovery) (IOAF code 5)

What i discovered is that it has nothing to do with the actual added code but with fact i added more variables and function calls. I tried removing other complexities from the shader and the error was removed. Another thing i discovered is that problem also removed when i set fast math to false.

My first guess is that there is some kind of a limit on number of variables when fast math is on. Is there such a limit? Any other ideas why such error might occur?

1

1 Answers

0
votes

Most probable cause is that Metal buffers or shaders are overloaded there is a limitations of using metal technology and it is described here

https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html

I was having this problem before and i was about to switch from Metal to OpenGL But the advantages of Metal let me try again then i discover that my issue that i was Calculating and sorting an Array of Heavy data (Mostly floats and doubles) within the renderer function

My Mistake was Here See the remarked line

- (void)renderer:(id <SCNSceneRenderer>)renderer updateAtTime:(NSTimeInterval)time
{

    [self calculateMyData];    // This Is Wrong

 }

- (void)calculateMyData
{
   // the Heavy Calculations 
}

to avoid most IOAF Errors try not to do heavy or complex calculations like sorting data or such within the renderer try use External Loops to call this calculations. This is what i have done

- (void)viewDidLoad
{
    // I Use A Timer Loop Every 0.3 Sec to call the heave calculations and sort data

    NSTimer *timerCounter2 = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(calculateMyData) userInfo:nil repeats: YES]; 

}
- (void)renderer:(id <SCNSceneRenderer>)renderer updateAtTime:(NSTimeInterval)time
{
    //[self calculateMyData];    // Now I Avoid The Mistake    
}

- (void)calculateMyData
{
   // the Heavy Calculations 
}