From 4b4922cdcecc83ac431759238eea81f1c8148a19 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Mon, 26 Jun 2017 10:57:45 -0400 Subject: [PATCH] Allow empty B->T copies This adds a test that empty copies are valid for B->B copies too. Tests for B->T will come in a follow up commit. --- src/backend/common/CommandBuffer.cpp | 5 ---- .../CopyCommandsValidationTests.cpp | 25 +++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/backend/common/CommandBuffer.cpp b/src/backend/common/CommandBuffer.cpp index c24a42a1b2..121b4da520 100644 --- a/src/backend/common/CommandBuffer.cpp +++ b/src/backend/common/CommandBuffer.cpp @@ -250,11 +250,6 @@ namespace backend { uint64_t z = copy->z; uint32_t level = copy->level; - if (width == 0 || height == 0 || depth == 0) { - HandleError("Empty copy"); - return false; - } - // TODO(cwallez@chromium.org): check for overflows uint64_t pixelSize = TextureFormatPixelSize(texture->GetFormat()); uint64_t dataSize = width * height * depth * pixelSize; diff --git a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp index a39115806b..d083840cfa 100644 --- a/src/tests/unittests/validation/CopyCommandsValidationTests.cpp +++ b/src/tests/unittests/validation/CopyCommandsValidationTests.cpp @@ -32,14 +32,25 @@ TEST_F(CopyCommandTest_B2B, Success) { destination.FreezeUsage(nxt::BufferUsageBit::TransferDst); // Copy different copies, including some that touch the OOB condition - nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) - .CopyBufferToBuffer(source, 0, destination, 0, 16) - .CopyBufferToBuffer(source, 8, destination, 0, 8) - .CopyBufferToBuffer(source, 0, destination, 8, 8) - .GetResult(); + { + nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) + .CopyBufferToBuffer(source, 0, destination, 0, 16) + .CopyBufferToBuffer(source, 8, destination, 0, 8) + .CopyBufferToBuffer(source, 0, destination, 8, 8) + .GetResult(); + } + + // Empty copies are valid + { + nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) + .CopyBufferToBuffer(source, 0, destination, 0, 0) + .CopyBufferToBuffer(source, 0, destination, 16, 0) + .CopyBufferToBuffer(source, 16, destination, 0, 0) + .GetResult(); + } } -// Test B2B copies with overflows +// Test B2B copies with OOB TEST_F(CopyCommandTest_B2B, OutOfBounds) { nxt::Buffer source = device.CreateBufferBuilder() .SetSize(16) @@ -68,7 +79,7 @@ TEST_F(CopyCommandTest_B2B, OutOfBounds) { } } -// Test B2B copies with overflows +// Test B2B copies with incorrect buffer usage TEST_F(CopyCommandTest_B2B, BadUsage) { nxt::Buffer source = device.CreateBufferBuilder() .SetSize(16)