1#!amber
2# Copyright 2021 Google LLC
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#     http://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 compute compute_shader GLSL
17#version 450
18layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
19
20layout(binding = 0) buffer block0
21{
22    int data[20];
23} ssbo;
24
25void main()
26{
27  // Zero constants
28  int ival = ssbo.data[0];
29  float val = float(ival);
30
31  // int div
32  ssbo.data[1] = 7 / ival;
33  // float div
34  ssbo.data[2] = int(7.0 / val);
35  // normalize float
36  ssbo.data[3] = int(normalize(val));
37  // normalize vec2
38  ssbo.data[4] = int(normalize(vec2(val))[ival]);
39  // normalize vec3
40  ssbo.data[5] = int(normalize(vec3(val))[ival]);
41  // normalize vec4
42  ssbo.data[6] = int(normalize(vec4(val))[ival]);
43  // integer mod
44  ssbo.data[7] = 7 % ival;
45  // float mod
46  ssbo.data[8] = int(mod(7.0, val));
47  // vec2 mod
48  ssbo.data[9] = int(mod(vec2(7.0), vec2(val))[ival]);
49  // vec3 mod
50  ssbo.data[10] = int(mod(vec3(7.0), vec3(val))[ival]);
51  // vec4 mod
52  ssbo.data[11] = int(mod(vec4(7.0), vec4(val))[ival]);
53  // float smoothstep
54  ssbo.data[12] = int(smoothstep(val, val, 0.3));
55  // vec2 smoothstep
56  ssbo.data[13] = int(smoothstep(vec2(val), vec2(val), vec2(0.3))[ival]);
57  // vec3 smoothstep
58  ssbo.data[14] = int(smoothstep(vec3(val), vec3(val), vec3(0.3))[ival]);
59  // vec4 smoothstep
60  ssbo.data[15] = int(smoothstep(vec4(val), vec4(val), vec4(0.3))[ival]);
61  // float atan2
62  ssbo.data[16] = int(atan(7.0, val));
63  // vec2 atan2
64  ssbo.data[17] = int(atan(vec2(7.0), vec2(val))[ival]);
65  // vec3 atan2
66  ssbo.data[18] = int(atan(vec3(7.0), vec3(val))[ival]);
67  // vec4 atan2
68  ssbo.data[19] = int(atan(vec4(7.0), vec4(val))[ival]);
69
70  // Known good value
71  ssbo.data[0] = 42;
72}
73END
74
75BUFFER ssbo_buffer DATA_TYPE int32 DATA
760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
77END
78
79PIPELINE compute pipeline
80  ATTACH compute_shader
81
82  BIND BUFFER ssbo_buffer AS storage DESCRIPTOR_SET 0 BINDING 0
83END
84
85RUN pipeline 1 1 1
86
87EXPECT ssbo_buffer IDX 0 EQ 42
88