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