[Mesa-dev] [PATCH 10/13] swrast: Avoid double promotion.
Iago Toral
itoral at igalia.com
Tue Jul 14 04:03:19 PDT 2015
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
On Mon, 2015-07-13 at 16:22 -0700, Matt Turner wrote:
> ---
> src/mesa/swrast/s_aaline.c | 28 ++++++++++++++--------------
> src/mesa/swrast/s_aalinetemp.h | 4 ++--
> src/mesa/swrast/s_atifragshader.c | 4 ++--
> src/mesa/swrast/s_copypix.c | 6 +++---
> src/mesa/swrast/s_drawpix.c | 12 ++++++------
> src/mesa/swrast/s_fragprog.c | 4 ++--
> src/mesa/swrast/s_lines.c | 4 ++--
> src/mesa/swrast/s_points.c | 10 +++++-----
> src/mesa/swrast/s_span.c | 10 +++++-----
> src/mesa/swrast/s_texcombine.c | 6 +++---
> src/mesa/swrast/s_texfilter.c | 8 ++++----
> src/mesa/swrast/s_tritemp.h | 2 +-
> src/mesa/swrast/s_zoom.c | 2 +-
> 13 files changed, 50 insertions(+), 50 deletions(-)
>
> diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
> index f3258e8..de5b42b 100644
> --- a/src/mesa/swrast/s_aaline.c
> +++ b/src/mesa/swrast/s_aaline.c
> @@ -116,11 +116,11 @@ compute_plane(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
> const GLfloat b = pz * py;
> const GLfloat c = px * px + py * py;
> const GLfloat d = -(a * x0 + b * y0 + c * z0);
> - if (a == 0.0 && b == 0.0 && c == 0.0 && d == 0.0) {
> - plane[0] = 0.0;
> - plane[1] = 0.0;
> - plane[2] = 1.0;
> - plane[3] = 0.0;
> + if (a == 0.0F && b == 0.0F && c == 0.0F && d == 0.0F) {
> + plane[0] = 0.0F;
> + plane[1] = 0.0F;
> + plane[2] = 1.0F;
> + plane[3] = 0.0F;
> }
> else {
> plane[0] = a;
> @@ -135,9 +135,9 @@ compute_plane(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
> static inline void
> constant_plane(GLfloat value, GLfloat plane[4])
> {
> - plane[0] = 0.0;
> - plane[1] = 0.0;
> - plane[2] = -1.0;
> + plane[0] = 0.0F;
> + plane[1] = 0.0F;
> + plane[2] = -1.0F;
> plane[3] = value;
> }
>
> @@ -160,8 +160,8 @@ static inline GLfloat
> solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4])
> {
> const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y;
> - if (denom == 0.0)
> - return 0.0;
> + if (denom == 0.0F)
> + return 0.0F;
> else
> return -plane[2] / denom;
> }
> @@ -374,7 +374,7 @@ segment(struct gl_context *ctx,
> if (x0 < x1) {
> xLeft = x0 - line->halfWidth;
> xRight = x1 + line->halfWidth;
> - if (line->dy >= 0.0) {
> + if (line->dy >= 0.0F) {
> yBot = y0 - 3.0F * line->halfWidth;
> yTop = y0 + line->halfWidth;
> }
> @@ -386,7 +386,7 @@ segment(struct gl_context *ctx,
> else {
> xLeft = x1 - line->halfWidth;
> xRight = x0 + line->halfWidth;
> - if (line->dy <= 0.0) {
> + if (line->dy <= 0.0F) {
> yBot = y1 - 3.0F * line->halfWidth;
> yTop = y1 + line->halfWidth;
> }
> @@ -420,7 +420,7 @@ segment(struct gl_context *ctx,
> if (y0 < y1) {
> yBot = y0 - line->halfWidth;
> yTop = y1 + line->halfWidth;
> - if (line->dx >= 0.0) {
> + if (line->dx >= 0.0F) {
> xLeft = x0 - 3.0F * line->halfWidth;
> xRight = x0 + line->halfWidth;
> }
> @@ -432,7 +432,7 @@ segment(struct gl_context *ctx,
> else {
> yBot = y1 - line->halfWidth;
> yTop = y0 + line->halfWidth;
> - if (line->dx <= 0.0) {
> + if (line->dx <= 0.0F) {
> xLeft = x1 - 3.0F * line->halfWidth;
> xRight = x1 + line->halfWidth;
> }
> diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h
> index f1d078f..bebb131 100644
> --- a/src/mesa/swrast/s_aalinetemp.h
> +++ b/src/mesa/swrast/s_aalinetemp.h
> @@ -44,7 +44,7 @@ NAME(plot)(struct gl_context *ctx, struct LineInfo *line, int ix, int iy)
>
> (void) swrast;
>
> - if (coverage == 0.0)
> + if (coverage == 0.0F)
> return;
>
> line->span.end++;
> @@ -123,7 +123,7 @@ NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1)
> ctx->Const.MinLineWidthAA,
> ctx->Const.MaxLineWidthAA);
>
> - if (line.len == 0.0 || IS_INF_OR_NAN(line.len))
> + if (line.len == 0.0F || IS_INF_OR_NAN(line.len))
> return;
>
> INIT_SPAN(line.span, GL_LINE);
> diff --git a/src/mesa/swrast/s_atifragshader.c b/src/mesa/swrast/s_atifragshader.c
> index 9e029db..2974dee 100644
> --- a/src/mesa/swrast/s_atifragshader.c
> +++ b/src/mesa/swrast/s_atifragshader.c
> @@ -436,13 +436,13 @@ execute_shader(struct gl_context *ctx, const struct ati_fragment_shader *shader,
> for (i = 0; i < 3; i++) {
> dst[optype][i] =
> (src[optype][2][i] >
> - 0.5) ? src[optype][0][i] : src[optype][1][i];
> + 0.5F) ? src[optype][0][i] : src[optype][1][i];
> }
> }
> else {
> dst[optype][3] =
> (src[optype][2][3] >
> - 0.5) ? src[optype][0][3] : src[optype][1][3];
> + 0.5F) ? src[optype][0][3] : src[optype][1][3];
> }
> break;
>
> diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
> index 8fde0c2..0dbccc0 100644
> --- a/src/mesa/swrast/s_copypix.c
> +++ b/src/mesa/swrast/s_copypix.c
> @@ -52,7 +52,7 @@ regions_overlap(GLint srcx, GLint srcy,
> GLint width, GLint height,
> GLfloat zoomX, GLfloat zoomY)
> {
> - if (zoomX == 1.0 && zoomY == 1.0) {
> + if (zoomX == 1.0F && zoomY == 1.0F) {
> return _mesa_regions_overlap(srcx, srcy, srcx + width, srcy + height,
> dstx, dsty, dstx + width, dsty + height);
> }
> @@ -201,8 +201,8 @@ scale_and_bias_z(struct gl_context *ctx, GLuint width,
> GLuint i;
>
> if (depthMax <= 0xffffff &&
> - ctx->Pixel.DepthScale == 1.0 &&
> - ctx->Pixel.DepthBias == 0.0) {
> + ctx->Pixel.DepthScale == 1.0F &&
> + ctx->Pixel.DepthBias == 0.0F) {
> /* no scale or bias and no clamping and no worry of overflow */
> const GLfloat depthMaxF = ctx->DrawBuffer->_DepthMaxF;
> for (i = 0; i < width; i++) {
> diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
> index fb677ee..dc6827e 100644
> --- a/src/mesa/swrast/s_drawpix.c
> +++ b/src/mesa/swrast/s_drawpix.c
> @@ -264,7 +264,7 @@ draw_stencil_pixels( struct gl_context *ctx, GLint x, GLint y,
> const struct gl_pixelstore_attrib *unpack,
> const GLvoid *pixels )
> {
> - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
> + const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
> const GLenum destType = GL_UNSIGNED_BYTE;
> GLint row;
> GLubyte *values;
> @@ -309,8 +309,8 @@ draw_depth_pixels( struct gl_context *ctx, GLint x, GLint y,
> const GLvoid *pixels )
> {
> const GLboolean scaleOrBias
> - = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
> - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
> + = ctx->Pixel.DepthScale != 1.0f || ctx->Pixel.DepthBias != 0.0f;
> + const GLboolean zoom = ctx->Pixel.ZoomX != 1.0f || ctx->Pixel.ZoomY != 1.0f;
> SWspan span;
>
> INIT_SPAN(span, GL_BITMAP);
> @@ -415,7 +415,7 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
> const GLvoid *pixels )
> {
> const GLint imgX = x, imgY = y;
> - const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
> + const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
> GLbitfield transferOps = ctx->_ImageTransferState;
> SWspan span;
>
> @@ -601,10 +601,10 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
> {
> const GLint imgX = x, imgY = y;
> const GLboolean scaleOrBias
> - = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
> + = ctx->Pixel.DepthScale != 1.0F || ctx->Pixel.DepthBias != 0.0F;
> const GLuint stencilMask = ctx->Stencil.WriteMask[0];
> const GLenum stencilType = GL_UNSIGNED_BYTE;
> - const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
> + const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
> struct gl_renderbuffer *depthRb, *stencilRb;
> struct gl_pixelstore_attrib clippedUnpack = *unpack;
>
> diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
> index 175915a..4fbf66b 100644
> --- a/src/mesa/swrast/s_fragprog.c
> +++ b/src/mesa/swrast/s_fragprog.c
> @@ -243,9 +243,9 @@ run_program(struct gl_context *ctx, SWspan *span, GLuint start, GLuint end)
> /* Store result depth/z */
> if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
> const GLfloat depth = machine->Outputs[FRAG_RESULT_DEPTH][2];
> - if (depth <= 0.0)
> + if (depth <= 0.0F)
> span->array->z[i] = 0;
> - else if (depth >= 1.0)
> + else if (depth >= 1.0F)
> span->array->z[i] = ctx->DrawBuffer->_DepthMax;
> else
> span->array->z[i] =
> diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
> index 58bd2fc..ab8da7d 100644
> --- a/src/mesa/swrast/s_lines.c
> +++ b/src/mesa/swrast/s_lines.c
> @@ -241,7 +241,7 @@ _swrast_choose_line( struct gl_context *ctx )
> USE(general_line);
> }
> else if (ctx->Depth.Test
> - || ctx->Line.Width != 1.0
> + || ctx->Line.Width != 1.0F
> || ctx->Line.StippleFlag) {
> /* no texture, but Z, fog, width>1, stipple, etc. */
> #if CHAN_BITS == 32
> @@ -252,7 +252,7 @@ _swrast_choose_line( struct gl_context *ctx )
> }
> else {
> assert(!ctx->Depth.Test);
> - assert(ctx->Line.Width == 1.0);
> + assert(ctx->Line.Width == 1.0F);
> /* simple lines */
> USE(simple_no_z_rgba_line);
> }
> diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
> index 2212c95..d9aae73 100644
> --- a/src/mesa/swrast/s_points.c
> +++ b/src/mesa/swrast/s_points.c
> @@ -208,9 +208,9 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert)
> else {
> /* even size */
> /* 0.501 factor allows conformance to pass */
> - xmin = (GLint) (x + 0.501) - iRadius;
> + xmin = (GLint) (x + 0.501F) - iRadius;
> xmax = xmin + iSize - 1;
> - ymin = (GLint) (y + 0.501) - iRadius;
> + ymin = (GLint) (y + 0.501F) - iRadius;
> ymax = ymin + iSize - 1;
> }
>
> @@ -423,9 +423,9 @@ large_point(struct gl_context *ctx, const SWvertex *vert)
> else {
> /* even size */
> /* 0.501 factor allows conformance to pass */
> - xmin = (GLint) (x + 0.501) - iRadius;
> + xmin = (GLint) (x + 0.501F) - iRadius;
> xmax = xmin + iSize - 1;
> - ymin = (GLint) (y + 0.501) - iRadius;
> + ymin = (GLint) (y + 0.501F) - iRadius;
> ymax = ymin + iSize - 1;
> }
>
> @@ -552,7 +552,7 @@ _swrast_choose_point(struct gl_context *ctx)
> else if (ctx->Point.SmoothFlag) {
> swrast->Point = smooth_point;
> }
> - else if (size > 1.0 ||
> + else if (size > 1.0F ||
> ctx->Point._Attenuated ||
> ctx->VertexProgram.PointSizeEnabled) {
> swrast->Point = large_point;
> diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
> index 3db10e1..cd939ba 100644
> --- a/src/mesa/swrast/s_span.c
> +++ b/src/mesa/swrast/s_span.c
> @@ -506,7 +506,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
> /* LOD is calculated directly in the ansiotropic filter, we can
> * skip the normal lambda function as the result is ignored.
> */
> - if (samp->MaxAnisotropy > 1.0 &&
> + if (samp->MaxAnisotropy > 1.0F &&
> samp->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
> needLambda = GL_FALSE;
> }
> @@ -886,16 +886,16 @@ apply_aa_coverage(SWspan *span)
> GLubyte (*rgba)[4] = span->array->rgba8;
> for (i = 0; i < span->end; i++) {
> const GLfloat a = rgba[i][ACOMP] * coverage[i];
> - rgba[i][ACOMP] = (GLubyte) CLAMP(a, 0.0, 255.0);
> - assert(coverage[i] >= 0.0);
> - assert(coverage[i] <= 1.0);
> + rgba[i][ACOMP] = (GLubyte) CLAMP(a, 0.0F, 255.0F);
> + assert(coverage[i] >= 0.0F);
> + assert(coverage[i] <= 1.0F);
> }
> }
> else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
> GLushort (*rgba)[4] = span->array->rgba16;
> for (i = 0; i < span->end; i++) {
> const GLfloat a = rgba[i][ACOMP] * coverage[i];
> - rgba[i][ACOMP] = (GLushort) CLAMP(a, 0.0, 65535.0);
> + rgba[i][ACOMP] = (GLushort) CLAMP(a, 0.0F, 65535.0F);
> }
> }
> else {
> diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c
> index 453bd36..da4a013 100644
> --- a/src/mesa/swrast/s_texcombine.c
> +++ b/src/mesa/swrast/s_texcombine.c
> @@ -670,8 +670,8 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
> }
> }
>
> - if (samp->MinLod != -1000.0 ||
> - samp->MaxLod != 1000.0) {
> + if (samp->MinLod != -1000.0F ||
> + samp->MaxLod != 1000.0F) {
> /* apply LOD clamping to lambda */
> const GLfloat min = samp->MinLod;
> const GLfloat max = samp->MaxLod;
> @@ -682,7 +682,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
> }
> }
> }
> - else if (samp->MaxAnisotropy > 1.0 &&
> + else if (samp->MaxAnisotropy > 1.0F &&
> samp->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
> /* sample_lambda_2d_aniso is beeing used as texture_sample_func,
> * it requires the current SWspan *span as an additional parameter.
> diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
> index abc1727..cb50b81 100644
> --- a/src/mesa/swrast/s_texfilter.c
> +++ b/src/mesa/swrast/s_texfilter.c
> @@ -1902,7 +1902,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
> const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
> const GLboolean adjustLOD =
> (texUnit->LodBias + samp->LodBias != 0.0F)
> - || (samp->MinLod != -1000.0 || samp->MaxLod != 1000.0);
> + || (samp->MinLod != -1000.0F || samp->MaxLod != 1000.0F);
>
> GLuint i;
>
> @@ -1973,8 +1973,8 @@ sample_lambda_2d_aniso(struct gl_context *ctx,
> ctx->Const.MaxTextureLodBias);
> lod += bias;
>
> - if (samp->MinLod != -1000.0 ||
> - samp->MaxLod != 1000.0) {
> + if (samp->MinLod != -1000.0F ||
> + samp->MaxLod != 1000.0F) {
> /* apply LOD clamping to lambda */
> lod = CLAMP(lod, samp->MinLod, samp->MaxLod);
> }
> @@ -3740,7 +3740,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx,
> }
> else if (needLambda) {
> /* Anisotropic filtering extension. Activated only if mipmaps are used */
> - if (sampler->MaxAnisotropy > 1.0 &&
> + if (sampler->MaxAnisotropy > 1.0F &&
> sampler->MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
> return &sample_lambda_2d_aniso;
> }
> diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
> index fddbbfd..1d71839 100644
> --- a/src/mesa/swrast/s_tritemp.h
> +++ b/src/mesa/swrast/s_tritemp.h
> @@ -242,7 +242,7 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0,
> if (IS_INF_OR_NAN(area) || area == 0.0F)
> return;
>
> - if (area * bf * swrast->_BackfaceCullSign < 0.0)
> + if (area * bf * swrast->_BackfaceCullSign < 0.0F)
> return;
>
> oneOverArea = 1.0F / area;
> diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c
> index 9879e2a..34b8eb1 100644
> --- a/src/mesa/swrast/s_zoom.c
> +++ b/src/mesa/swrast/s_zoom.c
> @@ -114,7 +114,7 @@ unzoom_x(GLfloat zoomX, GLint imageX, GLint zx)
> (zx - imageX) / zoomX = x - imageX;
> */
> GLint x;
> - if (zoomX < 0.0)
> + if (zoomX < 0.0F)
> zx++;
> x = imageX + (GLint) ((zx - imageX) / zoomX);
> return x;
More information about the mesa-dev
mailing list