Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #24883 - szeged:id_management, r=jdm
Add WebGPU identity management <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes addresses a part of #24706 <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> cc @jdm, @kvark, @zakorgy <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
- Loading branch information
Showing
6 changed files
with
72 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
use webgpu::wgpu::{AdapterId, Backend, DeviceId, IdentityManager, SurfaceId}; | ||
|
||
#[derive(Debug)] | ||
pub struct IdentityHub { | ||
adapters: IdentityManager<AdapterId>, | ||
devices: IdentityManager<DeviceId>, | ||
} | ||
|
||
impl IdentityHub { | ||
fn new(backend: Backend) -> Self { | ||
IdentityHub { | ||
adapters: IdentityManager::new(backend), | ||
devices: IdentityManager::new(backend), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Identities { | ||
surface: IdentityManager<SurfaceId>, | ||
hub: IdentityHub, | ||
} | ||
|
||
impl Identities { | ||
pub fn new() -> Self { | ||
let hub = if cfg!(any(target_os = "linux", target_os = "windows")) { | ||
IdentityHub::new(Backend::Vulkan) | ||
} else if cfg!(any(target_os = "ios", target_os = "macos")) { | ||
IdentityHub::new(Backend::Metal) | ||
} else { | ||
IdentityHub::new(Backend::Empty) | ||
}; | ||
|
||
Identities { | ||
surface: IdentityManager::new(Backend::Empty), | ||
hub, | ||
} | ||
} | ||
|
||
pub fn create_adapter_id(&mut self) -> AdapterId { | ||
self.hub.adapters.alloc() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters