mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
use ManuallyDrop
for Device.zero_buffer
This commit is contained in:
parent
c1bc0864c5
commit
728b288fda
@ -263,7 +263,7 @@ impl Global {
|
||||
encoder,
|
||||
&mut tracker.textures,
|
||||
&device.alignments,
|
||||
device.zero_buffer.as_ref().unwrap(),
|
||||
&device.zero_buffer,
|
||||
&snatch_guard,
|
||||
)
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ pub(crate) fn fixup_discarded_surfaces<
|
||||
encoder,
|
||||
texture_tracker,
|
||||
&device.alignments,
|
||||
device.zero_buffer.as_ref().unwrap(),
|
||||
&device.zero_buffer,
|
||||
snatch_guard,
|
||||
)
|
||||
.unwrap();
|
||||
@ -310,7 +310,7 @@ impl<A: HalApi> BakedCommands<A> {
|
||||
&mut self.encoder,
|
||||
&mut device_tracker.textures,
|
||||
&device.alignments,
|
||||
device.zero_buffer.as_ref().unwrap(),
|
||||
&device.zero_buffer,
|
||||
snatch_guard,
|
||||
);
|
||||
|
||||
|
@ -445,7 +445,7 @@ fn handle_texture_init<A: HalApi>(
|
||||
cmd_buf_raw,
|
||||
&mut trackers.textures,
|
||||
&device.alignments,
|
||||
device.zero_buffer.as_ref().unwrap(),
|
||||
&device.zero_buffer,
|
||||
snatch_guard,
|
||||
)?;
|
||||
}
|
||||
|
@ -723,7 +723,7 @@ impl Global {
|
||||
encoder,
|
||||
&mut trackers.textures,
|
||||
&device.alignments,
|
||||
device.zero_buffer.as_ref().unwrap(),
|
||||
&device.zero_buffer,
|
||||
&device.snatchable_lock.read(),
|
||||
)
|
||||
.map_err(QueueWriteError::from)?;
|
||||
@ -990,7 +990,7 @@ impl Global {
|
||||
encoder,
|
||||
&mut trackers.textures,
|
||||
&device.alignments,
|
||||
device.zero_buffer.as_ref().unwrap(),
|
||||
&device.zero_buffer,
|
||||
&device.snatchable_lock.read(),
|
||||
)
|
||||
.map_err(QueueWriteError::from)?;
|
||||
|
@ -84,7 +84,7 @@ pub struct Device<A: HalApi> {
|
||||
pub(crate) adapter: Arc<Adapter<A>>,
|
||||
pub(crate) queue: OnceCell<Weak<Queue<A>>>,
|
||||
queue_to_drop: OnceCell<A::Queue>,
|
||||
pub(crate) zero_buffer: Option<A::Buffer>,
|
||||
pub(crate) zero_buffer: ManuallyDrop<A::Buffer>,
|
||||
/// The `label` from the descriptor used to create the resource.
|
||||
label: String,
|
||||
|
||||
@ -171,12 +171,14 @@ impl<A: HalApi> Drop for Device<A> {
|
||||
resource_log!("Drop {}", self.error_ident());
|
||||
// SAFETY: We are in the Drop impl and we don't use self.raw anymore after this point.
|
||||
let raw = unsafe { ManuallyDrop::take(&mut self.raw) };
|
||||
// SAFETY: We are in the Drop impl and we don't use self.zero_buffer anymore after this point.
|
||||
let zero_buffer = unsafe { ManuallyDrop::take(&mut self.zero_buffer) };
|
||||
// SAFETY: We are in the Drop impl and we don't use self.pending_writes anymore after this point.
|
||||
let pending_writes = unsafe { ManuallyDrop::take(&mut self.pending_writes.lock()) };
|
||||
pending_writes.dispose(&raw);
|
||||
self.command_allocator.dispose(&raw);
|
||||
unsafe {
|
||||
raw.destroy_buffer(self.zero_buffer.take().unwrap());
|
||||
raw.destroy_buffer(zero_buffer);
|
||||
raw.destroy_fence(self.fence.write().take().unwrap());
|
||||
let queue = self.queue_to_drop.take().unwrap();
|
||||
raw.exit(queue);
|
||||
@ -276,7 +278,7 @@ impl<A: HalApi> Device<A> {
|
||||
adapter: adapter.clone(),
|
||||
queue: OnceCell::new(),
|
||||
queue_to_drop: OnceCell::new(),
|
||||
zero_buffer: Some(zero_buffer),
|
||||
zero_buffer: ManuallyDrop::new(zero_buffer),
|
||||
label: desc.label.to_string(),
|
||||
command_allocator,
|
||||
active_submission_index: AtomicU64::new(0),
|
||||
|
Loading…
Reference in New Issue
Block a user