From 1cc548a7a24461663e6a96ce982328ea7b0c0956 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 28 Apr 2020 13:54:57 -0400 Subject: [PATCH] Make descriptors generic over Label --- wgpu-core/src/device/mod.rs | 66 +++++++++++++++++++++++++----- wgpu-core/src/device/trace.rs | 30 +++++++++++++- wgpu-core/src/swap_chain.rs | 19 +++++++++ wgpu-types/src/lib.rs | 76 +++++++++++++++++++++++++++++++---- 4 files changed, 174 insertions(+), 17 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index f220877ac..5b24a82a8 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -32,10 +32,22 @@ use std::{ mod life; #[cfg(feature = "trace")] -mod trace; +pub(crate) mod trace; #[cfg(feature = "trace")] use trace::{Action, Trace}; +pub type Label = *const std::os::raw::c_char; +#[cfg(feature = "trace")] +fn own_label(label: &Label) -> String { + if label.is_null() { + String::new() + } else { + unsafe { ffi::CStr::from_ptr(*label) } + .to_string_lossy() + .to_string() + } +} + pub const MAX_COLOR_TARGETS: usize = 4; pub const MAX_MIP_LEVELS: usize = 16; pub const MAX_VERTEX_BUFFERS: usize = 16; @@ -200,7 +212,7 @@ pub struct Device { pub(crate) private_features: PrivateFeatures, limits: wgt::Limits, #[cfg(feature = "trace")] - trace: Option>, + pub(crate) trace: Option>, } impl Device { @@ -293,7 +305,7 @@ impl Device { fn create_buffer( &self, self_id: id::DeviceId, - desc: &wgt::BufferDescriptor, + desc: &wgt::BufferDescriptor