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