Resource Management 2: Buffer mapping error handling
Add error handling for buffer mapping ops. BUG=dawn:27 Change-Id: I9a66baf74c27b137990608c31cb04af8023594b0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9241 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
23dd12459c
commit
07b5be3bc5
|
@ -64,11 +64,13 @@ namespace dawn_native {
|
|||
UNREACHABLE();
|
||||
return {};
|
||||
}
|
||||
void MapReadAsyncImpl(uint32_t serial) override {
|
||||
MaybeError MapReadAsyncImpl(uint32_t serial) override {
|
||||
UNREACHABLE();
|
||||
return {};
|
||||
}
|
||||
void MapWriteAsyncImpl(uint32_t serial) override {
|
||||
MaybeError MapWriteAsyncImpl(uint32_t serial) override {
|
||||
UNREACHABLE();
|
||||
return {};
|
||||
}
|
||||
void UnmapImpl() override {
|
||||
UNREACHABLE();
|
||||
|
@ -244,7 +246,9 @@ namespace dawn_native {
|
|||
mMapUserdata = userdata;
|
||||
mState = BufferState::Mapped;
|
||||
|
||||
MapReadAsyncImpl(mMapSerial);
|
||||
if (GetDevice()->ConsumedError(MapReadAsyncImpl(mMapSerial))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MaybeError BufferBase::SetSubDataImpl(uint32_t start, uint32_t count, const void* data) {
|
||||
|
@ -282,7 +286,9 @@ namespace dawn_native {
|
|||
mMapUserdata = userdata;
|
||||
mState = BufferState::Mapped;
|
||||
|
||||
MapWriteAsyncImpl(mMapSerial);
|
||||
if (GetDevice()->ConsumedError(MapWriteAsyncImpl(mMapSerial))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void BufferBase::Destroy() {
|
||||
|
|
|
@ -82,8 +82,8 @@ namespace dawn_native {
|
|||
private:
|
||||
virtual MaybeError MapAtCreationImpl(uint8_t** mappedPointer) = 0;
|
||||
virtual MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data);
|
||||
virtual void MapReadAsyncImpl(uint32_t serial) = 0;
|
||||
virtual void MapWriteAsyncImpl(uint32_t serial) = 0;
|
||||
virtual MaybeError MapReadAsyncImpl(uint32_t serial) = 0;
|
||||
virtual MaybeError MapWriteAsyncImpl(uint32_t serial) = 0;
|
||||
virtual void UnmapImpl() = 0;
|
||||
virtual void DestroyImpl() = 0;
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
mWrittenMappedRange = {};
|
||||
D3D12_RANGE readRange = {0, GetSize()};
|
||||
char* data = nullptr;
|
||||
|
@ -225,9 +225,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
// writes available when the fence is passed.
|
||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
||||
tracker->Track(this, serial, data, false);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
mWrittenMappedRange = {0, GetSize()};
|
||||
char* data = nullptr;
|
||||
ASSERT_SUCCESS(mResource->Map(0, &mWrittenMappedRange, reinterpret_cast<void**>(&data)));
|
||||
|
@ -236,6 +237,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
// writes available on queue submission.
|
||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
||||
tracker->Track(this, serial, data, true);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::UnmapImpl() {
|
||||
|
|
|
@ -40,8 +40,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
private:
|
||||
// Dawn API
|
||||
void MapReadAsyncImpl(uint32_t serial) override;
|
||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||
void UnmapImpl() override;
|
||||
void DestroyImpl() override;
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
private:
|
||||
// Dawn API
|
||||
void MapReadAsyncImpl(uint32_t serial) override;
|
||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||
void UnmapImpl() override;
|
||||
void DestroyImpl() override;
|
||||
|
||||
|
|
|
@ -57,14 +57,16 @@ namespace dawn_native { namespace metal {
|
|||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
||||
tracker->Track(this, serial, false);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
||||
tracker->Track(this, serial, true);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::UnmapImpl() {
|
||||
|
|
|
@ -264,12 +264,14 @@ namespace dawn_native { namespace null {
|
|||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
MapAsyncImplCommon(serial, false);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
MapAsyncImplCommon(serial, true);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapAsyncImplCommon(uint32_t serial, bool isWrite) {
|
||||
|
|
|
@ -151,8 +151,8 @@ namespace dawn_native { namespace null {
|
|||
private:
|
||||
// Dawn API
|
||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data) override;
|
||||
void MapReadAsyncImpl(uint32_t serial) override;
|
||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||
void UnmapImpl() override;
|
||||
void DestroyImpl() override;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace dawn_native { namespace opengl {
|
|||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||
|
||||
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
||||
|
@ -66,9 +66,10 @@ namespace dawn_native { namespace opengl {
|
|||
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
|
||||
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||
|
||||
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
||||
|
@ -76,6 +77,7 @@ namespace dawn_native { namespace opengl {
|
|||
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::UnmapImpl() {
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace dawn_native { namespace opengl {
|
|||
private:
|
||||
// Dawn API
|
||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data) override;
|
||||
void MapReadAsyncImpl(uint32_t serial) override;
|
||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||
void UnmapImpl() override;
|
||||
void DestroyImpl() override;
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace dawn_native { namespace vulkan {
|
|||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
||||
|
@ -220,9 +220,10 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
||||
tracker->Track(this, serial, memory, false);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
||||
|
@ -233,6 +234,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
||||
tracker->Track(this, serial, memory, true);
|
||||
return {};
|
||||
}
|
||||
|
||||
void Buffer::UnmapImpl() {
|
||||
|
|
|
@ -42,8 +42,8 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
private:
|
||||
// Dawn API
|
||||
void MapReadAsyncImpl(uint32_t serial) override;
|
||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||
void UnmapImpl() override;
|
||||
void DestroyImpl() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue