Tuesday, February 8, 2011

Fun with shaders!

I just added GLSL shaders to the SDL OpenGL rendering implementation.

On my hardware this ends up being about a 200-400 FPS increase in testsprite2:

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite2
4259.55 frames per second

SDL_RENDER_OPENGL_SHADERS=1 ./testsprite2
4552.88 frames per second

I also got a modest increase with testsprite, using the old SDL 1.2 API:

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite
1329.16 frames per second

SDL_RENDER_OPENGL_SHADERS=1 ./testsprite
1354.20 frames per second

Woot! :)

I also noticed there's not a single example of using shaders with SDL that has full source code, so I added one:
http://hg.libsdl.org/SDL/file/default/test/testshader.c

Enjoy! :)

2 comments:

  1. Great, but beware with FPS comparisons.
    If you convert in ms, it gives a 0.0151 ms gain for SDL1.3, and a 0.0139 ms gain for SDL1.2 (ie, a 1.22 ┬Ás delta ^^)

    Anyway, great work, I'm very happy to see the SDL evolving so fast, keep it on !

    ReplyDelete
  2. Yep, the FPS comparison is really just about knowing that there is a speed increase, not a real measure of significant work reduction.

    In a real application, you'll never notice the difference. :)

    ReplyDelete