The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
GLSL shader fun!
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.

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

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite2
OpenGL shaders: DISABLED
3051.84 frames per second

./testsprite2
OpenGL shaders: ENABLED
3428.22 frames per second

Woot! Smile

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

See ya!
--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
GLSL shader fun!
Paulo Pinto
Guest

Great work Sam! Congratulations!

What do you think about adding OpenCL support as well?

In environments where OpenCL hardware is available, SDL can get better optimizations than
using processor vector extensions, most likely.

--
Paulo


On Wed, Feb 9, 2011 at 7:39 AM, Sam Lantinga wrote:
Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.

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

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite2
OpenGL shaders: DISABLED
3051.84 frames per second

./testsprite2
OpenGL shaders: ENABLED
3428.22 frames per second

Woot! Smile

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

See ya!
--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
GLSL shader fun!
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
I'm not planning on doing it myself, but I'm happy to accept patches. Smile

On Tue, Feb 8, 2011 at 11:53 PM, Paulo Pinto wrote:
Quote:
Great work Sam! Congratulations!

What do you think about adding OpenCL support as well?

In environments where OpenCL hardware is available, SDL can get better optimizations than
using processor vector extensions, most likely.

--
Paulo



On Wed, Feb 9, 2011 at 7:39 AM, Sam Lantinga wrote:


Quote:

I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.

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

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite2
OpenGL shaders: DISABLED
3051.84 frames per second

./testsprite2
OpenGL shaders: ENABLED
3428.22 frames per second

Woot! Smile

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

See ya!



--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks
GLSL shader fun!
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
I got a modest speed up with testsprite (using the 1.2 API) as well:

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite
1329.16 frames per second

SDL_RENDER_OPENGL_SHADERS=1 ./testsprite
1354.20 frames per second


On Tue, Feb 8, 2011 at 10:39 PM, Sam Lantinga wrote:
Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.

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

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite2
OpenGL shaders: DISABLED
3051.84 frames per second

./testsprite2
OpenGL shaders: ENABLED
3428.22 frames per second

Woot! Smile

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

See ya!
--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks



--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks
GLSL shader fun!
Paulo Pinto
Guest

I might try to have a look at it.

It is always a good excuse to learn OpenCL Smile

On Wed, Feb 9, 2011 at 10:42 AM, Sam Lantinga wrote:
Quote:
I'm not planning on doing it myself, but I'm happy to accept patches. Smile


On Tue, Feb 8, 2011 at 11:53 PM, Paulo Pinto wrote:
Quote:
Great work Sam! Congratulations!

What do you think about adding OpenCL support as well?

In environments where OpenCL hardware is available, SDL can get better optimizations than
using processor vector extensions, most likely.

--
Paulo



On Wed, Feb 9, 2011 at 7:39 AM, Sam Lantinga wrote:


Quote:

I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.

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

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite2
OpenGL shaders: DISABLED
3051.84 frames per second

./testsprite2
OpenGL shaders: ENABLED
3428.22 frames per second

Woot! Smile

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

See ya!



--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org






--

    -Sam Lantinga, Founder and CEO, Galaxy Gameworks




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

GLSL shader fun!
Mason Wheeler
Guest

Quote:
----- Original Message ----

Quote:
From: Sam Lantinga
Subject: [SDL] GLSL shader fun!


Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.

Hmm? Doesn't SDL already use shaders internally for GL rendering? I see
plenty of references to them in sdl_renderer_gl.


Quote:
I also noticed there's not a single example of using shaders with SDL

Quote:
that has full source code, so I added one:
http://hg.libsdl.org/SDL/file/default/test/testshader.c

Interesting example, but once you do that how do you get an SDL_Texture out
of it?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
GLSL shader fun!
Andreas Schiffler
Guest

Cool!

Shouldn't/couldn't this code be in some common (SDL1.3) helper function?

/* Check for shader support */

--Andreas


On 2/8/11 10:39 PM, Sam Lantinga wrote:
Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.

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

SDL_RENDER_OPENGL_SHADERS=0 ./testsprite2
OpenGL shaders: DISABLED
3051.84 frames per second

./testsprite2
OpenGL shaders: ENABLED
3428.22 frames per second

Woot! Smile

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

See ya!

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
GLSL shader fun!
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
SDL used to use ARB shaders, and I've pulled them out and updated them with a more powerful GLSL framework.

SDL's internal shader support is just that - it's not intended to be used outside of the API.  If you're using shaders directly, you shouldn't be using the rendering API.

On Wed, Feb 9, 2011 at 6:03 AM, Mason Wheeler wrote:
Quote:
>----- Original Message ----

Quote:
From: Sam Lantinga
Subject: [SDL] GLSL shader fun!


Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.


Hmm?  Doesn't SDL already use shaders internally for GL rendering?  I see
plenty of references to them in sdl_renderer_gl.


Quote:
I also noticed there's not a single example of using shaders with SDL

Quote:
that has full source code, so I added one:
http://hg.libsdl.org/SDL/file/default/test/testshader.c


