nir: Rename nir_intrinsic_barrier to control_barrier
[mesa.git] / src / compiler / nir / nir_intrinsics.py
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 class Intrinsic(object):
31 """Class that represents all the information about an intrinsic opcode.
32 NOTE: this must be kept in sync with nir_intrinsic_info.
33 """
34 def __init__(self, name, src_components, dest_components,
35 indices, flags, sysval, bit_sizes):
36 """Parameters:
37
38 - name: the intrinsic name
39 - src_components: list of the number of components per src, 0 means
40 vectorized instruction with number of components given in the
41 num_components field in nir_intrinsic_instr.
42 - dest_components: number of destination components, -1 means no
43 dest, 0 means number of components given in num_components field
44 in nir_intrinsic_instr.
45 - indices: list of constant indicies
46 - flags: list of semantic flags
47 - sysval: is this a system-value intrinsic
48 - bit_sizes: allowed dest bit_sizes
49 """
50 assert isinstance(name, str)
51 assert isinstance(src_components, list)
52 if src_components:
53 assert isinstance(src_components[0], int)
54 assert isinstance(dest_components, int)
55 assert isinstance(indices, list)
56 if indices:
57 assert isinstance(indices[0], str)
58 assert isinstance(flags, list)
59 if flags:
60 assert isinstance(flags[0], str)
61 assert isinstance(sysval, bool)
62 if bit_sizes:
63 assert isinstance(bit_sizes[0], int)
64
65 self.name = name
66 self.num_srcs = len(src_components)
67 self.src_components = src_components
68 self.has_dest = (dest_components >= 0)
69 self.dest_components = dest_components
70 self.num_indices = len(indices)
71 self.indices = indices
72 self.flags = flags
73 self.sysval = sysval
74 self.bit_sizes = bit_sizes
75
76 #
77 # Possible indices:
78 #
79
80 # A constant 'base' value that is added to an offset src:
81 BASE = "NIR_INTRINSIC_BASE"
82 # For store instructions, a writemask:
83 WRMASK = "NIR_INTRINSIC_WRMASK"
84 # The stream-id for GS emit_vertex/end_primitive intrinsics:
85 STREAM_ID = "NIR_INTRINSIC_STREAM_ID"
86 # The clip-plane id for load_user_clip_plane intrinsics:
87 UCP_ID = "NIR_INTRINSIC_UCP_ID"
88 # The amount of data, starting from BASE, that this instruction
89 # may access. This is used to provide bounds if the offset is
90 # not constant.
91 RANGE = "NIR_INTRINSIC_RANGE"
92 # The vulkan descriptor set binding for vulkan_resource_index
93 # intrinsic
94 DESC_SET = "NIR_INTRINSIC_DESC_SET"
95 # The vulkan descriptor set binding for vulkan_resource_index
96 # intrinsic
97 BINDING = "NIR_INTRINSIC_BINDING"
98 # Component offset
99 COMPONENT = "NIR_INTRINSIC_COMPONENT"
100 # Interpolation mode (only meaningful for FS inputs)
101 INTERP_MODE = "NIR_INTRINSIC_INTERP_MODE"
102 # A binary nir_op to use when performing a reduction or scan operation
103 REDUCTION_OP = "NIR_INTRINSIC_REDUCTION_OP"
104 # Cluster size for reduction operations
105 CLUSTER_SIZE = "NIR_INTRINSIC_CLUSTER_SIZE"
106 # Parameter index for a load_param intrinsic
107 PARAM_IDX = "NIR_INTRINSIC_PARAM_IDX"
108 # Image dimensionality for image intrinsics
109 IMAGE_DIM = "NIR_INTRINSIC_IMAGE_DIM"
110 # Non-zero if we are accessing an array image
111 IMAGE_ARRAY = "NIR_INTRINSIC_IMAGE_ARRAY"
112 # Access qualifiers for image and memory access intrinsics
113 ACCESS = "NIR_INTRINSIC_ACCESS"
114 DST_ACCESS = "NIR_INTRINSIC_DST_ACCESS"
115 SRC_ACCESS = "NIR_INTRINSIC_SRC_ACCESS"
116 # Image format for image intrinsics
117 FORMAT = "NIR_INTRINSIC_FORMAT"
118 # Offset or address alignment
119 ALIGN_MUL = "NIR_INTRINSIC_ALIGN_MUL"
120 ALIGN_OFFSET = "NIR_INTRINSIC_ALIGN_OFFSET"
121 # The vulkan descriptor type for vulkan_resource_index
122 DESC_TYPE = "NIR_INTRINSIC_DESC_TYPE"
123 # The nir_alu_type of a uniform/input/output
124 TYPE = "NIR_INTRINSIC_TYPE"
125 # The swizzle mask for quad_swizzle_amd & masked_swizzle_amd
126 SWIZZLE_MASK = "NIR_INTRINSIC_SWIZZLE_MASK"
127 # Driver location of attribute
128 DRIVER_LOCATION = "NIR_INTRINSIC_DRIVER_LOCATION"
129 # Ordering and visibility of a memory operation
130 MEMORY_SEMANTICS = "NIR_INTRINSIC_MEMORY_SEMANTICS"
131 # Modes affected by a memory operation
132 MEMORY_MODES = "NIR_INTRINSIC_MEMORY_MODES"
133 # Scope of a memory operation
134 MEMORY_SCOPE = "NIR_INTRINSIC_MEMORY_SCOPE"
135
136 #
137 # Possible flags:
138 #
139
140 CAN_ELIMINATE = "NIR_INTRINSIC_CAN_ELIMINATE"
141 CAN_REORDER = "NIR_INTRINSIC_CAN_REORDER"
142
143 INTR_OPCODES = {}
144
145 # Defines a new NIR intrinsic. By default, the intrinsic will have no sources
146 # and no destination.
147 #
148 # You can set dest_comp=n to enable a destination for the intrinsic, in which
149 # case it will have that many components, or =0 for "as many components as the
150 # NIR destination value."
151 #
152 # Set src_comp=n to enable sources for the intruction. It can be an array of
153 # component counts, or (for convenience) a scalar component count if there's
154 # only one source. If a component count is 0, it will be as many components as
155 # the intrinsic has based on the dest_comp.
156 def intrinsic(name, src_comp=[], dest_comp=-1, indices=[],
157 flags=[], sysval=False, bit_sizes=[]):
158 assert name not in INTR_OPCODES
159 INTR_OPCODES[name] = Intrinsic(name, src_comp, dest_comp,
160 indices, flags, sysval, bit_sizes)
161
162 intrinsic("nop", flags=[CAN_ELIMINATE])
163
164 intrinsic("load_param", dest_comp=0, indices=[PARAM_IDX], flags=[CAN_ELIMINATE])
165
166 intrinsic("load_deref", dest_comp=0, src_comp=[-1],
167 indices=[ACCESS], flags=[CAN_ELIMINATE])
168 intrinsic("store_deref", src_comp=[-1, 0], indices=[WRMASK, ACCESS])
169 intrinsic("copy_deref", src_comp=[-1, -1], indices=[DST_ACCESS, SRC_ACCESS])
170
171 # Interpolation of input. The interp_deref_at* intrinsics are similar to the
172 # load_var intrinsic acting on a shader input except that they interpolate the
173 # input differently. The at_sample and at_offset intrinsics take an
174 # additional source that is an integer sample id or a vec2 position offset
175 # respectively.
176
177 intrinsic("interp_deref_at_centroid", dest_comp=0, src_comp=[1],
178 flags=[ CAN_ELIMINATE, CAN_REORDER])
179 intrinsic("interp_deref_at_sample", src_comp=[1, 1], dest_comp=0,
180 flags=[CAN_ELIMINATE, CAN_REORDER])
181 intrinsic("interp_deref_at_offset", src_comp=[1, 2], dest_comp=0,
182 flags=[CAN_ELIMINATE, CAN_REORDER])
183
184 # Gets the length of an unsized array at the end of a buffer
185 intrinsic("deref_buffer_array_length", src_comp=[-1], dest_comp=1,
186 flags=[CAN_ELIMINATE, CAN_REORDER])
187
188 # Ask the driver for the size of a given buffer. It takes the buffer index
189 # as source.
190 intrinsic("get_buffer_size", src_comp=[-1], dest_comp=1,
191 flags=[CAN_ELIMINATE, CAN_REORDER])
192
193 # a barrier is an intrinsic with no inputs/outputs but which can't be moved
194 # around/optimized in general
195 def barrier(name):
196 intrinsic(name)
197
198 barrier("discard")
199
200 # Demote fragment shader invocation to a helper invocation. Any stores to
201 # memory after this instruction are suppressed and the fragment does not write
202 # outputs to the framebuffer. Unlike discard, demote needs to ensure that
203 # derivatives will still work for invocations that were not demoted.
204 #
205 # As specified by SPV_EXT_demote_to_helper_invocation.
206 barrier("demote")
207 intrinsic("is_helper_invocation", dest_comp=1, flags=[CAN_ELIMINATE])
208
209 # A workgroup-level control barrier. Any thread which hits this barrier will
210 # pause until all threads within the current workgroup have also hit the
211 # barrier. For compute shaders, the workgroup is defined as the local group.
212 # For tessellation control shaders, the workgroup is defined as the current
213 # patch. This intrinsic does not imply any sort of memory barrier.
214 barrier("control_barrier")
215
216 # Memory barrier with semantics analogous to the memoryBarrier() GLSL
217 # intrinsic.
218 barrier("memory_barrier")
219
220 # Memory barrier with explicit scope. Follows the semantics of SPIR-V
221 # OpMemoryBarrier, used to implement Vulkan Memory Model. Storage that the
222 # barrierr applies is represented using NIR variable modes.
223 intrinsic("scoped_memory_barrier",
224 indices=[MEMORY_SEMANTICS, MEMORY_MODES, MEMORY_SCOPE])
225
226 # Shader clock intrinsic with semantics analogous to the clock2x32ARB()
227 # GLSL intrinsic.
228 # The latter can be used as code motion barrier, which is currently not
229 # feasible with NIR.
230 intrinsic("shader_clock", dest_comp=2, flags=[CAN_ELIMINATE])
231
232 # Shader ballot intrinsics with semantics analogous to the
233 #
234 # ballotARB()
235 # readInvocationARB()
236 # readFirstInvocationARB()
237 #
238 # GLSL functions from ARB_shader_ballot.
239 intrinsic("ballot", src_comp=[1], dest_comp=0, flags=[CAN_ELIMINATE])
240 intrinsic("read_invocation", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
241 intrinsic("read_first_invocation", src_comp=[0], dest_comp=0, flags=[CAN_ELIMINATE])
242
243 # Additional SPIR-V ballot intrinsics
244 #
245 # These correspond to the SPIR-V opcodes
246 #
247 # OpGroupUniformElect
248 # OpSubgroupFirstInvocationKHR
249 intrinsic("elect", dest_comp=1, flags=[CAN_ELIMINATE])
250 intrinsic("first_invocation", dest_comp=1, flags=[CAN_ELIMINATE])
251
252 # Memory barrier with semantics analogous to the compute shader
253 # groupMemoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(),
254 # memoryBarrierImage() and memoryBarrierShared() GLSL intrinsics.
255 barrier("group_memory_barrier")
256 barrier("memory_barrier_atomic_counter")
257 barrier("memory_barrier_buffer")
258 barrier("memory_barrier_image")
259 barrier("memory_barrier_shared")
260 barrier("begin_invocation_interlock")
261 barrier("end_invocation_interlock")
262
263 # Memory barrier for synchronizing TCS patch outputs
264 barrier("memory_barrier_tcs_patch")
265
266 # A conditional discard/demote, with a single boolean source.
267 intrinsic("discard_if", src_comp=[1])
268 intrinsic("demote_if", src_comp=[1])
269
270 # ARB_shader_group_vote intrinsics
271 intrinsic("vote_any", src_comp=[1], dest_comp=1, flags=[CAN_ELIMINATE])
272 intrinsic("vote_all", src_comp=[1], dest_comp=1, flags=[CAN_ELIMINATE])
273 intrinsic("vote_feq", src_comp=[0], dest_comp=1, flags=[CAN_ELIMINATE])
274 intrinsic("vote_ieq", src_comp=[0], dest_comp=1, flags=[CAN_ELIMINATE])
275
276 # Ballot ALU operations from SPIR-V.
277 #
278 # These operations work like their ALU counterparts except that the operate
279 # on a uvec4 which is treated as a 128bit integer. Also, they are, in
280 # general, free to ignore any bits which are above the subgroup size.
281 intrinsic("ballot_bitfield_extract", src_comp=[4, 1], dest_comp=1, flags=[CAN_ELIMINATE])
282 intrinsic("ballot_bit_count_reduce", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
283 intrinsic("ballot_bit_count_inclusive", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
284 intrinsic("ballot_bit_count_exclusive", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
285 intrinsic("ballot_find_lsb", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
286 intrinsic("ballot_find_msb", src_comp=[4], dest_comp=1, flags=[CAN_ELIMINATE])
287
288 # Shuffle operations from SPIR-V.
289 intrinsic("shuffle", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
290 intrinsic("shuffle_xor", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
291 intrinsic("shuffle_up", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
292 intrinsic("shuffle_down", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
293
294 # Quad operations from SPIR-V.
295 intrinsic("quad_broadcast", src_comp=[0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
296 intrinsic("quad_swap_horizontal", src_comp=[0], dest_comp=0, flags=[CAN_ELIMINATE])
297 intrinsic("quad_swap_vertical", src_comp=[0], dest_comp=0, flags=[CAN_ELIMINATE])
298 intrinsic("quad_swap_diagonal", src_comp=[0], dest_comp=0, flags=[CAN_ELIMINATE])
299
300 intrinsic("reduce", src_comp=[0], dest_comp=0, indices=[REDUCTION_OP, CLUSTER_SIZE],
301 flags=[CAN_ELIMINATE])
302 intrinsic("inclusive_scan", src_comp=[0], dest_comp=0, indices=[REDUCTION_OP],
303 flags=[CAN_ELIMINATE])
304 intrinsic("exclusive_scan", src_comp=[0], dest_comp=0, indices=[REDUCTION_OP],
305 flags=[CAN_ELIMINATE])
306
307 # AMD shader ballot operations
308 intrinsic("quad_swizzle_amd", src_comp=[0], dest_comp=0, indices=[SWIZZLE_MASK],
309 flags=[CAN_ELIMINATE])
310 intrinsic("masked_swizzle_amd", src_comp=[0], dest_comp=0, indices=[SWIZZLE_MASK],
311 flags=[CAN_ELIMINATE])
312 intrinsic("write_invocation_amd", src_comp=[0, 0, 1], dest_comp=0, flags=[CAN_ELIMINATE])
313 intrinsic("mbcnt_amd", src_comp=[1], dest_comp=1, flags=[CAN_ELIMINATE])
314
315 # Basic Geometry Shader intrinsics.
316 #
317 # emit_vertex implements GLSL's EmitStreamVertex() built-in. It takes a single
318 # index, which is the stream ID to write to.
319 #
320 # end_primitive implements GLSL's EndPrimitive() built-in.
321 intrinsic("emit_vertex", indices=[STREAM_ID])
322 intrinsic("end_primitive", indices=[STREAM_ID])
323
324 # Geometry Shader intrinsics with a vertex count.
325 #
326 # Alternatively, drivers may implement these intrinsics, and use
327 # nir_lower_gs_intrinsics() to convert from the basic intrinsics.
328 #
329 # These maintain a count of the number of vertices emitted, as an additional
330 # unsigned integer source.
331 intrinsic("emit_vertex_with_counter", src_comp=[1], indices=[STREAM_ID])
332 intrinsic("end_primitive_with_counter", src_comp=[1], indices=[STREAM_ID])
333 intrinsic("set_vertex_count", src_comp=[1])
334
335 # Atomic counters
336 #
337 # The *_var variants take an atomic_uint nir_variable, while the other,
338 # lowered, variants take a constant buffer index and register offset.
339
340 def atomic(name, flags=[]):
341 intrinsic(name + "_deref", src_comp=[-1], dest_comp=1, flags=flags)
342 intrinsic(name, src_comp=[1], dest_comp=1, indices=[BASE], flags=flags)
343
344 def atomic2(name):
345 intrinsic(name + "_deref", src_comp=[-1, 1], dest_comp=1)
346 intrinsic(name, src_comp=[1, 1], dest_comp=1, indices=[BASE])
347
348 def atomic3(name):
349 intrinsic(name + "_deref", src_comp=[-1, 1, 1], dest_comp=1)
350 intrinsic(name, src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
351
352 atomic("atomic_counter_inc")
353 atomic("atomic_counter_pre_dec")
354 atomic("atomic_counter_post_dec")
355 atomic("atomic_counter_read", flags=[CAN_ELIMINATE])
356 atomic2("atomic_counter_add")
357 atomic2("atomic_counter_min")
358 atomic2("atomic_counter_max")
359 atomic2("atomic_counter_and")
360 atomic2("atomic_counter_or")
361 atomic2("atomic_counter_xor")
362 atomic2("atomic_counter_exchange")
363 atomic3("atomic_counter_comp_swap")
364
365 # Image load, store and atomic intrinsics.
366 #
367 # All image intrinsics come in three versions. One which take an image target
368 # passed as a deref chain as the first source, one which takes an index as the
369 # first source, and one which takes a bindless handle as the first source.
370 # In the first version, the image variable contains the memory and layout
371 # qualifiers that influence the semantics of the intrinsic. In the second and
372 # third, the image format and access qualifiers are provided as constant
373 # indices.
374 #
375 # All image intrinsics take a four-coordinate vector and a sample index as
376 # 2nd and 3rd sources, determining the location within the image that will be
377 # accessed by the intrinsic. Components not applicable to the image target
378 # in use are undefined. Image store takes an additional four-component
379 # argument with the value to be written, and image atomic operations take
380 # either one or two additional scalar arguments with the same meaning as in
381 # the ARB_shader_image_load_store specification.
382 def image(name, src_comp=[], **kwargs):
383 intrinsic("image_deref_" + name, src_comp=[1] + src_comp,
384 indices=[ACCESS], **kwargs)
385 intrinsic("image_" + name, src_comp=[1] + src_comp,
386 indices=[IMAGE_DIM, IMAGE_ARRAY, FORMAT, ACCESS], **kwargs)
387 intrinsic("bindless_image_" + name, src_comp=[1] + src_comp,
388 indices=[IMAGE_DIM, IMAGE_ARRAY, FORMAT, ACCESS], **kwargs)
389
390 image("load", src_comp=[4, 1, 1], dest_comp=0, flags=[CAN_ELIMINATE])
391 image("store", src_comp=[4, 1, 0, 1])
392 image("atomic_add", src_comp=[4, 1, 1], dest_comp=1)
393 image("atomic_imin", src_comp=[4, 1, 1], dest_comp=1)
394 image("atomic_umin", src_comp=[4, 1, 1], dest_comp=1)
395 image("atomic_imax", src_comp=[4, 1, 1], dest_comp=1)
396 image("atomic_umax", src_comp=[4, 1, 1], dest_comp=1)
397 image("atomic_and", src_comp=[4, 1, 1], dest_comp=1)
398 image("atomic_or", src_comp=[4, 1, 1], dest_comp=1)
399 image("atomic_xor", src_comp=[4, 1, 1], dest_comp=1)
400 image("atomic_exchange", src_comp=[4, 1, 1], dest_comp=1)
401 image("atomic_comp_swap", src_comp=[4, 1, 1, 1], dest_comp=1)
402 image("atomic_fadd", src_comp=[1, 4, 1, 1], dest_comp=1)
403 image("size", dest_comp=0, flags=[CAN_ELIMINATE, CAN_REORDER])
404 image("samples", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])
405 image("atomic_inc_wrap", src_comp=[4, 1, 1], dest_comp=1)
406 image("atomic_dec_wrap", src_comp=[4, 1, 1], dest_comp=1)
407
408 # Intel-specific query for loading from the brw_image_param struct passed
409 # into the shader as a uniform. The variable is a deref to the image
410 # variable. The const index specifies which of the six parameters to load.
411 intrinsic("image_deref_load_param_intel", src_comp=[1], dest_comp=0,
412 indices=[BASE], flags=[CAN_ELIMINATE, CAN_REORDER])
413 image("load_raw_intel", src_comp=[1], dest_comp=0,
414 flags=[CAN_ELIMINATE])
415 image("store_raw_intel", src_comp=[1, 0])
416
417 # Vulkan descriptor set intrinsics
418 #
419 # The Vulkan API uses a different binding model from GL. In the Vulkan
420 # API, all external resources are represented by a tuple:
421 #
422 # (descriptor set, binding, array index)
423 #
424 # where the array index is the only thing allowed to be indirect. The
425 # vulkan_surface_index intrinsic takes the descriptor set and binding as
426 # its first two indices and the array index as its source. The third
427 # index is a nir_variable_mode in case that's useful to the backend.
428 #
429 # The intended usage is that the shader will call vulkan_surface_index to
430 # get an index and then pass that as the buffer index ubo/ssbo calls.
431 #
432 # The vulkan_resource_reindex intrinsic takes a resource index in src0
433 # (the result of a vulkan_resource_index or vulkan_resource_reindex) which
434 # corresponds to the tuple (set, binding, index) and computes an index
435 # corresponding to tuple (set, binding, idx + src1).
436 intrinsic("vulkan_resource_index", src_comp=[1], dest_comp=0,
437 indices=[DESC_SET, BINDING, DESC_TYPE],
438 flags=[CAN_ELIMINATE, CAN_REORDER])
439 intrinsic("vulkan_resource_reindex", src_comp=[0, 1], dest_comp=0,
440 indices=[DESC_TYPE], flags=[CAN_ELIMINATE, CAN_REORDER])
441 intrinsic("load_vulkan_descriptor", src_comp=[-1], dest_comp=0,
442 indices=[DESC_TYPE], flags=[CAN_ELIMINATE, CAN_REORDER])
443
444 # variable atomic intrinsics
445 #
446 # All of these variable atomic memory operations read a value from memory,
447 # compute a new value using one of the operations below, write the new value
448 # to memory, and return the original value read.
449 #
450 # All operations take 2 sources except CompSwap that takes 3. These sources
451 # represent:
452 #
453 # 0: A deref to the memory on which to perform the atomic
454 # 1: The data parameter to the atomic function (i.e. the value to add
455 # in shared_atomic_add, etc).
456 # 2: For CompSwap only: the second data parameter.
457 intrinsic("deref_atomic_add", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
458 intrinsic("deref_atomic_imin", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
459 intrinsic("deref_atomic_umin", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
460 intrinsic("deref_atomic_imax", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
461 intrinsic("deref_atomic_umax", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
462 intrinsic("deref_atomic_and", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
463 intrinsic("deref_atomic_or", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
464 intrinsic("deref_atomic_xor", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
465 intrinsic("deref_atomic_exchange", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
466 intrinsic("deref_atomic_comp_swap", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
467 intrinsic("deref_atomic_fadd", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
468 intrinsic("deref_atomic_fmin", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
469 intrinsic("deref_atomic_fmax", src_comp=[-1, 1], dest_comp=1, indices=[ACCESS])
470 intrinsic("deref_atomic_fcomp_swap", src_comp=[-1, 1, 1], dest_comp=1, indices=[ACCESS])
471
472 # SSBO atomic intrinsics
473 #
474 # All of the SSBO atomic memory operations read a value from memory,
475 # compute a new value using one of the operations below, write the new
476 # value to memory, and return the original value read.
477 #
478 # All operations take 3 sources except CompSwap that takes 4. These
479 # sources represent:
480 #
481 # 0: The SSBO buffer index.
482 # 1: The offset into the SSBO buffer of the variable that the atomic
483 # operation will operate on.
484 # 2: The data parameter to the atomic function (i.e. the value to add
485 # in ssbo_atomic_add, etc).
486 # 3: For CompSwap only: the second data parameter.
487 intrinsic("ssbo_atomic_add", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
488 intrinsic("ssbo_atomic_imin", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
489 intrinsic("ssbo_atomic_umin", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
490 intrinsic("ssbo_atomic_imax", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
491 intrinsic("ssbo_atomic_umax", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
492 intrinsic("ssbo_atomic_and", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
493 intrinsic("ssbo_atomic_or", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
494 intrinsic("ssbo_atomic_xor", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
495 intrinsic("ssbo_atomic_exchange", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
496 intrinsic("ssbo_atomic_comp_swap", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
497 intrinsic("ssbo_atomic_fadd", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
498 intrinsic("ssbo_atomic_fmin", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
499 intrinsic("ssbo_atomic_fmax", src_comp=[1, 1, 1], dest_comp=1, indices=[ACCESS])
500 intrinsic("ssbo_atomic_fcomp_swap", src_comp=[1, 1, 1, 1], dest_comp=1, indices=[ACCESS])
501
502 # CS shared variable atomic intrinsics
503 #
504 # All of the shared variable atomic memory operations read a value from
505 # memory, compute a new value using one of the operations below, write the
506 # new value to memory, and return the original value read.
507 #
508 # All operations take 2 sources except CompSwap that takes 3. These
509 # sources represent:
510 #
511 # 0: The offset into the shared variable storage region that the atomic
512 # operation will operate on.
513 # 1: The data parameter to the atomic function (i.e. the value to add
514 # in shared_atomic_add, etc).
515 # 2: For CompSwap only: the second data parameter.
516 intrinsic("shared_atomic_add", src_comp=[1, 1], dest_comp=1, indices=[BASE])
517 intrinsic("shared_atomic_imin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
518 intrinsic("shared_atomic_umin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
519 intrinsic("shared_atomic_imax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
520 intrinsic("shared_atomic_umax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
521 intrinsic("shared_atomic_and", src_comp=[1, 1], dest_comp=1, indices=[BASE])
522 intrinsic("shared_atomic_or", src_comp=[1, 1], dest_comp=1, indices=[BASE])
523 intrinsic("shared_atomic_xor", src_comp=[1, 1], dest_comp=1, indices=[BASE])
524 intrinsic("shared_atomic_exchange", src_comp=[1, 1], dest_comp=1, indices=[BASE])
525 intrinsic("shared_atomic_comp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
526 intrinsic("shared_atomic_fadd", src_comp=[1, 1], dest_comp=1, indices=[BASE])
527 intrinsic("shared_atomic_fmin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
528 intrinsic("shared_atomic_fmax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
529 intrinsic("shared_atomic_fcomp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
530
531 # Global atomic intrinsics
532 #
533 # All of the shared variable atomic memory operations read a value from
534 # memory, compute a new value using one of the operations below, write the
535 # new value to memory, and return the original value read.
536 #
537 # All operations take 2 sources except CompSwap that takes 3. These
538 # sources represent:
539 #
540 # 0: The memory address that the atomic operation will operate on.
541 # 1: The data parameter to the atomic function (i.e. the value to add
542 # in shared_atomic_add, etc).
543 # 2: For CompSwap only: the second data parameter.
544 intrinsic("global_atomic_add", src_comp=[1, 1], dest_comp=1, indices=[BASE])
545 intrinsic("global_atomic_imin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
546 intrinsic("global_atomic_umin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
547 intrinsic("global_atomic_imax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
548 intrinsic("global_atomic_umax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
549 intrinsic("global_atomic_and", src_comp=[1, 1], dest_comp=1, indices=[BASE])
550 intrinsic("global_atomic_or", src_comp=[1, 1], dest_comp=1, indices=[BASE])
551 intrinsic("global_atomic_xor", src_comp=[1, 1], dest_comp=1, indices=[BASE])
552 intrinsic("global_atomic_exchange", src_comp=[1, 1], dest_comp=1, indices=[BASE])
553 intrinsic("global_atomic_comp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
554 intrinsic("global_atomic_fadd", src_comp=[1, 1], dest_comp=1, indices=[BASE])
555 intrinsic("global_atomic_fmin", src_comp=[1, 1], dest_comp=1, indices=[BASE])
556 intrinsic("global_atomic_fmax", src_comp=[1, 1], dest_comp=1, indices=[BASE])
557 intrinsic("global_atomic_fcomp_swap", src_comp=[1, 1, 1], dest_comp=1, indices=[BASE])
558
559 def system_value(name, dest_comp, indices=[], bit_sizes=[32]):
560 intrinsic("load_" + name, [], dest_comp, indices,
561 flags=[CAN_ELIMINATE, CAN_REORDER], sysval=True,
562 bit_sizes=bit_sizes)
563
564 system_value("frag_coord", 4)
565 system_value("point_coord", 2)
566 system_value("front_face", 1, bit_sizes=[1, 32])
567 system_value("vertex_id", 1)
568 system_value("vertex_id_zero_base", 1)
569 system_value("first_vertex", 1)
570 system_value("is_indexed_draw", 1)
571 system_value("base_vertex", 1)
572 system_value("instance_id", 1)
573 system_value("base_instance", 1)
574 system_value("draw_id", 1)
575 system_value("sample_id", 1)
576 # sample_id_no_per_sample is like sample_id but does not imply per-
577 # sample shading. See the lower_helper_invocation option.
578 system_value("sample_id_no_per_sample", 1)
579 system_value("sample_pos", 2)
580 system_value("sample_mask_in", 1)
581 system_value("primitive_id", 1)
582 system_value("invocation_id", 1)
583 system_value("tess_coord", 3)
584 system_value("tess_level_outer", 4)
585 system_value("tess_level_inner", 2)
586 system_value("tess_level_outer_default", 4)
587 system_value("tess_level_inner_default", 2)
588 system_value("patch_vertices_in", 1)
589 system_value("local_invocation_id", 3)
590 system_value("local_invocation_index", 1)
591 system_value("work_group_id", 3)
592 system_value("user_clip_plane", 4, indices=[UCP_ID])
593 system_value("num_work_groups", 3)
594 system_value("helper_invocation", 1, bit_sizes=[1, 32])
595 system_value("alpha_ref_float", 1)
596 system_value("layer_id", 1)
597 system_value("view_index", 1)
598 system_value("subgroup_size", 1)
599 system_value("subgroup_invocation", 1)
600 system_value("subgroup_eq_mask", 0, bit_sizes=[32, 64])
601 system_value("subgroup_ge_mask", 0, bit_sizes=[32, 64])
602 system_value("subgroup_gt_mask", 0, bit_sizes=[32, 64])
603 system_value("subgroup_le_mask", 0, bit_sizes=[32, 64])
604 system_value("subgroup_lt_mask", 0, bit_sizes=[32, 64])
605 system_value("num_subgroups", 1)
606 system_value("subgroup_id", 1)
607 system_value("local_group_size", 3)
608 system_value("global_invocation_id", 3, bit_sizes=[32, 64])
609 system_value("global_invocation_index", 1, bit_sizes=[32, 64])
610 system_value("work_dim", 1)
611 # Driver-specific viewport scale/offset parameters.
612 #
613 # VC4 and V3D need to emit a scaled version of the position in the vertex
614 # shaders for binning, and having system values lets us move the math for that
615 # into NIR.
616 #
617 # Panfrost needs to implement all coordinate transformation in the
618 # vertex shader; system values allow us to share this routine in NIR.
619 system_value("viewport_x_scale", 1)
620 system_value("viewport_y_scale", 1)
621 system_value("viewport_z_scale", 1)
622 system_value("viewport_z_offset", 1)
623 system_value("viewport_scale", 3)
624 system_value("viewport_offset", 3)
625
626 # Blend constant color values. Float values are clamped. Vectored versions are
627 # provided as well for driver convenience
628
629 system_value("blend_const_color_r_float", 1)
630 system_value("blend_const_color_g_float", 1)
631 system_value("blend_const_color_b_float", 1)
632 system_value("blend_const_color_a_float", 1)
633 system_value("blend_const_color_rgba", 4)
634 system_value("blend_const_color_rgba8888_unorm", 1)
635 system_value("blend_const_color_aaaa8888_unorm", 1)
636
637 # System values for gl_Color, for radeonsi which interpolates these in the
638 # shader prolog to handle two-sided color without recompiles and therefore
639 # doesn't handle these in the main shader part like normal varyings.
640 system_value("color0", 4)
641 system_value("color1", 4)
642
643 # System value for internal compute shaders in radeonsi.
644 system_value("user_data_amd", 4)
645
646 # Barycentric coordinate intrinsics.
647 #
648 # These set up the barycentric coordinates for a particular interpolation.
649 # The first three are for the simple cases: pixel, centroid, or per-sample
650 # (at gl_SampleID). The next two handle interpolating at a specified
651 # sample location, or interpolating with a vec2 offset,
652 #
653 # The interp_mode index should be either the INTERP_MODE_SMOOTH or
654 # INTERP_MODE_NOPERSPECTIVE enum values.
655 #
656 # The vec2 value produced by these intrinsics is intended for use as the
657 # barycoord source of a load_interpolated_input intrinsic.
658
659 def barycentric(name, src_comp=[]):
660 intrinsic("load_barycentric_" + name, src_comp=src_comp, dest_comp=2,
661 indices=[INTERP_MODE], flags=[CAN_ELIMINATE, CAN_REORDER])
662
663 # no sources.
664 barycentric("pixel")
665 barycentric("centroid")
666 barycentric("sample")
667 # src[] = { sample_id }.
668 barycentric("at_sample", [1])
669 # src[] = { offset.xy }.
670 barycentric("at_offset", [2])
671
672 # Load sample position:
673 #
674 # Takes a sample # and returns a sample position. Used for lowering
675 # interpolateAtSample() to interpolateAtOffset()
676 intrinsic("load_sample_pos_from_id", src_comp=[1], dest_comp=2,
677 flags=[CAN_ELIMINATE, CAN_REORDER])
678
679 # Loads what I believe is the primitive size, for scaling ij to pixel size:
680 intrinsic("load_size_ir3", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])
681
682 # Fragment shader input interpolation delta intrinsic.
683 #
684 # For hw where fragment shader input interpolation is handled in shader, the
685 # load_fs_input_interp deltas intrinsics can be used to load the input deltas
686 # used for interpolation as follows:
687 #
688 # vec3 iid = load_fs_input_interp_deltas(varying_slot)
689 # vec2 bary = load_barycentric_*(...)
690 # float result = iid.x + iid.y * bary.y + iid.z * bary.x
691
692 intrinsic("load_fs_input_interp_deltas", src_comp=[1], dest_comp=3,
693 indices=[BASE, COMPONENT], flags=[CAN_ELIMINATE, CAN_REORDER])
694
695 # Load operations pull data from some piece of GPU memory. All load
696 # operations operate in terms of offsets into some piece of theoretical
697 # memory. Loads from externally visible memory (UBO and SSBO) simply take a
698 # byte offset as a source. Loads from opaque memory (uniforms, inputs, etc.)
699 # take a base+offset pair where the nir_intrinsic_base() gives the location
700 # of the start of the variable being loaded and and the offset source is a
701 # offset into that variable.
702 #
703 # Uniform load operations have a nir_intrinsic_range() index that specifies the
704 # range (starting at base) of the data from which we are loading. If
705 # range == 0, then the range is unknown.
706 #
707 # Some load operations such as UBO/SSBO load and per_vertex loads take an
708 # additional source to specify which UBO/SSBO/vertex to load from.
709 #
710 # The exact address type depends on the lowering pass that generates the
711 # load/store intrinsics. Typically, this is vec4 units for things such as
712 # varying slots and float units for fragment shader inputs. UBO and SSBO
713 # offsets are always in bytes.
714
715 def load(name, num_srcs, indices=[], flags=[]):
716 intrinsic("load_" + name, [1] * num_srcs, dest_comp=0, indices=indices,
717 flags=flags)
718
719 # src[] = { offset }.
720 load("uniform", 1, [BASE, RANGE, TYPE], [CAN_ELIMINATE, CAN_REORDER])
721 # src[] = { buffer_index, offset }.
722 load("ubo", 2, [ACCESS, ALIGN_MUL, ALIGN_OFFSET], flags=[CAN_ELIMINATE, CAN_REORDER])
723 # src[] = { offset }.
724 load("input", 1, [BASE, COMPONENT, TYPE], [CAN_ELIMINATE, CAN_REORDER])
725 # src[] = { vertex, offset }.
726 load("per_vertex_input", 2, [BASE, COMPONENT], [CAN_ELIMINATE, CAN_REORDER])
727 # src[] = { barycoord, offset }.
728 intrinsic("load_interpolated_input", src_comp=[2, 1], dest_comp=0,
729 indices=[BASE, COMPONENT], flags=[CAN_ELIMINATE, CAN_REORDER])
730
731 # src[] = { buffer_index, offset }.
732 load("ssbo", 2, [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
733 # src[] = { offset }.
734 load("output", 1, [BASE, COMPONENT], flags=[CAN_ELIMINATE])
735 # src[] = { vertex, offset }.
736 load("per_vertex_output", 2, [BASE, COMPONENT], [CAN_ELIMINATE])
737 # src[] = { offset }.
738 load("shared", 1, [BASE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
739 # src[] = { offset }.
740 load("push_constant", 1, [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
741 # src[] = { offset }.
742 load("constant", 1, [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
743 # src[] = { address }.
744 load("global", 1, [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
745 # src[] = { address }.
746 load("kernel_input", 1, [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE, CAN_REORDER])
747 # src[] = { offset }.
748 load("scratch", 1, [ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
749
750 # Stores work the same way as loads, except now the first source is the value
751 # to store and the second (and possibly third) source specify where to store
752 # the value. SSBO and shared memory stores also have a
753 # nir_intrinsic_write_mask()
754
755 def store(name, num_srcs, indices=[], flags=[]):
756 intrinsic("store_" + name, [0] + ([1] * (num_srcs - 1)), indices=indices, flags=flags)
757
758 # src[] = { value, offset }.
759 store("output", 2, [BASE, WRMASK, COMPONENT, TYPE])
760 # src[] = { value, vertex, offset }.
761 store("per_vertex_output", 3, [BASE, WRMASK, COMPONENT])
762 # src[] = { value, block_index, offset }
763 store("ssbo", 3, [WRMASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
764 # src[] = { value, offset }.
765 store("shared", 2, [BASE, WRMASK, ALIGN_MUL, ALIGN_OFFSET])
766 # src[] = { value, address }.
767 store("global", 2, [WRMASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
768 # src[] = { value, offset }.
769 store("scratch", 2, [ALIGN_MUL, ALIGN_OFFSET, WRMASK])
770
771 # IR3-specific version of most SSBO intrinsics. The only different
772 # compare to the originals is that they add an extra source to hold
773 # the dword-offset, which is needed by the backend code apart from
774 # the byte-offset already provided by NIR in one of the sources.
775 #
776 # NIR lowering pass 'ir3_nir_lower_io_offset' will replace the
777 # original SSBO intrinsics by these, placing the computed
778 # dword-offset always in the last source.
779 #
780 # The float versions are not handled because those are not supported
781 # by the backend.
782 intrinsic("store_ssbo_ir3", src_comp=[0, 1, 1, 1],
783 indices=[WRMASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
784 intrinsic("load_ssbo_ir3", src_comp=[1, 1, 1], dest_comp=0,
785 indices=[ACCESS, ALIGN_MUL, ALIGN_OFFSET], flags=[CAN_ELIMINATE])
786 intrinsic("ssbo_atomic_add_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
787 intrinsic("ssbo_atomic_imin_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
788 intrinsic("ssbo_atomic_umin_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
789 intrinsic("ssbo_atomic_imax_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
790 intrinsic("ssbo_atomic_umax_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
791 intrinsic("ssbo_atomic_and_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
792 intrinsic("ssbo_atomic_or_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
793 intrinsic("ssbo_atomic_xor_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
794 intrinsic("ssbo_atomic_exchange_ir3", src_comp=[1, 1, 1, 1], dest_comp=1)
795 intrinsic("ssbo_atomic_comp_swap_ir3", src_comp=[1, 1, 1, 1, 1], dest_comp=1)
796
797 # System values for freedreno geometry shaders.
798 system_value("vs_primitive_stride_ir3", 1)
799 system_value("vs_vertex_stride_ir3", 1)
800 system_value("gs_header_ir3", 1)
801 system_value("primitive_location_ir3", 1, indices=[DRIVER_LOCATION])
802
803 # System values for freedreno tessellation shaders.
804 system_value("hs_patch_stride_ir3", 1)
805 system_value("tess_factor_base_ir3", 2)
806 system_value("tess_param_base_ir3", 2)
807 system_value("tcs_header_ir3", 1)
808
809 # IR3-specific intrinsics for tessellation control shaders. cond_end_ir3 end
810 # the shader when src0 is false and is used to narrow down the TCS shader to
811 # just thread 0 before writing out tessellation levels.
812 intrinsic("cond_end_ir3", src_comp=[1])
813 # end_patch_ir3 is used just before thread 0 exist the TCS and presumably
814 # signals the TE that the patch is complete and can be tessellated.
815 intrinsic("end_patch_ir3")
816
817 # IR3-specific load/store intrinsics. These access a buffer used to pass data
818 # between geometry stages - perhaps it's explicit access to the vertex cache.
819
820 # src[] = { value, offset }.
821 store("shared_ir3", 2, [BASE, WRMASK, ALIGN_MUL, ALIGN_OFFSET])
822 # src[] = { offset }.
823 load("shared_ir3", 1, [BASE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE])
824
825 # IR3-specific load/store global intrinsics. They take a 64-bit base address
826 # and a 32-bit offset. The hardware will add the base and the offset, which
827 # saves us from doing 64-bit math on the base address.
828
829 # src[] = { value, address(vec2 of hi+lo uint32_t), offset }.
830 # const_index[] = { write_mask, align_mul, align_offset }
831 intrinsic("store_global_ir3", [0, 2, 1], indices=[WRMASK, ACCESS, ALIGN_MUL, ALIGN_OFFSET])
832 # src[] = { address(vec2 of hi+lo uint32_t), offset }.
833 # const_index[] = { access, align_mul, align_offset }
834 intrinsic("load_global_ir3", [2, 1], dest_comp=0, indices=[ACCESS, ALIGN_MUL, ALIGN_OFFSET], flags=[CAN_ELIMINATE])
835
836 # Intrinsics used by the Midgard/Bifrost blend pipeline. These are defined
837 # within a blend shader to read/write the raw value from the tile buffer,
838 # without applying any format conversion in the process. If the shader needs
839 # usable pixel values, it must apply format conversions itself.
840 #
841 # These definitions are generic, but they are explicitly vendored to prevent
842 # other drivers from using them, as their semantics is defined in terms of the
843 # Midgard/Bifrost hardware tile buffer and may not line up with anything sane.
844 # One notable divergence is sRGB, which is asymmetric: raw_input_pan requires
845 # an sRGB->linear conversion, but linear values should be written to
846 # raw_output_pan and the hardware handles linear->sRGB.
847 #
848 # We also have format-specific Midgard intrinsics. There are rather
849 # here-be-dragons. load_output_u8_as_fp16_pan does the equivalent of
850 # load_raw_out_pan on an RGBA8 UNORM framebuffer followed by u2u16 -> fp16 ->
851 # division by 255.
852
853 # src[] = { value }
854 store("raw_output_pan", 1, [])
855 load("raw_output_pan", 0, [], [CAN_ELIMINATE, CAN_REORDER])
856 load("output_u8_as_fp16_pan", 0, [], [CAN_ELIMINATE, CAN_REORDER])
857
858 # Loads the sampler paramaters <min_lod, max_lod, lod_bias>
859 # src[] = { sampler_index }
860 load("sampler_lod_parameters_pan", 1, [CAN_ELIMINATE, CAN_REORDER])
861
862 # V3D-specific instrinc for tile buffer color reads.
863 #
864 # The hardware requires that we read the samples and components of a pixel
865 # in order, so we cannot eliminate or remove any loads in a sequence.
866 #
867 # src[] = { render_target }
868 # BASE = sample index
869 load("tlb_color_v3d", 1, [BASE, COMPONENT], [])
870
871 # V3D-specific instrinc for per-sample tile buffer color writes.
872 #
873 # The driver backend needs to identify per-sample color writes and emit
874 # specific code for them.
875 #
876 # src[] = { value, render_target }
877 # BASE = sample index
878 store("tlb_sample_color_v3d", 2, [BASE, COMPONENT, TYPE], [])
879
880 # V3D-specific intrinsic to load the number of layers attached to
881 # the target framebuffer
882 intrinsic("load_fb_layers_v3d", dest_comp=1, flags=[CAN_ELIMINATE, CAN_REORDER])