summaryrefslogtreecommitdiff
path: root/tests/spec/arb_tessellation_shader/compiler/barrier-redeclared.tesc
blob: e1ea1095b974912787b3256d547ba5a467cf1d42 (plain)
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
// [config]
// expect_result: pass
// glsl_version: 1.50
// require_extensions: GL_ARB_tessellation_shader
// check_link: true
// [end config]

/**
 * ARB_tessellation_shader imposes tight restrictions on where calls to the
 * built-in function barrier() may appear.
 *
 * If the app provides its own function named 'barrier', then the usual suppression
 * of the builtin function should apply, and the app-provided function should be
 * freely callable in any context.
 */

#version 150
#extension GL_ARB_tessellation_shader: require
layout(vertices = 3) out;

void barrier() {}	/* suppresses the builtin */

void calls_barrier() {
    barrier();		/* in non-main OK */
}

void main() {
    gl_out[gl_InvocationID].gl_Position = vec4(0.0);

    for (int i = 0; i < 3; i++)
        barrier();	/* in loops OK */

    calls_barrier();

    gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);
    gl_TessLevelInner = float[2](1.0, 1.0);

    if (gl_in[0].gl_Position.x < 0) {
        barrier();	/* in control flow OK */
        return;
    }

    barrier();          /* after return OK */
}