From 143c1564093237a6ab509f064eb652a24c3e55d1 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 26 Jan 2022 14:53:44 -0500 Subject: [PATCH] aux/tc: add tc_buffer_write to replace pipe_buffer_write usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tc_buffer_write is the tc-safe version of this function which will avoid accidental invalidations that break behavior Acked-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gallium/auxiliary/util/u_threaded_context.h b/src/gallium/auxiliary/util/u_threaded_context.h index 17bdb61bd77..ed375558ce8 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.h +++ b/src/gallium/auxiliary/util/u_threaded_context.h @@ -104,6 +104,8 @@ * TC_TRANSFER_MAP_NO_INVALIDATE into transfer_map and buffer_subdata to * indicate this. Ignoring the flag will lead to failures. * The threaded context uses its own buffer invalidation mechanism. + * Do NOT use pipe_buffer_write, as this may trigger invalidation; + * use tc_buffer_write instead. * * 4) PIPE_MAP_ONCE can no longer be used to infer that a buffer will not be mapped * a second time before it is unmapped. @@ -612,6 +614,16 @@ tc_buffer_disable_cpu_storage(struct pipe_resource *buf) } } +static inline void +tc_buffer_write(struct pipe_context *pipe, + struct pipe_resource *buf, + unsigned offset, + unsigned size, + const void *data) +{ + pipe->buffer_subdata(pipe, buf, PIPE_MAP_WRITE | TC_TRANSFER_MAP_NO_INVALIDATE, offset, size, data); +} + #ifdef __cplusplus } #endif