зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1637998 - Make wgpu pass destruction more explicit r=groves
The old way of calling `into_vec` on destruction was awkward Differential Revision: https://phabricator.services.mozilla.com/D77154
This commit is contained in:
Родитель
da55c8ff29
Коммит
d6f8c568eb
|
@ -93,7 +93,16 @@ impl RawPass {
|
|||
self.data as usize - self.base as usize
|
||||
}
|
||||
|
||||
pub unsafe fn into_vec(self) -> (Vec<u8>, id::CommandEncoderId) {
|
||||
/// Recover the data vector of the pass, consuming `self`.
|
||||
unsafe fn into_vec(mut self) -> (Vec<u8>, id::CommandEncoderId) {
|
||||
(self.invalidate(), self.parent)
|
||||
}
|
||||
|
||||
/// Make pass contents invalid, return the contained data.
|
||||
///
|
||||
/// Any following access to the pass will result in a crash
|
||||
/// for accessing address 0.
|
||||
pub unsafe fn invalidate(&mut self) -> Vec<u8> {
|
||||
let size = self.size();
|
||||
assert!(
|
||||
size <= self.capacity,
|
||||
|
@ -102,7 +111,10 @@ impl RawPass {
|
|||
self.capacity
|
||||
);
|
||||
let vec = Vec::from_raw_parts(self.base, size, self.capacity);
|
||||
(vec, self.parent)
|
||||
self.data = ptr::null_mut();
|
||||
self.base = ptr::null_mut();
|
||||
self.capacity = 0;
|
||||
vec
|
||||
}
|
||||
|
||||
unsafe fn ensure_extra_size(&mut self, extra_size: usize) {
|
||||
|
|
|
@ -160,8 +160,7 @@ impl super::RawPass {
|
|||
|
||||
pub unsafe fn finish_render(mut self) -> (Vec<u8>, id::CommandEncoderId) {
|
||||
self.finish(RenderCommand::End);
|
||||
let (vec, parent_id) = self.into_vec();
|
||||
(vec, parent_id)
|
||||
self.into_vec()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -281,8 +281,8 @@ pub unsafe extern "C" fn wgpu_command_encoder_begin_compute_pass(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wgpu_compute_pass_destroy(pass: wgc::command::RawPass) {
|
||||
let _ = pass.into_vec();
|
||||
pub unsafe extern "C" fn wgpu_compute_pass_destroy(mut pass: wgc::command::RawPass) {
|
||||
let _ = pass.invalidate();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -294,8 +294,8 @@ pub unsafe extern "C" fn wgpu_command_encoder_begin_render_pass(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wgpu_render_pass_destroy(pass: wgc::command::RawPass) {
|
||||
let _ = pass.into_vec();
|
||||
pub unsafe extern "C" fn wgpu_render_pass_destroy(mut pass: wgc::command::RawPass) {
|
||||
let _ = pass.invalidate();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Загрузка…
Ссылка в новой задаче