diff --git a/CHANGELOG_VULKANO.md b/CHANGELOG_VULKANO.md index d9bbf7ba..31e64b09 100644 --- a/CHANGELOG_VULKANO.md +++ b/CHANGELOG_VULKANO.md @@ -11,6 +11,7 @@ - Pipeline barriers are now correctly inserted when a resource is used more than two times. - Update Winit to 0.20.0 - Update MacOS dependency cocoa to 0.20 +- Add `host_cached` field to all `CpuAccessibleBuffer` initializers to allow the user to perfer host cached memory. - Propogate new lines correctly in shader compile errors. - `Queue` and `QueueFamily` now implement `PartialEq` and `Eq` diff --git a/examples/src/bin/basic-compute-shader.rs b/examples/src/bin/basic-compute-shader.rs index a008b451..7ce9ffc0 100644 --- a/examples/src/bin/basic-compute-shader.rs +++ b/examples/src/bin/basic-compute-shader.rs @@ -97,7 +97,7 @@ fn main() { // Iterator that produces the data. let data_iter = (0 .. 65536u32).map(|n| n); // Builds the buffer and fills it with this iterator. - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), data_iter).unwrap() + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter).unwrap() }; // In order to let the shader access the buffer, we need to build a *descriptor set* that diff --git a/examples/src/bin/deferred/frame/ambient_lighting_system.rs b/examples/src/bin/deferred/frame/ambient_lighting_system.rs index f8fb7b46..c06e55ff 100644 --- a/examples/src/bin/deferred/frame/ambient_lighting_system.rs +++ b/examples/src/bin/deferred/frame/ambient_lighting_system.rs @@ -41,7 +41,7 @@ impl AmbientLightingSystem { // TODO: vulkano doesn't allow us to draw without a vertex buffer, otherwise we could // hard-code these values in the shader let vertex_buffer = { - CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), false, [ Vertex { position: [-1.0, -1.0] }, Vertex { position: [-1.0, 3.0] }, Vertex { position: [3.0, -1.0] } diff --git a/examples/src/bin/deferred/frame/directional_lighting_system.rs b/examples/src/bin/deferred/frame/directional_lighting_system.rs index 425ffb6f..cf3af233 100644 --- a/examples/src/bin/deferred/frame/directional_lighting_system.rs +++ b/examples/src/bin/deferred/frame/directional_lighting_system.rs @@ -42,7 +42,7 @@ impl DirectionalLightingSystem { // TODO: vulkano doesn't allow us to draw without a vertex buffer, otherwise we could // hard-code these values in the shader let vertex_buffer = { - CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), false, [ Vertex { position: [-1.0, -1.0] }, Vertex { position: [-1.0, 3.0] }, Vertex { position: [3.0, -1.0] } diff --git a/examples/src/bin/deferred/frame/point_lighting_system.rs b/examples/src/bin/deferred/frame/point_lighting_system.rs index 975a0f9f..8eab3890 100644 --- a/examples/src/bin/deferred/frame/point_lighting_system.rs +++ b/examples/src/bin/deferred/frame/point_lighting_system.rs @@ -42,7 +42,7 @@ impl PointLightingSystem { // TODO: vulkano doesn't allow us to draw without a vertex buffer, otherwise we could // hard-code these values in the shader let vertex_buffer = { - CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), false, [ Vertex { position: [-1.0, -1.0] }, Vertex { position: [-1.0, 3.0] }, Vertex { position: [3.0, -1.0] } diff --git a/examples/src/bin/deferred/triangle_draw_system.rs b/examples/src/bin/deferred/triangle_draw_system.rs index d874358f..5511db12 100644 --- a/examples/src/bin/deferred/triangle_draw_system.rs +++ b/examples/src/bin/deferred/triangle_draw_system.rs @@ -33,7 +33,7 @@ impl TriangleDrawSystem { where R: RenderPassAbstract + Send + Sync + 'static { let vertex_buffer = { - CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(gfx_queue.device().clone(), BufferUsage::all(), false, [ Vertex { position: [-0.5, -0.25] }, Vertex { position: [0.0, 0.5] }, Vertex { position: [0.25, -0.1] } diff --git a/examples/src/bin/image/main.rs b/examples/src/bin/image/main.rs index aebefa10..2671a118 100644 --- a/examples/src/bin/image/main.rs +++ b/examples/src/bin/image/main.rs @@ -75,6 +75,7 @@ fn main() { let vertex_buffer = CpuAccessibleBuffer::<[Vertex]>::from_iter( device.clone(), BufferUsage::all(), + false, [ Vertex { position: [-0.5, -0.5 ] }, Vertex { position: [-0.5, 0.5 ] }, diff --git a/examples/src/bin/instancing.rs b/examples/src/bin/instancing.rs index 1fa072e5..1c2155ca 100644 --- a/examples/src/bin/instancing.rs +++ b/examples/src/bin/instancing.rs @@ -94,7 +94,7 @@ fn main() { // We now create a buffer that will store the shape of our triangle. // This triangle is identical to the one in the `triangle.rs` example. let triangle_vertex_buffer = { - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, [ Vertex { position: [-0.5, -0.25] }, Vertex { position: [0.0, 0.5] }, Vertex { position: [0.25, -0.1] } @@ -119,7 +119,7 @@ fn main() { data.push(InstanceData { position_offset, scale }); } } - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), data.iter().cloned()) + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data.iter().cloned()) .unwrap() }; diff --git a/examples/src/bin/msaa-renderpass.rs b/examples/src/bin/msaa-renderpass.rs index bdce8541..80871cdf 100644 --- a/examples/src/bin/msaa-renderpass.rs +++ b/examples/src/bin/msaa-renderpass.rs @@ -191,7 +191,7 @@ fn main() { let vertex1 = Vertex { position: [-0.5, -0.5] }; let vertex2 = Vertex { position: [ 0.0, 0.5] }; let vertex3 = Vertex { position: [ 0.5, -0.25] }; - let vertex_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), + let vertex_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, vec![vertex1, vertex2, vertex3].into_iter()).unwrap(); let pipeline = Arc::new(GraphicsPipeline::start() @@ -212,7 +212,7 @@ fn main() { .. DynamicState::none() }; - let buf = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), + let buf = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, (0 .. 1024 * 1024 * 4).map(|_| 0u8)).unwrap(); let command_buffer = AutoCommandBufferBuilder::primary_one_time_submit(device.clone(), queue.family()).unwrap() diff --git a/examples/src/bin/multi-window.rs b/examples/src/bin/multi-window.rs index b5b26b52..c8185ddb 100644 --- a/examples/src/bin/multi-window.rs +++ b/examples/src/bin/multi-window.rs @@ -94,7 +94,7 @@ fn main() { struct Vertex { position: [f32; 2] } vulkano::impl_vertex!(Vertex, position); - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, [ Vertex { position: [-0.5, -0.25] }, Vertex { position: [0.0, 0.5] }, Vertex { position: [0.25, -0.1] } diff --git a/examples/src/bin/push-constants.rs b/examples/src/bin/push-constants.rs index eb61e2bc..5029535e 100644 --- a/examples/src/bin/push-constants.rs +++ b/examples/src/bin/push-constants.rs @@ -64,7 +64,7 @@ fn main() { let data_buffer = { let data_iter = (0 .. 65536u32).map(|n| n); - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), data_iter).unwrap() + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter).unwrap() }; let layout = pipeline.layout().descriptor_set_layout(0).unwrap(); diff --git a/examples/src/bin/runtime-shader/main.rs b/examples/src/bin/runtime-shader/main.rs index fb1c7efa..bf36e7ee 100644 --- a/examples/src/bin/runtime-shader/main.rs +++ b/examples/src/bin/runtime-shader/main.rs @@ -367,6 +367,7 @@ fn main() { let vertex_buffer = CpuAccessibleBuffer::from_iter( device.clone(), BufferUsage::all(), + false, [ Vertex { position: [-1.0, 1.0], color: [1.0, 0.0, 0.0] }, Vertex { position: [ 0.0, -1.0], color: [0.0, 1.0, 0.0] }, diff --git a/examples/src/bin/shader-include/main.rs b/examples/src/bin/shader-include/main.rs index d893ea38..d8bd642f 100644 --- a/examples/src/bin/shader-include/main.rs +++ b/examples/src/bin/shader-include/main.rs @@ -72,7 +72,7 @@ fn main() { let data_buffer = { let data_iter = (0 .. 65536u32).map(|n| n); - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), data_iter).unwrap() + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter).unwrap() }; let layout = pipeline.layout().descriptor_set_layout(0).unwrap(); let set = Arc::new(PersistentDescriptorSet::start(layout.clone()) diff --git a/examples/src/bin/specialization-constants.rs b/examples/src/bin/specialization-constants.rs index 007e1b67..e8cd48b7 100644 --- a/examples/src/bin/specialization-constants.rs +++ b/examples/src/bin/specialization-constants.rs @@ -68,7 +68,7 @@ fn main() { let data_buffer = { let data_iter = (0 .. 65536u32).map(|n| n); - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), data_iter).unwrap() + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, data_iter).unwrap() }; let layout = pipeline.layout().descriptor_set_layout(0).unwrap(); diff --git a/examples/src/bin/teapot/main.rs b/examples/src/bin/teapot/main.rs index f2ebbe7b..e85eed19 100644 --- a/examples/src/bin/teapot/main.rs +++ b/examples/src/bin/teapot/main.rs @@ -75,13 +75,13 @@ fn main() { }; let vertices = VERTICES.iter().cloned(); - let vertex_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), vertices).unwrap(); + let vertex_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, vertices).unwrap(); let normals = NORMALS.iter().cloned(); - let normals_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), normals).unwrap(); + let normals_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, normals).unwrap(); let indices = INDICES.iter().cloned(); - let index_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), indices).unwrap(); + let index_buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, indices).unwrap(); let uniform_buffer = CpuBufferPool::::new(device.clone(), BufferUsage::all()); diff --git a/examples/src/bin/tessellation.rs b/examples/src/bin/tessellation.rs index 96d3db08..6ce01020 100644 --- a/examples/src/bin/tessellation.rs +++ b/examples/src/bin/tessellation.rs @@ -169,7 +169,7 @@ fn main() { struct Vertex { position: [f32; 2] } vulkano::impl_vertex!(Vertex, position); - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, [ Vertex { position: [-0.5, -0.25] }, Vertex { position: [ 0.0, 0.5] }, Vertex { position: [ 0.25, -0.1] }, diff --git a/examples/src/bin/triangle.rs b/examples/src/bin/triangle.rs index f97e37cb..9a96fb59 100644 --- a/examples/src/bin/triangle.rs +++ b/examples/src/bin/triangle.rs @@ -165,7 +165,7 @@ fn main() { struct Vertex { position: [f32; 2] } vulkano::impl_vertex!(Vertex, position); - CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), [ + CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), false, [ Vertex { position: [-0.5, -0.25] }, Vertex { position: [0.0, 0.5] }, Vertex { position: [0.25, -0.1] } diff --git a/vulkano/src/buffer/cpu_access.rs b/vulkano/src/buffer/cpu_access.rs index 66d827db..6dc1659a 100644 --- a/vulkano/src/buffer/cpu_access.rs +++ b/vulkano/src/buffer/cpu_access.rs @@ -59,6 +59,12 @@ use sync::AccessError; use sync::Sharing; /// Buffer whose content is accessible by the CPU. +/// +/// Setting the `host_cached` field on the various initializers to `true` will make it so +/// the `CpuAccessibleBuffer` perfers to allocate from host_cached memory. Host cached +/// memory caches GPU data on the CPU side. This can be more performant in cases where +/// the cpu needs to read data coming off the GPU. + #[derive(Debug)] pub struct CpuAccessibleBuffer> { // Inner content. @@ -94,13 +100,13 @@ enum CurrentGpuAccess { impl CpuAccessibleBuffer { /// Builds a new buffer with some data in it. Only allowed for sized data. - pub fn from_data(device: Arc, usage: BufferUsage, data: T) + pub fn from_data(device: Arc, usage: BufferUsage, host_cached: bool, data: T) -> Result>, DeviceMemoryAllocError> where T: Content + 'static { unsafe { let uninitialized = - CpuAccessibleBuffer::raw(device, mem::size_of::(), usage, iter::empty())?; + CpuAccessibleBuffer::raw(device, mem::size_of::(), usage, host_cached, iter::empty())?; // Note that we are in panic-unsafety land here. However a panic should never ever // happen here, so in theory we are safe. @@ -117,23 +123,23 @@ impl CpuAccessibleBuffer { /// Builds a new uninitialized buffer. Only allowed for sized data. #[inline] - pub unsafe fn uninitialized(device: Arc, usage: BufferUsage) + pub unsafe fn uninitialized(device: Arc, usage: BufferUsage, host_cached: bool) -> Result>, DeviceMemoryAllocError> { - CpuAccessibleBuffer::raw(device, mem::size_of::(), usage, iter::empty()) + CpuAccessibleBuffer::raw(device, mem::size_of::(), usage, host_cached, iter::empty()) } } impl CpuAccessibleBuffer<[T]> { /// Builds a new buffer that contains an array `T`. The initial data comes from an iterator /// that produces that list of Ts. - pub fn from_iter(device: Arc, usage: BufferUsage, data: I) + pub fn from_iter(device: Arc, usage: BufferUsage, host_cached: bool, data: I) -> Result>, DeviceMemoryAllocError> where I: ExactSizeIterator, T: Content + 'static { unsafe { let uninitialized = - CpuAccessibleBuffer::uninitialized_array(device, data.len(), usage)?; + CpuAccessibleBuffer::uninitialized_array(device, data.len(), usage, host_cached)?; // Note that we are in panic-unsafety land here. However a panic should never ever // happen here, so in theory we are safe. @@ -154,9 +160,9 @@ impl CpuAccessibleBuffer<[T]> { /// Builds a new buffer. Can be used for arrays. #[inline] pub unsafe fn uninitialized_array( - device: Arc, len: usize, usage: BufferUsage) + device: Arc, len: usize, usage: BufferUsage, host_cached: bool) -> Result>, DeviceMemoryAllocError> { - CpuAccessibleBuffer::raw(device, len * mem::size_of::(), usage, iter::empty()) + CpuAccessibleBuffer::raw(device, len * mem::size_of::(), usage, host_cached, iter::empty()) } } @@ -168,7 +174,7 @@ impl CpuAccessibleBuffer { /// You must ensure that the size that you pass is correct for `T`. /// pub unsafe fn raw<'a, I>(device: Arc, size: usize, usage: BufferUsage, - queue_families: I) + host_cached: bool, queue_families: I) -> Result>, DeviceMemoryAllocError> where I: IntoIterator> { @@ -197,7 +203,19 @@ impl CpuAccessibleBuffer { AllocLayout::Linear, MappingRequirement::Map, DedicatedAlloc::Buffer(&buffer), - |_| AllocFromRequirementsFilter::Allowed)?; + |m| if m.is_host_cached() { + if host_cached { + AllocFromRequirementsFilter::Preferred + } else { + AllocFromRequirementsFilter::Allowed + } + } else { + if host_cached { + AllocFromRequirementsFilter::Allowed + } else { + AllocFromRequirementsFilter::Preferred + } + })?; debug_assert!((mem.offset() % mem_reqs.alignment) == 0); debug_assert!(mem.mapped_memory().is_some()); buffer.bind_memory(mem.memory(), mem.offset())?; @@ -579,6 +597,6 @@ mod tests { const EMPTY: [i32; 0] = []; - let _ = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), EMPTY.iter()); + let _ = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), false, EMPTY.iter()); } } diff --git a/vulkano/src/buffer/immutable.rs b/vulkano/src/buffer/immutable.rs index 89f001cc..8e2babfb 100644 --- a/vulkano/src/buffer/immutable.rs +++ b/vulkano/src/buffer/immutable.rs @@ -97,6 +97,7 @@ impl ImmutableBuffer { { let source = CpuAccessibleBuffer::from_data(queue.device().clone(), BufferUsage::transfer_source(), + false, data)?; ImmutableBuffer::from_buffer(source, usage, queue) } @@ -180,6 +181,7 @@ impl ImmutableBuffer<[T]> { { let source = CpuAccessibleBuffer::from_iter(queue.device().clone(), BufferUsage::transfer_source(), + false, data)?; ImmutableBuffer::from_buffer(source, usage, queue) } @@ -469,7 +471,7 @@ mod tests { let (buffer, _) = ImmutableBuffer::from_data(12u32, BufferUsage::all(), queue.clone()) .unwrap(); - let destination = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0) + let destination = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), false, 0) .unwrap(); let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()) @@ -498,6 +500,7 @@ mod tests { let destination = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::all(), + false, (0 .. 512).map(|_| 0u32)) .unwrap(); @@ -549,7 +552,7 @@ mod tests { ImmutableBuffer::::uninitialized(device.clone(), BufferUsage::all()).unwrap() }; - let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0).unwrap(); + let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), false, 0).unwrap(); assert_should_panic!({ // TODO: check Result error instead of panicking @@ -575,7 +578,7 @@ mod tests { ImmutableBuffer::::uninitialized(device.clone(), BufferUsage::all()).unwrap() }; - let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0).unwrap(); + let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), false, 0).unwrap(); let _ = AutoCommandBufferBuilder::new(device.clone(), queue.family()) .unwrap() @@ -600,7 +603,7 @@ mod tests { ImmutableBuffer::::uninitialized(device.clone(), BufferUsage::all()).unwrap() }; - let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0).unwrap(); + let source = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), false, 0).unwrap(); let cb1 = AutoCommandBufferBuilder::new(device.clone(), queue.family()) .unwrap() diff --git a/vulkano/src/command_buffer/state_cacher.rs b/vulkano/src/command_buffer/state_cacher.rs index 97ab5f4a..f9afad0d 100644 --- a/vulkano/src/command_buffer/state_cacher.rs +++ b/vulkano/src/command_buffer/state_cacher.rs @@ -366,7 +366,7 @@ mod tests { const EMPTY: [i32; 0] = []; let buf = - CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), EMPTY.iter()) + CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), false, EMPTY.iter()) .unwrap(); let mut cacher = StateCacher::new(); @@ -390,7 +390,7 @@ mod tests { const EMPTY: [i32; 0] = []; let buf = - CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), EMPTY.iter()) + CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), false, EMPTY.iter()) .unwrap(); let mut cacher = StateCacher::new(); @@ -423,15 +423,19 @@ mod tests { const EMPTY: [i32; 0] = []; let buf1 = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::vertex_buffer(), + false, EMPTY.iter()) .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()) .unwrap(); - let buf3 = - CpuAccessibleBuffer::from_data(device, BufferUsage::vertex_buffer(), EMPTY.iter()) - .unwrap(); let mut cacher = StateCacher::new(); diff --git a/vulkano/src/command_buffer/synced/tests.rs b/vulkano/src/command_buffer/synced/tests.rs index 12a237cf..86455591 100644 --- a/vulkano/src/command_buffer/synced/tests.rs +++ b/vulkano/src/command_buffer/synced/tests.rs @@ -34,7 +34,7 @@ fn basic_conflict() { let pool = Device::standard_command_pool(&device, queue.family()); let mut sync = SyncCommandBufferBuilder::new(&pool, Kind::primary(), Flags::None).unwrap(); - let buf = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), 0u32).unwrap(); + let buf = CpuAccessibleBuffer::from_data(device, BufferUsage::all(), false, 0u32).unwrap(); match sync.copy_buffer(buf.clone(), buf.clone(), iter::once((0, 0, 4))) { Err(SyncCommandBufferBuilderError::Conflict { .. }) => (), diff --git a/vulkano/src/command_buffer/validity/fill_buffer.rs b/vulkano/src/command_buffer/validity/fill_buffer.rs index 2648849b..53c302a1 100644 --- a/vulkano/src/command_buffer/validity/fill_buffer.rs +++ b/vulkano/src/command_buffer/validity/fill_buffer.rs @@ -78,7 +78,7 @@ mod tests { fn missing_usage() { let (device, queue) = gfx_dev_and_queue!(); let buffer = - CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::vertex_buffer(), 0u32) + CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::vertex_buffer(), false, 0u32) .unwrap(); match check_fill_buffer(&device, &buffer) { @@ -91,7 +91,7 @@ mod tests { fn wrong_device() { let (dev1, queue) = gfx_dev_and_queue!(); let (dev2, _) = gfx_dev_and_queue!(); - let buffer = CpuAccessibleBuffer::from_data(dev1, BufferUsage::all(), 0u32).unwrap(); + let buffer = CpuAccessibleBuffer::from_data(dev1, BufferUsage::all(), false, 0u32).unwrap(); assert_should_panic!({ let _ = check_fill_buffer(&dev2, &buffer); diff --git a/vulkano/src/command_buffer/validity/index_buffer.rs b/vulkano/src/command_buffer/validity/index_buffer.rs index 19787417..e09a9144 100644 --- a/vulkano/src/command_buffer/validity/index_buffer.rs +++ b/vulkano/src/command_buffer/validity/index_buffer.rs @@ -96,6 +96,7 @@ mod tests { let (device, queue) = gfx_dev_and_queue!(); let buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::index_buffer(), + false, 0 .. 500u32) .unwrap(); @@ -112,6 +113,7 @@ mod tests { let (device, queue) = gfx_dev_and_queue!(); let buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::vertex_buffer(), + false, 0 .. 500u32) .unwrap(); @@ -126,7 +128,7 @@ mod tests { let (dev1, queue) = gfx_dev_and_queue!(); let (dev2, _) = gfx_dev_and_queue!(); - let buffer = CpuAccessibleBuffer::from_iter(dev1, BufferUsage::all(), 0 .. 500u32).unwrap(); + let buffer = CpuAccessibleBuffer::from_iter(dev1, BufferUsage::all(), false, 0 .. 500u32).unwrap(); assert_should_panic!({ let _ = check_index_buffer(&dev2, &buffer); diff --git a/vulkano/src/command_buffer/validity/update_buffer.rs b/vulkano/src/command_buffer/validity/update_buffer.rs index 6384643d..4f3b79a8 100644 --- a/vulkano/src/command_buffer/validity/update_buffer.rs +++ b/vulkano/src/command_buffer/validity/update_buffer.rs @@ -96,7 +96,7 @@ mod tests { fn missing_usage() { let (device, queue) = gfx_dev_and_queue!(); let buffer = - CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::vertex_buffer(), 0u32) + CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::vertex_buffer(), false, 0u32) .unwrap(); match check_update_buffer(&device, &buffer, &0) { @@ -110,6 +110,7 @@ mod tests { let (device, queue) = gfx_dev_and_queue!(); let buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::transfer_destination(), + false, 0 .. 65536) .unwrap(); let data = (0 .. 65536).collect::>(); @@ -125,6 +126,7 @@ mod tests { let (device, queue) = gfx_dev_and_queue!(); let buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::transfer_destination(), + false, (0 .. 100000).map(|_| 0)) .unwrap(); let data = (0 .. 65536).map(|_| 0).collect::>(); @@ -140,6 +142,7 @@ mod tests { let (device, queue) = gfx_dev_and_queue!(); let buffer = CpuAccessibleBuffer::from_iter(device.clone(), BufferUsage::transfer_destination(), + false, 0 .. 100) .unwrap(); let data = (0 .. 30).collect::>(); @@ -154,7 +157,7 @@ mod tests { fn wrong_device() { let (dev1, queue) = gfx_dev_and_queue!(); let (dev2, _) = gfx_dev_and_queue!(); - let buffer = CpuAccessibleBuffer::from_data(dev1, BufferUsage::all(), 0u32).unwrap(); + let buffer = CpuAccessibleBuffer::from_data(dev1, BufferUsage::all(), false, 0u32).unwrap(); assert_should_panic!({ let _ = check_update_buffer(&dev2, &buffer, &0); diff --git a/vulkano/src/image/immutable.rs b/vulkano/src/image/immutable.rs index 6d1a370c..9df3223f 100644 --- a/vulkano/src/image/immutable.rs +++ b/vulkano/src/image/immutable.rs @@ -201,6 +201,7 @@ impl ImmutableImage { { let source = CpuAccessibleBuffer::from_iter(queue.device().clone(), BufferUsage::transfer_source(), + false, iter)?; ImmutableImage::from_buffer(source, dimensions, format, queue) } diff --git a/vulkano/src/pipeline/compute_pipeline.rs b/vulkano/src/pipeline/compute_pipeline.rs index 1eda87f9..76790846 100644 --- a/vulkano/src/pipeline/compute_pipeline.rs +++ b/vulkano/src/pipeline/compute_pipeline.rs @@ -969,7 +969,7 @@ mod tests { &SpecConsts { VALUE: 0x12345678 }) .unwrap()); - let data_buffer = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), 0) + let data_buffer = CpuAccessibleBuffer::from_data(device.clone(), BufferUsage::all(), false, 0) .unwrap(); let layout = pipeline.layout().descriptor_set_layout(0).unwrap(); let set = PersistentDescriptorSet::start(layout.clone())