Return an error ComputePassEncoder when error occurs in BeginComputePass

This patch is a follow-up of the descriptorization of render pass
descriptor. In this patch we changes the return value of
BeginComputePass from nullptr to an error compute pass encoder when
there is any error in BeginComputePass() to keep it consistent with what
we do in BeginRenderPass().

This patch also provides functions to create error render/compute pass
encoders. With this patch we can create a pass encoder in error by
specifying ErrorTag in the constructor, which is more staightforward
and human readable than the current implementation.

BUG=dawn:6

Change-Id: I1899ae65804f8cecd3079dc313e7e18acb88e37c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5140
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao
2019-03-05 01:02:47 +00:00
committed by Commit Bot service account
parent d6eb2e7501
commit b47470daa7
8 changed files with 81 additions and 7 deletions

View File

@@ -130,6 +130,31 @@ TEST_F(CommandBufferValidationTest, ComputePassEndedTwice) {
}
}
// Test that beginning a compute pass before ending the previous pass causes an error.
TEST_F(CommandBufferValidationTest, BeginComputePassBeforeEndPreviousPass) {
DummyRenderPass dummyRenderPass(device);
// Beginning a compute pass before ending a render pass causes an error.
{
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = encoder.BeginRenderPass(&dummyRenderPass);
dawn::ComputePassEncoder computePass = encoder.BeginComputePass();
computePass.EndPass();
renderPass.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
// Beginning a compute pass before ending a compute pass causes an error.
{
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::ComputePassEncoder computePass1 = encoder.BeginComputePass();
dawn::ComputePassEncoder computePass2 = encoder.BeginComputePass();
computePass2.EndPass();
computePass1.EndPass();
ASSERT_DEVICE_ERROR(encoder.Finish());
}
}
// Test that using a single buffer in multiple read usages in the same pass is allowed.
TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
// Create a buffer used as both vertex and index buffer.