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 # const int _GLF_global_loop_bound = 100;
41 # int _GLF_global_loop_count = 0;
43 # // Contents of resolution: [0.2501191, 0.1597625]
44 # layout(set = 0, binding = 1) uniform buf1
49 # layout(location = 0) out vec4 _GLF_color;
54 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
56 # _GLF_global_loop_count ++;
61 # return vec4(_int_1, _int_0, _int_0, _int_1);
66 # return vec4(_int_0);
71 # // The x component of the ivec is zero because 0 / N is always zero.
72 # _GLF_color = func((ivec2(vec2(0, _int_1) / resolution)));
74 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
77 ; Generator: Khronos Glslang Reference Front End; 10
81 %1 = OpExtInstImport "GLSL.std.450"
82 OpMemoryModel Logical GLSL450
83 OpEntryPoint Fragment %4 "main" %67
84 OpExecutionMode %4 OriginUpperLeft
87 OpName %13 "func(vi2;"
89 OpName %16 "_GLF_global_loop_count"
91 OpMemberName %37 0 "_GLF_uniform_int_values"
93 OpName %67 "_GLF_color"
95 OpMemberName %74 0 "resolution"
98 OpDecorate %36 ArrayStride 16
99 OpMemberDecorate %37 0 Offset 0
101 OpDecorate %39 DescriptorSet 0
102 OpDecorate %39 Binding 0
103 OpDecorate %67 Location 0
104 OpMemberDecorate %74 0 Offset 0
106 OpDecorate %76 DescriptorSet 0
107 OpDecorate %76 Binding 1
109 %3 = OpTypeFunction %2
111 %7 = OpTypeVector %6 2
112 %8 = OpTypePointer Function %7
114 %10 = OpTypeVector %9 4
115 %11 = OpTypeFunction %10 %8
116 %15 = OpTypePointer Private %6
117 %16 = OpVariable %15 Private
118 %17 = OpConstant %6 0
119 %24 = OpConstant %6 100
121 %28 = OpConstant %6 1
123 %31 = OpConstant %30 0
124 %32 = OpTypePointer Function %6
125 %35 = OpConstant %30 2
126 %36 = OpTypeArray %6 %35
127 %37 = OpTypeStruct %36
128 %38 = OpTypePointer Uniform %37
129 %39 = OpVariable %38 Uniform
130 %40 = OpTypePointer Uniform %6
131 %66 = OpTypePointer Output %10
132 %67 = OpVariable %66 Output
133 %68 = OpConstant %9 0
134 %72 = OpTypeVector %9 2
135 %74 = OpTypeStruct %72
136 %75 = OpTypePointer Uniform %74
137 %76 = OpVariable %75 Uniform
138 %77 = OpTypePointer Uniform %72
139 %4 = OpFunction %2 None %3
141 %82 = OpVariable %8 Function
143 %69 = OpAccessChain %40 %39 %17 %28
145 %71 = OpConvertSToF %9 %70
146 %73 = OpCompositeConstruct %72 %68 %71
147 %78 = OpAccessChain %77 %76 %17
149 %80 = OpFDiv %72 %73 %79
150 %81 = OpConvertFToS %7 %80
152 %83 = OpFunctionCall %10 %13 %82
156 %13 = OpFunction %10 None %11
157 %12 = OpFunctionParameter %8
161 OpLoopMerge %20 %21 None
165 %26 = OpSLessThan %25 %23 %24
166 OpBranchConditional %26 %19 %20
169 %29 = OpIAdd %6 %27 %28
171 %33 = OpAccessChain %32 %12 %31
173 %41 = OpAccessChain %40 %39 %17 %28
175 %43 = OpSLessThan %25 %34 %42
176 OpSelectionMerge %45 None
177 OpBranchConditional %43 %44 %45
179 %46 = OpAccessChain %40 %39 %17 %28
181 %48 = OpConvertSToF %9 %47
182 %49 = OpAccessChain %40 %39 %17 %17
184 %51 = OpConvertSToF %9 %50
185 %52 = OpAccessChain %40 %39 %17 %17
187 %54 = OpConvertSToF %9 %53
188 %55 = OpAccessChain %40 %39 %17 %28
190 %57 = OpConvertSToF %9 %56
191 %58 = OpCompositeConstruct %10 %48 %51 %54 %57
198 %60 = OpAccessChain %40 %39 %17 %17
200 %62 = OpConvertSToF %9 %61
201 %63 = OpCompositeConstruct %10 %62 %62 %62 %62
206 # uniforms for variant
209 BUFFER variant_resolution DATA_TYPE vec2<float> STD140 DATA
212 # _GLF_uniform_int_values
213 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
217 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
219 PIPELINE graphics variant_pipeline
220 ATTACH variant_vertex_shader
221 ATTACH variant_fragment_shader
222 FRAMEBUFFER_SIZE 32 32
223 BIND BUFFER variant_framebuffer AS color LOCATION 0
224 BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 1
225 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
227 CLEAR_COLOR variant_pipeline 0 0 0 255
229 CLEAR variant_pipeline
230 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
232 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255