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 single block elimination 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;
30 # layout(set = 0, binding = 0) uniform buf0 {
31 # vec2 injectionSwitch;
34 # layout(location = 0) out vec4 _GLF_color;
40 # while(g < int(injectionSwitch.x + 2.0)) {
48 # while(g < int(injectionSwitch.y)) {
56 # _GLF_color = vec4(1, 0, 0, 1);
58 # _GLF_color = vec4(0);
60 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
63 ; Generator: Khronos Glslang Reference Front End; 8
67 %1 = OpExtInstImport "GLSL.std.450"
68 OpMemoryModel Logical GLSL450
69 OpEntryPoint Fragment %4 "main" %58
70 OpExecutionMode %4 OriginUpperLeft
75 OpMemberName %18 0 "injectionSwitch"
78 OpName %58 "_GLF_color"
79 OpDecorate %8 RelaxedPrecision
80 OpDecorate %15 RelaxedPrecision
81 OpMemberDecorate %18 0 Offset 0
83 OpDecorate %20 DescriptorSet 0
84 OpDecorate %20 Binding 0
85 OpDecorate %31 RelaxedPrecision
86 OpDecorate %33 RelaxedPrecision
87 OpDecorate %35 RelaxedPrecision
88 OpDecorate %36 RelaxedPrecision
89 OpDecorate %42 RelaxedPrecision
90 OpDecorate %48 RelaxedPrecision
91 OpDecorate %49 RelaxedPrecision
92 OpDecorate %50 RelaxedPrecision
93 OpDecorate %51 RelaxedPrecision
94 OpDecorate %58 Location 0
96 %3 = OpTypeFunction %2
98 %7 = OpTypePointer Private %6
99 %8 = OpVariable %7 Private
102 %17 = OpTypeVector %16 2
103 %18 = OpTypeStruct %17
104 %19 = OpTypePointer Uniform %18
105 %20 = OpVariable %19 Uniform
107 %22 = OpConstant %21 0
108 %23 = OpTypePointer Uniform %16
109 %26 = OpConstant %16 2
111 %32 = OpConstant %6 1
112 %34 = OpTypePointer Function %6
113 %43 = OpConstant %21 1
114 %52 = OpConstant %6 2
115 %56 = OpTypeVector %16 4
116 %57 = OpTypePointer Output %56
117 %58 = OpVariable %57 Output
118 %59 = OpConstant %16 1
119 %60 = OpConstant %16 0
120 %61 = OpConstantComposite %56 %59 %60 %60 %59
121 %63 = OpConstantComposite %56 %60 %60 %60 %60
122 %4 = OpFunction %2 None %3
124 %35 = OpVariable %34 Function
128 OpLoopMerge %12 %13 None
132 %24 = OpAccessChain %23 %20 %9 %22
134 %27 = OpFAdd %16 %25 %26
135 %28 = OpConvertFToS %6 %27
136 %30 = OpSLessThan %29 %15 %28
137 OpBranchConditional %30 %11 %12
140 %33 = OpIAdd %6 %31 %32
150 OpLoopMerge %39 %40 None
154 %44 = OpAccessChain %23 %20 %9 %43
156 %46 = OpConvertFToS %6 %45
157 %47 = OpSLessThan %29 %42 %46
158 OpBranchConditional %47 %38 %39
161 %49 = OpIAdd %6 %48 %32
170 %53 = OpIEqual %29 %51 %52
171 OpSelectionMerge %55 None
172 OpBranchConditional %53 %54 %62
184 # uniforms for variant
187 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
191 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
193 PIPELINE graphics variant_pipeline
194 ATTACH variant_vertex_shader
195 ATTACH variant_fragment_shader
196 FRAMEBUFFER_SIZE 256 256
197 BIND BUFFER variant_framebuffer AS color LOCATION 0
198 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
200 CLEAR_COLOR variant_pipeline 0 0 0 255
202 CLEAR variant_pipeline
203 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
205 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255