summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/viewport.c
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2013-11-05 22:36:38 -0800
committerIan Romanick <ian.d.romanick@intel.com>2014-01-20 11:31:59 -0800
commit9de863603d8092243df502365a75d65982223f0e (patch)
tree0e49c768abe940e76494bd19ad6c84dade3fbb7a /src/mesa/main/viewport.c
parentf6d7cd4a11e70b816733cff681dde7d03588d1c8 (diff)
downloadexternal_mesa3d-9de863603d8092243df502365a75d65982223f0e.zip
external_mesa3d-9de863603d8092243df502365a75d65982223f0e.tar.gz
external_mesa3d-9de863603d8092243df502365a75d65982223f0e.tar.bz2
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 <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> [v2]
Diffstat (limited to 'src/mesa/main/viewport.c')
-rw-r--r--src/mesa/main/viewport.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index ac891c8..cc031b0 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -197,18 +197,24 @@ _mesa_DepthRangef(GLclampf nearval, GLclampf farval)
void _mesa_init_viewport(struct gl_context *ctx)
{
GLfloat depthMax = 65535.0F; /* sorf of arbitrary */
+ unsigned i;
- /* Viewport group */
- 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);
+ /* 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++) {
+ /* Viewport group */
+ ctx->ViewportArray[i].X = 0;
+ ctx->ViewportArray[i].Y = 0;
+ ctx->ViewportArray[i].Width = 0;
+ ctx->ViewportArray[i].Height = 0;
+ ctx->ViewportArray[i].Near = 0.0;
+ ctx->ViewportArray[i].Far = 1.0;
+ _math_matrix_ctr(&ctx->ViewportArray[i]._WindowMap);
+
+ _math_matrix_viewport(&ctx->ViewportArray[i]._WindowMap, 0, 0, 0, 0,
+ 0.0F, 1.0F, depthMax);
+ }
}
@@ -218,6 +224,9 @@ void _mesa_init_viewport(struct gl_context *ctx)
*/
void _mesa_free_viewport_data(struct gl_context *ctx)
{
- _math_matrix_dtr(&ctx->ViewportArray[0]._WindowMap);
+ unsigned i;
+
+ for (i = 0; i < MAX_VIEWPORTS; i++)
+ _math_matrix_dtr(&ctx->ViewportArray[i]._WindowMap);
}