glGenerateMipmap需要哪个内存屏障? [英] Which memory barrier does glGenerateMipmap require?

查看:103
本文介绍了glGenerateMipmap需要哪个内存屏障?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用GL_ARB_shader_image_load_store写入了纹理的第一个mipmap级别.文档指出,在其他操作中使用该映像的内容之前,需要先调用glMemoryBarrier,以便适当地刷新缓存.

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.

例如,在执行glTexSubImage2D操作之前,我需要发出GL_TEXTURE_UPDATE_BARRIER_BIT,并且在使用使用该纹理采样的着色器发出绘制调用之前,我需要发出GL_TEXTURE_FETCH_BARRIER_BIT.

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​.

但是,在确保glGenerateMipmap使用最新写入的数据之前,我需要发布哪个障碍?

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

推荐答案

OpenGL 4.6规范对此进行了澄清:

The OpenGL 4.6 specification clarifies this:

执行此减少操作之前所需的任何同步都将完成 在Generate*Mipmap命令本身中.

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

因此,您不需要任何形式的同步.如果您以任何方式导致将数据写入基本Mipmap级别,则glGenerateMipmap将执行足够的同步以使读取工作.

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.

这篇关于glGenerateMipmap需要哪个内存屏障?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