nir: support lowering nir_intrinsic_image_samples to a constant load
This can be used by multiple drivers that do not support ms images Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Reviewed-by: Rob Clark <robclark@freedesktop.org> Reviewer-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Signed-off-by: Amber Amber <amber@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20813>
This commit is contained in:
@@ -5328,6 +5328,12 @@ typedef struct nir_lower_image_options {
|
||||
* Lower multi sample image load and samples_identical to use fragment_mask_load.
|
||||
*/
|
||||
bool lower_to_fragment_mask_load_amd;
|
||||
|
||||
/**
|
||||
* Lower image_samples to a constant in case the driver doesn't support multisampled
|
||||
* images.
|
||||
*/
|
||||
bool lower_image_samples_to_one;
|
||||
} nir_lower_image_options;
|
||||
|
||||
bool nir_lower_image(nir_shader *nir,
|
||||
|
@@ -182,6 +182,15 @@ lower_image_instr(nir_builder *b, nir_instr *instr, void *state)
|
||||
}
|
||||
return false;
|
||||
|
||||
case nir_intrinsic_image_samples: {
|
||||
if (options->lower_image_samples_to_one) {
|
||||
b->cursor = nir_after_instr(&intrin->instr);
|
||||
nir_ssa_def *samples = nir_imm_intN_t(b, 1, nir_dest_bit_size(intrin->dest));
|
||||
nir_ssa_def_rewrite_uses(&intrin->dest.ssa, samples);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user