• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2019 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 bug found by GraphicsFuzz.
19
20# Short description: A fragment shader with two loops with breaks
21
22# The test passes because the fragment shader always writes red; the loops do nothing.
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#
30# layout(location = 0) out vec4 _GLF_color;
31#
32# void main()
33# {
34#   vec4 GLF_live15c = vec4(0.0);
35#   for (
36#       int GLF_live15i = 0;
37#       GLF_live15i < 4;
38#       GLF_live15i++)
39#   {
40#     if (GLF_live15i >= 3)
41#     {
42#       break;
43#     }
44#     if (GLF_live15c[1] >= 1.0)
45#     {
46#       GLF_live15c[GLF_live15i] = 1.0;
47#     }
48#   }
49#   vec4 GLF_live15d = vec4(0.0);
50#   for (
51#       int GLF_live15i = 0;
52#       GLF_live15i < 4;
53#       GLF_live15i++)
54#   {
55#     if (GLF_live15i >= 3)
56#     {
57#       break;
58#     }
59#     if (GLF_live15d[1] >= 1.0)
60#     {
61#       GLF_live15d[GLF_live15i] = 1.0;
62#     }
63#   }
64#   _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
65# }
66SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67; SPIR-V
68; Version: 1.0
69; Generator: Khronos Glslang Reference Front End; 7
70; Bound: 71
71; Schema: 0
72               OpCapability Shader
73          %1 = OpExtInstImport "GLSL.std.450"
74               OpMemoryModel Logical GLSL450
75               OpEntryPoint Fragment %4 "main" %69
76               OpExecutionMode %4 OriginUpperLeft
77               OpSource ESSL 310
78               OpName %4 "main"
79               OpName %9 "GLF_live15c"
80               OpName %14 "GLF_live15i"
81               OpName %45 "GLF_live15d"
82               OpName %46 "GLF_live15i"
83               OpName %69 "_GLF_color"
84               OpDecorate %14 RelaxedPrecision
85               OpDecorate %21 RelaxedPrecision
86               OpDecorate %25 RelaxedPrecision
87               OpDecorate %40 RelaxedPrecision
88               OpDecorate %42 RelaxedPrecision
89               OpDecorate %44 RelaxedPrecision
90               OpDecorate %46 RelaxedPrecision
91               OpDecorate %52 RelaxedPrecision
92               OpDecorate %54 RelaxedPrecision
93               OpDecorate %64 RelaxedPrecision
94               OpDecorate %66 RelaxedPrecision
95               OpDecorate %67 RelaxedPrecision
96               OpDecorate %69 Location 0
97          %2 = OpTypeVoid
98          %3 = OpTypeFunction %2
99          %6 = OpTypeFloat 32
100          %7 = OpTypeVector %6 4
101          %8 = OpTypePointer Function %7
102         %10 = OpConstant %6 0
103         %11 = OpConstantComposite %7 %10 %10 %10 %10
104         %12 = OpTypeInt 32 1
105         %13 = OpTypePointer Function %12
106         %15 = OpConstant %12 0
107         %22 = OpConstant %12 4
108         %23 = OpTypeBool
109         %26 = OpConstant %12 3
110         %31 = OpTypeInt 32 0
111         %32 = OpConstant %31 1
112         %33 = OpTypePointer Function %6
113         %36 = OpConstant %6 1
114         %43 = OpConstant %12 1
115         %68 = OpTypePointer Output %7
116         %69 = OpVariable %68 Output
117         %70 = OpConstantComposite %7 %36 %10 %10 %36
118          %4 = OpFunction %2 None %3
119          %5 = OpLabel
120          %9 = OpVariable %8 Function
121         %14 = OpVariable %13 Function
122         %45 = OpVariable %8 Function
123         %46 = OpVariable %13 Function
124               OpStore %9 %11
125               OpStore %14 %15
126               OpBranch %16
127         %16 = OpLabel
128               OpLoopMerge %18 %19 None
129               OpBranch %20
130         %20 = OpLabel
131         %21 = OpLoad %12 %14
132         %24 = OpSLessThan %23 %21 %22
133               OpBranchConditional %24 %17 %18
134         %17 = OpLabel
135         %25 = OpLoad %12 %14
136         %27 = OpSGreaterThanEqual %23 %25 %26
137               OpSelectionMerge %29 None
138               OpBranchConditional %27 %28 %29
139         %28 = OpLabel
140               OpBranch %18
141         %29 = OpLabel
142         %34 = OpAccessChain %33 %9 %32
143         %35 = OpLoad %6 %34
144         %37 = OpFOrdGreaterThanEqual %23 %35 %36
145               OpSelectionMerge %39 None
146               OpBranchConditional %37 %38 %39
147         %38 = OpLabel
148         %40 = OpLoad %12 %14
149         %41 = OpAccessChain %33 %9 %40
150               OpStore %41 %36
151               OpBranch %39
152         %39 = OpLabel
153               OpBranch %19
154         %19 = OpLabel
155         %42 = OpLoad %12 %14
156         %44 = OpIAdd %12 %42 %43
157               OpStore %14 %44
158               OpBranch %16
159         %18 = OpLabel
160               OpStore %45 %11
161               OpStore %46 %15
162               OpBranch %47
163         %47 = OpLabel
164               OpLoopMerge %49 %50 None
165               OpBranch %51
166         %51 = OpLabel
167         %52 = OpLoad %12 %46
168         %53 = OpSLessThan %23 %52 %22
169               OpBranchConditional %53 %48 %49
170         %48 = OpLabel
171         %54 = OpLoad %12 %46
172         %55 = OpSGreaterThanEqual %23 %54 %26
173               OpSelectionMerge %57 None
174               OpBranchConditional %55 %56 %57
175         %56 = OpLabel
176               OpBranch %49
177         %57 = OpLabel
178         %59 = OpAccessChain %33 %45 %32
179         %60 = OpLoad %6 %59
180         %61 = OpFOrdGreaterThanEqual %23 %60 %36
181               OpSelectionMerge %63 None
182               OpBranchConditional %61 %62 %63
183         %62 = OpLabel
184         %64 = OpLoad %12 %46
185         %65 = OpAccessChain %33 %45 %64
186               OpStore %65 %36
187               OpBranch %63
188         %63 = OpLabel
189               OpBranch %50
190         %50 = OpLabel
191         %66 = OpLoad %12 %46
192         %67 = OpIAdd %12 %66 %43
193               OpStore %46 %67
194               OpBranch %47
195         %49 = OpLabel
196               OpStore %69 %70
197               OpReturn
198               OpFunctionEnd
199END
200
201# uniforms for variant
202
203
204BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
205
206PIPELINE graphics variant_pipeline
207  ATTACH variant_vertex_shader
208  ATTACH variant_fragment_shader
209  FRAMEBUFFER_SIZE 256 256
210  BIND BUFFER variant_framebuffer AS color LOCATION 0
211END
212CLEAR_COLOR variant_pipeline 0 0 0 255
213
214CLEAR variant_pipeline
215RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
216
217EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
218