[Mesa-dev] [PATCH 08/21] i965/vec4: Make src_reg conversion constructor from dst_reg implicit.

Francisco Jerez currojerez at riseup.net
Tue Apr 28 10:08:24 PDT 2015


The dst_reg to src_reg conversion is fairly safe since
430c6bf70e48c08ba4dc9e00f2b88e2230793010.  No information is lost and
OP(dst, src_reg(dst), src1) does what one would expect -- This seems
just annoying now.  The implicit conversion allows you to declare
temporaries that are both written and read from as dst_reg and have
them conveniently converted to src_reg when they are used.  They also
avoid redundant expressions like 'negate(src_reg(tmp))',
'swizzle(src_reg(tmp), ...)' or 'src_vector(src_reg(tmp), ...)' (the
latter function will be defined in a future commit).

The src_reg to dst_reg conversion is kept explicit because it does
lose component ordering information.
---
 src/mesa/drivers/dri/i965/brw_ir_vec4.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
index c65c148..a5fc26f 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
@@ -46,6 +46,7 @@ public:
    src_reg(int32_t i);
    src_reg(uint8_t vf[4]);
    src_reg(uint8_t vf0, uint8_t vf1, uint8_t vf2, uint8_t vf3);
+   src_reg(const dst_reg &reg);
    src_reg(struct brw_reg reg);
 
    bool equals(const src_reg &r) const;
@@ -53,8 +54,6 @@ public:
    src_reg(class vec4_visitor *v, const struct glsl_type *type);
    src_reg(class vec4_visitor *v, const struct glsl_type *type, int size);
 
-   explicit src_reg(const dst_reg &reg);
-
    unsigned swizzle; /**< BRW_SWIZZLE_XYZW macros from brw_reg.h. */
 
    src_reg *reladdr;
-- 
2.3.5



More information about the mesa-dev mailing list