Render-to-texture and sync

I have a cross-platform code base (iOS and Android) that uses a standard rendering setting for texture. Each frame (after initialization) has the following sequence:

  • glBindFramebuffer texture-bound framebuffer
  • Check out some things.
  • *
  • glBindFramebuffer standard framebuffer (0 on Android, usually 2 on iOS)
  • glBindTexture of the texture that was the color binding to the first framebuffer
  • Render using related texture

On iOS and some Android devices (including the emulator), this works fine and as expected. On other devices (currently seated in front of the Samsung Galaxy Note 4.0.4), rendering the second phase using texture looks β€œnervous”. Other animations continue to run at 60 frames per second on the same screen as the jumping bits; my conclusion is that changes in the target texture are not always visible in the second render pass.

To test this theory, I insert glFinish () in the step marked * above. On all devices, this now has the correct behavior. Interestingly, glFlush () does NOT fix the problem. But glFinish () is expensive, and I have not seen any documentation that suggests this is necessary.

So, here is my question: what should I do when I finish rendering the texture to make sure that the latest texture is available in subsequent transfers?

+6
source share
1 answer

The code you describe should be in order.

As long as you use one context and don’t select any extensions that weaken the synchronization behavior (for example, EXT_map_buffer_range ), then each command should seem to be executable, as if it were executed in exactly the same order specified in the API, and in your use of the API which you pass to the texture before reading from it.

Given this, you are likely to encounter driver errors on these devices. Can you list which devices are facing the problem? You will likely find common hardware or drivers.

+3
source

All Articles