Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Premade GPU shaders? #11398

Closed
slouken opened this issue Nov 3, 2024 · 6 comments
Closed

Premade GPU shaders? #11398

slouken opened this issue Nov 3, 2024 · 6 comments
Assignees
Milestone

Comments

@slouken
Copy link
Collaborator

slouken commented Nov 3, 2024

Does it make sense to have some premade shaders that people playing around with the GPU API can use, without adding the complexity of a shader pipeline? Maybe a simple vertex shader and solid color + alpha blending fragment shaders? The vertex shader might be used indefinitely for certain projects, and the solid and blending shaders will get people a long way in tutorials or just playing around with the API.

@slouken slouken added this to the 3.2.0 milestone Nov 3, 2024
@flibitijibibo
Copy link
Collaborator

We do actually have an equivalent of shadertoy but it's currently in C#, we were planning to port it but mainly as the example for shadercross.

@slouken
Copy link
Collaborator Author

slouken commented Nov 3, 2024

I'm thinking about just bare bones shaders that come with SDL that allow someone to stand up some GPU code and try it out without having to have their own shader workflow out of the box.

I'm looking at what's involved for @captain0xff's GPU text engine example, and the bulk of the commit is shaders:
libsdl-org/SDL_ttf#412

@flibitijibibo
Copy link
Collaborator

Maybe something like BasicEffect, where the idea is to implement the equivalent of the old fixed function toggles?

https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/Effect/StockEffects/HLSL/BasicEffect.fx
https://github.com/FNA-XNA/FNA/blob/master/src/Graphics/Effect/StockEffects/BasicEffect.cs

@JBetz
Copy link

JBetz commented Nov 10, 2024

How about exposing the shaders used by the GPU backend of SDL's renderer? I imagine that a lot of people will want to reimplement basic functionality of SDL's renderer to get started, then extend as needed.

@flibitijibibo
Copy link
Collaborator

How about exposing the shaders used by the GPU backend of SDL's renderer? I imagine that a lot of people will want to reimplement basic functionality of SDL's renderer to get started, then extend as needed.

Probably not since these are likely to change over time - the first big change that comes to mind would be moving sprite buffer generation to a compute shader, which would definitely break the existing setup. A fixed-function helper at least has exactly one way to do it, even if there are a handful of permutations we'd have to put up with.

@thatcosmonaut
Copy link
Collaborator

I'm pretty strongly against this, it's just a false simplification. Clients who want to use the programming paradigm that revolves almost entirely around shaders should just learn how to use shaders. There's not really any way to sugarcoat it. We'll only confuse people by providing "default" paths which are only defaults if the render pipeline makes the exact assumptions that we bake into the shaders. If someone wants to provide a library that makes basic stuff easier they are more than welcome to do that and take on the burden of the lack of flexibility that comes with making assumptions.

As far as the process of compiling shaders goes, the shadercross tooling I'm currently developing should eliminate a lot of the current friction points.

@slouken slouken closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants