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