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_10 _GLF_uniform_int_values[0]
29 # #define _int_25225 _GLF_uniform_int_values[1]
30 # #define _int_0 _GLF_uniform_int_values[2]
31 # #define _int_1 _GLF_uniform_int_values[3]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [10, 25225, 0, 1]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
42 # layout(location = 0) out vec4 _GLF_color;
47 # // a becomes -25235.
48 # int a = -25236 | _int_1;
50 # // Increments a by ten.
51 # for(int i = _int_0; i < _int_10; i++)
57 # if(a == -_int_25225)
59 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
63 # _GLF_color = vec4(_int_0);
66 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69 ; Generator: Khronos Glslang Reference Front End; 10
73 %1 = OpExtInstImport "GLSL.std.450"
74 OpMemoryModel Logical GLSL450
75 OpEntryPoint Fragment %4 "main" %51
76 OpExecutionMode %4 OriginUpperLeft
81 OpMemberName %13 0 "_GLF_uniform_int_values"
84 OpName %51 "_GLF_color"
85 OpDecorate %12 ArrayStride 16
86 OpMemberDecorate %13 0 Offset 0
88 OpDecorate %15 DescriptorSet 0
89 OpDecorate %15 Binding 0
90 OpDecorate %51 Location 0
92 %3 = OpTypeFunction %2
94 %7 = OpTypePointer Function %6
95 %9 = OpConstant %6 -25236
97 %11 = OpConstant %10 4
98 %12 = OpTypeArray %6 %11
99 %13 = OpTypeStruct %12
100 %14 = OpTypePointer Uniform %13
101 %15 = OpVariable %14 Uniform
102 %16 = OpConstant %6 0
103 %17 = OpConstant %6 3
104 %18 = OpTypePointer Uniform %6
105 %23 = OpConstant %6 2
107 %37 = OpConstant %6 1
109 %49 = OpTypeVector %48 4
110 %50 = OpTypePointer Output %49
111 %51 = OpVariable %50 Output
112 %4 = OpFunction %2 None %3
114 %8 = OpVariable %7 Function
115 %22 = OpVariable %7 Function
116 %19 = OpAccessChain %18 %15 %16 %17
118 %21 = OpBitwiseOr %6 %9 %20
120 %24 = OpAccessChain %18 %15 %16 %23
125 OpLoopMerge %28 %29 None
129 %32 = OpAccessChain %18 %15 %16 %16
131 %35 = OpSLessThan %34 %31 %33
132 OpBranchConditional %35 %27 %28
135 %38 = OpIAdd %6 %36 %37
140 %40 = OpIAdd %6 %39 %37
145 %42 = OpAccessChain %18 %15 %16 %37
147 %44 = OpSNegate %6 %43
148 %45 = OpIEqual %34 %41 %44
149 OpSelectionMerge %47 None
150 OpBranchConditional %45 %46 %65
152 %52 = OpAccessChain %18 %15 %16 %17
154 %54 = OpConvertSToF %48 %53
155 %55 = OpAccessChain %18 %15 %16 %23
157 %57 = OpConvertSToF %48 %56
158 %58 = OpAccessChain %18 %15 %16 %23
160 %60 = OpConvertSToF %48 %59
161 %61 = OpAccessChain %18 %15 %16 %17
163 %63 = OpConvertSToF %48 %62
164 %64 = OpCompositeConstruct %49 %54 %57 %60 %63
168 %66 = OpAccessChain %18 %15 %16 %23
170 %68 = OpConvertSToF %48 %67
171 %69 = OpCompositeConstruct %49 %68 %68 %68 %68
179 # uniforms for variant
181 # _GLF_uniform_int_values
182 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
186 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
188 PIPELINE graphics variant_pipeline
189 ATTACH variant_vertex_shader
190 ATTACH variant_fragment_shader
191 FRAMEBUFFER_SIZE 32 32
192 BIND BUFFER variant_framebuffer AS color LOCATION 0
193 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
195 CLEAR_COLOR variant_pipeline 0 0 0 255
197 CLEAR variant_pipeline
198 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
200 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255