• 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 a for loop condition being always false
21
22# An always false condition is passed to a for loop inside a function. The test passes if red color is written after the for loop.
23
24# Optimized using spirv-opt with the following arguments:
25# '--eliminate-dead-branches'
26# '--merge-blocks'
27# '--vector-dce'
28# '--eliminate-dead-branches'
29# '--merge-blocks'
30# '--eliminate-dead-code-aggressive'
31# '--eliminate-local-single-block'
32# '--private-to-local'
33# '--convert-local-access-chains'
34# '--simplify-instructions'
35# '--eliminate-dead-inserts'
36# '--copy-propagate-arrays'
37# '--simplify-instructions'
38# '--eliminate-dead-code-aggressive'
39# '--eliminate-local-multi-store'
40# spirv-opt commit hash: 9559cdbdf011c487f67f89e2d694bd4a18d5c1e0
41
42SHADER vertex variant_vertex_shader PASSTHROUGH
43
44# variant_fragment_shader is derived from the following GLSL:
45# #version 310 es
46# precision highp float;
47# layout(location=0) out vec4 color;
48#
49# vec3 drawShape(vec2 pos)
50# {
51#  bool c3;
52#  c3 = pos.y < 1.0;
53#  for(
54#      ivec2(8576, 72916);
55#      c3;
56#      bvec2(false, false)
57#  )
58#   {
59#    return vec3(1.0);
60#   }
61#  return vec3(1.0);
62# }
63# void main()
64# {
65#  drawShape(vec2(1.0));
66#  color = vec4(1, 0, 0, 1);
67# }
68SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
69; SPIR-V
70; Version: 1.0
71; Generator: Khronos Glslang Reference Front End; 7
72; Bound: 52
73; Schema: 0
74               OpCapability Shader
75          %1 = OpExtInstImport "GLSL.std.450"
76               OpMemoryModel Logical GLSL450
77               OpEntryPoint Fragment %4 "main" %47
78               OpExecutionMode %4 OriginUpperLeft
79               OpSource ESSL 310
80               OpName %4 "main"
81               OpName %12 "drawShape(vf2;"
82               OpName %11 "pos"
83               OpName %16 "c3"
84               OpName %43 "param"
85               OpName %47 "color"
86               OpDecorate %47 Location 0
87          %2 = OpTypeVoid
88          %3 = OpTypeFunction %2
89          %6 = OpTypeFloat 32
90          %7 = OpTypeVector %6 2
91          %8 = OpTypePointer Function %7
92          %9 = OpTypeVector %6 3
93         %10 = OpTypeFunction %9 %8
94         %14 = OpTypeBool
95         %15 = OpTypePointer Function %14
96         %17 = OpTypeInt 32 0
97         %18 = OpConstant %17 1
98         %19 = OpTypePointer Function %6
99         %22 = OpConstant %6 1
100         %35 = OpConstantComposite %9 %22 %22 %22
101         %42 = OpConstantComposite %7 %22 %22
102         %45 = OpTypeVector %6 4
103         %46 = OpTypePointer Output %45
104         %47 = OpVariable %46 Output
105         %48 = OpConstant %6 0
106         %49 = OpConstantComposite %45 %22 %48 %48 %22
107         %51 = OpUndef %14
108          %4 = OpFunction %2 None %3
109          %5 = OpLabel
110         %43 = OpVariable %8 Function
111               OpStore %43 %42
112         %44 = OpFunctionCall %9 %12 %43
113               OpStore %47 %49
114               OpReturn
115               OpFunctionEnd
116         %12 = OpFunction %9 None %10
117         %11 = OpFunctionParameter %8
118         %13 = OpLabel
119         %16 = OpVariable %15 Function
120         %20 = OpAccessChain %19 %11 %18
121         %21 = OpLoad %6 %20
122         %23 = OpFOrdLessThan %14 %21 %22
123               OpStore %16 %23
124               OpBranch %29
125         %29 = OpLabel
126         %50 = OpPhi %14 %23 %13 %51 %32
127               OpLoopMerge %31 %32 None
128               OpBranchConditional %50 %30 %31
129         %30 = OpLabel
130               OpReturnValue %35
131         %32 = OpLabel
132               OpBranch %29
133         %31 = OpLabel
134               OpReturnValue %35
135               OpFunctionEnd
136END
137
138BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
139
140PIPELINE graphics variant_pipeline
141  ATTACH variant_vertex_shader
142  ATTACH variant_fragment_shader
143  FRAMEBUFFER_SIZE 256 256
144  BIND BUFFER variant_framebuffer AS color LOCATION 0
145END
146CLEAR_COLOR variant_pipeline 0 0 0 255
147
148CLEAR variant_pipeline
149RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
150EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
151