[Mesa-dev] [PATCH 2/3] gallium/util: don't modify usage in pipe_buffer_write

Marek Olšák maraeo at gmail.com
Mon Jul 18 12:25:31 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

All drivers were already doing it except virgl.
---
 src/gallium/auxiliary/util/u_inlines.h     | 11 ++---------
 src/gallium/drivers/virgl/virgl_resource.c |  5 +++++
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 07f7354..c2a0b08 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -339,15 +339,8 @@ pipe_buffer_write(struct pipe_context *pipe,
                   unsigned size,
                   const void *data)
 {
-   unsigned access = PIPE_TRANSFER_WRITE;
-
-   if (offset == 0 && size == buf->width0) {
-      access |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
-   } else {
-      access |= PIPE_TRANSFER_DISCARD_RANGE;
-   }
-
-   pipe->buffer_subdata(pipe, buf, access, offset, size, data);
+   /* Don't set any other usage bits. Drivers should derive them. */
+   pipe->buffer_subdata(pipe, buf, PIPE_TRANSFER_WRITE, offset, size, data);
 }
 
 /**
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c
index 441b0c1..db5e7dd 100644
--- a/src/gallium/drivers/virgl/virgl_resource.c
+++ b/src/gallium/drivers/virgl/virgl_resource.c
@@ -89,6 +89,11 @@ static void virgl_buffer_subdata(struct pipe_context *pipe,
 {
    struct pipe_box box;
 
+   if (offset == 0 && size == resource->width0)
+      usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+   else
+      usage |= PIPE_TRANSFER_DISCARD_RANGE;
+
    u_box_1d(offset, size, &box);
    virgl_transfer_inline_write(pipe, resource, 0, usage, &box, data, 0, 0);
 }
-- 
2.7.4



More information about the mesa-dev mailing list