3 # Copyright 2022 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_4 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_2 _GLF_uniform_int_values[2]
31 # #define _int_0 _GLF_uniform_int_values[3]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [4, 1, 2, 0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
42 # layout(location = 0) out vec4 _GLF_color;
49 # for(int i = _int_0; i < _int_1; i++)
52 # int j = _int_1, i = i;
60 # for(j = 1; j < i; j++)
63 # // This would make the while loop infinite, but this is never executed.
64 # i = (_int_4 * i) / 1000;
75 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
79 # _GLF_color = vec4(_int_0);
82 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
85 ; Generator: Khronos Glslang Reference Front End; 10
89 %1 = OpExtInstImport "GLSL.std.450"
90 OpMemoryModel Logical GLSL450
91 OpEntryPoint Fragment %4 "main" %82
92 OpExecutionMode %4 OriginUpperLeft
97 OpMemberName %12 0 "_GLF_uniform_int_values"
102 OpName %82 "_GLF_color"
103 OpDecorate %11 ArrayStride 16
104 OpMemberDecorate %12 0 Offset 0
106 OpDecorate %14 DescriptorSet 0
107 OpDecorate %14 Binding 0
108 OpDecorate %82 Location 0
110 %3 = OpTypeFunction %2
112 %7 = OpTypePointer Function %6
114 %10 = OpConstant %9 4
115 %11 = OpTypeArray %6 %10
116 %12 = OpTypeStruct %11
117 %13 = OpTypePointer Uniform %12
118 %14 = OpVariable %13 Uniform
119 %15 = OpConstant %6 0
120 %16 = OpConstant %6 3
121 %17 = OpTypePointer Uniform %6
122 %29 = OpConstant %6 1
124 %64 = OpConstant %6 1000
125 %73 = OpConstant %6 2
127 %80 = OpTypeVector %79 4
128 %81 = OpTypePointer Output %80
129 %82 = OpVariable %81 Output
130 %4 = OpFunction %2 None %3
132 %8 = OpVariable %7 Function
133 %20 = OpVariable %7 Function
134 %34 = OpVariable %7 Function
135 %37 = OpVariable %7 Function
136 %18 = OpAccessChain %17 %14 %15 %16
139 %21 = OpAccessChain %17 %14 %15 %16
144 OpLoopMerge %25 %26 None
148 %30 = OpAccessChain %17 %14 %15 %29
150 %33 = OpSLessThan %32 %28 %31
151 OpBranchConditional %33 %24 %25
153 %35 = OpAccessChain %17 %14 %15 %29
160 OpLoopMerge %41 %42 None
164 %45 = OpAccessChain %17 %14 %15 %29
166 %47 = OpSLessThanEqual %32 %44 %46
167 OpBranchConditional %47 %40 %41
170 %49 = OpIAdd %6 %48 %29
175 OpLoopMerge %52 %53 None
180 %57 = OpSLessThan %32 %55 %56
181 OpBranchConditional %57 %51 %52
183 %58 = OpAccessChain %17 %14 %15 %16
186 %60 = OpAccessChain %17 %14 %15 %15
189 %63 = OpIMul %6 %61 %62
190 %65 = OpSDiv %6 %63 %64
195 %67 = OpIAdd %6 %66 %29
200 %69 = OpIAdd %6 %68 %29
209 %71 = OpIAdd %6 %70 %29
214 %74 = OpAccessChain %17 %14 %15 %73
216 %76 = OpIEqual %32 %72 %75
217 OpSelectionMerge %78 None
218 OpBranchConditional %76 %77 %96
220 %83 = OpAccessChain %17 %14 %15 %29
222 %85 = OpConvertSToF %79 %84
223 %86 = OpAccessChain %17 %14 %15 %16
225 %88 = OpConvertSToF %79 %87
226 %89 = OpAccessChain %17 %14 %15 %16
228 %91 = OpConvertSToF %79 %90
229 %92 = OpAccessChain %17 %14 %15 %29
231 %94 = OpConvertSToF %79 %93
232 %95 = OpCompositeConstruct %80 %85 %88 %91 %94
236 %97 = OpAccessChain %17 %14 %15 %16
238 %99 = OpConvertSToF %79 %98
239 %100 = OpCompositeConstruct %80 %99 %99 %99 %99
247 # uniforms for variant
249 # _GLF_uniform_int_values
250 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
254 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
256 PIPELINE graphics variant_pipeline
257 ATTACH variant_vertex_shader
258 ATTACH variant_fragment_shader
259 FRAMEBUFFER_SIZE 32 32
260 BIND BUFFER variant_framebuffer AS color LOCATION 0
261 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
263 CLEAR_COLOR variant_pipeline 0 0 0 255
265 CLEAR variant_pipeline
266 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
268 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255