libsdl-org / SDL-1.2

Simple Directmedia Layer, 1.2 branch ... ***DEPRECATED***, please use https://github.com/libsdl-org/SDL for new projects!
https://libsdl.org
GNU Lesser General Public License v2.1
104 stars 85 forks source link

[PATCH] video: Backport the fast paths for 24/32-bit blitting #830

Closed SDLBugzilla closed 3 years ago

SDLBugzilla commented 3 years ago

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 1.2 Reported for operating system, platform: All, All

Comments on the original bug report:

On 2020-10-24 15:00:43 +0000, Cameron Cawley wrote:

Created attachment 4484 video: Backport the fast paths for 24/32-bit blitting

This backports the optimized blitting code to SDL 1.2. This provides noticeable performance improvements in CSE2, however I haven't done extensive amounts of testing for all of the new paths.

On 2020-10-24 15:25:02 +0000, Ozkan Sezer wrote:

(In reply to Cameron Cawley from comment # 0)

however I haven't done extensive amounts of testing for all of the new paths.

If you can do some more testing, I'd wait, say, a week or something.

On 2020-10-25 15:50:43 +0000, Sylvain wrote:

Hey, if you look at the bug 4503 There is a testcase, an image, and a script to compare.

the testcase load a multi-color image, convert to all format and print some CRC for each step. if you run it before the patch to have a reference and after: the compare script will tell if it breaks anything and the speed improvements.

(I think there was a few fix to add like ... https://hg.libsdl.org/SDL/rev/233b2a61cad1 https://hg.libsdl.org/SDL/rev/dff36de37426 )

maybe the format of SDL 1.2 are different and testcase should be adapted

On 2020-11-12 04:21:52 +0000, Ozkan Sezer wrote:

Has the patch received more testing?

On 2020-11-13 10:00:22 +0000, Sylvain wrote:

Created attachment 4515 test-case for SDL-1.2

Hello, I tried the test-case from the previous ticket, and there are much more differences that what I remembered of SDL-1.2.

So I ported it to SDL-1.2. At least, it compiles and runs.

gcc fast_bench.c -Ibuild/include/SDL/ -Lbuild/lib -lSDL -lz -lcrypto

There are TODOs open:

  • Need to use IMG_Load (instead of loadBMP) for a .png file, so that the image has an alpha channel for testing.

  • Is there blending in SDL-1.2 ?

  • Currently it has lots of pixel_format: It takes all SDL2 pixel formats and copies them as SDL1 pixel formats. Not sure if that are all relevant. ( BPP1 and BPP4 commented out )

It needs to be tested with the SDL-1.2 + patch

On 2020-11-13 10:04:59 +0000, Sylvain wrote:

Created attachment 4516 compare script

The compare script hasn't changed much. I just updated to python3 (if needed:

  • keys = db2.keys()
  • keys = list(db2.keys()) #python3 )

Usage:

./testcase.out test.png > ref1.txt apply the patch ./testcase.out test.png > ref2.txt

python compare_blitlog.py ref1.txt ref2.txt

The image must be relevant. big enough to mesure the image processing time. Multi color + alpha so that we have all corner cases. various size odd/even, pitch padding.

On 2020-11-13 10:32:57 +0000, Sylvain wrote:

After fixing a crash: https://hg.libsdl.org/SDL/rev/0bbdbc7b3ff2

I've just tested the patch, and all pixel format ARGB2101010 are failing. not sure if this is supported, but at there are not "unsupported()" neither ?

Otherwise, there are improvements as expected: like BGRX8888 -> RGB24 with goes from 15 ms to 3 ms. and many others.

On 2020-11-13 16:42:33 +0000, Sylvain wrote:

Created attachment 4517 test-case for SDL-1.2

Update the test-case to remove ARGB2101010 and use IMG_Load from SDL_image

On 2020-11-13 16:43:22 +0000, Sylvain wrote:

Created attachment 4518 compare script

Update the script to print the "faster/slower" indication

On 2020-11-13 16:46:23 +0000, Sylvain wrote:

Created attachment 4519 results file

This my result file if you want to look at. It shows where there are blit improvements.

(NB: there are a few irrelevant suspicious/slower conversion because blits at two fast in those cases.)

On 2020-11-14 08:05:52 +0000, Sylvain wrote:

Created attachment 4521 test-case for SDL-1.2

Update the test-case to re-add the SDL_GetPerformanceCounter + some padding/memcheck.

On 2020-11-14 08:08:24 +0000, Sylvain wrote:

Created attachment 4522 results file

This the results file which show the the speed improvements on 50 conversions. using the image "IMG_2476_ColorKey_very_small.png" from bug 4503

On 2020-11-14 08:13:06 +0000, Sylvain wrote:

The results file looks ok to me, So I have committed the patch https://hg.libsdl.org/SDL/rev/e901fc96cf25

On 2020-11-14 08:25:12 +0000, Ozkan Sezer wrote:

Sylvain: Thanks for marvelous work testing this! And thanks Cameron Cawley for the backport patch!

Closing this as fixed.

On 2020-11-14 08:26:44 +0000, Ozkan Sezer wrote:

Closed as fixed.

On 2020-11-14 22:47:43 +0000, Cameron Cawley wrote:

Thanks a lot for sorting this out!