• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2021 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16DEVICE_FEATURE tessellationShader
17
18SHADER vertex vert GLSL
19#version 450
20
21layout (location = 0) in vec3 inPosition;
22
23void main(void)
24{
25    gl_Position = vec4(inPosition, 1.0);
26}
27END
28
29SHADER tessellation_control tesc GLSL
30#version 450
31
32layout (vertices = 4) out;
33
34void main(void)
35{
36    gl_TessLevelOuter[0] = 6.0;
37    gl_TessLevelOuter[1] = 2.0;
38
39    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
40}
41END
42
43SHADER tessellation_evaluation tese GLSL
44#version 450
45
46layout (isolines, equal_spacing, cw) in;
47
48void main(void)
49{
50    vec4 p1 = mix(gl_in[0].gl_Position,
51            gl_in[1].gl_Position,
52            gl_TessCoord.x);
53
54    vec4 p2 = mix(gl_in[2].gl_Position,
55            gl_in[3].gl_Position,
56            gl_TessCoord.x);
57
58    gl_Position = mix(p1, p2, gl_TessCoord.y);
59}
60END
61
62SHADER fragment frag GLSL
63#version 450
64
65layout (location = 0) out vec4 outColor;
66
67void main(void)
68{
69    outColor = vec4(1, 0, 0, 1);
70}
71END
72
73SHADER compute comp_shader GLSL
74#version 450
75layout(local_size_x=10,local_size_y=10) in;
76uniform layout(set=0, binding=0, rgba8) image2D resultImage;
77
78layout(set = 0, binding = 1) buffer block0
79{
80    int counter;
81};
82
83void main()
84{
85    ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
86    vec4 color = imageLoad(resultImage, uv);
87    if(color.r > 0.0) atomicAdd(counter, 1);
88}
89END
90
91BUFFER vertexPosition DATA_TYPE vec3<float> DATA
92-1.0 -1.0  0.0
93 1.0 -1.0  0.0
94-1.0  1.0  0.0
95 1.0  1.0  0.0
96END
97
98BUFFER counter DATA_TYPE int32 DATA 0 END
99
100BUFFER framebuffer FORMAT B8G8R8A8_UNORM
101
102PIPELINE graphics pipeline
103  ATTACH vert
104  ATTACH tesc
105  ATTACH tese
106  ATTACH frag
107
108  PATCH_CONTROL_POINTS 4
109
110  FRAMEBUFFER_SIZE 100 100
111  VERTEX_DATA vertexPosition LOCATION 0
112  BIND BUFFER framebuffer AS color LOCATION 0
113END
114
115CLEAR_COLOR pipeline 0 0 0 255
116CLEAR pipeline
117
118RUN pipeline DRAW_ARRAY AS PATCH_LIST START_IDX 0 COUNT 4
119
120PIPELINE compute verify_pipeline
121  ATTACH comp_shader
122  BIND BUFFER framebuffer AS storage_image DESCRIPTOR_SET 0 BINDING 0
123  BIND BUFFER counter AS storage DESCRIPTOR_SET 0 BINDING 1
124  FRAMEBUFFER_SIZE 100 100
125END
126
127# Count the number of red pixels as the line position might differ between implementations.
128RUN verify_pipeline 10 10 1
129
130EXPECT counter IDX 0 TOLERANCE 50 EQ 500
131