• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 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 the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
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 320 es
28# #define _int_256 _GLF_uniform_int_values[0]
29# #define _int_1 _GLF_uniform_int_values[1]
30# #define _int_0 _GLF_uniform_int_values[2]
31#
32# precision highp float;
33# precision highp int;
34#
35# // Contents of _GLF_uniform_int_values: [256, 1, 0]
36# layout(set = 0, binding = 0) uniform buf0
37# {
38#     int _GLF_uniform_int_values[3];
39# };
40#
41# // Contents of resolution: 256.0
42# layout(set = 0, binding = 1) uniform buf1
43# {
44#     float resolution;
45# };
46#
47# layout(location = 0) out vec4 _GLF_color;
48#
49# void main()
50# {
51#     // p becomes (128, 128).
52#     ivec2 p = ivec2(resolution) >> ivec2(1);
53#     // p becomes (256, 128).
54#     p.x += p.y;
55#
56#     // Always true.
57#     if(p.x == _int_256)
58#     {
59#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
60#     }
61#     else
62#     {
63#         _GLF_color = vec4(_int_0);
64#     }
65# }
66SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67; SPIR-V
68; Version: 1.0
69; Generator: Khronos Glslang Reference Front End; 10
70; Bound: 69
71; Schema: 0
72               OpCapability Shader
73          %1 = OpExtInstImport "GLSL.std.450"
74               OpMemoryModel Logical GLSL450
75               OpEntryPoint Fragment %4 "main" %49
76               OpExecutionMode %4 OriginUpperLeft
77               OpSource ESSL 320
78               OpName %4 "main"
79               OpName %9 "p"
80               OpName %11 "buf1"
81               OpMemberName %11 0 "resolution"
82               OpName %13 ""
83               OpName %37 "buf0"
84               OpMemberName %37 0 "_GLF_uniform_int_values"
85               OpName %39 ""
86               OpName %49 "_GLF_color"
87               OpMemberDecorate %11 0 Offset 0
88               OpDecorate %11 Block
89               OpDecorate %13 DescriptorSet 0
90               OpDecorate %13 Binding 1
91               OpDecorate %36 ArrayStride 16
92               OpMemberDecorate %37 0 Offset 0
93               OpDecorate %37 Block
94               OpDecorate %39 DescriptorSet 0
95               OpDecorate %39 Binding 0
96               OpDecorate %49 Location 0
97          %2 = OpTypeVoid
98          %3 = OpTypeFunction %2
99          %6 = OpTypeInt 32 1
100          %7 = OpTypeVector %6 2
101          %8 = OpTypePointer Function %7
102         %10 = OpTypeFloat 32
103         %11 = OpTypeStruct %10
104         %12 = OpTypePointer Uniform %11
105         %13 = OpVariable %12 Uniform
106         %14 = OpConstant %6 0
107         %15 = OpTypePointer Uniform %10
108         %20 = OpConstant %6 1
109         %21 = OpConstantComposite %7 %20 %20
110         %23 = OpTypeInt 32 0
111         %24 = OpConstant %23 1
112         %25 = OpTypePointer Function %6
113         %28 = OpConstant %23 0
114         %35 = OpConstant %23 3
115         %36 = OpTypeArray %6 %35
116         %37 = OpTypeStruct %36
117         %38 = OpTypePointer Uniform %37
118         %39 = OpVariable %38 Uniform
119         %40 = OpTypePointer Uniform %6
120         %43 = OpTypeBool
121         %47 = OpTypeVector %10 4
122         %48 = OpTypePointer Output %47
123         %49 = OpVariable %48 Output
124         %53 = OpConstant %6 2
125          %4 = OpFunction %2 None %3
126          %5 = OpLabel
127          %9 = OpVariable %8 Function
128         %16 = OpAccessChain %15 %13 %14
129         %17 = OpLoad %10 %16
130         %18 = OpConvertFToS %6 %17
131         %19 = OpCompositeConstruct %7 %18 %18
132         %22 = OpShiftRightArithmetic %7 %19 %21
133               OpStore %9 %22
134         %26 = OpAccessChain %25 %9 %24
135         %27 = OpLoad %6 %26
136         %29 = OpAccessChain %25 %9 %28
137         %30 = OpLoad %6 %29
138         %31 = OpIAdd %6 %30 %27
139         %32 = OpAccessChain %25 %9 %28
140               OpStore %32 %31
141         %33 = OpAccessChain %25 %9 %28
142         %34 = OpLoad %6 %33
143         %41 = OpAccessChain %40 %39 %14 %14
144         %42 = OpLoad %6 %41
145         %44 = OpIEqual %43 %34 %42
146               OpSelectionMerge %46 None
147               OpBranchConditional %44 %45 %64
148         %45 = OpLabel
149         %50 = OpAccessChain %40 %39 %14 %20
150         %51 = OpLoad %6 %50
151         %52 = OpConvertSToF %10 %51
152         %54 = OpAccessChain %40 %39 %14 %53
153         %55 = OpLoad %6 %54
154         %56 = OpConvertSToF %10 %55
155         %57 = OpAccessChain %40 %39 %14 %53
156         %58 = OpLoad %6 %57
157         %59 = OpConvertSToF %10 %58
158         %60 = OpAccessChain %40 %39 %14 %20
159         %61 = OpLoad %6 %60
160         %62 = OpConvertSToF %10 %61
161         %63 = OpCompositeConstruct %47 %52 %56 %59 %62
162               OpStore %49 %63
163               OpBranch %46
164         %64 = OpLabel
165         %65 = OpAccessChain %40 %39 %14 %53
166         %66 = OpLoad %6 %65
167         %67 = OpConvertSToF %10 %66
168         %68 = OpCompositeConstruct %47 %67 %67 %67 %67
169               OpStore %49 %68
170               OpBranch %46
171         %46 = OpLabel
172               OpReturn
173               OpFunctionEnd
174END
175
176# uniforms for variant
177
178# resolution
179BUFFER variant_resolution DATA_TYPE float STD140 DATA
180 256.0
181END
182# _GLF_uniform_int_values
183BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
184 256 1 0
185END
186
187BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
188
189PIPELINE graphics variant_pipeline
190  ATTACH variant_vertex_shader
191  ATTACH variant_fragment_shader
192  FRAMEBUFFER_SIZE 256 256
193  BIND BUFFER variant_framebuffer AS color LOCATION 0
194  BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 1
195  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
196END
197CLEAR_COLOR variant_pipeline 0 0 0 255
198
199CLEAR variant_pipeline
200RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
201
202EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
203