st/nine: Enforce centroid for color input when multisampling is on
authorAxel Davy <axel.davy@ens.fr>
Sat, 9 Jan 2016 13:16:15 +0000 (14:16 +0100)
committerAxel Davy <axel.davy@ens.fr>
Thu, 4 Feb 2016 21:12:17 +0000 (22:12 +0100)
The color inputs must automatically use centroid whether
multisampling is used or not.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
src/gallium/state_trackers/nine/nine_shader.c
src/gallium/state_trackers/nine/nine_shader.h
src/gallium/state_trackers/nine/pixelshader9.c
src/gallium/state_trackers/nine/pixelshader9.h

index 8f08983f64944a5df5553d6d55ca3be32c9576b7..a7a7da27903e17da95d16d92f86cb2c3aa0ba580 100644 (file)
@@ -875,9 +875,12 @@ 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_COLOR);
+                src = ureg_DECL_fs_input_cyl_centroid(
+                    ureg, TGSI_SEMANTIC_COLOR, param->idx,
+                    TGSI_INTERPOLATE_COLOR, 0,
+                    tx->info->force_color_in_centroid ?
+                      TGSI_INTERPOLATE_LOC_CENTROID : 0,
+                    0, 1);
             } else {
                 assert(!param->rel); /* TODO */
                 assert(param->idx < Elements(tx->regs.v));
@@ -2045,7 +2048,8 @@ DECL_SPECIAL(DCL)
             unsigned interp_location = 0;
             /* SM3 only, SM2 input semantic determined by file */
             assert(sem.reg.idx < Elements(tx->regs.v));
-            if (sem.reg.mod & NINED3DSPDM_CENTROID)
+            if (sem.reg.mod & NINED3DSPDM_CENTROID ||
+                (tgsi.Name == TGSI_SEMANTIC_COLOR && tx->info->force_color_in_centroid))
                 interp_location = TGSI_INTERPOLATE_LOC_CENTROID;
             tx->regs.v[sem.reg.idx] = ureg_DECL_fs_input_cyl_centroid(
                 ureg, tgsi.Name, tgsi.Index,
index 41577ac572b2a747ca7fbf01f2850070b0aa2e4f..1fe0c4bd182aef8761c29db52ed7e99a17c56c79 100644 (file)
@@ -61,6 +61,7 @@ struct nine_shader_info
 
     uint8_t fog_enable;
     uint8_t fog_mode;
+    uint8_t force_color_in_centroid;
     uint16_t projected; /* ps 1.1 to 1.3 */
 
     unsigned const_i_base; /* in vec4 (16 byte) units */
index 42bc349c2cc0f95a2a46b6cf567400435ff8bba8..00be67f8955eb6aeea0c2f1b76bf291ffe7a584a 100644 (file)
@@ -160,6 +160,7 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
         info.sampler_ps1xtypes = key;
         info.fog_enable = device->state.rs[D3DRS_FOGENABLE];
         info.fog_mode = device->state.rs[D3DRS_FOGTABLEMODE];
+        info.force_color_in_centroid = key >> 34 & 1;
         info.projected = (key >> 48) & 0xffff;
 
         hr = nine_translate_shader(This->base.device, &info);
index e09009f6621d8698e2a5cc60ae4506ff822b6d3e..6b431813a81c1e5f48d323ecb955447ee29b9ff4 100644 (file)
@@ -28,6 +28,7 @@
 #include "nine_state.h"
 #include "basetexture9.h"
 #include "nine_ff.h"
+#include "surface9.h"
 
 struct nine_lconstf;
 
@@ -92,6 +93,10 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps,
         key |= ((uint64_t)state->rs[D3DRS_FOGTABLEMODE]) << 33;
     }
 
+    /* centroid interpolation automatically used for color ps inputs */
+    if (state->rt[0]->desc.MultiSampleType > 1)
+        key |= ((uint64_t)1) << 34;
+
     if (unlikely(ps->byte_code.version < 0x14)) {
         projected = nine_ff_get_projected_key(state);
         key |= ((uint64_t) projected) << 48;