Skip to content

st/mesa: Use the texture_subdata memcpy path for non-busy PBO sources.

Kenneth Graunke requested to merge kwg/mesa:pbo-texsubimage into master

Civilization VI wants to provide some data to a vertex shader via a texture buffer. Unfortunately, the OpenGL port doesn't actually use texture buffers, and instead does some interesting things:

  1. glMapBufferRange with GL_MAP_INVALIDATE_BUFFER_BIT | GL_WRITE_BIT, causing the buffer's contents to be dropped and it to be CPU idle.
  2. memcpy some data into the buffer.
  3. Bind that buffer as a PBO.
  4. glTexSubImage2D from the PBO into a 4096xN rectangle texture.
  5. Have the shader texelFetch with / and % 4096 coordinate munging.

During the glTexSubImage operation, we see that the source data is in a PBO and queue a blit. But in this case the buffer was newly populated on the CPU and is still idle, so we can simply map it for reading and upload directly from there.

Eliminates a bunch of unnecessary GPU blits, which seemed to be taking around 6ms when measured in isolation.

Merge request reports