mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 08:10:14 +01:00
ac/nir: Add helper macros for emitting IO code.
These are implemented as macros because C doesn't have templates. They are meant for implementing properly split packed 16-bit IO stores and loads, to avoid repetition in the code. Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28768>
This commit is contained in:
parent
feb2ba9e9b
commit
7bfbff7440
1 changed files with 29 additions and 0 deletions
|
|
@ -361,6 +361,35 @@ ac_nir_store_debug_log_amd(nir_builder *b, nir_def *uvec4);
|
|||
bool
|
||||
ac_nir_opt_pack_half(nir_shader *shader, enum amd_gfx_level gfx_level);
|
||||
|
||||
#define AC_NIR_STORE_IO(b, store_val, const_offset, write_mask, hi_16bit, func, ...) \
|
||||
do { \
|
||||
if ((store_val)->bit_size >= 32) { \
|
||||
const unsigned store_write_mask = (write_mask); \
|
||||
const unsigned store_const_offset = (const_offset); \
|
||||
func((b), (store_val), __VA_ARGS__); \
|
||||
} else { \
|
||||
u_foreach_bit(c, (write_mask)) { \
|
||||
const unsigned store_write_mask = 1; \
|
||||
const unsigned store_const_offset = (const_offset) + c * 4 + ((hi_16bit) ? 2 : 0); \
|
||||
nir_def *store_component = nir_channel(b, (store_val), c); \
|
||||
func((b), store_component, __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define AC_NIR_LOAD_IO(load, b, num_components, bit_size, hi_16bit, func, ...) \
|
||||
do { \
|
||||
const unsigned load_bit_size = MAX2(32, (bit_size)); \
|
||||
(load) = func((b), (num_components), load_bit_size, __VA_ARGS__); \
|
||||
if ((bit_size) < load_bit_size) { \
|
||||
if ((hi_16bit)) { \
|
||||
(load) = nir_unpack_32_2x16_split_y(b, load); \
|
||||
} else { \
|
||||
(load) = nir_unpack_32_2x16_split_x(b, load); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue