Mesa (master): i965: Make sure that backend_reg::type and brw_reg:: type are consistent for fixed regs.

Francisco Jerez currojerez at kemper.freedesktop.org
Wed Feb 19 15:57:29 UTC 2014


Module: Mesa
Branch: master
Commit: 42b226ef824ed61ccf51fa9a1198cba305ad5472
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=42b226ef824ed61ccf51fa9a1198cba305ad5472

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Wed Feb 19 15:21:07 2014 +0100

i965: Make sure that backend_reg::type and brw_reg::type are consistent for fixed regs.

And define non-mutating helper functions to retype fixed and normal
regs with a common interface.  At some point we may want to get rid of
::fixed_hw_reg completely and have fixed regs use the normal register
data members (e.g. backend_reg::reg to select a fixed GRF number,
src_reg::swizzle to store the swizzle, etc.), I have the feeling that
this is not the last headache we're going to get because of the
multiple ways to represent the same thing and the different register
interface depending on the file a register is stored in...

Reviewed-by: Paul Berry <stereotype441 at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_fs.h               |    7 +++++++
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp   |    1 +
 src/mesa/drivers/dri/i965/brw_vec4.cpp           |    2 ++
 src/mesa/drivers/dri/i965/brw_vec4.h             |   14 ++++++++++++++
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |    2 ++
 5 files changed, 26 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index ce5050b..4845156 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -130,6 +130,13 @@ public:
 };
 
 static inline fs_reg
+retype(fs_reg reg, unsigned type)
+{
+   reg.fixed_hw_reg.type = reg.type = type;
+   return reg;
+}
+
+static inline fs_reg
 offset(fs_reg reg, unsigned delta)
 {
    assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 82db140..3f2060d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1053,6 +1053,7 @@ brw_reg_from_fs_reg(fs_reg *reg)
       }
       break;
    case HW_REG:
+      assert(reg->type == reg->fixed_hw_reg.type);
       brw_reg = reg->fixed_hw_reg;
       break;
    case BAD_FILE:
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 53fb9ee..fbf7fb9 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -118,6 +118,7 @@ src_reg::src_reg(struct brw_reg reg)
 
    this->file = HW_REG;
    this->fixed_hw_reg = reg;
+   this->type = reg.type;
 }
 
 src_reg::src_reg(dst_reg reg)
@@ -188,6 +189,7 @@ dst_reg::dst_reg(struct brw_reg reg)
 
    this->file = HW_REG;
    this->fixed_hw_reg = reg;
+   this->type = reg.type;
 }
 
 dst_reg::dst_reg(src_reg reg)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index a592af2..9dc4f01 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -141,6 +141,13 @@ public:
 };
 
 static inline src_reg
+retype(src_reg reg, unsigned type)
+{
+   reg.fixed_hw_reg.type = reg.type = type;
+   return reg;
+}
+
+static inline src_reg
 offset(src_reg reg, unsigned delta)
 {
    assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
@@ -193,6 +200,13 @@ public:
 };
 
 static inline dst_reg
+retype(dst_reg reg, unsigned type)
+{
+   reg.fixed_hw_reg.type = reg.type = type;
+   return reg;
+}
+
+static inline dst_reg
 offset(dst_reg reg, unsigned delta)
 {
    assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 058b639..e0c59ba 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -50,6 +50,7 @@ vec4_instruction::get_dst(void)
       break;
 
    case HW_REG:
+      assert(dst.type == dst.fixed_hw_reg.type);
       brw_reg = dst.fixed_hw_reg;
       break;
 
@@ -116,6 +117,7 @@ vec4_instruction::get_src(const struct brw_vec4_prog_data *prog_data, int i)
       break;
 
    case HW_REG:
+      assert(src[i].type == src[i].fixed_hw_reg.type);
       brw_reg = src[i].fixed_hw_reg;
       break;
 




More information about the mesa-commit mailing list