[Mesa-dev] [PATCH 16/23] i965: Make sure that backend_reg::type and brw_reg::type are consistent for fixed regs.
Francisco Jerez
currojerez at riseup.net
Mon Dec 2 11:31:21 PST 2013
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...
---
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_shader.h | 7 +++++++
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 ++
6 files changed, 33 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index c011758..f62da44 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -93,6 +93,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 1de59eb..9c2c318 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1018,6 +1018,7 @@ brw_reg_from_fs_reg(fs_reg *reg, unsigned dispatch_width)
}
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_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 322ef1f..c31f76d 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -81,6 +81,13 @@ public:
};
static inline backend_reg
+retype(backend_reg reg, unsigned type)
+{
+ reg.fixed_hw_reg.type = reg.type = type;
+ return reg;
+}
+
+static inline backend_reg
offset(backend_reg reg, unsigned delta)
{
assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index ab01b119..9d5d26f 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(const backend_reg ®)
@@ -190,6 +191,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(const backend_reg ®)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 8ce3a5e..19de4c6 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -118,6 +118,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));
@@ -171,6 +178,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 9ce2cf7..a0c44fe 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;
--
1.8.3.4
More information about the mesa-dev
mailing list