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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_0_0 _GLF_uniform_float_values[0]
31 # #define _float_1_0 _GLF_uniform_float_values[1]
32 # #define _float_10_0 _GLF_uniform_float_values[2]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: [1, 0]
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[2];
43 # // Contents of _GLF_uniform_float_values: [0.0, 1.0, 10.0]
44 # layout(set = 0, binding = 1) uniform buf1
46 # float _GLF_uniform_float_values[3];
49 # const int _GLF_global_loop_bound = 10;
50 # int _GLF_global_loop_count = 0;
52 # layout(location = 0) out vec4 _GLF_color;
60 # if(gl_FragCoord.y > _float_0_0)
63 # if(gl_FragCoord.y > _float_0_0)
65 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
67 # _GLF_global_loop_count++;
74 # float c = 256.0 - a + b;
75 # // Clamps 10.0 between 0 and 1.0 resulting in 1.0.
76 # b = clamp(_float_10_0, _float_0_0, c);
88 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
92 # _GLF_color = vec4(_int_0);
95 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
98 ; Generator: Khronos Glslang Reference Front End; 10
102 %1 = OpExtInstImport "GLSL.std.450"
103 OpMemoryModel Logical GLSL450
104 OpEntryPoint Fragment %4 "main" %19 %78
105 OpExecutionMode %4 OriginUpperLeft
109 OpName %10 "_GLF_global_loop_count"
112 OpName %19 "gl_FragCoord"
114 OpMemberName %27 0 "_GLF_uniform_float_values"
117 OpName %78 "_GLF_color"
119 OpMemberName %81 0 "_GLF_uniform_int_values"
121 OpDecorate %19 BuiltIn FragCoord
122 OpDecorate %26 ArrayStride 16
123 OpMemberDecorate %27 0 Offset 0
125 OpDecorate %29 DescriptorSet 0
126 OpDecorate %29 Binding 1
127 OpDecorate %78 Location 0
128 OpDecorate %80 ArrayStride 16
129 OpMemberDecorate %81 0 Offset 0
131 OpDecorate %83 DescriptorSet 0
132 OpDecorate %83 Binding 0
134 %3 = OpTypeFunction %2
136 %9 = OpTypePointer Private %8
137 %10 = OpVariable %9 Private
138 %11 = OpConstant %8 0
140 %13 = OpTypePointer Private %12
141 %14 = OpVariable %13 Private
142 %15 = OpConstant %12 1
143 %16 = OpVariable %13 Private
144 %17 = OpTypeVector %12 4
145 %18 = OpTypePointer Input %17
146 %19 = OpVariable %18 Input
148 %21 = OpConstant %20 1
149 %22 = OpTypePointer Input %12
150 %25 = OpConstant %20 3
151 %26 = OpTypeArray %12 %25
152 %27 = OpTypeStruct %26
153 %28 = OpTypePointer Uniform %27
154 %29 = OpVariable %28 Uniform
155 %30 = OpTypePointer Uniform %12
157 %50 = OpConstant %8 10
158 %53 = OpConstant %8 1
159 %55 = OpConstant %12 256
160 %56 = OpTypePointer Function %12
161 %62 = OpConstant %8 2
162 %77 = OpTypePointer Output %17
163 %78 = OpVariable %77 Output
164 %79 = OpConstant %20 2
165 %80 = OpTypeArray %8 %79
166 %81 = OpTypeStruct %80
167 %82 = OpTypePointer Uniform %81
168 %83 = OpVariable %82 Uniform
169 %84 = OpTypePointer Uniform %8
170 %4 = OpFunction %2 None %3
175 %69 = OpFunctionCall %2 %6
176 %70 = OpFunctionCall %2 %6
178 %72 = OpAccessChain %30 %29 %11 %53
180 %74 = OpFOrdEqual %33 %71 %73
181 OpSelectionMerge %76 None
182 OpBranchConditional %74 %75 %98
184 %85 = OpAccessChain %84 %83 %11 %11
186 %87 = OpConvertSToF %12 %86
187 %88 = OpAccessChain %84 %83 %11 %53
189 %90 = OpConvertSToF %12 %89
190 %91 = OpAccessChain %84 %83 %11 %53
192 %93 = OpConvertSToF %12 %92
193 %94 = OpAccessChain %84 %83 %11 %11
195 %96 = OpConvertSToF %12 %95
196 %97 = OpCompositeConstruct %17 %87 %90 %93 %96
200 %99 = OpAccessChain %84 %83 %11 %53
202 %101 = OpConvertSToF %12 %100
203 %102 = OpCompositeConstruct %17 %101 %101 %101 %101
209 %6 = OpFunction %2 None %3
211 %57 = OpVariable %56 Function
212 %23 = OpAccessChain %22 %19 %21
214 %31 = OpAccessChain %30 %29 %11 %11
216 %34 = OpFOrdGreaterThan %33 %24 %32
217 OpSelectionMerge %36 None
218 OpBranchConditional %34 %35 %36
220 %37 = OpAccessChain %22 %19 %21
222 %39 = OpAccessChain %30 %29 %11 %11
224 %41 = OpFOrdGreaterThan %33 %38 %40
225 OpSelectionMerge %43 None
226 OpBranchConditional %41 %42 %43
230 OpLoopMerge %46 %47 None
234 %51 = OpSLessThan %33 %49 %50
235 OpBranchConditional %51 %45 %46
238 %54 = OpIAdd %8 %52 %53
248 %59 = OpFSub %12 %55 %58
250 %61 = OpFAdd %12 %59 %60
252 %63 = OpAccessChain %30 %29 %11 %62
254 %65 = OpAccessChain %30 %29 %11 %11
257 %68 = OpExtInst %12 %1 FClamp %64 %66 %67
265 # uniforms for variant
267 # _GLF_uniform_float_values
268 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
271 # _GLF_uniform_int_values
272 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
276 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
278 PIPELINE graphics variant_pipeline
279 ATTACH variant_vertex_shader
280 ATTACH variant_fragment_shader
281 FRAMEBUFFER_SIZE 32 32
282 BIND BUFFER variant_framebuffer AS color LOCATION 0
283 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
284 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
286 CLEAR_COLOR variant_pipeline 0 0 0 255
288 CLEAR variant_pipeline
289 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
291 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255