dawn_native: Do CommandBufferStateTracker validation at encoding time

This is the last piece of validation that was done in a separate
validation pass so the validation pass is removed.

Bug: dawn:635
Change-Id: I91ce5d5a512ac188f3dd56c90db9e69aee518844
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38845
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez
2021-01-28 14:44:15 +00:00
committed by Commit Bot service account
parent 57fcd17625
commit 05045e0ad8
9 changed files with 25 additions and 301 deletions

View File

@@ -61,6 +61,10 @@ namespace dawn_native {
void ComputePassEncoder::Dispatch(uint32_t x, uint32_t y, uint32_t z) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
if (IsValidationEnabled()) {
DAWN_TRY(mCommandBufferState.ValidateCanDispatch());
}
DispatchCmd* dispatch = allocator->Allocate<DispatchCmd>(Command::Dispatch);
dispatch->x = x;
dispatch->y = y;
@@ -75,6 +79,7 @@ namespace dawn_native {
if (IsValidationEnabled()) {
DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer));
DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect));
DAWN_TRY(mCommandBufferState.ValidateCanDispatch());
// Indexed dispatches need a compute-shader based validation to check that the
// dispatch sizes aren't too big. Disallow them as unsafe until the validation is
@@ -113,6 +118,8 @@ namespace dawn_native {
DAWN_TRY(GetDevice()->ValidateObject(pipeline));
}
mCommandBufferState.SetComputePipeline(pipeline);
SetComputePipelineCmd* cmd =
allocator->Allocate<SetComputePipelineCmd>(Command::SetComputePipeline);
cmd->pipeline = pipeline;