Skip to content

iris: Implement pipe->texture_subdata directly

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

Chris Wilson noted that u_default_texture_subdata's transfer path sometimes results in wasteful double copies. This patch is based on an earlier path he wrote, but updated now that we have staging blits for busy or compressed textures.

Consider the case of idle, non-CCS-compressed, tiled images:

The transfer-based CPU path has to return a "linear" mapping, so upon map, it mallocs a temporary buffer. u_default_texture_subdata then copies the client memory to this malloc'd buffer, and transfer unmap performs a tiled_memcpy to copy it back into the texture. By writing a direct texture_subdata() implementation, we're able to directly do a tiled_memcpy from the client memory into the destination texture, resulting in only one copy.

For busy or CCS-compressed images, we still want to blit to avoid stalls or compress the new data. The transfer path would use a box-sized linear temporary, then blit that to the actual image. This isn't bad, but we can do better by using a tiled temporary, allowing the blit to sample from tiled memory, which is faster.

For linear buffers, there is no advantage to doing things directly, so we simply fall back to u_default_texture_subdata()'s transfer path to avoid replicating those cases.

This improves performance in x11perf ShmPutImage 500x500 square by about 3.3x on Kabylake, according to Chris Wilson.

Closes: #2500 (closed)

Merge request reports