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_10 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_0 _GLF_uniform_int_values[2]
32 # precision highp int;
33 # precision highp float;
35 # // Contents of _GLF_uniform_int_values: [10, 1, 0]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
40 # layout(location = 0) out vec4 _GLF_color;
50 # // This case is never his because i starts from one.
52 # if(bitCount(findMSB(_int_1)) > 1)
54 # // This would cause an infinite loop, but it's never executed.
60 # while((i < _int_10));
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" %52
82 OpExecutionMode %4 OriginUpperLeft
87 OpMemberName %12 0 "_GLF_uniform_int_values"
89 OpName %52 "_GLF_color"
90 OpDecorate %11 ArrayStride 16
91 OpMemberDecorate %12 0 Offset 0
93 OpDecorate %14 DescriptorSet 0
94 OpDecorate %14 Binding 0
95 OpDecorate %30 RelaxedPrecision
96 OpDecorate %52 Location 0
98 %3 = OpTypeFunction %2
100 %7 = OpTypePointer Function %6
102 %10 = OpConstant %9 3
103 %11 = OpTypeArray %6 %10
104 %12 = OpTypeStruct %11
105 %13 = OpTypePointer Uniform %12
106 %14 = OpVariable %13 Uniform
107 %15 = OpConstant %6 0
108 %16 = OpConstant %6 1
109 %17 = OpTypePointer Uniform %6
112 %50 = OpTypeVector %49 4
113 %51 = OpTypePointer Output %50
114 %52 = OpVariable %51 Output
115 %56 = OpConstant %6 2
116 %4 = OpFunction %2 None %3
118 %8 = OpVariable %7 Function
119 %18 = OpAccessChain %17 %14 %15 %16
124 OpLoopMerge %22 %23 None
128 OpSelectionMerge %26 None
129 OpSwitch %24 %26 0 %25
131 %27 = OpAccessChain %17 %14 %15 %16
133 %29 = OpExtInst %6 %1 FindSMsb %28
134 %30 = OpBitCount %6 %29
135 %32 = OpSGreaterThan %31 %30 %16
136 OpSelectionMerge %34 None
137 OpBranchConditional %32 %33 %34
144 %38 = OpIAdd %6 %37 %16
149 %40 = OpAccessChain %17 %14 %15 %15
151 %42 = OpSLessThan %31 %39 %41
152 OpBranchConditional %42 %20 %22
155 %44 = OpAccessChain %17 %14 %15 %15
157 %46 = OpIEqual %31 %43 %45
158 OpSelectionMerge %48 None
159 OpBranchConditional %46 %47 %67
161 %53 = OpAccessChain %17 %14 %15 %16
163 %55 = OpConvertSToF %49 %54
164 %57 = OpAccessChain %17 %14 %15 %56
166 %59 = OpConvertSToF %49 %58
167 %60 = OpAccessChain %17 %14 %15 %56
169 %62 = OpConvertSToF %49 %61
170 %63 = OpAccessChain %17 %14 %15 %16
172 %65 = OpConvertSToF %49 %64
173 %66 = OpCompositeConstruct %50 %55 %59 %62 %65
177 %68 = OpAccessChain %17 %14 %15 %56
179 %70 = OpConvertSToF %49 %69
180 %71 = OpCompositeConstruct %50 %70 %70 %70 %70
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