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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_32 _GLF_uniform_int_values[2]
31 # #define _int_8 _GLF_uniform_int_values[3]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [0, 1, 32, 8]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
42 # layout(location = 0) out vec4 _GLF_color;
50 # if(i <= int(gl_FragCoord.x))
55 # // Iterates empty code block for seven times.
56 # for(int j = _int_1; j < _int_8; j++) { }
62 # // Always true because of the framebuffer resolution of 32x32.
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" %18 %65
82 OpExecutionMode %4 OriginUpperLeft
86 OpName %18 "gl_FragCoord"
89 OpMemberName %33 0 "_GLF_uniform_int_values"
91 OpName %65 "_GLF_color"
92 OpDecorate %18 BuiltIn FragCoord
93 OpDecorate %32 ArrayStride 16
94 OpMemberDecorate %33 0 Offset 0
96 OpDecorate %35 DescriptorSet 0
97 OpDecorate %35 Binding 0
98 OpDecorate %65 Location 0
100 %3 = OpTypeFunction %2
102 %7 = OpTypePointer Function %6
105 %16 = OpTypeVector %15 4
106 %17 = OpTypePointer Input %16
107 %18 = OpVariable %17 Input
109 %20 = OpConstant %19 0
110 %21 = OpTypePointer Input %15
112 %31 = OpConstant %19 4
113 %32 = OpTypeArray %6 %31
114 %33 = OpTypeStruct %32
115 %34 = OpTypePointer Uniform %33
116 %35 = OpVariable %34 Uniform
117 %36 = OpConstant %6 1
118 %37 = OpTypePointer Uniform %6
119 %46 = OpConstant %6 3
120 %55 = OpConstant %6 50
121 %58 = OpConstant %6 2
122 %64 = OpTypePointer Output %16
123 %65 = OpVariable %64 Output
124 %4 = OpFunction %2 None %3
126 %8 = OpVariable %7 Function
127 %30 = OpVariable %7 Function
131 OpLoopMerge %12 %13 None
135 %22 = OpAccessChain %21 %18 %20
137 %24 = OpConvertFToS %6 %23
138 %26 = OpSLessThanEqual %25 %14 %24
139 OpSelectionMerge %28 None
140 OpBranchConditional %26 %27 %28
144 %38 = OpAccessChain %37 %35 %9 %36
149 OpLoopMerge %42 %43 None
153 %47 = OpAccessChain %37 %35 %9 %46
155 %49 = OpSLessThan %25 %45 %48
156 OpBranchConditional %49 %41 %42
161 %51 = OpIAdd %6 %50 %36
166 %53 = OpIAdd %6 %52 %36
171 %56 = OpSLessThan %25 %54 %55
172 OpBranchConditional %56 %10 %12
175 %59 = OpAccessChain %37 %35 %9 %58
177 %61 = OpSLessThan %25 %57 %60
178 OpSelectionMerge %63 None
179 OpBranchConditional %61 %62 %79
181 %66 = OpAccessChain %37 %35 %9 %36
183 %68 = OpConvertSToF %15 %67
184 %69 = OpAccessChain %37 %35 %9 %9
186 %71 = OpConvertSToF %15 %70
187 %72 = OpAccessChain %37 %35 %9 %9
189 %74 = OpConvertSToF %15 %73
190 %75 = OpAccessChain %37 %35 %9 %36
192 %77 = OpConvertSToF %15 %76
193 %78 = OpCompositeConstruct %16 %68 %71 %74 %77
197 %80 = OpAccessChain %37 %35 %9 %9
199 %82 = OpConvertSToF %15 %81
200 %83 = OpCompositeConstruct %16 %82 %82 %82 %82
208 # uniforms for variant
210 # _GLF_uniform_int_values
211 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
215 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
217 PIPELINE graphics variant_pipeline
218 ATTACH variant_vertex_shader
219 ATTACH variant_fragment_shader
220 FRAMEBUFFER_SIZE 32 32
221 BIND BUFFER variant_framebuffer AS color LOCATION 0
222 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
224 CLEAR_COLOR variant_pipeline 0 0 0 255
226 CLEAR variant_pipeline
227 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
229 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255