vk-shader-macros
A procedural macro for compiling GLSL into SPIR-V constants.
Unlike the standard include_bytes
macro, paths are currently
resolved relative to crate root. This is due to a temporary limitation
in the procedural macro API.
Examples
const VERT: & = include_glsl!;
const FRAG: & = include_glsl!;
Debug info is generated by default; pass strip
to the macro to omit
it, or build the create with the strip
feature enabled.
Why [u32]
?
SPIR-V is a stream of 32-bit words, not bytes, and this is reflected
in APIs that consume it. In particular, passing a [u8]
of SPIR-V
that is not 4-byte-aligned to Vulkan is undefined behavior. Storing
SPIR-V in its native format guarantees that this will never occur,
without requiring copying or unsafe code.
Dependencies
This crate currently depends on the foreign shaderc library. By default, it will be compiled automatically, requiring git, cmake, python 3, and a supported C++ compiler to be available in the build environment. A pre-compiled shaderc can be used by disabling the crate's default features, but care must be taken to use a version that is binary-compatible with the one checked out by the shaderc crate.