diff options
author | Ben Widawsky <benjamin.widawsky@intel.com> | 2014-12-22 19:29:22 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2015-01-20 15:24:40 -0800 |
commit | 169d7e5cb1cce73d39e40717d5f49ac30b626d1b (patch) | |
tree | 64654288b10ae81aa4230fa41b86cccf0a808902 | |
parent | 9394f5838364e3265b8f7ee87f3265848317e955 (diff) |
i965: Extract scalar region checking logic
There are currently 2 users of this functionality. I have 2 more users coming
up, and having a simple function makes the results much cleaner. The existing
interface semantics was proposed by Matt.
v2 (Ken): Rename to region_matches()/has_scalar_region().
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_eu_emit.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_reg.h | 13 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 8f15db9f728..c26bed2dee3 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1893,9 +1893,7 @@ void gen4_math(struct brw_compile *p, struct brw_context *brw = p->brw; brw_inst *insn = next_insn(p, BRW_OPCODE_SEND); unsigned data_type; - if (src.vstride == BRW_VERTICAL_STRIDE_0 && - src.width == BRW_WIDTH_1 && - src.hstride == BRW_HORIZONTAL_STRIDE_0) { + if (has_scalar_region(src)) { data_type = BRW_MATH_DATA_SCALAR; } else { data_type = BRW_MATH_DATA_VECTOR; diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index ab848f1714a..d473739452d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -1347,10 +1347,7 @@ fs_generator::generate_set_omask(fs_inst *inst, mask.width == BRW_WIDTH_8 && mask.hstride == BRW_HORIZONTAL_STRIDE_1); - bool stride_0_1_0 = - (mask.vstride == BRW_VERTICAL_STRIDE_0 && - mask.width == BRW_WIDTH_1 && - mask.hstride == BRW_HORIZONTAL_STRIDE_0); + bool stride_0_1_0 = has_scalar_region(mask); assert(stride_8_8_1 || stride_0_1_0); assert(dst.type == BRW_REGISTER_TYPE_UW); diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h index 76d3248bd7e..782cae18fc7 100644 --- a/src/mesa/drivers/dri/i965/brw_reg.h +++ b/src/mesa/drivers/dri/i965/brw_reg.h @@ -902,6 +902,19 @@ brw_indirect(unsigned addr_subnr, int offset) return ptr; } +static inline bool +region_matches(struct brw_reg reg, enum brw_vertical_stride v, + enum brw_width w, enum brw_horizontal_stride h) +{ + return reg.vstride == v && + reg.width == w && + reg.hstride == h; +} + +#define has_scalar_region(reg) \ + region_matches(reg, BRW_VERTICAL_STRIDE_0, BRW_WIDTH_1, \ + BRW_HORIZONTAL_STRIDE_0) + /* brw_packed_float.c */ int brw_float_to_vf(float f); float brw_vf_to_float(unsigned char vf); |