• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2020 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by GraphicsFuzz.
19
20# Short description: A fragment shader that covers a specific DAG combiner code path
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 310 es
28# precision highp float;
29# precision highp int;
30#
31# layout(location = 0) out vec4 _GLF_color;
32#
33# layout(set = 0, binding = 0) uniform buf0
34# {
35#     int minusEight;
36# };
37# layout(set = 0, binding = 1) uniform buf1
38# {
39#     int ten;
40# };
41#
42# void main()
43# {
44#     int a = 0;
45#     int b = 0;
46#
47#     for(int i = 0; i < ten; i++)
48#     {
49#         // Breaks when i == 3.
50#         if(a > 5)
51#             break;
52#
53#         // Increments a by 2.
54#         a += minusEight / -4;
55#         b++;
56#     }
57#
58#     if (b == 3)
59#         _GLF_color = vec4(1, 0, 0, 1);
60#     else
61#         _GLF_color = vec4(0);
62# }
63SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
64; SPIR-V
65; Version: 1.0
66; Generator: Khronos Glslang Reference Front End; 8
67; Bound: 60
68; Schema: 0
69               OpCapability Shader
70          %1 = OpExtInstImport "GLSL.std.450"
71               OpMemoryModel Logical GLSL450
72               OpEntryPoint Fragment %4 "main" %54
73               OpExecutionMode %4 OriginUpperLeft
74               OpSource ESSL 310
75               OpName %4 "main"
76               OpName %8 "a"
77               OpName %10 "b"
78               OpName %11 "i"
79               OpName %18 "buf1"
80               OpMemberName %18 0 "ten"
81               OpName %20 ""
82               OpName %32 "buf0"
83               OpMemberName %32 0 "minusEight"
84               OpName %34 ""
85               OpName %54 "_GLF_color"
86               OpMemberDecorate %18 0 Offset 0
87               OpDecorate %18 Block
88               OpDecorate %20 DescriptorSet 0
89               OpDecorate %20 Binding 1
90               OpMemberDecorate %32 0 Offset 0
91               OpDecorate %32 Block
92               OpDecorate %34 DescriptorSet 0
93               OpDecorate %34 Binding 0
94               OpDecorate %54 Location 0
95          %2 = OpTypeVoid
96          %3 = OpTypeFunction %2
97          %6 = OpTypeInt 32 1
98          %7 = OpTypePointer Function %6
99          %9 = OpConstant %6 0
100         %18 = OpTypeStruct %6
101         %19 = OpTypePointer Uniform %18
102         %20 = OpVariable %19 Uniform
103         %21 = OpTypePointer Uniform %6
104         %24 = OpTypeBool
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
112         %51 = OpTypeFloat 32
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
121          %5 = OpLabel
122          %8 = OpVariable %7 Function
123         %10 = OpVariable %7 Function
124         %11 = OpVariable %7 Function
125               OpStore %8 %9
126               OpStore %10 %9
127               OpStore %11 %9
128               OpBranch %12
129         %12 = OpLabel
130               OpLoopMerge %14 %15 None
131               OpBranch %16
132         %16 = OpLabel
133         %17 = OpLoad %6 %11
134         %22 = OpAccessChain %21 %20 %9
135         %23 = OpLoad %6 %22
136         %25 = OpSLessThan %24 %17 %23
137               OpBranchConditional %25 %13 %14
138         %13 = OpLabel
139         %26 = OpLoad %6 %8
140         %28 = OpSGreaterThan %24 %26 %27
141               OpSelectionMerge %30 None
142               OpBranchConditional %28 %29 %30
143         %29 = OpLabel
144               OpBranch %14
145         %30 = OpLabel
146         %35 = OpAccessChain %21 %34 %9
147         %36 = OpLoad %6 %35
148         %38 = OpSDiv %6 %36 %37
149         %39 = OpLoad %6 %8
150         %40 = OpIAdd %6 %39 %38
151               OpStore %8 %40
152         %41 = OpLoad %6 %10
153         %43 = OpIAdd %6 %41 %42
154               OpStore %10 %43
155               OpBranch %15
156         %15 = OpLabel
157         %44 = OpLoad %6 %11
158         %45 = OpIAdd %6 %44 %42
159               OpStore %11 %45
160               OpBranch %12
161         %14 = OpLabel
162         %46 = OpLoad %6 %10
163         %48 = OpIEqual %24 %46 %47
164               OpSelectionMerge %50 None
165               OpBranchConditional %48 %49 %58
166         %49 = OpLabel
167               OpStore %54 %57
168               OpBranch %50
169         %58 = OpLabel
170               OpStore %54 %59
171               OpBranch %50
172         %50 = OpLabel
173               OpReturn
174               OpFunctionEnd
175END
176
177# uniforms for variant
178
179# minuseight
180BUFFER variant_minuseight DATA_TYPE int32 DATA
181 -8
182END
183# ten
184BUFFER variant_ten DATA_TYPE int32 DATA
185 10
186END
187
188BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
189
190PIPELINE 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
197END
198CLEAR_COLOR variant_pipeline 0 0 0 255
199
200CLEAR variant_pipeline
201RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
202
203EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
204