-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement "internal_asserts" feature in wgpu-core.
Since `wgpu-core`'s public functions are supposed to validate their parameters, the internal `track` module skips many of Rust's usual run-time checks in release builds. However, some `wgpu-core` users are happy to pay the performance cost in exchange for more safety. The `"internal_asserts"` feature causes `wgpu_core` to perform the same checks in release builds as it does in debug builds.
- Loading branch information
Showing
9 changed files
with
144 additions
and
82 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
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,49 @@ | ||
//! Macros for validation internal to the resource tracker. | ||
//! | ||
//! This module defines assertion macros that respect `wgpu-core`'s | ||
//! `"internal_asserts"` feature. | ||
//! | ||
//! Because `wgpu-core`'s public APIs validate their arguments in all | ||
//! types of builds, for performance, the `track` module skips some of | ||
//! Rust's usual run-time checks on its internal operations in release | ||
//! builds. However, some `wgpu-core` applications have a strong | ||
//! preference for robustness over performance. To accommodate them, | ||
//! `wgpu-core`'s `"internal_asserts"` feature enables that validation | ||
//! in both debug and release builds. | ||
|
||
#[cfg(feature = "internal_asserts")] | ||
macro_rules! tracker_assert { | ||
( $( $arg:tt )* ) => { | ||
assert!( $( $arg )* ) | ||
} | ||
} | ||
|
||
#[cfg(feature = "internal_asserts")] | ||
macro_rules! tracker_assert_eq { | ||
( $( $arg:tt )* ) => { | ||
assert_eq!( $( $arg )* ) | ||
} | ||
} | ||
|
||
#[cfg(feature = "internal_asserts")] | ||
macro_rules! tracker_assert_ne { | ||
( $( $arg:tt )* ) => { | ||
assert_ne!( $( $arg )* ) | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "internal_asserts"))] | ||
#[macro_export] | ||
macro_rules! tracker_assert { | ||
( $( $arg:tt )* ) => {}; | ||
} | ||
|
||
#[cfg(not(feature = "internal_asserts"))] | ||
macro_rules! tracker_assert_eq { | ||
( $( $arg:tt )* ) => {}; | ||
} | ||
|
||
#[cfg(not(feature = "internal_asserts"))] | ||
macro_rules! tracker_assert_ne { | ||
( $( $arg:tt )* ) => {}; | ||
} |
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
Oops, something went wrong.