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 <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Ian Romanick 2013-11-05 22:40:38 -08:00
parent 562f353434
commit 454cec4299

View file

@ -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);