• 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 single store elimination path.
21
22# The test passes because shader always writes red.
23
24# Optimized using spirv-opt with the following arguments:
25# '--if-conversion'
26# '--eliminate-local-single-block'
27# '--redundancy-elimination'
28# '--reduce-load-size'
29# spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
30
31
32
33SHADER vertex variant_vertex_shader PASSTHROUGH
34
35# variant_fragment_shader is derived from the following GLSL:
36# #version 310 es
37# precision highp float;
38# precision highp int;
39#
40# layout(location = 0) out vec4 _GLF_color;
41# layout(set = 0, binding = 0) uniform buf0
42# {
43#     int one;
44# };
45#
46# void main()
47# {
48#     ivec2 v0 = ivec2(0);
49#     ivec2 v1 = ivec2(2);
50#     int a = one;
51#
52#     do
53#     {
54#         // Always false.
55#         if (a > 10)
56#         {
57#             _GLF_color = vec4(0);
58#             return;
59#         }
60#
61#         v0 = v1.x > a ? ivec2(0) : ivec2(1);
62#         a++;
63#     } while(a < 9);
64#
65#     // After the loop v0 == (1, 1).
66#
67#     if(v1.x > 1)
68#         v0 += ivec2(1);
69#
70#     if (v0 == ivec2(2))
71#         _GLF_color = vec4(1, 0, 0, 1);
72#     else
73#         _GLF_color = vec4(0);
74# }
75SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
76; SPIR-V
77; Version: 1.0
78; Generator: Khronos Glslang Reference Front End; 8
79; Bound: 71
80; Schema: 0
81               OpCapability Shader
82          %1 = OpExtInstImport "GLSL.std.450"
83               OpMemoryModel Logical GLSL450
84               OpEntryPoint Fragment %4 "main" %36
85               OpExecutionMode %4 OriginUpperLeft
86               OpSource ESSL 310
87               OpName %4 "main"
88               OpName %9 "v0"
89               OpName %12 "v1"
90               OpName %16 "a"
91               OpName %17 "buf0"
92               OpMemberName %17 0 "one"
93               OpName %19 ""
94               OpName %36 "_GLF_color"
95               OpMemberDecorate %17 0 Offset 0
96               OpDecorate %17 Block
97               OpDecorate %19 DescriptorSet 0
98               OpDecorate %19 Binding 0
99               OpDecorate %36 Location 0
100          %2 = OpTypeVoid
101          %3 = OpTypeFunction %2
102          %6 = OpTypeInt 32 1
103          %7 = OpTypeVector %6 2
104          %8 = OpTypePointer Function %7
105         %10 = OpConstant %6 0
106         %11 = OpConstantComposite %7 %10 %10
107         %13 = OpConstant %6 2
108         %14 = OpConstantComposite %7 %13 %13
109         %15 = OpTypePointer Function %6
110         %17 = OpTypeStruct %6
111         %18 = OpTypePointer Uniform %17
112         %19 = OpVariable %18 Uniform
113         %20 = OpTypePointer Uniform %6
114         %28 = OpConstant %6 10
115         %29 = OpTypeBool
116         %33 = OpTypeFloat 32
117         %34 = OpTypeVector %33 4
118         %35 = OpTypePointer Output %34
119         %36 = OpVariable %35 Output
120         %37 = OpConstant %33 0
121         %38 = OpConstantComposite %34 %37 %37 %37 %37
122         %40 = OpTypeInt 32 0
123         %41 = OpConstant %40 0
124         %46 = OpConstant %6 1
125         %47 = OpConstantComposite %7 %46 %46
126         %48 = OpTypeVector %29 2
127         %54 = OpConstant %6 9
128         %68 = OpConstant %33 1
129         %69 = OpConstantComposite %34 %68 %37 %37 %68
130          %4 = OpFunction %2 None %3
131          %5 = OpLabel
132          %9 = OpVariable %8 Function
133         %12 = OpVariable %8 Function
134         %16 = OpVariable %15 Function
135               OpStore %9 %11
136               OpStore %12 %14
137         %21 = OpAccessChain %20 %19 %10
138         %22 = OpLoad %6 %21
139               OpStore %16 %22
140               OpBranch %23
141         %23 = OpLabel
142               OpLoopMerge %25 %26 None
143               OpBranch %24
144         %24 = OpLabel
145         %27 = OpLoad %6 %16
146         %30 = OpSGreaterThan %29 %27 %28
147               OpSelectionMerge %32 None
148               OpBranchConditional %30 %31 %32
149         %31 = OpLabel
150               OpStore %36 %38
151               OpReturn
152         %32 = OpLabel
153         %42 = OpAccessChain %15 %12 %41
154         %43 = OpLoad %6 %42
155         %44 = OpLoad %6 %16
156         %45 = OpSGreaterThan %29 %43 %44
157         %49 = OpCompositeConstruct %48 %45 %45
158         %50 = OpSelect %7 %49 %11 %47
159               OpStore %9 %50
160         %52 = OpIAdd %6 %44 %46
161               OpStore %16 %52
162               OpBranch %26
163         %26 = OpLabel
164         %53 = OpLoad %6 %16
165         %55 = OpSLessThan %29 %53 %54
166               OpBranchConditional %55 %23 %25
167         %25 = OpLabel
168         %57 = OpLoad %6 %42
169         %58 = OpSGreaterThan %29 %57 %46
170               OpSelectionMerge %60 None
171               OpBranchConditional %58 %59 %60
172         %59 = OpLabel
173         %61 = OpLoad %7 %9
174         %62 = OpIAdd %7 %61 %47
175               OpStore %9 %62
176               OpBranch %60
177         %60 = OpLabel
178         %63 = OpLoad %7 %9
179         %64 = OpIEqual %48 %63 %14
180         %65 = OpAll %29 %64
181               OpSelectionMerge %67 None
182               OpBranchConditional %65 %66 %70
183         %66 = OpLabel
184               OpStore %36 %69
185               OpBranch %67
186         %70 = OpLabel
187               OpStore %36 %38
188               OpBranch %67
189         %67 = OpLabel
190               OpReturn
191               OpFunctionEnd
192END
193
194# uniforms for variant
195
196# one
197BUFFER variant_one DATA_TYPE int32 DATA
198 1
199END
200
201BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
202
203PIPELINE graphics variant_pipeline
204  ATTACH variant_vertex_shader
205  ATTACH variant_fragment_shader
206  FRAMEBUFFER_SIZE 256 256
207  BIND BUFFER variant_framebuffer AS color LOCATION 0
208  BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
209END
210CLEAR_COLOR variant_pipeline 0 0 0 255
211
212CLEAR variant_pipeline
213RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
214
215EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
216