nir,agx: pull lower_printf_buffer into backend
no other users now. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Marek Olšák <maraeo@gmail.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36516>
This commit is contained in:
committed by
Marge Bot
parent
1edd9c3e53
commit
3e8575c037
@@ -3890,6 +3890,22 @@ agx_preprocess_nir(nir_shader *nir)
|
||||
NIR_PASS(_, nir, agx_nir_lower_shared_bitsize);
|
||||
}
|
||||
|
||||
static bool
|
||||
lower_printf_buffer(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *_)
|
||||
{
|
||||
uint64_t value = 0;
|
||||
if (intr->intrinsic == nir_intrinsic_load_printf_buffer_address)
|
||||
value = LIBAGX_PRINTF_BUFFER_ADDRESS;
|
||||
else if (intr->intrinsic == nir_intrinsic_load_printf_buffer_size)
|
||||
value = LIBAGX_PRINTF_BUFFER_SIZE;
|
||||
else
|
||||
return false;
|
||||
|
||||
b->cursor = nir_before_instr(&intr->instr);
|
||||
nir_def_replace(&intr->def, nir_imm_intN_t(b, value, intr->def.bit_size));
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
|
||||
struct agx_shader_part *out)
|
||||
@@ -3910,8 +3926,8 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT)
|
||||
info->tag_write_disable = !nir->info.writes_memory;
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_printf_buffer, LIBAGX_PRINTF_BUFFER_ADDRESS,
|
||||
LIBAGX_PRINTF_BUFFER_SIZE - 8);
|
||||
NIR_PASS(_, nir, nir_shader_intrinsics_pass, lower_printf_buffer,
|
||||
nir_metadata_control_flow, NULL);
|
||||
|
||||
NIR_PASS(_, nir, nir_lower_frag_coord_to_pixel_coord);
|
||||
NIR_PASS(_, nir, nir_lower_vars_to_ssa);
|
||||
|
||||
@@ -6138,7 +6138,6 @@ typedef struct nir_lower_printf_options {
|
||||
} nir_lower_printf_options;
|
||||
|
||||
bool nir_lower_printf(nir_shader *nir, const nir_lower_printf_options *options);
|
||||
bool nir_lower_printf_buffer(nir_shader *nir, uint64_t address, uint32_t size);
|
||||
|
||||
/* This is here for unit tests. */
|
||||
bool nir_opt_comparison_pre_impl(nir_function_impl *impl);
|
||||
|
||||
@@ -166,39 +166,6 @@ nir_lower_printf(nir_shader *nir, const nir_lower_printf_options *options)
|
||||
(void *)options);
|
||||
}
|
||||
|
||||
struct buffer_opts {
|
||||
uint64_t address;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
static bool
|
||||
lower_printf_buffer(nir_builder *b, nir_intrinsic_instr *intr, void *_options)
|
||||
{
|
||||
const struct buffer_opts *options = _options;
|
||||
|
||||
uint64_t value = 0;
|
||||
if (intr->intrinsic == nir_intrinsic_load_printf_buffer_address)
|
||||
value = options->address;
|
||||
else if (intr->intrinsic == nir_intrinsic_load_printf_buffer_size)
|
||||
value = options->size;
|
||||
|
||||
if (value == 0)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_before_instr(&intr->instr);
|
||||
nir_def_replace(&intr->def, nir_imm_intN_t(b, value, intr->def.bit_size));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nir_lower_printf_buffer(nir_shader *nir, uint64_t address, uint32_t size)
|
||||
{
|
||||
struct buffer_opts opts = { .address = address, .size = size };
|
||||
|
||||
return nir_shader_intrinsics_pass(nir, lower_printf_buffer,
|
||||
nir_metadata_control_flow, &opts);
|
||||
}
|
||||
|
||||
static void
|
||||
nir_vprintf_fmt(nir_builder *b, unsigned ptr_bit_size, const char *fmt, va_list aq)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user