• 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 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# layout(set = 0, binding = 0) uniform buf0
32# {
33#     int one;
34# };
35#
36# void main()
37# {
38#   if (sign(cosh(709.)) == 1. || one == 1)
39#   {
40#     _GLF_color = vec4(1, 0, 0, 1);
41#   }
42#   else
43#   {
44#     _GLF_color = vec4(1);
45#   }
46# }
47SHADER fragment variant_fragment_shader SPIRV-ASM
48; SPIR-V
49; Version: 1.0
50; Generator: Khronos Glslang Reference Front End; 8
51; Bound: 36
52; Schema: 0
53               OpCapability Shader
54          %1 = OpExtInstImport "GLSL.std.450"
55               OpMemoryModel Logical GLSL450
56               OpEntryPoint Fragment %4 "main" %31
57               OpExecutionMode %4 OriginUpperLeft
58               OpSource ESSL 310
59               OpName %4 "main"
60               OpName %17 "buf0"
61               OpMemberName %17 0 "one"
62               OpName %19 ""
63               OpName %31 "_GLF_color"
64               OpMemberDecorate %17 0 RelaxedPrecision
65               OpMemberDecorate %17 0 Offset 0
66               OpDecorate %17 Block
67               OpDecorate %19 DescriptorSet 0
68               OpDecorate %19 Binding 0
69               OpDecorate %23 RelaxedPrecision
70               OpDecorate %31 Location 0
71          %2 = OpTypeVoid
72          %3 = OpTypeFunction %2
73          %6 = OpTypeBool
74          %7 = OpTypeFloat 32
75          %8 = OpConstant %7 709
76         %11 = OpConstant %7 1
77         %16 = OpTypeInt 32 1
78         %17 = OpTypeStruct %16
79         %18 = OpTypePointer Uniform %17
80         %19 = OpVariable %18 Uniform
81         %20 = OpConstant %16 0
82         %21 = OpTypePointer Uniform %16
83         %24 = OpConstant %16 1
84         %29 = OpTypeVector %7 4
85         %30 = OpTypePointer Output %29
86         %31 = OpVariable %30 Output
87         %32 = OpConstant %7 0
88         %33 = OpConstantComposite %29 %11 %32 %32 %11
89         %35 = OpConstantComposite %29 %11 %11 %11 %11
90          %4 = OpFunction %2 None %3
91          %5 = OpLabel
92          %9 = OpExtInst %7 %1 Cosh %8
93         %10 = OpExtInst %7 %1 FSign %9
94         %12 = OpFOrdEqual %6 %10 %11
95         %13 = OpLogicalNot %6 %12
96               OpSelectionMerge %15 None
97               OpBranchConditional %13 %14 %15
98         %14 = OpLabel
99         %22 = OpAccessChain %21 %19 %20
100         %23 = OpLoad %16 %22
101         %25 = OpIEqual %6 %23 %24
102               OpBranch %15
103         %15 = OpLabel
104         %26 = OpPhi %6 %12 %5 %25 %14
105               OpSelectionMerge %28 None
106               OpBranchConditional %26 %27 %34
107         %27 = OpLabel
108               OpStore %31 %33
109               OpBranch %28
110         %34 = OpLabel
111               OpStore %31 %35
112               OpBranch %28
113         %28 = OpLabel
114               OpReturn
115               OpFunctionEnd
116END
117
118# uniforms for variant
119
120# one
121BUFFER variant_one DATA_TYPE int32 DATA
122 1
123END
124
125BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
126
127PIPELINE graphics variant_pipeline
128  ATTACH variant_vertex_shader
129  ATTACH variant_fragment_shader
130  FRAMEBUFFER_SIZE 256 256
131  BIND BUFFER variant_framebuffer AS color LOCATION 0
132  BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
133END
134CLEAR_COLOR variant_pipeline 0 0 0 255
135
136CLEAR variant_pipeline
137RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
138
139EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
140