gpt4 book ai didi

opengl - 将缓冲内存映射指针传递给 glTex(Sub)Image2D。纹理上传是异步的吗?

转载 作者:行者123 更新时间:2023-12-03 21:43:33 28 4
gpt4 key购买 nike

假设我映射一个缓冲区,用

map_ptr = glMapBuffer (..)(目标应该无关紧要,但让我们说它的 GL_TEXTURE_BUFFER)

接下来我上传纹理数据:

glTexImage2D(..., map_ptr),将 map_ptr 作为我的纹理数据传递。 (我没有绑定(bind) GL_PIXEL_UNPACK_BUFFER)

从语义上讲,这涉及将数据从缓冲区的数据存储复制到纹理对象的数据存储,并且该操作可以通过 GPU DMA 复制来完成。

但实际上发生了什么?数据是完全复制到 GPU 上,还是 CPU 读取并缓存映射内存,然后在单独的 GPU 内存位置写回 GPU? IE。复制是异步的,还是 CPU 同步协调复制,利用 CPU 周期?

该实现的答案是否依赖?这是否取决于 OpenGL 驱动程序是否足够智能以识别传递给 glTexImage2D 的数据指针(GPU 内存映射指针),并且不需要往返 CPU?如果是这样,此功能在当今流行的驱动程序中有多普遍?

此外,内存被映射的 OpenCL 缓冲区的行为如何,即:

map_ptr = clEnqueueMapBuffer(..)(OpenCL 缓冲区映射内存)

map_ptr被传递给了glTexImage2D

最佳答案

根据 spec,您所做的只是未定义的行为 .

Pointer values returned by MapBufferRange may not be passed as parameter values to GL commands. For example, they may not be used to specify array pointers, or to specify or query pixel or texture image data; such actions produce undefined results, although implementations may not check for such behavior for performance reasons.

让我引用 GL_ARB_vertex_buffer_object扩展规范,最初引入了缓冲区对象和映射操作(强调我的):

Are any GL commands disallowed when at least one buffer object is mapped?

RESOLVED: NO. In general, applications may use whatever GL commands they wish when a buffer is mapped. However, several other restrictions on the application do apply: the application must not attempt to source data out of, or sink data into, a currently mapped buffer. Furthermore, the application may not use the pointer returned by Map as an argument to a GL command. (Note that this last restriction is unlikely to be enforced in practice, but it violates reasonable expectations about how the extension should be used, and it doesn't seem to be a very interesting usage model anyhow. Maps are for the user, not for the GL.)

关于opengl - 将缓冲内存映射指针传递给 glTex(Sub)Image2D。纹理上传是异步的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25167499/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com