3 # Copyright 2020 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 a specific machine scheduler path
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_10 _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_4_0 _GLF_uniform_float_values[1]
32 # #define _float_1_0 _GLF_uniform_float_values[2]
33 # #define _float_2_0 _GLF_uniform_float_values[3]
35 # precision highp float;
37 # // Contents of _GLF_uniform_int_values: [10, 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, 4.0, 1.0, 2.0]
44 # layout(set = 0, binding = 1) uniform buf1
46 # float _GLF_uniform_float_values[4];
49 # layout(location = 0) out vec4 _GLF_v1;
53 # vec2 uv = gl_FragCoord.xy;
54 # vec4 v1 = vec4(_float_0_0);
55 # if (uv.y >= _float_0_0)
63 # float a = _float_1_0;
64 # for (int i = _int_0; i < _int_10; i++)
67 # if (_float_1_0 < _float_0_0)
72 # a = pow(v1.x + v1.y + v1.z + v1.w, _float_2_0);
75 # if (a == _float_4_0)
81 # _GLF_v1 = vec4(_int_0);
84 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
87 ; Generator: Khronos Glslang Reference Front End; 8
91 %1 = OpExtInstImport "GLSL.std.450"
92 OpMemoryModel Logical GLSL450
93 OpEntryPoint Fragment %4 "main" %12 %109
94 OpExecutionMode %4 OriginUpperLeft
98 OpName %12 "gl_FragCoord"
101 OpMemberName %20 0 "_GLF_uniform_float_values"
106 OpMemberName %61 0 "_GLF_uniform_int_values"
108 OpName %109 "_GLF_v1"
109 OpDecorate %12 BuiltIn FragCoord
110 OpDecorate %19 ArrayStride 16
111 OpMemberDecorate %20 0 Offset 0
113 OpDecorate %22 DescriptorSet 0
114 OpDecorate %22 Binding 1
115 OpDecorate %59 RelaxedPrecision
116 OpDecorate %60 ArrayStride 16
117 OpMemberDecorate %61 0 RelaxedPrecision
118 OpMemberDecorate %61 0 Offset 0
120 OpDecorate %63 DescriptorSet 0
121 OpDecorate %63 Binding 0
122 OpDecorate %67 RelaxedPrecision
123 OpDecorate %73 RelaxedPrecision
124 OpDecorate %75 RelaxedPrecision
125 OpDecorate %100 RelaxedPrecision
126 OpDecorate %101 RelaxedPrecision
127 OpDecorate %109 Location 0
128 OpDecorate %113 RelaxedPrecision
130 %3 = OpTypeFunction %2
132 %7 = OpTypeVector %6 2
133 %8 = OpTypePointer Function %7
134 %10 = OpTypeVector %6 4
135 %11 = OpTypePointer Input %10
136 %12 = OpVariable %11 Input
137 %15 = OpTypePointer Function %10
139 %18 = OpConstant %17 4
140 %19 = OpTypeArray %6 %18
141 %20 = OpTypeStruct %19
142 %21 = OpTypePointer Uniform %20
143 %22 = OpVariable %21 Uniform
145 %24 = OpConstant %23 0
146 %25 = OpTypePointer Uniform %6
147 %29 = OpConstant %17 1
148 %30 = OpTypePointer Function %6
150 %39 = OpConstant %23 2
151 %42 = OpConstant %17 0
152 %49 = OpConstant %17 2
153 %53 = OpConstant %17 3
154 %58 = OpTypePointer Function %23
155 %60 = OpTypeArray %23 %49
156 %61 = OpTypeStruct %60
157 %62 = OpTypePointer Uniform %61
158 %63 = OpVariable %62 Uniform
159 %64 = OpConstant %23 1
160 %65 = OpTypePointer Uniform %23
161 %96 = OpConstant %23 3
162 %108 = OpTypePointer Output %10
163 %109 = OpVariable %108 Output
164 %4 = OpFunction %2 None %3
166 %9 = OpVariable %8 Function
167 %16 = OpVariable %15 Function
168 %55 = OpVariable %30 Function
169 %59 = OpVariable %58 Function
171 %14 = OpVectorShuffle %7 %13 %13 0 1
173 %26 = OpAccessChain %25 %22 %24 %24
175 %28 = OpCompositeConstruct %10 %27 %27 %27 %27
177 %31 = OpAccessChain %30 %9 %29
179 %33 = OpAccessChain %25 %22 %24 %24
181 %36 = OpFOrdGreaterThanEqual %35 %32 %34
182 OpSelectionMerge %38 None
183 OpBranchConditional %36 %37 %38
185 %40 = OpAccessChain %25 %22 %24 %39
187 %43 = OpAccessChain %30 %16 %42
189 %44 = OpAccessChain %25 %22 %24 %24
191 %46 = OpAccessChain %30 %16 %29
193 %47 = OpAccessChain %25 %22 %24 %24
195 %50 = OpAccessChain %30 %16 %49
197 %51 = OpAccessChain %25 %22 %24 %39
199 %54 = OpAccessChain %30 %16 %53
203 %56 = OpAccessChain %25 %22 %24 %39
206 %66 = OpAccessChain %65 %63 %24 %64
211 OpLoopMerge %70 %71 None
215 %74 = OpAccessChain %65 %63 %24 %24
217 %76 = OpSLessThan %35 %73 %75
218 OpBranchConditional %76 %69 %70
220 %77 = OpAccessChain %25 %22 %24 %39
222 %79 = OpAccessChain %25 %22 %24 %24
224 %81 = OpFOrdLessThan %35 %78 %80
225 OpSelectionMerge %83 None
226 OpBranchConditional %81 %82 %83
230 %85 = OpAccessChain %30 %16 %42
232 %87 = OpAccessChain %30 %16 %29
234 %89 = OpFAdd %6 %86 %88
235 %90 = OpAccessChain %30 %16 %49
237 %92 = OpFAdd %6 %89 %91
238 %93 = OpAccessChain %30 %16 %53
240 %95 = OpFAdd %6 %92 %94
241 %97 = OpAccessChain %25 %22 %24 %96
243 %99 = OpExtInst %6 %1 Pow %95 %98
247 %100 = OpLoad %23 %59
248 %101 = OpIAdd %23 %100 %64
253 %103 = OpAccessChain %25 %22 %24 %64
254 %104 = OpLoad %6 %103
255 %105 = OpFOrdEqual %35 %102 %104
256 OpSelectionMerge %107 None
257 OpBranchConditional %105 %106 %111
259 %110 = OpLoad %10 %16
263 %112 = OpAccessChain %65 %63 %24 %64
264 %113 = OpLoad %23 %112
265 %114 = OpConvertSToF %6 %113
266 %115 = OpCompositeConstruct %10 %114 %114 %114 %114
274 # uniforms for variant
276 # _GLF_uniform_float_values
277 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
280 # _GLF_uniform_int_values
281 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
285 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
287 PIPELINE graphics variant_pipeline
288 ATTACH variant_vertex_shader
289 ATTACH variant_fragment_shader
290 FRAMEBUFFER_SIZE 256 256
291 BIND BUFFER variant_framebuffer AS color LOCATION 0
292 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
293 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
295 CLEAR_COLOR variant_pipeline 0 0 0 255
297 CLEAR variant_pipeline
298 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
300 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255