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();
|
UNREACHABLE();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
void MapReadAsyncImpl(uint32_t serial) override {
|
MaybeError MapReadAsyncImpl(uint32_t serial) override {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
void MapWriteAsyncImpl(uint32_t serial) override {
|
MaybeError MapWriteAsyncImpl(uint32_t serial) override {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
void UnmapImpl() override {
|
void UnmapImpl() override {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -244,7 +246,9 @@ namespace dawn_native {
|
||||||
mMapUserdata = userdata;
|
mMapUserdata = userdata;
|
||||||
mState = BufferState::Mapped;
|
mState = BufferState::Mapped;
|
||||||
|
|
||||||
MapReadAsyncImpl(mMapSerial);
|
if (GetDevice()->ConsumedError(MapReadAsyncImpl(mMapSerial))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError BufferBase::SetSubDataImpl(uint32_t start, uint32_t count, const void* data) {
|
MaybeError BufferBase::SetSubDataImpl(uint32_t start, uint32_t count, const void* data) {
|
||||||
|
@ -282,7 +286,9 @@ namespace dawn_native {
|
||||||
mMapUserdata = userdata;
|
mMapUserdata = userdata;
|
||||||
mState = BufferState::Mapped;
|
mState = BufferState::Mapped;
|
||||||
|
|
||||||
MapWriteAsyncImpl(mMapSerial);
|
if (GetDevice()->ConsumedError(MapWriteAsyncImpl(mMapSerial))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferBase::Destroy() {
|
void BufferBase::Destroy() {
|
||||||
|
|
|
@ -82,8 +82,8 @@ namespace dawn_native {
|
||||||
private:
|
private:
|
||||||
virtual MaybeError MapAtCreationImpl(uint8_t** mappedPointer) = 0;
|
virtual MaybeError MapAtCreationImpl(uint8_t** mappedPointer) = 0;
|
||||||
virtual MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data);
|
virtual MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data);
|
||||||
virtual void MapReadAsyncImpl(uint32_t serial) = 0;
|
virtual MaybeError MapReadAsyncImpl(uint32_t serial) = 0;
|
||||||
virtual void MapWriteAsyncImpl(uint32_t serial) = 0;
|
virtual MaybeError MapWriteAsyncImpl(uint32_t serial) = 0;
|
||||||
virtual void UnmapImpl() = 0;
|
virtual void UnmapImpl() = 0;
|
||||||
virtual void DestroyImpl() = 0;
|
virtual void DestroyImpl() = 0;
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
mWrittenMappedRange = {};
|
mWrittenMappedRange = {};
|
||||||
D3D12_RANGE readRange = {0, GetSize()};
|
D3D12_RANGE readRange = {0, GetSize()};
|
||||||
char* data = nullptr;
|
char* data = nullptr;
|
||||||
|
@ -225,9 +225,10 @@ namespace dawn_native { namespace d3d12 {
|
||||||
// writes available when the fence is passed.
|
// writes available when the fence is passed.
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, data, false);
|
tracker->Track(this, serial, data, false);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
mWrittenMappedRange = {0, GetSize()};
|
mWrittenMappedRange = {0, GetSize()};
|
||||||
char* data = nullptr;
|
char* data = nullptr;
|
||||||
ASSERT_SUCCESS(mResource->Map(0, &mWrittenMappedRange, reinterpret_cast<void**>(&data)));
|
ASSERT_SUCCESS(mResource->Map(0, &mWrittenMappedRange, reinterpret_cast<void**>(&data)));
|
||||||
|
@ -236,6 +237,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
// writes available on queue submission.
|
// writes available on queue submission.
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, data, true);
|
tracker->Track(this, serial, data, true);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -40,8 +40,8 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void MapReadAsyncImpl(uint32_t serial) override;
|
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void MapReadAsyncImpl(uint32_t serial) override;
|
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,16 @@ namespace dawn_native { namespace metal {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
||||||
tracker->Track(this, serial, false);
|
tracker->Track(this, serial, false);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
|
||||||
tracker->Track(this, serial, true);
|
tracker->Track(this, serial, true);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -264,12 +264,14 @@ namespace dawn_native { namespace null {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
MapAsyncImplCommon(serial, false);
|
MapAsyncImplCommon(serial, false);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
MapAsyncImplCommon(serial, true);
|
MapAsyncImplCommon(serial, true);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapAsyncImplCommon(uint32_t serial, bool isWrite) {
|
void Buffer::MapAsyncImplCommon(uint32_t serial, bool isWrite) {
|
||||||
|
|
|
@ -151,8 +151,8 @@ namespace dawn_native { namespace null {
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data) override;
|
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data) override;
|
||||||
void MapReadAsyncImpl(uint32_t serial) override;
|
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace dawn_native { namespace opengl {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||||
|
|
||||||
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
// 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);
|
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||||
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
|
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
|
||||||
CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
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;
|
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
|
||||||
|
|
||||||
// TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
|
// 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);
|
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
||||||
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||||
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data, GetSize());
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace dawn_native { namespace opengl {
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data) override;
|
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const void* data) override;
|
||||||
void MapReadAsyncImpl(uint32_t serial) override;
|
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapReadAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapReadAsyncImpl(uint32_t serial) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
||||||
|
@ -220,9 +220,10 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, memory, false);
|
tracker->Track(this, serial, memory, false);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
MaybeError Buffer::MapWriteAsyncImpl(uint32_t serial) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
|
|
||||||
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
VkCommandBuffer commands = device->GetPendingCommandBuffer();
|
||||||
|
@ -233,6 +234,7 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
MapRequestTracker* tracker = device->GetMapRequestTracker();
|
||||||
tracker->Track(this, serial, memory, true);
|
tracker->Track(this, serial, memory, true);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Buffer::UnmapImpl() {
|
void Buffer::UnmapImpl() {
|
||||||
|
|
|
@ -42,8 +42,8 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void MapReadAsyncImpl(uint32_t serial) override;
|
MaybeError MapReadAsyncImpl(uint32_t serial) override;
|
||||||
void MapWriteAsyncImpl(uint32_t serial) override;
|
MaybeError MapWriteAsyncImpl(uint32_t serial) override;
|
||||||
void UnmapImpl() override;
|
void UnmapImpl() override;
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue