Hardware pixel primitves vs writing a shader?

What advantage does a fragment shader have over a hardware pixel primitive in 2d? Lets say I wanted to normal map a texture. Couldn’t I just iterate over it with a pxel primive? Would a shader be faster? If so why? As far as I know, SDL alone doesn’t support shaders, so i’m wondering if I need to upgrade to OpenGL to do something like this.

A shader would be much faster than drawing a bunch of pixels. This is for
several reasons, but here are a couple of good ones: The pixel drawing
restarts for each pixel (possibly waiting for the pixel to be rendered
before starting the next) whereas a fragment shader runs many fragments in
parallel. Also, more data needs to be sent over to the GPU to tell it
where all the pixels are. The shader engine knows where all fragments are
based on the primitive that it is rendering.

There may be a way to use shaders with SDL, but you’ll absolutely have to
touch OpenGL calls to do it. You might try SDL_gpu, which has a full
shader interface abstracted from OpenGL.

Jonny DOn Thu, May 28, 2015 at 2:11 PM, shinn497 wrote:

What advantage does a fragment shader have over a hardware pixel
primitive in 2d? Lets say I wanted to normal map a texture. Couldn’t I just
iterate over it with a pxel primive? Would a shader be faster? If so why?
As far as I know, SDL alone doesn’t support shaders, so i’m wondering if I
need to upgrade to OpenGL to do something like this.


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