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_2 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_10 _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: [2, 0, 10, 1]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
42 # layout(location = 0) out vec4 _GLF_color;
49 # for(int i = ((1 - _int_0) << 2) >> 1; i > _int_0 && a < _int_10; i--)
57 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
61 # _GLF_color = vec4(_int_0);
64 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67 ; Generator: Khronos Glslang Reference Front End; 10
71 %1 = OpExtInstImport "GLSL.std.450"
72 OpMemoryModel Logical GLSL450
73 OpEntryPoint Fragment %4 "main" %57
74 OpExecutionMode %4 OriginUpperLeft
79 OpMemberName %12 0 "_GLF_uniform_int_values"
82 OpName %57 "_GLF_color"
83 OpDecorate %11 ArrayStride 16
84 OpMemberDecorate %12 0 Offset 0
86 OpDecorate %14 DescriptorSet 0
87 OpDecorate %14 Binding 0
88 OpDecorate %57 Location 0
90 %3 = OpTypeFunction %2
92 %7 = OpTypePointer Function %6
95 %11 = OpTypeArray %6 %10
96 %12 = OpTypeStruct %11
97 %13 = OpTypePointer Uniform %12
98 %14 = OpVariable %13 Uniform
100 %16 = OpConstant %6 1
101 %17 = OpTypePointer Uniform %6
102 %24 = OpConstant %6 2
105 %55 = OpTypeVector %54 4
106 %56 = OpTypePointer Output %55
107 %57 = OpVariable %56 Output
108 %58 = OpConstant %6 3
109 %4 = OpFunction %2 None %3
111 %8 = OpVariable %7 Function
112 %20 = OpVariable %7 Function
113 %18 = OpAccessChain %17 %14 %15 %16
116 %21 = OpAccessChain %17 %14 %15 %16
118 %23 = OpISub %6 %16 %22
119 %25 = OpShiftLeftLogical %6 %23 %24
120 %26 = OpShiftRightArithmetic %6 %25 %16
124 OpLoopMerge %29 %30 None
128 %34 = OpAccessChain %17 %14 %15 %16
130 %36 = OpSGreaterThan %32 %33 %35
131 OpSelectionMerge %38 None
132 OpBranchConditional %36 %37 %38
135 %40 = OpAccessChain %17 %14 %15 %24
137 %42 = OpSLessThan %32 %39 %41
140 %43 = OpPhi %32 %36 %31 %42 %37
141 OpBranchConditional %43 %28 %29
144 %45 = OpIAdd %6 %44 %16
149 %47 = OpISub %6 %46 %16
154 %49 = OpAccessChain %17 %14 %15 %15
156 %51 = OpIEqual %32 %48 %50
157 OpSelectionMerge %53 None
158 OpBranchConditional %51 %52 %72
160 %59 = OpAccessChain %17 %14 %15 %58
162 %61 = OpConvertSToF %54 %60
163 %62 = OpAccessChain %17 %14 %15 %16
165 %64 = OpConvertSToF %54 %63
166 %65 = OpAccessChain %17 %14 %15 %16
168 %67 = OpConvertSToF %54 %66
169 %68 = OpAccessChain %17 %14 %15 %58
171 %70 = OpConvertSToF %54 %69
172 %71 = OpCompositeConstruct %55 %61 %64 %67 %70
176 %73 = OpAccessChain %17 %14 %15 %16
178 %75 = OpConvertSToF %54 %74
179 %76 = OpCompositeConstruct %55 %75 %75 %75 %75
187 # uniforms for variant
189 # _GLF_uniform_int_values
190 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
194 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
196 PIPELINE graphics variant_pipeline
197 ATTACH variant_vertex_shader
198 ATTACH variant_fragment_shader
199 FRAMEBUFFER_SIZE 32 32
200 BIND BUFFER variant_framebuffer AS color LOCATION 0
201 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
203 CLEAR_COLOR variant_pipeline 0 0 0 255
205 CLEAR variant_pipeline
206 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
208 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255