Bug 1879928 - Fix ErrorBuffer::GetError() handling in ReadbackPresentCallback() r=webgpu-reviewers,nical

Add ErrorBuffer::GetError() handling to wgpu_server_buffer_get_mapped_range() in ReadbackPresentCallback()
and call ForwardError(), if possible.

Differential Revision: https://phabricator.services.mozilla.com/D201790
This commit is contained in:
sotaro
2024-02-15 01:43:01 +00:00
parent aa3a599c30
commit cad8205f3c
2 changed files with 10 additions and 5 deletions

View File

@@ -994,7 +994,9 @@ static void ReadbackPresentCallback(ffi::WGPUBufferMapAsyncStatus status,
ErrorBuffer getRangeError;
const auto mapped = ffi::wgpu_server_buffer_get_mapped_range(
req->mContext, bufferId, 0, bufferSize, getRangeError.ToFFI());
if (auto innerError = getRangeError.GetError()) {
if (req->mData->mParent) {
req->mData->mParent->ForwardError(data->mDeviceId, getRangeError);
} else if (auto innerError = getRangeError.GetError()) {
// If an error occured in get_mapped_range, treat it as an internal error
// and crash. The error handling story for something unexpected happening
// during the present glue needs to befigured out in a more global way.
@@ -1027,7 +1029,9 @@ static void ReadbackPresentCallback(ffi::WGPUBufferMapAsyncStatus status,
}
ErrorBuffer unmapError;
wgpu_server_buffer_unmap(req->mContext, bufferId, unmapError.ToFFI());
if (auto innerError = unmapError.GetError()) {
if (req->mData->mParent) {
req->mData->mParent->ForwardError(data->mDeviceId, unmapError);
} else if (auto innerError = unmapError.GetError()) {
MOZ_LOG(sLogger, LogLevel::Info,
("WebGPU present: buffer unmap failed: %s\n",
innerError->message.get()));

View File

@@ -168,6 +168,10 @@ class WebGPUParent final : public PWebGPUParent, public SupportsWeakPtr {
const layers::RemoteTextureId aRemoteTextureId,
const layers::RemoteTextureOwnerId aOwnerId);
bool ForwardError(const RawId aDeviceId, ErrorBuffer& aError) {
return ForwardError(Some(aDeviceId), aError);
}
private:
static void MapCallback(ffi::WGPUBufferMapAsyncStatus aStatus,
uint8_t* aUserData);
@@ -182,9 +186,6 @@ class WebGPUParent final : public PWebGPUParent, public SupportsWeakPtr {
void LoseDevice(const RawId aDeviceId, Maybe<uint8_t> aReason,
const nsACString& aMessage);
bool ForwardError(const RawId aDeviceId, ErrorBuffer& aError) {
return ForwardError(Some(aDeviceId), aError);
}
bool ForwardError(Maybe<RawId> aDeviceId, ErrorBuffer& aError);
void ReportError(Maybe<RawId> aDeviceId, GPUErrorFilter,