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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_10 _GLF_uniform_int_values[2]
31 # #define _float_1_0 _GLF_uniform_float_values[0]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_float_values: 1.0
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[1];
42 # // Contents of _GLF_uniform_int_values: [0, 1, 10]
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[3];
48 # const int _GLF_global_loop_bound = 10;
49 # int _GLF_global_loop_count = 0;
51 # // Contents of zero: 0.0
52 # layout(set = 0, binding = 2) uniform buf2
57 # layout(location = 0) out vec4 _GLF_color;
61 # // a becomes -57167.
62 # int a = (zero > _float_1_0 ? 1 : -1) - 57166;
65 # // Iterates until the global loop bound is reached.
66 # for(int i = a; i < 80199 && _GLF_global_loop_count < _GLF_global_loop_bound; i += 2)
68 # _GLF_global_loop_count++;
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" %72
92 OpExecutionMode %4 OriginUpperLeft
95 OpName %8 "_GLF_global_loop_count"
98 OpMemberName %13 0 "zero"
101 OpMemberName %22 0 "_GLF_uniform_float_values"
105 OpMemberName %37 0 "_GLF_uniform_int_values"
108 OpName %72 "_GLF_color"
109 OpMemberDecorate %13 0 Offset 0
111 OpDecorate %15 DescriptorSet 0
112 OpDecorate %15 Binding 2
113 OpDecorate %21 ArrayStride 16
114 OpMemberDecorate %22 0 Offset 0
116 OpDecorate %24 DescriptorSet 0
117 OpDecorate %24 Binding 0
118 OpDecorate %36 ArrayStride 16
119 OpMemberDecorate %37 0 Offset 0
121 OpDecorate %39 DescriptorSet 0
122 OpDecorate %39 Binding 1
123 OpDecorate %72 Location 0
125 %3 = OpTypeFunction %2
127 %7 = OpTypePointer Private %6
128 %8 = OpVariable %7 Private
130 %10 = OpTypePointer Function %6
132 %13 = OpTypeStruct %12
133 %14 = OpTypePointer Uniform %13
134 %15 = OpVariable %14 Uniform
135 %16 = OpTypePointer Uniform %12
137 %20 = OpConstant %19 1
138 %21 = OpTypeArray %12 %20
139 %22 = OpTypeStruct %21
140 %23 = OpTypePointer Uniform %22
141 %24 = OpVariable %23 Uniform
143 %29 = OpConstant %6 1
144 %30 = OpConstant %6 -1
145 %32 = OpConstant %6 57166
146 %35 = OpConstant %19 3
147 %36 = OpTypeArray %6 %35
148 %37 = OpTypeStruct %36
149 %38 = OpTypePointer Uniform %37
150 %39 = OpVariable %38 Uniform
151 %40 = OpTypePointer Uniform %6
152 %51 = OpConstant %6 80199
153 %54 = OpConstant %6 10
154 %61 = OpConstant %6 2
155 %70 = OpTypeVector %12 4
156 %71 = OpTypePointer Output %70
157 %72 = OpVariable %71 Output
158 %4 = OpFunction %2 None %3
160 %11 = OpVariable %10 Function
161 %34 = OpVariable %10 Function
162 %43 = OpVariable %10 Function
164 %17 = OpAccessChain %16 %15 %9
166 %25 = OpAccessChain %16 %24 %9 %9
168 %28 = OpFOrdGreaterThan %27 %18 %26
169 %31 = OpSelect %6 %28 %29 %30
170 %33 = OpISub %6 %31 %32
172 %41 = OpAccessChain %40 %39 %9 %9
179 OpLoopMerge %47 %48 None
183 %52 = OpSLessThan %27 %50 %51
185 %55 = OpSLessThan %27 %53 %54
186 %56 = OpLogicalAnd %27 %52 %55
187 OpBranchConditional %56 %46 %47
190 %58 = OpIAdd %6 %57 %29
193 %60 = OpIAdd %6 %59 %29
198 %63 = OpIAdd %6 %62 %61
203 %65 = OpAccessChain %40 %39 %9 %61
205 %67 = OpIEqual %27 %64 %66
206 OpSelectionMerge %69 None
207 OpBranchConditional %67 %68 %86
209 %73 = OpAccessChain %40 %39 %9 %29
211 %75 = OpConvertSToF %12 %74
212 %76 = OpAccessChain %40 %39 %9 %9
214 %78 = OpConvertSToF %12 %77
215 %79 = OpAccessChain %40 %39 %9 %9
217 %81 = OpConvertSToF %12 %80
218 %82 = OpAccessChain %40 %39 %9 %29
220 %84 = OpConvertSToF %12 %83
221 %85 = OpCompositeConstruct %70 %75 %78 %81 %84
225 %87 = OpAccessChain %40 %39 %9 %9
227 %89 = OpConvertSToF %12 %88
228 %90 = OpCompositeConstruct %70 %89 %89 %89 %89
236 # uniforms for variant
239 BUFFER variant_zero DATA_TYPE float STD140 DATA
242 # _GLF_uniform_int_values
243 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
246 # _GLF_uniform_float_values
247 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
251 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
253 PIPELINE graphics variant_pipeline
254 ATTACH variant_vertex_shader
255 ATTACH variant_fragment_shader
256 FRAMEBUFFER_SIZE 32 32
257 BIND BUFFER variant_framebuffer AS color LOCATION 0
258 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 2
259 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
260 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
262 CLEAR_COLOR variant_pipeline 0 0 0 255
264 CLEAR variant_pipeline
265 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
267 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255