CommandEncoder: promote errors to device errors after finish()

BUG=dawn:138

Change-Id: Iddb1aab886558c706d0188adc21c7ee8f68533d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6720
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-04-25 20:14:32 +00:00 committed by Commit Bot service account
parent 3826880f81
commit ef90079944
3 changed files with 35 additions and 11 deletions

View File

@ -824,9 +824,13 @@ namespace dawn_native {
// Implementation of functions to interact with sub-encoders
void CommandEncoderBase::HandleError(const char* message) {
if (!mGotError) {
mGotError = true;
mErrorMessage = message;
if (mEncodingState != EncodingState::Finished) {
if (!mGotError) {
mGotError = true;
mErrorMessage = message;
}
} else {
GetDevice()->HandleError(message);
}
}

View File

@ -155,8 +155,28 @@ TEST_F(CommandBufferValidationTest, BeginComputePassBeforeEndPreviousPass) {
}
}
// Test that beginning a compute pass before ending the previous pass causes an error.
// Test that encoding command after a successful finish produces an error
TEST_F(CommandBufferValidationTest, CallsAfterASuccessfulFinish) {
// A buffer that can be used in CopyBufferToBuffer
dawn::BufferDescriptor copyBufferDesc;
copyBufferDesc.size = 16;
copyBufferDesc.usage = dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst;
dawn::Buffer copyBuffer = device.CreateBuffer(&copyBufferDesc);
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
encoder.Finish();
ASSERT_DEVICE_ERROR(encoder.CopyBufferToBuffer(copyBuffer, 0, copyBuffer, 0, 0));
}
// Test that encoding command after a failed finish produces an error
TEST_F(CommandBufferValidationTest, CallsAfterAFailedFinish) {
// A buffer that can be used in CopyBufferToBuffer
dawn::BufferDescriptor copyBufferDesc;
copyBufferDesc.size = 16;
copyBufferDesc.usage = dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst;
dawn::Buffer copyBuffer = device.CreateBuffer(&copyBufferDesc);
// A buffer that can't be used in CopyBufferToBuffer
dawn::BufferDescriptor bufferDesc;
bufferDesc.size = 16;
@ -167,8 +187,7 @@ TEST_F(CommandBufferValidationTest, CallsAfterAFailedFinish) {
encoder.CopyBufferToBuffer(buffer, 0, buffer, 0, 0);
ASSERT_DEVICE_ERROR(encoder.Finish());
// TODO(cwallez@chromium.org): Currently this does nothing, should it be a device error?
encoder.CopyBufferToBuffer(buffer, 0, buffer, 0, 0);
ASSERT_DEVICE_ERROR(encoder.CopyBufferToBuffer(copyBuffer, 0, copyBuffer, 0, 0));
}
// Test that using a single buffer in multiple read usages in the same pass is allowed.

View File

@ -34,31 +34,32 @@ TEST_F(SetScissorRectTest, Success) {
TEST_F(SetScissorRectTest, EmptyScissor) {
DummyRenderPass renderPass(device);
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
// Width of scissor rect is zero.
{
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, 0, 1);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
ASSERT_DEVICE_ERROR(encoder.Finish());
// Height of scissor rect is zero.
{
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, 1, 0);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
ASSERT_DEVICE_ERROR(encoder.Finish());
// Both width and height of scissor rect are zero.
{
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetScissorRect(0, 0, 0, 0);
pass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Test to check that a scissor larger than the framebuffer is allowed