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 4523

Summary: [PATCH] increase performance SDL_CreateTextureFromSurface for s/w render
Product: SDL Reporter: Dmitry Gapkalov <gapkalov>
Component: renderAssignee: Ryan C. Gordon <icculus>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: icculus, muesli4
Version: 2.0.9Keywords: target-2.0.16
Hardware: All   
OS: All   
Attachments: patch

Description Dmitry Gapkalov 2019-02-27 18:01:04 UTC
Created attachment 3659 [details]
patch

remove excess allocations and memory copying while SDL_CreateTextureFromSurface for s/w render in situation while texture and surface format is equal.

case:
1) load gfx file to surface
2) create texture from surface
3) free surface
4) use texture for blit to screen

basic idea in sharing pixel data between surface and texture in situation  while format of surface and texture are equal.
Comment 1 Ryan C. Gordon 2019-07-30 17:49:39 UTC
(Sorry if you get several emails like this, we're marking a bunch of bugs.)

We're hoping to ship SDL 2.0.11 on a much shorter timeframe than we have historically done releases, so I'm starting to tag bugs we hope to have closed in this release cycle.

Note that this tag means we just intend to scrutinize this bug for the 2.0.11 release: we may fix it, reject it, or even push it back to a later release for now, but this helps give us both a goal and a wishlist for the next release.

If this bug has been quiet for a few months and you have new information (such as, "this is definitely still broken" or "this got fixed at some point"), please feel free to retest and/or add more notes to the bug.

--ryan.
Comment 2 Moritz Bruder 2019-08-19 17:38:41 UTC
It would probably make more sense to provide this a function for the software back-end that falls back to something like:
SDL_Texture texture = SDL_CreateTexture(renderer, surface);
SDL_FreeSurface(surface);
return texture;

On the software back-end it moves the pixel data and the other stuff to the texture and overwrites and frees the surface. Basically, the important stuff gets moved without expensive copies. I wouldn't share any of that without explicitly stating it. Otherwise, that might lead to annoying behavior and unexpected side effects.
Comment 3 Ryan C. Gordon 2019-09-20 20:47:39 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 4 Ryan C. Gordon 2019-09-20 20:48:39 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 5 Ryan C. Gordon 2019-10-27 05:06:56 UTC
I agree with Moritz, we should probably add a function named something like SDL_ConvertSurfaceToTexture() where it explicitly destroys the surface, possibly stealing its internal data for the new texture without copying it.

As such, I'm removing the target-2.0.12 keyword from this bug, so we can explore this in the (near?) future.

--ryan.
Comment 6 Sam Lantinga 2019-11-01 17:40:06 UTC
Agreed.