From: Alyssa Rosenzweig Date: Tue, 19 May 2020 15:08:51 +0000 (-0400) Subject: mesa: Use SATURATE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=05bacdb9170edc408a86ca315f195b9aabdd3651;p=mesa.git mesa: Use SATURATE Signed-off-by: Alyssa Rosenzweig Reviewed-by: Eric Engestrom Part-of: --- diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index c1a924e49f7..6abe8681025 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -3356,7 +3356,7 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, const GLfloat x1 = x + width; const GLfloat y1 = y + height; - z = CLAMP(z, 0.0f, 1.0f); + z = SATURATE(z); z = invert_z(z); verts[0].x = x; diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c index 278a4ce40fa..ab98de745e4 100644 --- a/src/mesa/main/depth.c +++ b/src/mesa/main/depth.c @@ -154,8 +154,8 @@ _mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ) return; } - zmin = CLAMP(zmin, 0.0, 1.0); - zmax = CLAMP(zmax, 0.0, 1.0); + zmin = SATURATE(zmin); + zmax = SATURATE(zmax); if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax) return; diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 298a6b35d0a..2f2c7dc45a9 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -5338,7 +5338,7 @@ sample_locations(struct gl_context *ctx, struct gl_framebuffer *fb, if (isnan(v[i])) fb->SampleLocationTable[start * 2 + i] = 0.5f; else - fb->SampleLocationTable[start * 2 + i] = CLAMP(v[i], 0.0f, 1.0f); + fb->SampleLocationTable[start * 2 + i] = SATURATE(v[i]); } if (fb == ctx->DrawBuffer) diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c index 66eb0c8b98e..c1d0e3be94f 100644 --- a/src/mesa/main/multisample.c +++ b/src/mesa/main/multisample.c @@ -41,7 +41,7 @@ _mesa_SampleCoverage(GLclampf value, GLboolean invert) { GET_CURRENT_CONTEXT(ctx); - value = CLAMP(value, 0.0f, 1.0f); + value = SATURATE(value); if (ctx->Multisample.SampleCoverageInvert == invert && ctx->Multisample.SampleCoverageValue == value) @@ -165,7 +165,7 @@ _mesa_SampleMaski(GLuint index, GLbitfield mask) static void min_sample_shading(struct gl_context *ctx, GLclampf value) { - value = CLAMP(value, 0.0f, 1.0f); + value = SATURATE(value); if (ctx->Multisample.MinSampleShadingValue == value) return; diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index a501e245626..d8b80aa469f 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -295,8 +295,8 @@ set_depth_range_no_notify(struct gl_context *ctx, unsigned idx, FLUSH_VERTICES(ctx, _NEW_VIEWPORT); ctx->NewDriverState |= ctx->DriverFlags.NewViewport; - ctx->ViewportArray[idx].Near = CLAMP(nearval, 0.0, 1.0); - ctx->ViewportArray[idx].Far = CLAMP(farval, 0.0, 1.0); + ctx->ViewportArray[idx].Near = SATURATE(nearval); + ctx->ViewportArray[idx].Far = SATURATE(farval); } void diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 225acd853a0..b24e7540f0a 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -440,10 +440,10 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index16 state[], if(ctx->Light._ClampVertexColor && (idx == VERT_ATTRIB_COLOR0 || idx == VERT_ATTRIB_COLOR1)) { - value[0] = CLAMP(ctx->Current.Attrib[idx][0], 0.0f, 1.0f); - value[1] = CLAMP(ctx->Current.Attrib[idx][1], 0.0f, 1.0f); - value[2] = CLAMP(ctx->Current.Attrib[idx][2], 0.0f, 1.0f); - value[3] = CLAMP(ctx->Current.Attrib[idx][3], 0.0f, 1.0f); + value[0] = SATURATE(ctx->Current.Attrib[idx][0]); + value[1] = SATURATE(ctx->Current.Attrib[idx][1]); + value[2] = SATURATE(ctx->Current.Attrib[idx][2]); + value[3] = SATURATE(ctx->Current.Attrib[idx][3]); } else COPY_4V(value, ctx->Current.Attrib[idx]); diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index 4960a55e986..3ea5cffb512 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -219,7 +219,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, return; } - z = CLAMP(z, 0.0f, 1.0f); + z = SATURATE(z); /* positions (in clip coords) */ {