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:
29 # #define _int_0 _GLF_uniform_int_values[0]
30 # #define _int_1 _GLF_uniform_int_values[1]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [0, 1]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[2];
40 # layout(location = 0) out vec4 _GLF_color;
42 # int arr[128] = int[128](1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
48 # for(int i = 1; i < 8; i ++)
50 # for(int j = 1; j < 8; j ++)
56 # if(gl_FragCoord.x < 0.0)
72 # _GLF_color = vec4(1, _int_0, _int_0, _int_1);
76 # _GLF_color = vec4(_int_0);
79 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
82 ; Generator: Khronos Glslang Reference Front End; 10
86 %1 = OpExtInstImport "GLSL.std.450"
87 OpMemoryModel Logical GLSL450
88 OpEntryPoint Fragment %4 "main" %47 %77
89 OpExecutionMode %4 OriginUpperLeft
96 OpName %47 "gl_FragCoord"
97 OpName %77 "_GLF_color"
99 OpMemberName %81 0 "_GLF_uniform_int_values"
101 OpDecorate %47 BuiltIn FragCoord
102 OpDecorate %77 Location 0
103 OpDecorate %80 ArrayStride 16
104 OpMemberDecorate %81 0 Offset 0
106 OpDecorate %83 DescriptorSet 0
107 OpDecorate %83 Binding 0
109 %3 = OpTypeFunction %2
112 %8 = OpConstant %7 128
113 %9 = OpTypeArray %6 %8
114 %10 = OpTypePointer Private %9
115 %11 = OpVariable %10 Private
116 %12 = OpConstant %6 1
117 %13 = OpConstantComposite %9 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12
118 %14 = OpTypeVector %6 2
119 %15 = OpTypePointer Function %14
120 %17 = OpConstantComposite %14 %12 %12
121 %18 = OpTypePointer Function %6
122 %26 = OpConstant %6 8
124 %38 = OpTypePointer Private %6
126 %45 = OpTypeVector %44 4
127 %46 = OpTypePointer Input %45
128 %47 = OpVariable %46 Input
129 %48 = OpConstant %7 0
130 %49 = OpTypePointer Input %44
131 %52 = OpConstant %44 0
132 %58 = OpConstant %7 1
133 %69 = OpConstant %6 0
134 %76 = OpTypePointer Output %45
135 %77 = OpVariable %76 Output
136 %78 = OpConstant %44 1
137 %79 = OpConstant %7 2
138 %80 = OpTypeArray %6 %79
139 %81 = OpTypeStruct %80
140 %82 = OpTypePointer Uniform %81
141 %83 = OpVariable %82 Uniform
142 %84 = OpTypePointer Uniform %6
143 %4 = OpFunction %2 None %3
145 %16 = OpVariable %15 Function
146 %19 = OpVariable %18 Function
147 %29 = OpVariable %18 Function
153 OpLoopMerge %22 %23 None
157 %28 = OpSLessThan %27 %25 %26
158 OpBranchConditional %28 %21 %22
163 OpLoopMerge %32 %33 None
167 %36 = OpSLessThan %27 %35 %26
168 OpBranchConditional %36 %31 %32
171 %39 = OpAccessChain %38 %11 %37
173 %41 = OpIEqual %27 %40 %12
174 OpSelectionMerge %43 None
175 OpBranchConditional %41 %42 %43
177 %50 = OpAccessChain %49 %47 %48
179 %53 = OpFOrdLessThan %27 %51 %52
180 OpSelectionMerge %55 None
181 OpBranchConditional %53 %54 %55
186 %59 = OpAccessChain %18 %16 %58
193 %61 = OpIAdd %6 %60 %12
200 %63 = OpIAdd %6 %62 %12
204 %64 = OpAccessChain %18 %16 %48
206 %66 = OpAccessChain %18 %16 %58
208 %68 = OpIAdd %6 %65 %67
209 %70 = OpAccessChain %38 %11 %68
211 %71 = OpAccessChain %38 %11 %26
213 %73 = OpIEqual %27 %72 %69
214 OpSelectionMerge %75 None
215 OpBranchConditional %73 %74 %95
217 %85 = OpAccessChain %84 %83 %69 %69
219 %87 = OpConvertSToF %44 %86
220 %88 = OpAccessChain %84 %83 %69 %69
222 %90 = OpConvertSToF %44 %89
223 %91 = OpAccessChain %84 %83 %69 %12
225 %93 = OpConvertSToF %44 %92
226 %94 = OpCompositeConstruct %45 %78 %87 %90 %93
230 %96 = OpAccessChain %84 %83 %69 %69
232 %98 = OpConvertSToF %44 %97
233 %99 = OpCompositeConstruct %45 %98 %98 %98 %98
241 # uniforms for variant
243 # _GLF_uniform_int_values
244 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
248 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
250 PIPELINE graphics variant_pipeline
251 ATTACH variant_vertex_shader
252 ATTACH variant_fragment_shader
253 FRAMEBUFFER_SIZE 256 256
254 BIND BUFFER variant_framebuffer AS color LOCATION 0
255 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
257 CLEAR_COLOR variant_pipeline 0 0 0 255
259 CLEAR variant_pipeline
260 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
262 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255