i915: suppress repeated sampler state emission
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 25 Nov 2010 22:27:37 +0000 (22:27 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 21 Feb 2011 13:04:41 +0000 (13:04 +0000)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/mesa/drivers/dri/i915/i915_context.h
src/mesa/drivers/dri/i915/i915_vtbl.c

index 2c80ded075b83c6f756f8be71dc5b3ee496ad672..d0245218f010a302fac7af2402ee99a07a7e05ee 100644 (file)
@@ -262,6 +262,7 @@ struct i915_context
 
    struct i915_hw_state state;
    uint32_t last_draw_offset;
+   GLuint last_sampler;
 };
 
 
index 394935c96cc1cc0a3d7ab4c7e36308d72fa8f348..14c409bfc6c577f201890b0d1e601a847ff8d35f 100644 (file)
@@ -426,6 +426,7 @@ i915_emit_state(struct intel_context *intel)
     */
    if (dirty & I915_UPLOAD_TEX_ALL) {
       int nr = 0;
+      GLuint unwind;
 
       for (i = 0; i < I915_TEX_UNITS; i++)
          if (dirty & I915_UPLOAD_TEX(i))
@@ -445,6 +446,7 @@ i915_emit_state(struct intel_context *intel)
          }
       ADVANCE_BATCH();
 
+      unwind = intel->batch.used;
       BEGIN_BATCH(2 + nr * 3);
       OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * nr));
       OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT);
@@ -455,6 +457,13 @@ i915_emit_state(struct intel_context *intel)
             OUT_BATCH(state->Tex[i][I915_TEXREG_SS4]);
          }
       ADVANCE_BATCH();
+      if (i915->last_sampler &&
+         memcmp(intel->batch.map + i915->last_sampler,
+                intel->batch.map + unwind,
+                (2 + nr*3)*sizeof(int)) == 0)
+         intel->batch.used = unwind;
+      else
+         i915->last_sampler = unwind;
    }
 
    if (dirty & I915_UPLOAD_CONSTANTS) {
@@ -658,6 +667,7 @@ i915_new_batch(struct intel_context *intel)
     */
    i915->state.emitted = 0;
    i915->last_draw_offset = 0;
+   i915->last_sampler = 0;
 }
 
 static void