[Mesa-dev] [PATCH 20/24] i965: Add brw_reg constructors taking a dynamically determined vector width.

Francisco Jerez currojerez at riseup.net
Sun Sep 15 00:19:44 PDT 2013


The MRF variant is going to be used extensively by the next two
patches to assemble untyped atomic and surface read messages easily.
---
 src/mesa/drivers/dri/i965/brw_reg.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_reg.h b/src/mesa/drivers/dri/i965/brw_reg.h
index 6df3366..8d20ceb 100644
--- a/src/mesa/drivers/dri/i965/brw_reg.h
+++ b/src/mesa/drivers/dri/i965/brw_reg.h
@@ -281,6 +281,24 @@ brw_vec1_reg(unsigned file, unsigned nr, unsigned subnr)
                   WRITEMASK_X);
 }
 
+static inline struct brw_reg
+brw_vecn_reg(unsigned width, unsigned file, unsigned nr, unsigned subnr)
+{
+   switch (width) {
+   case 1:
+      return brw_vec1_reg(file, nr, subnr);
+   case 2:
+      return brw_vec2_reg(file, nr, subnr);
+   case 4:
+      return brw_vec4_reg(file, nr, subnr);
+   case 8:
+      return brw_vec8_reg(file, nr, subnr);
+   case 16:
+      return brw_vec16_reg(file, nr, subnr);
+   default:
+      assert(!"Invalid register width");
+   }
+}
 
 static inline struct brw_reg
 retype(struct brw_reg reg, unsigned type)
@@ -569,6 +587,12 @@ brw_message_reg(unsigned nr)
    return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, nr, 0);
 }
 
+static inline struct brw_reg
+brw_uvec_mrf(unsigned width, unsigned nr, unsigned subnr)
+{
+   return retype(brw_vecn_reg(width, BRW_MESSAGE_REGISTER_FILE, nr, subnr),
+                 BRW_REGISTER_TYPE_UD);
+}
 
 /* This is almost always called with a numeric constant argument, so
  * make things easy to evaluate at compile time:
-- 
1.8.3.4



More information about the mesa-dev mailing list