Which memory barrier does glGenerateMipmap require?
Asked Answered
E

1

8

I've written to the first mipmap level of a texture using GL_ARB_shader_image_load_store. The documentation states that I need to call glMemoryBarrier before I use the contents of this image in other operations, in order to flush the caches appropriately.

For instance, before I do a glTexSubImage2D operation, I need to issue GL_TEXTURE_UPDATE_BARRIER_BIT​, and before I issue a draw call using a shader that samples that texture, I need to issue GL_TEXTURE_FETCH_BARRIER_BIT​.

However, which barrier do I need to issue before I am ensured that glGenerateMipmap will use the most recently written data?

Eyed answered 11/7, 2014 at 8:59 Comment(2)
Looks to me like you've found a whole in the spec. I would suggest you contact the spec authors to ask they clarify it.Cornellcornelle
As OpenGL 4.5 released there is a new function glTextureBarrier() which expected to do what you want. opengl.org/sdk/docs/man/html/glTextureBarrier.xhtmlStereotype
P
4

The OpenGL 4.6 specification clarifies this:

Any synchronization required before performing this reduction will be done within the Generate*Mipmap commands themselves.

So you don't need any kind of synchronization. If you have caused data to be written to the base mipmap level in any way, glGenerateMipmap will perform sufficient synchronization to make reads work.

Given that, it's probably a really good idea not to call this in the middle of rendering a frame.

Prior specifications had no answer, though information from this bug report suggests that prior implementations did exactly the above.

Papacy answered 3/12, 2015 at 17:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.