mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
move destroy/drop tracing actions in Global
's methods
This commit is contained in:
parent
e2c4348959
commit
f2ea30772c
@ -1,5 +1,3 @@
|
||||
#[cfg(feature = "trace")]
|
||||
use crate::device::trace;
|
||||
use crate::{
|
||||
device::{
|
||||
bgl, Device, DeviceError, MissingDownlevelFlags, MissingFeatures, SHADER_STAGE_COUNT,
|
||||
@ -486,11 +484,6 @@ impl<A: HalApi> Drop for BindGroupLayout<A> {
|
||||
self.device.bgl_pool.remove(&self.entries);
|
||||
}
|
||||
if let Some(raw) = self.raw.take() {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyBindGroupLayout(self.info.id()));
|
||||
}
|
||||
|
||||
resource_log!("Destroy raw BindGroupLayout {:?}", self.info.label());
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
@ -639,11 +632,6 @@ impl<A: HalApi> Drop for PipelineLayout<A> {
|
||||
if let Some(raw) = self.raw.take() {
|
||||
resource_log!("Destroy raw PipelineLayout {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyPipelineLayout(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_pipeline_layout(raw);
|
||||
@ -880,11 +868,6 @@ impl<A: HalApi> Drop for BindGroup<A> {
|
||||
if let Some(raw) = self.raw.take() {
|
||||
resource_log!("Destroy raw BindGroup {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyBindGroup(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_bind_group(raw);
|
||||
|
@ -78,8 +78,6 @@ index format changes.
|
||||
|
||||
#![allow(clippy::reversed_empty_ranges)]
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
use crate::device::trace;
|
||||
use crate::{
|
||||
binding_model::{buffer_binding_type_alignment, BindGroup, BindGroupLayout, PipelineLayout},
|
||||
command::{
|
||||
@ -896,11 +894,6 @@ pub struct RenderBundle<A: HalApi> {
|
||||
impl<A: HalApi> Drop for RenderBundle<A> {
|
||||
fn drop(&mut self) {
|
||||
resource_log!("Destroy raw RenderBundle {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyRenderBundle(self.info.id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -490,6 +490,11 @@ impl Global {
|
||||
.get(buffer_id)
|
||||
.map_err(|_| resource::DestroyError::Invalid)?;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(trace) = buffer.device.trace.lock().as_mut() {
|
||||
trace.add(trace::Action::FreeBuffer(buffer_id));
|
||||
}
|
||||
|
||||
let _ = buffer.unmap();
|
||||
|
||||
buffer.destroy()
|
||||
@ -508,6 +513,11 @@ impl Global {
|
||||
}
|
||||
};
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = buffer.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyBuffer(buffer_id));
|
||||
}
|
||||
|
||||
let _ = buffer.unmap();
|
||||
|
||||
let last_submit_index = buffer.info.submission_index();
|
||||
@ -724,6 +734,11 @@ impl Global {
|
||||
.get(texture_id)
|
||||
.map_err(|_| resource::DestroyError::Invalid)?;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(trace) = texture.device.trace.lock().as_mut() {
|
||||
trace.add(trace::Action::FreeTexture(texture_id));
|
||||
}
|
||||
|
||||
texture.destroy()
|
||||
}
|
||||
|
||||
@ -734,6 +749,11 @@ impl Global {
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(texture) = hub.textures.unregister(texture_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = texture.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyTexture(texture_id));
|
||||
}
|
||||
|
||||
let last_submit_index = texture.info.submission_index();
|
||||
|
||||
let device = &texture.device;
|
||||
@ -840,6 +860,11 @@ impl Global {
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(view) = hub.texture_views.unregister(texture_view_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = view.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyTextureView(texture_view_id));
|
||||
}
|
||||
|
||||
let last_submit_index = view.info.submission_index();
|
||||
|
||||
view.device
|
||||
@ -909,6 +934,11 @@ impl Global {
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(sampler) = hub.samplers.unregister(sampler_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = sampler.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroySampler(sampler_id));
|
||||
}
|
||||
|
||||
sampler
|
||||
.device
|
||||
.lock_life()
|
||||
@ -1010,6 +1040,11 @@ impl Global {
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(layout) = hub.bind_group_layouts.unregister(bind_group_layout_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = layout.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyBindGroupLayout(bind_group_layout_id));
|
||||
}
|
||||
|
||||
layout
|
||||
.device
|
||||
.lock_life()
|
||||
@ -1068,6 +1103,11 @@ impl Global {
|
||||
|
||||
let hub = A::hub(self);
|
||||
if let Some(layout) = hub.pipeline_layouts.unregister(pipeline_layout_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = layout.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyPipelineLayout(pipeline_layout_id));
|
||||
}
|
||||
|
||||
layout
|
||||
.device
|
||||
.lock_life()
|
||||
@ -1140,6 +1180,11 @@ impl Global {
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(bind_group) = hub.bind_groups.unregister(bind_group_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = bind_group.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyBindGroup(bind_group_id));
|
||||
}
|
||||
|
||||
bind_group
|
||||
.device
|
||||
.lock_life()
|
||||
@ -1295,7 +1340,14 @@ impl Global {
|
||||
api_log!("ShaderModule::drop {shader_module_id:?}");
|
||||
|
||||
let hub = A::hub(self);
|
||||
hub.shader_modules.unregister(shader_module_id);
|
||||
|
||||
if let Some(shader_module) = hub.shader_modules.unregister(shader_module_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = shader_module.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyShaderModule(shader_module_id));
|
||||
}
|
||||
drop(shader_module)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn device_create_command_encoder<A: HalApi>(
|
||||
@ -1437,6 +1489,11 @@ impl Global {
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(bundle) = hub.render_bundles.unregister(render_bundle_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = bundle.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyRenderBundle(render_bundle_id));
|
||||
}
|
||||
|
||||
bundle
|
||||
.device
|
||||
.lock_life()
|
||||
@ -1496,7 +1553,7 @@ impl Global {
|
||||
let device = &query_set.device;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut trace) = *device.trace.lock() {
|
||||
if let Some(trace) = device.trace.lock().as_mut() {
|
||||
trace.add(trace::Action::DestroyQuerySet(query_set_id));
|
||||
}
|
||||
|
||||
@ -1632,6 +1689,12 @@ impl Global {
|
||||
|
||||
if let Some(pipeline) = hub.render_pipelines.unregister(render_pipeline_id) {
|
||||
let device = &pipeline.device;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = pipeline.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyRenderPipeline(render_pipeline_id));
|
||||
}
|
||||
|
||||
let mut life_lock = device.lock_life();
|
||||
life_lock
|
||||
.suspected_resources
|
||||
@ -1762,6 +1825,12 @@ impl Global {
|
||||
|
||||
if let Some(pipeline) = hub.compute_pipelines.unregister(compute_pipeline_id) {
|
||||
let device = &pipeline.device;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyComputePipeline(compute_pipeline_id));
|
||||
}
|
||||
|
||||
let mut life_lock = device.lock_life();
|
||||
life_lock
|
||||
.suspected_resources
|
||||
@ -1827,6 +1896,10 @@ impl Global {
|
||||
let hub = A::hub(self);
|
||||
|
||||
if let Some(cache) = hub.pipeline_caches.unregister(pipeline_cache_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = cache.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyPipelineCache(pipeline_cache_id));
|
||||
}
|
||||
drop(cache)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
#[cfg(feature = "trace")]
|
||||
use crate::device::trace;
|
||||
pub use crate::pipeline_cache::PipelineCacheValidationError;
|
||||
use crate::{
|
||||
binding_model::{CreateBindGroupLayoutError, CreatePipelineLayoutError, PipelineLayout},
|
||||
@ -60,10 +58,7 @@ 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());
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyShaderModule(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_shader_module(raw);
|
||||
@ -237,11 +232,6 @@ impl<A: HalApi> Drop for ComputePipeline<A> {
|
||||
if let Some(raw) = self.raw.take() {
|
||||
resource_log!("Destroy raw ComputePipeline {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyComputePipeline(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_compute_pipeline(raw);
|
||||
@ -311,11 +301,6 @@ impl<A: HalApi> Drop for PipelineCache<A> {
|
||||
if let Some(raw) = self.raw.take() {
|
||||
resource_log!("Destroy raw PipelineCache {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyPipelineCache(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_pipeline_cache(raw);
|
||||
@ -576,11 +561,6 @@ impl<A: HalApi> Drop for RenderPipeline<A> {
|
||||
if let Some(raw) = self.raw.take() {
|
||||
resource_log!("Destroy raw RenderPipeline {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyRenderPipeline(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_render_pipeline(raw);
|
||||
|
@ -473,11 +473,6 @@ impl<A: HalApi> Drop for Buffer<A> {
|
||||
if let Some(raw) = self.raw.take() {
|
||||
resource_log!("Destroy raw Buffer (dropped) {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyBuffer(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_buffer(raw);
|
||||
@ -743,11 +738,6 @@ impl<A: HalApi> Buffer<A> {
|
||||
pub(crate) fn destroy(self: &Arc<Self>) -> Result<(), DestroyError> {
|
||||
let device = &self.device;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut trace) = *device.trace.lock() {
|
||||
trace.add(trace::Action::FreeBuffer(self.info.id()));
|
||||
}
|
||||
|
||||
let temp = {
|
||||
let snatch_guard = device.snatchable_lock.write();
|
||||
let raw = match self.raw.snatch(snatch_guard) {
|
||||
@ -1042,11 +1032,6 @@ impl<A: HalApi> Drop for Texture<A> {
|
||||
};
|
||||
|
||||
if let Some(TextureInner::Native { raw }) = self.inner.take() {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyTexture(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
self.device.raw().destroy_texture(raw);
|
||||
}
|
||||
@ -1126,11 +1111,6 @@ impl<A: HalApi> Texture<A> {
|
||||
pub(crate) fn destroy(self: &Arc<Self>) -> Result<(), DestroyError> {
|
||||
let device = &self.device;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(ref mut trace) = *device.trace.lock() {
|
||||
trace.add(trace::Action::FreeTexture(self.info.id()));
|
||||
}
|
||||
|
||||
let temp = {
|
||||
let snatch_guard = device.snatchable_lock.write();
|
||||
let raw = match self.inner.snatch(snatch_guard) {
|
||||
@ -1580,11 +1560,6 @@ impl<A: HalApi> Drop for TextureView<A> {
|
||||
if let Some(raw) = self.raw.take() {
|
||||
resource_log!("Destroy raw TextureView {:?}", self.info.label());
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyTextureView(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_texture_view(raw);
|
||||
@ -1725,11 +1700,6 @@ 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() {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroySampler(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_sampler(raw);
|
||||
@ -1835,11 +1805,6 @@ 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() {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = self.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyQuerySet(self.info.id()));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
use hal::Device;
|
||||
self.device.raw().destroy_query_set(raw);
|
||||
|
Loading…
Reference in New Issue
Block a user