aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2020-07-01 13:11:33 -0400
committerMarek Olšák <[email protected]>2020-07-07 22:02:06 -0400
commit8fcf8e7fd401346ff32f0179ab96ee6b7739e0bb (patch)
tree8f919e9ca51c93f5e7a7cf49efb87557124acbb3 /src
parent3781697c23f5e75ab7a18cdec7140c779bb56ce7 (diff)
glsl: lower builtins to mediump that ignore precision of certain parameters
Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/lower_precision.cpp18
-rw-r--r--src/compiler/glsl/tests/lower_precision_test.py79
2 files changed, 97 insertions, 0 deletions
diff --git a/src/compiler/glsl/lower_precision.cpp b/src/compiler/glsl/lower_precision.cpp
index e9975322e84..f1ac00b2aaf 100644
--- a/src/compiler/glsl/lower_precision.cpp
+++ b/src/compiler/glsl/lower_precision.cpp
@@ -499,10 +499,28 @@ is_lowerable_builtin(ir_call *ir,
assert(ir->callee->return_precision == GLSL_PRECISION_NONE);
+ /* Number of parameters to check if they are lowerable. */
+ unsigned check_parameters = ir->actual_parameters.length();
+
+ /* Interpolation functions only consider the precision of the interpolant. */
+ /* Bitfield functions ignore the precision of "offset" and "bits". */
+ if (!strcmp(ir->callee_name(), "interpolateAtOffset") ||
+ !strcmp(ir->callee_name(), "interpolateAtSample") ||
+ !strcmp(ir->callee_name(), "bitfieldExtract")) {
+ check_parameters = 1;
+ } else if (!strcmp(ir->callee_name(), "bitfieldInsert")) {
+ check_parameters = 2;
+ }
+
foreach_in_list(ir_rvalue, param, &ir->actual_parameters) {
+ if (!check_parameters)
+ break;
+
if (!param->as_constant() &&
_mesa_set_search(lowerable_rvalues, param) == NULL)
return false;
+
+ --check_parameters;
}
return true;
diff --git a/src/compiler/glsl/tests/lower_precision_test.py b/src/compiler/glsl/tests/lower_precision_test.py
index 3fa74050ed8..2fc8f1922e7 100644
--- a/src/compiler/glsl/tests/lower_precision_test.py
+++ b/src/compiler/glsl/tests/lower_precision_test.py
@@ -1459,6 +1459,85 @@ TESTS = [
}
""",
r'expression uint packSnorm4x8 \(expression vec4'),
+ Test("interpolateAtCentroid",
+ """
+ #version 320 es
+ precision mediump float;
+ precision mediump int;
+
+ in float val;
+ out float color;
+
+ void main()
+ {
+ color = interpolateAtCentroid(val) + 1.0;
+ }
+ """,
+ r'expression float16_t interpolate_at_centroid \(expression float16_t'),
+ Test("interpolateAtOffset",
+ """
+ #version 320 es
+ precision mediump float;
+ precision mediump int;
+
+ uniform highp vec2 offset;
+ in float val;
+ out float color;
+
+ void main()
+ {
+ color = interpolateAtOffset(val, offset) + 1.0;
+ }
+ """,
+ r'expression float16_t interpolate_at_offset \(expression float16_t'),
+ Test("interpolateAtSample",
+ """
+ #version 320 es
+ precision mediump float;
+ precision mediump int;
+
+ uniform highp int sample_index;
+ in float val;
+ out float color;
+
+ void main()
+ {
+ color = interpolateAtSample(val, sample_index) + 1.0;
+ }
+ """,
+ r'expression float16_t interpolate_at_sample \(expression float16_t'),
+ Test("bitfieldExtract",
+ """
+ #version 310 es
+ precision mediump float;
+ precision mediump int;
+
+ uniform highp int offset, bits;
+ uniform int val;
+ out int color;
+
+ void main()
+ {
+ color = bitfieldExtract(val, offset, bits) + 1;
+ }
+ """,
+ r'expression int16_t bitfield_extract \(expression int16_t'),
+ Test("bitfieldInsert",
+ """
+ #version 310 es
+ precision mediump float;
+ precision mediump int;
+
+ uniform highp int offset, bits;
+ uniform int val, val2;
+ out int color;
+
+ void main()
+ {
+ color = bitfieldInsert(val, val2, offset, bits) + 1;
+ }
+ """,
+ r'expression int16_t bitfield_insert \(expression int16_t'),
]