mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
remove waiting functionality from Global.{buffer,texture,texture_view}_drop()
Those resources won't be destroyed if used by a submission anyway.
This commit is contained in:
parent
d1da4456a6
commit
2ea081fabf
@ -27,7 +27,7 @@ impl Resource for WebGpuBuffer {
|
||||
}
|
||||
|
||||
fn close(self: Rc<Self>) {
|
||||
gfx_select!(self.1 => self.0.buffer_drop(self.1, true));
|
||||
gfx_select!(self.1 => self.0.buffer_drop(self.1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl Resource for WebGpuTexture {
|
||||
fn close(self: Rc<Self>) {
|
||||
if self.owned {
|
||||
let instance = &self.instance;
|
||||
gfx_select!(self.id => instance.texture_drop(self.id, true));
|
||||
gfx_select!(self.id => instance.texture_drop(self.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ impl Resource for WebGpuTextureView {
|
||||
}
|
||||
|
||||
fn close(self: Rc<Self>) {
|
||||
gfx_select!(self.1 => self.0.texture_view_drop(self.1, true)).unwrap();
|
||||
gfx_select!(self.1 => self.0.texture_view_drop(self.1)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ impl GlobalPlay for wgc::global::Global {
|
||||
self.buffer_destroy::<A>(id).unwrap();
|
||||
}
|
||||
Action::DestroyBuffer(id) => {
|
||||
self.buffer_drop::<A>(id, true);
|
||||
self.buffer_drop::<A>(id);
|
||||
}
|
||||
Action::CreateTexture(id, desc) => {
|
||||
let (_, error) = self.device_create_texture::<A>(device, &desc, Some(id));
|
||||
@ -169,7 +169,7 @@ impl GlobalPlay for wgc::global::Global {
|
||||
self.texture_destroy::<A>(id).unwrap();
|
||||
}
|
||||
Action::DestroyTexture(id) => {
|
||||
self.texture_drop::<A>(id, true);
|
||||
self.texture_drop::<A>(id);
|
||||
}
|
||||
Action::CreateTextureView {
|
||||
id,
|
||||
@ -182,7 +182,7 @@ impl GlobalPlay for wgc::global::Global {
|
||||
}
|
||||
}
|
||||
Action::DestroyTextureView(id) => {
|
||||
self.texture_view_drop::<A>(id, true).unwrap();
|
||||
self.texture_view_drop::<A>(id).unwrap();
|
||||
}
|
||||
Action::CreateSampler(id, desc) => {
|
||||
let (_, error) = self.device_create_sampler::<A>(device, &desc, Some(id));
|
||||
|
@ -409,7 +409,7 @@ impl Global {
|
||||
buffer.destroy()
|
||||
}
|
||||
|
||||
pub fn buffer_drop<A: HalApi>(&self, buffer_id: id::BufferId, wait: bool) {
|
||||
pub fn buffer_drop<A: HalApi>(&self, buffer_id: id::BufferId) {
|
||||
profiling::scope!("Buffer::drop");
|
||||
api_log!("Buffer::drop {buffer_id:?}");
|
||||
|
||||
@ -431,20 +431,6 @@ impl Global {
|
||||
#[cfg(feature = "trace")]
|
||||
buffer_id,
|
||||
);
|
||||
|
||||
if wait {
|
||||
let Some(last_submit_index) = buffer
|
||||
.device
|
||||
.lock_life()
|
||||
.get_buffer_latest_submission_index(&buffer)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
match buffer.device.wait_for_submit(last_submit_index) {
|
||||
Ok(()) => (),
|
||||
Err(e) => log::error!("Failed to wait for buffer {:?}: {}", buffer_id, e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn device_create_texture<A: HalApi>(
|
||||
@ -601,31 +587,17 @@ impl Global {
|
||||
texture.destroy()
|
||||
}
|
||||
|
||||
pub fn texture_drop<A: HalApi>(&self, texture_id: id::TextureId, wait: bool) {
|
||||
pub fn texture_drop<A: HalApi>(&self, texture_id: id::TextureId) {
|
||||
profiling::scope!("Texture::drop");
|
||||
api_log!("Texture::drop {texture_id:?}");
|
||||
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(texture) = hub.textures.unregister(texture_id) {
|
||||
if let Some(_texture) = hub.textures.unregister(texture_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = texture.device.trace.lock().as_mut() {
|
||||
if let Some(t) = _texture.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyTexture(texture_id));
|
||||
}
|
||||
|
||||
if wait {
|
||||
let Some(last_submit_index) = texture
|
||||
.device
|
||||
.lock_life()
|
||||
.get_texture_latest_submission_index(&texture)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
match texture.device.wait_for_submit(last_submit_index) {
|
||||
Ok(()) => (),
|
||||
Err(e) => log::error!("Failed to wait for texture {texture_id:?}: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -679,34 +651,17 @@ impl Global {
|
||||
pub fn texture_view_drop<A: HalApi>(
|
||||
&self,
|
||||
texture_view_id: id::TextureViewId,
|
||||
wait: bool,
|
||||
) -> Result<(), resource::TextureViewDestroyError> {
|
||||
profiling::scope!("TextureView::drop");
|
||||
api_log!("TextureView::drop {texture_view_id:?}");
|
||||
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(view) = hub.texture_views.unregister(texture_view_id) {
|
||||
if let Some(_view) = hub.texture_views.unregister(texture_view_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = view.device.trace.lock().as_mut() {
|
||||
if let Some(t) = _view.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyTextureView(texture_view_id));
|
||||
}
|
||||
|
||||
if wait {
|
||||
let Some(last_submit_index) = view
|
||||
.device
|
||||
.lock_life()
|
||||
.get_texture_latest_submission_index(&view.parent)
|
||||
else {
|
||||
return Ok(());
|
||||
};
|
||||
match view.device.wait_for_submit(last_submit_index) {
|
||||
Ok(()) => (),
|
||||
Err(e) => {
|
||||
log::error!("Failed to wait for texture view {texture_view_id:?}: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ use crate::{
|
||||
UsageScopePool,
|
||||
},
|
||||
validation::{self, validate_color_attachment_bytes_per_sample},
|
||||
FastHashMap, LabelHelpers as _, PreHashedKey, PreHashedMap, SubmissionIndex,
|
||||
FastHashMap, LabelHelpers as _, PreHashedKey, PreHashedMap,
|
||||
};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
@ -3474,9 +3474,10 @@ impl<A: HalApi> Device<A> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "replay")]
|
||||
pub(crate) fn wait_for_submit(
|
||||
&self,
|
||||
submission_index: SubmissionIndex,
|
||||
submission_index: crate::SubmissionIndex,
|
||||
) -> Result<(), WaitIdleError> {
|
||||
let guard = self.fence.read();
|
||||
let fence = guard.as_ref().unwrap();
|
||||
|
@ -1651,7 +1651,7 @@ impl crate::Context for ContextWgpuCore {
|
||||
}
|
||||
|
||||
fn buffer_drop(&self, buffer: &Self::BufferId, _buffer_data: &Self::BufferData) {
|
||||
wgc::gfx_select!(buffer => self.0.buffer_drop(*buffer, false))
|
||||
wgc::gfx_select!(buffer => self.0.buffer_drop(*buffer))
|
||||
}
|
||||
|
||||
fn texture_destroy(&self, texture: &Self::TextureId, _texture_data: &Self::TextureData) {
|
||||
@ -1660,7 +1660,7 @@ impl crate::Context for ContextWgpuCore {
|
||||
}
|
||||
|
||||
fn texture_drop(&self, texture: &Self::TextureId, _texture_data: &Self::TextureData) {
|
||||
wgc::gfx_select!(texture => self.0.texture_drop(*texture, false))
|
||||
wgc::gfx_select!(texture => self.0.texture_drop(*texture))
|
||||
}
|
||||
|
||||
fn texture_view_drop(
|
||||
@ -1668,7 +1668,7 @@ impl crate::Context for ContextWgpuCore {
|
||||
texture_view: &Self::TextureViewId,
|
||||
__texture_view_data: &Self::TextureViewData,
|
||||
) {
|
||||
let _ = wgc::gfx_select!(*texture_view => self.0.texture_view_drop(*texture_view, false));
|
||||
let _ = wgc::gfx_select!(*texture_view => self.0.texture_view_drop(*texture_view));
|
||||
}
|
||||
|
||||
fn sampler_drop(&self, sampler: &Self::SamplerId, _sampler_data: &Self::SamplerData) {
|
||||
|
Loading…
Reference in New Issue
Block a user