st/nine: Clamp ps 1.X constants
authorAxel Davy <axel.davy@ens.fr>
Wed, 24 Dec 2014 08:58:49 +0000 (09:58 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 22 Jan 2015 22:16:21 +0000 (22:16 +0000)
This is wine (and windows) behaviour.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
src/gallium/state_trackers/nine/nine_shader.c

index bd695039e3378342481367725a085bc661c9452c..883743eb39e0388e7529c6bb2b9029db196e8264 100644 (file)
@@ -842,6 +842,13 @@ tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param)
                 nine_info_mark_const_f_used(tx->info, param->idx);
             src = ureg_src_register(TGSI_FILE_CONSTANT, param->idx);
         }
+        if (!IS_VS && tx->version.major < 2) {
+            /* ps 1.X clamps constants */
+            tmp = tx_scratch(tx);
+            ureg_MIN(ureg, tmp, src, ureg_imm1f(ureg, 1.0f));
+            ureg_MAX(ureg, tmp, ureg_src(tmp), ureg_imm1f(ureg, -1.0f));
+            src = ureg_src(tmp);
+        }
         break;
     case D3DSPR_CONST2:
     case D3DSPR_CONST3: