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