summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2015-07-11 22:46:19 -0700
committerMatt Turner <[email protected]>2015-07-29 09:34:51 -0700
commitf8a647883a14694f1b758c12187b3f35b9d039a7 (patch)
treecd11148549da4b67e6a9a3f1b941b3dfaa27295c
parentecc559218d0a544f8a5f878c500f125c2d588d82 (diff)
mesa: Use floats for viewport bounds.
ARB_viewport_array specifies that DEPTH_RANGE consists of double- precision parameters (corresponding commit d4dc35987), and a preparatory commit (6340e609a) added _mesa_get_viewport_xform() which returned double-precision scale[3] and translate[3] vectors, even though X, Y, Width, and Height were still floats. All users of _mesa_get_viewport_xform() immediately convert the double scale and translation vectors into floats (which were floats originally, but were converted to doubles in _mesa_get_viewport_xform(), sigh). i965 at least cannot consume doubles (see SF_CLIP_VIEWPORT). If we want to pass doubles to hardware, we should have a different function that does that. Acked-by: Mathias Froehlich <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i915/i915_state.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_sf_state.c2
-rw-r--r--src/mesa/drivers/dri/i965/gen6_viewport_state.c2
-rw-r--r--src/mesa/drivers/dri/i965/gen7_viewport_state.c2
-rw-r--r--src/mesa/drivers/dri/i965/gen8_viewport_state.c2
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_state.c2
-rw-r--r--src/mesa/main/viewport.c14
-rw-r--r--src/mesa/main/viewport.h2
-rw-r--r--src/mesa/math/m_matrix.c4
-rw-r--r--src/mesa/math/m_matrix.h4
-rw-r--r--src/mesa/state_tracker/st_atom_viewport.c2
-rw-r--r--src/mesa/tnl/t_context.c2
-rw-r--r--src/mesa/tnl/t_rasterpos.c2
14 files changed, 22 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c
index 5f10b840b1a..4c83073e692 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -402,7 +402,7 @@ void
intelCalcViewport(struct gl_context * ctx)
{
struct intel_context *intel = intel_context(ctx);
- double scale[3], translate[3];
+ float scale[3], translate[3];
_mesa_get_viewport_xform(ctx, 0, scale, translate);
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 5d9892214a9..3be6e4ab8e2 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -45,7 +45,7 @@ static void upload_sf_vp(struct brw_context *brw)
struct gl_context *ctx = &brw->ctx;
struct brw_sf_viewport *sfv;
GLfloat y_scale, y_bias;
- double scale[3], translate[3];
+ float scale[3], translate[3];
const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_STATE,
diff --git a/src/mesa/drivers/dri/i965/gen6_viewport_state.c b/src/mesa/drivers/dri/i965/gen6_viewport_state.c
index 7c8d8849f4e..11b9a360ced 100644
--- a/src/mesa/drivers/dri/i965/gen6_viewport_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_viewport_state.c
@@ -101,7 +101,7 @@ gen6_upload_sf_vp(struct brw_context *brw)
}
for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
- double scale[3], translate[3];
+ float scale[3], translate[3];
/* _NEW_VIEWPORT */
_mesa_get_viewport_xform(ctx, i, scale, translate);
diff --git a/src/mesa/drivers/dri/i965/gen7_viewport_state.c b/src/mesa/drivers/dri/i965/gen7_viewport_state.c
index b655205ec35..c75dc9964bf 100644
--- a/src/mesa/drivers/dri/i965/gen7_viewport_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_viewport_state.c
@@ -53,7 +53,7 @@ gen7_upload_sf_clip_viewport(struct brw_context *brw)
}
for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
- double scale[3], translate[3];
+ float scale[3], translate[3];
_mesa_get_viewport_xform(ctx, i, scale, translate);
/* According to the "Vertex X,Y Clamping and Quantization" section of
diff --git a/src/mesa/drivers/dri/i965/gen8_viewport_state.c b/src/mesa/drivers/dri/i965/gen8_viewport_state.c
index 2d8eeb1f10f..2692ad55999 100644
--- a/src/mesa/drivers/dri/i965/gen8_viewport_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_viewport_state.c
@@ -53,7 +53,7 @@ gen8_upload_sf_clip_viewport(struct brw_context *brw)
}
for (unsigned i = 0; i < ctx->Const.MaxViewports; i++) {
- double scale[3], translate[3];
+ float scale[3], translate[3];
_mesa_get_viewport_xform(ctx, i, scale, translate);
/* _NEW_VIEWPORT: Viewport Matrix Elements */
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index 2023ba09449..cca176d7f9b 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -1546,7 +1546,7 @@ void r200UpdateWindow( struct gl_context *ctx )
GLfloat xoffset = 0;
GLfloat yoffset = dPriv ? (GLfloat) dPriv->h : 0;
const GLboolean render_to_fbo = (ctx->DrawBuffer ? _mesa_is_user_fbo(ctx->DrawBuffer) : 0);
- double scale[3], translate[3];
+ float scale[3], translate[3];
GLfloat y_scale, y_bias;
if (render_to_fbo) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index 156afb6f6ac..74c1fc6c902 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1354,7 +1354,7 @@ void radeonUpdateWindow( struct gl_context *ctx )
GLfloat xoffset = 0.0;
GLfloat yoffset = dPriv ? (GLfloat) dPriv->h : 0;
const GLboolean render_to_fbo = (ctx->DrawBuffer ? _mesa_is_user_fbo(ctx->DrawBuffer) : 0);
- double scale[3], translate[3];
+ float scale[3], translate[3];
GLfloat y_scale, y_bias;
if (render_to_fbo) {
diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index 9917f2de299..7d8914291c3 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -443,12 +443,12 @@ _mesa_ClipControl(GLenum origin, GLenum depth)
*/
void
_mesa_get_viewport_xform(struct gl_context *ctx, unsigned i,
- double scale[3], double translate[3])
+ float scale[3], float translate[3])
{
- double x = ctx->ViewportArray[i].X;
- double y = ctx->ViewportArray[i].Y;
- double half_width = 0.5*ctx->ViewportArray[i].Width;
- double half_height = 0.5*ctx->ViewportArray[i].Height;
+ float x = ctx->ViewportArray[i].X;
+ float y = ctx->ViewportArray[i].Y;
+ float half_width = 0.5f * ctx->ViewportArray[i].Width;
+ float half_height = 0.5f * ctx->ViewportArray[i].Height;
double n = ctx->ViewportArray[i].Near;
double f = ctx->ViewportArray[i].Far;
@@ -462,8 +462,8 @@ _mesa_get_viewport_xform(struct gl_context *ctx, unsigned i,
translate[1] = half_height + y;
}
if (ctx->Transform.ClipDepthMode == GL_NEGATIVE_ONE_TO_ONE) {
- scale[2] = 0.5*(f - n);
- translate[2] = 0.5*(n + f);
+ scale[2] = 0.5 * (f - n);
+ translate[2] = 0.5 * (n + f);
} else {
scale[2] = f - n;
translate[2] = n;
diff --git a/src/mesa/main/viewport.h b/src/mesa/main/viewport.h
index 899dc2d0bcc..b0675db1096 100644
--- a/src/mesa/main/viewport.h
+++ b/src/mesa/main/viewport.h
@@ -73,6 +73,6 @@ _mesa_ClipControl(GLenum origin, GLenum depth);
extern void
_mesa_get_viewport_xform(struct gl_context *ctx, unsigned i,
- double scale[3], double translate[3]);
+ float scale[3], float translate[3]);
#endif
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index ecf564c0089..6a42c6c0ed2 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -1111,8 +1111,8 @@ _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, const double scale[3],
- const double translate[3], double depthMax)
+_math_matrix_viewport(GLmatrix *m, const float scale[3],
+ const float translate[3], double depthMax)
{
m->m[MAT_SX] = scale[0];
m->m[MAT_TX] = translate[0];
diff --git a/src/mesa/math/m_matrix.h b/src/mesa/math/m_matrix.h
index 778d716dce7..c34d9e3022f 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, const double scale[3],
- const double translate[3], double depthMax );
+_math_matrix_viewport( GLmatrix *m, const float scale[3],
+ const float translate[3], double depthMax );
extern void
_math_matrix_set_identity( GLmatrix *dest );
diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c
index 2f62590c4f1..9a692cecade 100644
--- a/src/mesa/state_tracker/st_atom_viewport.c
+++ b/src/mesa/state_tracker/st_atom_viewport.c
@@ -64,7 +64,7 @@ update_viewport( struct st_context *st )
*/
for (i = 0; i < ctx->Const.MaxViewports; i++)
{
- double scale[3], translate[3];
+ float scale[3], translate[3];
_mesa_get_viewport_xform(ctx, i, scale, translate);
st->state.viewport[i].scale[0] = scale[0];
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index bc77ba8bf95..b5c0b3e1f5b 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -190,7 +190,7 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state )
}
if (new_state & (_NEW_VIEWPORT | _NEW_BUFFERS)) {
- double scale[3], translate[3];
+ float scale[3], translate[3];
_mesa_get_viewport_xform(ctx, 0, scale, translate);
_math_matrix_viewport(&tnl->_WindowMap, scale, translate,
ctx->DrawBuffer->_DepthMaxF);
diff --git a/src/mesa/tnl/t_rasterpos.c b/src/mesa/tnl/t_rasterpos.c
index d4b45bac9ac..7ef50ea7cd7 100644
--- a/src/mesa/tnl/t_rasterpos.c
+++ b/src/mesa/tnl/t_rasterpos.c
@@ -378,7 +378,7 @@ _tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4])
GLfloat eye[4], clip[4], ndc[3], d;
GLfloat *norm, eyenorm[3];
GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
- double scale[3], translate[3];
+ float scale[3], translate[3];
/* apply modelview matrix: eye = MV * obj */
TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, vObj );