[Mesa-dev] [PATCH] mesa: Change driver interface for ARB_viewport_array

Courtney Goeltzenleuchter courtney at lunarg.com
Fri Nov 1 09:31:27 PDT 2013


Start setting the stage for ARB_viewport_array extension support.
Add the index parameter to the Scissor, Viewport and
DepthRange driver methods. Update i965 and Gallium to match.
Include change for i915, nouveau and radeon per feedback from mesa-dev.

piglit quick.tests passes
---
 src/mesa/drivers/common/driverfuncs.c        |  2 +-
 src/mesa/drivers/dri/i915/i830_state.c       |  6 +++---
 src/mesa/drivers/dri/i915/i830_vtbl.c        |  4 ++--
 src/mesa/drivers/dri/i915/i915_state.c       |  6 +++---
 src/mesa/drivers/dri/i915/i915_vtbl.c        |  4 ++--
 src/mesa/drivers/dri/i915/intel_context.c    |  4 ++--
 src/mesa/drivers/dri/i915/intel_context.h    |  2 +-
 src/mesa/drivers/dri/i965/brw_context.c      |  4 ++--
 src/mesa/drivers/dri/i965/brw_context.h      |  2 +-
 src/mesa/drivers/dri/nouveau/nouveau_state.c |  6 +++---
 src/mesa/drivers/dri/r200/r200_state.c       |  6 +++---
 src/mesa/drivers/dri/radeon/radeon_common.c  |  9 ++++-----
 src/mesa/drivers/dri/radeon/radeon_common.h  |  2 +-
 src/mesa/drivers/dri/radeon/radeon_state.c   |  6 +++---
 src/mesa/drivers/dri/swrast/swrast.c         |  3 ++-
 src/mesa/main/dd.h                           | 10 +++++++---
 src/mesa/main/scissor.c                      |  2 +-
 src/mesa/main/viewport.c                     |  4 ++--
 src/mesa/state_tracker/st_cb_viewport.c      |  3 ++-
 19 files changed, 45 insertions(+), 40 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 5faa98a..e45dc0e 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -299,7 +299,7 @@ _mesa_init_driver_state(struct gl_context *ctx)
    ctx->Driver.LogicOpcode(ctx, ctx->Color.LogicOp);
    ctx->Driver.PointSize(ctx, ctx->Point.Size);
    ctx->Driver.PolygonStipple(ctx, (const GLubyte *) ctx->PolygonStipple);
-   ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+   ctx->Driver.Scissor(ctx, 0, ctx->Scissor.X, ctx->Scissor.Y,
                        ctx->Scissor.Width, ctx->Scissor.Height);
    ctx->Driver.ShadeModel(ctx, ctx->Light.ShadeModel);
    ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT,
diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c
index cedc58a..c66feb3 100644
--- a/src/mesa/drivers/dri/i915/i830_state.c
+++ b/src/mesa/drivers/dri/i915/i830_state.c
@@ -453,7 +453,7 @@ i830DepthMask(struct gl_context * ctx, GLboolean flag)
 
 /** Called from ctx->Driver.Viewport() */
 static void
