Message-ID: <1382692901.m2f.40186 at forums.libsdl.org>
Content-Type: text/plain; charset=“iso-8859-1”
Can I get some consensus here? Because it seems like there’s some debate
whether sprite-batching with texture atlases would have any performance
benefit at all with SDL, because (according to some but not others) it
wouldn’t be operating at a low enough level to bypass a lot of the state
changes.
Even if it doesn’t help, the only way that it can hurt is if you use
atlases that are too large. The solution to that is just to use
smaller atlases, so no big deal. Whether any of the overhead gets
bypassed will tend to depend on two things:
- Whether the render api gets optimized at some point in the future
(I don’t think this is on the agenda, but there has been a discussion
on how to do it: it is possible without API breakage),
- Whether the total size of your textures is too large for the memory
of the GPU.
Either of these is enough to make sprite-batching (and, for the most
part, texture atlases) a genuine optimization. Will you get the full
speed-up that Mason talks about? No, but Mason’s method isn’t actually
compatible with the SDL render API (it breaks some of the rules that
renderer implementations need to follow), and was never going to be
part of SDL (it’s less a 2d rendering technique, and more a 2.5d
technique).
Also, sprite batching and texture atlases can benefit you when using
OpenGL, so if you decide that the Renderer api isn’t powerful enough
afterwards, you’ll already have the code in the right basic structure
for what you’ll wind up moving to.
All in all, I would recommend sprite batching + texture atlases for
most uses. If you just make certain to support more than one texture
atlas, you should be covered for the range of actual problems that you
might meet.> Date: Fri, 25 Oct 2013 09:21:41 +0000
From: “mattbentley”
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Surface vs Texture - optimal usage
Date: Fri, 25 Oct 2013 05:31:59 -0700 (PDT)
From: Mason Wheeler
To: “sdl at lists.libsdl.org”
Subject: Re: [SDL] Surface vs Texture - optimal usage
Message-ID:
<1382704319.20830.YahooMailNeo at web122505.mail.ne1.yahoo.com>
Content-Type: text/plain; charset=“iso-8859-1”
Sprite batching with texture atlases in raw OpenGL would have a
performance benefit.? Doing it with SDL render calls would not, because SDL
doesn’t support sprite batching.
I tried to bring up the subject a few months ago, but implementing it
properly would have required adding a parameter to SDL_RenderCopy, and folks
said “no, we can’t do that; the ABI is frozen.”
As I best recall, we had to repeat it multiple times before you
actually paid attention (or maybe it was in multiple threads?).
Extensions aren’t a problem, but changes to existing APIs was already
officially barred by the time that you even made the proposal.
The biggest problem, though, was that your vision of how the API
should work (which was rather akin to Netscape’s Layer tag) was
incompatible with how the API was actually intended to work (each call
on top of the previous one). As Forest mentioned at the time (yes, I
looked it up), in a 2d graphics API the implication is that your
draw-order is sacred. I myself mentioned a way to adapt your idea to
the actual API by using dirty rect checking for the sake of flushing
when it was needed.
However, you couldn’t seem to accept any version other than the one
that you were suggesting (which was a non-starter). There was never
any opposition to faster rendering, only to your particular
implementation. If you want to implement Nathaniel’s
SDL_RenderCopyMulti() function (
http://forums.libsdl.org/viewtopic.php?p=36668#36668 ) then I don’t
think you’ll have trouble getting it into the code base, but your
particular solution was already unacceptable by that point, and you
would have realized it if you’d slowed down long enough to think about
it. “The ABI is frozen” is genuinely enough reason to keep anything
conflicting out, “3x faster than the current system” is not enough
reason for inclusion if it goes against ABI compatibility, which your
suggestion did.