<legend id='IaRhv'><style id='IaRhv'><dir id='IaRhv'><q id='IaRhv'></q></dir></style></legend>

    <i id='IaRhv'><tr id='IaRhv'><dt id='IaRhv'><q id='IaRhv'><span id='IaRhv'><b id='IaRhv'><form id='IaRhv'><ins id='IaRhv'></ins><ul id='IaRhv'></ul><sub id='IaRhv'></sub></form><legend id='IaRhv'></legend><bdo id='IaRhv'><pre id='IaRhv'><center id='IaRhv'></center></pre></bdo></b><th id='IaRhv'></th></span></q></dt></tr></i><div id='IaRhv'><tfoot id='IaRhv'></tfoot><dl id='IaRhv'><fieldset id='IaRhv'></fieldset></dl></div>
      <bdo id='IaRhv'></bdo><ul id='IaRhv'></ul>

    <tfoot id='IaRhv'></tfoot>
  1. <small id='IaRhv'></small><noframes id='IaRhv'>

    1. OpenGL 读写相同的纹理

      时间:2023-09-17
      <i id='1R1mD'><tr id='1R1mD'><dt id='1R1mD'><q id='1R1mD'><span id='1R1mD'><b id='1R1mD'><form id='1R1mD'><ins id='1R1mD'></ins><ul id='1R1mD'></ul><sub id='1R1mD'></sub></form><legend id='1R1mD'></legend><bdo id='1R1mD'><pre id='1R1mD'><center id='1R1mD'></center></pre></bdo></b><th id='1R1mD'></th></span></q></dt></tr></i><div id='1R1mD'><tfoot id='1R1mD'></tfoot><dl id='1R1mD'><fieldset id='1R1mD'></fieldset></dl></div>
      <tfoot id='1R1mD'></tfoot>
      • <bdo id='1R1mD'></bdo><ul id='1R1mD'></ul>
      • <legend id='1R1mD'><style id='1R1mD'><dir id='1R1mD'><q id='1R1mD'></q></dir></style></legend>

                  <tbody id='1R1mD'></tbody>

                <small id='1R1mD'></small><noframes id='1R1mD'>

                本文介绍了OpenGL 读写相同的纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有一个 RGBA16F 纹理,上面有深度、normal.x、normal.y.我想读取 r、g、b 并写入纹理上的 a.我会准确地击中每个像素一次.

                I have a RGBA16F texture with depth, normal.x, normal.y on it. I want to read r, g, b and write to a on the texture. I will hit every pixel exactly once.

                如果我在这种情况下读写同一个纹理会不会有性能问题?

                Would there be a performance problem if I read and write to the same texture in this case?

                推荐答案

                不会有性能问题.会有一个功能问题.就像那样,它不起作用.

                There won't be a performance problem. There will be a functionality problem. As in, it won't work.

                您无法从您通过 FBO 写入的图像中读取并期望获得合理的结果.这会产生未定义的行为.

                You cannot read from an image that you are writing to via FBO and expect to get reasonable results. That's yields undefined behavior.

                如果您使用 shader_image_load_store 进行读/写,您可能可以逃脱.但即便如此,它也是一个读/修改/写操作;你必须写回你读到的 alpha.

                If you were using shader_image_load_store to do your reading/writing, you might be able to get away with it. But even then, it's a read/modify/write operation; you have to write back the alpha that you read.

                话虽如此,如果您确定每个像素恰好命中一次"(强调),那么您确实有追索权.即,NV_texture_barrier.不要让这个扩展上的NV"欺骗你;它也广泛应用于 AMD 硬件(所有 HD 系列卡).这个扩展允许你使用一个屏障"函数(实际上是一个告诉 GPU 清除帧缓冲区和纹理缓存的函数),在调用后,它将允许你完全 one 读取/在片段着色器中修改/写入.在第一次通过之后,您需要在第二次通过之间建立另一个障碍.

                That being said, if you are certain that you will "hit every pixel exactly once" (emphasis added), you do have a recourse. Namely, NV_texture_barrier. Don't let the "NV" on this extension fool you; it's widely implemented on AMD hardware as well (all HD-series cards). This extension allows you to use a "barrier" function (effectively a function that tells the GPU to clear the framebuffer and texture caches) which, after calling, will allow you to do exactly one pass of read/modify/write in your fragment shader. After that one pass, you need another barrier between that and your second pass.

                这篇关于OpenGL 读写相同的纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:OS X 上 Eclipse 中的 OpenGL 和 GLUT 下一篇:如何按自己的中心旋转所有对象,然后将它们转

                相关文章

                最新文章

                <small id='yLyLv'></small><noframes id='yLyLv'>

                  <i id='yLyLv'><tr id='yLyLv'><dt id='yLyLv'><q id='yLyLv'><span id='yLyLv'><b id='yLyLv'><form id='yLyLv'><ins id='yLyLv'></ins><ul id='yLyLv'></ul><sub id='yLyLv'></sub></form><legend id='yLyLv'></legend><bdo id='yLyLv'><pre id='yLyLv'><center id='yLyLv'></center></pre></bdo></b><th id='yLyLv'></th></span></q></dt></tr></i><div id='yLyLv'><tfoot id='yLyLv'></tfoot><dl id='yLyLv'><fieldset id='yLyLv'></fieldset></dl></div>
                1. <legend id='yLyLv'><style id='yLyLv'><dir id='yLyLv'><q id='yLyLv'></q></dir></style></legend>
                    <bdo id='yLyLv'></bdo><ul id='yLyLv'></ul>
                  1. <tfoot id='yLyLv'></tfoot>