GLSL Compiler Marco
Write GLSL Code directly in a marco!
- Compile GLSL to Spriv binary for vulkan
- Not inside a string with shit linting
- Compile-time evaluation to binary slice
- No nightly needed
- Errors with correct lines
- #include code from other marcos
Finally, it's possible to write GLSL directly in Rust.
let bin_shader_code: & = glsl!;
will evaluated to
let bin_shader_code: & = &;
Shader Types
Mark shader type with type = <shader type>
in marco.
Possible types
- Compute
- Vertex Fragment, Geometry, Mesh
- RayGeneration, AnyHit, ClosestHit, Miss
- Include
Proper Errors
glsl!;
will error with:
error: undeclared identifier
|
13 | imageStore(img, ivec2(pos), colo);
| ^^^
error: undeclared identifier
|
13 | imageStore(img, ivec2(pos), colo);
| ^^^^
error: no matching overloaded function found
|
13 | imageStore(img, ivec2(pos), colo);
| ^^^^^^^^^^
Just compiling a glsl file at compile time
let bin: & = glsl!;
Including Code from other glsl file
Example Glsl File Name: "shaders/included.glsl"
let bin: & = glsl!;
Including Code from other Macro
Example Rust File Name: "src/main.rs"