1#!amber
2# Copyright 2020 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 shaderStorageImageMultisample
17
18SHADER compute compute_shader GLSL
19#version 430
20
21layout(local_size_x = 16, local_size_y = 16) in;
22uniform layout(set=0, binding=0, rgba8) image2DMS texture;
23uniform layout(set=0, binding=1, rgba8) image2D sample0;
24uniform layout(set=0, binding=2, rgba8) image2D sample1;
25uniform layout(set=0, binding=3, rgba8) image2D sample2;
26uniform layout(set=0, binding=4, rgba8) image2D sample3;
27void main()
28{
29    ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
30    imageStore(texture, uv, 0, vec4(1, 0, 0, 1));
31    imageStore(texture, uv, 1, vec4(0, 1, 0, 1));
32    imageStore(texture, uv, 2, vec4(0, 0, 1, 1));
33    imageStore(texture, uv, 3, vec4(1, 1, 0, 1));
34    imageStore(sample0, uv, imageLoad(texture, uv, 3));
35    imageStore(sample1, uv, imageLoad(texture, uv, 2));
36    imageStore(sample2, uv, imageLoad(texture, uv, 1));
37    imageStore(sample3, uv, imageLoad(texture, uv, 0));
38}
39END
40
41IMAGE texture FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 256 HEIGHT 256 SAMPLES 4
42IMAGE sample0 FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 256 HEIGHT 256
43IMAGE sample1 FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 256 HEIGHT 256
44IMAGE sample2 FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 256 HEIGHT 256
45IMAGE sample3 FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 256 HEIGHT 256
46
47PIPELINE compute pipeline
48  ATTACH compute_shader
49  BIND BUFFER texture AS storage_image DESCRIPTOR_SET 0 BINDING 0
50  BIND BUFFER sample0 AS storage_image DESCRIPTOR_SET 0 BINDING 1
51  BIND BUFFER sample1 AS storage_image DESCRIPTOR_SET 0 BINDING 2
52  BIND BUFFER sample2 AS storage_image DESCRIPTOR_SET 0 BINDING 3
53  BIND BUFFER sample3 AS storage_image DESCRIPTOR_SET 0 BINDING 4
54END
55
56RUN pipeline 16 16 1
57
58EXPECT sample0 IDX 0 0 SIZE 256 256 EQ_RGBA 255 255   0 255
59EXPECT sample1 IDX 0 0 SIZE 256 256 EQ_RGBA   0   0 255 255
60EXPECT sample2 IDX 0 0 SIZE 256 256 EQ_RGBA   0 255   0 255
61EXPECT sample3 IDX 0 0 SIZE 256 256 EQ_RGBA 255   0   0 255
62