mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[rs] Immediate resource destruction
This commit is contained in:
committed by
Dzmitry Malyshau
parent
d6843fca7b
commit
c92dbae57e
@@ -1206,6 +1206,18 @@ impl crate::Context for Context {
|
||||
)
|
||||
}
|
||||
|
||||
fn buffer_destroy(&self, buffer: &Self::BufferId) {
|
||||
let global = &self.0;
|
||||
wgc::gfx_select!(buffer.id => global.buffer_destroy(buffer.id)).unwrap_pretty()
|
||||
}
|
||||
fn buffer_drop(&self, buffer: &Self::BufferId) {
|
||||
let global = &self.0;
|
||||
wgc::gfx_select!(buffer.id => global.buffer_drop(buffer.id, false))
|
||||
}
|
||||
fn texture_destroy(&self, texture: &Self::TextureId) {
|
||||
let global = &self.0;
|
||||
wgc::gfx_select!(texture.id => global.texture_destroy(texture.id)).unwrap_pretty()
|
||||
}
|
||||
fn texture_drop(&self, texture: &Self::TextureId) {
|
||||
let global = &self.0;
|
||||
wgc::gfx_select!(texture.id => global.texture_drop(texture.id, false))
|
||||
@@ -1218,10 +1230,6 @@ impl crate::Context for Context {
|
||||
let global = &self.0;
|
||||
wgc::gfx_select!(*sampler => global.sampler_drop(*sampler))
|
||||
}
|
||||
fn buffer_drop(&self, buffer: &Self::BufferId) {
|
||||
let global = &self.0;
|
||||
wgc::gfx_select!(buffer.id => global.buffer_drop(buffer.id, false))
|
||||
}
|
||||
fn bind_group_drop(&self, bind_group: &Self::BindGroupId) {
|
||||
let global = &self.0;
|
||||
wgc::gfx_select!(*bind_group => global.bind_group_drop(*bind_group))
|
||||
|
||||
@@ -1267,6 +1267,15 @@ impl crate::Context for Context {
|
||||
Sendable(texture.0.create_view_with_descriptor(&mapped))
|
||||
}
|
||||
|
||||
fn buffer_destroy(&self, _buffer: &Self::BufferId) {
|
||||
// TODO
|
||||
}
|
||||
fn buffer_drop(&self, _buffer: &Self::BufferId) {
|
||||
// Dropped automatically
|
||||
}
|
||||
fn texture_destroy(&self, _texture: &Self::TextureId) {
|
||||
// TODO
|
||||
}
|
||||
fn texture_drop(&self, _texture: &Self::TextureId) {
|
||||
// Dropped automatically
|
||||
}
|
||||
@@ -1276,9 +1285,6 @@ impl crate::Context for Context {
|
||||
fn sampler_drop(&self, _sampler: &Self::SamplerId) {
|
||||
// Dropped automatically
|
||||
}
|
||||
fn buffer_drop(&self, _buffer: &Self::BufferId) {
|
||||
// Dropped automatically
|
||||
}
|
||||
fn bind_group_drop(&self, _bind_group: &Self::BindGroupId) {
|
||||
// Dropped automatically
|
||||
}
|
||||
|
||||
@@ -301,10 +301,13 @@ trait Context: Debug + Send + Sized + Sync {
|
||||
texture: &Self::TextureId,
|
||||
desc: &TextureViewDescriptor,
|
||||
) -> Self::TextureViewId;
|
||||
|
||||
fn buffer_destroy(&self, buffer: &Self::BufferId);
|
||||
fn buffer_drop(&self, buffer: &Self::BufferId);
|
||||
fn texture_destroy(&self, buffer: &Self::TextureId);
|
||||
fn texture_drop(&self, texture: &Self::TextureId);
|
||||
fn texture_view_drop(&self, texture_view: &Self::TextureViewId);
|
||||
fn sampler_drop(&self, sampler: &Self::SamplerId);
|
||||
fn buffer_drop(&self, buffer: &Self::BufferId);
|
||||
fn bind_group_drop(&self, bind_group: &Self::BindGroupId);
|
||||
fn bind_group_layout_drop(&self, bind_group_layout: &Self::BindGroupLayoutId);
|
||||
fn pipeline_layout_drop(&self, pipeline_layout: &Self::PipelineLayoutId);
|
||||
@@ -1716,6 +1719,11 @@ impl Buffer {
|
||||
self.map_context.lock().reset();
|
||||
Context::buffer_unmap(&*self.context, &self.id);
|
||||
}
|
||||
|
||||
/// Destroy the associated native resources as soon as possible.
|
||||
pub fn destroy(&self) {
|
||||
Context::buffer_destroy(&*self.context, &self.id);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BufferSlice<'a> {
|
||||
@@ -1802,6 +1810,11 @@ impl Texture {
|
||||
owned: true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Destroy the associated native resources as soon as possible.
|
||||
pub fn destroy(&self) {
|
||||
Context::texture_destroy(&*self.context, &self.id);
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Texture {
|
||||
|
||||
Reference in New Issue
Block a user