Speed/cost of SDL2 accelerated vs SDL1.2 software rendering?

I’ve been working on an SDL1.2 project for a few months now, but I’ve been playing around with SDL2 the last couple days and I really like it—however, I’m a little confused as to whether the rendering is supposed to be considerably faster, or at least less CPU intensive.

I haven’t done very rigorous benchmarking, but here’s what I’ve seen (both programs locked to 60FPS):
SDL1.2: ~6,000 blits per frame, with ~4-6% CPU usage, inside my actual project
SDL2.0: ~6,000 render calls per frame, ~3-5% CPU usage, inside a project that does nothing else (i.e. no game logic)

Also, in that SDL2 program I’ve noticed that my GPU usage is often 0%, with sections of ~5-10% usage every couple of seconds (compared to a constant 0% GPU load before running the program). As I increase the number of RenderCopy calls per frame, GPU usage stays about the same while CPU usage increases a little less than linearly; to be honest, I’m not entirely convinced the program is using the GPU for rendering at all.

So I guess my questions are:

  1. Do these rendering speeds seem typical?
  2. Should the CPU be such a tight bottleneck for SDL2 rendering?
  3. Are these GPU load patterns normal?

Your system rocks. Try comparing them without being locked to 60 FPS.

What OS, SDL rendering driver, and hardware drivers are you running?On Sat, Jun 1, 2013 at 9:28 PM, TylerJNA wrote:

**
I’ve been working on an SDL1.2 project for a few months now, but I’ve been
playing around with SDL2 the last couple days and I really like
it—however, I’m a little confused as to whether the rendering is supposed
to be considerably faster, or at least less CPU intensive.

I haven’t done very rigorous benchmarking, but here’s what I’ve seen (both
programs locked to 60FPS):
SDL1.2: ~6,000 blits per frame, with ~4-6% CPU usage, inside my actual
project
SDL2.0: ~6,000 render calls per frame, ~3-5% CPU usage, inside a project
that does nothing else (i.e. no game logic)

Also, in that SDL2 program I’ve noticed that my GPU usage is often 0%,
with sections of ~5-10% usage every couple of seconds (compared to a
constant 0% GPU load before running the program). As I increase the number
of RenderCopy calls per frame, GPU usage stays about the same while CPU
usage increases a little less than linearly; to be honest, I’m not entirely
convinced the program is using the GPU for rendering at all.

So I guess my questions are:

  1. Do these rendering speeds seem typical?
  2. Should the CPU be such a tight bottleneck for SDL2 rendering?
  3. Are these GPU load patterns normal?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

On, Sun Jun 02, 2013, TylerJNA wrote:

I’ve been working on an SDL1.2 project for a few months now, but I’ve been playing around with SDL2 the last couple days and I really like it—however, I’m a little confused as to whether the rendering is supposed to be considerably faster, or at least less CPU intensive.

I haven’t done very rigorous benchmarking, but here’s what I’ve seen (both programs locked to 60FPS):
SDL1.2: ~6,000 blits per frame, with ~4-6% CPU usage, inside my actual project
SDL2.0: ~6,000 render calls per frame, ~3-5% CPU usage, inside a project that does nothing else (i.e. no game logic)

Also, in that SDL2 program I’ve noticed that my GPU usage is often 0%, with sections of ~5-10% usage every couple of seconds (compared to a constant 0% GPU load before running the program). As I increase the number of RenderCopy calls per frame, GPU usage stays about the same while CPU usage increases a little less than linearly; to be honest, I’m not entirely convinced the program is using the GPU for rendering at all.

So I guess my questions are:

  1. Do these rendering speeds seem typical?

If you are using software-based rendering (SDL_Surface, pixel buffer
operations, etc.), yes, that is most likely the case, since most
functions for SDL_Surface objects do not use the GPU or driver-specific
features, but do most of the stuff on the CPU - the difference to SDL
1.2 is not that much.

  1. Should the CPU be such a tight bottleneck for SDL2 rendering?

If you do CPU-based rendering, it surely will be the bottleneck.

  1. Are these GPU load patterns normal?

That’s most likely - however, without seeing your project implementation
it’s hard to say and only a guess.

Cheers
Marcus
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130602/2364c2d6/attachment-0001.pgp

First of all, 2D operations in GPUs are so lightweight that you aren’t
going to notice it most of the time - at least not unless you start
slapping in ridiculously complex shaders (something SDL will never do
on its own).

Second, yeah, the GPU is used only with the renderers, not surface.
You mention RenderCopy though, so that most likely means you’re using
the GPU. May want to try rendering different textures in each call.
Also may want to do lots of them, because as I said, rendering a
quad is pretty much nothing for a GPU. Remember, a quad is just two
triangles, while GPUs are made to handle many models with thousands of
them :stuck_out_tongue:

Did anyone get around to the batched rendering optimizations?

If you’re rendering a large number of small sprites, you’re not going to
notice much of a difference because SDL has to make lots of Direct3D/OpenGL
API calls and small CPU->GPU transfers. You may get better results with
large sprites.

Jonny DOn Sun, Jun 2, 2013 at 3:40 PM, Sik the hedgehog <sik.the.hedgehog at gmail.com wrote:

First of all, 2D operations in GPUs are so lightweight that you aren’t
going to notice it most of the time - at least not unless you start
slapping in ridiculously complex shaders (something SDL will never do
on its own).

Second, yeah, the GPU is used only with the renderers, not surface.
You mention RenderCopy though, so that most likely means you’re using
the GPU. May want to try rendering different textures in each call.
Also may want to do lots of them, because as I said, rendering a
quad is pretty much nothing for a GPU. Remember, a quad is just two
triangles, while GPUs are made to handle many models with thousands of
them :stuck_out_tongue:


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org