Mesa (master): i965: Don' t replicate data for zero-stride arrays when copying to VBOs.

Kenneth Graunke kwg at kemper.freedesktop.org
Thu Nov 1 03:00:22 UTC 2012


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Oct 26 15:48:00 2012 -0700

i965: Don't replicate data for zero-stride arrays when copying to VBOs.

When copy_array_to_vbo_array encountered an array with src_stride == 0
and dst_stride != 0, we would replicate out the single element to the
whole size (max - min + 1).  This is unnecessary: we can simply upload
one copy and set the buffer's stride to 0.

Decreases vertex upload overhead in an upcoming Steam for Linux title.
Prior to this patch, copy_array_to_vbo_array appeared very high in the
profile (Eric quoted 20%).  After the patch, it disappeared completely.

Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/drivers/dri/i965/brw_draw_upload.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 722166c..ad7fe7c 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -311,13 +311,13 @@ copy_array_to_vbo_array(struct brw_context *brw,
 			struct brw_vertex_buffer *buffer,
 			GLuint dst_stride)
 {
-   if (min == -1) {
-      /* If we don't have computed min/max bounds, then this must be a use of
-       * the current attribute, which has a 0 stride.  Otherwise, we wouldn't
-       * know what data to upload.
-       */
-      assert(element->glarray->StrideB == 0);
+   const int src_stride = element->glarray->StrideB;
 
+   /* If the source stride is zero, we just want to upload the current
+    * attribute once and set the buffer's stride to 0.  There's no need
+    * to replicate it out.
+    */
+   if (src_stride == 0) {
       intel_upload_data(&brw->intel, element->glarray->Ptr,
                         element->element_size,
                         element->element_size,
@@ -327,7 +327,6 @@ copy_array_to_vbo_array(struct brw_context *brw,
       return;
    }
 
-   int src_stride = element->glarray->StrideB;
    const unsigned char *src = element->glarray->Ptr + min * src_stride;
    int count = max - min + 1;
    GLuint size = count * dst_stride;




More information about the mesa-commit mailing list