summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_lower_tex.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2018-12-26 22:45:04 -0800
committerEric Anholt <[email protected]>2019-01-08 13:03:41 -0800
commit6051c11d17645b973f975b25cfdebc027dc36be7 (patch)
treea8165263f0db7569c44358dfeced251b4c862dfb /src/compiler/nir/nir_lower_tex.c
parent3fcec4a5505a51e90b07be8c392189fa7799d368 (diff)
nir: Add nir_lower_tex support for Broadcom's swizzled TG4 results.
V3D returns the texels in a different order in the resulting vec4 from what GLSL wants, so we need to put in a swizzle. Fixes dEQP-GLES31.functional.texture.gather.basic.2d.rgba8.base_level.level_1 Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_lower_tex.c')
-rw-r--r--src/compiler/nir/nir_lower_tex.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c
index 001c525e666..a618b86b34c 100644
--- a/src/compiler/nir/nir_lower_tex.c
+++ b/src/compiler/nir/nir_lower_tex.c
@@ -739,6 +739,21 @@ get_zero_or_one(nir_builder *b, nir_alu_type type, uint8_t swizzle_val)
}
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])
{
assert(tex->dest.is_ssa);
@@ -937,6 +952,11 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
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)) {