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_18 _GLF_uniform_int_values[2]
31 # #define _float_0_0 _GLF_uniform_float_values[0]
33 # precision highp int;
34 # precision highp float;
36 # // Contents of _GLF_uniform_float_values: 0.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, 18]
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[3];
48 # layout(location = 0) out vec4 _GLF_color;
54 # // The loop limit is always 20. The first iteration decreases the sum,
55 # // and all other iterations increases it.
56 # for(int i = 1; i < ((gl_FragCoord.x >= _float_0_0) ? 20 : - 1); i++)
58 # sum += i == _int_1 ? - _int_1 : _int_1;
64 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
68 # _GLF_color = vec4(_int_0);
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
74 ; Generator: Khronos Glslang Reference Front End; 10
78 %1 = OpExtInstImport "GLSL.std.450"
79 OpMemoryModel Logical GLSL450
80 OpEntryPoint Fragment %4 "main" %30 %75
81 OpExecutionMode %4 OriginUpperLeft
86 OpMemberName %12 0 "_GLF_uniform_int_values"
89 OpName %30 "gl_FragCoord"
91 OpMemberName %37 0 "_GLF_uniform_float_values"
93 OpName %75 "_GLF_color"
94 OpDecorate %11 ArrayStride 16
95 OpMemberDecorate %12 0 Offset 0
97 OpDecorate %14 DescriptorSet 0
98 OpDecorate %14 Binding 1
99 OpDecorate %30 BuiltIn FragCoord
100 OpDecorate %36 ArrayStride 16
101 OpMemberDecorate %37 0 Offset 0
103 OpDecorate %39 DescriptorSet 0
104 OpDecorate %39 Binding 0
105 OpDecorate %75 Location 0
107 %3 = OpTypeFunction %2
109 %7 = OpTypePointer Function %6
111 %10 = OpConstant %9 3
112 %11 = OpTypeArray %6 %10
113 %12 = OpTypeStruct %11
114 %13 = OpTypePointer Uniform %12
115 %14 = OpVariable %13 Uniform
116 %15 = OpConstant %6 0
117 %16 = OpConstant %6 1
118 %17 = OpTypePointer Uniform %6
120 %28 = OpTypeVector %27 4
121 %29 = OpTypePointer Input %28
122 %30 = OpVariable %29 Input
123 %31 = OpConstant %9 0
124 %32 = OpTypePointer Input %27
125 %35 = OpConstant %9 1
126 %36 = OpTypeArray %27 %35
127 %37 = OpTypeStruct %36
128 %38 = OpTypePointer Uniform %37
129 %39 = OpVariable %38 Uniform
130 %40 = OpTypePointer Uniform %27
132 %45 = OpConstant %6 20
133 %46 = OpConstant %6 -1
134 %68 = OpConstant %6 2
135 %74 = OpTypePointer Output %28
136 %75 = OpVariable %74 Output
137 %4 = OpFunction %2 None %3
139 %8 = OpVariable %7 Function
140 %20 = OpVariable %7 Function
141 %53 = OpVariable %7 Function
142 %18 = OpAccessChain %17 %14 %15 %16
148 OpLoopMerge %23 %24 None
152 %33 = OpAccessChain %32 %30 %31
154 %41 = OpAccessChain %40 %39 %15 %15
156 %44 = OpFOrdGreaterThanEqual %43 %34 %42
157 %47 = OpSelect %6 %44 %45 %46
158 %48 = OpSLessThan %43 %26 %47
159 OpBranchConditional %48 %22 %23
162 %50 = OpAccessChain %17 %14 %15 %16
164 %52 = OpIEqual %43 %49 %51
165 OpSelectionMerge %55 None
166 OpBranchConditional %52 %54 %59
168 %56 = OpAccessChain %17 %14 %15 %16
170 %58 = OpSNegate %6 %57
174 %60 = OpAccessChain %17 %14 %15 %16
181 %64 = OpIAdd %6 %63 %62
186 %66 = OpIAdd %6 %65 %16
191 %69 = OpAccessChain %17 %14 %15 %68
193 %71 = OpIEqual %43 %67 %70
194 OpSelectionMerge %73 None
195 OpBranchConditional %71 %72 %89
197 %76 = OpAccessChain %17 %14 %15 %16
199 %78 = OpConvertSToF %27 %77
200 %79 = OpAccessChain %17 %14 %15 %15
202 %81 = OpConvertSToF %27 %80
203 %82 = OpAccessChain %17 %14 %15 %15
205 %84 = OpConvertSToF %27 %83
206 %85 = OpAccessChain %17 %14 %15 %16
208 %87 = OpConvertSToF %27 %86
209 %88 = OpCompositeConstruct %28 %78 %81 %84 %87
213 %90 = OpAccessChain %17 %14 %15 %15
215 %92 = OpConvertSToF %27 %91
216 %93 = OpCompositeConstruct %28 %92 %92 %92 %92
224 # uniforms for variant
226 # _GLF_uniform_int_values
227 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
230 # _GLF_uniform_float_values
231 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
235 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
237 PIPELINE graphics variant_pipeline
238 ATTACH variant_vertex_shader
239 ATTACH variant_fragment_shader
240 FRAMEBUFFER_SIZE 32 32
241 BIND BUFFER variant_framebuffer AS color LOCATION 0
242 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
243 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
245 CLEAR_COLOR variant_pipeline 0 0 0 255
247 CLEAR variant_pipeline
248 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
250 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255