Commit 0060cdc9 authored by Ian Romanick's avatar Ian Romanick
Browse files

Add GLSL tests for constant evaluation of equal and notEqual

Currently all of the tests involving boolean inputs to either equal or
notEqual fail with an assertion failure in Mesa's glsl2 compiler.
parent a039ac66
......@@ -393,6 +393,15 @@ add_shader_generic(shaders, 'glsl-const-builtin-derivatives')
add_shader_generic(shaders, 'glsl-const-builtin-distance')
add_shader_generic(shaders, 'glsl-const-builtin-dot')
add_shader_generic(shaders, 'glsl-const-builtin-equal')
add_shader_generic(shaders, 'glsl-const-builtin-equal-02')
add_shader_generic(shaders, 'glsl-const-builtin-equal-03')
add_shader_generic(shaders, 'glsl-const-builtin-equal-04')
add_shader_generic(shaders, 'glsl-const-builtin-equal-05')
add_shader_generic(shaders, 'glsl-const-builtin-equal-06')
add_shader_generic(shaders, 'glsl-const-builtin-equal-07')
add_shader_generic(shaders, 'glsl-const-builtin-equal-08')
add_shader_generic(shaders, 'glsl-const-builtin-equal-09')
add_shader_generic(shaders, 'glsl-const-builtin-equal-10')
add_shader_generic(shaders, 'glsl-const-builtin-equal-bool')
add_shader_generic(shaders, 'glsl-const-builtin-exp')
add_shader_generic(shaders, 'glsl-const-builtin-exp2')
......@@ -415,6 +424,15 @@ add_shader_generic(shaders, 'glsl-const-builtin-mod')
add_shader_generic(shaders, 'glsl-const-builtin-normalize')
add_shader_generic(shaders, 'glsl-const-builtin-not')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-02')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-03')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-04')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-05')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-06')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-07')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-08')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-09')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-10')
add_shader_generic(shaders, 'glsl-const-builtin-notEqual-bool')
add_shader_generic(shaders, 'glsl-const-builtin-outerProduct')
add_shader_generic(shaders, 'glsl-const-builtin-pow')
......
import re
def emit_test(f, func, input1, input2, expected):
# Determine the expected return type of the equal function by looking at
# the string of the expected return value.
s = expected.split("(")
spaces = re.sub("[^ ]", " ", func+s[0])
test = """
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const %s res = %s(%s,
%s%s);
gl_FragColor = (res == %s)
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
""" % (s[0], func, input1, spaces, input2, expected)
f.write(test)
test_vectors = [
[
"vec2(3.0, 3.14)",
"vec2(-6.0, 7.88)",
"bvec2(false, false)"
],
[
"vec3(13.4, -0.9, 12.55)",
"vec3(13.4, 12.0, -55.3)",
"bvec3(true, false, false)"
],
[
"vec4(-2.0, 0.0, 0.123, -1000.5)",
"vec4(-2.4, 0.0, 0.456, 12.5)",
"bvec4(false, true, false, false)"
],
[
"ivec2(-8, 12)",
"ivec2(-19, 12)",
"bvec2(false, true)"
],
[
"ivec3(0, 8, 89)",
"ivec3(4, -7, 33)",
"bvec3(false, false, false)"
],
[
"ivec4(11, 1000, 1, -18)",
"ivec4(55, 1000, -21, -17)",
"bvec4(false, true, false, false)"
],
[
"bvec2(true, false)",
"bvec2(true, true)",
"bvec2(true, false)"
],
[
"bvec3(false, true, false)",
"bvec3(false, false, true)",
"bvec3(true, false, false)"
],
[
"bvec4(true, false, false, true)",
"bvec4(true, true, false, false)",
"bvec4(true, false, true, false)"
]
]
test_id = 2
for x in test_vectors:
name = "glsl-const-builtin-%s-%02d.shader_test" % ("equal", test_id)
test_id = test_id + 1
f = open(name, "w")
emit_test(f, "equal", x[0], x[1], x[2])
f.close()
test_id = 2
for x in test_vectors:
name = "glsl-const-builtin-%s-%02d.shader_test" % ("notEqual", test_id)
test_id = test_id + 1
# When generating the notEqual tests, each of the values in the expected
# result vector need to be inverted
expected = re.sub("true", "FALSE", x[2])
expected = re.sub("false", "TRUE", expected)
expected = expected.lower()
f = open(name, "w")
emit_test(f, "notEqual", x[0], x[1], expected)
f.close()
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec2 res = equal(vec2(3.0, 3.14),
vec2(-6.0, 7.88));
gl_FragColor = (res == bvec2(false, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec3 res = equal(vec3(13.4, -0.9, 12.55),
vec3(13.4, 12.0, -55.3));
gl_FragColor = (res == bvec3(true, false, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec4 res = equal(vec4(-2.0, 0.0, 0.123, -1000.5),
vec4(-2.4, 0.0, 0.456, 12.5));
gl_FragColor = (res == bvec4(false, true, false, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec2 res = equal(ivec2(-8, 12),
ivec2(-19, 12));
gl_FragColor = (res == bvec2(false, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec3 res = equal(ivec3(0, 8, 89),
ivec3(4, -7, 33));
gl_FragColor = (res == bvec3(false, false, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec4 res = equal(ivec4(11, 1000, 1, -18),
ivec4(55, 1000, -21, -17));
gl_FragColor = (res == bvec4(false, true, false, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec2 res = equal(bvec2(true, false),
bvec2(true, true));
gl_FragColor = (res == bvec2(true, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec3 res = equal(bvec3(false, true, false),
bvec3(false, false, true));
gl_FragColor = (res == bvec3(true, false, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec4 res = equal(bvec4(true, false, false, true),
bvec4(true, true, false, false));
gl_FragColor = (res == bvec4(true, false, true, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec2 res = notEqual(vec2(3.0, 3.14),
vec2(-6.0, 7.88));
gl_FragColor = (res == bvec2(true, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec3 res = notEqual(vec3(13.4, -0.9, 12.55),
vec3(13.4, 12.0, -55.3));
gl_FragColor = (res == bvec3(false, true, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec4 res = notEqual(vec4(-2.0, 0.0, 0.123, -1000.5),
vec4(-2.4, 0.0, 0.456, 12.5));
gl_FragColor = (res == bvec4(true, false, true, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec2 res = notEqual(ivec2(-8, 12),
ivec2(-19, 12));
gl_FragColor = (res == bvec2(true, false))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec3 res = notEqual(ivec3(0, 8, 89),
ivec3(4, -7, 33));
gl_FragColor = (res == bvec3(true, true, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec4 res = notEqual(ivec4(11, 1000, 1, -18),
ivec4(55, 1000, -21, -17));
gl_FragColor = (res == bvec4(true, false, true, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec2 res = notEqual(bvec2(true, false),
bvec2(true, true));
gl_FragColor = (res == bvec2(false, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec3 res = notEqual(bvec3(false, true, false),
bvec3(false, false, true));
gl_FragColor = (res == bvec3(false, true, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
[require]
GL >= 2.0
GLSL >= 1.20
[vertex shader file]
glsl-mvp.vert
[fragment shader]
#version 120
void main()
{
const bvec4 res = notEqual(bvec4(true, false, false, true),
bvec4(true, true, false, false));
gl_FragColor = (res == bvec4(false, true, false, true))
? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
[test]
clear color 0.0 0.0 0.0 0.0
clear
ortho
draw rect 10 10 10 10
probe rgb 15 15 0.0 1.0 0.0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment