Skip to content

Commit 6043b05

Browse files
Tweak error behavior for unbalanced passes, and update CTS (#8543)
1 parent 836c970 commit 6043b05

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

cts_runner/revision.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
cf8d39399889ae8324f77b6017071b3e1bfe3467
1+
ca488e91d0bace04c9c393bd733053da0b84ce11

wgpu-core/src/command/compute.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -491,22 +491,21 @@ impl Global {
491491

492492
let base = pass.base.take();
493493

494-
if matches!(
495-
base,
496-
Err(ComputePassError {
497-
inner: ComputePassErrorInner::EncoderState(EncoderStateError::Ended),
498-
scope: _,
499-
})
500-
) {
501-
// If the encoder was already finished at time of pass creation,
502-
// then it was not put in the locked state, so we need to
503-
// generate a validation error here and now due to the encoder not
504-
// being locked. The encoder already holds an error from when the
505-
// pass was opened, or earlier.
494+
if let Err(ComputePassError {
495+
inner:
496+
ComputePassErrorInner::EncoderState(
497+
err @ (EncoderStateError::Locked | EncoderStateError::Ended),
498+
),
499+
scope: _,
500+
}) = base
501+
{
502+
// Most encoding errors are detected and raised within `finish()`.
506503
//
507-
// All other errors are propagated to the encoder within `push_with`,
508-
// and will be reported later.
509-
return Err(EncoderStateError::Ended);
504+
// However, we raise a validation error here if the pass was opened
505+
// within another pass, or on a finished encoder. The latter is
506+
// particularly important, because in that case reporting errors via
507+
// `CommandEncoder::finish` is not possible.
508+
return Err(err.clone());
510509
}
511510

512511
cmd_buf_data.push_with(|| -> Result<_, ComputePassError> {

wgpu-core/src/command/render.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,22 +1823,21 @@ impl Global {
18231823

18241824
let base = pass.base.take();
18251825

1826-
if matches!(
1827-
base,
1828-
Err(RenderPassError {
1829-
inner: RenderPassErrorInner::EncoderState(EncoderStateError::Ended),
1830-
scope: _,
1831-
})
1832-
) {
1833-
// If the encoder was already finished at time of pass creation,
1834-
// then it was not put in the locked state, so we need to
1835-
// generate a validation error here and now due to the encoder not
1836-
// being locked. The encoder already holds an error from when the
1837-
// pass was opened, or earlier.
1826+
if let Err(RenderPassError {
1827+
inner:
1828+
RenderPassErrorInner::EncoderState(
1829+
err @ (EncoderStateError::Locked | EncoderStateError::Ended),
1830+
),
1831+
scope: _,
1832+
}) = base
1833+
{
1834+
// Most encoding errors are detected and raised within `finish()`.
18381835
//
1839-
// All other errors are propagated to the encoder within `push_with`,
1840-
// and will be reported later.
1841-
return Err(EncoderStateError::Ended);
1836+
// However, we raise a validation error here if the pass was opened
1837+
// within another pass, or on a finished encoder. The latter is
1838+
// particularly important, because in that case reporting errors via
1839+
// `CommandEncoder::finish` is not possible.
1840+
return Err(err.clone());
18421841
}
18431842

18441843
cmd_buf_data.push_with(|| -> Result<_, RenderPassError> {

0 commit comments

Comments
 (0)