Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which memory barrier does glGenerateMipmap require?

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?

like image 490
rdb Avatar asked Jul 11 '14 08:07

rdb


1 Answers

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.

like image 73
Nicol Bolas Avatar answered Sep 17 '22 21:09

Nicol Bolas