• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2019 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
16SHADER vertex vert_shader PASSTHROUGH
17SHADER fragment frag_shader_red GLSL
18#version 430
19layout(location = 0) out vec4 color_out;
20void main() {
21  color_out = vec4(1.0, 0.0, 0.0, 1.0);
22}
23END
24SHADER fragment frag_shader_tex GLSL
25#version 430
26layout(location = 0) out vec4 color_out;
27uniform layout(set=0, binding=0, rgba8) readonly image2D texture;
28void main() {
29  ivec2 uv = ivec2(gl_FragCoord.xy);
30  color_out = imageLoad(texture, ivec2(gl_FragCoord.xy));
31}
32END
33SHADER compute compute_shader GLSL
34#version 430
35layout(local_size_x=10,local_size_y=10) in;
36uniform layout (set=0, binding=0, rgba8) image2D texture;
37
38void main () {
39  ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
40  vec4 color = imageLoad(texture, uv) + vec4(0, 1.0, 0, 0);
41  imageStore(texture, uv, color);
42}
43END
44
45BUFFER texture FORMAT R8G8B8A8_UNORM
46BUFFER framebuffer FORMAT B8G8R8A8_UNORM
47
48PIPELINE graphics pipeline1
49  ATTACH vert_shader
50  ATTACH frag_shader_red
51  FRAMEBUFFER_SIZE 256 256
52  BIND BUFFER texture AS color LOCATION 0
53END
54
55PIPELINE graphics pipeline2
56  ATTACH vert_shader
57  ATTACH frag_shader_tex
58  BIND BUFFER texture AS storage_image DESCRIPTOR_SET 0 BINDING 0
59  FRAMEBUFFER_SIZE 256 256
60  BIND BUFFER framebuffer AS color LOCATION 0
61END
62
63PIPELINE compute pipeline3
64  ATTACH compute_shader
65  BIND BUFFER texture AS storage_image DESCRIPTOR_SET 0 BINDING 0
66  FRAMEBUFFER_SIZE 256 256
67END
68
69CLEAR_COLOR pipeline1 0 0 255 255
70CLEAR pipeline1
71RUN pipeline1 DRAW_RECT POS 50 50 SIZE 100 100
72RUN pipeline3 5 5 1
73CLEAR_COLOR pipeline2 0 255 0 255
74CLEAR pipeline2
75RUN pipeline2 DRAW_RECT POS 20 20 SIZE  170 170
76
77EXPECT framebuffer IDX 1 1 SIZE 1 1 EQ_RGBA 0 255 0 255
78EXPECT framebuffer IDX 21 21 SIZE 1 1 EQ_RGBA 0 255 255 255
79EXPECT framebuffer IDX 51 51 SIZE 1 1 EQ_RGBA 255 0 0 255
80EXPECT framebuffer IDX 189 189 SIZE 1 1 EQ_RGBA 0 0 255 255
81