[Mesa-dev] [PATCH 1/2] gallivm: handle texel swizzles correctly for d3d10-style sample opcodes
sroland at vmware.com
sroland at vmware.com
Fri Jul 26 12:40:09 PDT 2013
From: Roland Scheidegger <sroland at vmware.com>
unlike OpenGL, the texel swizzle is embedded in the instruction, so honor
that.
(Technically we now execute both the sampler_view swizzle and the
per-instruction swizzle but this should be quite ok.)
---
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 27 +++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 4355b3a..c199385 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -1859,6 +1859,19 @@ emit_sample(struct lp_build_tgsi_soa_context *bld,
deriv_ptr,
lod_bias, explicit_lod, scalar_lod,
texel);
+
+ if (inst->Src[1].Register.SwizzleX != PIPE_SWIZZLE_RED ||
+ inst->Src[1].Register.SwizzleY != PIPE_SWIZZLE_GREEN ||
+ inst->Src[1].Register.SwizzleZ != PIPE_SWIZZLE_BLUE ||
+ inst->Src[1].Register.SwizzleW != PIPE_SWIZZLE_ALPHA) {
+ unsigned char swizzles[4];
+ swizzles[0] = inst->Src[1].Register.SwizzleX;
+ swizzles[1] = inst->Src[1].Register.SwizzleY;
+ swizzles[2] = inst->Src[1].Register.SwizzleZ;
+ swizzles[3] = inst->Src[1].Register.SwizzleW;
+
+ lp_build_swizzle_soa_inplace(&bld->bld_base.base, texel, swizzles);
+ }
}
static void
@@ -1954,6 +1967,20 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld,
NULL,
NULL, explicit_lod, scalar_lod,
texel);
+
+ if (is_samplei &&
+ (inst->Src[1].Register.SwizzleX != PIPE_SWIZZLE_RED ||
+ inst->Src[1].Register.SwizzleY != PIPE_SWIZZLE_GREEN ||
+ inst->Src[1].Register.SwizzleZ != PIPE_SWIZZLE_BLUE ||
+ inst->Src[1].Register.SwizzleW != PIPE_SWIZZLE_ALPHA)) {
+ unsigned char swizzles[4];
+ swizzles[0] = inst->Src[1].Register.SwizzleX;
+ swizzles[1] = inst->Src[1].Register.SwizzleY;
+ swizzles[2] = inst->Src[1].Register.SwizzleZ;
+ swizzles[3] = inst->Src[1].Register.SwizzleW;
+
+ lp_build_swizzle_soa_inplace(&bld->bld_base.base, texel, swizzles);
+ }
}
static void
--
1.7.9.5
More information about the mesa-dev
mailing list