Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/compiler/nir/nir_intrinsics.py
4547 views
1
#
2
# Copyright (C) 2018 Red Hat
3
# Copyright (C) 2014 Intel Corporation
4
#
5
# Permission is hereby granted, free of charge, to any person obtaining a
6
# copy of this software and associated documentation files (the "Software"),
7
# to deal in the Software without restriction, including without limitation
8
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
# and/or sell copies of the Software, and to permit persons to whom the
10
# Software is furnished to do so, subject to the following conditions:
11
#
12
# The above copyright notice and this permission notice (including the next
13
# paragraph) shall be included in all copies or substantial portions of the
14
# Software.
15
#
16
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
# IN THE SOFTWARE.
23
#
24
25
# This file defines all the available intrinsics in one place.
26
#
27
# The Intrinsic class corresponds one-to-one with nir_intrinsic_info
28
# structure.
29
30
src0 = ('src', 0)
31
src1 = ('src', 1)
32
src2 = ('src', 2)
33
src3 = ('src', 3)
34
src4 = ('src', 4)
35
36
class Index(object):
37
def __init__(self, c_data_type, name):
38
self.c_data_type = c_data_type
39
self.name = name
40
41
class Intrinsic(object):
42
"""Class that represents all the information about an intrinsic opcode.
43
NOTE: this must be kept in sync with nir_intrinsic_info.
44
"""
45
def __init__(self, name, src_components, dest_components,
46
indices, flags, sysval, bit_sizes):
47
"""Parameters:
48
49
- name: the intrinsic name
50
- src_components: list of the number of components per src, 0 means
51
vectorized instruction with number of components given in the
52
num_components field in nir_intrinsic_instr.
53
- dest_components: number of destination components, -1 means no
54
dest, 0 means number of components given in num_components field
55
in nir_intrinsic_instr.
56
- indices: list of constant indicies
57
- flags: list of semantic flags
58
- sysval: is this a system-value intrinsic
59
- bit_sizes: allowed dest bit_sizes or the source it must match
60
"""
61
assert isinstance(name, str)
62
assert isinstance(src_components, list)
63
if src_components:
64
assert isinstance(src_components[0], int)
65
assert isinstance(dest_components, int)
66
assert isinstance(indices, list)
67
if indices:
68
assert isinstance(indices[0], Index)
69
assert isinstance(flags, list)
70
if flags:
71
assert isinstance(flags[0], str)
72
assert isinstance(sysval, bool)
73
if isinstance(bit_sizes, list):
74
assert not bit_sizes or isinstance(bit_sizes[0], int)
75
else:
76
assert isinstance(bit_sizes, tuple)
77
assert bit_sizes[0] == 'src'
78
assert isinstance(bit_sizes[1], int)
79
80
self.name = name
81
self.num_srcs = len(src_components)
82
self.src_components = src_components
83
self.has_dest = (dest_components >= 0)
84
self.dest_components = dest_components
85
self.num_indices = len(indices)
86
self.indices = indices
87
self.flags = flags
88
self.sysval = sysval
89
self.bit_sizes = bit_sizes if isinstance(bit_sizes, list) else []
90
self.bit_size_src = bit_sizes[1] if isinstance(bit_sizes, tuple) else -1
91
92
#
93
# Possible flags:
94
#
95
96
CAN_ELIMINATE = "NIR_INTRINSIC_CAN_ELIMINATE"
97
CAN_REORDER = "NIR_INTRINSIC_CAN_REORDER"
98
99
INTR_INDICES = []
100
INTR_OPCODES = {}
101
102
def index(c_data_type, name):
103
idx = Index(c_data_type, name)
104
INTR_INDICES.append(idx)
105
globals()[name.upper()] = idx
106
107
# Defines a new NIR intrinsic. By default, the intrinsic will have no sources
108
# and no destination.
109
#
110
# You can set dest_comp=n to enable a destination for the intrinsic, in which
111
# case it will have that many components, or =0 for "as many components as the
112
# NIR destination value."
113
#
114
# Set src_comp=n to enable sources for the intruction. It can be an array of
115
# component counts, or (for convenience) a scalar component count if there's
116
# only one source. If a component count is 0, it will be as many components as
117
# the intrinsic has based on the dest_comp.
118
def intrinsic(name, src_comp=[], dest_comp=-1, indices=[],
119
flags=[], sysval=False, bit_sizes=[]):
120
assert name not in INTR_OPCODES
121
INTR_OPCODES[name] = Intrinsic(name, src_comp, dest_comp,
122
indices, flags, sysval, bit_sizes)
123
124
#
125
# Possible indices:
126
#
127
128
# Generally instructions that take a offset src argument, can encode
129
# a constant 'base' value which is added to the offset.
130
index("int", "base")
131
132
# For store instructions, a writemask for the store.
133
index("unsigned", "write_mask")
134
135
# The stream-id for GS emit_vertex/end_primitive intrinsics.
136
index("unsigned", "stream_id")
137
138
# The clip-plane id for load_user_clip_plane intrinsic.
139
index("unsigned", "ucp_id")
140
141
# The offset to the start of the NIR_INTRINSIC_RANGE. This is an alternative
142
# to NIR_INTRINSIC_BASE for describing the valid range in intrinsics that don't
143
# have the implicit addition of a base to the offset.
144
#
145
# If the [range_base, range] is [0, ~0], then we don't know the possible
146
# range of the access.
147
index("unsigned", "range_base")
148
149
# The amount of data, starting from BASE or RANGE_BASE, that this
150
# instruction may access. This is used to provide bounds if the offset is
151
# not constant.
152
index("unsigned", "range")
153
154
# The Vulkan descriptor set for vulkan_resource_index intrinsic.
155
index("unsigned", "desc_set")
156
157
# The Vulkan descriptor set binding for vulkan_resource_index intrinsic.
158
index("unsigned", "binding")
159
160
# Component offset
161
index("unsigned", "component")
162
163
# Column index for matrix system values
164
index("unsigned", "column")
165
166
# Interpolation mode (only meaningful for FS inputs)
167
index("unsigned", "interp_mode")
168
169
# A binary nir_op to use when performing a reduction or scan operation
170
index("unsigned", "reduction_op")
171
172
# Cluster size for reduction operations
173
index("unsigned", "cluster_size")
174
175
# Parameter index for a load_param intrinsic
176
index("unsigned", "param_idx")
177
178
# Image dimensionality for image intrinsics
179
index("enum glsl_sampler_dim", "image_dim")
180
181
# Non-zero if we are accessing an array image
182
index("bool", "image_array")
183
184
# Image format for image intrinsics
185
index("enum pipe_format", "format")
186
187
# Access qualifiers for image and memory access intrinsics. ACCESS_RESTRICT is
188
# not set at the intrinsic if the NIR was created from SPIR-V.
189
index("enum gl_access_qualifier", "access")
190
191
# call index for split raytracing shaders
192
index("unsigned", "call_idx")
193
194
# The stack size increment/decrement for split raytracing shaders
195
index("unsigned", "stack_size")
196
197
# Alignment for offsets and addresses
198
#
199
# These two parameters, specify an alignment in terms of a multiplier and
200
# an offset. The multiplier is always a power of two. The offset or
201
# address parameter X of the intrinsic is guaranteed to satisfy the
202
# following:
203
#
204
# (X - align_offset) % align_mul == 0
205
#
206
# For constant offset values, align_mul will be NIR_ALIGN_MUL_MAX and the
207
# align_offset will be modulo that.
208
index("unsigned", "align_mul")
209
index("unsigned", "align_offset")
210
211
# The Vulkan descriptor type for a vulkan_resource_[re]index intrinsic.
212
index("unsigned", "desc_type")
213
214
# The nir_alu_type of input data to a store or conversion
215
index("nir_alu_type", "src_type")
216
217
# The nir_alu_type of the data output from a load or conversion
218
index("nir_alu_type", "dest_type")
219
220
# The swizzle mask for quad_swizzle_amd & masked_swizzle_amd
221
index("unsigned", "swizzle_mask")
222
223
# Whether the load_buffer_amd/store_buffer_amd is swizzled
224
index("bool", "is_swizzled")
225
226
# The SLC ("system level coherent") bit of load_buffer_amd/store_buffer_amd
227
index("bool", "slc_amd")
228
229
# Separate source/dest access flags for copies
230
index("enum gl_access_qualifier", "dst_access")
231
index("enum gl_access_qualifier", "src_access")
232
233
# Driver location of attribute
234
index("unsigned", "driver_location")
235
236
# Ordering and visibility of a memory operation
237
index("nir_memory_semantics", "memory_semantics")
238
239
# Modes affected by a memory operation
240
index("nir_variable_mode", "memory_modes")
241
242
# Scope of a memory operation
243
index("nir_scope", "memory_scope")
244
245
# Scope of a control barrier
246
index("nir_scope", "execution_scope")
247
248
# Semantics of an IO instruction
249
index("struct nir_io_semantics", "io_semantics")
250
251
# Rounding mode for conversions
252
index("nir_rounding_mode", "rounding_mode")
253
254
# Whether or not to saturate in conversions
255
index("unsigned", "saturate")
256
257
intrinsic("nop", flags=[CAN_ELIMINATE])
258
259
intrinsic("convert_alu_types", dest_comp=0, src_comp=[0],
260
indices=[SRC_TYPE, DEST_TYPE, ROUNDING_MODE, SATURATE],
261
flags=[CAN_ELIMINATE, CAN_REORDER])
262
263
intrinsic("load_param", dest_comp=0, indices=[PARAM_IDX], flags=[CAN_ELIMINATE])
264
265
intrinsic("load_deref", dest_comp=0, src_comp=[-1],
266
indices=[ACCESS], flags=[CAN_ELIMINATE])
267
intrinsic("store_deref", src_comp=[-1, 0], indices=[WRITE_MASK, ACCESS])
268
intrinsic("copy_deref", src_comp=[-1, -1], indices=[DST_ACCESS, SRC_ACCESS])
269
intrinsic("memcpy_deref", src_comp=[-1, -1, 1], indices=[DST_ACCESS, SRC_ACCESS])
270
271
# Interpolation of input. The interp_deref_at* intrinsics are similar to the
272
# load_var intrinsic acting on a shader input except that they interpolate the
273
# input differently. The at_sample, at_offset and at_vertex intrinsics take an
274
# additional source that is an integer sample id, a vec2 position offset, or a
275
# vertex ID respectively.
276
277
intrinsic("interp_deref_at_centroid", dest_comp=0, src_comp=[1],
278
flags=[ CAN_ELIMINATE, CAN_REORDER])
279
intrinsic("interp_deref_at_sample", src_comp=[1, 1], dest_comp=0,
280
flags=[CAN_ELIMINATE, CAN_REORDER])
281
intrinsic("interp_deref_at_offset", src_comp=[1, 2], dest_comp=0,
282
flags=[CAN_ELIMINATE, CAN_REORDER])
283
intrinsic("interp_deref_at_vertex", src_comp=[1, 1], dest_comp=0,
284
flags=[CAN_ELIMINATE, CAN_REORDER])
285
286
# Gets the length of an unsized array at the end of a buffer
287
intrinsic("deref_buffer_array_length", src_comp=[-1], dest_comp=1,
288
indices=[ACCESS], flags=[CAN_ELIMINATE, CAN_REORDER])
289
290
# Ask the driver for the size of a given SSBO. It takes the buffer index
291
# as source.
292
intrinsic("get_ssbo_size", src_comp=[-1], dest_comp=1, bit_sizes=[32],
293
indices=[ACCESS], flags=[CAN_ELIMINATE, CAN_REORDER])
294
intrinsic("get_ubo_size", src_comp=[-1], dest_comp=1,
295
flags=[CAN_ELIMINATE, CAN_REORDER])
296
297
# Intrinsics which provide a run-time mode-check. Unlike the compile-time
298
# mode checks, a pointer can only have exactly one mode at runtime.
299
intrinsic("deref_mode_is", src_comp=[-1], dest_comp=1,
300
indices=[MEMORY_MODES], flags=[CAN_ELIMINATE, CAN_REORDER])
301
intrinsic("addr_mode_is", src_comp=[-1], dest_comp=1,
302
indices=[MEMORY_MODES], flags=[CAN_ELIMINATE, CAN_REORDER])
303
304
intrinsic("is_sparse_texels_resident", dest_comp=1, src_comp=[1], bit_sizes=[1],
305
flags=[CAN_ELIMINATE, CAN_REORDER])
306
# result code is resident only if both inputs are resident
307
intrinsic("sparse_residency_code_and", dest_comp=1, src_comp=[1, 1], bit_sizes=[32],
308
flags=[CAN_ELIMINATE, CAN_REORDER])
309
310
# a barrier is an intrinsic with no inputs/outputs but which can't be moved
311
# around/optimized in general
312
def barrier(name):
313
intrinsic(name)
314
315
barrier("discard")
316
317
# Demote fragment shader invocation to a helper invocation. Any stores to
318
# memory after this instruction are suppressed and the fragment does not write
319
# outputs to the framebuffer. Unlike discard, demote needs to ensure that
320
# derivatives will still work for invocations that were not demoted.
321
#
322
# As specified by SPV_EXT_demote_to_helper_invocation.
323
barrier("demote")
324
intrinsic("is_helper_invocation", dest_comp=1, flags=[CAN_ELIMINATE])
325
326
# SpvOpTerminateInvocation from SPIR-V. Essentially a discard "for real".
327
barrier("terminate")
328
329
# A workgroup-level control barrier. Any thread which hits this barrier will
330
# pause until all threads within the current workgroup have also hit the
331
# barrier. For compute shaders, the workgroup is defined as the local group.
332
# For tessellation control shaders, the workgroup is defined as the current
333
# patch. This intrinsic does not imply any sort of memory barrier.
334
barrier("control_barrier")
335
336
# Memory barrier with semantics analogous to the memoryBarrier() GLSL
337
# intrinsic.
338
barrier("memory_barrier")
339
340
# Control/Memory barrier with explicit scope. Follows the semantics of SPIR-V
341
# OpMemoryBarrier and OpControlBarrier, used to implement Vulkan Memory Model.
342
# Storage that the barrier applies is represented using NIR variable modes.
343
# For an OpMemoryBarrier, set EXECUTION_SCOPE to NIR_SCOPE_NONE.
344
intrinsic("scoped_barrier",
345
indices=[EXECUTION_SCOPE, MEMORY_SCOPE, MEMORY_SEMANTICS, MEMORY_MODES])
346
347
# Shader clock intrinsic with semantics analogous to the clock2x32ARB()
348
# GLSL intrinsic.
349
# The latter can be used as code motion barrier, which is currently not
350
# feasible with NIR.
351
intrinsic("shader_clock", dest_comp=2, bit_sizes=[32], flags=[CAN_ELIMINATE],
352
indices=[MEMORY_SCOPE])
353
354
# Shader ballot intrinsics with semantics analogous to the
355
#
356
# ballotARB()
357
# readInvocationARB()
358
# readFirstInvocationARB()
359
#
360
# GLSL functions from ARB_shader_ballot.
361
intrinsic("ballot", src_comp=[1], dest_comp=0, flags=[CAN_ELIMINATE])
362
intrinsic("read_invocation", src_comp=[0, 1], dest_comp=0, bit_sizes=src0, flags=[CAN_ELIMINATE])
363
intrinsic("read_first_invocation", src_comp=[0], dest_comp=0, bit_sizes=src0, flags=[CAN_ELIMINATE])
364
365
# Returns the value of the first source for the lane where the second source is
366
# true. The second source must be true for exactly one lane.
367
intrinsic("read_invocation_cond_ir3", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
368
369
# Additional SPIR-V ballot intrinsics
370
#
371
# These correspond to the SPIR-V opcodes
372
#
373
# OpGroupNonUniformElect
374
# OpSubgroupFirstInvocationKHR
375
intrinsic("elect", dest_comp=1, flags=[CAN_ELIMINATE])
376
intrinsic("first_invocation", dest_comp=1, bit_sizes=[32], flags=[CAN_ELIMINATE])
377
intrinsic("last_invocation", dest_comp=1, bit_sizes=[32], flags=[CAN_ELIMINATE])
378
379
# Memory barrier with semantics analogous to the compute shader
380
# groupMemoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(),
381
# memoryBarrierImage() and memoryBarrierShared() GLSL intrinsics.
382
barrier("group_memory_barrier")
383
barrier("memory_barrier_atomic_counter")
384
barrier("memory_barrier_buffer")
385
barrier("memory_barrier_image")
386
barrier("memory_barrier_shared")
387
barrier("begin_invocation_interlock")
388
barrier("end_invocation_interlock")
389
390
# Memory barrier for synchronizing TCS patch outputs
391
barrier("memory_barrier_tcs_patch")
392
393
# A conditional discard/demote/terminate, with a single boolean source.
394
intrinsic("discard_if", src_comp=[1])
395
intrinsic("demote_if", src_comp=[1])
396
intrinsic("terminate_if", src_comp=[1])
397
398
# ARB_shader_group_vote intrinsics
399
intrinsic("vote_any", src_comp=[1], dest_comp=1, flags=[CAN_ELIMINATE])
400
intrinsic("vote_all", src_comp=[1], dest_comp=1, flags=[CAN_ELIMINATE])
401
intrinsic("vote_feq", src_comp=[0], dest_comp=1, flags=[CAN_ELIMINATE])
402
intrinsic("vote_ieq", src_comp=[0], dest_comp=1, flags=[CAN_ELIMINATE])
403
404
# Ballot ALU operations from SPIR-V.
405
#
406
# These operations work like their ALU counterparts except that the operate
407
# on a uvec4 which is treated as a 128bit integer. Also, they are, in
408
# general, free to ignore any bits which are above the subgroup size.
409
intrinsic("ballot_bitfield_extract", src_comp=[4, 1], dest_comp=1, flags=[CAN_ELIMINATE])
410
intrinsic("ballot_bit_count_reduce", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
411
intrinsic("ballot_bit_count_inclusive", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
412
intrinsic("ballot_bit_count_exclusive", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
413
intrinsic("ballot_find_lsb", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
414
intrinsic("ballot_find_msb", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
415
416
# Shuffle operations from SPIR-V.
417
intrinsic("shuffle", src_comp=[0, 1], dest_comp=0, bit_sizes=src0, flags=[CAN_ELIMINATE])
418
intrinsic("shuffle_xor", src_comp=[0, 1], dest_comp=0, bit_sizes=src0, flags=[CAN_ELIMINATE])
419
intrinsic("shuffle_up", src_comp=[0, 1], dest_comp=0, bit_sizes=src0, flags=[CAN_ELIMINATE])
420
intrinsic("shuffle_down", src_comp=[0, 1], dest_comp=0, bit_sizes=src0, flags=[CAN_ELIMINATE])
421
422
# Quad operations from SPIR-V.
423
intrinsic("quad_broadcast", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
424
intrinsic("quad_swap_horizontal", src_comp=[0], dest_comp=0, flags=[CAN_ELIMINATE])
425
intrinsic("quad_swap_vertical", src_comp=[0], dest_comp=0, flags=[CAN_ELIMINATE])
426
intrinsic("quad_swap_diagonal", src_comp=[0], dest_comp=0, flags=[CAN_ELIMINATE])
427
428
intrinsic("reduce", src_comp=[0], dest_comp=0, bit_sizes=src0,
429
indices=[REDUCTION_OP, CLUSTER_SIZE], flags=[CAN_ELIMINATE])
430
intrinsic("inclusive_scan", src_comp=[0], dest_comp=0, bit_sizes=src0,
431
indices=[REDUCTION_OP], flags=[CAN_ELIMINATE])
432
intrinsic("exclusive_scan", src_comp=[0], dest_comp=0, bit_sizes=src0,
433
indices=[REDUCTION_OP], flags=[CAN_ELIMINATE])
434
435
# AMD shader ballot operations
436
intrinsic("quad_swizzle_amd", src_comp=[0], dest_comp=0, bit_sizes=src0,
437
indices=[SWIZZLE_MASK], flags=[CAN_ELIMINATE])
438
intrinsic("masked_swizzle_amd", src_comp=[0], dest_comp=0, bit_sizes=src0,
439
indices=[SWIZZLE_MASK], flags=[CAN_ELIMINATE])
440
intrinsic("write_invocation_amd", src_comp=[0, 0, 1], dest_comp=0, bit_sizes=src0,
441
flags=[CAN_ELIMINATE])
442
# src = [ mask, addition ]
443
intrinsic("mbcnt_amd", src_comp=[1, 1], dest_comp=1, bit_sizes=[32], flags=[CAN_ELIMINATE])
444
# Compiled to v_perm_b32. src = [ in_bytes_hi, in_bytes_lo, selector ]
445
intrinsic("byte_permute_amd", src_comp=[1, 1, 1], dest_comp=1, bit_sizes=[32], flags=[CAN_ELIMINATE, CAN_REORDER])
446
# Compiled to v_permlane16_b32. src = [ value, lanesel_lo, lanesel_hi ]
447
intrinsic("lane_permute_16_amd", src_comp=[1, 1, 1], dest_comp=1, bit_sizes=[32], flags=[CAN_ELIMINATE])
448
449
# Basic Geometry Shader intrinsics.
450
#
451
# emit_vertex implements GLSL's EmitStreamVertex() built-in. It takes a single
452
# index, which is the stream ID to write to.
453
#
454
# end_primitive implements GLSL's EndPrimitive() built-in.
455
intrinsic("emit_vertex", indices=[STREAM_ID])
456
intrinsic("end_primitive", indices=[STREAM_ID])
457
458
# Geometry Shader intrinsics with a vertex count.
459
#
460
# Alternatively, drivers may implement these intrinsics, and use
461
# nir_lower_gs_intrinsics() to convert from the basic intrinsics.
462
#
463
# These contain two additional unsigned integer sources:
464
# 1. The total number of vertices emitted so far.
465
# 2. The number of vertices emitted for the current primitive
466
# so far if we're counting, otherwise undef.
467
intrinsic("emit_vertex_with_counter", src_comp=[1, 1], indices=[STREAM_ID])
468
intrinsic("end_primitive_with_counter", src_comp=[1, 1], indices=[STREAM_ID])
469
# Contains the final total vertex and primitive counts in the current GS thread.
470
intrinsic("set_vertex_and_primitive_count", src_comp=[1, 1], indices=[STREAM_ID])
471
472
# Trace a ray through an acceleration structure
473
#
474
# This instruction has a lot of parameters:
475
# 0. Acceleration Structure
476
# 1. Ray Flags
477
# 2. Cull Mask
478
# 3. SBT Offset
479
# 4. SBT Stride
480
# 5. Miss shader index
481
# 6. Ray Origin
482
# 7. Ray Tmin
483
# 8. Ray Direction
484
# 9. Ray Tmax
485
# 10. Payload
486
intrinsic("trace_ray", src_comp=[-1, 1, 1, 1, 1, 1, 3, 1, 3, 1, -1])
487
# src[] = { hit_t, hit_kind }
488
intrinsic("report_ray_intersection", src_comp=[1, 1], dest_comp=1)
489
intrinsic("ignore_ray_intersection")
490
intrinsic("accept_ray_intersection") # Not in SPIR-V; useful for lowering
491
intrinsic("terminate_ray")
492
# src[] = { sbt_index, payload }
493
intrinsic("execute_callable", src_comp=[1, -1])
494
495
# Driver independent raytracing helpers
496
497
# rt_resume is a helper that that be the first instruction accesing the
498
# stack/scratch in a resume shader for a raytracing pipeline. It includes the
499
# resume index (for nir_lower_shader_calls_internal reasons) and the stack size
500
# of the variables spilled during the call. The stack size can be use to e.g.
501
# adjust a stack pointer.
502
intrinsic("rt_resume", indices=[CALL_IDX, STACK_SIZE])
503
504
# Lowered version of execute_callabe that includes the index of the resume
505
# shader, and the amount of scratch space needed for this call (.ie. how much
506
# to increase a stack pointer by).
507
# src[] = { sbt_index, payload }
508
intrinsic("rt_execute_callable", src_comp=[1, -1], indices=[CALL_IDX,STACK_SIZE])
509
510
# Lowered version of trace_ray in a similar vein to rt_execute_callable.
511
# src same as trace_ray
512
intrinsic("rt_trace_ray", src_comp=[-1, 1, 1, 1, 1, 1, 3, 1, 3, 1, -1],
513
indices=[CALL_IDX, STACK_SIZE])
514
515
516
# Atomic counters
517
#
518
# The *_var variants take an atomic_uint nir_variable, while the other,
519
# lowered, variants take a constant buffer index and register offset.
520
521
def atomic(name, flags=[]):
522
intrinsic(name + "_deref", src_comp=[-1], dest_comp=1, flags=flags)
523
intrinsic(name, src_comp=[1], dest_comp=1, indices=[BASE], flags=flags)
524
525
def atomic2(name):
526
intrinsic(name + "_deref", src_comp=[-1, 1], dest_comp=1)
527
intrinsic(name, src_comp=[1, 1], dest_comp=1, indices=[BASE])
528
529
def atomic3(name):
530
intrinsic(name + "_deref", src_comp=[-1, 1, 1], dest_comp=1)
531
intrinsic(name, src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
532
533
atomic("atomic_counter_inc")
534
atomic("atomic_counter_pre_dec")
535
atomic("atomic_counter_post_dec")
536
atomic("atomic_counter_read", flags=[CAN_ELIMINATE])
537
atomic2("atomic_counter_add")
538
atomic2("atomic_counter_min")
539
atomic2("atomic_counter_max")
540
atomic2("atomic_counter_and")
541
atomic2("atomic_counter_or")
542
atomic2("atomic_counter_xor")
543
atomic2("atomic_counter_exchange")
544
atomic3("atomic_counter_comp_swap")
545
546
# Image load, store and atomic intrinsics.
547
#
548
# All image intrinsics come in three versions. One which take an image target
549
# passed as a deref chain as the first source, one which takes an index as the
550
# first source, and one which takes a bindless handle as the first source.
551
# In the first version, the image variable contains the memory and layout
552
# qualifiers that influence the semantics of the intrinsic. In the second and
553
# third, the image format and access qualifiers are provided as constant
554
# indices.
555
#
556
# All image intrinsics take a four-coordinate vector and a sample index as
557
# 2nd and 3rd sources, determining the location within the image that will be
558
# accessed by the intrinsic. Components not applicable to the image target
559
# in use are undefined. Image store takes an additional four-component
560
# argument with the value to be written, and image atomic operations take
561
# either one or two additional scalar arguments with the same meaning as in
562
# the ARB_shader_image_load_store specification.
563
def image(name, src_comp=[], extra_indices=[], **kwargs):
564
intrinsic("image_deref_" + name, src_comp=[1] + src_comp,
565
indices=[ACCESS] + extra_indices, **kwargs)
566
intrinsic("image_" + name, src_comp=[1] + src_comp,
567
indices=[IMAGE_DIM, IMAGE_ARRAY, FORMAT, ACCESS] + extra_indices, **kwargs)
568
intrinsic("bindless_image_" + name, src_comp=[1] + src_comp,
569
indices=[IMAGE_DIM, IMAGE_ARRAY, FORMAT, ACCESS] + extra_indices, **kwargs)
570
571
image("load", src_comp=[4, 1, 1], extra_indices=[DEST_TYPE], dest_comp=0, flags=[CAN_ELIMINATE])
572
image("sparse_load", src_comp=[4, 1, 1], extra_indices=[DEST_TYPE], dest_comp=0, flags=[CAN_ELIMINATE])
573
image("store", src_comp=[4, 1, 0, 1], extra_indices=[SRC_TYPE])
574
image("atomic_add", src_comp=[4, 1, 1], dest_comp=1)
575
image("atomic_imin", src_comp=[4, 1, 1], dest_comp=1)
576
image("atomic_umin", src_comp=[4, 1, 1], dest_comp=1)
577
image("atomic_imax", src_comp=[4, 1, 1], dest_comp=1)
578
image("atomic_umax", src_comp=[4, 1, 1], dest_comp=1)
579
image("atomic_and", src_comp=[4, 1, 1], dest_comp=1)
580
image("atomic_or", src_comp=[4, 1, 1], dest_comp=1)
581
image("atomic_xor", src_comp=[4, 1, 1], dest_comp=1)
582
image("atomic_exchange", src_comp=[4, 1, 1], dest_comp=1)
583
image("atomic_comp_swap", src_comp=[4, 1, 1, 1], dest_comp=1)
584
image("atomic_fadd", src_comp=[4, 1, 1], dest_comp=1)
585
image("atomic_fmin", src_comp=[4, 1, 1], dest_comp=1)
586
image("atomic_fmax", src_comp=[4, 1, 1], dest_comp=1)
587
image("size", dest_comp=0, src_comp=[1], flags=[CAN_ELIMINATE, CAN_REORDER])
588
image("samples", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])
589
image("atomic_inc_wrap", src_comp=[4, 1, 1], dest_comp=1)
590
image("atomic_dec_wrap", src_comp=[4, 1, 1], dest_comp=1)
591
# CL-specific format queries
592
image("format", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])
593
image("order", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])
594
595
# Vulkan descriptor set intrinsics
596
#
597
# The Vulkan API uses a different binding model from GL. In the Vulkan
598
# API, all external resources are represented by a tuple:
599
#
600
# (descriptor set, binding, array index)
601
#
602
# where the array index is the only thing allowed to be indirect. The
603
# vulkan_surface_index intrinsic takes the descriptor set and binding as
604
# its first two indices and the array index as its source. The third
605
# index is a nir_variable_mode in case that's useful to the backend.
606
#
607
# The intended usage is that the shader will call vulkan_surface_index to
608
# get an index and then pass that as the buffer index ubo/ssbo calls.
609
#
610
# The vulkan_resource_reindex intrinsic takes a resource index in src0
611
# (the result of a vulkan_resource_index or vulkan_resource_reindex) which
612
# corresponds to the tuple (set, binding, index) and computes an index
613
# corresponding to tuple (set, binding, idx + src1).
614
intrinsic("vulkan_resource_index", src_comp=[1], dest_comp=0,
615
indices=[DESC_SET, BINDING, DESC_TYPE],
616
flags=[CAN_ELIMINATE, CAN_REORDER])
617
intrinsic("vulkan_resource_reindex", src_comp=[0, 1], dest_comp=0,
618
indices=[DESC_TYPE], flags=[CAN_ELIMINATE, CAN_REORDER])
619
intrinsic("load_vulkan_descriptor", src_comp=[-1], dest_comp=0,
620
indices=[DESC_TYPE], flags=[CAN_ELIMINATE, CAN_REORDER])
621
622
# atomic intrinsics
623
#
624
# All of these atomic memory operations read a value from memory, compute a new
625
# value using one of the operations below, write the new value to memory, and
626
# return the original value read.
627
#
628
# All variable operations take 2 sources except CompSwap that takes 3. These
629
# sources represent:
630
#
631
# 0: A deref to the memory on which to perform the atomic
632
# 1: The data parameter to the atomic function (i.e. the value to add
633
# in shared_atomic_add, etc).
634
# 2: For CompSwap only: the second data parameter.
635
#
636
# All SSBO operations take 3 sources except CompSwap that takes 4. These
637
# sources represent:
638
#
639
# 0: The SSBO buffer index.
640
# 1: The offset into the SSBO buffer of the variable that the atomic
641
# operation will operate on.
642
# 2: The data parameter to the atomic function (i.e. the value to add
643
# in ssbo_atomic_add, etc).
644
# 3: For CompSwap only: the second data parameter.
645
#
646
# All shared variable operations take 2 sources except CompSwap that takes 3.
647
# These sources represent:
648
#
649
# 0: The offset into the shared variable storage region that the atomic
650
# operation will operate on.
651
# 1: The data parameter to the atomic function (i.e. the value to add
652
# in shared_atomic_add, etc).
653
# 2: For CompSwap only: the second data parameter.
654
#
655
# All global operations take 2 sources except CompSwap that takes 3. These
656
# sources represent:
657
#
658
# 0: The memory address that the atomic operation will operate on.
659
# 1: The data parameter to the atomic function (i.e. the value to add
660
# in shared_atomic_add, etc).
661
# 2: For CompSwap only: the second data parameter.
662
663
def memory_atomic_data1(name):
664
intrinsic("deref_atomic_" + name, src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
665
intrinsic("ssbo_atomic_" + name, src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
666
intrinsic("shared_atomic_" + name, src_comp=[1, 1], dest_comp=1, indices=[BASE])
667
intrinsic("global_atomic_" + name, src_comp=[1, 1], dest_comp=1, indices=[BASE])
668
669
def memory_atomic_data2(name):
670
intrinsic("deref_atomic_" + name, src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
671
intrinsic("ssbo_atomic_" + name, src_comp=[-1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
672
intrinsic("shared_atomic_" + name, src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
673
intrinsic("global_atomic_" + name, src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
674
675
memory_atomic_data1("add")
676
memory_atomic_data1("imin")
677
memory_atomic_data1("umin")
678
memory_atomic_data1("imax")
679
memory_atomic_data1("umax")
680
memory_atomic_data1("and")
681
memory_atomic_data1("or")
682
memory_atomic_data1("xor")
683
memory_atomic_data1("exchange")
684
memory_atomic_data1("fadd")
685
memory_atomic_data1("fmin")
686
memory_atomic_data1("fmax")
687
memory_atomic_data2("comp_swap")
688
memory_atomic_data2("fcomp_swap")
689
690
def system_value(name, dest_comp, indices=[], bit_sizes=[32]):
691
intrinsic("load_" + name, [], dest_comp, indices,
692
flags=[CAN_ELIMINATE, CAN_REORDER], sysval=True,
693
bit_sizes=bit_sizes)
694
695
system_value("frag_coord", 4)
696
system_value("point_coord", 2)
697
system_value("line_coord", 1)
698
system_value("front_face", 1, bit_sizes=[1, 32])
699
system_value("vertex_id", 1)
700
system_value("vertex_id_zero_base", 1)
701
system_value("first_vertex", 1)
702
system_value("is_indexed_draw", 1)
703
system_value("base_vertex", 1)
704
system_value("instance_id", 1)
705
system_value("base_instance", 1)
706
system_value("draw_id", 1)
707
system_value("sample_id", 1)
708
# sample_id_no_per_sample is like sample_id but does not imply per-
709
# sample shading. See the lower_helper_invocation option.
710
system_value("sample_id_no_per_sample", 1)
711
system_value("sample_pos", 2)
712
system_value("sample_mask_in", 1)
713
system_value("primitive_id", 1)
714
system_value("invocation_id", 1)
715
system_value("tess_coord", 3)
716
system_value("tess_level_outer", 4)
717
system_value("tess_level_inner", 2)
718
system_value("tess_level_outer_default", 4)
719
system_value("tess_level_inner_default", 2)
720
system_value("patch_vertices_in", 1)
721
system_value("local_invocation_id", 3)
722
system_value("local_invocation_index", 1)
723
# zero_base indicates it starts from 0 for the current dispatch
724
# non-zero_base indicates the base is included
725
system_value("workgroup_id", 3, bit_sizes=[32, 64])
726
system_value("workgroup_id_zero_base", 3)
727
system_value("base_workgroup_id", 3, bit_sizes=[32, 64])
728
system_value("user_clip_plane", 4, indices=[UCP_ID])
729
system_value("num_workgroups", 3, bit_sizes=[32, 64])
730
system_value("helper_invocation", 1, bit_sizes=[1, 32])
731
system_value("layer_id", 1)
732
system_value("view_index", 1)
733
system_value("subgroup_size", 1)
734
system_value("subgroup_invocation", 1)
735
system_value("subgroup_eq_mask", 0, bit_sizes=[32, 64])
736
system_value("subgroup_ge_mask", 0, bit_sizes=[32, 64])
737
system_value("subgroup_gt_mask", 0, bit_sizes=[32, 64])
738
system_value("subgroup_le_mask", 0, bit_sizes=[32, 64])
739
system_value("subgroup_lt_mask", 0, bit_sizes=[32, 64])
740
system_value("num_subgroups", 1)
741
system_value("subgroup_id", 1)
742
system_value("workgroup_size", 3)
743
# note: the definition of global_invocation_id_zero_base is based on
744
# (workgroup_id * workgroup_size) + local_invocation_id.
745
# it is *not* based on workgroup_id_zero_base, meaning the work group
746
# base is already accounted for, and the global base is additive on top of that
747
system_value("global_invocation_id", 3, bit_sizes=[32, 64])
748
system_value("global_invocation_id_zero_base", 3, bit_sizes=[32, 64])
749
system_value("base_global_invocation_id", 3, bit_sizes=[32, 64])
750
system_value("global_invocation_index", 1, bit_sizes=[32, 64])
751
system_value("work_dim", 1)
752
system_value("line_width", 1)
753
system_value("aa_line_width", 1)
754
# BASE=0 for global/shader, BASE=1 for local/function
755
system_value("scratch_base_ptr", 0, bit_sizes=[32,64], indices=[BASE])
756
system_value("constant_base_ptr", 0, bit_sizes=[32,64])
757
system_value("shared_base_ptr", 0, bit_sizes=[32,64])
758
759
# System values for ray tracing.
760
system_value("ray_launch_id", 3)
761
system_value("ray_launch_size", 3)
762
system_value("ray_world_origin", 3)
763
system_value("ray_world_direction", 3)
764
system_value("ray_object_origin", 3)
765
system_value("ray_object_direction", 3)
766
system_value("ray_t_min", 1)
767
system_value("ray_t_max", 1)
768
system_value("ray_object_to_world", 3, indices=[COLUMN])
769
system_value("ray_world_to_object", 3, indices=[COLUMN])
770
system_value("ray_hit_kind", 1)
771
system_value("ray_flags", 1)
772
system_value("ray_geometry_index", 1)
773
system_value("ray_instance_custom_index", 1)
774
system_value("shader_record_ptr", 1, bit_sizes=[64])
775
776
# Driver-specific viewport scale/offset parameters.
777
#
778
# VC4 and V3D need to emit a scaled version of the position in the vertex
779
# shaders for binning, and having system values lets us move the math for that
780
# into NIR.
781
#
782
# Panfrost needs to implement all coordinate transformation in the
783
# vertex shader; system values allow us to share this routine in NIR.
784
#
785
# RADV uses these for NGG primitive culling.
786
system_value("viewport_x_scale", 1)
787
system_value("viewport_y_scale", 1)
788
system_value("viewport_z_scale", 1)
789
system_value("viewport_x_offset", 1)
790
system_value("viewport_y_offset", 1)
791
system_value("viewport_z_offset", 1)
792
system_value("viewport_scale", 3)
793
system_value("viewport_offset", 3)
794
795
# Blend constant color values. Float values are clamped. Vectored versions are
796
# provided as well for driver convenience
797
798
system_value("blend_const_color_r_float", 1)
799
system_value("blend_const_color_g_float", 1)
800
system_value("blend_const_color_b_float", 1)
801
system_value("blend_const_color_a_float", 1)
802
system_value("blend_const_color_rgba", 4)
803
system_value("blend_const_color_rgba8888_unorm", 1)
804
system_value("blend_const_color_aaaa8888_unorm", 1)
805
806
# System values for gl_Color, for radeonsi which interpolates these in the
807
# shader prolog to handle two-sided color without recompiles and therefore
808
# doesn't handle these in the main shader part like normal varyings.
809
system_value("color0", 4)
810
system_value("color1", 4)
811
812
# System value for internal compute shaders in radeonsi.
813
system_value("user_data_amd", 4)
814
815
# Barycentric coordinate intrinsics.
816
#
817
# These set up the barycentric coordinates for a particular interpolation.
818
# The first four are for the simple cases: pixel, centroid, per-sample
819
# (at gl_SampleID), or pull model (1/W, 1/I, 1/J) at the pixel center. The next
820
# two handle interpolating at a specified sample location, or interpolating
821
# with a vec2 offset,
822
#
823
# The interp_mode index should be either the INTERP_MODE_SMOOTH or
824
# INTERP_MODE_NOPERSPECTIVE enum values.
825
#
826
# The vec2 value produced by these intrinsics is intended for use as the
827
# barycoord source of a load_interpolated_input intrinsic.
828
829
def barycentric(name, dst_comp, src_comp=[]):
830
intrinsic("load_barycentric_" + name, src_comp=src_comp, dest_comp=dst_comp,
831
indices=[INTERP_MODE], flags=[CAN_ELIMINATE, CAN_REORDER])
832
833
# no sources.
834
barycentric("pixel", 2)
835
barycentric("centroid", 2)
836
barycentric("sample", 2)
837
barycentric("model", 3)
838
# src[] = { sample_id }.
839
barycentric("at_sample", 2, [1])
840
# src[] = { offset.xy }.
841
barycentric("at_offset", 2, [2])
842
843
# Load sample position:
844
#
845
# Takes a sample # and returns a sample position. Used for lowering
846
# interpolateAtSample() to interpolateAtOffset()
847
intrinsic("load_sample_pos_from_id", src_comp=[1], dest_comp=2,
848
flags=[CAN_ELIMINATE, CAN_REORDER])
849
850
# Loads what I believe is the primitive size, for scaling ij to pixel size:
851
intrinsic("load_size_ir3", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])
852
853
# Load texture scaling values:
854
#
855
# Takes a sampler # and returns 1/size values for multiplying to normalize
856
# texture coordinates. Used for lowering rect textures.
857
intrinsic("load_texture_rect_scaling", src_comp=[1], dest_comp=2,
858
flags=[CAN_ELIMINATE, CAN_REORDER])
859
860
# Fragment shader input interpolation delta intrinsic.
861
#
862
# For hw where fragment shader input interpolation is handled in shader, the
863
# load_fs_input_interp deltas intrinsics can be used to load the input deltas
864
# used for interpolation as follows:
865
#
866
# vec3 iid = load_fs_input_interp_deltas(varying_slot)
867
# vec2 bary = load_barycentric_*(...)
868
# float result = iid.x + iid.y * bary.y + iid.z * bary.x
869
870
intrinsic("load_fs_input_interp_deltas", src_comp=[1], dest_comp=3,
871
indices=[BASE, COMPONENT, IO_SEMANTICS], flags=[CAN_ELIMINATE, CAN_REORDER])
872
873
# Load operations pull data from some piece of GPU memory. All load
874
# operations operate in terms of offsets into some piece of theoretical
875
# memory. Loads from externally visible memory (UBO and SSBO) simply take a
876
# byte offset as a source. Loads from opaque memory (uniforms, inputs, etc.)
877
# take a base+offset pair where the nir_intrinsic_base() gives the location
878
# of the start of the variable being loaded and and the offset source is a
879
# offset into that variable.
880
#
881
# Uniform load operations have a nir_intrinsic_range() index that specifies the
882
# range (starting at base) of the data from which we are loading. If
883
# range == 0, then the range is unknown.
884
#
885
# UBO load operations have a nir_intrinsic_range_base() and
886
# nir_intrinsic_range() that specify the byte range [range_base,
887
# range_base+range] of the UBO that the src offset access must lie within.
888
#
889
# Some load operations such as UBO/SSBO load and per_vertex loads take an
890
# additional source to specify which UBO/SSBO/vertex to load from.
891
#
892
# The exact address type depends on the lowering pass that generates the
893
# load/store intrinsics. Typically, this is vec4 units for things such as
894
# varying slots and float units for fragment shader inputs. UBO and SSBO
895
# offsets are always in bytes.
896
897
def load(name, src_comp, indices=[], flags=[]):
898
intrinsic("load_" + name, src_comp, dest_comp=0, indices=indices,
899
flags=flags)
900
901
# src[] = { offset }.
902
load("uniform", [1], [BASE, RANGE, DEST_TYPE], [CAN_ELIMINATE, CAN_REORDER])
903
# src[] = { buffer_index, offset }.
904
load("ubo", [-1, 1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET, RANGE_BASE, RANGE], flags=[CAN_ELIMINATE, CAN_REORDER])
905
# src[] = { buffer_index, offset in vec4 units }
906
load("ubo_vec4", [-1, 1], [ACCESS, COMPONENT], flags=[CAN_ELIMINATE, CAN_REORDER])
907
# src[] = { offset }.
908
load("input", [1], [BASE, COMPONENT, DEST_TYPE, IO_SEMANTICS], [CAN_ELIMINATE, CAN_REORDER])
909
# src[] = { vertex_id, offset }.
910
load("input_vertex", [1, 1], [BASE, COMPONENT, DEST_TYPE, IO_SEMANTICS], [CAN_ELIMINATE, CAN_REORDER])
911
# src[] = { vertex, offset }.
912
load("per_vertex_input", [1, 1], [BASE, COMPONENT, DEST_TYPE, IO_SEMANTICS], [CAN_ELIMINATE, CAN_REORDER])
913
# src[] = { barycoord, offset }.
914
load("interpolated_input", [2, 1], [BASE, COMPONENT, DEST_TYPE, IO_SEMANTICS], [CAN_ELIMINATE, CAN_REORDER])
915
916
# src[] = { buffer_index, offset }.
917
load("ssbo", [-1, 1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
918
# src[] = { buffer_index }
919
load("ssbo_address", [1], [], [CAN_ELIMINATE, CAN_REORDER])
920
# src[] = { offset }.
921
load("output", [1], [BASE, COMPONENT, DEST_TYPE, IO_SEMANTICS], flags=[CAN_ELIMINATE])
922
# src[] = { vertex, offset }.
923
load("per_vertex_output", [1, 1], [BASE, COMPONENT, DEST_TYPE, IO_SEMANTICS], [CAN_ELIMINATE])
924
# src[] = { offset }.
925
load("shared", [1], [BASE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
926
# src[] = { offset }.
927
load("push_constant", [1], [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
928
# src[] = { offset }.
929
load("constant", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET],
930
[CAN_ELIMINATE, CAN_REORDER])
931
# src[] = { address }.
932
load("global", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
933
# src[] = { address }.
934
load("global_constant", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET],
935
[CAN_ELIMINATE, CAN_REORDER])
936
# src[] = { base_address, offset }.
937
load("global_constant_offset", [1, 1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET],
938
[CAN_ELIMINATE, CAN_REORDER])
939
# src[] = { base_address, offset, bound }.
940
load("global_constant_bounded", [1, 1, 1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET],
941
[CAN_ELIMINATE, CAN_REORDER])
942
# src[] = { address }.
943
load("kernel_input", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE, CAN_REORDER])
944
# src[] = { offset }.
945
load("scratch", [1], [ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
946
947
# Stores work the same way as loads, except now the first source is the value
948
# to store and the second (and possibly third) source specify where to store
949
# the value. SSBO and shared memory stores also have a
950
# nir_intrinsic_write_mask()
951
952
def store(name, srcs, indices=[], flags=[]):
953
intrinsic("store_" + name, [0] + srcs, indices=indices, flags=flags)
954
955
# src[] = { value, offset }.
956
store("output", [1], [BASE, WRITE_MASK, COMPONENT, SRC_TYPE, IO_SEMANTICS])
957
# src[] = { value, vertex, offset }.
958
store("per_vertex_output", [1, 1], [BASE, WRITE_MASK, COMPONENT, SRC_TYPE, IO_SEMANTICS])
959
# src[] = { value, block_index, offset }
960
store("ssbo", [-1, 1], [WRITE_MASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
961
# src[] = { value, offset }.
962
store("shared", [1], [BASE, WRITE_MASK, ALIGN_MUL, ALIGN_OFFSET])
963
# src[] = { value, address }.
964
store("global", [1], [WRITE_MASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
965
# src[] = { value, offset }.
966
store("scratch", [1], [ALIGN_MUL, ALIGN_OFFSET, WRITE_MASK])
967
968
# A bit field to implement SPIRV FragmentShadingRateKHR
969
# bit | name | description
970
# 0 | Vertical2Pixels | Fragment invocation covers 2 pixels vertically
971
# 1 | Vertical4Pixels | Fragment invocation covers 4 pixels vertically
972
# 2 | Horizontal2Pixels | Fragment invocation covers 2 pixels horizontally
973
# 3 | Horizontal4Pixels | Fragment invocation covers 4 pixels horizontally
974
intrinsic("load_frag_shading_rate", dest_comp=1, bit_sizes=[32],
975
flags=[CAN_ELIMINATE, CAN_REORDER])
976
977
# OpenCL printf instruction
978
# First source is a deref to the format string
979
# Second source is a deref to a struct containing the args
980
# Dest is success or failure
981
intrinsic("printf", src_comp=[1, 1], dest_comp=1, bit_sizes=[32])
982
# Since most drivers will want to lower to just dumping args
983
# in a buffer, nir_lower_printf will do that, but requires
984
# the driver to at least provide a base location
985
system_value("printf_buffer_address", 1, bit_sizes=[32,64])
986
987
# IR3-specific version of most SSBO intrinsics. The only different
988
# compare to the originals is that they add an extra source to hold
989
# the dword-offset, which is needed by the backend code apart from
990
# the byte-offset already provided by NIR in one of the sources.
991
#
992
# NIR lowering pass 'ir3_nir_lower_io_offset' will replace the
993
# original SSBO intrinsics by these, placing the computed
994
# dword-offset always in the last source.
995
#
996
# The float versions are not handled because those are not supported
997
# by the backend.
998
store("ssbo_ir3", [1, 1, 1],
999
indices=[WRITE_MASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
1000
load("ssbo_ir3", [1, 1, 1],
1001
indices=[ACCESS, ALIGN_MUL, ALIGN_OFFSET], flags=[CAN_ELIMINATE])
1002
intrinsic("ssbo_atomic_add_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1003
intrinsic("ssbo_atomic_imin_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1004
intrinsic("ssbo_atomic_umin_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1005
intrinsic("ssbo_atomic_imax_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1006
intrinsic("ssbo_atomic_umax_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1007
intrinsic("ssbo_atomic_and_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1008
intrinsic("ssbo_atomic_or_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1009
intrinsic("ssbo_atomic_xor_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1010
intrinsic("ssbo_atomic_exchange_ir3", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1011
intrinsic("ssbo_atomic_comp_swap_ir3", src_comp=[1, 1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
1012
1013
# System values for freedreno geometry shaders.
1014
system_value("vs_primitive_stride_ir3", 1)
1015
system_value("vs_vertex_stride_ir3", 1)
1016
system_value("gs_header_ir3", 1)
1017
system_value("primitive_location_ir3", 1, indices=[DRIVER_LOCATION])
1018
1019
# System values for freedreno tessellation shaders.
1020
system_value("hs_patch_stride_ir3", 1)
1021
system_value("tess_factor_base_ir3", 2)
1022
system_value("tess_param_base_ir3", 2)
1023
system_value("tcs_header_ir3", 1)
1024
1025
# System values for freedreno compute shaders.
1026
system_value("subgroup_id_shift_ir3", 1)
1027
1028
# IR3-specific intrinsics for tessellation control shaders. cond_end_ir3 end
1029
# the shader when src0 is false and is used to narrow down the TCS shader to
1030
# just thread 0 before writing out tessellation levels.
1031
intrinsic("cond_end_ir3", src_comp=[1])
1032
# end_patch_ir3 is used just before thread 0 exist the TCS and presumably
1033
# signals the TE that the patch is complete and can be tessellated.
1034
intrinsic("end_patch_ir3")
1035
1036
# IR3-specific load/store intrinsics. These access a buffer used to pass data
1037
# between geometry stages - perhaps it's explicit access to the vertex cache.
1038
1039
# src[] = { value, offset }.
1040
store("shared_ir3", [1], [BASE, ALIGN_MUL, ALIGN_OFFSET])
1041
# src[] = { offset }.
1042
load("shared_ir3", [1], [BASE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
1043
1044
# IR3-specific load/store global intrinsics. They take a 64-bit base address
1045
# and a 32-bit offset. The hardware will add the base and the offset, which
1046
# saves us from doing 64-bit math on the base address.
1047
1048
# src[] = { value, address(vec2 of hi+lo uint32_t), offset }.
1049
# const_index[] = { write_mask, align_mul, align_offset }
1050
store("global_ir3", [2, 1], indices=[ACCESS, ALIGN_MUL, ALIGN_OFFSET])
1051
# src[] = { address(vec2 of hi+lo uint32_t), offset }.
1052
# const_index[] = { access, align_mul, align_offset }
1053
load("global_ir3", [2, 1], indices=[ACCESS, ALIGN_MUL, ALIGN_OFFSET], flags=[CAN_ELIMINATE])
1054
1055
# IR3-specific bindless handle specifier. Similar to vulkan_resource_index, but
1056
# without the binding because the hardware expects a single flattened index
1057
# rather than a (binding, index) pair. We may also want to use this with GL.
1058
# Note that this doesn't actually turn into a HW instruction.
1059
intrinsic("bindless_resource_ir3", [1], dest_comp=1, indices=[DESC_SET], flags=[CAN_ELIMINATE, CAN_REORDER])
1060
1061
# DXIL specific intrinsics
1062
# src[] = { value, mask, index, offset }.
1063
intrinsic("store_ssbo_masked_dxil", [1, 1, 1, 1])
1064
# src[] = { value, index }.
1065
intrinsic("store_shared_dxil", [1, 1])
1066
# src[] = { value, mask, index }.
1067
intrinsic("store_shared_masked_dxil", [1, 1, 1])
1068
# src[] = { value, index }.
1069
intrinsic("store_scratch_dxil", [1, 1])
1070
# src[] = { index }.
1071
load("shared_dxil", [1], [], [CAN_ELIMINATE])
1072
# src[] = { index }.
1073
load("scratch_dxil", [1], [], [CAN_ELIMINATE])
1074
# src[] = { deref_var, offset }
1075
load("ptr_dxil", [1, 1], [], [])
1076
# src[] = { index, 16-byte-based-offset }
1077
load("ubo_dxil", [1, 1], [], [CAN_ELIMINATE])
1078
1079
# DXIL Shared atomic intrinsics
1080
#
1081
# All of the shared variable atomic memory operations read a value from
1082
# memory, compute a new value using one of the operations below, write the
1083
# new value to memory, and return the original value read.
1084
#
1085
# All operations take 2 sources:
1086
#
1087
# 0: The index in the i32 array for by the shared memory region
1088
# 1: The data parameter to the atomic function (i.e. the value to add
1089
# in shared_atomic_add, etc).
1090
intrinsic("shared_atomic_add_dxil", src_comp=[1, 1], dest_comp=1)
1091
intrinsic("shared_atomic_imin_dxil", src_comp=[1, 1], dest_comp=1)
1092
intrinsic("shared_atomic_umin_dxil", src_comp=[1, 1], dest_comp=1)
1093
intrinsic("shared_atomic_imax_dxil", src_comp=[1, 1], dest_comp=1)
1094
intrinsic("shared_atomic_umax_dxil", src_comp=[1, 1], dest_comp=1)
1095
intrinsic("shared_atomic_and_dxil", src_comp=[1, 1], dest_comp=1)
1096
intrinsic("shared_atomic_or_dxil", src_comp=[1, 1], dest_comp=1)
1097
intrinsic("shared_atomic_xor_dxil", src_comp=[1, 1], dest_comp=1)
1098
intrinsic("shared_atomic_exchange_dxil", src_comp=[1, 1], dest_comp=1)
1099
intrinsic("shared_atomic_comp_swap_dxil", src_comp=[1, 1, 1], dest_comp=1)
1100
1101
# Intrinsics used by the Midgard/Bifrost blend pipeline. These are defined
1102
# within a blend shader to read/write the raw value from the tile buffer,
1103
# without applying any format conversion in the process. If the shader needs
1104
# usable pixel values, it must apply format conversions itself.
1105
#
1106
# These definitions are generic, but they are explicitly vendored to prevent
1107
# other drivers from using them, as their semantics is defined in terms of the
1108
# Midgard/Bifrost hardware tile buffer and may not line up with anything sane.
1109
# One notable divergence is sRGB, which is asymmetric: raw_input_pan requires
1110
# an sRGB->linear conversion, but linear values should be written to
1111
# raw_output_pan and the hardware handles linear->sRGB.
1112
1113
# src[] = { value }
1114
store("raw_output_pan", [], [])
1115
store("combined_output_pan", [1, 1, 1], [BASE, COMPONENT, SRC_TYPE])
1116
load("raw_output_pan", [1], [BASE], [CAN_ELIMINATE, CAN_REORDER])
1117
1118
# Loads the sampler paramaters <min_lod, max_lod, lod_bias>
1119
# src[] = { sampler_index }
1120
load("sampler_lod_parameters_pan", [1], flags=[CAN_ELIMINATE, CAN_REORDER])
1121
1122
# Loads the sample position array on Bifrost, in a packed Arm-specific format
1123
system_value("sample_positions_pan", 1, bit_sizes=[64])
1124
1125
# R600 specific instrincs
1126
#
1127
# location where the tesselation data is stored in LDS
1128
system_value("tcs_in_param_base_r600", 4)
1129
system_value("tcs_out_param_base_r600", 4)
1130
system_value("tcs_rel_patch_id_r600", 1)
1131
system_value("tcs_tess_factor_base_r600", 1)
1132
1133
# the tess coords come as xy only, z has to be calculated
1134
system_value("tess_coord_r600", 2)
1135
1136
# load as many components as needed giving per-component addresses
1137
intrinsic("load_local_shared_r600", src_comp=[0], dest_comp=0, indices = [], flags = [CAN_ELIMINATE])
1138
1139
store("local_shared_r600", [1], [WRITE_MASK])
1140
store("tf_r600", [])
1141
1142
# AMD GCN/RDNA specific intrinsics
1143
1144
# src[] = { descriptor, base address, scalar offset }
1145
intrinsic("load_buffer_amd", src_comp=[4, 1, 1], dest_comp=0, indices=[BASE, IS_SWIZZLED, SLC_AMD, MEMORY_MODES], flags=[CAN_ELIMINATE])
1146
# src[] = { store value, descriptor, base address, scalar offset }
1147
intrinsic("store_buffer_amd", src_comp=[0, 4, 1, 1], indices=[BASE, WRITE_MASK, IS_SWIZZLED, SLC_AMD, MEMORY_MODES])
1148
1149
# Same as shared_atomic_add, but with GDS. src[] = {store_val, gds_addr, m0}
1150
intrinsic("gds_atomic_add_amd", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
1151
1152
# Descriptor where TCS outputs are stored for TES
1153
system_value("ring_tess_offchip_amd", 4)
1154
system_value("ring_tess_offchip_offset_amd", 1)
1155
# Descriptor where TCS outputs are stored for the HW tessellator
1156
system_value("ring_tess_factors_amd", 4)
1157
system_value("ring_tess_factors_offset_amd", 1)
1158
# Descriptor where ES outputs are stored for GS to read on GFX6-8
1159
system_value("ring_esgs_amd", 4)
1160
system_value("ring_es2gs_offset_amd", 1)
1161
1162
# Number of patches processed by each TCS workgroup
1163
system_value("tcs_num_patches_amd", 1)
1164
# Relative tessellation patch ID within the current workgroup
1165
system_value("tess_rel_patch_id_amd", 1)
1166
# Vertex offsets used for GS per-vertex inputs
1167
system_value("gs_vertex_offset_amd", 1, [BASE])
1168
1169
# AMD merged shader intrinsics
1170
1171
# Whether the current invocation has an input vertex / primitive to process (also known as "ES thread" or "GS thread").
1172
# Not safe to reorder because it changes after overwrite_subgroup_num_vertices_and_primitives_amd.
1173
# Also, the generated code is more optimal if they are not CSE'd.
1174
intrinsic("has_input_vertex_amd", src_comp=[], dest_comp=1, bit_sizes=[1], indices=[])
1175
intrinsic("has_input_primitive_amd", src_comp=[], dest_comp=1, bit_sizes=[1], indices=[])
1176
1177
# AMD NGG intrinsics
1178
1179
# Number of initial input vertices in the current workgroup.
1180
system_value("workgroup_num_input_vertices_amd", 1)
1181
# Number of initial input primitives in the current workgroup.
1182
system_value("workgroup_num_input_primitives_amd", 1)
1183
# For NGG passthrough mode only. Pre-packed argument for export_primitive_amd.
1184
system_value("packed_passthrough_primitive_amd", 1)
1185
# Whether NGG GS should execute shader query.
1186
system_value("shader_query_enabled_amd", dest_comp=1, bit_sizes=[1])
1187
# Whether the shader should cull front facing triangles.
1188
intrinsic("load_cull_front_face_enabled_amd", dest_comp=1, bit_sizes=[1], flags=[CAN_ELIMINATE])
1189
# Whether the shader should cull back facing triangles.
1190
intrinsic("load_cull_back_face_enabled_amd", dest_comp=1, bit_sizes=[1], flags=[CAN_ELIMINATE])
1191
# True if face culling should use CCW (false if CW).
1192
intrinsic("load_cull_ccw_amd", dest_comp=1, bit_sizes=[1], flags=[CAN_ELIMINATE])
1193
# Whether the shader should cull small primitives that are not visible in a pixel.
1194
intrinsic("load_cull_small_primitives_enabled_amd", dest_comp=1, bit_sizes=[1], flags=[CAN_ELIMINATE])
1195
# Whether any culling setting is enabled in the shader.
1196
intrinsic("load_cull_any_enabled_amd", dest_comp=1, bit_sizes=[1], flags=[CAN_ELIMINATE])
1197
# Small primitive culling precision
1198
intrinsic("load_cull_small_prim_precision_amd", dest_comp=1, bit_sizes=[32], flags=[CAN_ELIMINATE, CAN_REORDER])
1199
# Initial edge flag in a Vertex Shader. src = {vertex index}.
1200
intrinsic("load_initial_edgeflag_amd", src_comp=[1], dest_comp=1, indices=[])
1201
# Exports the current invocation's vertex. This is a placeholder where all vertex attribute export instructions should be emitted.
1202
intrinsic("export_vertex_amd", src_comp=[], indices=[])
1203
# Exports the current invocation's primitive. src[] = {packed_primitive_data}.
1204
intrinsic("export_primitive_amd", src_comp=[1], indices=[])
1205
# Allocates export space for vertices and primitives. src[] = {num_vertices, num_primitives}.
1206
intrinsic("alloc_vertices_and_primitives_amd", src_comp=[1, 1], indices=[])
1207
# Overwrites VS input registers, for use with vertex compaction after culling. src = {vertex_id, instance_id}.
1208
intrinsic("overwrite_vs_arguments_amd", src_comp=[1, 1], indices=[])
1209
# Overwrites TES input registers, for use with vertex compaction after culling. src = {tes_u, tes_v, rel_patch_id, patch_id}.
1210
intrinsic("overwrite_tes_arguments_amd", src_comp=[1, 1, 1, 1], indices=[])
1211
# Overwrites the input vertex and primitive count in the current subgroup after culling. src = {num_vertices, num_primitives}.
1212
intrinsic("overwrite_subgroup_num_vertices_and_primitives_amd", src_comp=[1, 1], indices=[])
1213
1214
# src = [index] BINDING = which table BASE = offset within handle
1215
intrinsic("load_sbt_amd", src_comp=[-1], dest_comp=0, indices=[BINDING, BASE],
1216
flags=[CAN_ELIMINATE, CAN_REORDER])
1217
1218
# 1. HW descriptor
1219
# 2. BVH node(64-bit pointer as 2x32 ...)
1220
# 3. ray extent
1221
# 4. ray origin
1222
# 5. ray direction
1223
# 6. inverse ray direction (componentwise 1.0/ray direction)
1224
intrinsic("bvh64_intersect_ray_amd", [4, 2, 1, 3, 3, 3], 4, flags=[CAN_ELIMINATE, CAN_REORDER])
1225
1226
# V3D-specific instrinc for tile buffer color reads.
1227
#
1228
# The hardware requires that we read the samples and components of a pixel
1229
# in order, so we cannot eliminate or remove any loads in a sequence.
1230
#
1231
# src[] = { render_target }
1232
# BASE = sample index
1233
load("tlb_color_v3d", [1], [BASE, COMPONENT], [])
1234
1235
# V3D-specific instrinc for per-sample tile buffer color writes.
1236
#
1237
# The driver backend needs to identify per-sample color writes and emit
1238
# specific code for them.
1239
#
1240
# src[] = { value, render_target }
1241
# BASE = sample index
1242
store("tlb_sample_color_v3d", [1], [BASE, COMPONENT, SRC_TYPE], [])
1243
1244
# V3D-specific intrinsic to load the number of layers attached to
1245
# the target framebuffer
1246
intrinsic("load_fb_layers_v3d", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])
1247
1248
# Logical complement of load_front_face, mapping to an AGX system value
1249
system_value("back_face_agx", 1, bit_sizes=[1, 32])
1250
1251
# Intel-specific query for loading from the brw_image_param struct passed
1252
# into the shader as a uniform. The variable is a deref to the image
1253
# variable. The const index specifies which of the six parameters to load.
1254
intrinsic("image_deref_load_param_intel", src_comp=[1], dest_comp=0,
1255
indices=[BASE], flags=[CAN_ELIMINATE, CAN_REORDER])
1256
image("load_raw_intel", src_comp=[1], dest_comp=0,
1257
flags=[CAN_ELIMINATE])
1258
image("store_raw_intel", src_comp=[1, 0])
1259
1260
# Intrinsic to load a block of at least 32B of constant data from a 64-bit
1261
# global memory address. The memory address must be uniform and 32B-aligned.
1262
# The second source is a predicate which indicates whether or not to actually
1263
# do the load.
1264
# src[] = { address, predicate }.
1265
intrinsic("load_global_const_block_intel", src_comp=[1, 1], dest_comp=0,
1266
bit_sizes=[32], indices=[BASE], flags=[CAN_ELIMINATE, CAN_REORDER])
1267
1268
# Number of data items being operated on for a SIMD program.
1269
system_value("simd_width_intel", 1)
1270
1271
# Load a relocatable 32-bit value
1272
intrinsic("load_reloc_const_intel", dest_comp=1, bit_sizes=[32],
1273
indices=[PARAM_IDX], flags=[CAN_ELIMINATE, CAN_REORDER])
1274
1275
# 64-bit global address for a Vulkan descriptor set
1276
# src[0] = { set }
1277
intrinsic("load_desc_set_address_intel", dest_comp=1, bit_sizes=[64],
1278
src_comp=[1], flags=[CAN_ELIMINATE, CAN_REORDER])
1279
1280
# OpSubgroupBlockReadINTEL and OpSubgroupBlockWriteINTEL from SPV_INTEL_subgroups.
1281
intrinsic("load_deref_block_intel", dest_comp=0, src_comp=[-1],
1282
indices=[ACCESS], flags=[CAN_ELIMINATE])
1283
intrinsic("store_deref_block_intel", src_comp=[-1, 0], indices=[WRITE_MASK, ACCESS])
1284
1285
# src[] = { address }.
1286
load("global_block_intel", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
1287
1288
# src[] = { buffer_index, offset }.
1289
load("ssbo_block_intel", [-1, 1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
1290
1291
# src[] = { offset }.
1292
load("shared_block_intel", [1], [BASE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
1293
1294
# src[] = { value, address }.
1295
store("global_block_intel", [1], [WRITE_MASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
1296
1297
# src[] = { value, block_index, offset }
1298
store("ssbo_block_intel", [-1, 1], [WRITE_MASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
1299
1300
# src[] = { value, offset }.
1301
store("shared_block_intel", [1], [BASE, WRITE_MASK, ALIGN_MUL, ALIGN_OFFSET])
1302
1303
# Intrinsics for Intel bindless thread dispatch
1304
system_value("btd_dss_id_intel", 1)
1305
system_value("btd_stack_id_intel", 1)
1306
system_value("btd_global_arg_addr_intel", 1, bit_sizes=[64])
1307
system_value("btd_local_arg_addr_intel", 1, bit_sizes=[64])
1308
system_value("btd_resume_sbt_addr_intel", 1, bit_sizes=[64])
1309
# src[] = { global_arg_addr, btd_record }
1310
intrinsic("btd_spawn_intel", src_comp=[1, 1])
1311
# RANGE=stack_size
1312
intrinsic("btd_stack_push_intel", indices=[STACK_SIZE])
1313
# src[] = { }
1314
intrinsic("btd_retire_intel")
1315
1316
# Intel-specific ray-tracing intrinsics
1317
intrinsic("trace_ray_initial_intel")
1318
intrinsic("trace_ray_commit_intel")
1319
intrinsic("trace_ray_continue_intel")
1320
1321
# System values used for ray-tracing on Intel
1322
system_value("ray_base_mem_addr_intel", 1, bit_sizes=[64])
1323
system_value("ray_hw_stack_size_intel", 1)
1324
system_value("ray_sw_stack_size_intel", 1)
1325
system_value("ray_num_dss_rt_stacks_intel", 1)
1326
system_value("ray_hit_sbt_addr_intel", 1, bit_sizes=[64])
1327
system_value("ray_hit_sbt_stride_intel", 1, bit_sizes=[16])
1328
system_value("ray_miss_sbt_addr_intel", 1, bit_sizes=[64])
1329
system_value("ray_miss_sbt_stride_intel", 1, bit_sizes=[16])
1330
system_value("callable_sbt_addr_intel", 1, bit_sizes=[64])
1331
system_value("callable_sbt_stride_intel", 1, bit_sizes=[16])
1332
system_value("leaf_opaque_intel", 1, bit_sizes=[1])
1333
system_value("leaf_procedural_intel", 1, bit_sizes=[1])
1334
1335