3 # Copyright 2020 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 OpKill wrapping path.
22 # The test passes because shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--convert-local-access-chains'
26 # '--eliminate-dead-branches'
28 # '--eliminate-local-single-store'
29 # '--eliminate-dead-branches'
31 # '--inline-entry-points-exhaustive'
32 # '--copy-propagate-arrays'
34 # '--reduce-load-size'
35 # '--convert-local-access-chains'
37 # '--redundancy-elimination'
39 # '--simplify-instructions'
40 # '--scalar-replacement=100'
41 # '--simplify-instructions'
43 # '--eliminate-dead-inserts'
44 # '--eliminate-dead-branches'
45 # '--eliminate-dead-code-aggressive'
46 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
50 SHADER vertex variant_vertex_shader PASSTHROUGH
52 # variant_fragment_shader is derived from the following GLSL:
54 # precision highp float;
55 # precision highp int;
57 # layout(location = 0) out vec4 _GLF_color;
58 # layout(set = 0, binding = 0) uniform buf0
67 # if (gl_FragCoord.x < 0.5)
69 # else if (gl_FragCoord.y < 0.5)
80 # for(int i = 0; i < five; i++)
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" %20 %75
98 OpExecutionMode %4 OriginUpperLeft
101 OpName %10 "func(f1;"
103 OpName %20 "gl_FragCoord"
107 OpMemberName %56 0 "five"
110 OpName %75 "_GLF_color"
111 OpDecorate %20 BuiltIn FragCoord
112 OpMemberDecorate %56 0 Offset 0
114 OpDecorate %58 DescriptorSet 0
115 OpDecorate %58 Binding 0
116 OpDecorate %75 Location 0
118 %3 = OpTypeFunction %2
120 %7 = OpTypePointer Function %6
121 %8 = OpTypeFunction %6 %7
122 %13 = OpConstant %6 5
124 %18 = OpTypeVector %6 4
125 %19 = OpTypePointer Input %18
126 %20 = OpVariable %19 Input
128 %22 = OpConstant %21 0
129 %23 = OpTypePointer Input %6
130 %26 = OpConstant %6 0.5
131 %32 = OpConstant %21 1
132 %40 = OpConstant %6 1
133 %45 = OpConstant %6 0
135 %47 = OpTypePointer Function %46
136 %49 = OpConstant %46 0
137 %56 = OpTypeStruct %46
138 %57 = OpTypePointer Uniform %56
139 %58 = OpVariable %57 Uniform
140 %59 = OpTypePointer Uniform %46
141 %68 = OpConstant %46 1
142 %74 = OpTypePointer Output %18
143 %75 = OpVariable %74 Output
144 %76 = OpConstantComposite %18 %40 %45 %45 %40
145 %78 = OpConstantComposite %18 %45 %45 %45 %45
146 %4 = OpFunction %2 None %3
148 %44 = OpVariable %7 Function
149 %48 = OpVariable %47 Function
150 %65 = OpVariable %7 Function
156 %60 = OpAccessChain %59 %58 %49
158 %62 = OpSLessThan %14 %55 %61
159 OpLoopMerge %52 %51 None
160 OpBranchConditional %62 %51 %52
163 %64 = OpConvertSToF %6 %63
165 %66 = OpFunctionCall %6 %10 %65
168 %69 = OpIAdd %46 %67 %68
173 %71 = OpFOrdEqual %14 %70 %13
174 OpSelectionMerge %73 None
175 OpBranchConditional %71 %72 %77
185 %10 = OpFunction %6 None %8
186 %9 = OpFunctionParameter %7
189 %15 = OpFOrdGreaterThan %14 %12 %13
190 OpSelectionMerge %17 None
191 OpBranchConditional %15 %16 %17
193 %24 = OpAccessChain %23 %20 %22
195 %27 = OpFOrdLessThan %14 %25 %26
196 OpSelectionMerge %29 None
197 OpBranchConditional %27 %28 %31
201 %33 = OpAccessChain %23 %20 %32
203 %35 = OpFOrdLessThan %14 %34 %26
204 OpSelectionMerge %37 None
205 OpBranchConditional %35 %36 %37
214 %41 = OpFAdd %6 %39 %40
219 # uniforms for variant
222 BUFFER variant_five DATA_TYPE int32 DATA
226 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
228 PIPELINE graphics variant_pipeline
229 ATTACH variant_vertex_shader
230 ATTACH variant_fragment_shader
231 FRAMEBUFFER_SIZE 256 256
232 BIND BUFFER variant_framebuffer AS color LOCATION 0
233 BIND BUFFER variant_five AS uniform DESCRIPTOR_SET 0 BINDING 0
235 CLEAR_COLOR variant_pipeline 0 0 0 255
237 CLEAR variant_pipeline
238 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
240 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255