gallium/util: set correct usage flags in u_default_transfer_inline_write
authorMarek Olšák <maraeo@gmail.com>
Sun, 26 Feb 2012 17:48:42 +0000 (18:48 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 27 Feb 2012 15:22:13 +0000 (16:22 +0100)
The DISCARD flags should improve performance in drivers which handle them.

src/gallium/auxiliary/util/u_transfer.c

index 7e72a59ee00a97e1381f62e349c6aabbfe2346b8..1fa8d945982d7e37d047f3bd87fc421c60371fbb 100644 (file)
@@ -21,6 +21,18 @@ void u_default_transfer_inline_write( struct pipe_context *pipe,
    const uint8_t *src_data = data;
    unsigned i;
 
+   assert(!(usage & PIPE_TRANSFER_READ));
+
+   /* the write flag is implicit by the nature of transfer_inline_write */
+   usage |= PIPE_TRANSFER_WRITE;
+
+   /* transfer_inline_write implicitly discards the rewritten buffer range */
+   if (box->x == 0 && box->width == resource->width0) {
+      usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+   } else {
+      usage |= PIPE_TRANSFER_DISCARD_RANGE;
+   }
+
    transfer = pipe->get_transfer(pipe,
                                  resource,
                                  level,