Skip to content

Commit

Permalink
EncodingContext: Fix ASSERT when encoding on ended pass.
Browse files Browse the repository at this point in the history
When ValidateCanEncodeOn was processing the State::Open case, it
ASSERTed that we were in the case where the top level encoder is used
while locked, while this code path could also be reached when encoding
on an ended pass.

Adds a regression test.

Bug: 361717709, 361992469
Change-Id: I7d088cb46e092b122516834e033258e7603e63ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/204034
Reviewed-by: Brandon Jones <[email protected]>
Reviewed-by: Loko Kung <[email protected]>
Reviewed-by: Brandon Jones <[email protected]>
Auto-Submit: Corentin Wallez <[email protected]>
Commit-Queue: Loko Kung <[email protected]>
  • Loading branch information
Kangz authored and Dawn LUCI CQ committed Aug 26, 2024
1 parent b07b920 commit 92be693
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/dawn/native/EncodingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ class EncodingContext {
// change.
DAWN_INVALID_IF(encoder->IsError(), "Recording in an error %s.", encoder);

// The top level encoder was used when a pass encoder was current.
DAWN_ASSERT(mCurrentEncoder != mTopLevelEncoder);
// This happens when the CommandEncoder is used while a pass is open.
DAWN_INVALID_IF(encoder == mTopLevelEncoder,
"Recording in %s which is locked while %s is open.", encoder,
mCurrentEncoder);

// The remaining case is when an encoder is ended but we still try to encode
// commands in it.
return DAWN_VALIDATION_ERROR(
"Command cannot be recorded while %s is locked and %s is currently open.",
mTopLevelEncoder, mCurrentEncoder);
"Commands cannot be recorded in %s which has already been ended.", encoder);
}
}
return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,14 @@ TEST_F(CommandBufferValidationTest, EncodeAfterDeviceDestroyed) {
}
}

// Test that an error is produced when encoding happens after ending a pass.
TEST_F(CommandBufferValidationTest, EncodeAfterEndingPass) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
pass.End();
pass.PushDebugGroup("Foo");
ASSERT_DEVICE_ERROR(encoder.Finish());
}

} // anonymous namespace
} // namespace dawn

0 comments on commit 92be693

Please sign in to comment.