Skip to content

Avoid RLE for software render alpha subrect copies#15982

Merged
slouken merged 3 commits into
libsdl-org:mainfrom
meta-legend:fix-15958
Jul 17, 2026
Merged

Avoid RLE for software render alpha subrect copies#15982
slouken merged 3 commits into
libsdl-org:mainfrom
meta-legend:fix-15958

Conversation

@meta-legend

@meta-legend meta-legend commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
  • I confirm that I am the author of this code and release it to the SDL project under the Zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Description

Add a software-renderer copy preparation step that disables surface RLE when all of these are true:

  • the texture is static
  • the texture format has alpha
  • the source rectangle is smaller than, or offset within, the full texture

Whole texture alpha copies can still use RLE.

Existing Issue(s)

This resolves #15958

Benchmark

I compared unmodified SDL against this branch with a small benchmark. The benchmark creates an alpha texture atlas in memory, uses the software renderer, and renders 768 transparent 16x16 subrect copies per frame for 1000 frames.

Unmodified SDL:
frames=1000
copies_per_frame=768
seconds=1.805
fps=553.91

With my fix:
frames=1000
copies_per_frame=768
seconds=0.406
fps=2464.84

Comment thread src/render/software/SDL_render_sw.c Outdated
@meta-legend
meta-legend requested a review from slouken July 17, 2026 06:35
Comment thread src/render/software/SDL_render_sw.c Outdated
@meta-legend
meta-legend requested a review from slouken July 17, 2026 19:31
@slouken
slouken merged commit ac9ef17 into libsdl-org:main Jul 17, 2026
10 checks passed
@slouken

slouken commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks! I'm leaving this in 3.6 for now, in case there are performance regressions with other use cases.

@meta-legend
meta-legend deleted the fix-15958 branch July 17, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Software renderer performance regression for transparent subrect copies after enforced RLE (#14427)

2 participants