[cairo] Problems blending with different platforms

Siarhei Siamashka siarhei.siamashka at gmail.com
Fri Dec 11 07:14:33 PST 2009


On Friday 11 December 2009, Some Guy wrote:
> Hello,
>
> I am using Cairo 1.8.8 and Pixman .17.2 - I have some cross platform code
> that runs on an x86-64 machine and a low powered LE 32-bit MIPS.  I was
> using the image backend surface (ARGB) that was filled with opaque yellow
> and blending an ARGB image on top of it with the OVER operator.
>
> I found that if the alpha value of an image in the pixel is 0, but RGB data
> is not, I would get the proper blending behavior on the x86 but the MIPS
> would produce a destination pixel with 0 alpha.

Thanks for trying cairo/pixman on MIPS. The code really should be expected to
run identically on different platforms, so there must be some problem
somewhere.

Can you try to compile pixman and run 'blitters-test' test program from 'test'
directory on MIPS? Based on the information you provided, it would most likely
fail, but that's the first step to confirm things. Eventually we want to have
this test pass on MIPS (like it does on other platforms). After this the
problem can be considered resolved.

> I found that the combine 
> code being used was in pixman-combine32.c and eventually traced it to
> combine_over_u .  I did a quick test and it ended up working.
>
> I've attached my patch - it seems kind of hacky, but it was a quick fix for
> what I needed.  The gist of it is to not do anything if the input alpha is
> 0 ( ALPHA_8 (~s) returns 255) so I check for that and skip the
> UN8x4_MUL_UN8_ADD_UN8x4 operation.
>
> Anyway, please let me know if this is totally wrong, it appears to work for
> me, but I've been wrong before :)

It looks like this patch is just hiding the problem and the real root cause is
different. Though this patch may be useful to improve performance (which still
needs to be confirmed by benchmarks), but it's a different matter.

Anyway, I would try the following things first:
1. Make sure that it is not a bug in your compiler, try disabling
optimizations with -O0 option and run 'blitters-test' again.
2. It could be a result of some differences in how pixman gets configured, or 
some tiny platform related differences, for example default 'char' type
signedness or anything like this.
3. It could be that pixman is triggering some type of 'undefined behaviour' 
which happens to work differently on MIPS. Examples of such stuff are shifts
(negative or too big shift count results in undefined behavior according to C
standard).

Isolating the problem to a really small testcase would be very useful.

When making sure that 'blitters-test' runs identically on different platforms, 
it may be handy to use 'blitters-test-bisect.rb' script and use ssh to run
'blitters-test' on a MIPS host remotely, comparing results to a reference
binary from your desktop PC. Something like this could work:

$ ruby blitters-test-bisect.rb ./blitters-test "ssh 
username at mips_host /path/to/blitters-test"

Hope this helps.

-- 
Best regards,
Siarhei Siamashka
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.cairographics.org/archives/cairo/attachments/20091211/4c8f5bc8/attachment.pgp 


More information about the cairo mailing list