iris: Optimize out redundant sampler state binds
authorKenneth Graunke <kenneth@whitecape.org>
Sun, 8 Sep 2019 05:30:02 +0000 (22:30 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 9 Sep 2019 18:55:27 +0000 (11:55 -0700)
This cuts roughly 85% of the 3DSTATE_SAMPLER_STATE_POINTERS_PS calls in
the J2DBench images test.  For some reason, the state tracker is calling
bind_sampler_state with the same sampler state in a bunch of cases.

src/gallium/drivers/iris/iris_state.c

index 315b013342012bba9f93c120ccc16fd7c9f8593d..a503f38d6ca511a9c19e05c34bb0a3c0ac472a8a 100644 (file)
@@ -1606,11 +1606,17 @@ iris_bind_sampler_states(struct pipe_context *ctx,
 
    assert(start + count <= IRIS_MAX_TEXTURE_SAMPLERS);
 
+   bool dirty = false;
+
    for (int i = 0; i < count; i++) {
-      shs->samplers[start + i] = states[i];
+      if (shs->samplers[start + i] != states[i]) {
+         shs->samplers[start + i] = states[i];
+         dirty = true;
+      }
    }
 
-   ice->state.dirty |= IRIS_DIRTY_SAMPLER_STATES_VS << stage;
+   if (dirty)
+      ice->state.dirty |= IRIS_DIRTY_SAMPLER_STATES_VS << stage;
 }
 
 /**