Mesa (master): r300g: do not create a user buffer struct for misaligned ushort indices fallback

Marek Olšák mareko at kemper.freedesktop.org
Mon Feb 14 10:49:37 UTC 2011


Module: Mesa
Branch: master
Commit: 476cec37d615df7c7329ef74d4a7ea7200b2d8fb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=476cec37d615df7c7329ef74d4a7ea7200b2d8fb

Author: Marek Olšák <maraeo at gmail.com>
Date:   Mon Feb 14 10:08:59 2011 +0100

r300g: do not create a user buffer struct for misaligned ushort indices fallback

---

 src/gallium/drivers/r300/r300_render.c        |   15 ++++++---------
 src/gallium/drivers/r300/r300_screen_buffer.c |    3 +--
 src/gallium/drivers/r300/r300_screen_buffer.h |    2 +-
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 051f434..37b9934 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -578,7 +578,6 @@ static void r300_draw_range_elements(struct pipe_context* pipe,
     if (indexSize == 2 && (start & 1) &&
         !r300_resource(indexBuffer)->b.user_ptr) {
         struct pipe_transfer *transfer;
-        struct pipe_resource *userbuf;
 
         uint16_t *ptr = pipe_buffer_map(pipe, indexBuffer,
                                         PIPE_TRANSFER_READ |
@@ -590,18 +589,16 @@ static void r300_draw_range_elements(struct pipe_context* pipe,
         } else {
             /* Copy the mapped index buffer directly to the upload buffer.
              * The start index will be aligned simply from the fact that
-             * every sub-buffer in u_upload_mgr is aligned. */
-            userbuf = pipe->screen->user_buffer_create(pipe->screen,
-                                                       ptr, 0,
-                                                       PIPE_BIND_INDEX_BUFFER);
-            indexBuffer = userbuf;
-            r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start, count);
-            pipe_resource_reference(&userbuf, NULL);
+             * every sub-buffer in the upload buffer is aligned. */
+            r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start,
+                                     count, (uint8_t*)ptr);
         }
         pipe_buffer_unmap(pipe, transfer);
     } else {
         if (r300_resource(indexBuffer)->b.user_ptr)
-            r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start, count);
+            r300_upload_index_buffer(r300, &indexBuffer, indexSize,
+                                     &start, count,
+                                     r300_resource(indexBuffer)->b.user_ptr);
     }
 
     /* 19 dwords for emit_draw_elements. Give up if the function fails. */
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 04afae6..7855d70 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -51,10 +51,9 @@ unsigned r300_buffer_is_referenced(struct pipe_context *context,
 void r300_upload_index_buffer(struct r300_context *r300,
 			      struct pipe_resource **index_buffer,
 			      unsigned index_size, unsigned *start,
-			      unsigned count)
+			      unsigned count, uint8_t *ptr)
 {
     unsigned index_offset;
-    uint8_t *ptr = r300_resource(*index_buffer)->b.user_ptr;
     boolean flushed;
 
     *index_buffer = NULL;
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h
index ae87c44..14bee46 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.h
+++ b/src/gallium/drivers/r300/r300_screen_buffer.h
@@ -40,7 +40,7 @@
 void r300_upload_index_buffer(struct r300_context *r300,
 			      struct pipe_resource **index_buffer,
 			      unsigned index_size, unsigned *start,
-			      unsigned count);
+			      unsigned count, uint8_t *ptr);
 
 struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
 					 const struct pipe_resource *templ);




More information about the mesa-commit mailing list