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 SSCP 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_50 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
31 # #define _int_49 _GLF_uniform_int_values[3]
32 # #define _float_2_0 _GLF_uniform_float_values[0]
33 # #define _float_1_0 _GLF_uniform_float_values[1]
35 # precision highp float;
36 # precision highp int;
38 # // Contents of _GLF_uniform_float_values: [2.0, 1.0]
39 # layout(set = 0, binding = 0) uniform buf0
41 # float _GLF_uniform_float_values[2];
44 # // Contents of _GLF_uniform_int_values: [50, 0, 1, 49]
45 # layout(set = 0, binding = 1) uniform buf1
47 # int _GLF_uniform_int_values[4];
50 # layout(location = 0) out vec4 _GLF_color;
57 # // Initializes all A elements to 1.0 and leaves i at 49.
58 # for( i = _int_0; i < _int_50; i ++)
68 # A[clamp(a, _int_0, _int_49)] += _float_1_0;
70 # while(a < _int_1 && i < _int_50);
73 # if(A[_int_0] == _float_2_0)
75 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
79 # _GLF_color = vec4(_int_0);
83 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
86 ; Generator: Khronos Glslang Reference Front End; 10
90 %1 = OpExtInstImport "GLSL.std.450"
91 OpMemoryModel Logical GLSL450
92 OpEntryPoint Fragment %4 "main" %94
93 OpExecutionMode %4 OriginUpperLeft
98 OpMemberName %12 0 "_GLF_uniform_int_values"
102 OpMemberName %40 0 "_GLF_uniform_float_values"
105 OpName %94 "_GLF_color"
106 OpDecorate %11 ArrayStride 16
107 OpMemberDecorate %12 0 Offset 0
109 OpDecorate %14 DescriptorSet 0
110 OpDecorate %14 Binding 1
111 OpDecorate %39 ArrayStride 16
112 OpMemberDecorate %40 0 Offset 0
114 OpDecorate %42 DescriptorSet 0
115 OpDecorate %42 Binding 0
116 OpDecorate %51 RelaxedPrecision
117 OpDecorate %94 Location 0
119 %3 = OpTypeFunction %2
121 %7 = OpTypePointer Function %6
123 %10 = OpConstant %9 4
124 %11 = OpTypeArray %6 %10
125 %12 = OpTypeStruct %11
126 %13 = OpTypePointer Uniform %12
127 %14 = OpVariable %13 Uniform
128 %15 = OpConstant %6 0
129 %16 = OpConstant %6 1
130 %17 = OpTypePointer Uniform %6
133 %33 = OpConstant %9 50
134 %34 = OpTypeArray %32 %33
135 %35 = OpTypePointer Function %34
136 %38 = OpConstant %9 2
137 %39 = OpTypeArray %32 %38
138 %40 = OpTypeStruct %39
139 %41 = OpTypePointer Uniform %40
140 %42 = OpVariable %41 Uniform
141 %43 = OpTypePointer Uniform %32
142 %46 = OpTypePointer Function %32
143 %61 = OpConstant %6 3
144 %72 = OpConstant %6 2
145 %92 = OpTypeVector %32 4
146 %93 = OpTypePointer Output %92
147 %94 = OpVariable %93 Output
148 %4 = OpFunction %2 None %3
150 %8 = OpVariable %7 Function
151 %36 = OpVariable %35 Function
152 %50 = OpVariable %7 Function
153 %18 = OpAccessChain %17 %14 %15 %16
156 %20 = OpAccessChain %17 %14 %15 %16
161 OpLoopMerge %24 %25 None
165 %28 = OpAccessChain %17 %14 %15 %15
167 %31 = OpSLessThan %30 %27 %29
168 OpBranchConditional %31 %23 %24
171 %44 = OpAccessChain %43 %42 %15 %16
173 %47 = OpAccessChain %46 %36 %37
178 %49 = OpIAdd %6 %48 %16
182 %51 = OpExtInst %6 %1 FindILsb %15
186 OpLoopMerge %54 %55 None
190 %57 = OpIAdd %6 %56 %16
193 %59 = OpAccessChain %17 %14 %15 %16
195 %62 = OpAccessChain %17 %14 %15 %61
197 %64 = OpExtInst %6 %1 SClamp %58 %60 %63
198 %65 = OpAccessChain %43 %42 %15 %16
200 %67 = OpAccessChain %46 %36 %64
202 %69 = OpFAdd %32 %68 %66
203 %70 = OpAccessChain %46 %36 %64
208 %73 = OpAccessChain %17 %14 %15 %72
210 %75 = OpSLessThan %30 %71 %74
211 OpSelectionMerge %77 None
212 OpBranchConditional %75 %76 %77
215 %79 = OpAccessChain %17 %14 %15 %15
217 %81 = OpSLessThan %30 %78 %80
220 %82 = OpPhi %30 %75 %55 %81 %76
221 OpBranchConditional %82 %52 %54
223 %83 = OpAccessChain %17 %14 %15 %16
225 %85 = OpAccessChain %46 %36 %84
227 %87 = OpAccessChain %43 %42 %15 %15
229 %89 = OpFOrdEqual %30 %86 %88
230 OpSelectionMerge %91 None
231 OpBranchConditional %89 %90 %108
233 %95 = OpAccessChain %17 %14 %15 %72
235 %97 = OpConvertSToF %32 %96
236 %98 = OpAccessChain %17 %14 %15 %16
238 %100 = OpConvertSToF %32 %99
239 %101 = OpAccessChain %17 %14 %15 %16
240 %102 = OpLoad %6 %101
241 %103 = OpConvertSToF %32 %102
242 %104 = OpAccessChain %17 %14 %15 %72
243 %105 = OpLoad %6 %104
244 %106 = OpConvertSToF %32 %105
245 %107 = OpCompositeConstruct %92 %97 %100 %103 %106
249 %109 = OpAccessChain %17 %14 %15 %16
250 %110 = OpLoad %6 %109
251 %111 = OpConvertSToF %32 %110
252 %112 = OpCompositeConstruct %92 %111 %111 %111 %111
260 # uniforms for variant
262 # _GLF_uniform_int_values
263 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
266 # _GLF_uniform_float_values
267 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
271 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
273 PIPELINE graphics variant_pipeline
274 ATTACH variant_vertex_shader
275 ATTACH variant_fragment_shader
276 FRAMEBUFFER_SIZE 16 16
277 BIND BUFFER variant_framebuffer AS color LOCATION 0
278 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
279 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
281 CLEAR_COLOR variant_pipeline 0 0 0 255
283 CLEAR variant_pipeline
284 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
286 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255