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

Q: Slang for shaders #1162

Open
edubart opened this issue Dec 5, 2024 · 3 comments
Open

Q: Slang for shaders #1162

edubart opened this issue Dec 5, 2024 · 3 comments

Comments

@edubart
Copy link
Contributor

edubart commented Dec 5, 2024

Since announcement from Khronos about hosting the slang shading language last month, I wondered what if Sokol supported it to create shaders, it's playground seems cool. Seems like it could fit as a more modern, more capable, and highly cross platform shading language since it can target all backends Sokol cares, maybe it would simplify sokol-shdc.

What are your opinions on the subject?

@floooh
Copy link
Owner

floooh commented Dec 5, 2024

I'm thinking about it but there are a couple of issues to solve:

  • how to add the (more or less) engine-specific binding annotations, all Slang code I've seen so far seems to depend on not defining explicit binding information, but let Slang assign the bindings info and then obtain that via reflection
  • how to integrate with the sokol-gfx specific code generation - it would be ideal to use Slang as library and build our own cmdline tool around it
  • ...but for that it really depends on how big the resulting executable is, and things like whether Slang can be completely statically linked or requires DLLs (the .gitmodules of the Slang project looks kinda scary: https://github.com/shader-slang/slang/blob/master/.gitmodules)

PS: one intermediate step I might try is to accept SPIRV as input to sokol-shdc

@edubart
Copy link
Contributor Author

edubart commented Dec 5, 2024

on how big the resulting executable is

Seems like they offer prebuilt binaries for most platforms at releases page, but they have up to 276MB in size, so it's too big.

Slang can be completely statically linked

From inspecting their binary package, it looks like with some work it could be statically linked, but it could result in a 700MB binary file, ouch.

it would be ideal to use Slang as library

Since its binaries are very big, maybe expect the user to have a slang compiler available in the system, and invoke slangc command, instead of using it as a library?

Anyway, I have seen Sokol creating its own shader generator to target different backends, SDL3 seems to be on the same path with its own shader compiler. I just thought slang looks like a promising solution for this common problem that cross platform graphics libraries have.

@floooh
Copy link
Owner

floooh commented Dec 5, 2024

to have a slang compiler available in the system, and invoke slangc command

Yeah that could be the only realistic option, create a small wrapper cmdline tool which calls the slang executable and then uses its output for the sokol-gfx code generation...

Ideally I'd like to give sokol-gfx users multiple options for authoring their shaders (another one could be WGSL as shader authoring language). Just need to find a way which doesn't add too much maintenance overhead.

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

2 participants