| Summary: | BlitNtoNPixelAlpha, possible fix | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Ryan C. Gordon <icculus> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED WONTFIX | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | betasoft |
| Version: | HG 1.2 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | Benchmark program for 3 diffrent alpha algorithms | ||
|
Description
Ryan C. Gordon
2006-01-22 03:19:44 UTC
Date: Sat, 21 Jan 2006 01:56:27 +0100 From: Stephane Marchesin <stephane.marchesin@wanadoo.fr> To: "A list for developers using the SDL library. \(includes SDL-announce\)" <sdl@libsdl.org> Subject: Re: [SDL] alpha blending bug - possible fix? > [...quote snipped by ryan for bugzilla posting...] > could this change be introduced? thanks a lot, Is changing (even slightly) the alpha behaviour for one among many alpha blitting functions a good idea ? Stephane _______________________________________________ SDL mailing list SDL@libsdl.org http://www.libsdl.org/mailman/listinfo/sdl Date: Sat, 21 Jan 2006 13:58:38 +0100 (MET) From: Mattias Karlsson <betasoft@acc.umu.se> To: "A list for developers using the SDL library. \(includes SDL-announce\)" <sdl@libsdl.org> Subject: Re: [SDL] alpha blending bug - possible fix? > [...quotation clipped for bugzilla by ryan...Sam was asking...] > > Did you profile your code as opposed to simply dividing by 255? I have done some quick-and-dirty testing on both UltraSparc3 and Xeon by blending two arrays. Some preliminary results: * gcc 3.4 replaces /255 with a multiply+shift on both processors. * The suggested replacement above is on average faster than division, but slower than the current shifts. * On UltraSparc3 there is hardly any difference in speed between the suggested replacement and using division, unless the arrays grow realy, realy large. * The difference in time between cache-hit and cache-miss is larger than the difference between shift and division; division + cache-hit is faster than shift + cache-miss. Note that this is not tested using SDL blitter code, but a seperate implementation using the three different blending algorithms. More tests are in progress... _______________________________________________ SDL mailing list SDL@libsdl.org http://www.libsdl.org/mailman/listinfo/sdl My continued testing have revealed two bugs in the suggested algorithm: For src=255, dest=255 and alpha >= 128 it overflows, giving (modulo 255) the value 0 instead of the expected 255. For src=0, dest=1 and 0 < alpha < 127 it underflows, giving (modulo 255) the value 255 instead of the expected 0. Also, "slightly worse" means that it is off-by-one half the time, while shifting is off-by-one only in 1 out of 6 on average. Created attachment 27 [details]
Benchmark program for 3 diffrent alpha algorithms
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL. --ryan. Thanks for the analysis, Mattias. The fix proposed won't be implemented, although I'm open to suggestion for other fixes that are correct and still speedy. :) |