3 # Copyright 2021 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 the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
29 # #define _float_4_0 _GLF_uniform_float_values[0]
30 # #define _float_16_0 _GLF_uniform_float_values[1]
31 # #define _float_1_0 _GLF_uniform_float_values[2]
32 # #define _float_0_0 _GLF_uniform_float_values[3]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_float_values: [4.0, 16.0, 1.0, 0.0]
38 # layout(set = 0, binding = 0) uniform buf0
40 # float _GLF_uniform_float_values[4];
43 # // Contents of two: 2.0
44 # layout(set = 0, binding = 1) uniform buf1
49 # layout(location = 0) out vec4 _GLF_color;
53 # vec3 v = vec3(_float_1_0);
57 # if(gl_FragCoord.x < _float_0_0)
64 # // i = 1: v.y becomes v.y * v.y = 2 * 2 = 4
65 # // i = 2: v.z becomes v.y * v.y = 4 * 4 = 16
66 # for(int i = 1; i < 3; i ++)
69 # if(v[i] >= _float_1_0)
76 # if(v == vec3(_float_1_0, _float_4_0, _float_16_0))
78 # _GLF_color = vec4(1, 0, 0, 1);
82 # _GLF_color = vec4(0);
85 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
88 ; Generator: Khronos Glslang Reference Front End; 10
92 %1 = OpExtInstImport "GLSL.std.450"
93 OpMemoryModel Logical GLSL450
94 OpEntryPoint Fragment %4 "main" %33 %92
95 OpExecutionMode %4 OriginUpperLeft
100 OpMemberName %13 0 "_GLF_uniform_float_values"
103 OpMemberName %23 0 "two"
105 OpName %33 "gl_FragCoord"
107 OpName %92 "_GLF_color"
108 OpDecorate %12 ArrayStride 16
109 OpMemberDecorate %13 0 Offset 0
111 OpDecorate %15 DescriptorSet 0
112 OpDecorate %15 Binding 0
113 OpMemberDecorate %23 0 Offset 0
115 OpDecorate %25 DescriptorSet 0
116 OpDecorate %25 Binding 1
117 OpDecorate %33 BuiltIn FragCoord
118 OpDecorate %92 Location 0
120 %3 = OpTypeFunction %2
122 %7 = OpTypeVector %6 3
123 %8 = OpTypePointer Function %7
125 %11 = OpConstant %10 4
126 %12 = OpTypeArray %6 %11
127 %13 = OpTypeStruct %12
128 %14 = OpTypePointer Uniform %13
129 %15 = OpVariable %14 Uniform
131 %17 = OpConstant %16 0
132 %18 = OpConstant %16 2
133 %19 = OpTypePointer Uniform %6
134 %23 = OpTypeStruct %6
135 %24 = OpTypePointer Uniform %23
136 %25 = OpVariable %24 Uniform
137 %28 = OpConstant %10 1
138 %29 = OpTypePointer Function %6
139 %31 = OpTypeVector %6 4
140 %32 = OpTypePointer Input %31
141 %33 = OpVariable %32 Input
142 %34 = OpConstant %10 0
143 %35 = OpTypePointer Input %6
144 %38 = OpConstant %16 3
146 %50 = OpConstantTrue %41
147 %51 = OpTypePointer Function %16
148 %53 = OpConstant %16 1
149 %86 = OpTypeVector %41 3
150 %91 = OpTypePointer Output %31
151 %92 = OpVariable %91 Output
152 %93 = OpConstant %6 1
153 %94 = OpConstant %6 0
154 %95 = OpConstantComposite %31 %93 %94 %94 %93
155 %97 = OpConstantComposite %31 %94 %94 %94 %94
156 %4 = OpFunction %2 None %3
158 %9 = OpVariable %8 Function
159 %52 = OpVariable %51 Function
160 %20 = OpAccessChain %19 %15 %17 %18
162 %22 = OpCompositeConstruct %7 %21 %21 %21
164 %26 = OpAccessChain %19 %25 %17
166 %30 = OpAccessChain %29 %9 %28
168 %36 = OpAccessChain %35 %33 %34
170 %39 = OpAccessChain %19 %15 %17 %38
172 %42 = OpFOrdLessThan %41 %37 %40
173 OpSelectionMerge %44 None
174 OpBranchConditional %42 %43 %44
178 OpLoopMerge %47 %48 None
181 OpBranchConditional %50 %46 %47
192 OpLoopMerge %56 %57 None
196 %60 = OpSLessThan %41 %59 %38
197 OpBranchConditional %60 %55 %56
200 %62 = OpAccessChain %29 %9 %61
202 %64 = OpAccessChain %19 %15 %17 %18
204 %66 = OpFOrdGreaterThanEqual %41 %63 %65
205 OpSelectionMerge %68 None
206 OpBranchConditional %66 %67 %68
209 %70 = OpAccessChain %29 %9 %28
211 %72 = OpAccessChain %29 %9 %28
213 %74 = OpFMul %6 %71 %73
214 %75 = OpAccessChain %29 %9 %69
221 %77 = OpIAdd %16 %76 %53
226 %79 = OpAccessChain %19 %15 %17 %18
228 %81 = OpAccessChain %19 %15 %17 %17
230 %83 = OpAccessChain %19 %15 %17 %53
232 %85 = OpCompositeConstruct %7 %80 %82 %84
233 %87 = OpFOrdEqual %86 %78 %85
235 OpSelectionMerge %90 None
236 OpBranchConditional %88 %89 %96
248 # uniforms for variant
251 BUFFER variant_two DATA_TYPE float STD140 DATA
254 # _GLF_uniform_float_values
255 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
259 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
261 PIPELINE graphics variant_pipeline
262 ATTACH variant_vertex_shader
263 ATTACH variant_fragment_shader
264 FRAMEBUFFER_SIZE 256 256
265 BIND BUFFER variant_framebuffer AS color LOCATION 0
266 BIND BUFFER variant_two AS uniform DESCRIPTOR_SET 0 BINDING 1
267 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
269 CLEAR_COLOR variant_pipeline 0 0 0 255
271 CLEAR variant_pipeline
272 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
274 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255