Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-loop-break-floor-nan-never-executed.amber
1 #!amber
2
3 # Copyright 2021 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 NIR 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 # precision highp float;
29 # precision highp int;
30 #
31 # layout(set = 0, binding = 0) uniform buf0
32 # {
33 #     int one;
34 # };
35 #
36 # layout(location = 0) out highp vec4 _GLF_color;
37 #
38 # void main()
39 # {
40 #
41 #     int a = 0;
42 #
43 #     for (int i = 0; i < 5; i++)
44 #     {
45 #         // Always false.
46 #         if (one == 0)
47 #         {
48 #             // intBitsToFloat produces NaN. Floor of NaN is undefined, but this
49 #             // code is never executed.
50 #             if (floor(intBitsToFloat(0xffc00000)) > 0.0)
51 #             {
52 #                 a = -1;
53 #                 break;
54 #             }
55 #         }
56 #
57 #         a++;
58 #     }
59 #
60 #     // Always true.
61 #     if (a == 5)
62 #         _GLF_color = vec4(1, 0, 0, 1);
63 #     else
64 #         _GLF_color = vec4(0);
65 #
66 # }
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
68 ; SPIR-V
69 ; Version: 1.0
70 ; Generator: Khronos Glslang Reference Front End; 10
71 ; Bound: 55
72 ; Schema: 0
73                OpCapability Shader
74           %1 = OpExtInstImport "GLSL.std.450"
75                OpMemoryModel Logical GLSL450
76                OpEntryPoint Fragment %4 "main" %50
77                OpExecutionMode %4 OriginUpperLeft
78                OpSource ESSL 320
79                OpName %4 "main"
80                OpName %8 "a"
81                OpName %10 "i"
82                OpName %20 "buf0"
83                OpMemberName %20 0 "one"
84                OpName %22 ""
85                OpName %50 "_GLF_color"
86                OpMemberDecorate %20 0 Offset 0
87                OpDecorate %20 Block
88                OpDecorate %22 DescriptorSet 0
89                OpDecorate %22 Binding 0
90                OpDecorate %50 Location 0
91           %2 = OpTypeVoid
92           %3 = OpTypeFunction %2
93           %6 = OpTypeInt 32 1
94           %7 = OpTypePointer Function %6
95           %9 = OpConstant %6 0
96          %17 = OpConstant %6 5
97          %18 = OpTypeBool
98          %20 = OpTypeStruct %6
99          %21 = OpTypePointer Uniform %20
100          %22 = OpVariable %21 Uniform
101          %23 = OpTypePointer Uniform %6
102          %29 = OpConstant %6 -4194304
103          %30 = OpTypeFloat 32
104          %33 = OpConstant %30 0
105          %37 = OpConstant %6 -1
106          %40 = OpConstant %6 1
107          %48 = OpTypeVector %30 4
108          %49 = OpTypePointer Output %48
109          %50 = OpVariable %49 Output
110          %51 = OpConstant %30 1
111          %52 = OpConstantComposite %48 %51 %33 %33 %51
112          %54 = OpConstantComposite %48 %33 %33 %33 %33
113           %4 = OpFunction %2 None %3
114           %5 = OpLabel
115           %8 = OpVariable %7 Function
116          %10 = OpVariable %7 Function
117                OpStore %8 %9
118                OpStore %10 %9
119                OpBranch %11
120          %11 = OpLabel
121                OpLoopMerge %13 %14 None
122                OpBranch %15
123          %15 = OpLabel
124          %16 = OpLoad %6 %10
125          %19 = OpSLessThan %18 %16 %17
126                OpBranchConditional %19 %12 %13
127          %12 = OpLabel
128          %24 = OpAccessChain %23 %22 %9
129          %25 = OpLoad %6 %24
130          %26 = OpIEqual %18 %25 %9
131                OpSelectionMerge %28 None
132                OpBranchConditional %26 %27 %28
133          %27 = OpLabel
134          %31 = OpBitcast %30 %29
135          %32 = OpExtInst %30 %1 Floor %31
136          %34 = OpFOrdGreaterThan %18 %32 %33
137                OpSelectionMerge %36 None
138                OpBranchConditional %34 %35 %36
139          %35 = OpLabel
140                OpStore %8 %37
141                OpBranch %13
142          %36 = OpLabel
143                OpBranch %28
144          %28 = OpLabel
145          %39 = OpLoad %6 %8
146          %41 = OpIAdd %6 %39 %40
147                OpStore %8 %41
148                OpBranch %14
149          %14 = OpLabel
150          %42 = OpLoad %6 %10
151          %43 = OpIAdd %6 %42 %40
152                OpStore %10 %43
153                OpBranch %11
154          %13 = OpLabel
155          %44 = OpLoad %6 %8
156          %45 = OpIEqual %18 %44 %17
157                OpSelectionMerge %47 None
158                OpBranchConditional %45 %46 %53
159          %46 = OpLabel
160                OpStore %50 %52
161                OpBranch %47
162          %53 = OpLabel
163                OpStore %50 %54
164                OpBranch %47
165          %47 = OpLabel
166                OpReturn
167                OpFunctionEnd
168 END
169
170 # uniforms for variant
171
172 # one
173 BUFFER variant_one DATA_TYPE int32 STD140 DATA
174  1
175 END
176
177 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
178
179 PIPELINE graphics variant_pipeline
180   ATTACH variant_vertex_shader
181   ATTACH variant_fragment_shader
182   FRAMEBUFFER_SIZE 256 256
183   BIND BUFFER variant_framebuffer AS color LOCATION 0
184   BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
185 END
186 CLEAR_COLOR variant_pipeline 0 0 0 255
187
188 CLEAR variant_pipeline
189 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
190
191 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255