• 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 int;
30# precision highp float;
31#
32# layout(location = 0) out vec4 _GLF_color;
33#
34# void main()
35# {
36#     if(true)
37#     {
38#     }
39#
40#     if(0x3f800000 == floatBitsToInt(1.0))
41#     {
42#         _GLF_color = vec4(1, 0, 0, 1);
43#     }
44#     else
45#     {
46#         _GLF_color = vec4(0);
47#     }
48#
49# }
50SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
51; SPIR-V
52; Version: 1.0
53; Generator: Khronos Glslang Reference Front End; 10
54; Bound: 25
55; Schema: 0
56               OpCapability Shader
57          %1 = OpExtInstImport "GLSL.std.450"
58               OpMemoryModel Logical GLSL450
59               OpEntryPoint Fragment %4 "main" %20
60               OpExecutionMode %4 OriginUpperLeft
61               OpSource ESSL 320
62               OpName %4 "main"
63               OpName %20 "_GLF_color"
64               OpDecorate %20 Location 0
65          %2 = OpTypeVoid
66          %3 = OpTypeFunction %2
67          %6 = OpTypeBool
68          %7 = OpConstantTrue %6
69         %10 = OpTypeInt 32 1
70         %11 = OpConstant %10 1065353216
71         %12 = OpTypeFloat 32
72         %13 = OpConstant %12 1
73         %18 = OpTypeVector %12 4
74         %19 = OpTypePointer Output %18
75         %20 = OpVariable %19 Output
76         %21 = OpConstant %12 0
77         %22 = OpConstantComposite %18 %13 %21 %21 %13
78         %24 = OpConstantComposite %18 %21 %21 %21 %21
79          %4 = OpFunction %2 None %3
80          %5 = OpLabel
81               OpSelectionMerge %9 None
82               OpBranchConditional %7 %8 %9
83          %8 = OpLabel
84               OpBranch %9
85          %9 = OpLabel
86         %14 = OpBitcast %10 %13
87         %15 = OpIEqual %6 %11 %14
88               OpSelectionMerge %17 None
89               OpBranchConditional %15 %16 %23
90         %16 = OpLabel
91               OpStore %20 %22
92               OpBranch %17
93         %23 = OpLabel
94               OpStore %20 %24
95               OpBranch %17
96         %17 = OpLabel
97               OpReturn
98               OpFunctionEnd
99END
100
101
102BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
103
104PIPELINE graphics variant_pipeline
105  ATTACH variant_vertex_shader
106  ATTACH variant_fragment_shader
107  FRAMEBUFFER_SIZE 256 256
108  BIND BUFFER variant_framebuffer AS color LOCATION 0
109END
110CLEAR_COLOR variant_pipeline 0 0 0 255
111
112CLEAR variant_pipeline
113RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
114
115EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
116