3 # Copyright 2021 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 five: 5
41 # layout(set = 0, binding = 1) uniform buf1
46 # layout(location = 0) out vec4 _GLF_color;
51 # _GLF_color = vec4(_int_0);
63 # while(_int_1 < _int_1);
65 # // Iterated until a is 5.
80 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
84 # // The coverage points are lost if the value of a has any dependency to output color.
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" %23
96 OpExecutionMode %4 OriginUpperLeft
101 OpMemberName %12 0 "_GLF_uniform_int_values"
103 OpName %23 "_GLF_color"
105 OpMemberName %34 0 "five"
107 OpDecorate %11 ArrayStride 16
108 OpMemberDecorate %12 0 Offset 0
110 OpDecorate %14 DescriptorSet 0
111 OpDecorate %14 Binding 0
112 OpDecorate %23 Location 0
113 OpMemberDecorate %34 0 Offset 0
115 OpDecorate %36 DescriptorSet 0
116 OpDecorate %36 Binding 1
118 %3 = OpTypeFunction %2
120 %7 = OpTypePointer Function %6
122 %10 = OpConstant %9 2
123 %11 = OpTypeArray %6 %10
124 %12 = OpTypeStruct %11
125 %13 = OpTypePointer Uniform %12
126 %14 = OpVariable %13 Uniform
127 %15 = OpConstant %6 0
128 %16 = OpConstant %6 1
129 %17 = OpTypePointer Uniform %6
131 %21 = OpTypeVector %20 4
132 %22 = OpTypePointer Output %21
133 %23 = OpVariable %22 Output
134 %34 = OpTypeStruct %6
135 %35 = OpTypePointer Uniform %34
136 %36 = OpVariable %35 Uniform
138 %65 = OpConstant %6 20
139 %4 = OpFunction %2 None %3
141 %8 = OpVariable %7 Function
142 %18 = OpAccessChain %17 %14 %15 %16
145 %24 = OpAccessChain %17 %14 %15 %15
147 %26 = OpConvertSToF %20 %25
148 %27 = OpCompositeConstruct %21 %26 %26 %26 %26
152 OpLoopMerge %30 %31 None
155 %32 = OpAccessChain %17 %14 %15 %16
157 %37 = OpAccessChain %17 %36 %15
159 %40 = OpSGreaterThanEqual %39 %33 %38
160 OpSelectionMerge %42 None
161 OpBranchConditional %40 %41 %42
166 %45 = OpIAdd %6 %44 %16
170 %46 = OpAccessChain %17 %14 %15 %16
172 %48 = OpAccessChain %17 %14 %15 %16
174 %50 = OpSLessThan %39 %47 %49
175 OpBranchConditional %50 %28 %30
179 OpLoopMerge %53 %54 None
183 %56 = OpAccessChain %17 %36 %15
185 %58 = OpSGreaterThanEqual %39 %55 %57
186 OpSelectionMerge %60 None
187 OpBranchConditional %58 %59 %60
192 %63 = OpIAdd %6 %62 %16
197 %66 = OpSLessThan %39 %64 %65
198 OpBranchConditional %66 %51 %53
202 OpLoopMerge %69 %70 None
206 %72 = OpIAdd %6 %71 %16
208 %73 = OpAccessChain %17 %14 %15 %16
210 %75 = OpConvertSToF %20 %74
211 %76 = OpAccessChain %17 %14 %15 %15
213 %78 = OpConvertSToF %20 %77
214 %79 = OpAccessChain %17 %14 %15 %15
216 %81 = OpConvertSToF %20 %80
217 %82 = OpAccessChain %17 %14 %15 %16
219 %84 = OpConvertSToF %20 %83
220 %85 = OpCompositeConstruct %21 %75 %78 %81 %84
225 %87 = OpAccessChain %17 %14 %15 %16
227 %89 = OpSLessThan %39 %86 %88
228 OpBranchConditional %89 %67 %69
234 # uniforms for variant
237 BUFFER variant_five DATA_TYPE int32 STD140 DATA
240 # _GLF_uniform_int_values
241 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
245 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
247 PIPELINE graphics variant_pipeline
248 ATTACH variant_vertex_shader
249 ATTACH variant_fragment_shader
250 FRAMEBUFFER_SIZE 256 256
251 BIND BUFFER variant_framebuffer AS color LOCATION 0
252 BIND BUFFER variant_five AS uniform DESCRIPTOR_SET 0 BINDING 1
253 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
255 CLEAR_COLOR variant_pipeline 0 0 0 255
257 CLEAR variant_pipeline
258 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
260 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255