mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 16:25:31 +00:00
Make {CpuAccessibleBuffer,ImmutableBuffer}::from_data sound (#1517)
from_data needs flat memory structures. Types which implement Copy (either implicity or explicitly) ensure this property. This commit adds the Copy trait bound to {CpuAccessibleBuffer,ImmutableBuffer}::from_data and adapts the unit tests accordingly.
This commit is contained in:
parent
c2d404c669
commit
eb21fea03b
@ -29,6 +29,10 @@
|
||||
- Implemented synchronization for `SyncCommandBufferBuilder::execute_commands`.
|
||||
- `AutoCommandBufferBuilder::execute_commands` is now fully safe to use.
|
||||
- `SyncCommandBufferBuilder` now becomes poisoned when it returns an error, to prevent using the builder in an inconsistent state.
|
||||
- Fixed missing barriers in dispatch calls
|
||||
- **Breaking** `shader!` no longer marks descriptor sets as readonly as a fallback when it doesn't know
|
||||
- **Breaking** The keyword `readonly` might need to be added in front of the `buffer` keyword in GLSL files to get them working again
|
||||
- **Breaking** structures passed to `ImmutableBuffer::from_data` and `CpuAccessibleBuffer::from_data` must implement [`Copy`](https://doc.rust-lang.org/std/marker/trait.Copy.html) to ensure soundness of these functions
|
||||
- Added a `dispatch_indirect` command to `AutoCommandBufferBuilder`.
|
||||
|
||||
# Version 0.21.0 (2021-03-05)
|
||||
|
@ -108,7 +108,7 @@ impl<T> CpuAccessibleBuffer<T> {
|
||||
data: T,
|
||||
) -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocError>
|
||||
where
|
||||
T: Content + 'static,
|
||||
T: Content + Copy + 'static,
|
||||
{
|
||||
unsafe {
|
||||
let uninitialized = CpuAccessibleBuffer::raw(
|
||||
@ -661,6 +661,7 @@ mod tests {
|
||||
|
||||
const EMPTY: [i32; 0] = [];
|
||||
|
||||
let _ = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), false, EMPTY.iter());
|
||||
let _ = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), false, EMPTY);
|
||||
let _ = CpuAccessibleBuffer::from_iter(device, BufferUsage::all(), false, EMPTY.iter());
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl<T: ?Sized> ImmutableBuffer<T> {
|
||||
queue: Arc<Queue>,
|
||||
) -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferFromBufferFuture), DeviceMemoryAllocError>
|
||||
where
|
||||
T: 'static + Send + Sync + Sized,
|
||||
T: 'static + Copy + Send + Sync + Sized,
|
||||
{
|
||||
let source = CpuAccessibleBuffer::from_data(
|
||||
queue.device().clone(),
|
||||
|
@ -368,13 +368,9 @@ mod tests {
|
||||
let (device, queue) = gfx_dev_and_queue!();
|
||||
|
||||
const EMPTY: [i32; 0] = [];
|
||||
let buf = CpuAccessibleBuffer::from_data(
|
||||
device,
|
||||
BufferUsage::vertex_buffer(),
|
||||
false,
|
||||
EMPTY.iter(),
|
||||
)
|
||||
.unwrap();
|
||||
let buf =
|
||||
CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), false, EMPTY)
|
||||
.unwrap();
|
||||
|
||||
let mut cacher = StateCacher::new();
|
||||
|
||||
@ -396,13 +392,9 @@ mod tests {
|
||||
let (device, queue) = gfx_dev_and_queue!();
|
||||
|
||||
const EMPTY: [i32; 0] = [];
|
||||
let buf = CpuAccessibleBuffer::from_data(
|
||||
device,
|
||||
BufferUsage::vertex_buffer(),
|
||||
false,
|
||||
EMPTY.iter(),
|
||||
)
|
||||
.unwrap();
|
||||
let buf =
|
||||
CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), false, EMPTY)
|
||||
.unwrap();
|
||||
|
||||
let mut cacher = StateCacher::new();
|
||||
|
||||
@ -436,23 +428,19 @@ mod tests {
|
||||
device.clone(),
|
||||
BufferUsage::vertex_buffer(),
|
||||
false,
|
||||
EMPTY.iter(),
|
||||
EMPTY,
|
||||
)
|
||||
.unwrap();
|
||||
let buf2 = CpuAccessibleBuffer::from_data(
|
||||
device.clone(),
|
||||
BufferUsage::vertex_buffer(),
|
||||
false,
|
||||
EMPTY.iter(),
|
||||
)
|
||||
.unwrap();
|
||||
let buf3 = CpuAccessibleBuffer::from_data(
|
||||
device,
|
||||
BufferUsage::vertex_buffer(),
|
||||
false,
|
||||
EMPTY.iter(),
|
||||
EMPTY,
|
||||
)
|
||||
.unwrap();
|
||||
let buf3 =
|
||||
CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), false, EMPTY)
|
||||
.unwrap();
|
||||
|
||||
let mut cacher = StateCacher::new();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user