summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/viewport.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-11-05 22:40:38 -0800
committerIan Romanick <[email protected]>2014-01-20 11:31:59 -0800
commit454cec429969b7f09eeff17a5d1e7584d36f017f (patch)
treee6c7d55ee5f517b73ea93dd9a8d38e0e7f1564e8 /src/mesa/main/viewport.c
parent562f353434878844e3aca4d75d049d5f17242aa8 (diff)
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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/viewport.c')
-rw-r--r--src/mesa/main/viewport.c30
1 files 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);