GPU hangs when rendering with two render encoders?

Hello! I’m trying to make use of G-buffer in my project and I’m using a project from Chapter 14 as a reference. For some reason GPU hangs for about 5 seconds if I try to render composition quad in a separate pass, and consequent render commands are ignored. Console log says this after the app “unfreezes”:
Execution of the command buffer was aborted due to an error during execution. Caused GPU Timeout Error (IOAF code 2)
Then the screen goes black and console is flooded with these messages:
Execution of the command buffer was aborted due to an error during execution. Ignored (for causing prior/excessive GPU errors) (IOAF code 4)
My rendering pipeline is almost identical to the book’s companion project, except it’s even simpler right now - I skipped shadow pass and don’t even render any models, so there’s also no draw calls in G-buffer pass, but GPU hangs anyway.
I’ve also stripped down shader functions for debugging purposes: vertex functions simply pass through vertex position and fragment functions return constant values, and I don’t receive/pass any arguments to them from CPU, only two buffers for quad vertices in Composition pass.
If I render quad in the same pass (encoder) as G-buffer, or if I skip G-buffer pass, or if I return constant position from vertex function for all vertices in Composition pass (essentially not rendering the quad), then it “works” okay, i.e. it doesn’t crash.
At the same I modified book’s project the same way and It works as intended. What am I missing here?
I’ve been banging my head on this for the whole day, starting to feel a bit desperate :frowning:

I’m using Xcode 10, macOS/iOS 12.

@dormouse the IOAF error codes are hard to debug but I could give it a try if you zip up your project and upload it to dropbox or some other place so I can take a look at it.

That’d be great! I’ve made a bare-bones project to narrow down the searches. Here’s the link. Thank you!

I do not get any error when I run your project on my Macbook Pro. The red screen only means the values you wrote are undefined for the drawable you present on the screen.

18%20AM

Okay, I just tested it again on two iOS devices and it works indeed. Maybe the problem has something to do with my MacBook or its Intel GPU in particular, but what bothers me is that tutorial’s project works completely fine on the MacBook, too. Looks like I’ll have to research it more thoroughly.
Thanks again!

I figured it out! Turns out I have to issue at least one draw call in G-buffer pass, it works without any problems then. However, if nothing is drawn, then it crashes. Tested it also on book’s project, removing draw calls causes a crash on my machine. Could this be a driver bug or something?

It cannot be a bug because you need to draw at least once in the G-buffer pass so that you can save the scene to a texture which is used in the next pass.