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