-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Clone on Api Types and Arc Dispatcher (#6665)
- Loading branch information
1 parent
fb17ee8
commit 03ff99e
Showing
30 changed files
with
374 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use wgpu_test::{gpu_test, TestingContext}; | ||
|
||
#[gpu_test] | ||
static CLONEABLE_BUFFERS: GpuTestConfiguration = | ||
wgpu_test::GpuTestConfiguration::new().run_sync(cloneable_buffers); | ||
|
||
// Test a basic case of cloneable types where you clone the buffer to be able | ||
// to access the buffer inside the callback as well as outside. | ||
fn cloneable_buffers(ctx: TestingContext) { | ||
let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor { | ||
label: None, | ||
size: 32, | ||
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ, | ||
mapped_at_creation: true, | ||
}); | ||
|
||
let buffer_contents: Vec<u8> = (0..32).collect(); | ||
|
||
buffer | ||
.slice(..) | ||
.get_mapped_range_mut() | ||
.copy_from_slice(&buffer_contents); | ||
|
||
buffer.unmap(); | ||
|
||
// This is actually a bug, we should not need to call submit to make the buffer contents visible. | ||
ctx.queue.submit([]); | ||
|
||
let cloned_buffer = buffer.clone(); | ||
let cloned_buffer_contents = buffer_contents.clone(); | ||
|
||
buffer.slice(..).map_async(wgpu::MapMode::Read, move |_| { | ||
let data = cloned_buffer.slice(..).get_mapped_range(); | ||
|
||
assert_eq!(&*data, &cloned_buffer_contents); | ||
}); | ||
|
||
ctx.device.poll(wgpu::Maintain::Wait); | ||
|
||
let data = buffer.slice(..).get_mapped_range(); | ||
|
||
assert_eq!(&*data, &buffer_contents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.