[Mesa-dev] [PATCH 05/50] glsl: add utility function to extract 64-bit sign.
Dave Airlie
airlied at gmail.com
Tue Mar 13 04:24:30 UTC 2018
From: Elie Tournier <tournier.elie at gmail.com>
[airlied: left over from dropping le64]
Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
---
src/compiler/glsl/builtin_float64.h | 18 ++++++++++++++++++
src/compiler/glsl/float64.glsl | 7 +++++++
2 files changed, 25 insertions(+)
diff --git a/src/compiler/glsl/builtin_float64.h b/src/compiler/glsl/builtin_float64.h
index 2340c48..6a8afea 100644
--- a/src/compiler/glsl/builtin_float64.h
+++ b/src/compiler/glsl/builtin_float64.h
@@ -200,3 +200,21 @@ feq64(void *mem_ctx, builtin_available_predicate avail)
sig->replace_parameters(&sig_parameters);
return sig;
}
+ir_function_signature *
+extractFloat64Sign(void *mem_ctx, builtin_available_predicate avail)
+{
+ ir_function_signature *const sig =
+ new(mem_ctx) ir_function_signature(glsl_type::uint_type, avail);
+ ir_factory body(&sig->body, mem_ctx);
+ sig->is_defined = true;
+
+ exec_list sig_parameters;
+
+ ir_variable *const r0049 = new(mem_ctx) ir_variable(glsl_type::uvec2_type, "a", ir_var_function_in);
+ sig_parameters.push_tail(r0049);
+ ir_expression *const r004A = rshift(swizzle_y(r0049), body.constant(int(31)));
+ body.emit(ret(r004A));
+
+ sig->replace_parameters(&sig_parameters);
+ return sig;
+}
diff --git a/src/compiler/glsl/float64.glsl b/src/compiler/glsl/float64.glsl
index 0cd7991..6d939c2 100644
--- a/src/compiler/glsl/float64.glsl
+++ b/src/compiler/glsl/float64.glsl
@@ -104,3 +104,10 @@ feq64(uvec2 a, uvec2 b)
((a.y == b.y) || ((a.x == 0u) && (((a.y | b.y)<<1) == 0u)));
return mix(result, false, isaNaN || isbNaN);
}
+
+/* Returns the sign bit of the double-precision floating-point value `a'.*/
+uint
+extractFloat64Sign(uvec2 a)
+{
+ return (a.y>>31);
+}
--
2.9.5
More information about the mesa-dev
mailing list