3 # Copyright 2019 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a bug found by GraphicsFuzz.
20 # Short description: A shader with a discard in a loop
22 # The test passes because the discard is always reached, so the background colour will remain black.
24 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: 6b072126595dd8c2448eb1fda616251c5e6d7079
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # precision highp float;
36 # precision highp int;
38 # layout(location = 0) out vec4 _GLF_color;
42 # for(int i = 0; i < 10; i++)
44 # if(gl_FragCoord.y < 0.0)
46 # if(gl_FragCoord.x < 0.0)
54 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
56 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
59 ; Generator: Khronos Glslang Reference Front End; 7
63 %1 = OpExtInstImport "GLSL.std.450"
64 OpMemoryModel Logical GLSL450
65 OpEntryPoint Fragment %4 "main" %22 %45
66 OpExecutionMode %4 OriginUpperLeft
69 OpName %22 "gl_FragCoord"
70 OpName %45 "_GLF_color"
71 OpDecorate %22 BuiltIn FragCoord
72 OpDecorate %45 Location 0
74 %3 = OpTypeFunction %2
77 %16 = OpConstant %6 10
80 %20 = OpTypeVector %19 4
81 %21 = OpTypePointer Input %20
82 %22 = OpVariable %21 Input
84 %24 = OpConstant %23 1
85 %25 = OpTypePointer Input %19
86 %28 = OpConstant %19 0
87 %32 = OpConstant %23 0
89 %44 = OpTypePointer Output %20
90 %45 = OpVariable %44 Output
91 %46 = OpConstant %19 1
92 %47 = OpConstantComposite %20 %46 %28 %28 %46
93 %55 = OpConstantFalse %17
94 %58 = OpConstantTrue %17
95 %4 = OpFunction %2 None %3
99 OpLoopMerge %51 %54 None
102 %61 = OpPhi %6 %9 %52 %43 %37
103 %18 = OpSLessThan %17 %61 %16
104 OpLoopMerge %12 %37 None
105 OpBranchConditional %18 %11 %12
107 %26 = OpAccessChain %25 %22 %24
109 %29 = OpFOrdLessThan %17 %27 %28
110 OpSelectionMerge %31 None
111 OpBranchConditional %29 %30 %31
113 %33 = OpAccessChain %25 %22 %32
115 %35 = OpFOrdLessThan %17 %34 %28
116 OpSelectionMerge %63 None
117 OpBranchConditional %35 %36 %37
123 %43 = OpIAdd %6 %61 %42
126 %50 = OpFunctionCall %2 %48
129 %62 = OpPhi %17 %55 %10 %55 %36 %58 %31
130 OpSelectionMerge %59 None
131 OpBranchConditional %62 %51 %59
140 %48 = OpFunction %2 None %3
147 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
149 PIPELINE graphics variant_pipeline
150 ATTACH variant_vertex_shader
151 ATTACH variant_fragment_shader
152 FRAMEBUFFER_SIZE 256 256
153 BIND BUFFER variant_framebuffer AS color LOCATION 0
155 CLEAR_COLOR variant_pipeline 0 0 0 255
157 CLEAR variant_pipeline
158 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
160 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 0 0 0 255