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 add/sub combining 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_9 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_0 _GLF_uniform_int_values[2]
31 # #define _int_5 _GLF_uniform_int_values[3]
32 # #define _int_10 _GLF_uniform_int_values[4]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: [9, 1, 0, 5, 10]
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[5];
43 # layout(location = 0) out vec4 _GLF_color;
50 # for (int i = _int_0; i < _int_10; i++)
57 # // Simplifies to a = i - 2.
58 # a = int(f) - 1 - _int_1 + i;
74 # if (func(-9.3 + 10.0) == _int_1)
76 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
80 # _GLF_color = vec4(_int_0);
83 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
86 ; Generator: Khronos Glslang Reference Front End; 8
90 %1 = OpExtInstImport "GLSL.std.450"
91 OpMemoryModel Logical GLSL450
92 OpEntryPoint Fragment %4 "main" %88
93 OpExecutionMode %4 OriginUpperLeft
100 OpMemberName %18 0 "_GLF_uniform_int_values"
105 OpName %88 "_GLF_color"
106 OpDecorate %17 ArrayStride 16
107 OpMemberDecorate %18 0 Offset 0
109 OpDecorate %20 DescriptorSet 0
110 OpDecorate %20 Binding 0
111 OpDecorate %88 Location 0
113 %3 = OpTypeFunction %2
115 %7 = OpTypePointer Function %6
117 %9 = OpTypeFunction %8 %7
118 %13 = OpTypePointer Function %8
120 %16 = OpConstant %15 5
121 %17 = OpTypeArray %8 %16
122 %18 = OpTypeStruct %17
123 %19 = OpTypePointer Uniform %18
124 %20 = OpVariable %19 Uniform
125 %21 = OpConstant %8 0
126 %22 = OpConstant %8 1
127 %23 = OpTypePointer Uniform %8
128 %27 = OpConstant %8 2
129 %39 = OpConstant %8 4
131 %45 = OpConstant %8 3
132 %78 = OpConstant %6 0.699999988
133 %86 = OpTypeVector %6 4
134 %87 = OpTypePointer Output %86
135 %88 = OpVariable %87 Output
136 %4 = OpFunction %2 None %3
138 %79 = OpVariable %7 Function
140 %80 = OpFunctionCall %8 %11 %79
141 %81 = OpAccessChain %23 %20 %21 %22
143 %83 = OpIEqual %42 %80 %82
144 OpSelectionMerge %85 None
145 OpBranchConditional %83 %84 %102
147 %89 = OpAccessChain %23 %20 %21 %22
149 %91 = OpConvertSToF %6 %90
150 %92 = OpAccessChain %23 %20 %21 %27
152 %94 = OpConvertSToF %6 %93
153 %95 = OpAccessChain %23 %20 %21 %27
155 %97 = OpConvertSToF %6 %96
156 %98 = OpAccessChain %23 %20 %21 %22
158 %100 = OpConvertSToF %6 %99
159 %101 = OpCompositeConstruct %86 %91 %94 %97 %100
163 %103 = OpAccessChain %23 %20 %21 %27
164 %104 = OpLoad %8 %103
165 %105 = OpConvertSToF %6 %104
166 %106 = OpCompositeConstruct %86 %105 %105 %105 %105
172 %11 = OpFunction %8 None %9
173 %10 = OpFunctionParameter %7
175 %14 = OpVariable %13 Function
176 %26 = OpVariable %13 Function
177 %30 = OpVariable %13 Function
178 %24 = OpAccessChain %23 %20 %21 %22
181 %28 = OpAccessChain %23 %20 %21 %27
184 %31 = OpAccessChain %23 %20 %21 %27
189 OpLoopMerge %35 %36 None
193 %40 = OpAccessChain %23 %20 %21 %39
195 %43 = OpSLessThan %42 %38 %41
196 OpBranchConditional %43 %34 %35
199 %46 = OpAccessChain %23 %20 %21 %45
201 %48 = OpSGreaterThan %42 %44 %47
202 OpSelectionMerge %50 None
203 OpBranchConditional %48 %49 %50
208 %53 = OpConvertFToS %8 %52
209 %54 = OpISub %8 %53 %22
210 %55 = OpAccessChain %23 %20 %21 %22
212 %57 = OpISub %8 %54 %56
214 %59 = OpIAdd %8 %57 %58
217 %61 = OpIAdd %8 %60 %22
222 %63 = OpIAdd %8 %62 %22
227 %65 = OpAccessChain %23 %20 %21 %21
229 %67 = OpIEqual %42 %64 %66
230 OpSelectionMerge %69 None
231 OpBranchConditional %67 %68 %73
233 %70 = OpAccessChain %23 %20 %21 %22
237 %74 = OpAccessChain %23 %20 %21 %27
245 # uniforms for variant
247 # _GLF_uniform_int_values
248 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
252 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
254 PIPELINE graphics variant_pipeline
255 ATTACH variant_vertex_shader
256 ATTACH variant_fragment_shader
257 FRAMEBUFFER_SIZE 256 256
258 BIND BUFFER variant_framebuffer AS color LOCATION 0
259 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
261 CLEAR_COLOR variant_pipeline 0 0 0 255
263 CLEAR variant_pipeline
264 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
266 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255