iris: Optimize out redundant sampler state binds
[mesa.git] / 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;
 }
 
 /**