• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2020 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by GraphicsFuzz.
19
20# Short description: A fragment shader that covers a specific instruction simplification code path
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 310 es
28# precision highp float;
29#
30# layout(location = 0) out vec4 _GLF_color;
31#
32# layout(set = 0, binding = 0) uniform buf0
33# {
34#     float three;
35# };
36#
37# void main()
38# {
39#     // f becomes 3.0 * 2^0 = 3.0.
40#     float f = ldexp(three, 0);
41#
42#     if (f == 3.0)
43#         _GLF_color = vec4(1, 0, 0, 1);
44#     else
45#         _GLF_color = vec4(0);
46# }
47SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
48; SPIR-V
49; Version: 1.0
50; Generator: Khronos Glslang Reference Front End; 8
51; Bound: 32
52; Schema: 0
53               OpCapability Shader
54          %1 = OpExtInstImport "GLSL.std.450"
55               OpMemoryModel Logical GLSL450
56               OpEntryPoint Fragment %4 "main" %26
57               OpExecutionMode %4 OriginUpperLeft
58               OpSource ESSL 310
59               OpName %4 "main"
60               OpName %8 "f"
61               OpName %9 "buf0"
62               OpMemberName %9 0 "three"
63               OpName %11 ""
64               OpName %26 "_GLF_color"
65               OpMemberDecorate %9 0 Offset 0
66               OpDecorate %9 Block
67               OpDecorate %11 DescriptorSet 0
68               OpDecorate %11 Binding 0
69               OpDecorate %26 Location 0
70          %2 = OpTypeVoid
71          %3 = OpTypeFunction %2
72          %6 = OpTypeFloat 32
73          %7 = OpTypePointer Function %6
74          %9 = OpTypeStruct %6
75         %10 = OpTypePointer Uniform %9
76         %11 = OpVariable %10 Uniform
77         %12 = OpTypeInt 32 1
78         %13 = OpConstant %12 0
79         %14 = OpTypePointer Uniform %6
80         %19 = OpConstant %6 3
81         %20 = OpTypeBool
82         %24 = OpTypeVector %6 4
83         %25 = OpTypePointer Output %24
84         %26 = OpVariable %25 Output
85         %27 = OpConstant %6 1
86         %28 = OpConstant %6 0
87         %29 = OpConstantComposite %24 %27 %28 %28 %27
88         %31 = OpConstantComposite %24 %28 %28 %28 %28
89          %4 = OpFunction %2 None %3
90          %5 = OpLabel
91          %8 = OpVariable %7 Function
92         %15 = OpAccessChain %14 %11 %13
93         %16 = OpLoad %6 %15
94         %17 = OpExtInst %6 %1 Ldexp %16 %13
95               OpStore %8 %17
96         %18 = OpLoad %6 %8
97         %21 = OpFOrdEqual %20 %18 %19
98               OpSelectionMerge %23 None
99               OpBranchConditional %21 %22 %30
100         %22 = OpLabel
101               OpStore %26 %29
102               OpBranch %23
103         %30 = OpLabel
104               OpStore %26 %31
105               OpBranch %23
106         %23 = OpLabel
107               OpReturn
108               OpFunctionEnd
109END
110
111# uniforms for variant
112
113# three
114BUFFER variant_three DATA_TYPE float DATA
115 3.0
116END
117
118BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
119
120PIPELINE graphics variant_pipeline
121  ATTACH variant_vertex_shader
122  ATTACH variant_fragment_shader
123  FRAMEBUFFER_SIZE 256 256
124  BIND BUFFER variant_framebuffer AS color LOCATION 0
125  BIND BUFFER variant_three AS uniform DESCRIPTOR_SET 0 BINDING 0
126END
127CLEAR_COLOR variant_pipeline 0 0 0 255
128
129CLEAR variant_pipeline
130RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
131
132EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
133