llvmpipe: dynamic allocation of triangle a0/dadx/dady arrays
authorBrian Paul <brianp@vmware.com>
Fri, 4 Dec 2009 16:14:40 +0000 (09:14 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 4 Dec 2009 16:14:42 +0000 (09:14 -0700)
Much less memory per triangle now.

src/gallium/drivers/llvmpipe/lp_rast.h
src/gallium/drivers/llvmpipe/lp_setup_tri.c

index ab21a7783457f0d2a708535286d50e877534f394..435993d44d26551fd693a5ce92703cfdf660265d 100644 (file)
@@ -64,14 +64,12 @@ struct lp_rast_shader_inputs {
    const struct lp_rast_state *state;
 
    /* Attribute interpolation:
-    *
     * First coefficient is position.
-    *
-    * FIXME: reduce memory waste!
+    * These pointers point into the bin data buffer.
     */
-   float a0[1 + PIPE_MAX_SHADER_INPUTS][4];
-   float dadx[1 + PIPE_MAX_SHADER_INPUTS][4];
-   float dady[1 + PIPE_MAX_SHADER_INPUTS][4];
+   float (*a0)[4];
+   float (*dadx)[4];
+   float (*dady)[4];
 };
 
 
index c21c465a75dfcee2436b6b1a3bba9ba13048cf6c..3b71bc4c034684ab03a7deb9a7bff294af11d722 100644 (file)
@@ -177,6 +177,16 @@ static void setup_tri_coefficients( struct setup_context *setup,
 {
    unsigned slot;
 
+   /* Allocate space for the a0, dadx and dady arrays
+    */
+   {
+      unsigned bytes;
+      bytes = (setup->fs.nr_inputs + 1) * 4 * sizeof(float);
+      tri->inputs.a0   = get_data_aligned( &setup->data, bytes, 16 );
+      tri->inputs.dadx = get_data_aligned( &setup->data, bytes, 16 );
+      tri->inputs.dady = get_data_aligned( &setup->data, bytes, 16 );
+   }
+
    /* The internal position input is in slot zero:
     */
    setup_fragcoord_coef(tri, 0, v1, v2, v3);