summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2014-12-28 14:26:12 +0100
committerEmil Velikov <[email protected]>2015-01-23 00:47:24 +0000
commite3a393b4c3ef111f7352ddad5647a10b76861205 (patch)
treed3a3692bd92fec4fdbba8c9291602efca92ef865
parent7ecd0f9528c16018c675de41811a6eedd17a9e57 (diff)
st/nine: Implement TEXM3x3SPEC
Reviewed-by: Ilia Mirkin <[email protected]> Signed-off-by: Axel Davy <[email protected]> Cc: "10.4" <[email protected]> (cherry picked from commit 3676ab02fbf14708c4aab94480d841003f33fcc7)
-rw-r--r--src/gallium/state_trackers/nine/nine_shader.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
index c84a78c5ab2..a60599816c4 100644
--- a/src/gallium/state_trackers/nine/nine_shader.c
+++ b/src/gallium/state_trackers/nine/nine_shader.c
@@ -2164,7 +2164,44 @@ DECL_SPECIAL(TEXM3x3PAD)
DECL_SPECIAL(TEXM3x3SPEC)
{
- STUB(D3DERR_INVALIDCALL);
+ struct ureg_program *ureg = tx->ureg;
+ struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]);
+ struct ureg_src E = tx_src_param(tx, &tx->insn.src[1]);
+ struct ureg_src sample;
+ struct ureg_dst tmp;
+ const int m = tx->insn.dst[0].idx - 2;
+ const int n = tx->insn.src[0].idx;
+ assert(m >= 0 && m > n);
+
+ tx_texcoord_alloc(tx, m);
+ tx_texcoord_alloc(tx, m+1);
+ tx_texcoord_alloc(tx, m+2);
+
+ ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_X), tx->regs.vT[m], ureg_src(tx->regs.tS[n]));
+ ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], ureg_src(tx->regs.tS[n]));
+ ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Z), tx->regs.vT[m+2], ureg_src(tx->regs.tS[n]));
+
+ sample = ureg_DECL_sampler(ureg, m + 2);
+ tx->info->sampler_mask |= 1 << (m + 2);
+ tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_XYZ);
+
+ /* At this step, dst = N = (u', w', z').
+ * We want dst to be the texture sampled at (u'', w'', z''), with
+ * (u'', w'', z'') = 2 * (N.E / N.N) * N - E */
+ ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_src(dst), ureg_src(dst));
+ ureg_RCP(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X));
+ /* at this step tmp.x = 1/N.N */
+ ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Y), ureg_src(dst), E);
+ /* at this step tmp.y = N.E */
+ ureg_MUL(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y));
+ /* at this step tmp.x = N.E/N.N */
+ ureg_MUL(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), ureg_imm1f(ureg, 2.0f));
+ ureg_MUL(ureg, tmp, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), ureg_src(dst));
+ /* at this step tmp.xyz = 2 * (N.E / N.N) * N */
+ ureg_SUB(ureg, tmp, ureg_src(tmp), E);
+ ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 2), ureg_src(tmp), sample);
+
+ return D3D_OK;
}
DECL_SPECIAL(TEXREG2RGB)