From 454cec429969b7f09eeff17a5d1e7584d36f017f Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 5 Nov 2013 22:40:38 -0800 Subject: [PATCH] mesa: Set all viewports from _mesa_Viewport and _mesa_DepthRange In _mesa_Viewport and _mesa_DepthRange, make sure that ctx->Driver.Viewport is only called once instead of once per viewport or depth range. v2: Make _mesa_DepthRange actually set all of the depth ranges (instead of just index 0). Noticed by Ken. Signed-off-by: Ian Romanick Reviewed-by: Kenneth Graunke --- src/mesa/main/viewport.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index cc031b00a41..ad16e875311 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -74,6 +74,7 @@ set_viewport_no_notify(struct gl_context *ctx, unsigned idx, GLint x, GLint y, void GLAPIENTRY _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { + unsigned i; GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); @@ -86,7 +87,19 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) return; } - set_viewport_no_notify(ctx, 0, x, y, width, height); + /* The GL_ARB_viewport_array spec says: + * + * "Viewport sets the parameters for all viewports to the same values + * and is equivalent (assuming no errors are generated) to: + * + * for (uint i = 0; i < MAX_VIEWPORTS; i++) + * ViewportIndexedf(i, 1, (float)x, (float)y, (float)w, (float)h);" + * + * Set all of the viewports supported by the implementation, but only + * signal the driver once at the end. + */ + for (i = 0; i < ctx->Const.MaxViewports; i++) + set_viewport_no_notify(ctx, i, x, y, width, height); if (ctx->Driver.Viewport) { /* Many drivers will use this call to check for window size changes @@ -170,6 +183,7 @@ _mesa_set_depth_range(struct gl_context *ctx, unsigned idx, void GLAPIENTRY _mesa_DepthRange(GLclampd nearval, GLclampd farval) { + unsigned i; GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); @@ -177,7 +191,19 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); - set_depth_range_no_notify(ctx, 0, nearval, farval); + /* The GL_ARB_viewport_array spec says: + * + * "DepthRange sets the depth range for all viewports to the same + * values and is equivalent (assuming no errors are generated) to: + * + * for (uint i = 0; i < MAX_VIEWPORTS; i++) + * DepthRangeIndexed(i, n, f);" + * + * Set the depth range for all of the viewports supported by the + * implementation, but only signal the driver once at the end. + */ + for (i = 0; i < ctx->Const.MaxViewports; i++) + set_depth_range_no_notify(ctx, i, nearval, farval); if (ctx->Driver.DepthRange) { ctx->Driver.DepthRange(ctx); -- 2.30.2