Matt Turner <[email protected]> writes: > In order to do this, we have to change the signature of the > backend_reg(brw_reg) constructor to take a reference to a brw_reg in > order to avoid unresolvable ambiguity about which constructor is > actually being called in the other modifications in this patch. > > As far as I understand it, the rule in C++ is that if multiple > constructors are available for parent classes, the one closest to you in > the class heirarchy is closen, but if one of them didn't take a > reference, that screws things up.
I believe that the reason is that the ordering between more and less derived classes is only defined for values of the same kind, i.e. a conversion from 'const src_reg &' to 'const backend_reg &' is considered a better match than 'const src_reg &' to 'const brw_reg &', and a conversion from 'src_reg' to backend_reg' would have been considered better than 'src_reg' to 'brw_reg', but that doesn't necessarily disambiguate between the conversions to 'const backend_reg &' and 'brw_reg'. Anyway there was no good reason to pass the brw_reg object by value. For the series: Reviewed-by: Francisco Jerez <[email protected]> > --- > src/mesa/drivers/dri/i965/brw_shader.h | 2 +- > src/mesa/drivers/dri/i965/brw_vec4.cpp | 6 ++---- > 2 files changed, 3 insertions(+), 5 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_shader.h > b/src/mesa/drivers/dri/i965/brw_shader.h > index 718a225..abf04cf 100644 > --- a/src/mesa/drivers/dri/i965/brw_shader.h > +++ b/src/mesa/drivers/dri/i965/brw_shader.h > @@ -42,7 +42,7 @@ > struct backend_reg : public brw_reg > { > backend_reg() {} > - backend_reg(struct brw_reg reg) : brw_reg(reg) {} > + backend_reg(const struct brw_reg ®) : brw_reg(reg) {} > > bool equals(const backend_reg &r) const; > > diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp > b/src/mesa/drivers/dri/i965/brw_vec4.cpp > index a23fd82..60b2fed 100644 > --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp > +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp > @@ -79,9 +79,8 @@ src_reg::src_reg(struct brw_reg reg) : > } > > src_reg::src_reg(const dst_reg ®) : > - backend_reg(static_cast<struct brw_reg>(reg)) > + backend_reg(reg) > { > - this->reg_offset = reg.reg_offset; > this->reladdr = reg.reladdr; > this->swizzle = brw_swizzle_for_mask(reg.writemask); > } > @@ -137,9 +136,8 @@ dst_reg::dst_reg(struct brw_reg reg) : > } > > dst_reg::dst_reg(const src_reg ®) : > - backend_reg(static_cast<struct brw_reg>(reg)) > + backend_reg(reg) > { > - this->reg_offset = reg.reg_offset; > this->writemask = brw_mask_for_swizzle(reg.swizzle); > this->reladdr = reg.reladdr; > } > -- > 2.4.9
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
