Include DepthRange as well since it's state is lumped together with viewport state. Updates all the drivers that reference Viewport state in gl_context.
Have meta driver call _mesa_Viewport as that interface is not changing. Signed-off-by: Courtney Goeltzenleuchter <court...@lunarg.com> --- src/mesa/drivers/common/meta.c | 32 +++++++-------- src/mesa/drivers/dri/i915/i830_vtbl.c | 2 +- src/mesa/drivers/dri/i915/i915_state.c | 24 ++++++------ src/mesa/drivers/dri/i915/i915_vtbl.c | 2 +- src/mesa/drivers/dri/i965/brw_cc.c | 4 +- src/mesa/drivers/dri/i965/brw_clip_state.c | 12 +++--- src/mesa/drivers/dri/i965/brw_sf_state.c | 2 +- src/mesa/drivers/dri/i965/gen6_clip_state.c | 8 ++-- src/mesa/drivers/dri/i965/gen6_viewport_state.c | 6 +-- src/mesa/drivers/dri/i965/gen7_viewport_state.c | 6 +-- src/mesa/drivers/dri/nouveau/nouveau_util.h | 4 +- src/mesa/drivers/dri/nouveau/nv10_state_fb.c | 2 +- src/mesa/drivers/dri/r200/r200_state.c | 6 +-- src/mesa/drivers/dri/radeon/radeon_common.c | 4 +- src/mesa/drivers/dri/radeon/radeon_state.c | 4 +- src/mesa/main/attrib.c | 6 ++- src/mesa/main/context.c | 21 ++++++---- src/mesa/main/get.c | 16 ++++++-- src/mesa/main/get_hash_params.py | 2 +- src/mesa/main/mtypes.h | 8 ++-- src/mesa/main/rastpos.c | 4 +- src/mesa/main/state.c | 17 ++++---- src/mesa/main/viewport.c | 52 ++++++++++++------------- src/mesa/math/m_matrix.c | 9 +++-- src/mesa/math/m_matrix.h | 4 +- src/mesa/program/prog_statevars.c | 7 ++-- src/mesa/state_tracker/st_atom_viewport.c | 12 +++--- src/mesa/swrast/s_context.c | 8 ++-- src/mesa/swrast/s_depth.c | 10 ++--- src/mesa/swrast_setup/ss_context.c | 4 +- src/mesa/tnl/t_rasterpos.c | 16 ++++---- 31 files changed, 166 insertions(+), 148 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 7b0e42c..0cb6625 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -735,21 +735,21 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) if (state & MESA_META_VIEWPORT) { /* save viewport state */ - save->ViewportX = ctx->Viewport.X; - save->ViewportY = ctx->Viewport.Y; - save->ViewportW = ctx->Viewport.Width; - save->ViewportH = ctx->Viewport.Height; + save->ViewportX = ctx->ViewportArray[0].X; + save->ViewportY = ctx->ViewportArray[0].Y; + save->ViewportW = ctx->ViewportArray[0].Width; + save->ViewportH = ctx->ViewportArray[0].Height; /* set viewport to match window size */ - if (ctx->Viewport.X != 0 || - ctx->Viewport.Y != 0 || - ctx->Viewport.Width != ctx->DrawBuffer->Width || - ctx->Viewport.Height != ctx->DrawBuffer->Height) { - _mesa_set_viewport(ctx, 0, 0, - ctx->DrawBuffer->Width, ctx->DrawBuffer->Height); + if (ctx->ViewportArray[0].X != 0 || + ctx->ViewportArray[0].Y != 0 || + ctx->ViewportArray[0].Width != ctx->DrawBuffer->Width || + ctx->ViewportArray[0].Height != ctx->DrawBuffer->Height) { + _mesa_Viewport(0, 0, + ctx->DrawBuffer->Width, ctx->DrawBuffer->Height); } /* save depth range state */ - save->DepthNear = ctx->Viewport.Near; - save->DepthFar = ctx->Viewport.Far; + save->DepthNear = ctx->ViewportArray[0].Near; + save->DepthFar = ctx->ViewportArray[0].Far; /* set depth range to default */ _mesa_DepthRange(0.0, 1.0); } @@ -1087,10 +1087,10 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_VIEWPORT) { - if (save->ViewportX != ctx->Viewport.X || - save->ViewportY != ctx->Viewport.Y || - save->ViewportW != ctx->Viewport.Width || - save->ViewportH != ctx->Viewport.Height) { + if (save->ViewportX != ctx->ViewportArray[0].X || + save->ViewportY != ctx->ViewportArray[0].Y || + save->ViewportW != ctx->ViewportArray[0].Width || + save->ViewportH != ctx->ViewportArray[0].Height) { _mesa_set_viewport(ctx, save->ViewportX, save->ViewportY, save->ViewportW, save->ViewportH); } diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index 72445ae..e0959cc 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -840,7 +840,7 @@ i830_update_draw_buffer(struct intel_context *intel) ctx->Driver.Scissor(ctx, 0, ctx->Scissor.ScissorArray[0].X, ctx->Scissor.ScissorArray[0].Y, ctx->Scissor.ScissorArray[0].Width, ctx->Scissor.ScissorArray[0].Height); - ctx->Driver.DepthRange(ctx, 0, ctx->Viewport.Near, ctx->Viewport.Far); + ctx->Driver.DepthRange(ctx, 0, ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far); /* Update culling direction which changes depending on the * orientation of the buffer: diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index ee7d4ae..5f58f33 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -404,21 +404,21 @@ intelCalcViewport(struct gl_context * ctx) if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) { _math_matrix_viewport(&intel->ViewportMatrix, - ctx->Viewport.X, - ctx->DrawBuffer->Height - ctx->Viewport.Y, - ctx->Viewport.Width, - -ctx->Viewport.Height, - ctx->Viewport.Near, - ctx->Viewport.Far, + ctx->ViewportArray[0].X, + ctx->DrawBuffer->Height - ctx->ViewportArray[0].Y, + ctx->ViewportArray[0].Width, + -ctx->ViewportArray[0].Height, + ctx->ViewportArray[0].Near, + ctx->ViewportArray[0].Far, 1.0); } else { _math_matrix_viewport(&intel->ViewportMatrix, - ctx->Viewport.X, - ctx->Viewport.Y, - ctx->Viewport.Width, - ctx->Viewport.Height, - ctx->Viewport.Near, - ctx->Viewport.Far, + ctx->ViewportArray[0].X, + ctx->ViewportArray[0].Y, + ctx->ViewportArray[0].Width, + ctx->ViewportArray[0].Height, + ctx->ViewportArray[0].Near, + ctx->ViewportArray[0].Far, 1.0); } } diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index 854bc4f..c9b06a9 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -811,7 +811,7 @@ i915_update_draw_buffer(struct intel_context *intel) /* Set state we know depends on drawable parameters: */ - ctx->Driver.DepthRange(ctx, 0, ctx->Viewport.Near, ctx->Viewport.Far); + ctx->Driver.DepthRange(ctx, 0, ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far); ctx->Driver.Scissor(ctx, 0, ctx->Scissor.ScissorArray[0].X, ctx->Scissor.ScissorArray[0].Y, ctx->Scissor.ScissorArray[0].Width, ctx->Scissor.ScissorArray[0].Height); diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c index 53466e7..e524bb5 100644 --- a/src/mesa/drivers/dri/i965/brw_cc.c +++ b/src/mesa/drivers/dri/i965/brw_cc.c @@ -50,8 +50,8 @@ brw_upload_cc_vp(struct brw_context *brw) /* _NEW_TRANSFORM */ if (ctx->Transform.DepthClamp) { /* _NEW_VIEWPORT */ - ccv->min_depth = MIN2(ctx->Viewport.Near, ctx->Viewport.Far); - ccv->max_depth = MAX2(ctx->Viewport.Near, ctx->Viewport.Far); + ccv->min_depth = MIN2(ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far); + ccv->max_depth = MAX2(ctx->ViewportArray[0].Near, ctx->ViewportArray[0].Far); } else { ccv->min_depth = 0.0; ccv->max_depth = 1.0; diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c index 634719b..259a8f0 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_state.c +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c @@ -43,8 +43,8 @@ upload_clip_vp(struct brw_context *brw) sizeof(*vp), 32, &brw->clip.vp_offset); const float maximum_post_clamp_delta = 4096; - float gbx = maximum_post_clamp_delta / (float) ctx->Viewport.Width; - float gby = maximum_post_clamp_delta / (float) ctx->Viewport.Height; + float gbx = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Width; + float gby = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Height; vp->xmin = -gbx; vp->xmax = gbx; @@ -125,10 +125,10 @@ brw_upload_clip_unit(struct brw_context *brw) clip->clip5.userclip_must_clip = 1; /* enable guardband clipping if we can */ - if (ctx->Viewport.X == 0 && - ctx->Viewport.Y == 0 && - ctx->Viewport.Width == fb->Width && - ctx->Viewport.Height == fb->Height) + if (ctx->ViewportArray[0].X == 0 && + ctx->ViewportArray[0].Y == 0 && + ctx->ViewportArray[0].Width == fb->Width && + ctx->ViewportArray[0].Height == fb->Height) { clip->clip5.guard_band_enable = 1; clip->clip6.clipper_viewport_state_ptr = diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 8d12a2f..0a023fc 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -46,7 +46,7 @@ static void upload_sf_vp(struct brw_context *brw) struct brw_sf_viewport *sfv; GLfloat y_scale, y_bias; const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer); - const GLfloat *v = ctx->Viewport._WindowMap.m; + const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE, sizeof(*sfv), 32, &brw->sf.vp_offset); diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c index 03d0f90..fe8b133 100644 --- a/src/mesa/drivers/dri/i965/gen6_clip_state.c +++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c @@ -96,10 +96,10 @@ upload_clip_state(struct brw_context *brw) dw2 |= (ctx->Transform.ClipPlanesEnabled << GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT); - if (ctx->Viewport.X == 0 && - ctx->Viewport.Y == 0 && - ctx->Viewport.Width == fb->Width && - ctx->Viewport.Height == fb->Height) { + if (ctx->ViewportArray[0].X == 0 && + ctx->ViewportArray[0].Y == 0 && + ctx->ViewportArray[0].Width == fb->Width && + ctx->ViewportArray[0].Height == fb->Height) { dw2 |= GEN6_CLIP_GB_TEST; } diff --git a/src/mesa/drivers/dri/i965/gen6_viewport_state.c b/src/mesa/drivers/dri/i965/gen6_viewport_state.c index 0335920..b30f3f3 100644 --- a/src/mesa/drivers/dri/i965/gen6_viewport_state.c +++ b/src/mesa/drivers/dri/i965/gen6_viewport_state.c @@ -55,8 +55,8 @@ gen6_upload_clip_vp(struct brw_context *brw) * drawable. */ const float maximum_post_clamp_delta = 8192; - float gbx = maximum_post_clamp_delta / (float) ctx->Viewport.Width; - float gby = maximum_post_clamp_delta / (float) ctx->Viewport.Height; + float gbx = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Width; + float gby = maximum_post_clamp_delta / (float) ctx->ViewportArray[0].Height; vp->xmin = -gbx; vp->xmax = gbx; @@ -83,7 +83,7 @@ gen6_upload_sf_vp(struct brw_context *brw) struct brw_sf_viewport *sfv; GLfloat y_scale, y_bias; const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer); - const GLfloat *v = ctx->Viewport._WindowMap.m; + const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE, sizeof(*sfv), 32, &brw->sf.vp_offset); diff --git a/src/mesa/drivers/dri/i965/gen7_viewport_state.c b/src/mesa/drivers/dri/i965/gen7_viewport_state.c index 8c5fcac..d676919 100644 --- a/src/mesa/drivers/dri/i965/gen7_viewport_state.c +++ b/src/mesa/drivers/dri/i965/gen7_viewport_state.c @@ -34,7 +34,7 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw) const GLfloat depth_scale = 1.0F / ctx->DrawBuffer->_DepthMaxF; GLfloat y_scale, y_bias; const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer); - const GLfloat *v = ctx->Viewport._WindowMap.m; + const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; struct gen7_sf_clip_viewport *vp; vp = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE, @@ -54,8 +54,8 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw) * drawable. */ const float maximum_guardband_extent = 8192; - float gbx = maximum_guardband_extent / (float) ctx->Viewport.Width; - float gby = maximum_guardband_extent / (float) ctx->Viewport.Height; + float gbx = maximum_guardband_extent / (float) ctx->ViewportArray[0].Width; + float gby = maximum_guardband_extent / (float) ctx->ViewportArray[0].Height; vp->guardband.xmin = -gbx; vp->guardband.xmax = gbx; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h index 17d6965..e44e8ef 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_util.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h @@ -140,7 +140,7 @@ get_scissors(struct gl_framebuffer *fb, int *x, int *y, int *w, int *h) static inline void get_viewport_scale(struct gl_context *ctx, float a[16]) { - struct gl_viewport_attrib *vp = &ctx->Viewport; + struct gl_viewport_attrib *vp = &ctx->ViewportArray[0]; struct gl_framebuffer *fb = ctx->DrawBuffer; a[MAT_SX] = (float)vp->Width / 2; @@ -157,7 +157,7 @@ get_viewport_scale(struct gl_context *ctx, float a[16]) static inline void get_viewport_translate(struct gl_context *ctx, float a[4]) { - struct gl_viewport_attrib *vp = &ctx->Viewport; + struct gl_viewport_attrib *vp = &ctx->ViewportArray[0]; struct gl_framebuffer *fb = ctx->DrawBuffer; a[0] = (float)vp->Width / 2 + vp->X; diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c index 87ae1d6..6f55461 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c @@ -176,7 +176,7 @@ void nv10_emit_viewport(struct gl_context *ctx, int emit) { struct nouveau_pushbuf *push = context_push(ctx); - struct gl_viewport_attrib *vp = &ctx->Viewport; + struct gl_viewport_attrib *vp = &ctx->ViewportArray[0]; struct gl_framebuffer *fb = ctx->DrawBuffer; float a[4] = {}; diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 388e904..a62928e 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -1544,7 +1544,7 @@ void r200UpdateWindow( struct gl_context *ctx ) __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon); GLfloat xoffset = 0; GLfloat yoffset = dPriv ? (GLfloat) dPriv->h : 0; - const GLfloat *v = ctx->Viewport._WindowMap.m; + const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; const GLboolean render_to_fbo = (ctx->DrawBuffer ? _mesa_is_user_fbo(ctx->DrawBuffer) : 0); const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF; GLfloat y_scale, y_bias; @@ -1619,7 +1619,7 @@ static void r200Viewport( struct gl_context *ctx, GLuint idx, } static void r200DepthRange( struct gl_context *ctx, GLuint idx, - GLclampd nearval, GLclampd farval ) + GLclampd nearval, GLclampd farval ) { r200UpdateWindow( ctx ); } @@ -1630,7 +1630,7 @@ void r200UpdateViewportOffset( struct gl_context *ctx ) __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon); GLfloat xoffset = (GLfloat)0; GLfloat yoffset = (GLfloat)dPriv->h; - const GLfloat *v = ctx->Viewport._WindowMap.m; + const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; float_ui32_type tx; float_ui32_type ty; diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c index 88f530a..eeb73c9 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.c +++ b/src/mesa/drivers/dri/radeon/radeon_common.c @@ -334,8 +334,8 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb) if (ctx->Driver.DepthRange) ctx->Driver.DepthRange(ctx, 0, - ctx->Viewport.Near, - ctx->Viewport.Far); + ctx->ViewportArray[0].Near, + ctx->ViewportArray[0].Far); /* Update culling direction which changes depending on the * orientation of the buffer: diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c index 258f18f..1225cd5 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state.c +++ b/src/mesa/drivers/dri/radeon/radeon_state.c @@ -1352,7 +1352,7 @@ void radeonUpdateWindow( struct gl_context *ctx ) __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon); GLfloat xoffset = 0.0; GLfloat yoffset = dPriv ? (GLfloat) dPriv->h : 0; - const GLfloat *v = ctx->Viewport._WindowMap.m; + const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; const GLboolean render_to_fbo = (ctx->DrawBuffer ? _mesa_is_user_fbo(ctx->DrawBuffer) : 0); const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF; GLfloat y_scale, y_bias; @@ -1413,7 +1413,7 @@ void radeonUpdateViewportOffset( struct gl_context *ctx ) __DRIdrawable *dPriv = radeon_get_drawable(&rmesa->radeon); GLfloat xoffset = 0.0; GLfloat yoffset = (GLfloat)dPriv->h; - const GLfloat *v = ctx->Viewport._WindowMap.m; + const GLfloat *v = ctx->ViewportArray[0]._WindowMap.m; float_ui32_type tx; float_ui32_type ty; diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index a17a1d6..996e2cf 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -463,8 +463,10 @@ _mesa_PushAttrib(GLbitfield mask) if (mask & GL_VIEWPORT_BIT) { struct gl_viewport_attrib *attr; - attr = MALLOC_STRUCT( gl_viewport_attrib ); - memcpy( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) ); + attr = (struct gl_viewport_attrib *) MALLOC(sizeof(struct gl_viewport_attrib) + * ctx->Const.MaxViewports); + memcpy( attr, &ctx->ViewportArray, sizeof(struct gl_viewport_attrib) + * ctx->Const.MaxViewports); save_attrib_data(&head, GL_VIEWPORT_BIT, attr); } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 8cbc935..15eedcd 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -587,6 +587,9 @@ _mesa_init_constants(struct gl_context *ctx) ctx->Const.MaxViewportWidth = MAX_VIEWPORT_WIDTH; ctx->Const.MaxViewportHeight = MAX_VIEWPORT_HEIGHT; + /* 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; @@ -1347,13 +1350,16 @@ _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); + GLuint 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? @@ -1413,7 +1419,6 @@ check_compatible(const struct gl_context *ctx, return GL_TRUE; } - /** * Check if the viewport/scissor size has not yet been initialized. * Initialize the size if the given width and height are non-zero. diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index dd2f599..b8929a5 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -113,6 +113,7 @@ enum value_type { TYPE_FLOATN_3, TYPE_FLOATN_4, TYPE_DOUBLEN, + TYPE_DOUBLEN_2, TYPE_MATRIX, TYPE_MATRIX_T, TYPE_CONST @@ -161,6 +162,8 @@ struct value_desc { union value { GLfloat value_float; GLfloat value_float_4[4]; + GLdouble value_double_2[2]; + GLdouble value_double_4[4]; GLmatrix *value_matrix; GLint value_int; GLint value_int_4[4]; @@ -677,10 +680,15 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; case GL_VIEWPORT: - v->value_int_4[0] = ctx->Viewport.X; - v->value_int_4[1] = ctx->Viewport.Y; - v->value_int_4[2] = ctx->Viewport.Width; - v->value_int_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->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/get_hash_params.py b/src/mesa/main/get_hash_params.py index f678053..1081ff0 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -11,7 +11,7 @@ descriptor=[ [ "DEPTH_BITS", "BUFFER_INT(Visual.depthBits), extra_new_buffers" ], [ "DEPTH_CLEAR_VALUE", "CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA" ], [ "DEPTH_FUNC", "CONTEXT_ENUM(Depth.Func), NO_EXTRA" ], - [ "DEPTH_RANGE", "CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA" ], + [ "DEPTH_RANGE", "LOC_CUSTOM, TYPE_DOUBLEN_2, 0, NO_EXTRA" ], [ "DEPTH_TEST", "CONTEXT_BOOL(Depth.Test), NO_EXTRA" ], [ "DEPTH_WRITEMASK", "CONTEXT_BOOL(Depth.Mask), NO_EXTRA" ], [ "DITHER", "CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA" ], diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 54b1bdc..63d1420 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1406,9 +1406,9 @@ struct gl_transform_attrib */ struct gl_viewport_attrib { - GLint X, Y; /**< position */ - GLsizei Width, Height; /**< size */ - GLfloat Near, Far; /**< Depth buffer range */ + GLfloat X, Y; /**< position */ + GLfloat Width, Height; /**< size */ + GLdouble Near, Far; /**< Depth buffer range */ GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */ }; @@ -3861,7 +3861,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 1acdb8b..a90f057 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -227,8 +227,8 @@ 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 33070b7..8632fcd 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -262,13 +262,11 @@ update_program_constants(struct gl_context *ctx) return new_state; } - - - static void update_viewport_matrix(struct gl_context *ctx) { const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; + GLint i; ASSERT(depthMax > 0); @@ -276,11 +274,14 @@ 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, - depthMax); + + for (i = 0; i < ctx->Const.MaxViewports; i++) { + _math_matrix_viewport(&ctx->ViewportArray[i]._WindowMap, + ctx->ViewportArray[i].X, ctx->ViewportArray[i].Y, + ctx->ViewportArray[i].Width, ctx->ViewportArray[i].Height, + ctx->ViewportArray[i].Near, ctx->ViewportArray[i].Far, + depthMax); + } } diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index 5da10ba..08efd05 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -77,10 +77,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 @@ -88,10 +88,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 @@ -122,12 +122,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 = (GLfloat) CLAMP(nearval, 0.0, 1.0); - ctx->Viewport.Far = (GLfloat) CLAMP(farval, 0.0, 1.0); + ctx->ViewportArray[0].Near = (GLfloat) CLAMP(nearval, 0.0, 1.0); + ctx->ViewportArray[0].Far = (GLfloat) CLAMP(farval, 0.0, 1.0); ctx->NewState |= _NEW_VIEWPORT; #if 1 @@ -135,10 +135,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 @@ -162,15 +162,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); } @@ -181,6 +181,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); } diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c index 2902315..2c2e7c7 100644 --- a/src/mesa/math/m_matrix.c +++ b/src/mesa/math/m_matrix.c @@ -1110,15 +1110,16 @@ _math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ) * Transforms Normalized Device Coords to window/Z values. */ void -_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height, - GLfloat zNear, GLfloat zFar, GLfloat depthMax) +_math_matrix_viewport(GLmatrix *m, GLfloat x, GLfloat y, + GLfloat width, GLfloat height, + GLdouble zNear, GLdouble zFar, GLdouble depthMax) { m->m[MAT_SX] = (GLfloat) width / 2.0F; m->m[MAT_TX] = m->m[MAT_SX] + x; m->m[MAT_SY] = (GLfloat) height / 2.0F; m->m[MAT_TY] = m->m[MAT_SY] + y; - m->m[MAT_SZ] = depthMax * ((zFar - zNear) / 2.0F); - m->m[MAT_TZ] = depthMax * ((zFar - zNear) / 2.0F + zNear); + m->m[MAT_SZ] = (GLfloat) depthMax * ((zFar - zNear) / 2.0F); + m->m[MAT_TZ] = (GLfloat) depthMax * ((zFar - zNear) / 2.0F + zNear); m->flags = MAT_FLAG_GENERAL_SCALE | MAT_FLAG_TRANSLATION; m->type = MATRIX_3D_NO_ROT; } diff --git a/src/mesa/math/m_matrix.h b/src/mesa/math/m_matrix.h index 2b097cb..dddce70 100644 --- a/src/mesa/math/m_matrix.h +++ b/src/mesa/math/m_matrix.h @@ -122,8 +122,8 @@ _math_matrix_frustum( GLmatrix *mat, GLfloat nearval, GLfloat farval ); extern void -_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height, - GLfloat zNear, GLfloat zFar, GLfloat depthMax); +_math_matrix_viewport(GLmatrix *m, GLfloat x, GLfloat y, GLfloat width, GLfloat height, + GLdouble zNear, GLdouble zFar, GLdouble depthMax); extern void _math_matrix_set_identity( GLmatrix *dest ); diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index f6fd535..c7ee403 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -353,9 +353,10 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], ((int *)value)[0] = ctx->DrawBuffer->Visual.samples; return; case STATE_DEPTH_RANGE: - value[0] = ctx->Viewport.Near; /* near */ - value[1] = ctx->Viewport.Far; /* far */ - value[2] = ctx->Viewport.Far - ctx->Viewport.Near; /* far - near */ + // TODO: Need a new query to get full viewport array? + value[0] = (GLfloat) ctx->ViewportArray[0].Near; /* near */ + value[1] = (GLfloat) ctx->ViewportArray[0].Far; /* far */ + value[2] = (GLfloat) ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near; /* far - near */ value[3] = 1.0; return; case STATE_FRAGMENT_PROGRAM: diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c index 133cc49..03c1521f 100644 --- a/src/mesa/state_tracker/st_atom_viewport.c +++ b/src/mesa/state_tracker/st_atom_viewport.c @@ -62,12 +62,12 @@ update_viewport( struct st_context *st ) /* _NEW_VIEWPORT */ { - GLfloat x = (GLfloat)ctx->Viewport.X; - GLfloat y = (GLfloat)ctx->Viewport.Y; - GLfloat z = ctx->Viewport.Near; - GLfloat half_width = (GLfloat)ctx->Viewport.Width * 0.5f; - GLfloat half_height = (GLfloat)ctx->Viewport.Height * 0.5f; - GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) * 0.5f; + GLfloat x = (GLfloat)ctx->ViewportArray[0].X; + GLfloat y = (GLfloat)ctx->ViewportArray[0].Y; + GLfloat z = ctx->ViewportArray[0].Near; + GLfloat half_width = (GLfloat)ctx->ViewportArray[0].Width * 0.5f; + GLfloat half_height = (GLfloat)ctx->ViewportArray[0].Height * 0.5f; + GLfloat half_depth = (GLfloat)(ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near) * 0.5f; st->state.viewport.scale[0] = half_width; st->state.viewport.scale[1] = half_height * yScale; diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 7002506..ed1ddd8 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -74,10 +74,10 @@ _swrast_update_rasterflags( struct gl_context *ctx ) } if (ctx->Color.ColorLogicOpEnabled) rasterMask |= LOGIC_OP_BIT; if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT; - if ( ctx->Viewport.X < 0 - || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width - || ctx->Viewport.Y < 0 - || ctx->Viewport.Y + ctx->Viewport.Height > (GLint) ctx->DrawBuffer->Height) { + if ( ctx->ViewportArray[0].X < 0 + || ctx->ViewportArray[0].X + ctx->ViewportArray[0].Width > (GLint) ctx->DrawBuffer->Width + || ctx->ViewportArray[0].Y < 0 + || ctx->ViewportArray[0].Y + ctx->ViewportArray[0].Height > (GLint) ctx->DrawBuffer->Height) { rasterMask |= CLIP_BIT; } diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 0f4fb95..7f3c76d 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -171,12 +171,12 @@ _swrast_depth_clamp_span( struct gl_context *ctx, SWspan *span ) GLfloat min_f, max_f; GLuint i; - if (ctx->Viewport.Near < ctx->Viewport.Far) { - min_f = ctx->Viewport.Near; - max_f = ctx->Viewport.Far; + if (ctx->ViewportArray[0].Near < ctx->ViewportArray[0].Far) { + min_f = ctx->ViewportArray[0].Near; + max_f = ctx->ViewportArray[0].Far; } else { - min_f = ctx->Viewport.Far; - max_f = ctx->Viewport.Near; + min_f = ctx->ViewportArray[0].Far; + max_f = ctx->ViewportArray[0].Near; } /* Convert floating point values in [0,1] to device Z coordinates in diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index 6ef1a57..707dc75 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -167,7 +167,7 @@ setup_vertex_format(struct gl_context *ctx) EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize ); _tnl_install_attrs( ctx, map, e, - ctx->Viewport._WindowMap.m, + ctx->ViewportArray[0]._WindowMap.m, sizeof(SWvertex) ); swsetup->last_index_bitset = index_bitset; @@ -265,7 +265,7 @@ _swsetup_Wakeup( struct gl_context *ctx ) void _swsetup_Translate( struct gl_context *ctx, const void *vertex, SWvertex *dest ) { - const GLfloat *m = ctx->Viewport._WindowMap.m; + const GLfloat *m = ctx->ViewportArray[0]._WindowMap.m; GLfloat tmp[4]; GLuint i; diff --git a/src/mesa/tnl/t_rasterpos.c b/src/mesa/tnl/t_rasterpos.c index 3ee5c45..e538c34 100644 --- a/src/mesa/tnl/t_rasterpos.c +++ b/src/mesa/tnl/t_rasterpos.c @@ -409,19 +409,19 @@ _tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]) ndc[1] = clip[1] * d; ndc[2] = clip[2] * d; /* wincoord = viewport_mapping(ndc) */ - ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] - + ctx->Viewport._WindowMap.m[MAT_TX]); - ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] - + ctx->Viewport._WindowMap.m[MAT_TY]); - ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] - + ctx->Viewport._WindowMap.m[MAT_TZ]) + ctx->Current.RasterPos[0] = (ndc[0] * ctx->ViewportArray[0]._WindowMap.m[MAT_SX] + + ctx->ViewportArray[0]._WindowMap.m[MAT_TX]); + ctx->Current.RasterPos[1] = (ndc[1] * ctx->ViewportArray[0]._WindowMap.m[MAT_SY] + + ctx->ViewportArray[0]._WindowMap.m[MAT_TY]); + ctx->Current.RasterPos[2] = (ndc[2] * ctx->ViewportArray[0]._WindowMap.m[MAT_SZ] + + ctx->ViewportArray[0]._WindowMap.m[MAT_TZ]) / ctx->DrawBuffer->_DepthMaxF; ctx->Current.RasterPos[3] = clip[3]; if (ctx->Transform.DepthClamp) { ctx->Current.RasterPos[3] = CLAMP(ctx->Current.RasterPos[3], - ctx->Viewport.Near, - ctx->Viewport.Far); + ctx->ViewportArray[0].Near, + ctx->ViewportArray[0].Far); } /* compute raster distance */ -- 1.8.1.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev