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