use .error_ident() for resource_log! in Drop impls

This commit is contained in:
teoxoy 2024-06-21 12:29:27 +02:00 committed by Teodor Tanasoaia
parent 5f78485f30
commit c4e067b394
7 changed files with 17 additions and 24 deletions

View File

@ -483,7 +483,7 @@ impl<A: HalApi> Drop for BindGroupLayout<A> {
self.device.bgl_pool.remove(&self.entries);
}
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw BindGroupLayout {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_bind_group_layout(raw);
@ -625,8 +625,7 @@ pub struct PipelineLayout<A: HalApi> {
impl<A: HalApi> Drop for PipelineLayout<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw PipelineLayout {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_pipeline_layout(raw);
@ -861,8 +860,7 @@ pub struct BindGroup<A: HalApi> {
impl<A: HalApi> Drop for BindGroup<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw BindGroup {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_bind_group(raw);

View File

@ -876,7 +876,7 @@ pub struct RenderBundle<A: HalApi> {
impl<A: HalApi> Drop for RenderBundle<A> {
fn drop(&mut self) {
resource_log!("Destroy raw RenderBundle {:?}", self.info.label());
resource_log!("Drop {}", self.error_ident());
}
}

View File

@ -320,10 +320,10 @@ pub struct CommandBuffer<A: HalApi> {
impl<A: HalApi> Drop for CommandBuffer<A> {
fn drop(&mut self) {
resource_log!("Drop {}", self.error_ident());
if self.data.lock().is_none() {
return;
}
resource_log!("resource::CommandBuffer::drop {:?}", self.info.label());
let mut baked = self.extract_baked_commands();
unsafe {
baked.encoder.reset_all(baked.list.into_iter());

View File

@ -64,6 +64,7 @@ impl<A: HalApi> ParentDevice<A> for Queue<A> {
impl<A: HalApi> Drop for Queue<A> {
fn drop(&mut self) {
resource_log!("Drop {}", self.error_ident());
let queue = self.raw.take().unwrap();
self.device.as_ref().unwrap().release_queue(queue);
}

View File

@ -161,6 +161,7 @@ impl<A: HalApi> std::fmt::Debug for Device<A> {
impl<A: HalApi> Drop for Device<A> {
fn drop(&mut self) {
resource_log!("Drop {}", self.error_ident());
let raw = self.raw.take().unwrap();
let pending_writes = self.pending_writes.lock().take().unwrap();
pending_writes.dispose(&raw);
@ -169,7 +170,6 @@ impl<A: HalApi> Drop for Device<A> {
raw.destroy_buffer(self.zero_buffer.take().unwrap());
raw.destroy_fence(self.fence.write().take().unwrap());
let queue = self.queue_to_drop.take().unwrap();
resource_log!("Destroy raw Device {:?} and its Queue", self.info.label());
raw.exit(queue);
}
}

View File

@ -56,8 +56,7 @@ pub struct ShaderModule<A: HalApi> {
impl<A: HalApi> Drop for ShaderModule<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw ShaderModule {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_shader_module(raw);
@ -225,8 +224,7 @@ pub struct ComputePipeline<A: HalApi> {
impl<A: HalApi> Drop for ComputePipeline<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw ComputePipeline {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_compute_pipeline(raw);
@ -294,8 +292,7 @@ pub struct PipelineCache<A: HalApi> {
impl<A: HalApi> Drop for PipelineCache<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw PipelineCache {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_pipeline_cache(raw);
@ -554,8 +551,7 @@ pub struct RenderPipeline<A: HalApi> {
impl<A: HalApi> Drop for RenderPipeline<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw RenderPipeline {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_render_pipeline(raw);

View File

@ -472,8 +472,7 @@ pub struct Buffer<A: HalApi> {
impl<A: HalApi> Drop for Buffer<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw Buffer (dropped) {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_buffer(raw);
@ -893,7 +892,7 @@ pub struct StagingBuffer<A: HalApi> {
impl<A: HalApi> Drop for StagingBuffer<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.lock().take() {
resource_log!("Destroy raw StagingBuffer {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_buffer(raw);
@ -997,7 +996,6 @@ impl<A: HalApi> Texture<A> {
impl<A: HalApi> Drop for Texture<A> {
fn drop(&mut self) {
resource_log!("Destroy raw Texture {:?}", self.info.label());
use hal::Device;
let mut clear_mode = self.clear_mode.write();
let clear_mode = &mut *clear_mode;
@ -1027,6 +1025,7 @@ impl<A: HalApi> Drop for Texture<A> {
};
if let Some(TextureInner::Native { raw }) = self.inner.take() {
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
self.device.raw().destroy_texture(raw);
}
@ -1542,8 +1541,7 @@ pub struct TextureView<A: HalApi> {
impl<A: HalApi> Drop for TextureView<A> {
fn drop(&mut self) {
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw TextureView {:?}", self.info.label());
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_texture_view(raw);
@ -1682,8 +1680,8 @@ pub struct Sampler<A: HalApi> {
impl<A: HalApi> Drop for Sampler<A> {
fn drop(&mut self) {
resource_log!("Destroy raw Sampler {:?}", self.info.label());
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_sampler(raw);
@ -1787,8 +1785,8 @@ pub struct QuerySet<A: HalApi> {
impl<A: HalApi> Drop for QuerySet<A> {
fn drop(&mut self) {
resource_log!("Destroy raw QuerySet {:?}", self.info.label());
if let Some(raw) = self.raw.take() {
resource_log!("Destroy raw {}", self.error_ident());
unsafe {
use hal::Device;
self.device.raw().destroy_query_set(raw);