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]
31 # precision highp float;
32 # precision highp int;
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0
37 # int _GLF_uniform_int_values[2];
40 # // Contents of one: 1
41 # layout(set = 0, binding = 1) uniform buf1
46 # layout(location = 0) out vec4 _GLF_color;
50 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
53 # for(int i = _int_1; one != _int_1; _int_1)
55 # _GLF_color = vec4(_int_0);
59 # for(int i = _int_1; i < one; i ++)
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" %9
74 OpExecutionMode %4 OriginUpperLeft
77 OpName %9 "_GLF_color"
79 OpMemberName %14 0 "_GLF_uniform_int_values"
83 OpMemberName %42 0 "one"
86 OpDecorate %9 Location 0
87 OpDecorate %13 ArrayStride 16
88 OpMemberDecorate %14 0 Offset 0
90 OpDecorate %16 DescriptorSet 0
91 OpDecorate %16 Binding 0
92 OpMemberDecorate %42 0 Offset 0
94 OpDecorate %44 DescriptorSet 0
95 OpDecorate %44 Binding 1
97 %3 = OpTypeFunction %2
99 %7 = OpTypeVector %6 4
100 %8 = OpTypePointer Output %7
101 %9 = OpVariable %8 Output
104 %12 = OpConstant %11 2
105 %13 = OpTypeArray %10 %12
106 %14 = OpTypeStruct %13
107 %15 = OpTypePointer Uniform %14
108 %16 = OpVariable %15 Uniform
109 %17 = OpConstant %10 0
110 %18 = OpTypePointer Uniform %10
111 %22 = OpConstant %10 1
112 %33 = OpTypePointer Function %10
113 %42 = OpTypeStruct %10
114 %43 = OpTypePointer Uniform %42
115 %44 = OpVariable %43 Uniform
117 %4 = OpFunction %2 None %3
119 %34 = OpVariable %33 Function
120 %55 = OpVariable %33 Function
121 %19 = OpAccessChain %18 %16 %17 %17
123 %21 = OpConvertSToF %6 %20
124 %23 = OpAccessChain %18 %16 %17 %22
126 %25 = OpConvertSToF %6 %24
127 %26 = OpAccessChain %18 %16 %17 %22
129 %28 = OpConvertSToF %6 %27
130 %29 = OpAccessChain %18 %16 %17 %17
132 %31 = OpConvertSToF %6 %30
133 %32 = OpCompositeConstruct %7 %21 %25 %28 %31
135 %35 = OpAccessChain %18 %16 %17 %17
140 OpLoopMerge %39 %40 None
143 %45 = OpAccessChain %18 %44 %17
145 %47 = OpAccessChain %18 %16 %17 %17
147 %50 = OpINotEqual %49 %46 %48
148 OpBranchConditional %50 %38 %39
150 %51 = OpAccessChain %18 %16 %17 %22
152 %53 = OpConvertSToF %6 %52
153 %54 = OpCompositeConstruct %7 %53 %53 %53 %53
159 %56 = OpAccessChain %18 %16 %17 %17
164 OpLoopMerge %60 %61 None
168 %64 = OpAccessChain %18 %44 %17
170 %66 = OpSLessThan %49 %63 %65
171 OpBranchConditional %66 %59 %60
173 %67 = OpAccessChain %18 %16 %17 %22
175 %69 = OpConvertSToF %6 %68
176 %70 = OpCompositeConstruct %7 %69 %69 %69 %69
181 %72 = OpIAdd %10 %71 %22
189 # uniforms for variant
192 BUFFER variant_one DATA_TYPE int32 STD140 DATA
195 # _GLF_uniform_int_values
196 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
200 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
202 PIPELINE graphics variant_pipeline
203 ATTACH variant_vertex_shader
204 ATTACH variant_fragment_shader
205 FRAMEBUFFER_SIZE 32 32
206 BIND BUFFER variant_framebuffer AS color LOCATION 0
207 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 1
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 32 32
215 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255