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]
30 # #define _int_10 _GLF_uniform_int_values[2]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [0, 1, 10]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # const int _GLF_global_loop_bound = 10;
42 # int _GLF_global_loop_count = 0;
44 # layout(location = 0) out vec4 _GLF_color;
46 # // Contents of one: 1
47 # layout(set = 0, binding = 1) uniform buf1
56 # // (1 ^ 1) & 1 = 0, therefore the loop iterates until global loop bound is reached.
57 # for(int i = _int_1; i != ((1 ^ one) & 1) && _GLF_global_loop_count < _GLF_global_loop_bound; i++)
59 # _GLF_global_loop_count++;
66 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
70 # _GLF_color = vec4(_int_0);
73 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
76 ; Generator: Khronos Glslang Reference Front End; 10
80 %1 = OpExtInstImport "GLSL.std.450"
81 OpMemoryModel Logical GLSL450
82 OpEntryPoint Fragment %4 "main" %60
83 OpExecutionMode %4 OriginUpperLeft
86 OpName %8 "_GLF_global_loop_count"
89 OpMemberName %15 0 "_GLF_uniform_int_values"
93 OpMemberName %31 0 "one"
95 OpName %60 "_GLF_color"
96 OpDecorate %14 ArrayStride 16
97 OpMemberDecorate %15 0 Offset 0
99 OpDecorate %17 DescriptorSet 0
100 OpDecorate %17 Binding 0
101 OpMemberDecorate %31 0 Offset 0
103 OpDecorate %33 DescriptorSet 0
104 OpDecorate %33 Binding 1
105 OpDecorate %60 Location 0
107 %3 = OpTypeFunction %2
109 %7 = OpTypePointer Private %6
110 %8 = OpVariable %7 Private
112 %10 = OpTypePointer Function %6
114 %13 = OpConstant %12 3
115 %14 = OpTypeArray %6 %13
116 %15 = OpTypeStruct %14
117 %16 = OpTypePointer Uniform %15
118 %17 = OpVariable %16 Uniform
119 %18 = OpTypePointer Uniform %6
120 %22 = OpConstant %6 1
121 %31 = OpTypeStruct %6
122 %32 = OpTypePointer Uniform %31
123 %33 = OpVariable %32 Uniform
125 %41 = OpConstant %6 10
126 %51 = OpConstant %6 2
128 %58 = OpTypeVector %57 4
129 %59 = OpTypePointer Output %58
130 %60 = OpVariable %59 Output
131 %4 = OpFunction %2 None %3
133 %11 = OpVariable %10 Function
134 %21 = OpVariable %10 Function
136 %19 = OpAccessChain %18 %17 %9 %9
139 %23 = OpAccessChain %18 %17 %9 %22
144 OpLoopMerge %27 %28 None
148 %34 = OpAccessChain %18 %33 %9
150 %36 = OpBitwiseXor %6 %22 %35
151 %37 = OpBitwiseAnd %6 %36 %22
152 %39 = OpINotEqual %38 %30 %37
154 %42 = OpSLessThan %38 %40 %41
155 %43 = OpLogicalAnd %38 %39 %42
156 OpBranchConditional %43 %26 %27
159 %45 = OpIAdd %6 %44 %22
162 %47 = OpIAdd %6 %46 %22
167 %49 = OpIAdd %6 %48 %22
172 %52 = OpAccessChain %18 %17 %9 %51
174 %54 = OpIEqual %38 %50 %53
175 OpSelectionMerge %56 None
176 OpBranchConditional %54 %55 %74
178 %61 = OpAccessChain %18 %17 %9 %22
180 %63 = OpConvertSToF %57 %62
181 %64 = OpAccessChain %18 %17 %9 %9
183 %66 = OpConvertSToF %57 %65
184 %67 = OpAccessChain %18 %17 %9 %9
186 %69 = OpConvertSToF %57 %68
187 %70 = OpAccessChain %18 %17 %9 %22
189 %72 = OpConvertSToF %57 %71
190 %73 = OpCompositeConstruct %58 %63 %66 %69 %72
194 %75 = OpAccessChain %18 %17 %9 %9
196 %77 = OpConvertSToF %57 %76
197 %78 = OpCompositeConstruct %58 %77 %77 %77 %77
205 # uniforms for variant
208 BUFFER variant_one DATA_TYPE int32 STD140 DATA
211 # _GLF_uniform_int_values
212 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
216 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
218 PIPELINE graphics variant_pipeline
219 ATTACH variant_vertex_shader
220 ATTACH variant_fragment_shader
221 FRAMEBUFFER_SIZE 32 32
222 BIND BUFFER variant_framebuffer AS color LOCATION 0
223 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 1
224 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
226 CLEAR_COLOR variant_pipeline 0 0 0 255
228 CLEAR variant_pipeline
229 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
231 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255