21 ms·
In the Lisp world... it is ambiguous if functions or macros are called at compile time or runtime. I'm not sure if this is kosher in the world of Rust, but...
by dragontamer 5y ago
In the Lisp world... it is ambiguous if functions or macros are called at compile time or runtime.
I'm not sure if this is kosher in the world of Rust, but...
static RAY_STACK: [Shared<Ray>; 2000] = [Shared::new(Ray::default()); 2000];
This could still work, if Shared::new(...) were a compile-time function. Or a language-extension that looked like a compile-time function.
EDIT: You wouldn't be allowed to have Shared::new inside of a loop or a recursive function though. But as long as you had assurances that any such Shared::new instance ran exactly once throughout the code, it might work?
Or maybe that's too ugly. "static" probably captures the idea better
- nynx 5y agoThe best way to do it is probably the way rust-gpu does it: https://github.com/EmbarkStudios/rust-gpu/blob/main/docs/src/attributes.md#workgroup-shared-memory https://github.com/EmbarkStudios/rust-gpu/blob/main/docs/src... The entry point of the kernel would supply any objects that have special properties.