Skip to content

Commit

Permalink
Add expose-ids feature (#3104)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyMrCat authored Nov 4, 2022
1 parent eda77e6 commit 6ed103e
Show file tree
Hide file tree
Showing 5 changed files with 386 additions and 90 deletions.
1 change: 1 addition & 0 deletions wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ angle = ["wgc/angle"]
webgl = ["wgc"]
emscripten = ["webgl"]
vulkan-portability = ["wgc/vulkan-portability"]
expose-ids = []

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc]
workspace = true
Expand Down
43 changes: 43 additions & 0 deletions wgpu/src/backend/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,49 @@ pub(crate) struct CommandEncoder {
open: bool,
}

pub(crate) type Id = (u32, u32, wgt::Backend);

impl<T: wgc::id::TypedId> crate::GlobalId for T {
fn global_id(&self) -> Id {
self.unzip()
}
}

impl crate::GlobalId for Surface {
fn global_id(&self) -> Id {
use wgc::id::TypedId;
self.id.unzip()
}
}

impl crate::GlobalId for Device {
fn global_id(&self) -> Id {
use wgc::id::TypedId;
self.id.unzip()
}
}

impl crate::GlobalId for Buffer {
fn global_id(&self) -> Id {
use wgc::id::TypedId;
self.id.unzip()
}
}

impl crate::GlobalId for Texture {
fn global_id(&self) -> Id {
use wgc::id::TypedId;
self.id.unzip()
}
}

impl crate::GlobalId for CommandEncoder {
fn global_id(&self) -> Id {
use wgc::id::TypedId;
self.id.unzip()
}
}

impl crate::Context for Context {
type AdapterId = wgc::id::AdapterId;
type DeviceId = Device;
Expand Down
4 changes: 2 additions & 2 deletions wgpu/src/backend/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
mod web;
#[cfg(all(target_arch = "wasm32", not(feature = "webgl")))]
pub(crate) use web::{BufferMappedRange, Context, QueueWriteBuffer};
pub(crate) use web::{BufferMappedRange, Context, Id, QueueWriteBuffer};

#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
mod direct;
#[cfg(any(not(target_arch = "wasm32"), feature = "webgl"))]
pub(crate) use direct::{BufferMappedRange, Context, QueueWriteBuffer};
pub(crate) use direct::{BufferMappedRange, Context, Id, QueueWriteBuffer};
Loading

0 comments on commit 6ed103e

Please sign in to comment.