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_3 _GLF_uniform_int_values[1]
30 # #define _int_63 _GLF_uniform_int_values[2]
31 # #define _int_0 _GLF_uniform_int_values[3]
32 # #define _int_1 _GLF_uniform_int_values[4]
33 # #define _float_0_0 _GLF_uniform_float_values[0]
34 # #define _float_1_0 _GLF_uniform_float_values[1]
36 # precision highp float;
37 # precision highp int;
39 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
40 # layout(set = 0, binding = 0) uniform buf0
42 # float _GLF_uniform_float_values[2];
45 # // Contents of _GLF_uniform_int_values: [10, 3, 63, 0, 1]
46 # layout(set = 0, binding = 1) uniform buf1
48 # int _GLF_uniform_int_values[5];
51 # layout(location = 0) out vec4 _GLF_color;
57 # for(int i = _int_0; i < _int_10; i ++)
59 # // b = findMSB(256 - 1) = findMSB(255) = 7
60 # int b = findMSB(256 - _int_1);
61 # // a = a + b - 1 = a + 6
68 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
72 # _GLF_color = vec4(_int_0);
75 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
78 ; Generator: Khronos Glslang Reference Front End; 10
82 %1 = OpExtInstImport "GLSL.std.450"
83 OpMemoryModel Logical GLSL450
84 OpEntryPoint Fragment %4 "main" %59
85 OpExecutionMode %4 OriginUpperLeft
90 OpMemberName %12 0 "_GLF_uniform_int_values"
94 OpName %59 "_GLF_color"
96 OpMemberName %80 0 "_GLF_uniform_float_values"
98 OpDecorate %11 ArrayStride 16
99 OpMemberDecorate %12 0 Offset 0
101 OpDecorate %14 DescriptorSet 0
102 OpDecorate %14 Binding 1
103 OpDecorate %59 Location 0
104 OpDecorate %79 ArrayStride 16
105 OpMemberDecorate %80 0 Offset 0
107 OpDecorate %82 DescriptorSet 0
108 OpDecorate %82 Binding 0
110 %3 = OpTypeFunction %2
112 %7 = OpTypePointer Function %6
114 %10 = OpConstant %9 5
115 %11 = OpTypeArray %6 %10
116 %12 = OpTypeStruct %11
117 %13 = OpTypePointer Uniform %12
118 %14 = OpVariable %13 Uniform
119 %15 = OpConstant %6 0
120 %16 = OpConstant %6 1
121 %17 = OpTypePointer Uniform %6
122 %21 = OpConstant %6 3
124 %35 = OpConstant %6 256
125 %36 = OpConstant %6 4
126 %50 = OpConstant %6 2
128 %57 = OpTypeVector %56 4
129 %58 = OpTypePointer Output %57
130 %59 = OpVariable %58 Output
131 %78 = OpConstant %9 2
132 %79 = OpTypeArray %56 %78
133 %80 = OpTypeStruct %79
134 %81 = OpTypePointer Uniform %80
135 %82 = OpVariable %81 Uniform
136 %4 = OpFunction %2 None %3
138 %8 = OpVariable %7 Function
139 %20 = OpVariable %7 Function
140 %34 = OpVariable %7 Function
141 %18 = OpAccessChain %17 %14 %15 %16
144 %22 = OpAccessChain %17 %14 %15 %21
149 OpLoopMerge %26 %27 None
153 %30 = OpAccessChain %17 %14 %15 %15
155 %33 = OpSLessThan %32 %29 %31
156 OpBranchConditional %33 %25 %26
158 %37 = OpAccessChain %17 %14 %15 %36
160 %39 = OpISub %6 %35 %38
161 %40 = OpExtInst %6 %1 FindSMsb %39
165 %43 = OpIAdd %6 %41 %42
166 %44 = OpAccessChain %17 %14 %15 %36
168 %46 = OpISub %6 %43 %45
173 %48 = OpIAdd %6 %47 %16
178 %51 = OpAccessChain %17 %14 %15 %50
180 %53 = OpIEqual %32 %49 %52
181 OpSelectionMerge %55 None
182 OpBranchConditional %53 %54 %73
184 %60 = OpAccessChain %17 %14 %15 %36
186 %62 = OpConvertSToF %56 %61
187 %63 = OpAccessChain %17 %14 %15 %21
189 %65 = OpConvertSToF %56 %64
190 %66 = OpAccessChain %17 %14 %15 %21
192 %68 = OpConvertSToF %56 %67
193 %69 = OpAccessChain %17 %14 %15 %36
195 %71 = OpConvertSToF %56 %70
196 %72 = OpCompositeConstruct %57 %62 %65 %68 %71
200 %74 = OpAccessChain %17 %14 %15 %21
202 %76 = OpConvertSToF %56 %75
203 %77 = OpCompositeConstruct %57 %76 %76 %76 %76
211 # uniforms for variant
213 # _GLF_uniform_int_values
214 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
217 # _GLF_uniform_float_values
218 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
222 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
224 PIPELINE graphics variant_pipeline
225 ATTACH variant_vertex_shader
226 ATTACH variant_fragment_shader
227 FRAMEBUFFER_SIZE 256 256
228 BIND BUFFER variant_framebuffer AS color LOCATION 0
229 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
230 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
232 CLEAR_COLOR variant_pipeline 0 0 0 255
234 CLEAR variant_pipeline
235 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
237 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255