summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/context.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-11-05 22:36:38 -0800
committerIan Romanick <[email protected]>2014-01-20 11:31:59 -0800
commit9de863603d8092243df502365a75d65982223f0e (patch)
tree0e49c768abe940e76494bd19ad6c84dade3fbb7a /src/mesa/main/context.c
parentf6d7cd4a11e70b816733cff681dde7d03588d1c8 (diff)
mesa: Initialize all the viewports
v2: Use MAX_VIEWPORTS instead of ctx->Const.MaxViewports because the driver may not set ctx->Const.MaxViewports yet. v3: Handle all viewport entries in update_viewport_matrix and _mesa_copy_context too. This was previously in an earlier patch. Having the code in the earlier patch could cause _mesa_copy_context to access a matrix that hadn't been constructed. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> [v2]
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r--src/mesa/main/context.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 91fcbd284a6..1cd006416e1 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1357,14 +1357,17 @@ _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->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);
+ unsigned i;
+ for (i = 0; i < src->Const.MaxViewports; i++) {
+ dst->ViewportArray[i].X = src->ViewportArray[i].X;
+ dst->ViewportArray[i].Y = src->ViewportArray[i].Y;
+ dst->ViewportArray[i].Width = src->ViewportArray[i].Width;
+ dst->ViewportArray[i].Height = src->ViewportArray[i].Height;
+ dst->ViewportArray[i].Near = src->ViewportArray[i].Near;
+ dst->ViewportArray[i].Far = src->ViewportArray[i].Far;
+ _math_matrix_copy(&dst->ViewportArray[i]._WindowMap,
+ &src->ViewportArray[i]._WindowMap);
+ }
}
/* XXX FIXME: Call callbacks?
@@ -1433,11 +1436,19 @@ void
_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
{
if (!ctx->ViewportInitialized && width > 0 && height > 0) {
+ unsigned i;
+
/* Note: set flag here, before calling _mesa_set_viewport(), to prevent
* potential infinite recursion.
*/
ctx->ViewportInitialized = GL_TRUE;
- _mesa_set_viewport(ctx, 0, 0, 0, width, height);
+
+ /* Note: ctx->Const.MaxViewports may not have been set by the driver
+ * yet, so just initialize all of them.
+ */
+ for (i = 0; i < MAX_VIEWPORTS; i++) {
+ _mesa_set_viewport(ctx, i, 0, 0, width, height);
+ }
_mesa_set_scissor(ctx, 0, 0, 0, width, height);
}
}