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_2 _GLF_uniform_int_values[2]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [1, 0, 2]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # // Contents of one: 1
42 # layout(push_constant) uniform buf_push
47 # layout(location = 0) out vec4 _GLF_color;
54 # for(b = -1; b <= one; b++)
63 # if(a == -_int_1 && b == _int_2)
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" %69
82 OpExecutionMode %4 OriginUpperLeft
87 OpMemberName %12 0 "_GLF_uniform_int_values"
91 OpMemberName %30 0 "one"
93 OpName %69 "_GLF_color"
94 OpDecorate %11 ArrayStride 16
95 OpMemberDecorate %12 0 Offset 0
97 OpDecorate %14 DescriptorSet 0
98 OpDecorate %14 Binding 0
99 OpMemberDecorate %30 0 Offset 0
101 OpDecorate %69 Location 0
103 %3 = OpTypeFunction %2
105 %7 = OpTypePointer Function %6
107 %10 = OpConstant %9 3
108 %11 = OpTypeArray %6 %10
109 %12 = OpTypeStruct %11
110 %13 = OpTypePointer Uniform %12
111 %14 = OpVariable %13 Uniform
112 %15 = OpConstant %6 0
113 %16 = OpTypePointer Uniform %6
114 %20 = OpConstant %6 1
115 %23 = OpConstant %6 -1
116 %30 = OpTypeStruct %6
117 %31 = OpTypePointer PushConstant %30
118 %32 = OpVariable %31 PushConstant
119 %33 = OpTypePointer PushConstant %6
121 %59 = OpConstant %6 2
123 %67 = OpTypeVector %66 4
124 %68 = OpTypePointer Output %67
125 %69 = OpVariable %68 Output
126 %4 = OpFunction %2 None %3
128 %8 = OpVariable %7 Function
129 %19 = OpVariable %7 Function
130 %17 = OpAccessChain %16 %14 %15 %15
133 %21 = OpAccessChain %16 %14 %15 %20
139 OpLoopMerge %26 %27 None
143 %34 = OpAccessChain %33 %32 %15
145 %37 = OpSLessThanEqual %36 %29 %35
146 OpBranchConditional %37 %25 %26
150 OpLoopMerge %40 %41 None
154 %44 = OpAccessChain %16 %14 %15 %20
156 %46 = OpSGreaterThanEqual %36 %43 %45
157 OpBranchConditional %46 %39 %40
160 %48 = OpISub %6 %47 %20
169 %50 = OpIAdd %6 %49 %20
174 %52 = OpAccessChain %16 %14 %15 %15
176 %54 = OpSNegate %6 %53
177 %55 = OpIEqual %36 %51 %54
178 OpSelectionMerge %57 None
179 OpBranchConditional %55 %56 %57
182 %60 = OpAccessChain %16 %14 %15 %59
184 %62 = OpIEqual %36 %58 %61
187 %63 = OpPhi %36 %55 %26 %62 %56
188 OpSelectionMerge %65 None
189 OpBranchConditional %63 %64 %83
191 %70 = OpAccessChain %16 %14 %15 %15
193 %72 = OpConvertSToF %66 %71
194 %73 = OpAccessChain %16 %14 %15 %20
196 %75 = OpConvertSToF %66 %74
197 %76 = OpAccessChain %16 %14 %15 %20
199 %78 = OpConvertSToF %66 %77
200 %79 = OpAccessChain %16 %14 %15 %15
202 %81 = OpConvertSToF %66 %80
203 %82 = OpCompositeConstruct %67 %72 %75 %78 %81
207 %84 = OpAccessChain %16 %14 %15 %20
209 %86 = OpConvertSToF %66 %85
210 %87 = OpCompositeConstruct %67 %86 %86 %86 %86
218 # uniforms for variant
221 BUFFER variant_one DATA_TYPE int32 STD140 DATA
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 256 256
235 BIND BUFFER variant_framebuffer AS color LOCATION 0
236 BIND BUFFER variant_one AS push_constant
237 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
239 CLEAR_COLOR variant_pipeline 0 0 0 255
241 CLEAR variant_pipeline
242 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
244 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255