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]
30 # #define _int_9 _GLF_uniform_int_values[2]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [1, 0, 9]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # layout(location = 0) out vec4 _GLF_color;
45 # int msb10 = _int_0 | 1024;
48 # // Iterated nine times.
49 # for(int i = _int_1; i < findLSB(msb10); i++)
57 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
61 # _GLF_color = vec4(_int_0);
64 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67 ; Generator: Khronos Glslang Reference Front End; 10
71 %1 = OpExtInstImport "GLSL.std.450"
72 OpMemoryModel Logical GLSL450
73 OpEntryPoint Fragment %4 "main" %52
74 OpExecutionMode %4 OriginUpperLeft
79 OpMemberName %12 0 "_GLF_uniform_int_values"
83 OpName %52 "_GLF_color"
84 OpDecorate %11 ArrayStride 16
85 OpMemberDecorate %12 0 Offset 0
87 OpDecorate %14 DescriptorSet 0
88 OpDecorate %14 Binding 0
89 OpDecorate %52 Location 0
91 %3 = OpTypeFunction %2
93 %7 = OpTypePointer Function %6
96 %11 = OpTypeArray %6 %10
97 %12 = OpTypeStruct %11
98 %13 = OpTypePointer Uniform %12
99 %14 = OpVariable %13 Uniform
100 %15 = OpConstant %6 0
101 %16 = OpConstant %6 1
102 %17 = OpTypePointer Uniform %6
103 %20 = OpConstant %6 1024
105 %43 = OpConstant %6 2
107 %50 = OpTypeVector %49 4
108 %51 = OpTypePointer Output %50
109 %52 = OpVariable %51 Output
110 %4 = OpFunction %2 None %3
112 %8 = OpVariable %7 Function
113 %22 = OpVariable %7 Function
114 %25 = OpVariable %7 Function
115 %18 = OpAccessChain %17 %14 %15 %16
117 %21 = OpBitwiseOr %6 %19 %20
119 %23 = OpAccessChain %17 %14 %15 %16
122 %26 = OpAccessChain %17 %14 %15 %15
127 OpLoopMerge %30 %31 None
132 %35 = OpExtInst %6 %1 FindILsb %34
133 %37 = OpSLessThan %36 %33 %35
134 OpBranchConditional %37 %29 %30
137 %39 = OpIAdd %6 %38 %16
142 %41 = OpIAdd %6 %40 %16
147 %44 = OpAccessChain %17 %14 %15 %43
149 %46 = OpIEqual %36 %42 %45
150 OpSelectionMerge %48 None
151 OpBranchConditional %46 %47 %66
153 %53 = OpAccessChain %17 %14 %15 %15
155 %55 = OpConvertSToF %49 %54
156 %56 = OpAccessChain %17 %14 %15 %16
158 %58 = OpConvertSToF %49 %57
159 %59 = OpAccessChain %17 %14 %15 %16
161 %61 = OpConvertSToF %49 %60
162 %62 = OpAccessChain %17 %14 %15 %15
164 %64 = OpConvertSToF %49 %63
165 %65 = OpCompositeConstruct %50 %55 %58 %61 %64
169 %67 = OpAccessChain %17 %14 %15 %16
171 %69 = OpConvertSToF %49 %68
172 %70 = OpCompositeConstruct %50 %69 %69 %69 %69
180 # uniforms for variant
182 # _GLF_uniform_int_values
183 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
187 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
189 PIPELINE graphics variant_pipeline
190 ATTACH variant_vertex_shader
191 ATTACH variant_fragment_shader
192 FRAMEBUFFER_SIZE 32 32
193 BIND BUFFER variant_framebuffer AS color LOCATION 0
194 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
196 CLEAR_COLOR variant_pipeline 0 0 0 255
198 CLEAR variant_pipeline
199 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
201 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255