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 float;
33 # precision highp int;
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];
41 # layout(location = 0) out vec4 _GLF_color;
46 # for( i = _int_1; i < _int_10; i++)
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" %53
85 OpExecutionMode %4 OriginUpperLeft
90 OpMemberName %13 0 "_GLF_uniform_int_values"
92 OpName %53 "_GLF_color"
93 OpDecorate %12 ArrayStride 16
94 OpMemberDecorate %13 0 Offset 0
96 OpDecorate %15 DescriptorSet 0
97 OpDecorate %15 Binding 0
98 OpDecorate %53 Location 0
100 %3 = OpTypeFunction %2
102 %7 = OpTypePointer Function %6
105 %11 = OpConstant %10 3
106 %12 = OpTypeArray %6 %11
107 %13 = OpTypeStruct %12
108 %14 = OpTypePointer Uniform %13
109 %15 = OpVariable %14 Uniform
110 %16 = OpConstant %6 0
111 %17 = OpTypePointer Uniform %6
114 %51 = OpTypeVector %50 4
115 %52 = OpTypePointer Output %51
116 %53 = OpVariable %52 Output
117 %57 = OpConstant %6 2
118 %4 = OpFunction %2 None %3
120 %8 = OpVariable %7 Function
122 %18 = OpAccessChain %17 %15 %16 %9
127 OpLoopMerge %22 %23 None
131 %26 = OpAccessChain %17 %15 %16 %16
133 %29 = OpSLessThan %28 %25 %27
134 OpBranchConditional %29 %21 %22
137 %31 = OpSGreaterThan %28 %30 %16
138 OpSelectionMerge %33 None
139 OpBranchConditional %31 %32 %34
144 OpSelectionMerge %38 None
145 OpSwitch %35 %38 -1 %36 0 %37
156 %43 = OpIAdd %6 %42 %9
161 %45 = OpAccessChain %17 %15 %16 %16
163 %47 = OpIEqual %28 %44 %46
164 OpSelectionMerge %49 None
165 OpBranchConditional %47 %48 %68
167 %54 = OpAccessChain %17 %15 %16 %9
169 %56 = OpConvertSToF %50 %55
170 %58 = OpAccessChain %17 %15 %16 %57
172 %60 = OpConvertSToF %50 %59
173 %61 = OpAccessChain %17 %15 %16 %57
175 %63 = OpConvertSToF %50 %62
176 %64 = OpAccessChain %17 %15 %16 %9
178 %66 = OpConvertSToF %50 %65
179 %67 = OpCompositeConstruct %51 %56 %60 %63 %66
183 %69 = OpAccessChain %17 %15 %16 %57
185 %71 = OpConvertSToF %50 %70
186 %72 = OpCompositeConstruct %51 %71 %71 %71 %71
194 # uniforms for variant
196 # _GLF_uniform_int_values
197 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
201 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
203 PIPELINE graphics variant_pipeline
204 ATTACH variant_vertex_shader
205 ATTACH variant_fragment_shader
206 FRAMEBUFFER_SIZE 256 256
207 BIND BUFFER variant_framebuffer AS color LOCATION 0
208 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
210 CLEAR_COLOR variant_pipeline 0 0 0 255
212 CLEAR variant_pipeline
213 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
215 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255