struct nir_fold_tex_srcs_options {
unsigned sampler_dims;
unsigned src_types;
+ bool only_fold_all; /* Only fold sources if all of them can be folded. */
};
struct nir_fold_16bit_tex_image_options {
if (!(options->sampler_dims & BITFIELD_BIT(tex->sampler_dim)))
return false;
- bool changed = false;
+ unsigned fold_srcs = 0;
for (unsigned i = 0; i < tex->num_srcs; i++) {
/* Filter out sources that should be ignored. */
if (!(BITFIELD_BIT(tex->src[i].src_type) & options->src_types))
* because it's out of bounds and the higher bits don't
* matter.
*/
- if (!can_fold_16bit_src(src->ssa, src_type, false))
- continue;
+ if (can_fold_16bit_src(src->ssa, src_type, false))
+ fold_srcs |= (1 << i);
+ else if (options->only_fold_all)
+ return false;
+ }
+ u_foreach_bit(i, fold_srcs) {
+ nir_src *src = &tex->src[i].src;
+ nir_alu_type src_type = nir_tex_instr_src_type(tex, i) | src->ssa->bit_size;
fold_16bit_src(b, &tex->instr, src, src_type);
- changed = true;
}
- return changed;
+ return !!fold_srcs;
}
static bool