Deprecates PopErrorScope returning a bool.

Bug: dawn:526
Change-Id: Ia4e985fbe4fcb5edb3fe80849f5b0df0190eea00
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130340
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Loko Kung 2023-05-01 19:25:18 +00:00 committed by Dawn LUCI CQ
parent fab65123e1
commit 4e9ebeff02
6 changed files with 15 additions and 22 deletions

View File

@ -1203,7 +1203,6 @@
},
{
"name": "pop error scope",
"returns": "bool",
"args": [
{"name": "callback", "type": "error callback"},
{"name": "userdata", "type": "void", "annotation": "*"}

View File

@ -631,9 +631,7 @@ void DeviceBase::APIPushErrorScope(wgpu::ErrorFilter filter) {
mErrorScopeStack->Push(filter);
}
bool DeviceBase::APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata) {
// TODO(crbug.com/dawn/1324) Remove return and make function void when users are updated.
bool returnValue = true;
void DeviceBase::APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata) {
if (callback == nullptr) {
static wgpu::ErrorCallback defaultCallback = [](WGPUErrorType, char const*, void*) {};
callback = defaultCallback;
@ -642,20 +640,18 @@ bool DeviceBase::APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata)
if (IsLost()) {
mCallbackTaskManager->AddCallbackTask(
std::bind(callback, WGPUErrorType_DeviceLost, "GPU device disconnected", userdata));
return returnValue;
return;
}
if (mErrorScopeStack->Empty()) {
mCallbackTaskManager->AddCallbackTask(
std::bind(callback, WGPUErrorType_Unknown, "No error scopes to pop", userdata));
return returnValue;
return;
}
ErrorScope scope = mErrorScopeStack->Pop();
mCallbackTaskManager->AddCallbackTask(
[callback, errorType = static_cast<WGPUErrorType>(scope.GetErrorType()),
message = scope.GetErrorMessage(),
userdata] { callback(errorType, message.c_str(), userdata); });
return returnValue;
}
BlobCache* DeviceBase::GetBlobCache() {

View File

@ -309,7 +309,7 @@ class DeviceBase : public RefCountedWithExternalCount {
void APISetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);
void APISetLoggingCallback(wgpu::LoggingCallback callback, void* userdata);
void APIPushErrorScope(wgpu::ErrorFilter filter);
bool APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata);
void APIPopErrorScope(wgpu::ErrorCallback callback, void* userdata);
MaybeError ValidateIsAlive() const;

View File

@ -149,7 +149,7 @@ TEST_F(WireErrorCallbackTests, PushPopErrorScopeCallback) {
WGPUErrorCallback callback;
void* userdata;
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true)));
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata)));
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
FlushClient();
@ -174,8 +174,8 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) {
void* userdata1;
void* userdata2;
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
.WillOnce(DoAll(SaveArg<1>(&callback1), SaveArg<2>(&userdata1), Return(true)))
.WillOnce(DoAll(SaveArg<1>(&callback2), SaveArg<2>(&userdata2), Return(true)));
.WillOnce(DoAll(SaveArg<1>(&callback1), SaveArg<2>(&userdata1)))
.WillOnce(DoAll(SaveArg<1>(&callback2), SaveArg<2>(&userdata2)));
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1);
FlushClient();
@ -205,8 +205,8 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeCallbackOrdering) {
void* userdata1;
void* userdata2;
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
.WillOnce(DoAll(SaveArg<1>(&callback1), SaveArg<2>(&userdata1), Return(true)))
.WillOnce(DoAll(SaveArg<1>(&callback2), SaveArg<2>(&userdata2), Return(true)));
.WillOnce(DoAll(SaveArg<1>(&callback1), SaveArg<2>(&userdata1)))
.WillOnce(DoAll(SaveArg<1>(&callback2), SaveArg<2>(&userdata2)));
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this + 1);
FlushClient();
@ -231,7 +231,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeDeviceInFlightDestroy) {
wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
FlushClient();
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _)).WillOnce(Return(true));
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _)).Times(1);
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
FlushClient();
@ -248,7 +248,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeThenDisconnect) {
EXPECT_CALL(api, DevicePushErrorScope(apiDevice, WGPUErrorFilter_Validation)).Times(1);
wgpuDevicePushErrorScope(device, WGPUErrorFilter_Validation);
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _)).WillOnce(Return(true));
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _)).Times(1);
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
FlushClient();
@ -278,7 +278,7 @@ TEST_F(WireErrorCallbackTests, PopErrorScopeEmptyStack) {
WGPUErrorCallback callback;
void* userdata;
EXPECT_CALL(api, OnDevicePopErrorScope(apiDevice, _, _))
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata), Return(true)));
.WillOnce(DoAll(SaveArg<1>(&callback), SaveArg<2>(&userdata)));
wgpuDevicePopErrorScope(device, ToMockDevicePopErrorScopeCallback, this);
FlushClient();

View File

@ -148,12 +148,11 @@ void Device::SetDeviceLostCallback(WGPUDeviceLostCallback callback, void* userda
mDeviceLostUserdata = userdata;
}
bool Device::PopErrorScope(WGPUErrorCallback callback, void* userdata) {
// TODO(crbug.com/dawn/1324) Replace bool return with void when users are updated.
void Device::PopErrorScope(WGPUErrorCallback callback, void* userdata) {
Client* client = GetClient();
if (client->IsDisconnected()) {
callback(WGPUErrorType_DeviceLost, "GPU device disconnected", userdata);
return true;
return;
}
uint64_t serial = mErrorScopes.Add({callback, userdata});
@ -161,7 +160,6 @@ bool Device::PopErrorScope(WGPUErrorCallback callback, void* userdata) {
cmd.deviceId = GetWireId();
cmd.requestSerial = serial;
client->SerializeCommand(cmd);
return true;
}
bool Device::OnPopErrorScopeCallback(uint64_t requestSerial,

View File

@ -39,7 +39,7 @@ class Device final : public ObjectBase {
void SetLoggingCallback(WGPULoggingCallback errorCallback, void* errorUserdata);
void SetDeviceLostCallback(WGPUDeviceLostCallback errorCallback, void* errorUserdata);
void InjectError(WGPUErrorType type, const char* message);
bool PopErrorScope(WGPUErrorCallback callback, void* userdata);
void PopErrorScope(WGPUErrorCallback callback, void* userdata);
WGPUBuffer CreateBuffer(const WGPUBufferDescriptor* descriptor);
WGPUBuffer CreateErrorBuffer(const WGPUBufferDescriptor* descriptor);
void CreateComputePipelineAsync(WGPUComputePipelineDescriptor const* descriptor,