gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.36k stars 547 forks source link

Unable to copy a mapped buffer in GL #3453

Open kvark opened 4 years ago

kvark commented 4 years ago

It looks like glCopyBufferSubDatais forbidden when either of the buffers is mapped. This conflicts with our CPU-visible memory in GL that's backed by a persistently mapped buffer. It's quite strange that we are allowed to do anything with such a buffer except for copying from/to it?

kvark commented 4 years ago

Found something in https://docs.nvidia.com/drive/active/5.1.6.0L/nvvib_docs/DRIVE_OS_Linux_SDK_Development_Guide/baggage/GL_EXT_buffer_storage.html

What commands are affected by the relaxed errors for persistently mapped buffers?

RESOLVED: In GL 4.5 the following commands have the relaxed language BufferSubData, ClearBufferSubData, CopyBufferSubData, GetBufferSubData and InvalidateBufferSubData. Of these commands the only ones that apply to ES 3.1 are BufferSubData and CopyBufferSubData. However, if additional extensions add any of the other commands and EXT_buffer_storage is supported, they would have the same behavior in ES.

So it sounds like copying should be supported. Hmm. I'm seeing this on macOS/Intel, which advertises GL 4.1 core. I suppose it doesn't really have persistent mapping.

kvark commented 4 years ago

Ok, so this is valid when we have private_caps.buffer_storage enabled. However, when we don't, gfx-memory still treats us as persistently mappable... This may be solved with https://github.com/gfx-rs/wgpu/pull/1015 In the meantime, we'd have to switch emulate_map to true.