From d3e20e88347e13fb9ba8462ed435dc85147cd381 Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Sun, 13 Nov 2022 16:30:39 +0800 Subject: [PATCH] ac/nir/ngg: gs store output use src_type index for type info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit More precise type info, can be used for 16bit output streamout to convert 16bit int/uint/float to 32bit one later. Reviewed-by: Timur Kristóf Signed-off-by: Qiang Yu Part-of: --- src/amd/common/ac_nir_lower_ngg.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/amd/common/ac_nir_lower_ngg.c b/src/amd/common/ac_nir_lower_ngg.c index 4fd9120cf72..29aec164056 100644 --- a/src/amd/common/ac_nir_lower_ngg.c +++ b/src/amd/common/ac_nir_lower_ngg.c @@ -2476,6 +2476,8 @@ lower_ngg_gs_store_output(nir_builder *b, nir_intrinsic_instr *intrin, lower_ngg assert(base_index < VARYING_SLOT_MAX); nir_ssa_def *store_val = intrin->src[0].ssa; + nir_alu_type src_type = nir_intrinsic_src_type(intrin); + enum glsl_base_type val_type = nir_get_glsl_base_type_for_nir_type(src_type); /* Small bitsize components consume the same amount of space as 32-bit components, * but 64-bit ones consume twice as many. (Vulkan spec 15.1.5) @@ -2483,6 +2485,7 @@ lower_ngg_gs_store_output(nir_builder *b, nir_intrinsic_instr *intrin, lower_ngg * 64-bit IO has been lowered to multi 32-bit IO. */ assert(store_val->bit_size <= 32); + assert(glsl_base_type_get_bit_size(val_type) == store_val->bit_size); /* Save output usage info. */ gs_output_info *info = &s->output_info[location]; @@ -2515,11 +2518,10 @@ lower_ngg_gs_store_output(nir_builder *b, nir_intrinsic_instr *intrin, lower_ngg nir_variable *var = s->output_vars[location][component]; if (!var) { - var = nir_local_variable_create( - s->impl, glsl_uintN_t_type(store_val->bit_size), "output"); + var = nir_local_variable_create(s->impl, glsl_scalar_type(val_type), "output"); s->output_vars[location][component] = var; } - assert(glsl_base_type_bit_size(glsl_get_base_type(var->type)) == store_val->bit_size); + assert(glsl_get_base_type(var->type) == val_type); nir_store_var(b, var, nir_channel(b, store_val, comp), 0x1u); }