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_1 _GLF_uniform_int_values[1]
30 # #define _float_1_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 1.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
40 # // Contents of _GLF_uniform_int_values: [0, 1]
41 # layout(set = 0, binding = 1) uniform buf1
43 # int _GLF_uniform_int_values[2];
46 # const int _GLF_global_loop_bound = 10;
47 # int _GLF_global_loop_count = 0;
49 # layout(location = 0) out vec4 _GLF_color;
53 # vec4 v = vec4(_float_1_0);
55 # // Iterated twice with i = 1, 0.
56 # for(int i = _int_1; i >= 0 && _GLF_global_loop_count < _GLF_global_loop_bound; i--)
58 # _GLF_global_loop_count++;
60 # for(int j = 1; j >= 1 && _GLF_global_loop_count < _GLF_global_loop_bound; j--)
62 # _GLF_global_loop_count++;
64 # // i = 1: decreases v[1] by one.
65 # // i = 0: decreases v[0] by zero.
66 # v[i] -= mat4(1.0)[i][_int_1];
71 # if(v == vec4(_int_1, _int_0, _int_1, _int_1))
73 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
77 # _GLF_color = vec4(_int_0);
80 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
83 ; Generator: Khronos Glslang Reference Front End; 10
87 %1 = OpExtInstImport "GLSL.std.450"
88 OpMemoryModel Logical GLSL450
89 OpEntryPoint Fragment %4 "main" %107
90 OpExecutionMode %4 OriginUpperLeft
93 OpName %8 "_GLF_global_loop_count"
96 OpMemberName %17 0 "_GLF_uniform_float_values"
100 OpMemberName %28 0 "_GLF_uniform_int_values"
103 OpName %75 "indexable"
104 OpName %107 "_GLF_color"
105 OpDecorate %16 ArrayStride 16
106 OpMemberDecorate %17 0 Offset 0
108 OpDecorate %19 DescriptorSet 0
109 OpDecorate %19 Binding 0
110 OpDecorate %27 ArrayStride 16
111 OpMemberDecorate %28 0 Offset 0
113 OpDecorate %30 DescriptorSet 0
114 OpDecorate %30 Binding 1
115 OpDecorate %107 Location 0
117 %3 = OpTypeFunction %2
119 %7 = OpTypePointer Private %6
120 %8 = OpVariable %7 Private
123 %11 = OpTypeVector %10 4
124 %12 = OpTypePointer Function %11
126 %15 = OpConstant %14 1
127 %16 = OpTypeArray %10 %15
128 %17 = OpTypeStruct %16
129 %18 = OpTypePointer Uniform %17
130 %19 = OpVariable %18 Uniform
131 %20 = OpTypePointer Uniform %10
132 %24 = OpTypePointer Function %6
133 %26 = OpConstant %14 2
134 %27 = OpTypeArray %6 %26
135 %28 = OpTypeStruct %27
136 %29 = OpTypePointer Uniform %28
137 %30 = OpVariable %29 Uniform
138 %31 = OpConstant %6 1
139 %32 = OpTypePointer Uniform %6
141 %44 = OpConstant %6 10
142 %63 = OpTypeMatrix %11 4
143 %64 = OpConstant %10 1
144 %65 = OpConstant %10 0
145 %66 = OpConstantComposite %11 %64 %65 %65 %65
146 %67 = OpConstantComposite %11 %65 %64 %65 %65
147 %68 = OpConstantComposite %11 %65 %65 %64 %65
148 %69 = OpConstantComposite %11 %65 %65 %65 %64
149 %70 = OpConstantComposite %63 %66 %67 %68 %69
150 %74 = OpTypePointer Function %63
151 %76 = OpTypePointer Function %10
152 %101 = OpTypeVector %41 4
153 %106 = OpTypePointer Output %11
154 %107 = OpVariable %106 Output
155 %4 = OpFunction %2 None %3
157 %13 = OpVariable %12 Function
158 %25 = OpVariable %24 Function
159 %49 = OpVariable %24 Function
160 %75 = OpVariable %74 Function
162 %21 = OpAccessChain %20 %19 %9 %9
164 %23 = OpCompositeConstruct %11 %22 %22 %22 %22
166 %33 = OpAccessChain %32 %30 %9 %31
171 OpLoopMerge %37 %38 None
175 %42 = OpSGreaterThanEqual %41 %40 %9
177 %45 = OpSLessThan %41 %43 %44
178 %46 = OpLogicalAnd %41 %42 %45
179 OpBranchConditional %46 %36 %37
182 %48 = OpIAdd %6 %47 %31
187 OpLoopMerge %52 %53 None
191 %56 = OpSGreaterThanEqual %41 %55 %31
193 %58 = OpSLessThan %41 %57 %44
194 %59 = OpLogicalAnd %41 %56 %58
195 OpBranchConditional %59 %51 %52
198 %61 = OpIAdd %6 %60 %31
202 %72 = OpAccessChain %32 %30 %9 %31
205 %77 = OpAccessChain %76 %75 %71 %73
207 %79 = OpAccessChain %76 %13 %62
209 %81 = OpFSub %10 %80 %78
210 %82 = OpAccessChain %76 %13 %62
215 %84 = OpISub %6 %83 %31
222 %86 = OpISub %6 %85 %31
227 %88 = OpAccessChain %32 %30 %9 %31
229 %90 = OpConvertSToF %10 %89
230 %91 = OpAccessChain %32 %30 %9 %9
232 %93 = OpConvertSToF %10 %92
233 %94 = OpAccessChain %32 %30 %9 %31
235 %96 = OpConvertSToF %10 %95
236 %97 = OpAccessChain %32 %30 %9 %31
238 %99 = OpConvertSToF %10 %98
239 %100 = OpCompositeConstruct %11 %90 %93 %96 %99
240 %102 = OpFOrdEqual %101 %87 %100
241 %103 = OpAll %41 %102
242 OpSelectionMerge %105 None
243 OpBranchConditional %103 %104 %121
245 %108 = OpAccessChain %32 %30 %9 %31
246 %109 = OpLoad %6 %108
247 %110 = OpConvertSToF %10 %109
248 %111 = OpAccessChain %32 %30 %9 %9
249 %112 = OpLoad %6 %111
250 %113 = OpConvertSToF %10 %112
251 %114 = OpAccessChain %32 %30 %9 %9
252 %115 = OpLoad %6 %114
253 %116 = OpConvertSToF %10 %115
254 %117 = OpAccessChain %32 %30 %9 %31
255 %118 = OpLoad %6 %117
256 %119 = OpConvertSToF %10 %118
257 %120 = OpCompositeConstruct %11 %110 %113 %116 %119
261 %122 = OpAccessChain %32 %30 %9 %9
262 %123 = OpLoad %6 %122
263 %124 = OpConvertSToF %10 %123
264 %125 = OpCompositeConstruct %11 %124 %124 %124 %124
272 # uniforms for variant
274 # _GLF_uniform_int_values
275 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
278 # _GLF_uniform_float_values
279 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
283 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
285 PIPELINE graphics variant_pipeline
286 ATTACH variant_vertex_shader
287 ATTACH variant_fragment_shader
288 FRAMEBUFFER_SIZE 256 256
289 BIND BUFFER variant_framebuffer AS color LOCATION 0
290 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
291 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
293 CLEAR_COLOR variant_pipeline 0 0 0 255
295 CLEAR variant_pipeline
296 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
298 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255