• 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 uv value comparison as boolean
21
22# The test passes because the shader always writes the color red.
23
24# Optimized using spirv-opt with the following arguments:
25# '--scalar-replacement=100'
26# '--vector-dce'
27# '--redundancy-elimination'
28# '--ccp'
29# '--redundancy-elimination'
30# '--copy-propagate-arrays'
31# '--eliminate-dead-code-aggressive'
32# '--redundancy-elimination'
33# '--vector-dce'
34# '--inline-entry-points-exhaustive'
35# '--private-to-local'
36# '--if-conversion'
37# '--if-conversion'
38# '--eliminate-dead-code-aggressive'
39# '--if-conversion'
40# '--simplify-instructions'
41# '--eliminate-local-multi-store'
42# spirv-opt commit hash: ad7f2c5c4c7f51360e9e079109a9217aa5ba5cc0
43
44
45
46SHADER vertex variant_vertex_shader PASSTHROUGH
47
48# variant_fragment_shader is derived from the following GLSL:
49# #version 310 es
50# precision highp float;
51#
52# layout(location = 0) out vec4 _GLF_color;
53#
54# void main()
55# {
56#   vec2 uv;
57#   bool c1 = uv.y < 0.25;
58#
59#   for (int i = 0; i < 1; i++)
60#   {
61#     _GLF_color = vec4(1.0, 0.0, 0.0, 1.0); // Writes the color red
62#     return;
63#   }
64#   if (c1)
65#   {
66#     return;
67#   }
68# }
69SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70; SPIR-V
71; Version: 1.0
72; Generator: Khronos Glslang Reference Front End; 7
73; Bound: 49
74; Schema: 0
75               OpCapability Shader
76          %1 = OpExtInstImport "GLSL.std.450"
77               OpMemoryModel Logical GLSL450
78               OpEntryPoint Fragment %4 "main" %34
79               OpExecutionMode %4 OriginUpperLeft
80               OpSource ESSL 310
81               OpName %4 "main"
82               OpName %8 "c1"
83               OpName %12 "uv"
84               OpName %22 "i"
85               OpName %34 "_GLF_color"
86               OpDecorate %22 RelaxedPrecision
87               OpDecorate %34 Location 0
88               OpDecorate %39 RelaxedPrecision
89               OpDecorate %40 RelaxedPrecision
90               OpDecorate %45 RelaxedPrecision
91          %2 = OpTypeVoid
92          %3 = OpTypeFunction %2
93          %6 = OpTypeBool
94          %7 = OpTypePointer Function %6
95          %9 = OpTypeFloat 32
96         %10 = OpTypeVector %9 2
97         %11 = OpTypePointer Function %10
98         %13 = OpTypeInt 32 0
99         %14 = OpConstant %13 1
100         %15 = OpTypePointer Function %9
101         %18 = OpConstant %9 0.25
102         %20 = OpTypeInt 32 1
103         %21 = OpTypePointer Function %20
104         %23 = OpConstant %20 0
105         %30 = OpConstant %20 1
106         %32 = OpTypeVector %9 4
107         %33 = OpTypePointer Output %32
108         %34 = OpVariable %33 Output
109         %35 = OpConstant %9 1
110         %36 = OpConstant %9 0
111         %37 = OpConstantComposite %32 %35 %36 %36 %35
112         %47 = OpUndef %20
113         %48 = OpUndef %6
114          %4 = OpFunction %2 None %3
115          %5 = OpLabel
116          %8 = OpVariable %7 Function
117         %12 = OpVariable %11 Function
118         %22 = OpVariable %21 Function
119         %16 = OpAccessChain %15 %12 %14
120         %17 = OpLoad %9 %16
121         %19 = OpFOrdLessThan %6 %17 %18
122               OpStore %8 %19
123               OpStore %22 %23
124               OpBranch %24
125         %24 = OpLabel
126         %46 = OpPhi %6 %19 %5 %48 %27
127         %45 = OpPhi %20 %23 %5 %47 %27
128               OpLoopMerge %26 %27 None
129               OpBranch %28
130         %28 = OpLabel
131         %31 = OpSLessThan %6 %45 %30
132               OpBranchConditional %31 %25 %26
133         %25 = OpLabel
134               OpStore %34 %37
135               OpReturn
136         %27 = OpLabel
137         %39 = OpLoad %20 %22
138         %40 = OpIAdd %20 %39 %30
139               OpStore %22 %40
140               OpBranch %24
141         %26 = OpLabel
142               OpSelectionMerge %43 None
143               OpBranchConditional %46 %42 %43
144         %42 = OpLabel
145               OpReturn
146         %43 = OpLabel
147               OpReturn
148               OpFunctionEnd
149END
150
151# uniforms for variant
152
153
154BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
155
156PIPELINE graphics variant_pipeline
157  ATTACH variant_vertex_shader
158  ATTACH variant_fragment_shader
159  FRAMEBUFFER_SIZE 256 256
160  BIND BUFFER variant_framebuffer AS color LOCATION 0
161END
162CLEAR_COLOR variant_pipeline 0 0 0 255
163
164CLEAR variant_pipeline
165RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
166
167EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
168