i965: add helper for creating packing writemask
authorTimothy Arceri <timothy.arceri@collabora.com>
Thu, 23 Jun 2016 02:52:05 +0000 (12:52 +1000)
committerTimothy Arceri <timothy.arceri@collabora.com>
Thu, 21 Jul 2016 02:06:11 +0000 (12:06 +1000)
For example where n=3 first_component=1 this will give us
0xE (WRITEMASK_YZW).

V2:
Add assert to check first component is <= 4 (Suggested by Ken)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
src/mesa/drivers/dri/i965/brw_reg.h

index 7eab7b51e380b98d7c8f2aa1195f0acc7c7a825e..5b427b22230d30e1472d50f4b8587fd708f2b21e 100644 (file)
@@ -972,6 +972,13 @@ brw_writemask_for_size(unsigned n)
    return (1 << n) - 1;
 }
 
+static inline unsigned
+brw_writemask_for_component_packing(unsigned n, unsigned first_component)
+{
+   assert(first_component + n <= 4);
+   return (((1 << n) - 1) << first_component);
+}
+
 static inline struct brw_reg
 negate(struct brw_reg reg)
 {