Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expose-ids feature #3104

Merged
merged 7 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
package = "wgpu-core"
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 @@ -801,6 +801,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