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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # layout(location = 0) out vec4 _GLF_color;
44 # _GLF_color = vec4(_int_0);
46 # // Iterates once with i = 1.
47 # for(int i = 1; i <= 1; i *= 2)
49 # // Iterates once with j = 0.
50 # for(int j = 0; j < 1; j += 2 * i)
52 # // k = 1 + 0 + 1 = 2
56 # while((j + i) >= _int_1 && k <= min(j + 2 * i, 1))
63 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
65 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
68 ; Generator: Khronos Glslang Reference Front End; 10
72 %1 = OpExtInstImport "GLSL.std.450"
73 OpMemoryModel Logical GLSL450
74 OpEntryPoint Fragment %4 "main" %9
75 OpExecutionMode %4 OriginUpperLeft
78 OpName %9 "_GLF_color"
80 OpMemberName %14 0 "_GLF_uniform_int_values"
85 OpDecorate %9 Location 0
86 OpDecorate %13 ArrayStride 16
87 OpMemberDecorate %14 0 Offset 0
89 OpDecorate %16 DescriptorSet 0
90 OpDecorate %16 Binding 0
92 %3 = OpTypeFunction %2
94 %7 = OpTypeVector %6 4
95 %8 = OpTypePointer Output %7
96 %9 = OpVariable %8 Output
99 %12 = OpConstant %11 2
100 %13 = OpTypeArray %10 %12
101 %14 = OpTypeStruct %13
102 %15 = OpTypePointer Uniform %14
103 %16 = OpVariable %15 Uniform
104 %17 = OpConstant %10 0
105 %18 = OpConstant %10 1
106 %19 = OpTypePointer Uniform %10
107 %24 = OpTypePointer Function %10
109 %62 = OpConstant %10 2
110 %4 = OpFunction %2 None %3
112 %25 = OpVariable %24 Function
113 %34 = OpVariable %24 Function
114 %42 = OpVariable %24 Function
115 %20 = OpAccessChain %19 %16 %17 %18
117 %22 = OpConvertSToF %6 %21
118 %23 = OpCompositeConstruct %7 %22 %22 %22 %22
123 OpLoopMerge %28 %29 None
127 %33 = OpSLessThanEqual %32 %31 %18
128 OpBranchConditional %33 %27 %28
133 OpLoopMerge %37 %38 None
137 %41 = OpSLessThan %32 %40 %18
138 OpBranchConditional %41 %36 %37
142 %45 = OpIAdd %10 %43 %44
143 %46 = OpIAdd %10 %45 %18
147 OpLoopMerge %49 %50 None
152 %54 = OpIAdd %10 %52 %53
153 %55 = OpAccessChain %19 %16 %17 %17
155 %57 = OpSGreaterThanEqual %32 %54 %56
156 OpSelectionMerge %59 None
157 OpBranchConditional %57 %58 %59
162 %64 = OpIMul %10 %62 %63
163 %65 = OpIAdd %10 %61 %64
164 %66 = OpExtInst %10 %1 SMin %65 %18
165 %67 = OpSLessThanEqual %32 %60 %66
168 %68 = OpPhi %32 %57 %51 %67 %58
169 OpBranchConditional %68 %48 %49
178 %71 = OpIMul %10 %62 %70
180 %73 = OpIAdd %10 %72 %71
187 %75 = OpIMul %10 %74 %62
191 %76 = OpAccessChain %19 %16 %17 %17
193 %78 = OpConvertSToF %6 %77
194 %79 = OpAccessChain %19 %16 %17 %18
196 %81 = OpConvertSToF %6 %80
197 %82 = OpAccessChain %19 %16 %17 %18
199 %84 = OpConvertSToF %6 %83
200 %85 = OpAccessChain %19 %16 %17 %17
202 %87 = OpConvertSToF %6 %86
203 %88 = OpCompositeConstruct %7 %78 %81 %84 %87
209 # uniforms for variant
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__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
225 CLEAR_COLOR variant_pipeline 0 0 0 255
227 CLEAR variant_pipeline
228 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
230 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255