[Mesa-stable] [PATCH 19/53] st/nine: Clamp color inputs for ps <= 2.0 at ps level instead of vs

Axel Davy axel.davy at ens.fr
Wed Jan 7 08:36:29 PST 2015


Nine code was clamping color outputs for vs < 3,
but msdn docs says it is done in the ps.
Wine seems to clamp them at the vs level.

It makes more sense to clamp at vs level for performance,
but according to doc, ps 2.x shouldn't see clamping.

Reviewed-by: David Heidelberg <david at ixit.cz>
Signed-off-by: Axel Davy <axel.davy at ens.fr>

Cc: "10.4" <mesa-stable at lists.freedesktop.org>
---
 src/gallium/state_trackers/nine/nine_shader.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
index 8b96673..b0c08ad 100644
--- a/src/gallium/state_trackers/nine/nine_shader.c
+++ b/src/gallium/state_trackers/nine/nine_shader.c
@@ -800,9 +800,21 @@ tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param)
         } else {
             if (tx->version.major < 3) {
                 assert(!param->rel);
-                src = ureg_DECL_fs_input(tx->ureg, TGSI_SEMANTIC_COLOR,
-                                         param->idx,
-                                         TGSI_INTERPOLATE_PERSPECTIVE);
+                assert(param->idx < 2);
+                if (ureg_src_is_undef(tx->regs.vC[param->idx])) {
+                    src = ureg_DECL_fs_input(ureg,
+                                             TGSI_SEMANTIC_COLOR,
+                                             param->idx,
+                                             TGSI_INTERPOLATE_PERSPECTIVE);
+                    /* ps <= 2.0: diffuse and specular are clamped to [0, 1] */
+                    if (tx->version.major < 2 || tx->version.minor == 0) {
+                        tmp = ureg_DECL_temporary(ureg);
+                        ureg_MOV(ureg, ureg_saturate(tmp), src);
+                        tx->regs.vC[param->idx] = ureg_src(tmp);
+                    } else
+                        tx->regs.vC[param->idx] = src;
+                }
+                src = tx->regs.vC[param->idx];
             } else {
                 assert(!param->rel); /* TODO */
                 assert(param->idx < Elements(tx->regs.v));
@@ -1045,8 +1057,6 @@ _tx_dst_param(struct shader_translator *tx, const struct sm1_dst_param *param)
             tx->regs.oCol[param->idx] =
                ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_COLOR, param->idx);
         dst = tx->regs.oCol[param->idx];
-        if (IS_VS && tx->version.major < 3)
-            dst = ureg_saturate(dst);
         break;
     case D3DSPR_DEPTHOUT:
         assert(!param->rel);
-- 
2.1.3



More information about the mesa-stable mailing list