{
struct nir_lower_tex_options tex_options = {
.lower_txd = true,
+ .lower_tg4_broadcom_swizzle = true,
+
.lower_rect = false, /* XXX: Use this on V3D 3.x */
.lower_txp = ~0,
/* Apply swizzles to all samplers. */
*/
bool lower_txd_offset_clamp;
+ /**
+ * If true, apply a .bagr swizzle on tg4 results to handle Broadcom's
+ * mixed-up tg4 locations.
+ */
+ bool lower_tg4_broadcom_swizzle;
+
enum nir_lower_tex_packing lower_tex_packing[32];
} nir_lower_tex_options;
return nir_build_imm(b, 4, 32, v);
}
+static void
+swizzle_tg4_broadcom(nir_builder *b, nir_tex_instr *tex)
+{
+ assert(tex->dest.is_ssa);
+
+ b->cursor = nir_after_instr(&tex->instr);
+
+ assert(nir_tex_instr_dest_size(tex) == 4);
+ unsigned swiz[4] = { 2, 3, 1, 0 };
+ nir_ssa_def *swizzled = nir_swizzle(b, &tex->dest.ssa, swiz, 4, false);
+
+ nir_ssa_def_rewrite_uses_after(&tex->dest.ssa, nir_src_for_ssa(swizzled),
+ swizzled->parent_instr);
+}
+
static void
swizzle_result(nir_builder *b, nir_tex_instr *tex, const uint8_t swizzle[4])
{
progress = true;
}
+ if (tex->op == nir_texop_tg4 && options->lower_tg4_broadcom_swizzle) {
+ swizzle_tg4_broadcom(b, tex);
+ progress = true;
+ }
+
if (((1 << tex->texture_index) & options->swizzle_result) &&
!nir_tex_instr_is_query(tex) &&
!(tex->is_shadow && tex->is_new_style_shadow)) {