i915g: Don't emit FS constants when VS contants change
authorJakob Bornecrantz <wallbraker@gmail.com>
Mon, 29 Nov 2010 20:37:09 +0000 (21:37 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Fri, 21 Jan 2011 19:53:29 +0000 (20:53 +0100)
src/gallium/drivers/i915/i915_context.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_debug.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i915/i915_state_fpc.c

index 9d43381f7b39571e2d0c91a7ee8bb6866de49111..15454d02cfb4f62ed54dfe44ab1b319c464000c7 100644 (file)
@@ -51,6 +51,14 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    struct draw_context *draw = i915->draw;
    void *mapped_indices = NULL;
    unsigned i;
+   unsigned cbuf_dirty;
+
+
+   /*
+    * Ack vs contants here, helps ipers a lot.
+    */
+   cbuf_dirty = i915->dirty & I915_NEW_VS_CONSTANTS;
+   i915->dirty &= ~I915_NEW_VS_CONSTANTS;
 
    if (i915->dirty)
       i915_update_derived(i915);
@@ -70,10 +78,12 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       mapped_indices = i915_buffer(i915->index_buffer.buffer)->data;
    draw_set_mapped_index_buffer(draw, mapped_indices);
 
-   draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
-                                   i915->current.constants[PIPE_SHADER_VERTEX],
-                                   (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 
-                                      4 * sizeof(float)));
+   if (cbuf_dirty) {
+      draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
+                                      i915->current.constants[PIPE_SHADER_VERTEX],
+                                      (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 
+                                         4 * sizeof(float)));
+   }
 
    /*
     * Do the drawing
index 1bf9cde4d4de15b0b8e3922c0651d1c25623009d..6dab3a14a58d3063a266ac852bd3341ecad81aa7 100644 (file)
@@ -257,9 +257,11 @@ struct i915_context {
 #define I915_NEW_DEPTH_STENCIL 0x200
 #define I915_NEW_SAMPLER       0x400
 #define I915_NEW_SAMPLER_VIEW  0x800
-#define I915_NEW_CONSTANTS     0x1000
-#define I915_NEW_VBO           0x2000
-#define I915_NEW_VS            0x4000
+#define I915_NEW_VS_CONSTANTS  0x1000
+#define I915_NEW_FS_CONSTANTS  0x2000
+#define I915_NEW_GS_CONSTANTS  0x4000
+#define I915_NEW_VBO           0x8000
+#define I915_NEW_VS            0x10000
 
 
 /* Driver's internally generated state flags:
index 87c435a2f364c0d98ff2064e81276a1f18d3f7a6..845e92cf5c60194d562393b58c9b27424ca7902b 100644 (file)
@@ -948,7 +948,8 @@ i915_dump_dirty(struct i915_context *i915, const char *func)
       {I915_NEW_DEPTH_STENCIL, "depth_stencil"},
       {I915_NEW_SAMPLER,       "sampler"},
       {I915_NEW_SAMPLER_VIEW,  "sampler_view"},
-      {I915_NEW_CONSTANTS,     "constants"},
+      {I915_NEW_VS_CONSTANTS,  "vs_const"},
+      {I915_NEW_FS_CONSTANTS,  "fs_const"},
       {I915_NEW_VBO,           "vbo"},
       {I915_NEW_VS,            "vs"},
       {0, NULL},
index f5b60ed59427414d348ac823871622037675b953..cc8bd3b0c396587c7858103e18f062f8dadd4694 100644 (file)
@@ -527,6 +527,10 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
    struct i915_context *i915 = i915_context(pipe);
    draw_flush(i915->draw);
 
+   /* XXX don't support geom shaders now */
+   if (shader == PIPE_SHADER_GEOMETRY)
+      return;
+
    /* Make a copy of shader constants.
     * During fragment program translation we may add additional
     * constants to the array.
@@ -538,6 +542,10 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
     */
    if (buf) {
       struct i915_buffer *ir = i915_buffer(buf);
+
+      if (!memcmp(i915->current.constants[shader], ir->data, ir->b.b.width0))
+         return;
+
       memcpy(i915->current.constants[shader], ir->data, ir->b.b.width0);
       i915->current.num_user_constants[shader] = (ir->b.b.width0 /
                                                  4 * sizeof(float));
@@ -546,8 +554,7 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
       i915->current.num_user_constants[shader] = 0;
    }
 
-
-   i915->dirty |= I915_NEW_CONSTANTS;
+   i915->dirty |= shader == PIPE_SHADER_VERTEX ? I915_NEW_VS_CONSTANTS : I915_NEW_FS_CONSTANTS;
 }
 
 
index ec7cec0e4713d651ec9f27fc328c06ac1889e0aa..1959a24691dcdcc1578c988bd16022a67a0c6254 100644 (file)
@@ -40,7 +40,7 @@ static void update_hw_constants(struct i915_context *i915)
 struct i915_tracked_state i915_hw_constants = {
    "hw_constants",
    update_hw_constants,
-   I915_NEW_CONSTANTS | I915_NEW_FS
+   I915_NEW_FS_CONSTANTS | I915_NEW_FS
 };