-i830Viewport(struct gl_context * ctx,
+i830Viewport(struct gl_context * ctx, GLuint idx,
               GLint x, GLint y, GLsizei width, GLsizei height)
 {
    intelCalcViewport(ctx);
@@ -462,7 +462,7 @@ i830Viewport(struct gl_context * ctx,
 
 /** Called from ctx->Driver.DepthRange() */
 static void
-i830DepthRange(struct gl_context * ctx, GLclampd nearval, GLclampd farval)
+i830DepthRange(struct gl_context * ctx, GLuint idx, GLclampd nearval, GLclampd farval)
 {
    intelCalcViewport(ctx);
 }
@@ -536,7 +536,7 @@ i830PolygonStipple(struct gl_context * ctx, const GLubyte * mask)
  * Hardware clipping
  */
 static void
-i830Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+i830Scissor(struct gl_context * ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
    struct i830_context *i830 = i830_context(ctx);
    int x1, y1, x2, y2;
diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c
index f988a83..33ca002 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -837,10 +837,10 @@ i830_update_draw_buffer(struct intel_context *intel)
 
    /* Set state we know depends on drawable parameters:
     */
-   ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+   ctx->Driver.Scissor(ctx, 0, ctx->Scissor.X, ctx->Scissor.Y,
 		       ctx->Scissor.Width, ctx->Scissor.Height);
 
-   ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far);
+   ctx->Driver.DepthRange(ctx, 0, ctx->Viewport.Near, ctx->Viewport.Far);
 
    /* Update culling direction which changes depending on the
     * orientation of the buffer:
diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c
index 2fd0bf1..fb6b7a1 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -426,7 +426,7 @@ intelCalcViewport(struct gl_context * ctx)
 
 /** Called from ctx->Driver.Viewport() */
 static void
-i915Viewport(struct gl_context * ctx,
+i915Viewport(struct gl_context * ctx, GLuint idx,
               GLint x, GLint y, GLsizei width, GLsizei height)
 {
    intelCalcViewport(ctx);
@@ -435,7 +435,7 @@ i915Viewport(struct gl_context * ctx,
 
 /** Called from ctx->Driver.DepthRange() */
 static void
-i915DepthRange(struct gl_context * ctx, GLclampd nearval, GLclampd farval)
+i915DepthRange(struct gl_context * ctx, GLuint idx, GLclampd nearval, GLclampd farval)
 {
    intelCalcViewport(ctx);
 }
@@ -510,7 +510,7 @@ i915PolygonStipple(struct gl_context * ctx, const GLubyte * mask)
  * Hardware clipping
  */
 static void
-i915Scissor(struct gl_context * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+i915Scissor(struct gl_context * ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
    struct i915_context *i915 = I915_CONTEXT(ctx);
    int x1, y1, x2, y2;
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 3368fe4..10a2865 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -811,9 +811,9 @@ i915_update_draw_buffer(struct intel_context *intel)
 
    /* Set state we know depends on drawable parameters:
     */
-   ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+   ctx->Driver.Scissor(ctx, 0, ctx->Scissor.X, ctx->Scissor.Y,
 		       ctx->Scissor.Width, ctx->Scissor.Height);
-   ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far);
+   ctx->Driver.DepthRange(ctx, 0, ctx->Viewport.Near, ctx->Viewport.Far);
 
    /* Update culling direction which changes depending on the
     * orientation of the buffer:
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index 2748514..40a7a4f 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -248,13 +248,13 @@ intel_prepare_render(struct intel_context *intel)
 }
 
 static void
-intel_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+intel_viewport(struct gl_context *ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
     struct intel_context *intel = intel_context(ctx);
     __DRIcontext *driContext = intel->driContext;
 
     if (intel->saved_viewport)
-	intel->saved_viewport(ctx, x, y, w, h);
+	intel->saved_viewport(ctx, 0, x, y, w, h);
 
     if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
        dri2InvalidateDrawable(driContext->driDrawablePriv);
diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h
index 6fb73fc..8b00f8b 100644
--- a/src/mesa/drivers/dri/i915/intel_context.h
+++ b/src/mesa/drivers/dri/i915/intel_context.h
@@ -278,7 +278,7 @@ struct intel_context
 
    __DRIcontext *driContext;
    struct intel_screen *intelScreen;
-   void (*saved_viewport)(struct gl_context * ctx,
+   void (*saved_viewport)(struct gl_context * ctx, GLuint idx,
 			  GLint x, GLint y, GLsizei width, GLsizei height);
 
    /**
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 3880e18..5b4d662d 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -125,13 +125,13 @@ intelGetString(struct gl_context * ctx, GLenum name)
 }
 
 static void
-intel_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+intel_viewport(struct gl_context *ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
    struct brw_context *brw = brw_context(ctx);
    __DRIcontext *driContext = brw->driContext;
 
    if (brw->saved_viewport)
-      brw->saved_viewport(ctx, x, y, w, h);
+      brw->saved_viewport(ctx, idx, x, y, w, h);
 
    if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
       dri2InvalidateDrawable(driContext->driDrawablePriv);
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 3be2138..c261ae8 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1411,7 +1411,7 @@ struct brw_context
 
    __DRIcontext *driContext;
    struct intel_screen *intelScreen;
-   void (*saved_viewport)(struct gl_context *ctx,
+   void (*saved_viewport)(struct gl_context *ctx, GLuint idx,
                           GLint x, GLint y, GLsizei width, GLsizei height);
 };
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index 5155da9..f9c093a 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -107,7 +107,7 @@ nouveau_depth_mask(struct gl_context *ctx, GLboolean flag)
 }
 
 static void
-nouveau_depth_range(struct gl_context *ctx, GLclampd nearval, GLclampd farval)
+nouveau_depth_range(struct gl_context *ctx, GLuint idx, GLclampd nearval, GLclampd farval)
 {
 	context_dirty(ctx, VIEWPORT);
 }
@@ -343,7 +343,7 @@ nouveau_render_mode(struct gl_context *ctx, GLenum mode)
 }
 
 static void
-nouveau_scissor(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+nouveau_scissor(struct gl_context *ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
 	context_dirty(ctx, SCISSOR);
 }
@@ -430,7 +430,7 @@ nouveau_tex_parameter(struct gl_context *ctx, GLenum target,
 }
 
 static void
-nouveau_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+nouveau_viewport(struct gl_context *ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
 	context_dirty(ctx, VIEWPORT);
 }
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index d3e8114..4662dcb 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -1600,7 +1600,7 @@ void r200_vtbl_update_scissor( struct gl_context *ctx )
 }
 
 
-static void r200Viewport( struct gl_context *ctx, GLint x, GLint y,
+static void r200Viewport( struct gl_context *ctx, GLuint idx, GLint x, GLint y,
 			    GLsizei width, GLsizei height )
 {
    /* Don't pipeline viewport changes, conflict with window offset
@@ -1612,8 +1612,8 @@ static void r200Viewport( struct gl_context *ctx, GLint x, GLint y,
    radeon_viewport(ctx, x, y, width, height);
 }
 
-static void r200DepthRange( struct gl_context *ctx, GLclampd nearval,
-			      GLclampd farval )
+static void r200DepthRange( struct gl_context *ctx, GLuint idx,
+                           GLclampd nearval, GLclampd farval )
 {
    r200UpdateWindow( ctx );
 }
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c
index 0f0945d..4a37acd 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.c
+++ b/src/mesa/drivers/dri/radeon/radeon_common.c
@@ -141,8 +141,7 @@ void radeonUpdateScissor( struct gl_context *ctx )
 /* =============================================================
  * Scissoring
  */
-
-void radeonScissor(struct gl_context* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+void radeonScissor(struct gl_context* ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
 	radeonContextPtr radeon = RADEON_CONTEXT(ctx);
 	if (ctx->Scissor.Enabled) {
@@ -320,7 +319,7 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
 #if 0
 	/* update viewport since it depends on window size */
 	if (ctx->Driver.Viewport) {
-		ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y,
+		ctx->Driver.Viewport(ctx, 0, ctx->Viewport.X, ctx->Viewport.Y,
 				     ctx->Viewport.Width, ctx->Viewport.Height);
 	} else {
 
@@ -334,7 +333,7 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
 	radeon->NewGLState |= _NEW_SCISSOR;
 
 	if (ctx->Driver.DepthRange)
-		ctx->Driver.DepthRange(ctx,
+		ctx->Driver.DepthRange(ctx, 0,
 				       ctx->Viewport.Near,
 				       ctx->Viewport.Far);
 
@@ -411,7 +410,7 @@ void radeon_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GL
 {
 	radeonContextPtr radeon = RADEON_CONTEXT(ctx);
 	__DRIcontext *driContext = radeon->dri.context;
-	void (*old_viewport)(struct gl_context *ctx, GLint x, GLint y,
+	void (*old_viewport)(struct gl_context *ctx, GLuint idx, GLint x, GLint y,
 			     GLsizei w, GLsizei h);
 
 	if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.h b/src/mesa/drivers/dri/radeon/radeon_common.h
index 636822f..1d04088 100644
--- a/src/mesa/drivers/dri/radeon/radeon_common.h
+++ b/src/mesa/drivers/dri/radeon/radeon_common.h
@@ -8,7 +8,7 @@
 void radeonUserClear(struct gl_context *ctx, GLuint mask);
 void radeonSetCliprects(radeonContextPtr radeon);
 void radeonUpdateScissor( struct gl_context *ctx );
-void radeonScissor(struct gl_context* ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+void radeonScissor(struct gl_context* ctx, GLuint idx, GLint x, GLint y, GLsizei w, GLsizei h);
 
 extern uint32_t radeonGetAge(radeonContextPtr radeon);
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index 70542f6..19ead91 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1383,7 +1383,7 @@ void radeonUpdateWindow( struct gl_context *ctx )
 }
 
 
-static void radeonViewport( struct gl_context *ctx, GLint x, GLint y,
+static void radeonViewport( struct gl_context *ctx, GLuint idx, GLint x, GLint y,
 			    GLsizei width, GLsizei height )
 {
    /* Don't pipeline viewport changes, conflict with window offset
@@ -1395,8 +1395,8 @@ static void radeonViewport( struct gl_context *ctx, GLint x, GLint y,
    radeon_viewport(ctx, x, y, width, height);
 }
 
-static void radeonDepthRange( struct gl_context *ctx, GLclampd nearval,
-			      GLclampd farval )
+static void radeonDepthRange( struct gl_context *ctx, GLuint idx,
+                             GLclampd nearval, GLclampd farval )
 {
    radeonUpdateWindow( ctx );
 }
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index bfa2efd..ffb1fa0 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -618,7 +618,8 @@ update_state( struct gl_context *ctx, GLuint new_state )
 }
 
 static void
-viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+viewport(struct gl_context *ctx, GLuint idx,
+         GLint x, GLint y, GLsizei w, GLsizei h)
 {
     struct gl_framebuffer *draw = ctx->WinSysDrawBuffer;
     struct gl_framebuffer *read = ctx->WinSysReadBuffer;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 5011921..7f57a39 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -479,7 +479,8 @@ struct dd_function_table {
    /** Enable or disable writing into the depth buffer */
    void (*DepthMask)(struct gl_context *ctx, GLboolean flag);
    /** Specify mapping of depth values from NDC to window coordinates */
-   void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval);
+   void (*DepthRange)(struct gl_context *ctx, GLuint idx,
+                      GLclampd nearval, GLclampd farval);
    /** Specify the current buffer for writing */
    void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer );
    /** Specify the buffers for writing for fragment programs*/
@@ -519,7 +520,9 @@ struct dd_function_table {
    /** Set rasterization mode */
    void (*RenderMode)(struct gl_context *ctx, GLenum mode );
    /** Define the scissor box */
-   void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+   void (*Scissor)(struct gl_context *ctx, GLuint idx,
+                   GLint x, GLint y,
+                   GLsizei width, GLsizei height);
    /** Select flat or smooth shading */
    void (*ShadeModel)(struct gl_context *ctx, GLenum mode);
    /** OpenGL 2.0 two-sided StencilFunc */
@@ -541,7 +544,8 @@ struct dd_function_table {
                         struct gl_texture_object *texObj,
                         GLenum pname, const GLfloat *params);
    /** Set the viewport */
-   void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+   void (*Viewport)(struct gl_context *ctx, GLuint idx,
+                    GLint x, GLint y, GLsizei w, GLsizei h);
    /*@}*/
 
 
diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c
index 0eddaa6..4eb6337 100644
--- a/src/mesa/main/scissor.c
+++ b/src/mesa/main/scissor.c
@@ -79,7 +79,7 @@ _mesa_set_scissor(struct gl_context *ctx,
    ctx->Scissor.Height = height;
 
    if (ctx->Driver.Scissor)
-      ctx->Driver.Scissor( ctx, x, y, width, height );
+      ctx->Driver.Scissor( ctx, 0, x, y, width, height );
 }
 
 
diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 91578ba..5da10ba 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -99,7 +99,7 @@ _mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y,
       /* Many drivers will use this call to check for window size changes
        * and reallocate the z/stencil/accum/etc buffers if needed.
        */
-      ctx->Driver.Viewport(ctx, x, y, width, height);
+      ctx->Driver.Viewport(ctx, 0, x, y, width, height);
    }
 }
 
@@ -143,7 +143,7 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval)
 #endif
 
    if (ctx->Driver.DepthRange) {
-      ctx->Driver.DepthRange(ctx, nearval, farval);
+      ctx->Driver.DepthRange(ctx, 0, nearval, farval);
    }
 }
 
diff --git a/src/mesa/state_tracker/st_cb_viewport.c b/src/mesa/state_tracker/st_cb_viewport.c
index d654ed6..d48127e 100644
--- a/src/mesa/state_tracker/st_cb_viewport.c
+++ b/src/mesa/state_tracker/st_cb_viewport.c
@@ -48,7 +48,8 @@ st_ws_framebuffer(struct gl_framebuffer *fb)
    return NULL;
 }
 
-static void st_viewport(struct gl_context * ctx, GLint x, GLint y,
+static void st_viewport(struct gl_context * ctx, GLuint idx,
+                        GLint x, GLint y,
                         GLsizei width, GLsizei height)
 {
    struct st_context *st = ctx->st;
-- 
1.8.1.2



More information about the mesa-dev mailing list