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.
This commit is contained in:
Corentin Wallez 2017-06-26 10:57:45 -04:00 committed by Corentin Wallez
parent eaae746433
commit 4b4922cdce
2 changed files with 18 additions and 12 deletions

View File

@ -250,11 +250,6 @@ namespace backend {
uint64_t z = copy->z; uint64_t z = copy->z;
uint32_t level = copy->level; uint32_t level = copy->level;
if (width == 0 || height == 0 || depth == 0) {
HandleError("Empty copy");
return false;
}
// TODO(cwallez@chromium.org): check for overflows // TODO(cwallez@chromium.org): check for overflows
uint64_t pixelSize = TextureFormatPixelSize(texture->GetFormat()); uint64_t pixelSize = TextureFormatPixelSize(texture->GetFormat());
uint64_t dataSize = width * height * depth * pixelSize; uint64_t dataSize = width * height * depth * pixelSize;

View File

@ -32,6 +32,7 @@ TEST_F(CopyCommandTest_B2B, Success) {
destination.FreezeUsage(nxt::BufferUsageBit::TransferDst); destination.FreezeUsage(nxt::BufferUsageBit::TransferDst);
// Copy different copies, including some that touch the OOB condition // Copy different copies, including some that touch the OOB condition
{
nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder()) nxt::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
.CopyBufferToBuffer(source, 0, destination, 0, 16) .CopyBufferToBuffer(source, 0, destination, 0, 16)
.CopyBufferToBuffer(source, 8, destination, 0, 8) .CopyBufferToBuffer(source, 8, destination, 0, 8)
@ -39,7 +40,17 @@ TEST_F(CopyCommandTest_B2B, Success) {
.GetResult(); .GetResult();
} }
// Test B2B copies with overflows // 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 OOB
TEST_F(CopyCommandTest_B2B, OutOfBounds) { TEST_F(CopyCommandTest_B2B, OutOfBounds) {
nxt::Buffer source = device.CreateBufferBuilder() nxt::Buffer source = device.CreateBufferBuilder()
.SetSize(16) .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) { TEST_F(CopyCommandTest_B2B, BadUsage) {
nxt::Buffer source = device.CreateBufferBuilder() nxt::Buffer source = device.CreateBufferBuilder()
.SetSize(16) .SetSize(16)