diff options
author | Axel Davy <[email protected]> | 2014-12-28 14:18:26 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2015-01-22 22:16:22 +0000 |
commit | fdff111dc8ce95c554371ac5aaaf611aa497c0f8 (patch) | |
tree | 487008bb8859d53177cc74cfb961f7ce22f08724 | |
parent | 7865210670a735f268044b0c388a4895bed1ea4c (diff) |
st/nine: implement TEXM3x2DEPTH
Reviewed-by: Ilia Mirkin <[email protected]>
Signed-off-by: Axel Davy <[email protected]>
Cc: "10.4" <[email protected]>
-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 0a733df1ef7..11541a0c2c2 100644 --- a/src/gallium/state_trackers/nine/nine_shader.c +++ b/src/gallium/state_trackers/nine/nine_shader.c @@ -2167,7 +2167,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) |