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