Skip to content

Add lang option to vulkano_shaders::shader! macro for source language selection#2791

Merged
marc0246 merged 2 commits into
vulkano-rs:masterfrom
nshyrei:master
May 2, 2026
Merged

Add lang option to vulkano_shaders::shader! macro for source language selection#2791
marc0246 merged 2 commits into
vulkano-rs:masterfrom
nshyrei:master

Conversation

@nshyrei
Copy link
Copy Markdown
Contributor

@nshyrei nshyrei commented Apr 30, 2026

Adds source_language field to MacroInput to support compiling shaders in multiple languages (e.g. HLSL, Slang), motivated by #2622. Changes adapted from #2568 as suggested by @marc0246.

Currently adds HLSL as the first supported language variant, which is passed to shaderc during shader compilation.

Closes #2568

- set source language for shaderc compiler
@CptPotato
Copy link
Copy Markdown
Contributor

Side note: In order to support bindless for HLSL we'd need an equivalent of vulkano.glsl. I think this can be tackled separately, though.

@nshyrei
Copy link
Copy Markdown
Contributor Author

nshyrei commented May 2, 2026

@CptPotato I can remove the call to shaderc with HLSL if it produces unsupported features.

@marc0246
Copy link
Copy Markdown
Contributor

marc0246 commented May 2, 2026

No no, it's fine. vulkano.hlsl should be a separate concern, not one for this PR.

@marc0246
Copy link
Copy Markdown
Contributor

marc0246 commented May 2, 2026

You need to run cargo +nightly fmt.

@nshyrei
Copy link
Copy Markdown
Contributor Author

nshyrei commented May 2, 2026

@marc0246 done.

@marc0246 marc0246 added this pull request to the merge queue May 2, 2026
@marc0246
Copy link
Copy Markdown
Contributor

marc0246 commented May 2, 2026

Thank you for the PR ❤️ Next, you can add the slang lang option. You could use libslang like we use libshaderc, but I think it's best to move away from this. We don't need to link against anything because this is a proc-macro... It doesn't end up in the binary. And a program invocation is much easier to work with and less set up for the user.

Merged via the queue into vulkano-rs:master with commit ab39b3e May 2, 2026
8 checks passed
@nshyrei
Copy link
Copy Markdown
Contributor Author

nshyrei commented May 3, 2026

@marc0246 You mean you want to call libshaderc and libslang as a subprocess in Rust directly instead of using a shaderc crate (and some equivalent for slang) ?

@marc0246
Copy link
Copy Markdown
Contributor

marc0246 commented May 3, 2026

I mean not using libshaderc or libslang. Because those are libraries that we need to link against, which is more set up for the user, and not necessary because it doesn't end up in the binary anyway. Instead, I would like us to use Command::new("glslc") / Command::new("slangc").

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

Successfully merging this pull request may close these issues.

3 participants