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 a discard, continue, and return
22 # The test passes because main always writes the color red.
24 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: 06407250a169c6a03b3765e86619075af1a8c187
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # precision highp float;
36 # layout(set = 0, binding = 0) uniform buf0 {
37 # vec2 injectionSwitch;
40 # layout(location = 0) out vec4 _GLF_color;
46 # if(gl_FragCoord.x < 0.0)
48 # if(1.0 > injectionSwitch.y)
62 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
64 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67 ; Generator: Khronos Glslang Reference Front End; 7
71 %1 = OpExtInstImport "GLSL.std.450"
72 OpMemoryModel Logical GLSL450
73 OpEntryPoint Fragment %4 "main" %17 %51
74 OpExecutionMode %4 OriginUpperLeft
77 OpName %17 "gl_FragCoord"
79 OpMemberName %30 0 "injectionSwitch"
81 OpName %51 "_GLF_color"
82 OpDecorate %17 BuiltIn FragCoord
83 OpMemberDecorate %30 0 Offset 0
85 OpDecorate %32 DescriptorSet 0
86 OpDecorate %32 Binding 0
87 OpDecorate %51 Location 0
89 %3 = OpTypeFunction %2
91 %15 = OpTypeVector %6 4
92 %16 = OpTypePointer Input %15
93 %17 = OpVariable %16 Input
95 %19 = OpConstant %18 0
96 %20 = OpTypePointer Input %6
100 %29 = OpTypeVector %6 2
101 %30 = OpTypeStruct %29
102 %31 = OpTypePointer Uniform %30
103 %32 = OpVariable %31 Uniform
105 %34 = OpConstant %33 0
106 %35 = OpConstant %18 1
107 %36 = OpTypePointer Uniform %6
108 %46 = OpConstantFalse %24
109 %50 = OpTypePointer Output %15
110 %51 = OpVariable %50 Output
111 %52 = OpConstantComposite %15 %28 %23 %23 %28
112 %65 = OpConstantTrue %24
113 %4 = OpFunction %2 None %3
117 OpLoopMerge %72 %73 None
120 OpLoopMerge %76 %87 None
123 %79 = OpAccessChain %20 %17 %19
125 %81 = OpFOrdLessThan %24 %80 %23
126 OpSelectionMerge %82 None
127 OpBranchConditional %81 %83 %82
129 %84 = OpAccessChain %36 %32 %34 %35
131 %86 = OpFOrdGreaterThan %24 %28 %85
132 OpSelectionMerge %95 None
133 OpBranchConditional %86 %88 %87
139 OpBranchConditional %46 %75 %76
143 %94 = OpPhi %24 %65 %82 %46 %87
144 OpSelectionMerge %91 None
145 OpBranchConditional %94 %72 %91
156 # uniforms for variant
159 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
163 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
165 PIPELINE graphics variant_pipeline
166 ATTACH variant_vertex_shader
167 ATTACH variant_fragment_shader
168 FRAMEBUFFER_SIZE 256 256
169 BIND BUFFER variant_framebuffer AS color LOCATION 0
170 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
172 CLEAR_COLOR variant_pipeline 0 0 0 255
174 CLEAR variant_pipeline
175 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
177 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255