Skip to content

Instantly share code, notes, and snippets.

@kiljacken
Created August 19, 2022 11:40
Show Gist options
  • Save kiljacken/10b727592c3a8ad2b30f944ad09e466d to your computer and use it in GitHub Desktop.
Save kiljacken/10b727592c3a8ad2b30f944ad09e466d to your computer and use it in GitHub Desktop.
macro_rules! inner_ptr {
($gpuva:expr, $($f:tt)*) 0> ({
fn uninit_from<T: GPUStruct>(_: &GPUWeakPointer<T>) -> MaybeUninit<T::Raw<'static>> {
core::mem::MaybeUninit::uninit()
}
let tmp = uninit_from($gpuva);
// ... All the stuff up to and including `inner.offset_from(...)`
let off = inner.offset_from(...);
let outer = tmp.as_ptr();
fn out_from<T: GPUStruct, U>(gpuva: &GPUWeakPointer<T>) -> GPUWeakPointer<U> {
unsafe{ gpuva.offset(...) }
}
out_from($gpuva)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment