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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: [0, 1]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # // Contents of zero: 0
41 # layout(set = 0, binding = 1) uniform buf1
46 # layout(location = 0) out vec4 _GLF_color;
50 # ivec2 v = ivec2(zero, 2);
52 # // i = 0: v changes from (0, 2) to (1, 2).
53 # // i = 1: v changes from (1, 2) to (1, 1).
54 # // i = 2: v changes from (1, 1) to (1, 0).
55 # for(int i = 0; i < 3; i++)
65 # // This loop is never iterated.
77 # if(func() == ivec2(1, 0))
79 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
83 # _GLF_color = vec4(_int_0);
86 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
89 ; Generator: Khronos Glslang Reference Front End; 10
93 %1 = OpExtInstImport "GLSL.std.450"
94 OpMemoryModel Logical GLSL450
95 OpEntryPoint Fragment %4 "main" %82
96 OpExecutionMode %4 OriginUpperLeft
102 OpMemberName %13 0 "zero"
106 OpMemberName %39 0 "_GLF_uniform_int_values"
108 OpName %82 "_GLF_color"
109 OpMemberDecorate %13 0 Offset 0
111 OpDecorate %15 DescriptorSet 0
112 OpDecorate %15 Binding 1
113 OpDecorate %38 ArrayStride 16
114 OpMemberDecorate %39 0 Offset 0
116 OpDecorate %41 DescriptorSet 0
117 OpDecorate %41 Binding 0
118 OpDecorate %82 Location 0
120 %3 = OpTypeFunction %2
122 %7 = OpTypeVector %6 2
123 %8 = OpTypeFunction %7
124 %11 = OpTypePointer Function %7
125 %13 = OpTypeStruct %6
126 %14 = OpTypePointer Uniform %13
127 %15 = OpVariable %14 Uniform
128 %16 = OpConstant %6 0
129 %17 = OpTypePointer Uniform %6
130 %20 = OpConstant %6 2
131 %22 = OpTypePointer Function %6
132 %30 = OpConstant %6 3
135 %34 = OpConstant %33 0
136 %37 = OpConstant %33 2
137 %38 = OpTypeArray %6 %37
138 %39 = OpTypeStruct %38
139 %40 = OpTypePointer Uniform %39
140 %41 = OpVariable %40 Uniform
141 %47 = OpConstant %33 1
142 %50 = OpConstant %6 1
143 %73 = OpConstantComposite %7 %50 %16
144 %74 = OpTypeVector %31 2
146 %80 = OpTypeVector %79 4
147 %81 = OpTypePointer Output %80
148 %82 = OpVariable %81 Output
149 %4 = OpFunction %2 None %3
151 %72 = OpFunctionCall %7 %9
152 %75 = OpIEqual %74 %72 %73
154 OpSelectionMerge %78 None
155 OpBranchConditional %76 %77 %96
157 %83 = OpAccessChain %17 %41 %16 %50
159 %85 = OpConvertSToF %79 %84
160 %86 = OpAccessChain %17 %41 %16 %16
162 %88 = OpConvertSToF %79 %87
163 %89 = OpAccessChain %17 %41 %16 %16
165 %91 = OpConvertSToF %79 %90
166 %92 = OpAccessChain %17 %41 %16 %50
168 %94 = OpConvertSToF %79 %93
169 %95 = OpCompositeConstruct %80 %85 %88 %91 %94
173 %97 = OpAccessChain %17 %41 %16 %16
175 %99 = OpConvertSToF %79 %98
176 %100 = OpCompositeConstruct %80 %99 %99 %99 %99
182 %9 = OpFunction %7 None %8
184 %12 = OpVariable %11 Function
185 %23 = OpVariable %22 Function
186 %18 = OpAccessChain %17 %15 %16
188 %21 = OpCompositeConstruct %7 %19 %20
193 OpLoopMerge %26 %27 None
197 %32 = OpSLessThan %31 %29 %30
198 OpBranchConditional %32 %25 %26
200 %35 = OpAccessChain %22 %12 %34
202 %42 = OpAccessChain %17 %41 %16 %16
204 %44 = OpSGreaterThan %31 %36 %43
205 OpSelectionMerge %46 None
206 OpBranchConditional %44 %45 %46
208 %48 = OpAccessChain %22 %12 %47
210 %51 = OpISub %6 %49 %50
214 %52 = OpAccessChain %22 %12 %47
216 %54 = OpSDiv %6 %53 %20
217 %55 = OpAccessChain %22 %12 %34
219 %57 = OpIAdd %6 %56 %54
220 %58 = OpAccessChain %22 %12 %34
225 %60 = OpIAdd %6 %59 %50
231 OpLoopMerge %63 %64 None
234 %66 = OpAccessChain %22 %12 %34
236 %68 = OpSGreaterThan %31 %67 %50
237 OpBranchConditional %68 %62 %63
248 # uniforms for variant
251 BUFFER variant_zero DATA_TYPE int32 STD140 DATA
254 # _GLF_uniform_int_values
255 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
259 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
261 PIPELINE graphics variant_pipeline
262 ATTACH variant_vertex_shader
263 ATTACH variant_fragment_shader
264 FRAMEBUFFER_SIZE 32 32
265 BIND BUFFER variant_framebuffer AS color LOCATION 0
266 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 1
267 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
269 CLEAR_COLOR variant_pipeline 0 0 0 255
271 CLEAR variant_pipeline
272 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
274 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255