gallium/threaded_context: add another rule for buffer mapping
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 8 Apr 2021 18:43:04 +0000 (14:43 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 8 Apr 2021 19:35:10 +0000 (19:35 +0000)
commitc79c2afd9f056295cb6237d7272f6eb0d3f8c1cc
tree278cc15a55ff510cd9bc88aaf7e60f304f45b80d
parent663272c4dabcee276eecca972eecefcb62a1f13a
gallium/threaded_context: add another rule for buffer mapping

a synchronous driver can use PIPE_MAP_ONCE to infer that a buffer is
guaranteed to not be mapped multiple times, as this is only used when
doing map -> memcpy -> unmap directly

a threaded driver performs maps/unmaps asynchronously, so this flag
can only be used by the driver to confirm that the mapped region is accessed
exactly once, not that it will not need to remain mapped for other transfer_map
uses after it is unmapped

in short, consider this scenario:
  transfer_map(A) -> memcpy(map, data) -> transfer_unmap(map_A) ->
  transfer_map(A) -> memcpy(map, data) -> transfer_unmap(map_A)

when a synchronous driver executes this, the call chain is unmodified

when a tc driver executes this, the call chain may become:
  transfer_map(A) -> memcpy(map, data) ->
  transfer_map(A) -> memcpy(map, data) ->
  transfer_unmap(map_A) -> transfer_unmap(map_A)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10113>
src/gallium/auxiliary/util/u_threaded_context.h