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 GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific shader simplification path.
22 # The test passes because shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
31 # layout(location = 0) out vec4 _GLF_color;
32 # layout(set = 0, binding = 0) uniform buf0
42 # int func(inout S s, int x)
57 # for(int i = 0; i < 5 + one; i++)
60 # a = func(arr[0], i);
62 # a = func(arr[0], 1);
66 # _GLF_color = vec4(1, 0, 0, 1);
68 # _GLF_color = vec4(0);
70 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73 ; Generator: Khronos Glslang Reference Front End; 8
77 %1 = OpExtInstImport "GLSL.std.450"
78 OpMemoryModel Logical GLSL450
79 OpEntryPoint Fragment %4 "main" %89
80 OpExecutionMode %4 OriginUpperLeft
84 OpMemberName %7 0 "data"
85 OpName %13 "func(struct-S-i11;i1;"
91 OpMemberName %38 0 "one"
98 OpName %89 "_GLF_color"
99 OpMemberDecorate %7 0 RelaxedPrecision
100 OpDecorate %13 RelaxedPrecision
101 OpDecorate %12 RelaxedPrecision
102 OpDecorate %17 RelaxedPrecision
103 OpDecorate %23 RelaxedPrecision
104 OpDecorate %25 RelaxedPrecision
105 OpDecorate %26 RelaxedPrecision
106 OpDecorate %29 RelaxedPrecision
107 OpDecorate %32 RelaxedPrecision
108 OpMemberDecorate %38 0 RelaxedPrecision
109 OpMemberDecorate %38 0 Offset 0
111 OpDecorate %40 DescriptorSet 0
112 OpDecorate %40 Binding 0
113 OpDecorate %43 RelaxedPrecision
114 OpDecorate %45 RelaxedPrecision
115 OpDecorate %51 RelaxedPrecision
116 OpDecorate %54 RelaxedPrecision
117 OpDecorate %55 RelaxedPrecision
118 OpDecorate %57 RelaxedPrecision
119 OpDecorate %59 RelaxedPrecision
120 OpDecorate %67 RelaxedPrecision
121 OpDecorate %68 RelaxedPrecision
122 OpDecorate %76 RelaxedPrecision
123 OpDecorate %79 RelaxedPrecision
124 OpDecorate %80 RelaxedPrecision
125 OpDecorate %81 RelaxedPrecision
126 OpDecorate %89 Location 0
128 %3 = OpTypeFunction %2
131 %8 = OpTypePointer Function %7
132 %9 = OpTypePointer Function %6
133 %10 = OpTypeFunction %6 %8 %9
134 %15 = OpConstant %6 0
135 %18 = OpConstant %6 1
138 %34 = OpConstant %33 1
139 %35 = OpTypeArray %7 %34
140 %36 = OpTypePointer Function %35
141 %38 = OpTypeStruct %6
142 %39 = OpTypePointer Uniform %38
143 %40 = OpVariable %39 Uniform
144 %41 = OpTypePointer Uniform %6
145 %52 = OpConstant %6 5
146 %58 = OpConstant %6 2
147 %82 = OpConstant %6 6
149 %87 = OpTypeVector %86 4
150 %88 = OpTypePointer Output %87
151 %89 = OpVariable %88 Output
152 %90 = OpConstant %86 1
153 %91 = OpConstant %86 0
154 %92 = OpConstantComposite %87 %90 %91 %91 %90
155 %94 = OpConstantComposite %87 %91 %91 %91 %91
156 %4 = OpFunction %2 None %3
158 %32 = OpVariable %9 Function
159 %37 = OpVariable %36 Function
160 %45 = OpVariable %9 Function
161 %63 = OpVariable %8 Function
162 %66 = OpVariable %9 Function
163 %72 = OpVariable %8 Function
164 %75 = OpVariable %9 Function
166 %42 = OpAccessChain %41 %40 %15
168 %44 = OpAccessChain %9 %37 %15 %15
173 OpLoopMerge %48 %49 None
177 %53 = OpAccessChain %41 %40 %15
179 %55 = OpIAdd %6 %52 %54
180 %56 = OpSLessThan %19 %51 %55
181 OpBranchConditional %56 %47 %48
184 %59 = OpSMod %6 %57 %58
185 %60 = OpINotEqual %19 %59 %15
186 OpSelectionMerge %62 None
187 OpBranchConditional %60 %61 %71
189 %64 = OpAccessChain %8 %37 %15
194 %68 = OpFunctionCall %6 %13 %63 %66
196 %70 = OpAccessChain %8 %37 %15
201 %73 = OpAccessChain %8 %37 %15
205 %76 = OpFunctionCall %6 %13 %72 %75
207 %78 = OpAccessChain %8 %37 %15
215 %80 = OpIAdd %6 %79 %18
220 %83 = OpIEqual %19 %81 %82
221 OpSelectionMerge %85 None
222 OpBranchConditional %83 %84 %93
232 %13 = OpFunction %6 None %10
233 %11 = OpFunctionParameter %8
234 %12 = OpFunctionParameter %9
236 %16 = OpAccessChain %9 %11 %15
238 %20 = OpIEqual %19 %17 %18
239 OpSelectionMerge %22 None
240 OpBranchConditional %20 %21 %28
243 %24 = OpAccessChain %9 %11 %15
245 %26 = OpIAdd %6 %23 %25
255 # uniforms for variant
258 BUFFER variant_one DATA_TYPE int32 DATA
262 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
264 PIPELINE graphics variant_pipeline
265 ATTACH variant_vertex_shader
266 ATTACH variant_fragment_shader
267 FRAMEBUFFER_SIZE 256 256
268 BIND BUFFER variant_framebuffer AS color LOCATION 0
269 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
271 CLEAR_COLOR variant_pipeline 0 0 0 255
273 CLEAR variant_pipeline
274 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
276 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255