Skip to content

Commit

Permalink
Merge #1050
Browse files Browse the repository at this point in the history
1050: player: use the wgpu-cores's gfx-select macro r=kvark a=kvark

**Connections**
Looks like I broke the player in #1034, surprised we didn't notice, and that `cargo test` still passed. The problem was having the `Empty` backend for the device.

**Description**
Fixes the `device` backend in the player, switches the backend set to be `PRIMARY`, and re-uses the `wgc::gfx-select`.

**Testing**
Replaying a trace from #1049

Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
  • Loading branch information
bors[bot] and kvark authored Nov 26, 2020
2 parents 75b4697 + cd08f84 commit d603bbb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions player/src/bin/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/*! This is a player for WebGPU traces.
!*/

use player::{gfx_select, GlobalPlay as _, IdentityPassThroughFactory};
use wgc::device::trace;
use player::{GlobalPlay as _, IdentityPassThroughFactory};
use wgc::{device::trace, gfx_select};

use std::{
fs,
Expand Down Expand Up @@ -55,8 +55,11 @@ fn main() {
.build(&event_loop)
.unwrap();

let global =
wgc::hub::Global::new("player", IdentityPassThroughFactory, wgt::BackendBit::all());
let global = wgc::hub::Global::new(
"player",
IdentityPassThroughFactory,
wgt::BackendBit::PRIMARY,
);
let mut command_buffer_id_manager = wgc::hub::IdentityManager::default();

#[cfg(feature = "winit")]
Expand Down Expand Up @@ -84,7 +87,7 @@ fn main() {

let info = gfx_select!(adapter => global.adapter_get_info(adapter)).unwrap();
log::info!("Picked '{}'", info.name);
let id = wgc::id::TypedId::zip(1, 0, wgt::Backend::Empty);
let id = wgc::id::TypedId::zip(1, 0, backend);
let (_, error) = gfx_select!(adapter => global.adapter_request_device(
adapter,
&desc,
Expand Down
17 changes: 0 additions & 17 deletions player/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@ use wgc::device::trace;

use std::{borrow::Cow, fmt::Debug, fs, marker::PhantomData, path::Path};

#[macro_export]
macro_rules! gfx_select {
($id:expr => $global:ident.$method:ident( $($param:expr),+ )) => {
match $id.backend() {
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
wgt::Backend::Vulkan => $global.$method::<wgc::backend::Vulkan>( $($param),+ ),
#[cfg(any(target_os = "ios", target_os = "macos"))]
wgt::Backend::Metal => $global.$method::<wgc::backend::Metal>( $($param),+ ),
#[cfg(windows)]
wgt::Backend::Dx12 => $global.$method::<wgc::backend::Dx12>( $($param),+ ),
#[cfg(windows)]
wgt::Backend::Dx11 => $global.$method::<wgc::backend::Dx11>( $($param),+ ),
_ => unreachable!()
}
};
}

#[derive(Debug)]
pub struct IdentityPassThrough<I>(PhantomData<I>);

Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ macro_rules! gfx_select {
wgt::Backend::Dx11 => $global.$method::<$crate::backend::Dx11>( $($param),* ),
#[cfg(all(unix, not(target_os = "ios")))]
wgt::Backend::Gl => $global.$method::<$crate::backend::Gl>( $($param),+ ),
_ => unreachable!()
other => panic!("Unexpected backend {:?}", other),
}
};
}
Expand Down

0 comments on commit d603bbb

Please sign in to comment.