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 fragment shader with discards in loops and conditionals
22 # The test passes because the fragment shader writes a red pixel, and then
23 # terminates without further output manipulation (the discards are not
24 # dynamically reachable)
26 SHADER vertex variant_vertex_shader PASSTHROUGH
28 # variant_fragment_shader is derived from the following GLSL:
31 # precision highp float;
33 # layout(location = 0) out vec4 _GLF_color;
37 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
38 # if(int(gl_FragCoord.x) < 2000) {
40 # for(int ll = 0; ; ll++) {
41 # if(gl_FragCoord.x < 0.0) {
48 # if(int(gl_FragCoord.x) >= 2000) {
53 SHADER fragment variant_fragment_shader SPIRV-ASM
56 ; Generator: Khronos Glslang Reference Front End; 7
60 %1 = OpExtInstImport "GLSL.std.450"
61 OpMemoryModel Logical GLSL450
62 OpEntryPoint Fragment %4 "main" %9 %14
63 OpExecutionMode %4 OriginUpperLeft
66 OpName %9 "_GLF_color"
67 OpName %14 "gl_FragCoord"
69 OpDecorate %9 Location 0
70 OpDecorate %14 BuiltIn FragCoord
71 OpDecorate %29 RelaxedPrecision
72 OpDecorate %41 RelaxedPrecision
73 OpDecorate %47 RelaxedPrecision
74 OpDecorate %49 RelaxedPrecision
76 %3 = OpTypeFunction %2
78 %7 = OpTypeVector %6 4
79 %8 = OpTypePointer Output %7
80 %9 = OpVariable %8 Output
83 %12 = OpConstantComposite %7 %10 %11 %11 %10
84 %13 = OpTypePointer Input %7
85 %14 = OpVariable %13 Input
87 %16 = OpConstant %15 0
88 %17 = OpTypePointer Input %6
90 %22 = OpConstant %20 2000
92 %28 = OpTypePointer Function %20
93 %30 = OpConstant %20 0
94 %42 = OpConstant %20 5
95 %48 = OpConstant %20 1
96 %4 = OpFunction %2 None %3
98 %29 = OpVariable %28 Function
100 %18 = OpAccessChain %17 %14 %16
102 %21 = OpConvertFToS %20 %19
103 %24 = OpSLessThan %23 %21 %22
104 OpSelectionMerge %26 None
105 OpBranchConditional %24 %25 %27
112 OpLoopMerge %33 %34 None
115 %35 = OpAccessChain %17 %14 %16
117 %37 = OpFOrdLessThan %23 %36 %11
118 OpSelectionMerge %39 None
119 OpBranchConditional %37 %38 %39
124 %43 = OpSGreaterThanEqual %23 %41 %42
125 OpSelectionMerge %45 None
126 OpBranchConditional %43 %44 %45
133 %49 = OpIAdd %20 %47 %48
137 %50 = OpAccessChain %17 %14 %16
139 %52 = OpConvertFToS %20 %51
140 %53 = OpSGreaterThanEqual %23 %52 %22
141 OpSelectionMerge %55 None
142 OpBranchConditional %53 %54 %55
152 # uniforms for variant
155 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
157 PIPELINE graphics variant_pipeline
158 ATTACH variant_vertex_shader
159 ATTACH variant_fragment_shader
160 FRAMEBUFFER_SIZE 256 256
161 BIND BUFFER variant_framebuffer AS color LOCATION 0
163 CLEAR_COLOR variant_pipeline 0 0 0 255
165 CLEAR variant_pipeline
166 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
168 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255