[Mesa-dev] [PATCH 12/21] i965: Extract scalar region checking logic

Ben Widawsky benjamin.widawsky at intel.com
Mon Dec 22 19:29:22 PST 2014


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.

Cc: Matt Turner <mattst88 at gmail.com>
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 src/mesa/drivers/dri/i965/brw_eu_emit.c        |  4 +---
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp |  5 +----
 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 51bf1b9..1fc5a2f 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1928,9 +1928,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 (is_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 d45a548..6c526ad 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1326,10 +1326,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 = is_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 a76932c..d6438b2 100644
--- a/src/mesa/drivers/dri/i965/brw_reg.h
+++ b/src/mesa/drivers/dri/i965/brw_reg.h
@@ -908,6 +908,19 @@ brw_indirect(unsigned addr_subnr, int offset)
    return ptr;
 }
 
+static inline bool
+is_regioned(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 is_scalar_region(reg) \
+   is_regioned(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);
-- 
2.2.1



More information about the mesa-dev mailing list