File: length-vector.shader_test

package info (click to toggle)
piglit 0~git20180515-62ef6b0db-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 102,084 kB
  • sloc: ansic: 244,201; xml: 47,485; python: 28,308; lisp: 19,320; cpp: 10,678; sh: 301; makefile: 33; pascal: 5
file content (43 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (4)
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
/* The ARB_shading_language_420pack says:
 *
 *     "The *length* method may be applied to vectors (but not scalars). The
 *      result is the number of components in the vector. For example,
 *
 *           vec3 v;
 *           const int L = v.length();
 *
 *      sets the constant L to 3. The type returned by .length() on a vector is
 *      *int*."
 *
 * Verify that vec.length() returns the number of elements and that the type is
 * int.
 */

[require]
GLSL >= 1.30
GL_ARB_shading_language_420pack

[vertex shader passthrough]

[fragment shader]
#extension GL_ARB_shading_language_420pack: enable

out vec4 frag_color;

void main() {
    vec2 v2;
    vec3 v3;
    vec4 v4;

    frag_color = vec4(0.0, 1.0, 0.0, 1.0);

    if (v2.length() != 2 ||
        v3.length() != 3 ||
        v4.length() != 4) {
        frag_color = vec4(1.0, 0.0, 0.0, 1.0);
    }
}

[test]
draw rect -1 -1 2 2
probe all rgba 0.0 1.0 0.0 1.0