
# Objective * Remove all uses of render_resource_wrapper. * Make it easier to share a `wgpu::Device` between Bevy and application code. ## Solution Removed the `render_resource_wrapper` macro. To improve the `RenderCreation:: Manual ` API, `ErasedRenderDevice` was replaced by `Arc`. Unfortunately I had to introduce one more usage of `WgpuWrapper` which seems like an unwanted constraint on the caller. ## Testing - Did you test these changes? If so, how? - Ran `cargo test`. - Ran a few examples. - Used `RenderCreation::Manual` in my own project - Exercised `RenderCreation::Automatic` through examples - Are there any parts that need more testing? - No - How can other people (reviewers) test your changes? Is there anything specific they need to know? - Run examples - Use `RenderCreation::Manual` in their own project
38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
#[macro_export]
|
|
macro_rules! define_atomic_id {
|
|
($atomic_id_type:ident) => {
|
|
#[derive(Copy, Clone, Hash, Eq, PartialEq, PartialOrd, Ord, Debug)]
|
|
pub struct $atomic_id_type(core::num::NonZero<u32>);
|
|
|
|
// We use new instead of default to indicate that each ID created will be unique.
|
|
#[allow(clippy::new_without_default)]
|
|
impl $atomic_id_type {
|
|
pub fn new() -> Self {
|
|
use core::sync::atomic::{AtomicU32, Ordering};
|
|
|
|
static COUNTER: AtomicU32 = AtomicU32::new(1);
|
|
|
|
let counter = COUNTER.fetch_add(1, Ordering::Relaxed);
|
|
Self(core::num::NonZero::<u32>::new(counter).unwrap_or_else(|| {
|
|
panic!(
|
|
"The system ran out of unique `{}`s.",
|
|
stringify!($atomic_id_type)
|
|
);
|
|
}))
|
|
}
|
|
}
|
|
|
|
impl From<$atomic_id_type> for core::num::NonZero<u32> {
|
|
fn from(value: $atomic_id_type) -> Self {
|
|
value.0
|
|
}
|
|
}
|
|
|
|
impl From<core::num::NonZero<u32>> for $atomic_id_type {
|
|
fn from(value: core::num::NonZero<u32>) -> Self {
|
|
Self(value)
|
|
}
|
|
}
|
|
};
|
|
}
|