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 DAG combiner 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 # precision highp float;
29 # precision highp int;
31 # layout(location = 0) out vec4 _GLF_color;
33 # layout(set = 0, binding = 0) uniform buf0
37 # layout(set = 0, binding = 1) uniform buf1
47 # for(int i = 0; i < ten; i++)
49 # // Breaks when i == 3.
53 # // Increments a by 2.
54 # a += minusEight / -4;
59 # _GLF_color = vec4(1, 0, 0, 1);
61 # _GLF_color = vec4(0);
63 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
66 ; Generator: Khronos Glslang Reference Front End; 8
70 %1 = OpExtInstImport "GLSL.std.450"
71 OpMemoryModel Logical GLSL450
72 OpEntryPoint Fragment %4 "main" %54
73 OpExecutionMode %4 OriginUpperLeft
80 OpMemberName %18 0 "ten"
83 OpMemberName %32 0 "minusEight"
85 OpName %54 "_GLF_color"
86 OpMemberDecorate %18 0 Offset 0
88 OpDecorate %20 DescriptorSet 0
89 OpDecorate %20 Binding 1
90 OpMemberDecorate %32 0 Offset 0
92 OpDecorate %34 DescriptorSet 0
93 OpDecorate %34 Binding 0
94 OpDecorate %54 Location 0
96 %3 = OpTypeFunction %2
98 %7 = OpTypePointer Function %6
100 %18 = OpTypeStruct %6
101 %19 = OpTypePointer Uniform %18
102 %20 = OpVariable %19 Uniform
103 %21 = OpTypePointer Uniform %6
105 %27 = OpConstant %6 5
106 %32 = OpTypeStruct %6
107 %33 = OpTypePointer Uniform %32
108 %34 = OpVariable %33 Uniform
109 %37 = OpConstant %6 -4
110 %42 = OpConstant %6 1
111 %47 = OpConstant %6 3
113 %52 = OpTypeVector %51 4
114 %53 = OpTypePointer Output %52
115 %54 = OpVariable %53 Output
116 %55 = OpConstant %51 1
117 %56 = OpConstant %51 0
118 %57 = OpConstantComposite %52 %55 %56 %56 %55
119 %59 = OpConstantComposite %52 %56 %56 %56 %56
120 %4 = OpFunction %2 None %3
122 %8 = OpVariable %7 Function
123 %10 = OpVariable %7 Function
124 %11 = OpVariable %7 Function
130 OpLoopMerge %14 %15 None
134 %22 = OpAccessChain %21 %20 %9
136 %25 = OpSLessThan %24 %17 %23
137 OpBranchConditional %25 %13 %14
140 %28 = OpSGreaterThan %24 %26 %27
141 OpSelectionMerge %30 None
142 OpBranchConditional %28 %29 %30
146 %35 = OpAccessChain %21 %34 %9
148 %38 = OpSDiv %6 %36 %37
150 %40 = OpIAdd %6 %39 %38
153 %43 = OpIAdd %6 %41 %42
158 %45 = OpIAdd %6 %44 %42
163 %48 = OpIEqual %24 %46 %47
164 OpSelectionMerge %50 None
165 OpBranchConditional %48 %49 %58
177 # uniforms for variant
180 BUFFER variant_minuseight DATA_TYPE int32 DATA
184 BUFFER variant_ten DATA_TYPE int32 DATA
188 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
190 PIPELINE graphics variant_pipeline
191 ATTACH variant_vertex_shader
192 ATTACH variant_fragment_shader
193 FRAMEBUFFER_SIZE 256 256
194 BIND BUFFER variant_framebuffer AS color LOCATION 0
195 BIND BUFFER variant_minuseight AS uniform DESCRIPTOR_SET 0 BINDING 0
196 BIND BUFFER variant_ten AS uniform DESCRIPTOR_SET 0 BINDING 1
198 CLEAR_COLOR variant_pipeline 0 0 0 255
200 CLEAR variant_pipeline
201 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
203 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255