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 texgen_vert PASSTHROUGH
26 SHADER fragment texgen_frag GLSL
28 precision highp float;
30 layout(location = 0) out vec4 _GLF_color;
35 floor(gl_FragCoord.x) * (1.0 / 255.0),
36 (int(gl_FragCoord.x) ^ int(gl_FragCoord.y)) * (1.0 / 255.0),
37 floor(gl_FragCoord.y) * (1.0 / 255.0),
41 BUFFER default_texture FORMAT B8G8R8A8_UNORM
43 PIPELINE graphics texgen_pipeline
46 FRAMEBUFFER_SIZE 256 256
47 BIND BUFFER default_texture AS color LOCATION 0
50 CLEAR_COLOR texgen_pipeline 0 0 0 255
52 RUN texgen_pipeline DRAW_RECT POS 0 0 SIZE 256 256
54 SHADER vertex variant_vertex_shader PASSTHROUGH
56 # variant_fragment_shader is derived from the following GLSL:
58 # #define _int_1 _GLF_uniform_int_values[0]
59 # #define _int_0 _GLF_uniform_int_values[1]
60 # #define _int_4 _GLF_uniform_int_values[2]
61 # #define _float_1_0 _GLF_uniform_float_values[0]
62 # #define _float_0_0 _GLF_uniform_float_values[1]
64 # precision highp float;
65 # precision highp int;
67 # // Contents of _GLF_uniform_float_values: [1.0, 0.0]
68 # layout(set = 0, binding = 0) uniform buf0
70 # float _GLF_uniform_float_values[2];
73 # // Contents of _GLF_uniform_int_values: [1, 0, 4]
74 # layout(set = 0, binding = 1) uniform buf1
76 # int _GLF_uniform_int_values[3];
79 # layout(set = 0, binding = 2) uniform sampler2D tex;
81 # // Contents of zero: 0.0
82 # layout(set = 0, binding = 3) uniform buf3
87 # layout(location = 0) out vec4 _GLF_color;
92 # float f = texture(tex, vec2(_float_1_0)).y;
94 # // Sampled texel components are always <= 1. The loop will run until i is four.
95 # while(f <= _float_1_0 && i < 4)
98 # if(zero < _float_0_0)
109 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
113 # _GLF_color = vec4(_int_0);
116 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
119 ; Generator: Khronos Glslang Reference Front End; 10
123 %1 = OpExtInstImport "GLSL.std.450"
124 OpMemoryModel Logical GLSL450
125 OpEntryPoint Fragment %4 "main" %75
126 OpExecutionMode %4 OriginUpperLeft
133 OpMemberName %21 0 "_GLF_uniform_float_values"
136 OpMemberName %47 0 "zero"
139 OpMemberName %64 0 "_GLF_uniform_int_values"
141 OpName %75 "_GLF_color"
142 OpDecorate %16 RelaxedPrecision
143 OpDecorate %16 DescriptorSet 0
144 OpDecorate %16 Binding 2
145 OpDecorate %17 RelaxedPrecision
146 OpDecorate %20 ArrayStride 16
147 OpMemberDecorate %21 0 Offset 0
149 OpDecorate %23 DescriptorSet 0
150 OpDecorate %23 Binding 0
151 OpDecorate %28 RelaxedPrecision
152 OpDecorate %30 RelaxedPrecision
153 OpDecorate %32 RelaxedPrecision
154 OpMemberDecorate %47 0 Offset 0
156 OpDecorate %49 DescriptorSet 0
157 OpDecorate %49 Binding 3
158 OpDecorate %63 ArrayStride 16
159 OpMemberDecorate %64 0 Offset 0
161 OpDecorate %66 DescriptorSet 0
162 OpDecorate %66 Binding 1
163 OpDecorate %75 Location 0
165 %3 = OpTypeFunction %2
167 %7 = OpTypePointer Function %6
170 %11 = OpTypePointer Function %10
171 %13 = OpTypeImage %10 2D 0 0 0 1 Unknown
172 %14 = OpTypeSampledImage %13
173 %15 = OpTypePointer UniformConstant %14
174 %16 = OpVariable %15 UniformConstant
176 %19 = OpConstant %18 2
177 %20 = OpTypeArray %10 %19
178 %21 = OpTypeStruct %20
179 %22 = OpTypePointer Uniform %21
180 %23 = OpVariable %22 Uniform
181 %24 = OpTypePointer Uniform %10
182 %27 = OpTypeVector %10 2
183 %29 = OpTypeVector %10 4
184 %31 = OpConstant %18 1
186 %44 = OpConstant %6 4
187 %47 = OpTypeStruct %10
188 %48 = OpTypePointer Uniform %47
189 %49 = OpVariable %48 Uniform
190 %52 = OpConstant %6 1
191 %62 = OpConstant %18 3
192 %63 = OpTypeArray %6 %62
193 %64 = OpTypeStruct %63
194 %65 = OpTypePointer Uniform %64
195 %66 = OpVariable %65 Uniform
196 %67 = OpConstant %6 2
197 %68 = OpTypePointer Uniform %6
198 %74 = OpTypePointer Output %29
199 %75 = OpVariable %74 Output
200 %4 = OpFunction %2 None %3
202 %8 = OpVariable %7 Function
203 %12 = OpVariable %11 Function
206 %25 = OpAccessChain %24 %23 %9 %9
208 %28 = OpCompositeConstruct %27 %26 %26
209 %30 = OpImageSampleImplicitLod %29 %17 %28
210 %32 = OpCompositeExtract %10 %30 1
214 OpLoopMerge %35 %36 None
218 %39 = OpAccessChain %24 %23 %9 %9
220 %42 = OpFOrdLessThanEqual %41 %38 %40
222 %45 = OpSLessThan %41 %43 %44
223 %46 = OpLogicalAnd %41 %42 %45
224 OpBranchConditional %46 %34 %35
226 %50 = OpAccessChain %24 %49 %9
228 %53 = OpAccessChain %24 %23 %9 %52
230 %55 = OpFOrdLessThan %41 %51 %54
231 OpSelectionMerge %57 None
232 OpBranchConditional %55 %56 %57
237 %60 = OpIAdd %6 %59 %52
244 %69 = OpAccessChain %68 %66 %9 %67
246 %71 = OpIEqual %41 %61 %70
247 OpSelectionMerge %73 None
248 OpBranchConditional %71 %72 %89
250 %76 = OpAccessChain %68 %66 %9 %9
252 %78 = OpConvertSToF %10 %77
253 %79 = OpAccessChain %68 %66 %9 %52
255 %81 = OpConvertSToF %10 %80
256 %82 = OpAccessChain %68 %66 %9 %52
258 %84 = OpConvertSToF %10 %83
259 %85 = OpAccessChain %68 %66 %9 %9
261 %87 = OpConvertSToF %10 %86
262 %88 = OpCompositeConstruct %29 %78 %81 %84 %87
266 %90 = OpAccessChain %68 %66 %9 %52
268 %92 = OpConvertSToF %10 %91
269 %93 = OpCompositeConstruct %29 %92 %92 %92 %92
277 # uniforms for variant
283 BUFFER variant_zero DATA_TYPE float STD140 DATA
286 # _GLF_uniform_int_values
287 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
290 # _GLF_uniform_float_values
291 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
295 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
297 PIPELINE graphics variant_pipeline
298 ATTACH variant_vertex_shader
299 ATTACH variant_fragment_shader
300 FRAMEBUFFER_SIZE 32 32
301 BIND BUFFER variant_framebuffer AS color LOCATION 0
302 BIND BUFFER default_texture AS combined_image_sampler SAMPLER variant_tex DESCRIPTOR_SET 0 BINDING 2
303 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 3
304 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
305 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
307 CLEAR_COLOR variant_pipeline 0 0 0 255
309 CLEAR variant_pipeline
310 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
312 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255