SDL_Texture shader proposition

Hi, one of the things that’s bothered me about SDL is the lack of shader support (and further access to the GPU), something that would work with SDL_Texture and SDL_Renderer to maintain its cross platform ease.

From what I understand the lack of a shader implementation has been due to people asking for a cross platform solution that works for both opengl, opengl es, and directx - which thus requires an shader specification that abstracts glsl, hlsl, including the necessary parsers for each.

I personally also feel that this feels beyond the scope of SDL. However, I do think it would be possible to:

  1. Ask SDL for the current graphic implementation (opengl, directx, etc.)
  2. Access an SDL_ApplyShader(char* shader_program, Enum shader_type)
    a. where the enum denotes glsl, hlsl, etc. (and will return an error if it is incompatible with the current graphic implementation)

I personally love the simple use that SDL_Texture and SDL_Renderer bring, and I feel this would be a minimalistic way to also open the road to simple shader use (without having to touch directx, opengl, etc. directly).

Thoughts? Shaders would be a great addition, and discussion to implementation would be great.

SDL_gpu supports shaders and its rendering API is similar to SDL’s built-in
one. You can determine the graphics API that you’re running on and what
version it is for shader selection, but there has been little reason to
actually implement a Direct3D renderer, so it’s just GLSL and GLSL ES.

Jonny D

Thanks for the reply, SDL_gpu was something our team looked into, and it really looked nice.

Sadly, we need to support Direct3D - in consideration that some player PCs still run on either Windows XP, or have graphic cards that have odd little bugs in opengl that cause unexpected crashes (especially integrated intel chips). There still seem to exist a large audience running PCs that don’t support anything other than DirectX9 predictably.

Our team mainly builds games targeting China, Japan, and Korea where this is still a widespread issue - if SDL_gpu could make Direct3D additions that would be great (and I’m rather sure this will be a reason for more teams to pick it up).

Still, I think a simple shader mechanism like this would be a great addition to SDL core.

Speaking of SDL_gpu though, I’m curious as to why it hasn’t been integrated into SDL core until now. The performance benefits for opengl and opengl es seem quite massive, and I would expect performance to be one of the higher priorities of SDL.