Which memory barrier does glGenerateMipmap require?

妖精的绣舞 提交于 2019-12-08 17:12:20

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/24693861/which-memory-barrier-does-glgeneratemipmap-require

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!