[Mesa-dev] llvmpipe vs fbo-alphatest-formats

Jose Fonseca jfonseca at vmware.com
Fri Dec 30 09:31:25 PST 2011

----- Original Message -----
> >>
> >> Okay this fixes it here, and even seems reasonable to me.
> >
> > Yes. Great catch Dave.
> >
> > This should also fix to L8 rendering.  But I belive that in the
> > commit message, you mean "i8" and not "l8".
> >
> > Please add a comment about why order matters in the inv_swizzle()
> > function, for future reference.
> Yup this fixed a few tests, and showed up a blending problem that you
> guessed at least for I8,
> The fbo-blending-formats test now only fails on I8 with DST_ALPHA,
> I'm
> guessing what happens is we have an I8 dst, but we never flush the
> tiles, so we end up using the alpha from the tile as the dst alpha
> value instead of the red value.

The solution is to generalize the tweaks we do formats without alpha (alpha's swizzle is ONE), to the formats where alpha replicates another channel, like these.

That is, extend this code:

       * Our swizzled render tiles always have an alpha channel, but the linear
       * render target format often does not, so force here the dst alpha to be
       * one.
       * This is not a mere optimization. Wrong results will be produced if the
       * dst alpha is used, the dst format does not have alpha, and the previous
       * rendering was not flushed from the swizzled to linear buffer. For
       * example, NonPowTwo DCT.
       * TODO: This should be generalized to all channels for better
       * performance, but only alpha causes correctness issues.
       * Also, force rgb/alpha func/factors match, to make AoS blending easier.
      if (format_desc->swizzle[3] > UTIL_FORMAT_SWIZZLE_W) {
         blend_rt->rgb_src_factor   = force_dst_alpha_one(blend_rt->rgb_src_factor);
         blend_rt->rgb_dst_factor   = force_dst_alpha_one(blend_rt->rgb_dst_factor);
         blend_rt->alpha_func       = blend_rt->rgb_func;
         blend_rt->alpha_src_factor = blend_rt->rgb_src_factor;
         blend_rt->alpha_dst_factor = blend_rt->rgb_dst_factor;

to handle a situation where format_desc->swizzle[3] == format_desc->swizzle[0], by replacing all ALPHA related factors with RGB. Or something along those lines.

Another would be to make the blending code aware of replicating swizzles.

Flushing the unswizzling is not really effective -- it would need to be done per primitive to be fully correct, which is unfeasible.


More information about the mesa-dev mailing list