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 instruction simplification code path
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
30 # layout(location = 0) out vec4 _GLF_color;
31 # layout(set = 0, binding = 0) uniform buf0
38 # float f = gl_FragCoord.x;
40 # // (1.0 / 0.0) -> Inf.
41 # // (Inf * 0.0) -> Nan.
43 # f += (1.0 / 0.0) * 0.0;
45 # // Doesn't matter if this is executed or not.
49 # if (isnan(f) || f != zero)
54 # _GLF_color = vec4(1, 0, 0, 1);
56 # _GLF_color = vec4(0);
58 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
61 ; Generator: Khronos Glslang Reference Front End; 8
65 %1 = OpExtInstImport "GLSL.std.450"
66 OpMemoryModel Logical GLSL450
67 OpEntryPoint Fragment %4 "main" %11 %54
68 OpExecutionMode %4 OriginUpperLeft
72 OpName %11 "gl_FragCoord"
74 OpMemberName %37 0 "zero"
76 OpName %54 "_GLF_color"
77 OpDecorate %11 BuiltIn FragCoord
78 OpMemberDecorate %37 0 Offset 0
80 OpDecorate %39 DescriptorSet 0
81 OpDecorate %39 Binding 0
82 OpDecorate %54 Location 0
84 %3 = OpTypeFunction %2
86 %7 = OpTypePointer Function %6
87 %9 = OpTypeVector %6 4
88 %10 = OpTypePointer Input %9
89 %11 = OpVariable %10 Input
91 %13 = OpConstant %12 0
92 %14 = OpTypePointer Input %6
93 %17 = OpConstant %6 -0x1.8p+128
99 %38 = OpTypePointer Uniform %37
100 %39 = OpVariable %38 Uniform
102 %41 = OpConstant %40 0
103 %42 = OpTypePointer Uniform %6
104 %53 = OpTypePointer Output %9
105 %54 = OpVariable %53 Output
106 %55 = OpConstantComposite %9 %28 %23 %23 %28
107 %57 = OpConstantComposite %9 %23 %23 %23 %23
108 %4 = OpFunction %2 None %3
110 %8 = OpVariable %7 Function
111 %15 = OpAccessChain %14 %11 %13
115 %19 = OpFAdd %6 %18 %17
118 %22 = OpFDiv %6 %20 %21
119 %25 = OpFOrdEqual %24 %22 %23
120 OpSelectionMerge %27 None
121 OpBranchConditional %25 %26 %27
124 %30 = OpFAdd %6 %29 %28
129 %32 = OpIsNan %24 %31
130 %33 = OpLogicalNot %24 %32
131 OpSelectionMerge %35 None
132 OpBranchConditional %33 %34 %35
135 %43 = OpAccessChain %42 %39 %41
137 %45 = OpFOrdNotEqual %24 %36 %44
140 %46 = OpPhi %24 %32 %27 %45 %34
141 OpSelectionMerge %48 None
142 OpBranchConditional %46 %47 %48
148 %50 = OpFOrdEqual %24 %49 %23
149 OpSelectionMerge %52 None
150 OpBranchConditional %50 %51 %56
162 # uniforms for variant
165 BUFFER variant_zero DATA_TYPE float DATA
169 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
171 PIPELINE graphics variant_pipeline
172 ATTACH variant_vertex_shader
173 ATTACH variant_fragment_shader
174 FRAMEBUFFER_SIZE 256 256
175 BIND BUFFER variant_framebuffer AS color LOCATION 0
176 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
178 CLEAR_COLOR variant_pipeline 0 0 0 255
180 CLEAR variant_pipeline
181 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
183 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255