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_10 _GLF_uniform_int_values[2]
32 # precision highp int;
33 # precision highp float;
35 # // Contents of _GLF_uniform_int_values: [1, 0, 10]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # layout(location = 0) out vec4 _GLF_color;
47 # // Iterates once: min(2, findMSB(1)) = min(2, 0) = 0.
48 # for(int i = 0; i <= min(2, findMSB(1)) && a < _int_10; i++)
56 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
60 # _GLF_color = vec4(_int_0);
63 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
66 ; Generator: Khronos Glslang Reference Front End; 10
70 %1 = OpExtInstImport "GLSL.std.450"
71 OpMemoryModel Logical GLSL450
72 OpEntryPoint Fragment %4 "main" %52
73 OpExecutionMode %4 OriginUpperLeft
78 OpMemberName %12 0 "_GLF_uniform_int_values"
81 OpName %52 "_GLF_color"
82 OpDecorate %11 ArrayStride 16
83 OpMemberDecorate %12 0 Offset 0
85 OpDecorate %14 DescriptorSet 0
86 OpDecorate %14 Binding 0
87 OpDecorate %30 RelaxedPrecision
88 OpDecorate %52 Location 0
90 %3 = OpTypeFunction %2
92 %7 = OpTypePointer Function %6
95 %11 = OpTypeArray %6 %10
96 %12 = OpTypeStruct %11
97 %13 = OpTypePointer Uniform %12
98 %14 = OpVariable %13 Uniform
100 %16 = OpConstant %6 1
101 %17 = OpTypePointer Uniform %6
103 %28 = OpConstant %6 2
105 %50 = OpTypeVector %49 4
106 %51 = OpTypePointer Output %50
107 %52 = OpVariable %51 Output
108 %4 = OpFunction %2 None %3
110 %8 = OpVariable %7 Function
111 %20 = OpVariable %7 Function
112 %18 = OpAccessChain %17 %14 %15 %16
118 OpLoopMerge %23 %24 None
122 %29 = OpExtInst %6 %1 FindSMsb %16
123 %30 = OpExtInst %6 %1 SMin %28 %29
124 %31 = OpSLessThanEqual %26 %27 %30
125 OpSelectionMerge %33 None
126 OpBranchConditional %31 %32 %33
129 %35 = OpAccessChain %17 %14 %15 %28
131 %37 = OpSLessThan %26 %34 %36
134 %38 = OpPhi %26 %31 %25 %37 %32
135 OpBranchConditional %38 %22 %23
138 %40 = OpIAdd %6 %39 %16
143 %42 = OpIAdd %6 %41 %16
148 %44 = OpAccessChain %17 %14 %15 %15
150 %46 = OpIEqual %26 %43 %45
151 OpSelectionMerge %48 None
152 OpBranchConditional %46 %47 %66
154 %53 = OpAccessChain %17 %14 %15 %15
156 %55 = OpConvertSToF %49 %54
157 %56 = OpAccessChain %17 %14 %15 %16
159 %58 = OpConvertSToF %49 %57
160 %59 = OpAccessChain %17 %14 %15 %16
162 %61 = OpConvertSToF %49 %60
163 %62 = OpAccessChain %17 %14 %15 %15
165 %64 = OpConvertSToF %49 %63
166 %65 = OpCompositeConstruct %50 %55 %58 %61 %64
170 %67 = OpAccessChain %17 %14 %15 %16
172 %69 = OpConvertSToF %49 %68
173 %70 = OpCompositeConstruct %50 %69 %69 %69 %69
181 # uniforms for variant
183 # _GLF_uniform_int_values
184 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
188 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
190 PIPELINE graphics variant_pipeline
191 ATTACH variant_vertex_shader
192 ATTACH variant_fragment_shader
193 FRAMEBUFFER_SIZE 32 32
194 BIND BUFFER variant_framebuffer AS color LOCATION 0
195 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
197 CLEAR_COLOR variant_pipeline 0 0 0 255
199 CLEAR variant_pipeline
200 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
202 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255