Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / unreachable-discard-statement.amber
1 #!amber
2
3 # Copyright 2019 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 bug found by GraphicsFuzz.
19
20 # Short description: A fragment shader with unreachable discard statement
21
22 # The test passes because the shader always writes the color red. The discard statement is never reached.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--scalar-replacement=100'
26 # '--private-to-local'
27 # '--eliminate-dead-branches'
28 # '--merge-return'
29 # '--eliminate-dead-branches'
30 # '--private-to-local'
31 # '--copy-propagate-arrays'
32 # '--scalar-replacement=100'
33 # '--combine-access-chains'
34 # '--vector-dce'
35 # '--convert-local-access-chains'
36 # '--if-conversion'
37 # '--eliminate-dead-branches'
38 # '--merge-return'
39 # '--ccp'
40 # '--eliminate-dead-branches'
41 # '--eliminate-dead-branches'
42 # '--merge-blocks'
43 # '--combine-access-chains'
44 # '--eliminate-local-single-block'
45 # '--copy-propagate-arrays'
46 # '--ccp'
47 # '--private-to-local'
48 # '--private-to-local'
49 # spirv-opt commit hash: 06407250a169c6a03b3765e86619075af1a8c187
50
51
52
53 SHADER vertex variant_vertex_shader PASSTHROUGH
54
55 # variant_fragment_shader is derived from the following GLSL:
56 # #version 310 es
57 # precision highp float;
58 #
59 # layout(location = 0) out vec4 _GLF_color;
60 #
61 # vec3 mand()
62 # {
63 #     for (int k = 0; k < 1000; k++)
64 #         return vec3(1.0);
65 #
66 #     discard;    // This statement is never reached
67 #     return vec3(1.0);
68 # }
69 #
70 # void main()
71 # {
72 #     _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
73 #
74 #     for (int i = 0; i < 4; i++)
75 #         mand();
76 #
77 # }
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
79 ; SPIR-V
80 ; Version: 1.0
81 ; Generator: Khronos Glslang Reference Front End; 7
82 ; Bound: 63
83 ; Schema: 0
84                OpCapability Shader
85           %1 = OpExtInstImport "GLSL.std.450"
86                OpMemoryModel Logical GLSL450
87                OpEntryPoint Fragment %4 "main" %35
88                OpExecutionMode %4 OriginUpperLeft
89                OpSource ESSL 310
90                OpName %4 "main"
91                OpName %9 "mand("
92                OpName %13 "k"
93                OpName %35 "_GLF_color"
94                OpName %38 "i"
95                OpDecorate %13 RelaxedPrecision
96                OpDecorate %20 RelaxedPrecision
97                OpDecorate %35 Location 0
98                OpDecorate %38 RelaxedPrecision
99                OpDecorate %44 RelaxedPrecision
100                OpDecorate %48 RelaxedPrecision
101                OpDecorate %49 RelaxedPrecision
102           %2 = OpTypeVoid
103           %3 = OpTypeFunction %2
104           %6 = OpTypeFloat 32
105           %7 = OpTypeVector %6 3
106           %8 = OpTypeFunction %7
107          %11 = OpTypeInt 32 1
108          %12 = OpTypePointer Function %11
109          %14 = OpConstant %11 0
110          %21 = OpConstant %11 1000
111          %22 = OpTypeBool
112          %24 = OpConstant %6 1
113          %25 = OpConstantComposite %7 %24 %24 %24
114          %28 = OpConstant %11 1
115          %33 = OpTypeVector %6 4
116          %34 = OpTypePointer Output %33
117          %35 = OpVariable %34 Output
118          %36 = OpConstant %6 0
119          %37 = OpConstantComposite %33 %24 %36 %36 %24
120          %45 = OpConstant %11 4
121          %51 = OpTypePointer Function %7
122          %57 = OpConstantFalse %22
123          %58 = OpTypePointer Function %22
124          %60 = OpConstantTrue %22
125           %4 = OpFunction %2 None %3
126           %5 = OpLabel
127          %38 = OpVariable %12 Function
128                OpStore %35 %37
129                OpStore %38 %14
130                OpBranch %39
131          %39 = OpLabel
132          %44 = OpLoad %11 %38
133          %46 = OpSLessThan %22 %44 %45
134                OpLoopMerge %41 %40 None
135                OpBranchConditional %46 %40 %41
136          %40 = OpLabel
137          %47 = OpFunctionCall %7 %9
138          %48 = OpLoad %11 %38
139          %49 = OpIAdd %11 %48 %28
140                OpStore %38 %49
141                OpBranch %39
142          %41 = OpLabel
143                OpReturn
144                OpFunctionEnd
145           %9 = OpFunction %7 None %8
146          %10 = OpLabel
147          %59 = OpVariable %58 Function %57
148          %52 = OpVariable %51 Function
149          %13 = OpVariable %12 Function
150                OpBranch %54
151          %54 = OpLabel
152                OpStore %13 %14
153                OpLoopMerge %50 %56 None
154                OpBranch %15
155          %15 = OpLabel
156          %20 = OpLoad %11 %13
157          %23 = OpSLessThan %22 %20 %21
158                OpLoopMerge %17 %18 None
159                OpBranchConditional %23 %16 %17
160          %16 = OpLabel
161                OpStore %59 %60
162                OpStore %52 %25
163                OpBranch %17
164          %18 = OpLabel
165                OpBranch %15
166          %17 = OpLabel
167          %62 = OpLoad %22 %59
168                OpSelectionMerge %61 None
169                OpBranchConditional %62 %50 %61
170          %61 = OpLabel
171                OpKill
172          %56 = OpLabel
173                OpBranch %54
174          %50 = OpLabel
175          %53 = OpLoad %7 %52
176                OpReturnValue %53
177                OpFunctionEnd
178 END
179
180 # uniforms for variant
181
182
183 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
184
185 PIPELINE graphics variant_pipeline
186   ATTACH variant_vertex_shader
187   ATTACH variant_fragment_shader
188   FRAMEBUFFER_SIZE 256 256
189   BIND BUFFER variant_framebuffer AS color LOCATION 0
190 END
191 CLEAR_COLOR variant_pipeline 0 0 0 255
192
193 CLEAR variant_pipeline
194 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
195
196 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255