Mesa (mesa_7_7_branch): svga: Follow buffer usage semantics properly.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Thu Jan 21 23:27:44 UTC 2010
Module: Mesa
Branch: mesa_7_7_branch
Commit: 0ae076bf40782c48b1b26ca63ed2c349532dd81e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ae076bf40782c48b1b26ca63ed2c349532dd81e
Author: José Fonseca <jfonseca at vmware.com>
Date: Thu Jan 21 12:12:33 2010 -0800
svga: Follow buffer usage semantics properly.
It's necessary to download buffers from the host always, except if the
buffer is undefined, because:
- just PIPE_BUFFER_USAGE_CPU_WRITE doesn't guarantee all data is written
-- old contents may still pierce through
- PIPE_BUFFER_USAGE_DISCARD refers to a range, not the whole buffer, so
unless we track which parts have been modified and not we still need
to download the data.
---
src/gallium/drivers/svga/svga_screen_buffer.c | 10 ++++++----
src/gallium/drivers/svga/svga_screen_buffer.h | 5 +++++
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c
index c014f2e..cc2d3cd 100644
--- a/src/gallium/drivers/svga/svga_screen_buffer.c
+++ b/src/gallium/drivers/svga/svga_screen_buffer.c
@@ -355,6 +355,8 @@ svga_buffer_upload_flush(struct svga_context *svga,
sbuf->hw.svga = NULL;
sbuf->hw.boxes = NULL;
+ sbuf->host_written = TRUE;
+
/* Decrement reference count */
pipe_buffer_reference((struct pipe_buffer **)&sbuf, NULL);
}
@@ -436,17 +438,17 @@ svga_buffer_map_range( struct pipe_screen *screen,
}
else {
if(!sbuf->hw.buf) {
- struct svga_winsys_surface *handle = sbuf->handle;
-
if(svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK)
return NULL;
/* Populate the hardware storage if the host surface pre-existed */
- if((usage & PIPE_BUFFER_USAGE_CPU_READ) && handle) {
+ if(sbuf->host_written) {
SVGA3dSurfaceDMAFlags flags;
enum pipe_error ret;
struct pipe_fence_handle *fence = NULL;
+ assert(sbuf->handle);
+
SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "dma from sid %p (buffer), bytes %u - %u\n",
sbuf->handle, 0, sbuf->base.size);
@@ -478,7 +480,7 @@ svga_buffer_map_range( struct pipe_screen *screen,
}
}
else {
- if((usage & PIPE_BUFFER_USAGE_CPU_READ) && !sbuf->needs_flush) {
+ if(!(usage & PIPE_BUFFER_USAGE_DISCARD) && !sbuf->needs_flush) {
/* We already had the hardware storage but we would have to issue
* a download if we hadn't, so move the buffer to the begginning
* of the LRU list.
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.h b/src/gallium/drivers/svga/svga_screen_buffer.h
index 5d7af5a..c9bbe37 100644
--- a/src/gallium/drivers/svga/svga_screen_buffer.h
+++ b/src/gallium/drivers/svga/svga_screen_buffer.h
@@ -135,6 +135,11 @@ struct svga_buffer
*/
struct svga_winsys_surface *handle;
+ /**
+ * Whether the host has been ever written.
+ */
+ boolean host_written;
+
struct {
unsigned count;
boolean writing;
More information about the mesa-commit
mailing list