aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2020-02-03 21:18:42 +0000
committerMarge Bot <[email protected]>2020-05-07 10:39:19 +0000
commitd8a27c0bb3049963934c77d104db39ecf610e3b9 (patch)
tree61293761c0778f3af3dbc6b847d16a653ca2e50e
parent9a11aa4ece691ac9b6d8911cac6f3727ac3d7094 (diff)
compiler/spirv: flag nclamp/nmin/nmax as exact
Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3716>
-rw-r--r--src/compiler/spirv/vtn_glsl450.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 8a234827dc5..ca836bde61b 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -219,8 +219,10 @@ build_asin(nir_builder *b, nir_ssa_def *x, float p0, float p1)
static nir_op
vtn_nir_alu_op_for_spirv_glsl_opcode(struct vtn_builder *b,
enum GLSLstd450 opcode,
- unsigned execution_mode)
+ unsigned execution_mode,
+ bool *exact)
{
+ *exact = false;
switch (opcode) {
case GLSLstd450Round: return nir_op_fround_even;
case GLSLstd450RoundEven: return nir_op_fround_even;
@@ -239,11 +241,11 @@ vtn_nir_alu_op_for_spirv_glsl_opcode(struct vtn_builder *b,
case GLSLstd450Log2: return nir_op_flog2;
case GLSLstd450Sqrt: return nir_op_fsqrt;
case GLSLstd450InverseSqrt: return nir_op_frsq;
- case GLSLstd450NMin: return nir_op_fmin;
+ case GLSLstd450NMin: *exact = true; return nir_op_fmin;
case GLSLstd450FMin: return nir_op_fmin;
case GLSLstd450UMin: return nir_op_umin;
case GLSLstd450SMin: return nir_op_imin;
- case GLSLstd450NMax: return nir_op_fmax;
+ case GLSLstd450NMax: *exact = true; return nir_op_fmax;
case GLSLstd450FMax: return nir_op_fmax;
case GLSLstd450UMax: return nir_op_umax;
case GLSLstd450SMax: return nir_op_imax;
@@ -353,8 +355,12 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
return;
case GLSLstd450FClamp:
+ val->ssa->def = nir_fclamp(nb, src[0], src[1], src[2]);
+ return;
case GLSLstd450NClamp:
+ nb->exact = true;
val->ssa->def = nir_fclamp(nb, src[0], src[1], src[2]);
+ nb->exact = false;
return;
case GLSLstd450UClamp:
val->ssa->def = nir_uclamp(nb, src[0], src[1], src[2]);
@@ -515,10 +521,11 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
default: {
unsigned execution_mode =
b->shader->info.float_controls_execution_mode;
- val->ssa->def =
- nir_build_alu(&b->nb,
- vtn_nir_alu_op_for_spirv_glsl_opcode(b, entrypoint, execution_mode),
- src[0], src[1], src[2], NULL);
+ bool exact;
+ nir_op op = vtn_nir_alu_op_for_spirv_glsl_opcode(b, entrypoint, execution_mode, &exact);
+ b->nb.exact = exact;
+ val->ssa->def = nir_build_alu(&b->nb, op, src[0], src[1], src[2], NULL);
+ b->nb.exact = false;
return;
}
}