diff options
author | Axel Davy <[email protected]> | 2014-12-28 14:18:26 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2015-01-23 00:47:24 +0000 |
commit | 336887bca1c239665c19ecd2da32e62e40a2a61c (patch) | |
tree | 3c2da65c0fe86179e83c241926f95ef8a2011f3d | |
parent | 8e08ba6f9676fd5433f38c8969a1100ccccd69b1 (diff) |
st/nine: implement TEXM3x2DEPTH
Reviewed-by: Ilia Mirkin <[email protected]>
Signed-off-by: Axel Davy <[email protected]>
Cc: "10.4" <[email protected]>
(cherry picked from commit fdff111dc8ce95c554371ac5aaaf611aa497c0f8)
-rw-r--r-- | src/gallium/state_trackers/nine/nine_shader.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c index e2b0b67f3ca..93ca6390036 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -2161,7 +2161,32 @@ DECL_SPECIAL(TEXDP3TEX) DECL_SPECIAL(TEXM3x2DEPTH) { - STUB(D3DERR_INVALIDCALL); + struct ureg_program *ureg = tx->ureg; + struct ureg_dst tmp; + const int m = tx->insn.dst[0].idx - 1; + const int n = tx->insn.src[0].idx; + assert(m >= 0 && m > n); + + tx_texcoord_alloc(tx, m); + tx_texcoord_alloc(tx, m+1); + + tmp = tx_scratch(tx); + + /* performs the matrix multiplication */ + ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), tx->regs.vT[m], ureg_src(tx->regs.tS[n])); + ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], ureg_src(tx->regs.tS[n])); + + ureg_RCP(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Z), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y)); + /* tmp.x = 'z', tmp.y = 'w', tmp.z = 1/'w'. */ + ureg_MUL(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Z)); + /* res = 'w' == 0 ? 1.0 : z/w */ + ureg_CMP(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), ureg_negate(ureg_abs(ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y))), + ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), ureg_imm1f(ureg, 1.0f)); + /* replace the depth for depth testing with the result */ + tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0, TGSI_WRITEMASK_Z); + ureg_MOV(ureg, tx->regs.oDepth, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X)); + /* note that we write nothing to the destination, since it's disallowed to use it afterward */ + return D3D_OK; } DECL_SPECIAL(TEXDP3) |