nir/opt_shrink_vectors: shrink image stores using the format
fossil-db (Navi): Totals from 657 (0.48% of 135946) affected shaders: VGPRs: 26076 -> 25520 (-2.13%); split: -2.15%, +0.02% CodeSize: 3033016 -> 3014472 (-0.61%); split: -0.64%, +0.03% MaxWaves: 9386 -> 9420 (+0.36%) Instrs: 590109 -> 585502 (-0.78%); split: -0.82%, +0.04% Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5772>
This commit is contained in:
parent
bd428162b6
commit
e4d75c22be
|
@ -109,6 +109,30 @@ opt_shrink_vectors_alu(nir_builder *b, nir_alu_instr *instr)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
opt_shrink_vectors_image_store(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
{
|
||||
enum pipe_format format;
|
||||
if (instr->intrinsic == nir_intrinsic_image_deref_store) {
|
||||
nir_deref_instr *deref = nir_src_as_deref(instr->src[0]);
|
||||
format = nir_deref_instr_get_variable(deref)->data.image.format;
|
||||
} else {
|
||||
format = nir_intrinsic_format(instr);
|
||||
}
|
||||
if (format == PIPE_FORMAT_NONE)
|
||||
return false;
|
||||
|
||||
unsigned components = util_format_get_nr_components(format);
|
||||
if (components >= instr->num_components)
|
||||
return false;
|
||||
|
||||
nir_ssa_def *data = nir_channels(b, instr->src[3].ssa, BITSET_MASK(components));
|
||||
nir_instr_rewrite_src(&instr->instr, &instr->src[3], nir_src_for_ssa(data));
|
||||
instr->num_components = components;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
opt_shrink_vectors_intrinsic(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
{
|
||||
|
@ -133,6 +157,10 @@ opt_shrink_vectors_intrinsic(nir_builder *b, nir_intrinsic_instr *instr)
|
|||
case nir_intrinsic_store_global:
|
||||
case nir_intrinsic_store_scratch:
|
||||
break;
|
||||
case nir_intrinsic_bindless_image_store:
|
||||
case nir_intrinsic_image_deref_store:
|
||||
case nir_intrinsic_image_store:
|
||||
return opt_shrink_vectors_image_store(b, instr);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue