3 # Copyright 2021 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]
30 # #define _int_5 _GLF_uniform_int_values[2]
31 # #define _int_2 _GLF_uniform_int_values[3]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0, 5, 2]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
41 # layout(location = 0) out vec4 _GLF_color;
47 # // Loops three time until breaks.
48 # for(int i = -_int_5; i < (_int_1 >> _int_1); i++)
60 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
64 # _GLF_color = vec4(_int_0);
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70 ; Generator: Khronos Glslang Reference Front End; 10
74 %1 = OpExtInstImport "GLSL.std.450"
75 OpMemoryModel Logical GLSL450
76 OpEntryPoint Fragment %4 "main" %57
77 OpExecutionMode %4 OriginUpperLeft
82 OpMemberName %12 0 "_GLF_uniform_int_values"
85 OpName %57 "_GLF_color"
86 OpDecorate %11 ArrayStride 16
87 OpMemberDecorate %12 0 Offset 0
89 OpDecorate %14 DescriptorSet 0
90 OpDecorate %14 Binding 0
91 OpDecorate %57 Location 0
93 %3 = OpTypeFunction %2
95 %7 = OpTypePointer Function %6
98 %11 = OpTypeArray %6 %10
99 %12 = OpTypeStruct %11
100 %13 = OpTypePointer Uniform %12
101 %14 = OpVariable %13 Uniform
102 %15 = OpConstant %6 0
103 %16 = OpConstant %6 1
104 %17 = OpTypePointer Uniform %6
105 %21 = OpConstant %6 2
107 %48 = OpConstant %6 3
109 %55 = OpTypeVector %54 4
110 %56 = OpTypePointer Output %55
111 %57 = OpVariable %56 Output
112 %4 = OpFunction %2 None %3
114 %8 = OpVariable %7 Function
115 %20 = OpVariable %7 Function
116 %18 = OpAccessChain %17 %14 %15 %16
119 %22 = OpAccessChain %17 %14 %15 %21
121 %24 = OpSNegate %6 %23
125 OpLoopMerge %27 %28 None
129 %31 = OpAccessChain %17 %14 %15 %15
131 %33 = OpAccessChain %17 %14 %15 %15
133 %35 = OpShiftRightArithmetic %6 %32 %34
134 %37 = OpSLessThan %36 %30 %35
135 OpBranchConditional %37 %26 %27
138 %39 = OpSGreaterThanEqual %36 %38 %21
139 OpSelectionMerge %41 None
140 OpBranchConditional %39 %40 %41
145 %44 = OpIAdd %6 %43 %16
150 %46 = OpIAdd %6 %45 %16
155 %49 = OpAccessChain %17 %14 %15 %48
157 %51 = OpIEqual %36 %47 %50
158 OpSelectionMerge %53 None
159 OpBranchConditional %51 %52 %71
161 %58 = OpAccessChain %17 %14 %15 %15
163 %60 = OpConvertSToF %54 %59
164 %61 = OpAccessChain %17 %14 %15 %16
166 %63 = OpConvertSToF %54 %62
167 %64 = OpAccessChain %17 %14 %15 %16
169 %66 = OpConvertSToF %54 %65
170 %67 = OpAccessChain %17 %14 %15 %15
172 %69 = OpConvertSToF %54 %68
173 %70 = OpCompositeConstruct %55 %60 %63 %66 %69
177 %72 = OpAccessChain %17 %14 %15 %16
179 %74 = OpConvertSToF %54 %73
180 %75 = OpCompositeConstruct %55 %74 %74 %74 %74
188 # uniforms for variant
190 # _GLF_uniform_int_values
191 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
195 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
197 PIPELINE graphics variant_pipeline
198 ATTACH variant_vertex_shader
199 ATTACH variant_fragment_shader
200 FRAMEBUFFER_SIZE 256 256
201 BIND BUFFER variant_framebuffer AS color LOCATION 0
202 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
204 CLEAR_COLOR variant_pipeline 0 0 0 255
206 CLEAR variant_pipeline
207 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
209 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255