On Fri, Jun 26, 2015 at 1:06 AM, Eduardo Lima Mitev <el...@igalia.com> wrote: > From: Antia Puentes <apuen...@igalia.com> > > For operations that have a predefined operand size > 0, defined in > glsl/nir/nir_opcodes.c, NIR returns a swizzle containing zeros in the > components from outside the source vector. However, the driver > expects those components to have a swizzle value equal to the swizzle > of the component in (number of vector elements - 1). For example, > > for a vec2 operation with an identity swizzle (.xy): > - (NIR -> XYXX, driver ->XYYYY) > > for a vec3 operation with swizzle (.zxy) > - (NIR-> ZXYX, driver -> ZXYY)
Why is this needed. Was there some bug you ran into regarding this or are you just trying to make the generated code match? If the component isn't used, then it seems to me like the swizzle shouldn't matter. NIR may give you bogus swizzles outside of the enabled channels but it may do that regardless. I'm also not seeing how composing swizzles fixes anything. Please explain --Jason > This method handles that. > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89580 > --- > src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp > b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp > index cf74693..6beb95d 100644 > --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp > +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp > @@ -734,6 +734,28 @@ brw_conditional_for_nir_comparison(nir_op op) > } > } > > +static src_reg > +fix_swizzle_for_input_fixed_size(nir_op op, src_reg src) > +{ > + /* For operations that have a predefined operand size > 0, defined in > + * glsl/nir/nir_opcodes.c, NIR returns a swizzle containing zeros in the > + * components from outside the source vector. However, the driver > + * expects those components to have a swizzle value equal to the swizzle > + * of the component in (number of vector elements - 1). For example, > + * for a vec2 operation with an identity swizzle (.xy): > + * - (NIR -> XYXX, driver ->XYYYY) > + * for a vec3 operation with swizzle (.zxy) > + * - (NIR-> ZXYX, driver -> ZXYY) > + */ > + unsigned size = nir_op_infos[op].input_sizes[0]; > + assert(size > 0); > + > + src.swizzle = brw_compose_swizzle(brw_swizzle_for_size(size), > + src.swizzle); > + > + return src; > +} > + > void > vec4_visitor::nir_emit_alu(nir_alu_instr *instr) > { > -- > 2.1.4 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev