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:
29 # #define _int_1 _GLF_uniform_int_values[0]
30 # #define _int_0 _GLF_uniform_int_values[1]
31 # #define _int_2 _GLF_uniform_int_values[2]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0, 2]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[3];
42 # layout(location = 0) out vec4 _GLF_color;
46 # ivec4 v = ivec4(_int_1);
52 # for(int i = 2; i >= 1; i--)
54 # // Iterates once when i = 2 and twice when i = 1.
55 # for(int j = _int_2; j >= i; j--)
63 # if(v == ivec4(_int_1, -_int_1, _int_0, _int_1))
65 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
69 # _GLF_color = vec4(_int_0);
72 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
75 ; Generator: Khronos Glslang Reference Front End; 10
79 %1 = OpExtInstImport "GLSL.std.450"
80 OpMemoryModel Logical GLSL450
81 OpEntryPoint Fragment %4 "main" %76
82 OpExecutionMode %4 OriginUpperLeft
87 OpMemberName %13 0 "_GLF_uniform_int_values"
91 OpName %76 "_GLF_color"
92 OpDecorate %12 ArrayStride 16
93 OpMemberDecorate %13 0 Offset 0
95 OpDecorate %15 DescriptorSet 0
96 OpDecorate %15 Binding 0
97 OpDecorate %76 Location 0
99 %3 = OpTypeFunction %2
101 %7 = OpTypeVector %6 4
102 %8 = OpTypePointer Function %7
104 %11 = OpConstant %10 3
105 %12 = OpTypeArray %6 %11
106 %13 = OpTypeStruct %12
107 %14 = OpTypePointer Uniform %13
108 %15 = OpVariable %14 Uniform
109 %16 = OpConstant %6 0
110 %17 = OpTypePointer Uniform %6
111 %23 = OpConstant %6 1
113 %28 = OpTypePointer Function %6
114 %30 = OpConstant %6 2
115 %68 = OpTypeVector %24 4
117 %74 = OpTypeVector %73 4
118 %75 = OpTypePointer Output %74
119 %76 = OpVariable %75 Output
120 %4 = OpFunction %2 None %3
122 %9 = OpVariable %8 Function
123 %29 = OpVariable %28 Function
124 %38 = OpVariable %28 Function
125 %18 = OpAccessChain %17 %15 %16 %16
127 %20 = OpCompositeConstruct %7 %19 %19 %19 %19
129 %21 = OpAccessChain %17 %15 %16 %16
131 %25 = OpIEqual %24 %22 %23
132 OpSelectionMerge %27 None
133 OpBranchConditional %25 %26 %27
138 OpLoopMerge %33 %34 None
142 %37 = OpSGreaterThanEqual %24 %36 %23
143 OpBranchConditional %37 %32 %33
145 %39 = OpAccessChain %17 %15 %16 %30
150 OpLoopMerge %43 %44 None
155 %48 = OpSGreaterThanEqual %24 %46 %47
156 OpBranchConditional %48 %42 %43
159 %50 = OpAccessChain %28 %9 %49
161 %52 = OpISub %6 %51 %23
166 %54 = OpISub %6 %53 %23
173 %56 = OpISub %6 %55 %23
180 %58 = OpAccessChain %17 %15 %16 %16
182 %60 = OpAccessChain %17 %15 %16 %16
184 %62 = OpSNegate %6 %61
185 %63 = OpAccessChain %17 %15 %16 %23
187 %65 = OpAccessChain %17 %15 %16 %16
189 %67 = OpCompositeConstruct %7 %59 %62 %64 %66
190 %69 = OpIEqual %68 %57 %67
192 OpSelectionMerge %72 None
193 OpBranchConditional %70 %71 %90
195 %77 = OpAccessChain %17 %15 %16 %16
197 %79 = OpConvertSToF %73 %78
198 %80 = OpAccessChain %17 %15 %16 %23
200 %82 = OpConvertSToF %73 %81
201 %83 = OpAccessChain %17 %15 %16 %23
203 %85 = OpConvertSToF %73 %84
204 %86 = OpAccessChain %17 %15 %16 %16
206 %88 = OpConvertSToF %73 %87
207 %89 = OpCompositeConstruct %74 %79 %82 %85 %88
211 %91 = OpAccessChain %17 %15 %16 %23
213 %93 = OpConvertSToF %73 %92
214 %94 = OpCompositeConstruct %74 %93 %93 %93 %93
222 # uniforms for variant
224 # _GLF_uniform_int_values
225 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
229 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
231 PIPELINE graphics variant_pipeline
232 ATTACH variant_vertex_shader
233 ATTACH variant_fragment_shader
234 FRAMEBUFFER_SIZE 32 32
235 BIND BUFFER variant_framebuffer AS color LOCATION 0
236 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
238 CLEAR_COLOR variant_pipeline 0 0 0 255
240 CLEAR variant_pipeline
241 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
243 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255