blob: bf0b1ae04636dc368ddd7e906c31a3d5f8876949 [file] [log] [blame]
John Kessenich453bb262015-06-12 05:01:25 +00001#version 310 es
2
John Kessenich105704e2015-06-19 06:28:59 +00003#ifdef GL_EXT_geometry_shader
John Kessenich453bb262015-06-12 05:01:25 +00004#extension GL_EXT_geometry_shader : enable
John Kessenich105704e2015-06-19 06:28:59 +00005#else
6#error no GL_EXT_geometry_shader
7#endif
8
9#ifndef GL_OES_geometry_shader
10#error no GL_OES_geometry_shader
11#endif
John Kessenich453bb262015-06-12 05:01:25 +000012
13precision mediump float;
14
15in fromVertex {
16 in vec3 color;
17} fromV[];
18
John Kessenichf6deb622015-06-14 21:36:44 +000019in vec4 nonBlockUnsized[];
20
John Kessenich453bb262015-06-12 05:01:25 +000021out toFragment {
22 out vec3 color;
23} toF;
24
25out fromVertex { // okay to reuse a block name for another block name
26 vec3 color;
27};
28
John Kessenich105704e2015-06-19 06:28:59 +000029out fooB { // ERROR, cannot reuse block name as block instance
John Kessenich453bb262015-06-12 05:01:25 +000030 vec2 color;
John Kessenich105704e2015-06-19 06:28:59 +000031} fromVertex;
John Kessenich453bb262015-06-12 05:01:25 +000032
33int fromVertex; // ERROR, cannot reuse a block name for something else
34
John Kessenich105704e2015-06-19 06:28:59 +000035out fooC { // ERROR, cannot have same name for block and instance name
John Kessenich453bb262015-06-12 05:01:25 +000036 vec2 color;
John Kessenich105704e2015-06-19 06:28:59 +000037} fooC;
John Kessenich453bb262015-06-12 05:01:25 +000038
39void main()
40{
41 EmitVertex();
42 EndPrimitive();
43 EmitStreamVertex(1); // ERROR
44 EndStreamPrimitive(0); // ERROR
45
46 color = fromV[0].color;
John Kessenichf6deb622015-06-14 21:36:44 +000047 gl_ClipDistance[3] = // ERROR, no ClipDistance
48 gl_in[1].gl_ClipDistance[2]; // ERROR, no ClipDistance
John Kessenich453bb262015-06-12 05:01:25 +000049 gl_Position = gl_in[0].gl_Position;
John Kessenichb61b8212015-06-23 04:14:00 +000050
John Kessenich453bb262015-06-12 05:01:25 +000051 gl_PrimitiveID = gl_PrimitiveIDIn;
52 gl_Layer = 2;
53}
54
John Kessenichf6deb622015-06-14 21:36:44 +000055layout(stream = 4) out vec4 ov4; // ERROR, no streams
John Kessenich453bb262015-06-12 05:01:25 +000056
John Kessenichf6deb622015-06-14 21:36:44 +000057layout(line_strip, points, triangle_strip, points, triangle_strip) out; // just means triangle_strip"
John Kessenich453bb262015-06-12 05:01:25 +000058
John Kessenichf6deb622015-06-14 21:36:44 +000059out ooutb { vec4 a; } ouuaa6;
John Kessenich453bb262015-06-12 05:01:25 +000060
61layout(max_vertices = 200) out;
62layout(max_vertices = 300) out; // ERROR, too big
63void foo(layout(max_vertices = 4) int a) // ERROR
64{
65 ouuaa6.a = vec4(1.0);
66}
67
John Kessenichf6deb622015-06-14 21:36:44 +000068layout(line_strip, points, triangle_strip, points) out; // ERROR, changing output primitive
69layout(line_strip, points) out; // ERROR, changing output primitive
John Kessenich453bb262015-06-12 05:01:25 +000070layout(triangle_strip) in; // ERROR, not an input primitive
71layout(triangle_strip) uniform; // ERROR
72layout(triangle_strip) out vec4 badv4; // ERROR, not on a variable
73layout(triangle_strip) in vec4 bad2v4[]; // ERROR, not on a variable or input
74layout(invocations = 3) out outbn { int a; }; // 2 ERROR, not on a block, not until 4.0
75out outbn2 {
76 layout(invocations = 3) int a; // 2 ERRORs, not on a block member, not until 4.0
77 layout(max_vertices = 3) int b; // ERROR, not on a block member
78 layout(triangle_strip) int c; // ERROR, not on a block member
79} outbi;
80
81layout(lines) out; // ERROR, not on output
82layout(lines_adjacency) in;
83layout(triangles) in; // ERROR, can't change it
84layout(triangles_adjacency) in; // ERROR, can't change it
John Kessenich105704e2015-06-19 06:28:59 +000085layout(invocations = 4) in;
John Kessenich453bb262015-06-12 05:01:25 +000086
John Kessenich453bb262015-06-12 05:01:25 +000087in sameName {
88 int a15;
89} insn[];
90
91out sameName {
92 float f15;
93};
94
95uniform sameName {
96 bool b15;
97};
98
John Kessenichf6deb622015-06-14 21:36:44 +000099const int summ = gl_MaxVertexAttribs +
100 gl_MaxGeometryInputComponents +
101 gl_MaxGeometryOutputComponents +
102 gl_MaxGeometryImageUniforms +
103 gl_MaxGeometryTextureImageUnits +
104 gl_MaxGeometryOutputVertices +
105 gl_MaxGeometryTotalOutputComponents +
106 gl_MaxGeometryUniformComponents +
107 gl_MaxGeometryAtomicCounters +
108 gl_MaxGeometryAtomicCounterBuffers +
John Kessenich453bb262015-06-12 05:01:25 +0000109 gl_MaxVertexTextureImageUnits +
110 gl_MaxCombinedTextureImageUnits +
111 gl_MaxTextureImageUnits +
John Kessenichf6deb622015-06-14 21:36:44 +0000112 gl_MaxDrawBuffers;
John Kessenich453bb262015-06-12 05:01:25 +0000113
114void fooe1()
115{
John Kessenichf6deb622015-06-14 21:36:44 +0000116 gl_ViewportIndex; // ERROR, not in ES
117 gl_MaxViewports; // ERROR, not in ES
John Kessenich105704e2015-06-19 06:28:59 +0000118 insn.length(); // 4: lines_adjacency
119 int inv = gl_InvocationID;
John Kessenich453bb262015-06-12 05:01:25 +0000120}
John Kessenich105704e2015-06-19 06:28:59 +0000121
122in vec4 explArray[4];
123in vec4 explArrayBad[5]; // ERROR, wrong size
124in vec4 nonArrayed; // ERROR, not an array
125flat out vec3 myColor1;
126centroid out vec3 myColor2;
127centroid in vec3 centr[];
128sample out vec4 perSampleColor; // ERROR without sample extensions
129
130layout(max_vertices = 200) out; // matching redecl
131
132layout(location = 7, component = 2) in float comp[]; // ERROR, es has no component
133
134void notHere()
135{
136 gl_MaxGeometryVaryingComponents; // ERROR, not in ES
137 gl_VerticesIn; // ERROR, not in ES
138}
139
John Kessenichb61b8212015-06-23 04:14:00 +0000140void pointSize1()
141{
142 highp float ps = gl_in[3].gl_PointSize; // ERROR, need point_size extension
143 gl_PointSize = ps; // ERROR, need point_size extension
144}
145
146#extension GL_OES_geometry_point_size : enable
147
148void pointSize2()
149{
150 highp float ps = gl_in[3].gl_PointSize;
151 gl_PointSize = ps;
152}