[Mesa-dev] [PATCH v2 07/12] nine: always generate two-dimensional constant file accesses

Nicolai Hähnle nhaehnle at gmail.com
Mon Aug 28 08:58:15 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Acked-by: Roland Scheidegger <sroland at vmware.com>
Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de>
---
 src/gallium/state_trackers/nine/nine_ff.c     |  2 +-
 src/gallium/state_trackers/nine/nine_shader.c | 10 ++++------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index 2175bdbcc51..39fcb8b1591 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -476,21 +476,21 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
             ureg_MAD(ureg, tmp, vs->aInd, ureg_imm1f(ureg, 4.0f), ureg_imm1f(ureg, 160.0f));
             ureg_ARL(ureg, AR, ureg_src(tmp));
         }
 
         ureg_MOV(ureg, aVtx_dst, ureg_imm4f(ureg, 0.0f, 0.0f, 0.0f, 0.0f));
         ureg_MOV(ureg, aNrm_dst, ureg_imm4f(ureg, 0.0f, 0.0f, 0.0f, 0.0f));
         ureg_MOV(ureg, sum_blendweights, ureg_imm4f(ureg, 1.0f, 1.0f, 1.0f, 1.0f));
 
         for (i = 0; i < key->vertexblend; ++i) {
             for (c = 0; c < 4; ++c) {
-                cWM[c] = ureg_src_register(TGSI_FILE_CONSTANT, (160 + i * 4) * !key->vertexblend_indexed + c);
+                cWM[c] = ureg_src_dimension(ureg_src_register(TGSI_FILE_CONSTANT, (160 + i * 4) * !key->vertexblend_indexed + c), 0);
                 if (key->vertexblend_indexed)
                     cWM[c] = ureg_src_indirect(cWM[c], ureg_scalar(ureg_src(AR), i));
             }
 
             /* multiply by WORLD(index) */
             ureg_MUL(ureg, tmp, _XXXX(vs->aVtx), cWM[0]);
             ureg_MAD(ureg, tmp, _YYYY(vs->aVtx), cWM[1], ureg_src(tmp));
             ureg_MAD(ureg, tmp, _ZZZZ(vs->aVtx), cWM[2], ureg_src(tmp));
             ureg_MAD(ureg, tmp, _WWWW(vs->aVtx), cWM[3], ureg_src(tmp));
 
diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
index 5b60dcbac8f..cc667ebfbcd 100644
--- a/src/gallium/state_trackers/nine/nine_shader.c
+++ b/src/gallium/state_trackers/nine/nine_shader.c
@@ -84,21 +84,21 @@ static inline const char *d3dsio_to_string(unsigned opcode);
 #define NINED3DSP_WRITEMASK_2   0x4
 #define NINED3DSP_WRITEMASK_3   0x8
 #define NINED3DSP_WRITEMASK_ALL 0xf
 
 #define NINED3DSP_NOSWIZZLE ((0 << 0) | (1 << 2) | (2 << 4) | (3 << 6))
 
 #define NINE_SWIZZLE4(x,y,z,w) \
    TGSI_SWIZZLE_##x, TGSI_SWIZZLE_##y, TGSI_SWIZZLE_##z, TGSI_SWIZZLE_##w
 
 #define NINE_CONSTANT_SRC(index) \
-   ureg_src_register(TGSI_FILE_CONSTANT, index)
+   ureg_src_dimension(ureg_src_register(TGSI_FILE_CONSTANT, index), 0)
 
 #define NINE_APPLY_SWIZZLE(src, s) \
    ureg_swizzle(src, NINE_SWIZZLE4(s, s, s, s))
 
 #define NINE_CONSTANT_SRC_SWIZZLE(index, s) \
    NINE_APPLY_SWIZZLE(NINE_CONSTANT_SRC(index), s)
 
 #define NINED3DSPDM_SATURATE (D3DSPDM_SATURATE >> D3DSP_DSTMOD_SHIFT)
 #define NINED3DSPDM_PARTIALP (D3DSPDM_PARTIALPRECISION >> D3DSP_DSTMOD_SHIFT)
 #define NINED3DSPDM_CENTROID (D3DSPDM_MSAMPCENTROID >> D3DSP_DSTMOD_SHIFT)
@@ -1002,21 +1002,21 @@ tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param)
                         src = ureg_src_dimension(src, 0);
                     } else {
                         src = ureg_src_register(TGSI_FILE_CONSTANT, param->idx - 4096);
                         src = ureg_src_dimension(src, 1);
                     }
                 } else {
                     src = ureg_src_register(TGSI_FILE_CONSTANT, param->idx); /* TODO: swvp rel > 4096 */
                     src = ureg_src_dimension(src, 0);
                 }
             } else
-                src = ureg_src_register(TGSI_FILE_CONSTANT, param->idx);
+                src = NINE_CONSTANT_SRC(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:
@@ -1028,36 +1028,34 @@ tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param)
         break;
     case D3DSPR_CONSTINT:
         /* relative adressing only possible for float constants in vs */
         assert(!param->rel);
         if (!tx_lconsti(tx, &src, param->idx)) {
             nine_info_mark_const_i_used(tx->info, param->idx);
             if (IS_VS && tx->info->swvp_on) {
                 src = ureg_src_register(TGSI_FILE_CONSTANT, param->idx);
                 src = ureg_src_dimension(src, 2);
             } else
-                src = ureg_src_register(TGSI_FILE_CONSTANT,
-                                        tx->info->const_i_base + param->idx);
+                src = NINE_CONSTANT_SRC(tx->info->const_i_base + param->idx);
         }
         break;
     case D3DSPR_CONSTBOOL:
         assert(!param->rel);
         if (!tx_lconstb(tx, &src, param->idx)) {
            char r = param->idx / 4;
            char s = param->idx & 3;
            nine_info_mark_const_b_used(tx->info, param->idx);
            if (IS_VS && tx->info->swvp_on) {
                src = ureg_src_register(TGSI_FILE_CONSTANT, r);
                src = ureg_src_dimension(src, 3);
            } else
-               src = ureg_src_register(TGSI_FILE_CONSTANT,
-                                       tx->info->const_b_base + r);
+               src = NINE_CONSTANT_SRC(tx->info->const_b_base + r);
            src = ureg_swizzle(src, s, s, s, s);
         }
         break;
     case D3DSPR_LOOP:
         if (ureg_dst_is_undef(tx->regs.address))
             tx->regs.address = ureg_DECL_address(ureg);
         if (!tx->native_integers)
             ureg_ARR(ureg, tx->regs.address, tx_get_loopal(tx));
         else
             ureg_UARL(ureg, tx->regs.address, tx_get_loopal(tx));
-- 
2.11.0



More information about the mesa-dev mailing list