Skip to content

Commit

Permalink
Update docs for Backend and implement std::fmt::Display instead o…
Browse files Browse the repository at this point in the history
…f custom to_str method
  • Loading branch information
Wumpf committed Jan 31, 2024
1 parent 0888a63 commit e4397a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub async fn compare_image_output(
let file_stem = reference_path.file_stem().unwrap().to_string_lossy();
let renderer = format!(
"{}-{}-{}",
adapter_info.backend.to_str(),
adapter_info.backend,
sanitize_for_path(&adapter_info.name),
sanitize_for_path(&adapter_info.driver)
);
Expand Down
13 changes: 6 additions & 7 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,28 @@ pub const QUERY_SIZE: u32 = 8;
pub enum Backend {
/// Dummy backend, used for testing.
Empty = 0,
/// Vulkan API
/// Vulkan API (Windows, Linux, Android, MacOS via `vulkan-portability`/MoltenVK)
Vulkan = 1,
/// Metal API (Apple platforms)
Metal = 2,
/// Direct3D-12 (Windows)
Dx12 = 3,
/// OpenGL ES-3 (Linux, Android)
/// OpenGL ES-3 (Linux, Android, Browser WebGL, Windows, MacOS (via Angle))
Gl = 4,
/// WebGPU in the browser
BrowserWebGpu = 5,
}

impl Backend {
/// Returns the string name of the backend.
pub fn to_str(self) -> &'static str {
match self {
impl std::fmt::Display for Backend {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Backend::Empty => "empty",
Backend::Vulkan => "vulkan",
Backend::Metal => "metal",
Backend::Dx12 => "dx12",
Backend::Gl => "gl",
Backend::BrowserWebGpu => "webgpu",
}
})
}
}

Expand Down

0 comments on commit e4397a9

Please sign in to comment.