[Mesa-dev] [i965][V2] i965/draw: Move constant formation outside of for loop and use an enum.

Mark Mueller markkmueller at gmail.com
Thu Aug 8 13:41:25 PDT 2013


Signed-off-by: Mark Mueller <MarkKMueller at gmail.com>
---
 src/mesa/drivers/dri/i965/brw_draw.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 6170d07..1b5ed55 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -367,6 +367,12 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
    bool retval = true;
    GLuint i;
    bool fail_next = false;
+   const int estimated_max_prim_size =
+           512 + /* batchbuffer commands */
+           ((BRW_MAX_TEX_UNIT * (sizeof(struct brw_sampler_state) + sizeof(struct gen5_sampler_default_color)))) +
+           1024 + /* gen6 VS push constants */
+           1024 + /* gen6 WM push constants */
+           512; /* misc. pad */
 
    if (ctx->NewState)
       _mesa_update_state( ctx );
@@ -405,16 +411,6 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
    brw->state.dirty.brw |= BRW_NEW_VERTICES;
 
    for (i = 0; i < nr_prims; i++) {
-      int estimated_max_prim_size;
-
-      estimated_max_prim_size = 512; /* batchbuffer commands */
-      estimated_max_prim_size += (BRW_MAX_TEX_UNIT *
-				  (sizeof(struct brw_sampler_state) +
-				   sizeof(struct gen5_sampler_default_color)));
-      estimated_max_prim_size += 1024; /* gen6 VS push constants */
-      estimated_max_prim_size += 1024; /* gen6 WM push constants */
-      estimated_max_prim_size += 512; /* misc. pad */
-
       /* Flush the batch if it's approaching full, so that we don't wrap while
        * we've got validated state that needs to be in the same batch as the
        * primitives.
-- 
1.8.3.1




More information about the mesa-dev mailing list