Optimizing alpha blending of two 32bit images : Graphics
This is a discussion on Optimizing alpha blending of two 32bit images within the Graphics forums in Theory and Concepts category; On Apr 9, 12:38 am, Nils <n.pipenbri...@cubic.org> wrote: > Thank you all for the insights on this topic and division. I'm still lost at MMX/SIMD, they seem helpful in processing several operations simultaneously, such as processing the 3 color or even more at the same time. But I didn't know how yet. I'll give it some more time. In the mean time, I'm happy with the performance gain from premultiplication and division optimization. Thanks, Bill Holt...
![]() |
| | LinkBack | Thread Tools |
|
#11
| |||
| |||
| > Thank you all for the insights on this topic and division. I'm still lost at MMX/SIMD, they seem helpful in processing several operations simultaneously, such as processing the 3 color or even more at the same time. But I didn't know how yet. I'll give it some more time. In the mean time, I'm happy with the performance gain from premultiplication and division optimization. Thanks, Bill Holt |
|
#12
| |||
| |||
| Nils a écrit : > For division by 255 there is the good old Jim Blinn-Trick which encodes > the first continued fraction and adds some rounding: > > > ui32 iyteblend (ui8 a, ui8 b) > // returns a*b/255. Exact in all corner-cases but > // some difference in the inbetweens. > { > i32 t = a * b; > return ((t>>8) + t + 1)>>8; > } > > > For ARGB32 blending you might want to check out this weblink: > > http://www.stereopsis.com/doubleblend.html > > Nils Hi ! // Returns (a * b) / 255. Exact value =) int blend(byte a, byte b) { return ((a * b) * 0x8081) >> 23; } |
|
#13
| |||
| |||
| Agnain wrote: > Nils a écrit : >> For division by 255 there is the good old Jim Blinn-Trick which >> encodes the first continued fraction and adds some rounding: >> >> >> ui32 iyteblend (ui8 a, ui8 b) >> // returns a*b/255. Exact in all corner-cases but >> // some difference in the inbetweens. >> { >> i32 t = a * b; >> return ((t>>8) + t + 1)>>8; >> } >> >> >> For ARGB32 blending you might want to check out this weblink: >> >> http://www.stereopsis.com/doubleblend.html >> >> Nils > > Hi ! > > // Returns (a * b) / 255. Exact value =) > int blend(byte a, byte b) > { > return ((a * b) * 0x8081) >> 23; > } #define MULT_DIV_255(_res, _a, _b) \ (_res) = (_a) * (_b) + 0x80; \ (_res) = ((((_res) >> 8) + (_res)) >> 8); Exact value, and it can be performed in 16 bits precision (if a and b are 8 bits numbers) ![]() |




