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:
28 # #define _int_0 _GLF_uniform_int_values[0]
29 # #define _int_5 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 # #define _float_0_0 _GLF_uniform_float_values[0]
32 # #define _float_1_0 _GLF_uniform_float_values[1]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
38 # layout(set = 0, binding = 0) uniform buf0
40 # float _GLF_uniform_float_values[2];
43 # // Contents of _GLF_uniform_int_values: [0, 5, 1]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[3];
49 # layout(location = 0) out vec4 _GLF_color;
51 # // Contents of injectionSwitch: [0.0, 1.0]
52 # layout(set = 0, binding = 2) uniform buf2
54 # vec2 injectionSwitch;
59 # _GLF_color = vec4(_int_0);
62 # if(injectionSwitch.x > injectionSwitch.y)
68 # if(gl_FragCoord.x >= _float_0_0)
70 # _GLF_color = vec4(_float_1_0);
73 # for(int i = _int_0; i < _int_5; i++)
75 # _GLF_color = vec4(_int_1, _int_0, _int_0, 1);
78 # if(gl_FragCoord.y >= _float_0_0)
81 # if(injectionSwitch.x > injectionSwitch.y)
83 # _GLF_color = vec4(0);
89 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
92 ; Generator: Khronos Glslang Reference Front End; 10
96 %1 = OpExtInstImport "GLSL.std.450"
97 OpMemoryModel Logical GLSL450
98 OpEntryPoint Fragment %4 "main" %9 %40
99 OpExecutionMode %4 OriginUpperLeft
102 OpName %9 "_GLF_color"
104 OpMemberName %14 0 "_GLF_uniform_int_values"
107 OpMemberName %24 0 "injectionSwitch"
109 OpName %40 "gl_FragCoord"
111 OpMemberName %46 0 "_GLF_uniform_float_values"
114 OpDecorate %9 Location 0
115 OpDecorate %13 ArrayStride 16
116 OpMemberDecorate %14 0 Offset 0
118 OpDecorate %16 DescriptorSet 0
119 OpDecorate %16 Binding 1
120 OpMemberDecorate %24 0 Offset 0
122 OpDecorate %26 DescriptorSet 0
123 OpDecorate %26 Binding 2
124 OpDecorate %40 BuiltIn FragCoord
125 OpDecorate %45 ArrayStride 16
126 OpMemberDecorate %46 0 Offset 0
128 OpDecorate %48 DescriptorSet 0
129 OpDecorate %48 Binding 0
131 %3 = OpTypeFunction %2
133 %7 = OpTypeVector %6 4
134 %8 = OpTypePointer Output %7
135 %9 = OpVariable %8 Output
138 %12 = OpConstant %11 3
139 %13 = OpTypeArray %10 %12
140 %14 = OpTypeStruct %13
141 %15 = OpTypePointer Uniform %14
142 %16 = OpVariable %15 Uniform
143 %17 = OpConstant %10 0
144 %18 = OpTypePointer Uniform %10
145 %23 = OpTypeVector %6 2
146 %24 = OpTypeStruct %23
147 %25 = OpTypePointer Uniform %24
148 %26 = OpVariable %25 Uniform
149 %27 = OpConstant %11 0
150 %28 = OpTypePointer Uniform %6
151 %31 = OpConstant %11 1
153 %39 = OpTypePointer Input %7
154 %40 = OpVariable %39 Input
155 %41 = OpTypePointer Input %6
156 %44 = OpConstant %11 2
157 %45 = OpTypeArray %6 %44
158 %46 = OpTypeStruct %45
159 %47 = OpTypePointer Uniform %46
160 %48 = OpVariable %47 Uniform
161 %54 = OpConstant %10 1
162 %58 = OpTypePointer Function %10
163 %71 = OpConstant %10 2
164 %81 = OpConstant %6 1
165 %97 = OpConstant %6 0
166 %98 = OpConstantComposite %7 %97 %97 %97 %97
167 %4 = OpFunction %2 None %3
169 %59 = OpVariable %58 Function
170 %19 = OpAccessChain %18 %16 %17 %17
172 %21 = OpConvertSToF %6 %20
173 %22 = OpCompositeConstruct %7 %21 %21 %21 %21
175 %29 = OpAccessChain %28 %26 %17 %27
177 %32 = OpAccessChain %28 %26 %17 %31
179 %35 = OpFOrdGreaterThan %34 %30 %33
180 OpSelectionMerge %37 None
181 OpBranchConditional %35 %36 %38
185 %42 = OpAccessChain %41 %40 %27
187 %49 = OpAccessChain %28 %48 %17 %17
189 %51 = OpFOrdGreaterThanEqual %34 %43 %50
190 OpSelectionMerge %53 None
191 OpBranchConditional %51 %52 %53
193 %55 = OpAccessChain %28 %48 %17 %54
195 %57 = OpCompositeConstruct %7 %56 %56 %56 %56
199 %60 = OpAccessChain %18 %16 %17 %17
204 OpLoopMerge %64 %65 None
208 %68 = OpAccessChain %18 %16 %17 %54
210 %70 = OpSLessThan %34 %67 %69
211 OpBranchConditional %70 %63 %64
213 %72 = OpAccessChain %18 %16 %17 %71
215 %74 = OpConvertSToF %6 %73
216 %75 = OpAccessChain %18 %16 %17 %17
218 %77 = OpConvertSToF %6 %76
219 %78 = OpAccessChain %18 %16 %17 %17
221 %80 = OpConvertSToF %6 %79
222 %82 = OpCompositeConstruct %7 %74 %77 %80 %81
224 %83 = OpAccessChain %41 %40 %31
226 %85 = OpAccessChain %28 %48 %17 %17
228 %87 = OpFOrdGreaterThanEqual %34 %84 %86
229 OpSelectionMerge %89 None
230 OpBranchConditional %87 %88 %89
232 %90 = OpAccessChain %28 %26 %17 %27
234 %92 = OpAccessChain %28 %26 %17 %31
236 %94 = OpFOrdGreaterThan %34 %91 %93
237 OpSelectionMerge %96 None
238 OpBranchConditional %94 %95 %96
248 %100 = OpIAdd %10 %99 %54
258 # uniforms for variant
261 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
264 # _GLF_uniform_int_values
265 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
268 # _GLF_uniform_float_values
269 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
273 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
275 PIPELINE graphics variant_pipeline
276 ATTACH variant_vertex_shader
277 ATTACH variant_fragment_shader
278 FRAMEBUFFER_SIZE 256 256
279 BIND BUFFER variant_framebuffer AS color LOCATION 0
280 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 2
281 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
282 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
284 CLEAR_COLOR variant_pipeline 0 0 0 255
286 CLEAR variant_pipeline
287 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
289 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255