Module: Mesa
Branch: main
Commit: b5df20568a6e60056211b634efa3bea4758f18e9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5df20568a6e60056211b634efa3bea4758f18e9

Author: Axel Davy <[email protected]>
Date:   Thu Jul 28 22:55:40 2022 +0200

frontend/nine: Fix ff position_t fallback when w = 0

For post-transformed vertices, w = 0 is similar to
w = 1. Replace the value to fix rcp(w).

It is common for apps to pass w = 0 for
position_t.

cc: mesa-stable

Signed-off-by: Axel Davy <[email protected]>
Acked-by: David Heidelberg <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18021>

---

 src/gallium/frontends/nine/nine_ff.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/frontends/nine/nine_ff.c 
b/src/gallium/frontends/nine/nine_ff.c
index edf131cefad..6705fc2208c 100644
--- a/src/gallium/frontends/nine/nine_ff.c
+++ b/src/gallium/frontends/nine/nine_ff.c
@@ -455,6 +455,9 @@ nine_ff_build_vs(struct NineDevice9 *device, struct 
vs_build_ctx *vs)
             ureg_ADD(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_XY), 
ureg_src(tmp), ureg_imm1f(ureg, -1.0f));
             /* Y needs to be reversed */
             ureg_MOV(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Y), 
ureg_negate(ureg_src(tmp)));
+            /* Replace w by 1 if it equals to 0 */
+            ureg_CMP(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_W), 
ureg_negate(ureg_abs(ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_W))),
+                     ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_W), 
ureg_imm1f(ureg, 1.0f));
             /* inverse rhw */
             ureg_RCP(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_W), _W(tmp));
             /* multiply X, Y, Z by w */

Reply via email to