mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-10-29 21:42:26 +00:00
Add buffer_slice_field! macro
This commit is contained in:
parent
39f84d554c
commit
efb6dcdc2f
@ -2,12 +2,6 @@
|
||||
|
||||
- No way to store an object and its borrowing in the same struct. This is the reason why the whole API uses `Arc`s.
|
||||
|
||||
- No pointer-to-struct-member. When you request the GPU to perform an operation on some data, you have to give a pointer to the data that
|
||||
must be manipulated. However regular Rust pointers can't be used, as the buffers are not necessarily in the memory accessible from your
|
||||
program. Instead vulkano provides its own pointer-like struct named `BufferSlice`. The problem is that there is no way to safely convert
|
||||
a `BufferSlice<Foo>` (equivalent of a virtual `&Foo`), where `struct Foo { a: i32 }`, into a `BufferSlice<i32>` (equivalent of a virtual
|
||||
`&i32`) pointing to the `a` member.
|
||||
|
||||
- Lack of plugins means that you have to use a build script to compile your shaders instead of inlining them directly where they are used.
|
||||
In addition to this, lots of existing macros would be much simpler to implement with plugins. The code generated by macros is currently
|
||||
inefficient because using the efficient way would make the code very difficult to read.
|
||||
|
@ -232,6 +232,16 @@ impl<'a, T, B: 'a> From<BufferSlice<'a, T, B>> for BufferSlice<'a, [T], B>
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes a `BufferSlice` that points to a struct, and returns a `BufferSlice` that points to
|
||||
/// a specific field of that struct.
|
||||
#[macro_export]
|
||||
macro_rules! buffer_slice_field {
|
||||
($slice:expr, $field:ident) => (
|
||||
// TODO: add #[allow(unsafe_code)] when that's allowed
|
||||
unsafe { $slice.slice_custom(|s| &s.$field) }
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// TODO: restore these tests
|
||||
|
Loading…
Reference in New Issue
Block a user