summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2014-12-28 14:38:25 +0100
committerEmil Velikov <[email protected]>2015-01-23 00:47:24 +0000
commit2b4c5777306c9dd20b3431516e4ae9a64feb2116 (patch)
tree42fa3741feb628e31d21dd187399c0354f248973 /src
parente3a393b4c3ef111f7352ddad5647a10b76861205 (diff)
st/nine: Implement TEXDEPTH
Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: David Heidelberg <[email protected]> Signed-off-by: Axel Davy <[email protected]> Cc: "10.4" <[email protected]> (cherry picked from commit f19e699368405f5fe74efe7b483f032c1a2c69be)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/nine/nine_shader.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
index a60599816c4..cb0793efc59 100644
--- a/src/gallium/state_trackers/nine/nine_shader.c
+++ b/src/gallium/state_trackers/nine/nine_shader.c
@@ -2308,7 +2308,28 @@ DECL_SPECIAL(TEXM3x3)
DECL_SPECIAL(TEXDEPTH)
{
- STUB(D3DERR_INVALIDCALL);
+ struct ureg_program *ureg = tx->ureg;
+ struct ureg_dst r5;
+ struct ureg_src r5r, r5g;
+
+ assert(tx->insn.dst[0].idx == 5); /* instruction must get r5 here */
+
+ /* we must replace the depth by r5.g == 0 ? 1.0f : r5.r/r5.g.
+ * r5 won't be used afterward, thus we can use r5.ba */
+ r5 = tx->regs.r[5];
+ r5r = ureg_scalar(ureg_src(r5), TGSI_SWIZZLE_X);
+ r5g = ureg_scalar(ureg_src(r5), TGSI_SWIZZLE_Y);
+
+ ureg_RCP(ureg, ureg_writemask(r5, TGSI_WRITEMASK_Z), r5g);
+ ureg_MUL(ureg, ureg_writemask(r5, TGSI_WRITEMASK_X), r5r, ureg_scalar(ureg_src(r5), TGSI_SWIZZLE_Z));
+ /* r5.r = r/g */
+ ureg_CMP(ureg, ureg_writemask(r5, TGSI_WRITEMASK_X), ureg_negate(ureg_abs(r5g)),
+ r5r, 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, r5r);
+
+ return D3D_OK;
}
DECL_SPECIAL(BEM)