3 # Copyright 2019 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific propagate array copy path.
22 # The test passes because shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-branches'
27 # '--reduce-load-size'
29 # '--private-to-local'
31 # '--eliminate-dead-branches'
32 # '--eliminate-local-multi-store'
33 # '--scalar-replacement=100'
35 # '--inline-entry-points-exhaustive'
36 # '--eliminate-local-single-store'
37 # '--convert-local-access-chains'
38 # '--eliminate-dead-branches'
40 # '--reduce-load-size'
41 # '--eliminate-dead-branches'
43 # '--redundancy-elimination'
44 # '--eliminate-dead-branches'
45 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
49 SHADER vertex variant_vertex_shader PASSTHROUGH
51 # variant_fragment_shader is derived from the following GLSL:
53 # precision highp float;
55 # layout(location = 0) out vec4 _GLF_color;
57 # layout(set = 0, binding = 0) uniform buf0
67 # // Function always returns 1
72 # if(a.values[zero] == 0)
83 # // If condition is always true
85 # _GLF_color = vec4(1, 0, 0, 1);
87 # _GLF_color = vec4(0);
89 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
92 ; Generator: Khronos Glslang Reference Front End; 8
96 %1 = OpExtInstImport "GLSL.std.450"
97 OpMemoryModel Logical GLSL450
98 OpEntryPoint Fragment %4 "main" %54
99 OpExecutionMode %4 OriginUpperLeft
103 OpMemberName %10 0 "values"
104 OpName %14 "func(struct-Array-i1[2]1;"
107 OpMemberName %24 0 "zero"
110 OpName %54 "_GLF_color"
111 OpMemberDecorate %10 0 RelaxedPrecision
112 OpDecorate %14 RelaxedPrecision
113 OpMemberDecorate %24 0 RelaxedPrecision
114 OpMemberDecorate %24 0 Offset 0
116 OpDecorate %26 DescriptorSet 0
117 OpDecorate %26 Binding 0
118 OpDecorate %29 RelaxedPrecision
119 OpDecorate %32 RelaxedPrecision
120 OpDecorate %43 RelaxedPrecision
121 OpDecorate %54 Location 0
122 OpDecorate %61 RelaxedPrecision
123 OpDecorate %75 RelaxedPrecision
124 OpDecorate %74 RelaxedPrecision
125 OpDecorate %81 RelaxedPrecision
126 OpDecorate %86 RelaxedPrecision
127 OpDecorate %87 RelaxedPrecision
128 OpDecorate %102 RelaxedPrecision
129 OpDecorate %106 RelaxedPrecision
130 OpDecorate %109 RelaxedPrecision
131 OpDecorate %110 RelaxedPrecision
132 OpDecorate %111 RelaxedPrecision
134 %3 = OpTypeFunction %2
138 %9 = OpTypeArray %6 %8
139 %10 = OpTypeStruct %9
140 %11 = OpTypePointer Function %10
141 %12 = OpTypeFunction %6 %11
143 %22 = OpConstantTrue %21
144 %23 = OpConstant %6 0
145 %24 = OpTypeStruct %6
146 %25 = OpTypePointer Uniform %24
147 %26 = OpVariable %25 Uniform
148 %27 = OpTypePointer Uniform %6
149 %30 = OpTypePointer Function %6
150 %36 = OpConstant %6 42
152 %52 = OpTypeVector %51 4
153 %53 = OpTypePointer Output %52
154 %54 = OpVariable %53 Output
155 %55 = OpConstant %51 1
156 %56 = OpConstant %51 0
157 %57 = OpConstantComposite %52 %55 %56 %56 %55
158 %59 = OpConstantComposite %52 %56 %56 %56 %56
159 %66 = OpConstantFalse %21
160 %67 = OpTypePointer Function %21
163 %80 = OpTypePointer Function %9
164 %4 = OpFunction %2 None %3
166 %85 = OpVariable %67 Function %66
167 %86 = OpVariable %30 Function
168 %87 = OpVariable %30 Function
169 %81 = OpVariable %80 Function
170 %45 = OpVariable %11 Function
171 %42 = OpAccessChain %27 %26 %23
174 %111 = OpCompositeInsert %9 %43 %110 0
177 %84 = OpCompositeConstruct %10 %83
182 OpLoopMerge %91 %89 None
185 OpLoopMerge %96 %94 None
188 %101 = OpAccessChain %30 %45 %23 %43
189 %102 = OpLoad %6 %101
190 %103 = OpIEqual %21 %102 %23
191 OpSelectionMerge %104 None
192 OpBranchConditional %103 %105 %104
202 %106 = OpPhi %6 %36 %105 %78 %104
203 %107 = OpPhi %21 %22 %105 %66 %104
204 OpSelectionMerge %108 None
205 OpBranchConditional %107 %91 %108
213 %109 = OpPhi %6 %106 %96 %36 %108
215 %48 = OpIEqual %21 %109 %36
216 OpSelectionMerge %50 None
217 OpBranchConditional %48 %49 %58
227 %14 = OpFunction %6 None %12
228 %13 = OpFunctionParameter %11
230 %68 = OpVariable %67 Function %66
231 %61 = OpVariable %30 Function
234 %73 = OpPhi %21 %66 %15 %79 %65
235 OpLoopMerge %60 %65 None
240 %72 = OpPhi %21 %73 %64 %79 %19
241 OpLoopMerge %18 %19 None
246 %28 = OpAccessChain %27 %26 %23
248 %31 = OpAccessChain %30 %13 %23 %29
250 %33 = OpIEqual %21 %32 %23
251 OpSelectionMerge %35 None
252 OpBranchConditional %33 %34 %35
262 %75 = OpPhi %6 %36 %34 %78 %35
263 %71 = OpPhi %21 %22 %34 %72 %35
264 OpSelectionMerge %69 None
265 OpBranchConditional %71 %60 %69
273 %74 = OpPhi %6 %75 %18 %36 %69
278 # uniforms for variant
281 BUFFER variant_zero DATA_TYPE int32 DATA
285 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
287 PIPELINE graphics variant_pipeline
288 ATTACH variant_vertex_shader
289 ATTACH variant_fragment_shader
290 FRAMEBUFFER_SIZE 256 256
291 BIND BUFFER variant_framebuffer AS color LOCATION 0
292 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
294 CLEAR_COLOR variant_pipeline 0 0 0 255
296 CLEAR variant_pipeline
297 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
299 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255