diff options
author | Francisco Jerez <[email protected]> | 2015-02-04 17:58:49 +0200 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2015-02-19 14:06:42 +0200 |
commit | 509f58740c721e1a8cc8ec4e556af3ed993f927e (patch) | |
tree | 9c3ec8297501b396945f99ccb8f40754f5982b64 | |
parent | 63d6d09a3b3790c5ec00f2cbc06f58c82ae40b0c (diff) |
i965/fs: Replace ud_reg_to_w() with a more general helper function.
Reviewed-by: Matt Turner <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 27 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_reg.h | 22 |
2 files changed, 25 insertions, 24 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 3475b31338e..86cc6679d12 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -1399,27 +1399,6 @@ fs_generator::generate_set_sample_id(fs_inst *inst, brw_pop_insn_state(p); } -/** - * Change the register's data type from UD to W, doubling the strides in order - * to compensate for halving the data type width. - */ -static struct brw_reg -ud_reg_to_w(struct brw_reg r) -{ - assert(r.type == BRW_REGISTER_TYPE_UD); - r.type = BRW_REGISTER_TYPE_W; - - /* The BRW_*_STRIDE enums are defined so that incrementing the field - * doubles the real stride. - */ - if (r.hstride != 0) - ++r.hstride; - if (r.vstride != 0) - ++r.vstride; - - return r; -} - void fs_generator::generate_pack_half_2x16_split(fs_inst *inst, struct brw_reg dst, @@ -1440,9 +1419,9 @@ fs_generator::generate_pack_half_2x16_split(fs_inst *inst, * (HorzStride) of 2. The 16-bit result is stored in the lower word of * each destination channel and the upper word is not modified. */ - struct brw_reg dst_w = ud_reg_to_w(dst); + struct brw_reg dst_w = spread(retype(dst, BRW_REGISTER_TYPE_W), 2); - /* Give each 32-bit channel of dst the form below , where "." means + /* Give each 32-bit channel of dst the form below, where "." means * unchanged. * 0x....hhhh */ @@ -1474,7 +1453,7 @@ fs_generator::generate_unpack_half_2x16_split(fs_inst *inst, * the source data type must be Word (W). The destination type must be * F (Float). */ - struct brw_reg src_w = ud_reg_to_w(src); + struct brw_reg src_w = spread(retype(src, BRW_REGISTER_TYPE_W), 2); /* Each channel of src has the form of unpackHalf2x16's input: 0xhhhhllll. * For the Y case, we wish to access only the upper word; therefore diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h index 782cae18fc7..eaf6620998e 100644 --- a/src/mesa/drivers/dri/i965/brw_reg.h +++ b/src/mesa/drivers/dri/i965/brw_reg.h @@ -45,6 +45,7 @@ #include <stdbool.h> #include "main/imports.h" #include "main/compiler.h" +#include "main/macros.h" #include "program/prog_instruction.h" #include "brw_defines.h" @@ -720,6 +721,27 @@ stride(struct brw_reg reg, unsigned vstride, unsigned width, unsigned hstride) return reg; } +/** + * Multiply the vertical and horizontal stride of a register by the given + * factor \a s. + */ +static inline struct brw_reg +spread(struct brw_reg reg, unsigned s) +{ + if (s) { + assert(is_power_of_two(s)); + + if (reg.hstride) + reg.hstride += cvt(s) - 1; + + if (reg.vstride) + reg.vstride += cvt(s) - 1; + + return reg; + } else { + return stride(reg, 0, 1, 0); + } +} static inline struct brw_reg vec16(struct brw_reg reg) |