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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0 {
36 # int _GLF_uniform_int_values[2];
39 # const int _GLF_global_loop_bound = 10;
40 # int _GLF_global_loop_count = 0;
42 # layout(location = 0) out vec4 _GLF_color;
46 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
49 # for(int i = _int_1; i > _int_0 && _GLF_global_loop_count < _GLF_global_loop_bound; i--)
52 # for(int i = _int_1; i != _int_0 && _GLF_global_loop_count < _GLF_global_loop_bound; i--)
54 # // Uninitialized here, but this gets a value in the while loop below.
57 # // Iterated ten times.
58 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
60 # _GLF_global_loop_count++;
64 # _GLF_color = vec4(_int_0);
73 # _GLF_color = vec4(_int_0);
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; Generator: Khronos Glslang Reference Front End; 10
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %13
88 OpExecutionMode %4 OriginUpperLeft
91 OpName %8 "_GLF_global_loop_count"
92 OpName %13 "_GLF_color"
94 OpMemberName %17 0 "_GLF_uniform_int_values"
99 OpDecorate %13 Location 0
100 OpDecorate %16 ArrayStride 16
101 OpMemberDecorate %17 0 Offset 0
103 OpDecorate %19 DescriptorSet 0
104 OpDecorate %19 Binding 0
106 %3 = OpTypeFunction %2
108 %7 = OpTypePointer Private %6
109 %8 = OpVariable %7 Private
112 %11 = OpTypeVector %10 4
113 %12 = OpTypePointer Output %11
114 %13 = OpVariable %12 Output
116 %15 = OpConstant %14 2
117 %16 = OpTypeArray %6 %15
118 %17 = OpTypeStruct %16
119 %18 = OpTypePointer Uniform %17
120 %19 = OpVariable %18 Uniform
121 %20 = OpTypePointer Uniform %6
122 %24 = OpConstant %6 1
123 %35 = OpTypePointer Function %6
125 %50 = OpConstant %6 10
126 %77 = OpTypePointer Function %11
127 %4 = OpFunction %2 None %3
129 %36 = OpVariable %35 Function
130 %53 = OpVariable %35 Function
131 %78 = OpVariable %77 Function
133 %21 = OpAccessChain %20 %19 %9 %9
135 %23 = OpConvertSToF %10 %22
136 %25 = OpAccessChain %20 %19 %9 %24
138 %27 = OpConvertSToF %10 %26
139 %28 = OpAccessChain %20 %19 %9 %24
141 %30 = OpConvertSToF %10 %29
142 %31 = OpAccessChain %20 %19 %9 %9
144 %33 = OpConvertSToF %10 %32
145 %34 = OpCompositeConstruct %11 %23 %27 %30 %33
147 %37 = OpAccessChain %20 %19 %9 %9
152 OpLoopMerge %41 %42 None
156 %45 = OpAccessChain %20 %19 %9 %24
158 %48 = OpSGreaterThan %47 %44 %46
160 %51 = OpSLessThan %47 %49 %50
161 %52 = OpLogicalAnd %47 %48 %51
162 OpBranchConditional %52 %40 %41
164 %54 = OpAccessChain %20 %19 %9 %9
169 OpLoopMerge %58 %59 None
173 %62 = OpAccessChain %20 %19 %9 %24
175 %64 = OpINotEqual %47 %61 %63
177 %66 = OpSLessThan %47 %65 %50
178 %67 = OpLogicalAnd %47 %64 %66
179 OpBranchConditional %67 %57 %58
183 OpLoopMerge %70 %71 None
187 %74 = OpSLessThan %47 %73 %50
188 OpBranchConditional %74 %69 %70
191 %76 = OpIAdd %6 %75 %24
199 %80 = OpAccessChain %20 %19 %9 %24
201 %82 = OpConvertSToF %10 %81
202 %83 = OpCompositeConstruct %11 %82 %82 %82 %82
204 %84 = OpAccessChain %20 %19 %9 %9
206 %86 = OpAccessChain %20 %19 %9 %24
208 %88 = OpSGreaterThan %47 %85 %87
209 OpSelectionMerge %90 None
210 OpBranchConditional %88 %89 %92
216 %93 = OpAccessChain %20 %19 %9 %24
218 %95 = OpConvertSToF %10 %94
219 %96 = OpCompositeConstruct %11 %95 %95 %95 %95
226 %98 = OpISub %6 %97 %24
233 %100 = OpISub %6 %99 %24
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 32 32
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 32 32
262 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255