Texture output/input sync problem

Hi guys,

I have synchronization problem between two of my rendering pass and I didn’t saw anything in the specification that explain my problem. My first pass is a simple render to texture:

Geo --> Vertex Shader --> Fragment Shader --> Texture0

In the second pass, I disable the rasterizer stage and perform computation with the vertex shader only and transform feedback output enabled (I read the render target texture of the previous pass in this vertex shader):

Geo2 --> Vertex Shader --> Transform feedback output
^
Texture0 -------/

The problem is that data written in Texture0 from the first pass is not always available in the second pass (the texture Texture0 is only partially written). As a workaround, inserting a glFlush between the two pass fix the problem.

I was wondering if I’m missing something from the spec or if it could be a driver bug (I don’t use the EXT_shader_image_load_store extension) ?

Here’s my driver version:
NVIDIA GeForce GTX 470
Linux Driver Version: 270.41.06

Thanks

The problem is that data written in Texture0 from the first pass is not always available in the second pass

Sounds like a driver bug. Once you bind and render with that texture, the OpenGL implementation should insert whatever machinery is necessary to ensure that the data is fully written and the caches flushed before it is read.

A less heavyweight workaround than glFlush is to use NV_texture_barrier and insert a barrier before your second rendering.

BTW, you may want to unbind the FBO just to be safe.

Thanks Alfonse,

Using glMemoryBarrierEXT(GL_TEXTURE_FETCH_BARRIER_BIT_EXT) instead of glFlush() is working great !