1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
# Test that varying structs work properly.
#
# From the GLSL 1.50 specification, section 4.3.4 ("Input Variables"):
#
# Fragment inputs can only be signed and unsigned integers and
# integer vectors, float, floating-point vectors, matrices, or
# arrays or structures of these.
#
# And from section 4.3.6 ("Output Variables"):
#
# Vertex output variables ... can only be float, floating-point
# vectors, matrices, signed or unsigned integers or integer
# vectors, or arrays or structures of any these.
#
# This test verifies basic functionality of varying structs using a
# varying struct containing a variety of types.
[require]
GL >= 3.2
GLSL >= 1.50
[vertex shader]
#version 150
uniform float ref;
in vec4 piglit_vertex;
struct Foo
{
mat4 a;
mat3 b;
mat2 c;
vec4 d;
vec3 e;
vec2 f;
float g;
};
out Foo foo;
void main()
{
gl_Position = piglit_vertex;
foo.a = mat4(ref, ref + 1.0, ref + 2.0, ref + 3.0,
ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0,
ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0,
ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0);
foo.b = mat3(ref + 16.0, ref + 17.0, ref + 18.0,
ref + 19.0, ref + 20.0, ref + 21.0,
ref + 22.0, ref + 23.0, ref + 24.0);
foo.c = mat2(ref + 25.0, ref + 26.0,
ref + 27.0, ref + 28.0);
foo.d = vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0);
foo.e = vec3(ref + 33.0, ref + 34.0, ref + 35.0);
foo.f = vec2(ref + 36.0, ref + 37.0);
foo.g = ref + 38.0;
}
[fragment shader]
#version 150
uniform float ref;
struct Foo
{
mat4 a;
mat3 b;
mat2 c;
vec4 d;
vec3 e;
vec2 f;
float g;
};
in Foo foo;
out vec4 color;
#define CHECK(value, expected) \
if (distance(value, expected) > 0.00001) \
failed = true
void main()
{
bool failed = false;
CHECK(foo.a[0], vec4(ref, ref + 1.0, ref + 2.0, ref + 3.0));
CHECK(foo.a[1], vec4(ref + 4.0, ref + 5.0, ref + 6.0, ref + 7.0));
CHECK(foo.a[2], vec4(ref + 8.0, ref + 9.0, ref + 10.0, ref + 11.0));
CHECK(foo.a[3], vec4(ref + 12.0, ref + 13.0, ref + 14.0, ref + 15.0));
CHECK(foo.b[0], vec3(ref + 16.0, ref + 17.0, ref + 18.0));
CHECK(foo.b[1], vec3(ref + 19.0, ref + 20.0, ref + 21.0));
CHECK(foo.b[2], vec3(ref + 22.0, ref + 23.0, ref + 24.0));
CHECK(foo.c[0], vec2(ref + 25.0, ref + 26.0));
CHECK(foo.c[1], vec2(ref + 27.0, ref + 28.0));
CHECK(foo.d, vec4(ref + 29.0, ref + 30.0, ref + 31.0, ref + 32.0));
CHECK(foo.e, vec3(ref + 33.0, ref + 34.0, ref + 35.0));
CHECK(foo.f, vec2(ref + 36.0, ref + 37.0));
CHECK(foo.g, ref + 38.0);
if (failed)
color = vec4(1.0, 0.0, 0.0, 1.0);
else
color = vec4(0.0, 1.0, 0.0, 1.0);
}
[test]
uniform float ref 137.035999074
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0
|