[Mesa-dev] [PATCH 08/18] mesa: Add indexed version of mesa_scissor

Courtney Goeltzenleuchter courtney at lunarg.com
Wed Nov 20 14:59:23 PST 2013


Signed-off-by: Courtney Goeltzenleuchter <courtney at LunarG.com>
---
 src/mesa/main/attrib.c  | 17 ++++++++++-------
 src/mesa/main/context.c | 10 +++++++++-
 src/mesa/main/scissor.c | 46 ++++++++++++++++++++++++++++++----------------
 src/mesa/main/scissor.h |  2 +-
 4 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 996e2cf..3f9c648 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1210,14 +1210,17 @@ _mesa_PopAttrib(void)
          case GL_SCISSOR_BIT:
             {
                const struct gl_scissor_attrib *scissor;
+               GLuint i;
                scissor = (const struct gl_scissor_attrib *) attr->data;
-               _mesa_set_scissor(ctx,
-                                 scissor->ScissorArray[0].X,
-                                 scissor->ScissorArray[0].Y,
-                                 scissor->ScissorArray[0].Width,
-                                 scissor->ScissorArray[0].Height);
-               _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->EnableFlags & 1);
-
+               for (i = 0; i < ctx->Const.MaxViewports; i++) {
+                  _mesa_set_scissori(ctx, i,
+                                     scissor->ScissorArray[i].X,
+                                     scissor->ScissorArray[i].Y,
+                                     scissor->ScissorArray[i].Width,
+                                     scissor->ScissorArray[i].Height);
+                  _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i,
+                                    (scissor->EnableFlags >> i) & 1);
+               }
             }
             break;
          case GL_STENCIL_BUFFER_BIT:
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 15eedcd..91f3812 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1426,13 +1426,21 @@ check_compatible(const struct gl_context *ctx,
 void
 _mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
 {
+   GLuint i;
+
    if (!ctx->ViewportInitialized && width > 0 && height > 0) {
       /* Note: set flag here, before calling _mesa_set_viewport(), to prevent
        * potential infinite recursion.
        */
       ctx->ViewportInitialized = GL_TRUE;
       _mesa_set_viewport(ctx, 0, 0, width, height);
-      _mesa_set_scissor(ctx, 0, 0, width, height);
+      /* ARB_viewport_array specifies that glScissor is equivalent to
+       * calling glViewportArray with an array containing a single
+       * viewport once for each supported viewport.
+       */
+      for (i = 0; i < ctx->Const.MaxViewports; i++) {
+         _mesa_set_scissori(ctx, i, 0, 0, width, height);
+      }
    }
 }
 
diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c
index 426632e..3187ab1 100644
--- a/src/mesa/main/scissor.c
+++ b/src/mesa/main/scissor.c
@@ -35,6 +35,7 @@
 void GLAPIENTRY
 _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
 {
+   GLuint i;
    GET_CURRENT_CONTEXT(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
@@ -45,7 +46,13 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
       return;
    }
 
-   _mesa_set_scissor(ctx, x, y, width, height);
+   /* ARB_viewport_array specifies that glScissor is equivalent to
+    * calling glViewportArray with an array containing a single
+    * viewport once for each supported viewport.
+    */
+   for (i = 0; i < ctx->Const.MaxViewports; i++) {
+      _mesa_set_scissori(ctx, i, x, y, width, height);
+   }
 }
 
 
@@ -63,23 +70,25 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
  * the dd_function_table::Scissor callback.
  */
 void
-_mesa_set_scissor(struct gl_context *ctx, 
+_mesa_set_scissori(struct gl_context *ctx, GLuint index,
                   GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   if (x == ctx->Scissor.ScissorArray[0].X &&
-       y == ctx->Scissor.ScissorArray[0].Y &&
-       width == ctx->Scissor.ScissorArray[0].Width &&
-       height == ctx->Scissor.ScissorArray[0].Height)
+   if (x == ctx->Scissor.ScissorArray[index].X &&
+       y == ctx->Scissor.ScissorArray[index].Y &&
+       width == ctx->Scissor.ScissorArray[index].Width &&
+       height == ctx->Scissor.ScissorArray[index].Height)
       return;
 
    FLUSH_VERTICES(ctx, _NEW_SCISSOR);
-   ctx->Scissor.ScissorArray[0].X = x;
-   ctx->Scissor.ScissorArray[0].Y = y;
-   ctx->Scissor.ScissorArray[0].Width = width;
-   ctx->Scissor.ScissorArray[0].Height = height;
+   ctx->Scissor.ScissorArray[index].X = x;
+   ctx->Scissor.ScissorArray[index].Y = y;
+   ctx->Scissor.ScissorArray[index].Width = width;
+   ctx->Scissor.ScissorArray[index].Height = height;
 
    if (ctx->Driver.Scissor)
-      ctx->Driver.Scissor( ctx, 0, x, y, width, height );
+      ctx->Driver.Scissor(ctx, index,
+                          ctx->Scissor.ScissorArray[index].X, ctx->Scissor.ScissorArray[index].Y,
+                          ctx->Scissor.ScissorArray[index].Width, ctx->Scissor.ScissorArray[index].Height);
 }
 
 
@@ -90,10 +99,15 @@ _mesa_set_scissor(struct gl_context *ctx,
 void
 _mesa_init_scissor(struct gl_context *ctx)
 {
+   GLint i;
+
    /* Scissor group */
-   ctx->Scissor.EnableFlags = GL_FALSE;
-   ctx->Scissor.ScissorArray[0].X = 0;
-   ctx->Scissor.ScissorArray[0].Y = 0;
-   ctx->Scissor.ScissorArray[0].Width = 0;
-   ctx->Scissor.ScissorArray[0].Height = 0;
+   ctx->Scissor.EnableFlags = 0;
+
+   for (i = 0; i < MAX_VIEWPORTS; i++) {
+      ctx->Scissor.ScissorArray[i].X = 0;
+      ctx->Scissor.ScissorArray[i].Y = 0;
+      ctx->Scissor.ScissorArray[i].Width = 0;
+      ctx->Scissor.ScissorArray[i].Height = 0;
+   }
 }
diff --git a/src/mesa/main/scissor.h b/src/mesa/main/scissor.h
index 0d7e201..f8aca2c 100644
--- a/src/mesa/main/scissor.h
+++ b/src/mesa/main/scissor.h
@@ -36,7 +36,7 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height );
 
 
 extern void
-_mesa_set_scissor(struct gl_context *ctx, 
+_mesa_set_scissori(struct gl_context *ctx, GLuint index,
                   GLint x, GLint y, GLsizei width, GLsizei height);
 
 
-- 
1.8.1.2



More information about the mesa-dev mailing list