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