-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Report errors when CommandEncoder.finish
is called
#7820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andyleiserson
wants to merge
8
commits into
gfx-rs:trunk
Choose a base branch
from
andyleiserson:errors-on-finish
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,259
−931
Conversation
This file contains hidden or 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
The render_pass_commands debug scope tests may be doing something unintentional -- they make debug scopes on the encoder, not the pass. Which is still an interesting case, so a dedicated test should be added if this is fixed in render_pass_commands and one doesn't already exist.
7 tasks
teoxoy
reviewed
Jun 23, 2025
Comment on lines
+900
to
+932
macro_rules! pass_base { | ||
($pass:expr, $scope:expr $(,)?) => { | ||
match (&$pass.parent, &$pass.base.error) { | ||
// Attempting to record a command on a finished encoder raises a | ||
// validation error. | ||
(&None, _) => return Err(EncoderStateError::Ended).map_pass_err($scope), | ||
|
||
// Attempting to record a command on an open but invalid pass (i.e. | ||
// a pass with a stored error) fails silently. (The stored error | ||
// will be transferred to the parent encoder when the pass is ended, | ||
// and then raised as a validation error when `finish()` is called | ||
// for the parent). | ||
(&Some(_), &Some(_)) => return Ok(()), | ||
|
||
// Happy path | ||
(&Some(_), &None) => &mut $pass.base, | ||
} | ||
}; | ||
} | ||
pub(crate) use pass_base; | ||
|
||
macro_rules! pass_try { | ||
($base:expr, $scope:expr, $res:expr $(,)?) => { | ||
match $res.map_pass_err($scope) { | ||
Ok(val) => val, | ||
Err(err) => { | ||
$base.error.get_or_insert(err); | ||
return Ok(()); | ||
} | ||
} | ||
}; | ||
} | ||
pub(crate) use pass_try; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could these 2 macros be methods on the pass/base instead? Ideally we shouldn't have hidden control flow inside macros.
teoxoy
reviewed
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This has the rest of the error reporting changes for #7391. I don't think there is urgency to get these changes in before the train leaves, but it's probably better to take either all of them or none of them than to take some of them, so here's a PR with all of them. It can be reviewed commit-by-commit if that's easier.
As in the other PRs, turning on the "hide whitespace" option will substantially reduce the diff.
Testing
Enables relevant CTS tests, and updates some wgpu tests that are sensitive to the timing of error reporting.
Squash or Rebase? Rebase, but check for fixups that should be squashed first.
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.