glsl: don't lower precision of textureSize
authorMarek Olšák <marek.olsak@amd.com>
Fri, 26 Jun 2020 11:19:46 +0000 (07:19 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 8 Jul 2020 02:02:06 +0000 (22:02 -0400)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5746>

src/compiler/glsl/lower_precision.cpp
src/compiler/glsl/tests/lower_precision_test.py

index b2d8330a44dd0bf0481b58a1425ca11884d251af..2529a35b4ddb5d27b46a4c98cd60e5534b7f214e 100644 (file)
@@ -457,6 +457,10 @@ is_lowerable_builtin(ir_call *ir,
        * uses lower precision. The function parameters don't matter.
        */
       if (var && var->type->without_array()->is_sampler()) {
+         /* textureSize always returns highp. */
+         if (!strcmp(ir->callee_name(), "textureSize"))
+            return false;
+
          return var->data.precision == GLSL_PRECISION_MEDIUM ||
                 var->data.precision == GLSL_PRECISION_LOW;
       }
index 65f3e25b0d743f4f4c8aae997a06bd95d5f83e7a..9651a066ed6d87567744069a3c32d3dae203e2fd 100644 (file)
@@ -1161,6 +1161,21 @@ TESTS = [
          }
          """,
          r'\(expression +f16vec4 +dFdy +\(expression +f16vec4'),
+    Test("textureSize",
+         """
+         #version 310 es
+         precision mediump float;
+         precision mediump int;
+
+         uniform mediump sampler2D tex;
+         out ivec2 color;
+
+         void main()
+         {
+                 color = textureSize(tex, 0) * ivec2(2);
+         }
+         """,
+         r'expression ivec2 \* \(txs ivec2 \(var_ref tex'),
 ]