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 regardless of array contents
72 # if(a.values[zero] == 1)
82 # // If condition is always true
84 # _GLF_color = vec4(1, 0, 0, 1);
86 # _GLF_color = vec4(0);
88 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
91 ; Generator: Khronos Glslang Reference Front End; 8
95 %1 = OpExtInstImport "GLSL.std.450"
96 OpMemoryModel Logical GLSL450
97 OpEntryPoint Fragment %4 "main" %51
98 OpExecutionMode %4 OriginUpperLeft
102 OpMemberName %10 0 "values"
103 OpName %14 "func(struct-Array-i1[2]1;"
106 OpMemberName %24 0 "zero"
109 OpName %51 "_GLF_color"
110 OpMemberDecorate %10 0 RelaxedPrecision
111 OpDecorate %14 RelaxedPrecision
112 OpMemberDecorate %24 0 RelaxedPrecision
113 OpMemberDecorate %24 0 Offset 0
115 OpDecorate %26 DescriptorSet 0
116 OpDecorate %26 Binding 0
117 OpDecorate %29 RelaxedPrecision
118 OpDecorate %32 RelaxedPrecision
119 OpDecorate %51 Location 0
120 OpDecorate %58 RelaxedPrecision
121 OpDecorate %73 RelaxedPrecision
122 OpDecorate %72 RelaxedPrecision
123 OpDecorate %80 RelaxedPrecision
124 OpDecorate %81 RelaxedPrecision
125 OpDecorate %94 RelaxedPrecision
126 OpDecorate %96 RelaxedPrecision
127 OpDecorate %100 RelaxedPrecision
128 OpDecorate %103 RelaxedPrecision
130 %3 = OpTypeFunction %2
134 %9 = OpTypeArray %6 %8
135 %10 = OpTypeStruct %9
136 %11 = OpTypePointer Function %10
137 %12 = OpTypeFunction %6 %11
139 %22 = OpConstantTrue %21
140 %23 = OpConstant %6 0
141 %24 = OpTypeStruct %6
142 %25 = OpTypePointer Uniform %24
143 %26 = OpVariable %25 Uniform
144 %27 = OpTypePointer Uniform %6
145 %30 = OpTypePointer Function %6
146 %33 = OpConstant %6 1
148 %49 = OpTypeVector %48 4
149 %50 = OpTypePointer Output %49
150 %51 = OpVariable %50 Output
151 %52 = OpConstant %48 1
152 %53 = OpConstant %48 0
153 %54 = OpConstantComposite %49 %52 %53 %53 %52
154 %56 = OpConstantComposite %49 %53 %53 %53 %53
155 %63 = OpConstantFalse %21
156 %64 = OpTypePointer Function %21
160 %78 = OpConstantNull %9
161 %4 = OpFunction %2 None %3
163 %79 = OpVariable %64 Function %63
164 %80 = OpVariable %30 Function
165 %81 = OpVariable %30 Function
166 %42 = OpVariable %11 Function
171 OpLoopMerge %85 %83 None
174 OpLoopMerge %90 %88 None
177 %93 = OpAccessChain %27 %26 %23
179 %95 = OpAccessChain %30 %42 %23 %94
181 %97 = OpIEqual %21 %96 %33
182 OpSelectionMerge %98 None
183 OpBranchConditional %97 %99 %98
193 %100 = OpPhi %6 %33 %99 %76 %98
194 %101 = OpPhi %21 %22 %99 %63 %98
195 OpSelectionMerge %102 None
196 OpBranchConditional %101 %85 %102
204 %103 = OpPhi %6 %100 %90 %33 %102
206 %45 = OpIEqual %21 %103 %33
207 OpSelectionMerge %47 None
208 OpBranchConditional %45 %46 %55
218 %14 = OpFunction %6 None %12
219 %13 = OpFunctionParameter %11
221 %65 = OpVariable %64 Function %63
222 %58 = OpVariable %30 Function
225 %71 = OpPhi %21 %63 %15 %77 %62
226 OpLoopMerge %57 %62 None
231 %70 = OpPhi %21 %71 %61 %77 %19
232 OpLoopMerge %18 %19 None
237 %28 = OpAccessChain %27 %26 %23
239 %31 = OpAccessChain %30 %13 %23 %29
241 %34 = OpIEqual %21 %32 %33
242 OpSelectionMerge %36 None
243 OpBranchConditional %34 %35 %36
253 %73 = OpPhi %6 %33 %35 %76 %36
254 %69 = OpPhi %21 %22 %35 %70 %36
255 OpSelectionMerge %66 None
256 OpBranchConditional %69 %57 %66
264 %72 = OpPhi %6 %73 %18 %33 %66
269 # uniforms for variant
272 BUFFER variant_zero DATA_TYPE int32 DATA
276 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
278 PIPELINE graphics variant_pipeline
279 ATTACH variant_vertex_shader
280 ATTACH variant_fragment_shader
281 FRAMEBUFFER_SIZE 256 256
282 BIND BUFFER variant_framebuffer AS color LOCATION 0
283 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
285 CLEAR_COLOR variant_pipeline 0 0 0 255
287 CLEAR variant_pipeline
288 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
290 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255