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: Covers specific combine shifts and combine simplify demanded 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_3 _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_2 _GLF_uniform_int_values[3]
32 # #define _float_0_25 _GLF_uniform_float_values[0]
33 # #define _float_0_75 _GLF_uniform_float_values[1]
34 # #define _float_0_0 _GLF_uniform_float_values[2]
35 # #define _float_127_0 _GLF_uniform_float_values[3]
36 # #define _float_64_0 _GLF_uniform_float_values[4]
37 # #define _float_1_0 _GLF_uniform_float_values[5]
38 # #define _float_65_0 _GLF_uniform_float_values[6]
40 # precision highp float;
41 # precision highp int;
43 # // Contents of _GLF_uniform_int_values: [3, 1, 0, 2]
44 # layout(set = 0, binding = 0) uniform buf0
46 # int _GLF_uniform_int_values[4];
49 # // Contents of _GLF_uniform_float_values: [0.25, 0.75, 0.0, 127.0, 64.0, 1.0, 65.0]
50 # layout(set = 0, binding = 1) uniform buf1
52 # float _GLF_uniform_float_values[7];
55 # layout(location = 0) out vec4 _GLF_color;
59 # // Packs the two components into an unsigned integer of 3221176320.
60 # uint a = packUnorm2x16(vec2(_float_0_25, _float_0_75));
62 # // Unpacks the integer into values of 0.0, 64.0, -1.0 and -65.0.
63 # // Then converts them into floating-point values by dividing with 127.0.
64 # vec4 v1 = unpackSnorm4x8(a);
67 # if ( abs(v1[_int_0] - (_float_0_0 / _float_127_0)) < E
68 # && abs(v1[_int_1] - (_float_64_0 / _float_127_0)) < E
69 # && abs(v1[_int_2] - (-_float_1_0 / _float_127_0)) < E
70 # && abs(v1[_int_3] - (-_float_65_0 / _float_127_0)) < E
73 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
77 # _GLF_color = vec4(_float_1_0);
80 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
83 ; Generator: Khronos Glslang Reference Front End; 8
87 %1 = OpExtInstImport "GLSL.std.450"
88 OpMemoryModel Logical GLSL450
89 OpEntryPoint Fragment %4 "main" %112
90 OpExecutionMode %4 OriginUpperLeft
95 OpMemberName %12 0 "_GLF_uniform_float_values"
100 OpMemberName %37 0 "_GLF_uniform_int_values"
102 OpName %112 "_GLF_color"
103 OpDecorate %11 ArrayStride 16
104 OpMemberDecorate %12 0 Offset 0
106 OpDecorate %14 DescriptorSet 0
107 OpDecorate %14 Binding 1
108 OpDecorate %36 ArrayStride 16
109 OpMemberDecorate %37 0 Offset 0
111 OpDecorate %39 DescriptorSet 0
112 OpDecorate %39 Binding 0
113 OpDecorate %112 Location 0
115 %3 = OpTypeFunction %2
117 %7 = OpTypePointer Function %6
119 %10 = OpConstant %6 7
120 %11 = OpTypeArray %9 %10
121 %12 = OpTypeStruct %11
122 %13 = OpTypePointer Uniform %12
123 %14 = OpVariable %13 Uniform
125 %16 = OpConstant %15 0
126 %17 = OpTypePointer Uniform %9
127 %20 = OpConstant %15 1
128 %23 = OpTypeVector %9 2
129 %26 = OpTypeVector %9 4
130 %27 = OpTypePointer Function %26
131 %31 = OpTypePointer Function %9
132 %33 = OpConstant %9 0.00999999978
134 %35 = OpConstant %6 4
135 %36 = OpTypeArray %15 %35
136 %37 = OpTypeStruct %36
137 %38 = OpTypePointer Uniform %37
138 %39 = OpVariable %38 Uniform
139 %40 = OpConstant %15 2
140 %41 = OpTypePointer Uniform %15
141 %48 = OpConstant %15 3
142 %62 = OpConstant %15 4
143 %79 = OpConstant %15 5
144 %97 = OpConstant %15 6
145 %111 = OpTypePointer Output %26
146 %112 = OpVariable %111 Output
147 %4 = OpFunction %2 None %3
149 %8 = OpVariable %7 Function
150 %28 = OpVariable %27 Function
151 %32 = OpVariable %31 Function
152 %18 = OpAccessChain %17 %14 %16 %16
154 %21 = OpAccessChain %17 %14 %16 %20
156 %24 = OpCompositeConstruct %23 %19 %22
157 %25 = OpExtInst %6 %1 PackUnorm2x16 %24
160 %30 = OpExtInst %26 %1 UnpackSnorm4x8 %29
163 %42 = OpAccessChain %41 %39 %16 %40
165 %44 = OpAccessChain %31 %28 %43
167 %46 = OpAccessChain %17 %14 %16 %40
169 %49 = OpAccessChain %17 %14 %16 %48
171 %51 = OpFDiv %9 %47 %50
172 %52 = OpFSub %9 %45 %51
173 %53 = OpExtInst %9 %1 FAbs %52
175 %55 = OpFOrdLessThan %34 %53 %54
176 OpSelectionMerge %57 None
177 OpBranchConditional %55 %56 %57
179 %58 = OpAccessChain %41 %39 %16 %20
181 %60 = OpAccessChain %31 %28 %59
183 %63 = OpAccessChain %17 %14 %16 %62
185 %65 = OpAccessChain %17 %14 %16 %48
187 %67 = OpFDiv %9 %64 %66
188 %68 = OpFSub %9 %61 %67
189 %69 = OpExtInst %9 %1 FAbs %68
191 %71 = OpFOrdLessThan %34 %69 %70
194 %72 = OpPhi %34 %55 %5 %71 %56
195 OpSelectionMerge %74 None
196 OpBranchConditional %72 %73 %74
198 %75 = OpAccessChain %41 %39 %16 %48
200 %77 = OpAccessChain %31 %28 %76
202 %80 = OpAccessChain %17 %14 %16 %79
204 %82 = OpFNegate %9 %81
205 %83 = OpAccessChain %17 %14 %16 %48
207 %85 = OpFDiv %9 %82 %84
208 %86 = OpFSub %9 %78 %85
209 %87 = OpExtInst %9 %1 FAbs %86
211 %89 = OpFOrdLessThan %34 %87 %88
214 %90 = OpPhi %34 %72 %57 %89 %73
215 OpSelectionMerge %92 None
216 OpBranchConditional %90 %91 %92
218 %93 = OpAccessChain %41 %39 %16 %16
220 %95 = OpAccessChain %31 %28 %94
222 %98 = OpAccessChain %17 %14 %16 %97
224 %100 = OpFNegate %9 %99
225 %101 = OpAccessChain %17 %14 %16 %48
226 %102 = OpLoad %9 %101
227 %103 = OpFDiv %9 %100 %102
228 %104 = OpFSub %9 %96 %103
229 %105 = OpExtInst %9 %1 FAbs %104
231 %107 = OpFOrdLessThan %34 %105 %106
234 %108 = OpPhi %34 %90 %74 %107 %91
235 OpSelectionMerge %110 None
236 OpBranchConditional %108 %109 %126
238 %113 = OpAccessChain %41 %39 %16 %20
239 %114 = OpLoad %15 %113
240 %115 = OpConvertSToF %9 %114
241 %116 = OpAccessChain %41 %39 %16 %40
242 %117 = OpLoad %15 %116
243 %118 = OpConvertSToF %9 %117
244 %119 = OpAccessChain %41 %39 %16 %40
245 %120 = OpLoad %15 %119
246 %121 = OpConvertSToF %9 %120
247 %122 = OpAccessChain %41 %39 %16 %20
248 %123 = OpLoad %15 %122
249 %124 = OpConvertSToF %9 %123
250 %125 = OpCompositeConstruct %26 %115 %118 %121 %124
254 %127 = OpAccessChain %17 %14 %16 %79
255 %128 = OpLoad %9 %127
256 %129 = OpCompositeConstruct %26 %128 %128 %128 %128
264 # uniforms for variant
266 # _GLF_uniform_float_values
267 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
268 0.25 0.75 0.0 127.0 64.0 1.0 65.0
270 # _GLF_uniform_int_values
271 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
275 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
277 PIPELINE graphics variant_pipeline
278 ATTACH variant_vertex_shader
279 ATTACH variant_fragment_shader
280 FRAMEBUFFER_SIZE 16 16
281 BIND BUFFER variant_framebuffer AS color LOCATION 0
282 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
283 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
285 CLEAR_COLOR variant_pipeline 0 0 0 255
287 CLEAR variant_pipeline
288 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
290 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255