zink: force streamout rebind when mapping a streamout buffer for writing
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 19 May 2021 16:39:48 +0000 (12:39 -0400)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 26 May 2021 01:51:17 +0000 (21:51 -0400)
if the contents of the buffer change between uses, trigger the rebind path
next time a draw happens for synchronization

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10882>

src/gallium/drivers/zink/zink_resource.c

index 686ad27..8d3abdc 100644 (file)
@@ -943,6 +943,12 @@ buffer_transfer_map(struct zink_context *ctx, struct zink_resource *res, unsigne
    }
 
    if (!ptr) {
+      /* if writing to a streamout buffer, ensure synchronization next time it's used */
+      if (usage & PIPE_MAP_WRITE && res->bind_history & ZINK_RESOURCE_USAGE_STREAMOUT) {
+         ctx->dirty_so_targets = true;
+         /* force counter buffer reset */
+         res->bind_history &= ~ZINK_RESOURCE_USAGE_STREAMOUT;
+      }
       ptr = map_resource(screen, res);
       if (!ptr)
          return NULL;