aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2020-05-09 21:38:34 -0400
committerMarge Bot <[email protected]>2020-06-02 20:01:18 +0000
commit11929895332213363628d632f7f9f6d79b5124d1 (patch)
tree0e65929703800e555548149de807c0ee70a4fbd2 /src/compiler/glsl
parent6fe20ebaaa933ddd17b655e61ba3fe3d358b8513 (diff)
glsl: lower mediump partial derivatives
Reviewed-by: Alyssa Rosenzweig <[email protected]> Reviewed-by: Rob Clark <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5002>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r--src/compiler/glsl/lower_precision.cpp13
-rw-r--r--src/compiler/glsl/standalone.cpp1
-rw-r--r--src/compiler/glsl/tests/lower_precision_test.py28
3 files changed, 36 insertions, 6 deletions
diff --git a/src/compiler/glsl/lower_precision.cpp b/src/compiler/glsl/lower_precision.cpp
index 44cc7969204..b410e3290a2 100644
--- a/src/compiler/glsl/lower_precision.cpp
+++ b/src/compiler/glsl/lower_precision.cpp
@@ -399,12 +399,13 @@ find_lowerable_rvalues_visitor::visit_enter(ir_expression *ir)
stack.back().state = CANT_LOWER;
/* Don't lower precision for derivative calculations */
- if (ir->operation == ir_unop_dFdx ||
- ir->operation == ir_unop_dFdx_coarse ||
- ir->operation == ir_unop_dFdx_fine ||
- ir->operation == ir_unop_dFdy ||
- ir->operation == ir_unop_dFdy_coarse ||
- ir->operation == ir_unop_dFdy_fine) {
+ if (!options->LowerPrecisionDerivatives &&
+ (ir->operation == ir_unop_dFdx ||
+ ir->operation == ir_unop_dFdx_coarse ||
+ ir->operation == ir_unop_dFdx_fine ||
+ ir->operation == ir_unop_dFdy ||
+ ir->operation == ir_unop_dFdy_coarse ||
+ ir->operation == ir_unop_dFdy_fine)) {
stack.back().state = CANT_LOWER;
}
diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 02f019e0bde..5b34297df59 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -440,6 +440,7 @@ standalone_compile_shader(const struct standalone_options *_options,
&ctx->Const.ShaderCompilerOptions[i];
options->LowerPrecisionFloat16 = true;
options->LowerPrecisionInt16 = true;
+ options->LowerPrecisionDerivatives = true;
}
}
diff --git a/src/compiler/glsl/tests/lower_precision_test.py b/src/compiler/glsl/tests/lower_precision_test.py
index 0934e61e4ab..3626d8d2a4b 100644
--- a/src/compiler/glsl/tests/lower_precision_test.py
+++ b/src/compiler/glsl/tests/lower_precision_test.py
@@ -1035,6 +1035,34 @@ TESTS = [
}
""",
r'\(expression +uint16_t min'),
+ Test("dFdx",
+ """
+ #version 300 es
+ precision mediump float;
+
+ in vec4 var;
+ out vec4 color;
+
+ void main()
+ {
+ color = dFdx(var);
+ }
+ """,
+ r'\(expression +f16vec4 +dFdx +\(expression +f16vec4'),
+ Test("dFdy",
+ """
+ #version 300 es
+ precision mediump float;
+
+ in vec4 var;
+ out vec4 color;
+
+ void main()
+ {
+ color = dFdy(var);
+ }
+ """,
+ r'\(expression +f16vec4 +dFdy +\(expression +f16vec4'),
]