st/mesa: Skip scissor rect updates when scissor is entirely disabled.
[mesa.git] / src / mesa / state_tracker / st_atom_scissor.c
index d3450be01e9695c1ea96384f822c36644db403cd..f0546df6cb3b2fee1311314f886a7bfd31fef5d4 100644 (file)
@@ -36,6 +36,7 @@
 #include "st_context.h"
 #include "pipe/p_context.h"
 #include "st_atom.h"
+#include "st_util.h"
 
 
 /**
@@ -53,7 +54,10 @@ st_update_scissor( struct st_context *st )
    unsigned i;
    bool changed = false;
 
-   for (i = 0 ; i < ctx->Const.MaxViewports; i++) {
+   if (!ctx->Scissor.EnableFlags)
+      return;
+
+   for (i = 0 ; i < st->state.num_viewports; i++) {
       scissor[i].minx = 0;
       scissor[i].miny = 0;
       scissor[i].maxx = fb_width;
@@ -82,7 +86,7 @@ st_update_scissor( struct st_context *st )
       /* Now invert Y if needed.
        * Gallium drivers use the convention Y=0=top for surfaces.
        */
-      if (st_fb_orientation(fb) == Y_0_TOP) {
+      if (st->state.fb_orientation == Y_0_TOP) {
          miny = fb->Height - scissor[i].maxy;
          maxy = fb->Height - scissor[i].miny;
          scissor[i].miny = miny;
@@ -95,8 +99,12 @@ st_update_scissor( struct st_context *st )
          changed = true;
       }
    }
-   if (changed)
-      st->pipe->set_scissor_states(st->pipe, 0, ctx->Const.MaxViewports, scissor); /* activate */
+
+   if (changed) {
+      struct pipe_context *pipe = st->pipe;
+
+      pipe->set_scissor_states(pipe, 0, st->state.num_viewports, scissor);
+   }
 }
 
 void