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