Rename Empty backend to Noop.

This is in preparation for making it a more substantial test stub,
able to execute nontrivial code, and usable from the safe `wgpu` API.
This commit is contained in:
Kevin Reid
2025-02-10 21:54:44 -08:00
committed by Connor Fitzgerald
parent ff907736ef
commit 0143b4aaa0
8 changed files with 16 additions and 18 deletions

View File

@@ -3,7 +3,7 @@
//! and run the tests through them.
//!
//! Test requirements:
//! - all IDs have the backend `Empty`
//! - all IDs have the backend `Noop`
//! - all expected buffers have `MAP_READ` usage
//! - last action is `Submit`
//! - no swapchain use
@@ -74,9 +74,7 @@ impl Test<'_> {
wgt::Backend::Gl => "Gl",
_ => unreachable!(),
};
let string = read_to_string(&path)
.unwrap()
.replace("Empty", backend_name);
let string = read_to_string(&path).unwrap().replace("Noop", backend_name);
ron::de::from_str(&string)
.unwrap_or_else(|e| panic!("{path:?}:{} {}", e.position.line, e.code))
}

View File

@@ -4,8 +4,8 @@ pub trait HalApi: hal::Api + 'static + WasmNotSendSync {
const VARIANT: Backend;
}
impl HalApi for hal::api::Empty {
const VARIANT: Backend = Backend::Empty;
impl HalApi for hal::api::Noop {
const VARIANT: Backend = Backend::Noop;
}
#[cfg(vulkan)]

View File

@@ -65,11 +65,11 @@ impl RawId {
/// any backend, but the corresponding resource types ([`Texture<A>`], for
/// example) are always parameterized by a specific backend `A`.
///
/// So the `T` in `Id<T>` is usually a resource type like `Texture<Empty>`,
/// where [`Empty`] is the `wgpu_hal` dummy back end. These empty types are
/// So the `T` in `Id<T>` is usually a resource type like `Texture<Noop>`,
/// where [`Noop`] is the `wgpu_hal` dummy back end. These empty types are
/// never actually used, beyond just making sure you access each `Storage` with
/// the right kind of identifier. The members of [`Hub<A>`] pair up each
/// `X<Empty>` type with the resource type `X<A>`, for some specific backend
/// `X<Noop>` type with the resource type `X<A>`, for some specific backend
/// `A`.
///
/// [`Global`]: crate::global::Global
@@ -77,7 +77,7 @@ impl RawId {
/// [`Hub<A>`]: crate::hub::Hub
/// [`Texture<A>`]: crate::resource::Texture
/// [`Registry`]: crate::hub::Registry
/// [`Empty`]: hal::api::Empty
/// [`Noop`]: hal::api::Noop
#[repr(transparent)]
#[cfg_attr(any(feature = "serde", feature = "trace"), derive(serde::Serialize))]
#[cfg_attr(any(feature = "serde", feature = "replay"), derive(serde::Deserialize))]

View File

@@ -815,7 +815,7 @@ cfg_if::cfg_if! {
}
// Fallback
else {
type Api = hal::api::Empty;
type Api = hal::api::Noop;
}
}

View File

@@ -1129,7 +1129,7 @@ cfg_if::cfg_if! {
}
// Fallback
else {
type Api = hal::api::Empty;
type Api = hal::api::Noop;
}
}

View File

@@ -239,14 +239,14 @@ extern crate wgpu_types as wgt;
/// DirectX12 API internals.
#[cfg(dx12)]
pub mod dx12;
/// A dummy API implementation.
pub mod empty;
/// GLES API internals.
#[cfg(gles)]
pub mod gles;
/// Metal API internals.
#[cfg(metal)]
pub mod metal;
/// A dummy API implementation.
pub mod noop;
/// Vulkan API internals.
#[cfg(vulkan)]
pub mod vulkan;
@@ -255,11 +255,11 @@ pub mod auxil;
pub mod api {
#[cfg(dx12)]
pub use super::dx12::Api as Dx12;
pub use super::empty::Api as Empty;
#[cfg(gles)]
pub use super::gles::Api as Gles;
#[cfg(metal)]
pub use super::metal::Api as Metal;
pub use super::noop::Api as Noop;
#[cfg(vulkan)]
pub use super::vulkan::Api as Vulkan;
}

View File

@@ -75,8 +75,8 @@ pub const QUERY_SIZE: u32 = 8;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Backend {
/// Dummy backend, used for testing.
Empty = 0,
/// Dummy backend, which may be used for testing.
Noop = 0,
/// Vulkan API (Windows, Linux, Android, MacOS via `vulkan-portability`/MoltenVK)
Vulkan = 1,
/// Metal API (Apple platforms)
@@ -94,7 +94,7 @@ impl Backend {
#[must_use]
pub const fn to_str(self) -> &'static str {
match self {
Backend::Empty => "empty",
Backend::Noop => "noop",
Backend::Vulkan => "vulkan",
Backend::Metal => "metal",
Backend::Dx12 => "dx12",