Runtime layout validation. Slang provides a reflection API that reports struct layouts (size, field offsets, field types) after compilation. Goldy could query this at shader load time and compare against the Rust-side layout (derivable via std::mem::size_of, std::mem::offset_of!, etc.). A mismatch would produce a clear error at startup rather than silent corruption. This is the most practical near-term improvement.
Static reflection and compile-time checking. If Rust's type metadata (field names, types, offsets) could be compared against Slang's reflection data at compile time — perhaps via a build script that compiles the shader, extracts reflection, and asserts layout compatibility — the mismatch would become a build error. This is the ideal end state but requires tooling that doesn't exist yet.
The cross-language type coherence problem is fundamental to any multi-language GPU stack. Goldy's current approach (convention + testing) works but scales poorly as the number of shared types grows. Runtime reflection validation is the likely next step.
Runtime layout validation. Slang provides a reflection API that reports struct layouts (size, field offsets, field types) after compilation. Goldy could query this at shader load time and compare against the Rust-side layout (derivable via
std::mem::size_of,std::mem::offset_of!, etc.). A mismatch would produce a clear error at startup rather than silent corruption. This is the most practical near-term improvement.Static reflection and compile-time checking. If Rust's type metadata (field names, types, offsets) could be compared against Slang's reflection data at compile time — perhaps via a build script that compiles the shader, extracts reflection, and asserts layout compatibility — the mismatch would become a build error. This is the ideal end state but requires tooling that doesn't exist yet.
The cross-language type coherence problem is fundamental to any multi-language GPU stack. Goldy's current approach (convention + testing) works but scales poorly as the number of shared types grows. Runtime reflection validation is the likely next step.