3 # Copyright 2020 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 coverage-gap found by GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific return merge path.
22 # The test passes because shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--simplify-instructions'
26 # '--eliminate-dead-branches'
28 # '--private-to-local'
29 # '--eliminate-local-single-block'
30 # '--eliminate-local-single-block'
32 # '--eliminate-local-multi-store'
33 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
37 SHADER vertex variant_vertex_shader PASSTHROUGH
39 # variant_fragment_shader is derived from the following GLSL:
41 # precision highp float;
43 # layout(location = 0) out vec4 _GLF_color;
44 # layout(set = 0, binding = 0) uniform buf0
49 # // Always returns 1.0.
74 # _GLF_color = vec4(1, 0, 0, 1);
76 # _GLF_color = vec4(0);
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; Generator: Khronos Glslang Reference Front End; 8
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %48
88 OpExecutionMode %4 OriginUpperLeft
94 OpMemberName %17 0 "three"
96 OpName %48 "_GLF_color"
97 OpMemberDecorate %17 0 Offset 0
99 OpDecorate %19 DescriptorSet 0
100 OpDecorate %19 Binding 0
101 OpDecorate %48 Location 0
103 %3 = OpTypeFunction %2
105 %7 = OpTypeFunction %6
106 %10 = OpTypePointer Function %6
107 %12 = OpConstant %6 2
108 %17 = OpTypeStruct %6
109 %18 = OpTypePointer Uniform %17
110 %19 = OpVariable %18 Uniform
112 %21 = OpConstant %20 0
113 %22 = OpTypePointer Uniform %6
114 %25 = OpConstant %6 0
116 %36 = OpConstant %6 1
117 %38 = OpConstantFalse %26
118 %46 = OpTypeVector %6 4
119 %47 = OpTypePointer Output %46
120 %48 = OpVariable %47 Output
121 %49 = OpConstantComposite %46 %36 %25 %25 %36
122 %51 = OpConstantComposite %46 %25 %25 %25 %25
123 %4 = OpFunction %2 None %3
125 %42 = OpFunctionCall %6 %8
126 %43 = OpFOrdEqual %26 %42 %36
127 OpSelectionMerge %45 None
128 OpBranchConditional %43 %44 %50
138 %8 = OpFunction %6 None %7
140 %11 = OpVariable %10 Function
144 %53 = OpPhi %6 %12 %9 %36 %16
145 OpLoopMerge %15 %16 None
148 %23 = OpAccessChain %22 %19 %21
150 %27 = OpFOrdEqual %26 %24 %25
151 OpSelectionMerge %29 None
152 OpBranchConditional %27 %28 %29
156 %31 = OpAccessChain %22 %19 %21
158 %33 = OpFOrdEqual %26 %32 %25
159 OpSelectionMerge %35 None
160 OpBranchConditional %33 %34 %35
167 OpBranchConditional %38 %13 %15
169 %52 = OpPhi %6 %53 %28 %36 %16
174 # uniforms for variant
177 BUFFER variant_three DATA_TYPE float DATA
181 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
183 PIPELINE graphics variant_pipeline
184 ATTACH variant_vertex_shader
185 ATTACH variant_fragment_shader
186 FRAMEBUFFER_SIZE 256 256
187 BIND BUFFER variant_framebuffer AS color LOCATION 0
188 BIND BUFFER variant_three AS uniform DESCRIPTOR_SET 0 BINDING 0
190 CLEAR_COLOR variant_pipeline 0 0 0 255
192 CLEAR variant_pipeline
193 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
195 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255