Trying to understand the unsignedness in ALPHA_BLEND_RGBA

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Trying to understand the unsignedness in ALPHA_BLEND_RGBA

capehill
After debugging testautomation_surface, I have concluded that SW blending doesn't work at least for me (big endian AmigaOS platform).

For example, if sR is 0 and dR is 255, we will get -255*sA casted to an unsigned value. Basically results are quite large numbers instead of the expected 0-255 range. Am I missing something here?

Reference: https://hg.libsdl.org/SDL/file/d11daa346140/src/video/SDL_blit.h#l455

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to understand the unsignedness in ALPHA_BLEND_RGBA

Sam Lantinga-4
I think that was just trying to promote Uint8 to a larger type. Does it work if you replace (unsigned) with (int)?

On Tue, Jan 3, 2017 at 12:44 PM, capehill <[hidden email]> wrote:
After debugging testautomation_surface, I have concluded that SW blending doesn't work at least for me (big endian AmigaOS platform).

For example, if sR is 0 and dR is 255, we will get -255*sA casted to an unsigned value. Basically results are quite large numbers instead of the expected 0-255 range. Am I missing something here?

Reference: https://hg.libsdl.org/SDL/file/d11daa346140/src/video/SDL_blit.h#l455

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to understand the unsignedness in ALPHA_BLEND_RGBA

capehill
In reply to this post by capehill
Yes, replacing unsigned with int makes "testBlit" case work on my platform.








Sam Lantinga wrote:
I think that was just trying to promote Uint8 to a larger type. Does it work if you replace (unsigned) with (int)?

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to understand the unsignedness in ALPHA_BLEND_RGBA

Sam Lantinga-4

On Wed, Jan 4, 2017 at 11:39 AM, capehill <[hidden email]> wrote:
Yes, replacing unsigned with int makes "testBlit" case work on my platform.




Sam Lantinga wrote:

I think that was just trying to promote Uint8 to a larger type. Does it work if you replace (unsigned) with (int)?


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to understand the unsignedness in ALPHA_BLEND_RGBA

capehill
In reply to this post by capehill
Unfortunately it doesn't work for me. You probably have to cast sA to int, at least that helps here. Perhaps compiler promotes result to unsigned because sA's type is unsigned? (SDL_blit_A.c)








Sam Lantinga wrote:
Okay, can you try this?https://hg.libsdl.org/SDL/rev/6285a56f6729

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to understand the unsignedness in ALPHA_BLEND_RGBA

Sam Lantinga-4
Can you provide a patch on the bug?

On Fri, Jan 6, 2017 at 11:26 AM, capehill <[hidden email]> wrote:
Unfortunately it doesn't work for me. You probably have to cast sA to int, at least that helps here. Perhaps compiler promotes result to unsigned because sA's type is unsigned? (SDL_blit_A.c)




Sam Lantinga wrote:

Okay, can you try this?https://hg.libsdl.org/SDL/rev/6285a56f6729


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to understand the unsignedness in ALPHA_BLEND_RGBA

capehill
In reply to this post by capehill
Following patch worked for me: https://sourceforge.net/p/sdl2-amigaos4/code/157/








Sam Lantinga wrote:
Can you provide a patch on the bug?

On Fri, Jan 6, 2017 at 11:26 AM, capehill <> wrote:







Quote:
Unfortunately it doesn't work for me. You probably have to cast sA to int, at least that helps here. Perhaps compiler promotes result to unsigned because sA's type is unsigned? (SDL_blit_A.c)




Sam Lantinga wrote:

Okay, can you try this?https://hg.libsdl.org/SDL/rev/6285a56f6729





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to understand the unsignedness in ALPHA_BLEND_RGBA

Sam Lantinga-4
Okay, I think I got it.

Thanks!

On Sat, Jan 7, 2017 at 7:16 AM, capehill <[hidden email]> wrote:
Following patch worked for me: https://sourceforge.net/p/sdl2-amigaos4/code/157/




Sam Lantinga wrote:

Can you provide a patch on the bug?

On Fri, Jan 6, 2017 at 11:26 AM, capehill <> wrote:



Quote:

Unfortunately it doesn't work for me. You probably have to cast sA to int, at least that helps here. Perhaps compiler promotes result to unsigned because sA's type is unsigned? (SDL_blit_A.c)




Sam Lantinga wrote:

Okay, can you try this?https://hg.libsdl.org/SDL/rev/6285a56f6729





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Loading...