• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 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 the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
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 320 es
28#
29# precision highp float;
30# precision highp int;
31#
32# layout(set = 0, binding = 0) uniform buf0
33# {
34#     int one;
35# };
36#
37# layout(location = 0) out vec4 _GLF_color;
38#
39# void main()
40# {
41#     // Arithmetic shift replicates the sign bit.
42#     int a = 0xffffffff >> one;
43#     // Clamps to 2.0.
44#     float f = clamp(5.0, 1.0, (a == 0xffffffff) ? 2.0 : 3.0);
45#
46#     // Always true.
47#     if (int(f) == 2)
48#         _GLF_color = vec4(1, 0, 0, 1);
49#     else
50#         _GLF_color = vec4(0);
51# }
52SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
53; SPIR-V
54; Version: 1.0
55; Generator: Khronos Glslang Reference Front End; 10
56; Bound: 43
57; Schema: 0
58               OpCapability Shader
59          %1 = OpExtInstImport "GLSL.std.450"
60               OpMemoryModel Logical GLSL450
61               OpEntryPoint Fragment %4 "main" %38
62               OpExecutionMode %4 OriginUpperLeft
63               OpSource ESSL 320
64               OpName %4 "main"
65               OpName %8 "a"
66               OpName %10 "buf0"
67               OpMemberName %10 0 "one"
68               OpName %12 ""
69               OpName %20 "f"
70               OpName %38 "_GLF_color"
71               OpMemberDecorate %10 0 Offset 0
72               OpDecorate %10 Block
73               OpDecorate %12 DescriptorSet 0
74               OpDecorate %12 Binding 0
75               OpDecorate %38 Location 0
76          %2 = OpTypeVoid
77          %3 = OpTypeFunction %2
78          %6 = OpTypeInt 32 1
79          %7 = OpTypePointer Function %6
80          %9 = OpConstant %6 -1
81         %10 = OpTypeStruct %6
82         %11 = OpTypePointer Uniform %10
83         %12 = OpVariable %11 Uniform
84         %13 = OpConstant %6 0
85         %14 = OpTypePointer Uniform %6
86         %18 = OpTypeFloat 32
87         %19 = OpTypePointer Function %18
88         %21 = OpConstant %18 5
89         %22 = OpConstant %18 1
90         %24 = OpTypeBool
91         %26 = OpConstant %18 2
92         %27 = OpConstant %18 3
93         %32 = OpConstant %6 2
94         %36 = OpTypeVector %18 4
95         %37 = OpTypePointer Output %36
96         %38 = OpVariable %37 Output
97         %39 = OpConstant %18 0
98         %40 = OpConstantComposite %36 %22 %39 %39 %22
99         %42 = OpConstantComposite %36 %39 %39 %39 %39
100          %4 = OpFunction %2 None %3
101          %5 = OpLabel
102          %8 = OpVariable %7 Function
103         %20 = OpVariable %19 Function
104         %15 = OpAccessChain %14 %12 %13
105         %16 = OpLoad %6 %15
106         %17 = OpShiftRightArithmetic %6 %9 %16
107               OpStore %8 %17
108         %23 = OpLoad %6 %8
109         %25 = OpIEqual %24 %23 %9
110         %28 = OpSelect %18 %25 %26 %27
111         %29 = OpExtInst %18 %1 FClamp %21 %22 %28
112               OpStore %20 %29
113         %30 = OpLoad %18 %20
114         %31 = OpConvertFToS %6 %30
115         %33 = OpIEqual %24 %31 %32
116               OpSelectionMerge %35 None
117               OpBranchConditional %33 %34 %41
118         %34 = OpLabel
119               OpStore %38 %40
120               OpBranch %35
121         %41 = OpLabel
122               OpStore %38 %42
123               OpBranch %35
124         %35 = OpLabel
125               OpReturn
126               OpFunctionEnd
127END
128
129# uniforms for variant
130
131# one
132BUFFER variant_one DATA_TYPE int32 STD140 DATA
133 1
134END
135
136BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
137
138PIPELINE graphics variant_pipeline
139  ATTACH variant_vertex_shader
140  ATTACH variant_fragment_shader
141  FRAMEBUFFER_SIZE 256 256
142  BIND BUFFER variant_framebuffer AS color LOCATION 0
143  BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
144END
145CLEAR_COLOR variant_pipeline 0 0 0 255
146
147CLEAR variant_pipeline
148RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
149
150EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
151