summaryrefslogtreecommitdiff
path: root/lib/mesa/src/compiler/glsl/tests
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2023-11-02 04:53:47 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2023-11-02 04:53:47 +0000
commitb44518130b33cadb5c1d619e9e936ae0e0dbf7cb (patch)
tree6069eb03c39fbc79808a7d94f857118cce75cbe3 /lib/mesa/src/compiler/glsl/tests
parent32aeb3c41fedbbd7b11aacfec48e8f699d16bff0 (diff)
Merge Mesa 23.1.9
Diffstat (limited to 'lib/mesa/src/compiler/glsl/tests')
-rw-r--r--lib/mesa/src/compiler/glsl/tests/lower_precision_test.py392
1 files changed, 74 insertions, 318 deletions
diff --git a/lib/mesa/src/compiler/glsl/tests/lower_precision_test.py b/lib/mesa/src/compiler/glsl/tests/lower_precision_test.py
index 999c6267a..7e4f49214 100644
--- a/lib/mesa/src/compiler/glsl/tests/lower_precision_test.py
+++ b/lib/mesa/src/compiler/glsl/tests/lower_precision_test.py
@@ -28,149 +28,9 @@ from collections import namedtuple
Test = namedtuple("Test", "name source match_re")
+# NOTE: This test is deprecated, please add any new tests to test_gl_lower_mediump.cpp.
TESTS = [
- Test("f32 simple division",
- """
- uniform mediump float a, b;
-
- void main()
- {
- gl_FragColor.rgba = vec4(a / b);
- }
- """,
- r'\(expression +float16_t +/'),
- Test("i32 simple division",
- """
- #version 300 es
- precision mediump float;
- precision mediump int;
- uniform mediump int a, b;
-
- out vec4 color;
-
- void main()
- {
- color = vec4(a / b);
- }
- """,
- r'\(expression +int16_t +/'),
- Test("u32 simple division",
- """
- #version 300 es
- precision mediump float;
- precision mediump int;
- uniform mediump uint a, b;
-
- out vec4 color;
-
- void main()
- {
- color = vec4(a / b);
- }
- """,
- r'\(expression +uint16_t +/'),
- Test("dot",
- """
- uniform mediump vec2 a, b;
-
- void main()
- {
- gl_FragColor.rgba = vec4(dot(a, b));
- }
- """,
- r'\(expression +float16_t +dot\b'),
- Test("f32 array with const index",
- """
- precision mediump float;
-
- uniform float in_simple[2];
-
- void main()
- {
- gl_FragColor = vec4(in_simple[0] / in_simple[1]);
- }
- """,
- r'\(expression +float16_t +/'),
- Test("i32 array with const index",
- """
- #version 300 es
- precision mediump float;
- precision mediump int;
-
- uniform int in_simple[2];
-
- out vec4 color;
-
- void main()
- {
- color = vec4(in_simple[0] / in_simple[1]);
- }
- """,
- r'\(expression +int16_t +/'),
- Test("u32 array with const index",
- """
- #version 300 es
- precision mediump float;
- precision mediump int;
-
- uniform uint in_simple[2];
-
- out vec4 color;
-
- void main()
- {
- color = vec4(in_simple[0] / in_simple[1]);
- }
- """,
- r'\(expression +uint16_t +/'),
- Test("f32 array with uniform index",
- """
- precision mediump float;
-
- uniform float in_simple[2];
- uniform int i0, i1;
-
- void main()
- {
- gl_FragColor = vec4(in_simple[i0] / in_simple[i1]);
- }
- """,
- r'\(expression +float16_t +/'),
- Test("i32 array with uniform index",
- """
- #version 300 es
- precision mediump float;
- precision mediump int;
-
- uniform int in_simple[2];
- uniform int i0, i1;
-
- out vec4 color;
-
- void main()
- {
- color = vec4(in_simple[i0] / in_simple[i1]);
- }
- """,
- r'\(expression +int16_t +/'),
- Test("u32 array with uniform index",
- """
- #version 300 es
- precision mediump float;
- precision mediump int;
-
- uniform uint in_simple[2];
- uniform int i0, i1;
-
- out vec4 color;
-
- void main()
- {
- color = vec4(in_simple[i0] / in_simple[i1]);
- }
- """,
- r'\(expression +uint16_t +/'),
Test("f32 array-of-array with const index",
"""
#version 310 es
@@ -268,34 +128,6 @@ TESTS = [
}
""",
r'\(expression +uint16_t +/'),
- Test("f32 array index",
- """
- uniform mediump float a, b;
- uniform mediump float values[2];
-
- void main()
- {
- gl_FragColor.rgba = vec4(values[int(a / b)]);
- }
- """,
- r'\(expression +float16_t +/'),
- Test("i32 array index",
- """
- #version 310 es
- precision mediump float;
- precision mediump int;
-
- uniform mediump int a, b;
- uniform mediump int values[2];
-
- out highp int color;
-
- void main()
- {
- color = values[a / b];
- }
- """,
- r'\(expression +int16_t +/'),
Test("f32 function",
"""
precision mediump float;
@@ -500,126 +332,7 @@ TESTS = [
}
""",
r'\(expression +uint +/'),
- Test("f32 function inout different precision highp",
- """
- uniform mediump float a, b;
-
- void
- do_div(inout highp float x, highp float y)
- {
- x = x / y;
- }
-
- void main()
- {
- mediump float temp = a;
- do_div(temp, b);
- gl_FragColor = vec4(temp);
- }
- """,
- r'\(expression +float +/'),
- Test("i32 function inout different precision highp",
- """
- #version 310 es
- uniform mediump int a, b;
-
- void
- do_div(inout highp int x, highp int y)
- {
- x = x / y;
- }
-
- out mediump int color;
-
- void main()
- {
- mediump int temp = a;
- do_div(temp, b);
- color = temp;
- }
- """,
- r'\(expression +int +/'),
- Test("u32 function inout different precision highp",
- """
- #version 310 es
- uniform mediump uint a, b;
-
- void
- do_div(inout highp uint x, highp uint y)
- {
- x = x / y;
- }
-
- out mediump uint color;
-
- void main()
- {
- mediump uint temp = a;
- do_div(temp, b);
- color = temp;
- }
- """,
- r'\(expression +uint +/'),
- Test("f32 function inout different precision mediump",
- """
- uniform highp float a, b;
- void
- do_div(inout mediump float x, mediump float y)
- {
- x = x / y;
- }
-
- void main()
- {
- highp float temp = a;
- do_div(temp, b);
- gl_FragColor = vec4(temp);
- }
- """,
- r'\(expression +float16_t +/'),
- Test("i32 function inout different precision mediump",
- """
- #version 310 es
- uniform highp int a, b;
-
- out highp int color;
-
- void
- do_div(inout mediump int x, mediump int y)
- {
- x = x / y;
- }
-
- void main()
- {
- highp int temp = a;
- do_div(temp, b);
- color = temp;
- }
- """,
- r'\(expression +int16_t +/'),
- Test("u32 function inout different precision mediump",
- """
- #version 310 es
- uniform highp uint a, b;
-
- out highp uint color;
-
- void
- do_div(inout mediump uint x, mediump uint y)
- {
- x = x / y;
- }
-
- void main()
- {
- highp uint temp = a;
- do_div(temp, b);
- color = temp;
- }
- """,
- r'\(expression +uint16_t +/'),
Test("f32 if",
"""
precision mediump float;
@@ -1268,7 +981,7 @@ TESTS = [
color2 = y + 1;
}
""",
- r'assign \(x\) \(var_ref x@2\) \(expression float f162f'),
+ r'expression int16_t i2imp \(expression int frexp_exp \(expression float f162f'),
Test("ldexp",
"""
#version 310 es
@@ -1301,7 +1014,7 @@ TESTS = [
color *= carry;
}
""",
- r'expression uint \+ \(var_ref x\) \(var_ref y'),
+ r'expression uint \+ \(expression uint u2u \(expression uint16_t \* \(expression uint16_t u2ump \(var_ref x\) \) \(constant uint16_t \(2\)\) \) \) \(expression uint u2u \(expression uint16_t \* \(expression uint16_t u2ump \(var_ref y'),
Test("usubBorrow",
"""
#version 310 es
@@ -1318,7 +1031,7 @@ TESTS = [
color *= borrow;
}
""",
- r'expression uint \- \(var_ref x\) \(var_ref y'),
+ r'expression uint \- \(expression uint u2u \(expression uint16_t \* \(expression uint16_t u2ump \(var_ref x\) \) \(constant uint16_t \(2\)\) \) \) \(expression uint u2u \(expression uint16_t \* \(expression uint16_t u2ump \(var_ref y'),
Test("imulExtended",
"""
#version 310 es
@@ -1640,7 +1353,7 @@ TESTS = [
color = (var.x > var.y) ? var : vec4(10.0);
}
""",
- r'\(constant +f16vec4 \(10'),
+ r'\(expression f16vec4 f2fmp \(constant vec4 \(10'),
Test("i32 csel",
"""
#version 310 es
@@ -1654,7 +1367,7 @@ TESTS = [
color = (var.x > var.y) ? var : ivec4(10);
}
""",
- r'\(constant +i16vec4 \(10'),
+ r'\(expression i16vec4 i2imp \(constant ivec4 \(10'),
Test("u32 csel",
"""
#version 310 es
@@ -1668,7 +1381,7 @@ TESTS = [
color = (var.x > var.y) ? var : uvec4(10);
}
""",
- r'\(constant +u16vec4 \(10'),
+ r'\(expression u16vec4 u2ump \(constant uvec4 \(10'),
Test("f32 loop counter",
"""
#version 300 es
@@ -1735,7 +1448,7 @@ TESTS = [
color = a[0] + a[1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array",
"""
#version 310 es
@@ -1752,7 +1465,7 @@ TESTS = [
color = a[0] + a[1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array",
"""
#version 310 es
@@ -1769,7 +1482,7 @@ TESTS = [
color = a[0] + a[1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp array of array",
"""
#version 310 es
@@ -1786,7 +1499,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array of array",
"""
#version 310 es
@@ -1803,7 +1516,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array of array",
"""
#version 310 es
@@ -1820,7 +1533,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp array of array assigned from highp",
"""
#version 310 es
@@ -1839,7 +1552,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array of array assigned from highp",
"""
#version 310 es
@@ -1858,7 +1571,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array of array assigned from highp",
"""
#version 310 es
@@ -1877,7 +1590,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp array of array assigned to highp",
"""
#version 310 es
@@ -1897,7 +1610,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array of array assigned to highp",
"""
#version 310 es
@@ -1917,7 +1630,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array of array assigned to highp",
"""
#version 310 es
@@ -1937,7 +1650,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp array of array returned by function",
"""
#version 310 es
@@ -1959,7 +1672,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array of array returned by function",
"""
#version 310 es
@@ -1981,7 +1694,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array of array returned by function",
"""
#version 310 es
@@ -2003,7 +1716,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp array of array as function out",
"""
#version 310 es
@@ -2026,7 +1739,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array of array as function out",
"""
#version 310 es
@@ -2049,7 +1762,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array of array as function out",
"""
#version 310 es
@@ -2072,7 +1785,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp array of array as function in",
"""
#version 310 es
@@ -2096,7 +1809,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array of array as function in",
"""
#version 310 es
@@ -2120,7 +1833,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array of array as function in",
"""
#version 310 es
@@ -2144,7 +1857,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp array of array as function inout",
"""
#version 310 es
@@ -2168,7 +1881,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant float16_t \(3'),
+ r'\(expression float16_t f2fmp \(constant float \(3'),
Test("i32 temp array of array as function inout",
"""
#version 310 es
@@ -2192,7 +1905,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant int16_t \(3'),
+ r'\(expression int16_t i2imp \(constant int \(3'),
Test("u32 temp array of array as function inout",
"""
#version 310 es
@@ -2216,7 +1929,7 @@ TESTS = [
color = a[0][0] + a[1][1];
}
""",
- r'\(constant uint16_t \(3'),
+ r'\(expression uint16_t u2ump \(constant uint \(3'),
Test("f32 temp struct (not lowered in the presence of control flow - TODO)",
"""
#version 300 es
@@ -2274,6 +1987,49 @@ TESTS = [
}
""",
r'\(constant uint \(3'), # should be uint16_t
+
+ Test("vec4 constructor from float",
+ """
+ uniform highp float a;
+ uniform mediump float b;
+
+ void main()
+ {
+ gl_FragColor = vec4(a) * b;
+ }
+ """,
+ r'\(expression vec4 \* \(swiz xxxx \(var_ref a\) \)\(expression float f162f \(var_ref b\) \) \)'),
+
+ Test("respect copies",
+ """
+ uniform mediump float a, b;
+
+ void main()
+ {
+ highp float x = a;
+ gl_FragColor.x = x * b;
+ }
+ """,
+ r'expression float \* \(expression float f162f \(var_ref a\) \) \(expression float f162f \(var_ref b\) \) '), # should be uint16_t
+
+ Test("conversion constructor precision",
+ """
+ #version 300 es
+ uniform mediump uint a;
+ out highp float result;
+
+ void main()
+ {
+ /* Constructors don't have a precision qualifier themselves, but
+ * constructors are an operation, and so they do the usual "get
+ * precision from my operands, or default to the precision of the
+ * lvalue" rule. So, the u2f is done at mediump due to a's precision.
+ */
+ result = float(a);
+ }
+ """,
+ r'expression float16_t u2f \(expression uint16_t u2ump \(var_ref a\) \)'), # should be uint16_t
+
]