From: Ian Romanick Date: Wed, 6 Nov 2013 05:34:26 +0000 (-0800) Subject: mesa: Refactor depth range setting even more X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=42f916e1507f2a5b3da002936418ffe91925104f;p=mesa.git mesa: Refactor depth range setting even more Create an internal function that just writes data into the depth range. In future patches this will see more use because we only want to call dd_function_table::DepthRange once after setting all of the depth ranges instead of once per depth range. Signed-off-by: Ian Romanick Reviewed-by: Kenneth Graunke --- diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index d4b03936610..2c81af70d41 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -108,6 +108,43 @@ _mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLint x, GLint y, } } +static void +set_depth_range_no_notify(struct gl_context *ctx, unsigned idx, + GLclampd nearval, GLclampd farval) +{ + if (ctx->ViewportArray[idx].Near == nearval && + ctx->ViewportArray[idx].Far == farval) + return; + + ctx->ViewportArray[idx].Near = CLAMP(nearval, 0.0, 1.0); + ctx->ViewportArray[idx].Far = CLAMP(farval, 0.0, 1.0); + ctx->NewState |= _NEW_VIEWPORT; + +#if 1 + /* XXX remove this someday. Currently the DRI drivers rely on + * the WindowMap matrix being up to date in the driver's Viewport + * and DepthRange functions. + */ + _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap, + ctx->ViewportArray[idx].X, + ctx->ViewportArray[idx].Y, + ctx->ViewportArray[idx].Width, + ctx->ViewportArray[idx].Height, + ctx->ViewportArray[idx].Near, + ctx->ViewportArray[idx].Far, + ctx->DrawBuffer->_DepthMaxF); +#endif +} + +void +_mesa_set_depth_range(struct gl_context *ctx, unsigned idx, + GLclampd nearval, GLclampd farval) +{ + set_depth_range_no_notify(ctx, idx, nearval, farval); + + if (ctx->Driver.DepthRange) + ctx->Driver.DepthRange(ctx); +} /** * Called by glDepthRange @@ -127,25 +164,7 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); - if (ctx->ViewportArray[0].Near == nearval && - ctx->ViewportArray[0].Far == farval) - return; - - ctx->ViewportArray[0].Near = CLAMP(nearval, 0.0, 1.0); - ctx->ViewportArray[0].Far = CLAMP(farval, 0.0, 1.0); - ctx->NewState |= _NEW_VIEWPORT; - -#if 1 - /* XXX remove this someday. Currently the DRI drivers rely on - * the WindowMap matrix being up to date in the driver's Viewport - * and DepthRange functions. - */ - _math_matrix_viewport(&ctx->ViewportArray[0]._WindowMap, - ctx->ViewportArray[0].X, ctx->ViewportArray[0].Y, - ctx->ViewportArray[0].Width, ctx->ViewportArray[0].Height, - ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far, - ctx->DrawBuffer->_DepthMaxF); -#endif + set_depth_range_no_notify(ctx, 0, nearval, farval); if (ctx->Driver.DepthRange) { ctx->Driver.DepthRange(ctx); diff --git a/src/mesa/main/viewport.h b/src/mesa/main/viewport.h index b4eb5217cd1..44bca1b3a1a 100644 --- a/src/mesa/main/viewport.h +++ b/src/mesa/main/viewport.h @@ -46,6 +46,9 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval); extern void GLAPIENTRY _mesa_DepthRangef(GLclampf nearval, GLclampf farval); +extern void +_mesa_set_depth_range(struct gl_context *ctx, unsigned idx, + GLclampd nearval, GLclampd farval); extern void _mesa_init_viewport(struct gl_context *ctx);