[965] Move temporary vbo array storage into the function using it.
authorEric Anholt <eric@anholt.net>
Tue, 22 Jan 2008 22:03:24 +0000 (14:03 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 5 Feb 2008 02:24:16 +0000 (18:24 -0800)
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_draw_upload.c

index 4b3fdb47fcaaa1294bcde16bc38929889ae2efe6..7fdaeaee17ca11b5c665f34c62a6a9f22d261ad5 100644 (file)
@@ -427,12 +427,6 @@ struct brw_context
    struct brw_cached_batch_item *cached_batch_items;
 
    struct {
-
-      /* Arrays with buffer objects to copy non-bufferobj arrays into
-       * for upload:
-       */
-      struct gl_client_array vbo_array[VERT_ATTRIB_MAX];
-
       struct brw_vertex_element inputs[VERT_ATTRIB_MAX];
 
 #define BRW_NR_UPLOAD_BUFS 17
index c9e1a6e7bd7c61bdd4725d958e3e765f2be3c53b..a6581cbb85a98244a48e38b997d1f3388d2ce32b 100644 (file)
@@ -303,15 +303,14 @@ static void get_space( struct brw_context *brw,
    brw->vb.upload.offset += size;
 }
 
-static struct gl_client_array *
+static void
 copy_array_to_vbo_array( struct brw_context *brw,
-                        GLuint i,
+                        struct gl_client_array *vbo_array,
                         const struct gl_client_array *array,
                         GLuint element_size,
                         GLuint count)
 {
    GLcontext *ctx = &brw->intel.ctx;
-   struct gl_client_array *vbo_array = &brw->vb.vbo_array[i];
    GLuint size = count * element_size;
    struct gl_buffer_object *vbo;
    GLuint offset;
@@ -352,33 +351,29 @@ copy_array_to_vbo_array( struct brw_context *brw,
 
       ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, vbo_array->BufferObj);
    }
-
-   return vbo_array;
 }
 
 /**
  * Just a wrapper to highlight which cause of copy_array_to_vbo_array
  * is happening in the profile.
  */
-static struct gl_client_array *
+static void
 interleaved_copy_array_to_vbo_array(struct brw_context *brw,
-                                   GLuint i,
+                                   struct gl_client_array *vbo_array,
                                    const struct gl_client_array *array,
                                    GLuint element_size,
                                    GLuint count)
 {
-   return copy_array_to_vbo_array(brw, i, array, element_size, count);
+   copy_array_to_vbo_array(brw, vbo_array, array, element_size, count);
 }
 
-static struct gl_client_array *
+static void
 interleaved_vbo_array( struct brw_context *brw,
-                      GLuint i,
+                      struct gl_client_array *vbo_array,
                       const struct gl_client_array *uploaded_array,
                       const struct gl_client_array *array,
                       const char *ptr)
 {
-   struct gl_client_array *vbo_array = &brw->vb.vbo_array[i];
-
    vbo_array->Size = array->Size;
    vbo_array->Type = array->Type;
    vbo_array->Stride = array->Stride;
@@ -389,8 +384,6 @@ interleaved_vbo_array( struct brw_context *brw,
    vbo_array->Normalized = array->Normalized;
    vbo_array->_MaxElement = array->_MaxElement;        
    vbo_array->BufferObj = uploaded_array->BufferObj;
-
-   return vbo_array;
 }
 
 
@@ -404,6 +397,7 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
    GLuint i;
    const void *ptr = NULL;
    GLuint interleave = 0;
+   struct gl_client_array vbo_array_temp[VERT_ATTRIB_MAX];
 
    struct brw_vertex_element *enabled[VERT_ATTRIB_MAX];
    GLuint nr_enabled = 0;
@@ -457,30 +451,29 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
 
    /* Upload interleaved arrays if all uploads are interleaved
     */
-   if (nr_uploads > 1 && 
-       interleave && 
-       interleave <= 256) {
-      upload[0]->glarray =
-        interleaved_copy_array_to_vbo_array(brw, 0,
-                                            upload[0]->glarray,
-                                            interleave,
-                                            upload[0]->count);
+   if (nr_uploads > 1 && interleave && interleave <= 256) {
+      interleaved_copy_array_to_vbo_array(brw, &vbo_array_temp[0],
+                                         upload[0]->glarray,
+                                         interleave,
+                                         upload[0]->count);
+      upload[0]->glarray = &vbo_array_temp[0];
 
       for (i = 1; i < nr_uploads; i++) {
-        upload[i]->glarray = interleaved_vbo_array(brw,
-                                                   i,
-                                                   upload[0]->glarray,
-                                                   upload[i]->glarray,
-                                                   ptr);
+        interleaved_vbo_array(brw,
+                              &vbo_array_temp[i],
+                              upload[0]->glarray,
+                              upload[i]->glarray,
+                              ptr);
+        upload[i]->glarray = &vbo_array_temp[i];
       }
    }
    else {
       for (i = 0; i < nr_uploads; i++) {
-        upload[i]->glarray = copy_array_to_vbo_array(brw, i,
-                                                     upload[i]->glarray,
-                                                     upload[i]->element_size,
-                                                     upload[i]->count);
-
+        copy_array_to_vbo_array(brw, &vbo_array_temp[i],
+                                upload[i]->glarray,
+                                upload[i]->element_size,
+                                upload[i]->count);
+        upload[i]->glarray = &vbo_array_temp[i];
       }
    }