3 # Copyright 2022 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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _uint_1 _GLF_uniform_uint_values[0]
31 # #define _uint_0 _GLF_uniform_uint_values[1]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
42 # // Contents of _GLF_uniform_uint_values: [1, 0]
43 # layout(set = 0, binding = 1) uniform buf1
45 # uint _GLF_uniform_uint_values[2];
48 # // Contents of one: 1
49 # layout(set = 0, binding = 2) uniform buf2
54 # layout(location = 0) out vec4 _GLF_color;
58 # // Simplifies to min((1 & 1 != 0 ? 1 : 0) / 1, 1 & 1 != 0 ? 1 : 0) = min(1 / 1, 1) = 1.
59 # uint a = min(((one & _uint_1) != _uint_0 ? _uint_1 : _uint_0) / one, (one & _uint_1) != _uint_0 ? _uint_1 : _uint_0);
64 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
68 # _GLF_color = vec4(_int_0);
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
74 ; Generator: Khronos Glslang Reference Front End; 10
78 %1 = OpExtInstImport "GLSL.std.450"
79 OpMemoryModel Logical GLSL450
80 OpEntryPoint Fragment %4 "main" %69
81 OpExecutionMode %4 OriginUpperLeft
86 OpMemberName %9 0 "one"
89 OpMemberName %19 0 "_GLF_uniform_uint_values"
91 OpName %69 "_GLF_color"
93 OpMemberName %71 0 "_GLF_uniform_int_values"
95 OpMemberDecorate %9 0 Offset 0
97 OpDecorate %11 DescriptorSet 0
98 OpDecorate %11 Binding 2
99 OpDecorate %18 ArrayStride 16
100 OpMemberDecorate %19 0 Offset 0
102 OpDecorate %21 DescriptorSet 0
103 OpDecorate %21 Binding 1
104 OpDecorate %69 Location 0
105 OpDecorate %70 ArrayStride 16
106 OpMemberDecorate %71 0 Offset 0
108 OpDecorate %73 DescriptorSet 0
109 OpDecorate %73 Binding 0
111 %3 = OpTypeFunction %2
113 %7 = OpTypePointer Function %6
115 %10 = OpTypePointer Uniform %9
116 %11 = OpVariable %10 Uniform
118 %13 = OpConstant %12 0
119 %14 = OpTypePointer Uniform %6
120 %17 = OpConstant %6 2
121 %18 = OpTypeArray %6 %17
122 %19 = OpTypeStruct %18
123 %20 = OpTypePointer Uniform %19
124 %21 = OpVariable %20 Uniform
125 %25 = OpConstant %12 1
128 %67 = OpTypeVector %66 4
129 %68 = OpTypePointer Output %67
130 %69 = OpVariable %68 Output
131 %70 = OpTypeArray %12 %17
132 %71 = OpTypeStruct %70
133 %72 = OpTypePointer Uniform %71
134 %73 = OpVariable %72 Uniform
135 %74 = OpTypePointer Uniform %12
136 %4 = OpFunction %2 None %3
138 %8 = OpVariable %7 Function
139 %30 = OpVariable %7 Function
140 %50 = OpVariable %7 Function
141 %15 = OpAccessChain %14 %11 %13
143 %22 = OpAccessChain %14 %21 %13 %13
145 %24 = OpBitwiseAnd %6 %16 %23
146 %26 = OpAccessChain %14 %21 %13 %25
148 %29 = OpINotEqual %28 %24 %27
149 OpSelectionMerge %32 None
150 OpBranchConditional %29 %31 %35
152 %33 = OpAccessChain %14 %21 %13 %13
157 %36 = OpAccessChain %14 %21 %13 %25
163 %39 = OpAccessChain %14 %11 %13
165 %41 = OpUDiv %6 %38 %40
166 %42 = OpAccessChain %14 %11 %13
168 %44 = OpAccessChain %14 %21 %13 %13
170 %46 = OpBitwiseAnd %6 %43 %45
171 %47 = OpAccessChain %14 %21 %13 %25
173 %49 = OpINotEqual %28 %46 %48
174 OpSelectionMerge %52 None
175 OpBranchConditional %49 %51 %55
177 %53 = OpAccessChain %14 %21 %13 %13
182 %56 = OpAccessChain %14 %21 %13 %25
188 %59 = OpExtInst %6 %1 UMin %41 %58
191 %61 = OpAccessChain %14 %21 %13 %13
193 %63 = OpIEqual %28 %60 %62
194 OpSelectionMerge %65 None
195 OpBranchConditional %63 %64 %88
197 %75 = OpAccessChain %74 %73 %13 %13
199 %77 = OpConvertSToF %66 %76
200 %78 = OpAccessChain %74 %73 %13 %25
202 %80 = OpConvertSToF %66 %79
203 %81 = OpAccessChain %74 %73 %13 %25
205 %83 = OpConvertSToF %66 %82
206 %84 = OpAccessChain %74 %73 %13 %13
208 %86 = OpConvertSToF %66 %85
209 %87 = OpCompositeConstruct %67 %77 %80 %83 %86
213 %89 = OpAccessChain %74 %73 %13 %25
215 %91 = OpConvertSToF %66 %90
216 %92 = OpCompositeConstruct %67 %91 %91 %91 %91
224 # uniforms for variant
227 BUFFER variant_one DATA_TYPE uint32 STD140 DATA
230 # _GLF_uniform_uint_values
231 BUFFER variant__GLF_uniform_uint_values DATA_TYPE int32[] STD140 DATA
234 # _GLF_uniform_int_values
235 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
239 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
241 PIPELINE graphics variant_pipeline
242 ATTACH variant_vertex_shader
243 ATTACH variant_fragment_shader
244 FRAMEBUFFER_SIZE 32 32
245 BIND BUFFER variant_framebuffer AS color LOCATION 0
246 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 2
247 BIND BUFFER variant__GLF_uniform_uint_values AS uniform DESCRIPTOR_SET 0 BINDING 1
248 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
250 CLEAR_COLOR variant_pipeline 0 0 0 255
252 CLEAR variant_pipeline
253 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
255 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255