diff options
author | Courtney Goeltzenleuchter <[email protected]> | 2013-11-13 16:24:56 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2014-01-20 11:31:56 -0800 |
commit | cbb271a48845c2d236f31327df316d42888a1907 (patch) | |
tree | a860c48f113d8171d31d77bacf1c341627e4c099 /src/mesa/main | |
parent | 5b84226c31e941219422f6d60c31524081b7a188 (diff) |
mesa: Convert gl_context::Viewport to gl_context::ViewportArray
Only element 0 of the array is used anywhere at this time, so there
should be no changes.
v4: Split out from a single megapatch. Suggested by Ken.
Signed-off-by: Courtney Goeltzenleuchter <[email protected]>
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/attrib.c | 5 | ||||
-rw-r--r-- | src/mesa/main/context.c | 18 | ||||
-rw-r--r-- | src/mesa/main/get.c | 12 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | src/mesa/main/rastpos.c | 5 | ||||
-rw-r--r-- | src/mesa/main/state.c | 8 | ||||
-rw-r--r-- | src/mesa/main/viewport.c | 52 |
7 files changed, 54 insertions, 48 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index f571f9fc7f0..3a6bf05eee9 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -533,8 +533,9 @@ _mesa_PushAttrib(GLbitfield mask) if (mask & GL_VIEWPORT_BIT) { if (!push_attrib(ctx, &head, GL_VIEWPORT_BIT, - sizeof(struct gl_viewport_attrib), - (void*)&ctx->Viewport)) + sizeof(struct gl_viewport_attrib) + * ctx->Const.MaxViewports, + (void*)&ctx->ViewportArray)) goto end; } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 538322e9eb8..5c67159e5a9 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -594,6 +594,9 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.ViewportBounds.Min = 0; ctx->Const.ViewportBounds.Max = 0; + /* Driver must override if it supports ARB_viewport_array */ + ctx->Const.MaxViewports = 1; + /** GL_ARB_uniform_buffer_object */ ctx->Const.MaxCombinedUniformBlocks = 36; ctx->Const.MaxUniformBufferBindings = 36; @@ -1354,13 +1357,14 @@ _mesa_copy_context( const struct gl_context *src, struct gl_context *dst, } if (mask & GL_VIEWPORT_BIT) { /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */ - dst->Viewport.X = src->Viewport.X; - dst->Viewport.Y = src->Viewport.Y; - dst->Viewport.Width = src->Viewport.Width; - dst->Viewport.Height = src->Viewport.Height; - dst->Viewport.Near = src->Viewport.Near; - dst->Viewport.Far = src->Viewport.Far; - _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap); + dst->ViewportArray[0].X = src->ViewportArray[0].X; + dst->ViewportArray[0].Y = src->ViewportArray[0].Y; + dst->ViewportArray[0].Width = src->ViewportArray[0].Width; + dst->ViewportArray[0].Height = src->ViewportArray[0].Height; + dst->ViewportArray[0].Near = src->ViewportArray[0].Near; + dst->ViewportArray[0].Far = src->ViewportArray[0].Far; + _math_matrix_copy(&dst->ViewportArray[0]._WindowMap, + &src->ViewportArray[0]._WindowMap); } /* XXX FIXME: Call callbacks? diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index fa48195cdf4..c8accb6d261 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -691,15 +691,15 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; case GL_VIEWPORT: - v->value_float_4[0] = ctx->Viewport.X; - v->value_float_4[1] = ctx->Viewport.Y; - v->value_float_4[2] = ctx->Viewport.Width; - v->value_float_4[3] = ctx->Viewport.Height; + v->value_float_4[0] = ctx->ViewportArray[0].X; + v->value_float_4[1] = ctx->ViewportArray[0].Y; + v->value_float_4[2] = ctx->ViewportArray[0].Width; + v->value_float_4[3] = ctx->ViewportArray[0].Height; break; case GL_DEPTH_RANGE: - v->value_double_2[0] = ctx->Viewport.Near; - v->value_double_2[1] = ctx->Viewport.Far; + v->value_double_2[0] = ctx->ViewportArray[0].Near; + v->value_double_2[1] = ctx->ViewportArray[0].Far; break; case GL_ACTIVE_STENCIL_FACE_EXT: diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 1231a6f4415..cac02061516 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3983,7 +3983,7 @@ struct gl_context struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */ struct gl_texture_attrib Texture; /**< Texture attributes */ struct gl_transform_attrib Transform; /**< Transformation attributes */ - struct gl_viewport_attrib Viewport; /**< Viewport attributes */ + struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */ /*@}*/ /** \name Client attribute stack */ diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index 1acdb8b53eb..a9a6ceec0c1 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -227,8 +227,9 @@ window_pos3f(GLfloat x, GLfloat y, GLfloat z) FLUSH_VERTICES(ctx, 0); FLUSH_CURRENT(ctx, 0); - z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near) - + ctx->Viewport.Near; + z2 = CLAMP(z, 0.0F, 1.0F) + * (ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near) + + ctx->ViewportArray[0].Near; /* set raster position */ ctx->Current.RasterPos[0] = x; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 33070b7e02d..acb2f2073d2 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -276,10 +276,10 @@ update_viewport_matrix(struct gl_context *ctx) * and should be maintained elsewhere if at all. * NOTE: RasterPos uses this. */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, + _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, depthMax); } diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 8eede518f9d..360f066a966 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -78,10 +78,10 @@ _mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); - ctx->Viewport.X = x; - ctx->Viewport.Width = width; - ctx->Viewport.Y = y; - ctx->Viewport.Height = height; + ctx->ViewportArray[0].X = x; + ctx->ViewportArray[0].Width = width; + ctx->ViewportArray[0].Y = y; + ctx->ViewportArray[0].Height = height; ctx->NewState |= _NEW_VIEWPORT; #if 1 @@ -89,10 +89,10 @@ _mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y, * the WindowMap matrix being up to date in the driver's Viewport * and DepthRange functions. */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, + _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 @@ -123,12 +123,12 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval) if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); - if (ctx->Viewport.Near == nearval && - ctx->Viewport.Far == farval) + if (ctx->ViewportArray[0].Near == nearval && + ctx->ViewportArray[0].Far == farval) return; - ctx->Viewport.Near = CLAMP(nearval, 0.0, 1.0); - ctx->Viewport.Far = CLAMP(farval, 0.0, 1.0); + 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 @@ -136,10 +136,10 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval) * the WindowMap matrix being up to date in the driver's Viewport * and DepthRange functions. */ - _math_matrix_viewport(&ctx->Viewport._WindowMap, - ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height, - ctx->Viewport.Near, ctx->Viewport.Far, + _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 @@ -163,15 +163,15 @@ void _mesa_init_viewport(struct gl_context *ctx) GLfloat depthMax = 65535.0F; /* sorf of arbitrary */ /* Viewport group */ - ctx->Viewport.X = 0; - ctx->Viewport.Y = 0; - ctx->Viewport.Width = 0; - ctx->Viewport.Height = 0; - ctx->Viewport.Near = 0.0; - ctx->Viewport.Far = 1.0; - _math_matrix_ctr(&ctx->Viewport._WindowMap); - - _math_matrix_viewport(&ctx->Viewport._WindowMap, 0, 0, 0, 0, + ctx->ViewportArray[0].X = 0; + ctx->ViewportArray[0].Y = 0; + ctx->ViewportArray[0].Width = 0; + ctx->ViewportArray[0].Height = 0; + ctx->ViewportArray[0].Near = 0.0; + ctx->ViewportArray[0].Far = 1.0; + _math_matrix_ctr(&ctx->ViewportArray[0]._WindowMap); + + _math_matrix_viewport(&ctx->ViewportArray[0]._WindowMap, 0, 0, 0, 0, 0.0F, 1.0F, depthMax); } @@ -182,6 +182,6 @@ void _mesa_init_viewport(struct gl_context *ctx) */ void _mesa_free_viewport_data(struct gl_context *ctx) { - _math_matrix_dtr(&ctx->Viewport._WindowMap); + _math_matrix_dtr(&ctx->ViewportArray[0]._WindowMap); } |