3 # Copyright 2020 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 a specific tail duplicator code path
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_0 _GLF_uniform_int_values[0]
29 # #define _int_4 _GLF_uniform_int_values[1]
30 # #define _float_0_0 _GLF_uniform_float_values[0]
32 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: 0
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[2];
42 # // Contents of _GLF_uniform_float_values: 0.0
43 # layout(set = 0, binding = 1) uniform buf1
45 # float _GLF_uniform_float_values[1];
48 # layout(location = 0) out vec4 _GLF_color;
52 # vec4 color = vec4(1.0);
54 # for (int i = _int_0; i < _int_4; i++)
60 # for (int j = _int_0; i > i; j++)
62 # for (int k = _int_0; k < i; k++)
64 # color[k] = _float_0_0;
68 # color[i] = _float_0_0;
72 # color[i] = _float_0_0;
79 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
82 ; Generator: Khronos Glslang Reference Front End; 8
86 %1 = OpExtInstImport "GLSL.std.450"
87 OpMemoryModel Logical GLSL450
88 OpEntryPoint Fragment %4 "main" %91
89 OpExecutionMode %4 OriginUpperLeft
95 OpMemberName %18 0 "_GLF_uniform_int_values"
100 OpMemberName %65 0 "_GLF_uniform_float_values"
102 OpName %91 "_GLF_color"
103 OpDecorate %17 ArrayStride 16
104 OpMemberDecorate %18 0 Offset 0
106 OpDecorate %20 DescriptorSet 0
107 OpDecorate %20 Binding 0
108 OpDecorate %64 ArrayStride 16
109 OpMemberDecorate %65 0 Offset 0
111 OpDecorate %67 DescriptorSet 0
112 OpDecorate %67 Binding 1
113 OpDecorate %91 Location 0
115 %3 = OpTypeFunction %2
117 %7 = OpTypeVector %6 4
118 %8 = OpTypePointer Function %7
119 %10 = OpConstant %6 1
120 %11 = OpConstantComposite %7 %10 %10 %10 %10
122 %13 = OpTypePointer Function %12
124 %16 = OpConstant %15 2
125 %17 = OpTypeArray %12 %16
126 %18 = OpTypeStruct %17
127 %19 = OpTypePointer Uniform %18
128 %20 = OpVariable %19 Uniform
129 %21 = OpConstant %12 0
130 %22 = OpTypePointer Uniform %12
131 %31 = OpConstant %12 1
133 %63 = OpConstant %15 1
134 %64 = OpTypeArray %6 %63
135 %65 = OpTypeStruct %64
136 %66 = OpTypePointer Uniform %65
137 %67 = OpVariable %66 Uniform
138 %68 = OpTypePointer Uniform %6
139 %71 = OpTypePointer Function %6
140 %90 = OpTypePointer Output %7
141 %91 = OpVariable %90 Output
142 %4 = OpFunction %2 None %3
144 %9 = OpVariable %8 Function
145 %14 = OpVariable %13 Function
146 %40 = OpVariable %13 Function
147 %51 = OpVariable %13 Function
149 %23 = OpAccessChain %22 %20 %21 %21
154 OpLoopMerge %27 %28 None
158 %32 = OpAccessChain %22 %20 %21 %31
160 %35 = OpSLessThan %34 %30 %33
161 OpBranchConditional %35 %26 %27
164 OpSelectionMerge %39 None
165 OpSwitch %36 %39 1 %37 2 %38
167 %41 = OpAccessChain %22 %20 %21 %21
172 OpLoopMerge %45 %46 None
177 %50 = OpSGreaterThan %34 %48 %49
178 OpBranchConditional %50 %44 %45
180 %52 = OpAccessChain %22 %20 %21 %21
185 OpLoopMerge %56 %57 None
190 %61 = OpSLessThan %34 %59 %60
191 OpBranchConditional %61 %55 %56
194 %69 = OpAccessChain %68 %67 %21 %21
196 %72 = OpAccessChain %71 %9 %62
201 %74 = OpIAdd %12 %73 %31
208 %76 = OpIAdd %12 %75 %31
213 %78 = OpAccessChain %68 %67 %21 %21
215 %80 = OpAccessChain %71 %9 %77
220 %83 = OpAccessChain %68 %67 %21 %21
222 %85 = OpAccessChain %71 %9 %82
229 %89 = OpIAdd %12 %88 %31
239 # uniforms for variant
241 # _GLF_uniform_int_values
242 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
245 # _GLF_uniform_float_values
246 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
250 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
252 PIPELINE graphics variant_pipeline
253 ATTACH variant_vertex_shader
254 ATTACH variant_fragment_shader
255 FRAMEBUFFER_SIZE 256 256
256 BIND BUFFER variant_framebuffer AS color LOCATION 0
257 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
258 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
260 CLEAR_COLOR variant_pipeline 0 0 0 255
262 CLEAR variant_pipeline
263 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
265 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255