Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-function-clamp-min-identical-shift-right.amber
1 #!amber
2
3 # Copyright 2022 Google LLC
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 # A test for a coverage-gap found by the GraphicsFuzz project.
19
20 # Short description: A fragment shader that covers specific LLVM code paths
21
22 # The test passes because the shader always writes red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 320 es
28 # #define _int_4 _GLF_uniform_int_values[0]
29 # #define _int_2 _GLF_uniform_int_values[1]
30 # #define _int_5 _GLF_uniform_int_values[2]
31 # #define _int_1 _GLF_uniform_int_values[3]
32 # #define _int_6 _GLF_uniform_int_values[4]
33 # #define _int_0 _GLF_uniform_int_values[5]
34 #
35 # precision highp float;
36 # precision highp int;
37 #
38 # // Contents of _GLF_uniform_int_values: [4, 2, 5, 1, 6, 0]
39 # layout(set = 0, binding = 0) uniform buf0
40 # {
41 #     int _GLF_uniform_int_values[6];
42 # };
43 #
44 # layout(location = 0) out vec4 _GLF_color;
45 #
46 # int func()
47 # {
48 #     int a = _int_1 << _int_6;
49 #     // Returns 2.
50 #     return clamp(a >> _int_5, a >> _int_5, _int_4);
51 # }
52 #
53 # void main()
54 # {
55 #     // Always true.
56 #     if(func() == _int_2)
57 #     {
58 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
59 #     }
60 #     else
61 #     {
62 #         _GLF_color = vec4(_int_0);
63 #     }
64 # }
65 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
66 ; SPIR-V
67 ; Version: 1.0
68 ; Generator: Khronos Glslang Reference Front End; 10
69 ; Bound: 72
70 ; Schema: 0
71                OpCapability Shader
72           %1 = OpExtInstImport "GLSL.std.450"
73                OpMemoryModel Logical GLSL450
74                OpEntryPoint Fragment %4 "main" %52
75                OpExecutionMode %4 OriginUpperLeft
76                OpSource ESSL 320
77                OpName %4 "main"
78                OpName %8 "func("
79                OpName %11 "a"
80                OpName %15 "buf0"
81                OpMemberName %15 0 "_GLF_uniform_int_values"
82                OpName %17 ""
83                OpName %52 "_GLF_color"
84                OpDecorate %14 ArrayStride 16
85                OpMemberDecorate %15 0 Offset 0
86                OpDecorate %15 Block
87                OpDecorate %17 DescriptorSet 0
88                OpDecorate %17 Binding 0
89                OpDecorate %52 Location 0
90           %2 = OpTypeVoid
91           %3 = OpTypeFunction %2
92           %6 = OpTypeInt 32 1
93           %7 = OpTypeFunction %6
94          %10 = OpTypePointer Function %6
95          %12 = OpTypeInt 32 0
96          %13 = OpConstant %12 6
97          %14 = OpTypeArray %6 %13
98          %15 = OpTypeStruct %14
99          %16 = OpTypePointer Uniform %15
100          %17 = OpVariable %16 Uniform
101          %18 = OpConstant %6 0
102          %19 = OpConstant %6 3
103          %20 = OpTypePointer Uniform %6
104          %23 = OpConstant %6 4
105          %28 = OpConstant %6 2
106          %42 = OpConstant %6 1
107          %45 = OpTypeBool
108          %49 = OpTypeFloat 32
109          %50 = OpTypeVector %49 4
110          %51 = OpTypePointer Output %50
111          %52 = OpVariable %51 Output
112          %56 = OpConstant %6 5
113           %4 = OpFunction %2 None %3
114           %5 = OpLabel
115          %41 = OpFunctionCall %6 %8
116          %43 = OpAccessChain %20 %17 %18 %42
117          %44 = OpLoad %6 %43
118          %46 = OpIEqual %45 %41 %44
119                OpSelectionMerge %48 None
120                OpBranchConditional %46 %47 %67
121          %47 = OpLabel
122          %53 = OpAccessChain %20 %17 %18 %19
123          %54 = OpLoad %6 %53
124          %55 = OpConvertSToF %49 %54
125          %57 = OpAccessChain %20 %17 %18 %56
126          %58 = OpLoad %6 %57
127          %59 = OpConvertSToF %49 %58
128          %60 = OpAccessChain %20 %17 %18 %56
129          %61 = OpLoad %6 %60
130          %62 = OpConvertSToF %49 %61
131          %63 = OpAccessChain %20 %17 %18 %19
132          %64 = OpLoad %6 %63
133          %65 = OpConvertSToF %49 %64
134          %66 = OpCompositeConstruct %50 %55 %59 %62 %65
135                OpStore %52 %66
136                OpBranch %48
137          %67 = OpLabel
138          %68 = OpAccessChain %20 %17 %18 %56
139          %69 = OpLoad %6 %68
140          %70 = OpConvertSToF %49 %69
141          %71 = OpCompositeConstruct %50 %70 %70 %70 %70
142                OpStore %52 %71
143                OpBranch %48
144          %48 = OpLabel
145                OpReturn
146                OpFunctionEnd
147           %8 = OpFunction %6 None %7
148           %9 = OpLabel
149          %11 = OpVariable %10 Function
150          %21 = OpAccessChain %20 %17 %18 %19
151          %22 = OpLoad %6 %21
152          %24 = OpAccessChain %20 %17 %18 %23
153          %25 = OpLoad %6 %24
154          %26 = OpShiftLeftLogical %6 %22 %25
155                OpStore %11 %26
156          %27 = OpLoad %6 %11
157          %29 = OpAccessChain %20 %17 %18 %28
158          %30 = OpLoad %6 %29
159          %31 = OpShiftRightArithmetic %6 %27 %30
160          %32 = OpLoad %6 %11
161          %33 = OpAccessChain %20 %17 %18 %28
162          %34 = OpLoad %6 %33
163          %35 = OpShiftRightArithmetic %6 %32 %34
164          %36 = OpAccessChain %20 %17 %18 %18
165          %37 = OpLoad %6 %36
166          %38 = OpExtInst %6 %1 SClamp %31 %35 %37
167                OpReturnValue %38
168                OpFunctionEnd
169 END
170
171 # uniforms for variant
172
173 # _GLF_uniform_int_values
174 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
175  4 2 5 1 6 0
176 END
177
178 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
179
180 PIPELINE graphics variant_pipeline
181   ATTACH variant_vertex_shader
182   ATTACH variant_fragment_shader
183   FRAMEBUFFER_SIZE 32 32
184   BIND BUFFER variant_framebuffer AS color LOCATION 0
185   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
186 END
187 CLEAR_COLOR variant_pipeline 0 0 0 255
188
189 CLEAR variant_pipeline
190 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
191
192 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255