Correctly support setSubData of 0 bytes.

DynamicUploader/RingBuffer were incorrectly assuming that they could not
get empty allocation requests. Fix this and add a test.

The test also surfaced a bug in the Metal backend where the command
recording context could be left with a blit encoder open that was not
properly handled on device shutdown.

Bug: chromium:1069076
Change-Id: I9793b37142bd509254ce2894fa9f6208e9a68048
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19291
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2020-04-16 09:51:26 +00:00
committed by Commit Bot service account
parent 0721c1cf2a
commit d3bbcc3334
5 changed files with 34 additions and 6 deletions

View File

@@ -249,6 +249,22 @@ TEST_P(BufferSetSubDataTests, SmallDataAtZero) {
EXPECT_BUFFER_U32_EQ(value, buffer, 0);
}
// Test the simplest set sub data: setting nothing
TEST_P(BufferSetSubDataTests, ZeroSized) {
wgpu::BufferDescriptor descriptor;
descriptor.size = 4;
descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
uint32_t initialValue = 0x42;
buffer.SetSubData(0, sizeof(initialValue), &initialValue);
buffer.SetSubData(0, 0, nullptr);
// The content of the buffer isn't changed
EXPECT_BUFFER_U32_EQ(initialValue, buffer, 0);
}
// Call SetSubData at offset 0 via a u32 twice. Test that data is updated accoordingly.
TEST_P(BufferSetSubDataTests, SetTwice) {
wgpu::BufferDescriptor descriptor;