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