[Mesa-dev] [PATCH 14/23] i965: Add non-mutating helper functions to modify the register offset.
Francisco Jerez
currojerez at riseup.net
Mon Dec 2 11:31:19 PST 2013
Yes, we could avoid having four copies of essentially the same code by
using templates here.
---
src/mesa/drivers/dri/i965/brw_fs.h | 8 ++++++++
src/mesa/drivers/dri/i965/brw_shader.h | 8 ++++++++
src/mesa/drivers/dri/i965/brw_vec4.h | 16 ++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index f918f7e..c011758 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -93,6 +93,14 @@ public:
};
static inline fs_reg
+offset(fs_reg reg, unsigned delta)
+{
+ assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
+ reg.reg_offset += delta;
+ return reg;
+}
+
+static inline fs_reg
byte_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_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index d1357ce..322ef1f 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -80,6 +80,14 @@ public:
} imm;
};
+static inline backend_reg
+offset(backend_reg reg, unsigned delta)
+{
+ assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
+ reg.reg_offset += delta;
+ return reg;
+}
+
class backend_instruction : public exec_node {
public:
bool is_tex();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 720cc6e..db1604a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -117,6 +117,14 @@ public:
src_reg *reladdr;
};
+static inline src_reg
+offset(src_reg reg, unsigned delta)
+{
+ assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
+ reg.reg_offset += delta;
+ return reg;
+}
+
class dst_reg : public backend_reg
{
public:
@@ -138,6 +146,14 @@ public:
src_reg *reladdr;
};
+static inline dst_reg
+offset(dst_reg reg, unsigned delta)
+{
+ assert(delta == 0 || (reg.file != HW_REG && reg.file != IMM));
+ reg.reg_offset += delta;
+ return reg;
+}
+
dst_reg
with_writemask(dst_reg const &r, int mask);
--
1.8.3.4
More information about the mesa-dev
mailing list