Skip to content

tc: implement unsynchronized texture uploads

Mike Blumenkrantz requested to merge zmike/mesa:tc-asyncsubdata into main

At present there are three modes for texture subdata calls:

  • small subdatas are enqueued
  • large subdatas are either
    • sequenced into strided copies and enqueued (rp-tracked path)
    • called directly after a tc_sync

The large subdatas part is problematic for the rp-tracked path as it can result in dozens/hundreds of enqueued copies. In spite of the batch overhead, this is still preferable to incurring a tc_sync on some implementations (when rp-tracking is enabled), as a sync call is likely to void any of the tracked renderpass data, which obliterates performance on tilers. But having tons of copies is bad for other reasons, least of which is the overhead incurred by having tc serialize that many calls.

An optimization here which works for many cases is to enable unsynchronized subdata calls. This lets the frontend pass the subdata call directly to the driver without any synchronization/serialization as long as the texture is known to be unused.

Usage is detected by a mechanism similar to what zink uses:

  • tag textures on use
    • special tag for persistent use to block all unsynchronized access
  • check texture usage data when attempting to promote a subdata call to unsynchronized

Driver requirements to use/test:

  • handle pipe_context::is_resource_busy with TC_TRANSFER_MAP_THREADED_UNSYNC
  • handle texture_subdata with TC_TRANSFER_MAP_THREADED_UNSYNC
  • set unsynchronized_texture_subdata=true

https://gitlab.freedesktop.org/zmike/mesa/-/pipelines/1002913 in ci, though currently only lavapipe can access this path since nobody else supports HIC

Merge request reports