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;
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;

View File

@ -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)