We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2639 - SDL_BLENDMODE_BLEND not working properly for software renderer
Summary: SDL_BLENDMODE_BLEND not working properly for software renderer
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-12 19:40 UTC by Damian Kaczmarek
Modified: 2014-07-12 23:22 UTC (History)
1 user (show)

See Also:


Attachments
Source coding showing the problem (2.79 KB, text/x-c++src)
2014-07-12 19:40 UTC, Damian Kaczmarek
Details
software blending patch (712 bytes, patch)
2014-07-12 20:57 UTC, Melker Narikka
Details | Diff
software blending patch - non-eaten version (660 bytes, patch)
2014-07-12 21:04 UTC, Melker Narikka
Details | Diff
software blending patch - v2 (679 bytes, patch)
2014-07-12 22:01 UTC, Melker Narikka
Details | Diff
Updated test code (3.10 KB, text/x-c++src)
2014-07-12 22:29 UTC, Damian Kaczmarek
Details
software blending patch - v3 (335 bytes, patch)
2014-07-12 23:01 UTC, Melker Narikka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Damian Kaczmarek 2014-07-12 19:40:34 UTC
Created attachment 1742 [details]
Source coding showing the problem

I attach a program showing the problem. 

g++ sdl2bug.cpp -lSDL2 && ./a.out

Window on the right shows software renderer which is wrong
Window on the left shows hardware renderer which is right

I would also appreciate suggestions if there are possible workarounds
Comment 1 Damian Kaczmarek 2014-07-12 19:46:05 UTC
I should also add that setting render mode does not fail.
Comment 2 Sam Lantinga 2014-07-12 20:08:00 UTC
Great bug report, I'll look into it.

Thanks!
Comment 3 Melker Narikka 2014-07-12 20:57:22 UTC
Created attachment 1743 [details]
software blending patch

Does this patch help?
Comment 4 Melker Narikka 2014-07-12 21:04:39 UTC
Created attachment 1744 [details]
software blending patch - non-eaten version

Oops, bugzilla ate the patch headers :(
Comment 5 Damian Kaczmarek 2014-07-12 21:08:25 UTC
I applied the patch manually and it works! Thanks!
Comment 7 Melker Narikka 2014-07-12 22:01:42 UTC
Created attachment 1745 [details]
software blending patch - v2

Here's an updated patch. Does it make a difference?
Comment 8 Damian Kaczmarek 2014-07-12 22:29:55 UTC
Created attachment 1746 [details]
Updated test code

Added a semi-transparent green rectangle being blended, again this shows different results from software and hardware renderers
Comment 9 Damian Kaczmarek 2014-07-12 22:30:41 UTC
Otherwise your latest patch fixes the most obvious problems, we're getting there! Good work.
Comment 10 Melker Narikka 2014-07-12 23:01:06 UTC
Created attachment 1747 [details]
software blending patch - v3

Okay, let's try that again, shall we? This one only touches the alpha, and seems to act right with the updated test case.
Comment 11 Damian Kaczmarek 2014-07-12 23:10:07 UTC
Seems to work perfectly, thank you!
Comment 12 Sam Lantinga 2014-07-12 23:12:48 UTC
Does this work?
sa = DRAW_MUL(inva, sa) + a;
Comment 13 Melker Narikka 2014-07-12 23:14:14 UTC
(In reply to Sam Lantinga from comment #12)
> Does this work?
> sa = DRAW_MUL(inva, sa) + a;

v3 does just that :)
Comment 14 Sam Lantinga 2014-07-12 23:15:04 UTC
Yeah, I just wanted to see if ordering mattered, for consistency with the previous lines.
Comment 15 Damian Kaczmarek 2014-07-12 23:16:05 UTC
It works quite fine.
Comment 16 Sam Lantinga 2014-07-12 23:22:30 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/515be38f3f37