Interesting example, but once you do that how do you get an SDL_Texture out
of it?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks
GLSL shader fun!
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Seriously, if you keep trying to use the rendering API and mixing it with your own OpenGL, you're going to be frustrated.  Just don't do it. Smile

On Wed, Feb 9, 2011 at 10:04 AM, Sam Lantinga wrote:
Quote:
SDL used to use ARB shaders, and I've pulled them out and updated them with a more powerful GLSL framework.

SDL's internal shader support is just that - it's not intended to be used outside of the API.  If you're using shaders directly, you shouldn't be using the rendering API.


On Wed, Feb 9, 2011 at 6:03 AM, Mason Wheeler wrote:
Quote:
>----- Original Message ----

Quote:
From: Sam Lantinga
Subject: [SDL] GLSL shader fun!


Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.


Hmm?  Doesn't SDL already use shaders internally for GL rendering?  I see
plenty of references to them in sdl_renderer_gl.


Quote:
I also noticed there's not a single example of using shaders with SDL

Quote:
that has full source code, so I added one:
http://hg.libsdl.org/SDL/file/default/test/testshader.c


Interesting example, but once you do that how do you get an SDL_Texture out
of it?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org








--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks






--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks
GLSL shader fun!
Mason Wheeler
Guest

Same thing as the rotation thing I was talking about earlier. The vast majority of my textures won't require any special shading, but there are some specific cases where I will require certain effects, particularly HSL transforms, that can't be done without the use of a shader. I'd really prefer not to have to throw out a very good, simple solution for the 99% case (the SDL rendering API) just to be able to support the 1% case.


From: Sam Lantinga
Subject: Re: [SDL] GLSL shader fun!

Seriously, if you keep trying to use the rendering API and mixing it with your own OpenGL, you're going to be frustrated. Just don't do it. Smile

On Wed, Feb 9, 2011 at 10:04 AM, Sam Lantinga wrote:
Quote:
SDL used to use ARB shaders, and I've pulled them out and updated them with a more powerful GLSL framework.

SDL's internal shader support is just that - it's not intended to be used outside of the API. If you're using shaders directly, you shouldn't be using the rendering API.


On Wed, Feb 9, 2011 at 6:03 AM, Mason Wheeler wrote:
Quote:
>----- Original Message ----

Quote:
From: Sam Lantinga
Subject: [SDL] GLSL shader fun!


Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.


Hmm? Doesn't SDL already use shaders internally for GL rendering? I see
plenty of references to them in sdl_renderer_gl.


Quote:
I also noticed there's not a single example of using shaders with SDL

Quote:
that has full source code, so I added one:
http://hg.libsdl.org/SDL/file/default/test/testshader.c


Interesting example, but once you do that how do you get an SDL_Texture out
of it?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org








--
-Sam Lantinga, Founder and CEO, Galaxy Gameworks






--
-Sam Lantinga, Founder and CEO, Galaxy Gameworks
GLSL shader fun!
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Okay, fair enough. Smile

On Wed, Feb 9, 2011 at 11:08 AM, Mason Wheeler wrote:
Quote:
Same thing as the rotation thing I was talking about earlier.  The vast majority of my textures won't require any special shading, but there are some specific cases where I will require certain effects, particularly HSL transforms, that can't be done without the use of a shader.  I'd really prefer not to have to throw out a very good, simple solution for the 99% case (the SDL rendering API) just to be able to support the 1% case.


From: Sam Lantinga

Subject: Re: [SDL] GLSL shader fun!


Seriously, if you keep trying to use the rendering API and mixing it with your own OpenGL, you're going to be frustrated.  Just don't do it. Smile

On Wed, Feb 9, 2011 at 10:04 AM, Sam Lantinga wrote:
Quote:
SDL used to use ARB shaders, and I've pulled them out and updated them with a more powerful GLSL framework.

SDL's internal shader support is just that - it's not intended to be used outside of the API.  If you're using shaders directly, you shouldn't be using the rendering API.


On Wed, Feb 9, 2011 at 6:03 AM, Mason Wheeler wrote:
Quote:
>----- Original Message ----

Quote:
From: Sam Lantinga
Subject: [SDL] GLSL shader fun!


Quote:
I just added GLSL shaders to the OpenGL rendering implementation!
You can disable them by setting the SDL_HINT_RENDER_OPENGL_SHADERS
hint in your application, or the SDL_RENDER_OPENGL_SHADERS environment
variable.


Hmm?  Doesn't SDL already use shaders internally for GL rendering?  I see
plenty of references to them in sdl_renderer_gl.


Quote:
I also noticed there's not a single example of using shaders with SDL

Quote:
that has full source code, so I added one:
http://hg.libsdl.org/SDL/file/default/test/testshader.c


Interesting example, but once you do that how do you get an SDL_Texture out
of it?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org








--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks






--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks








_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
    -Sam Lantinga, Founder and CEO, Galaxy Gameworks