Skip to content

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
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

andyleiserson
Copy link
Contributor

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

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • Add a CHANGELOG.md entry.

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.
@andyleiserson andyleiserson requested review from crowlKats and a team as code owners June 18, 2025 00:55
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;
Copy link
Member

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.

Copy link
Member

@teoxoy teoxoy left a 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants