Print warning if errors occur and no error callback has been set

Bug: none
Change-Id: Ibbd6f90be5192ad3975bb8b24f9b3053f7f9d74f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32744
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Austin Eng 2020-11-16 23:32:36 +00:00 committed by Commit Bot service account
parent 0055d95fa7
commit f2bc3b3edd
2 changed files with 47 additions and 0 deletions

View File

@ -101,6 +101,31 @@ namespace dawn_native {
mRootErrorScope = AcquireRef(new ErrorScope());
mCurrentErrorScope = mRootErrorScope.Get();
#if defined(DAWN_ENABLE_ASSERTS)
mRootErrorScope->SetCallback(
[](WGPUErrorType, char const*, void*) {
static bool calledOnce = false;
if (!calledOnce) {
calledOnce = true;
dawn::WarningLog()
<< "No Dawn device uncaptured error callback was set. This is "
"probably not intended. If you really want to ignore errors "
"and suppress this message, set the callback to null.";
}
},
nullptr);
mDeviceLostCallback = [](char const*, void*) {
static bool calledOnce = false;
if (!calledOnce) {
calledOnce = true;
dawn::WarningLog() << "No Dawn device lost callback was set. This is probably not "
"intended. If you really want to ignore device lost "
"and suppress this message, set the callback to null.";
}
};
#endif // DAWN_ENABLE_ASSERTS
mCaches = std::make_unique<DeviceBase::Caches>();
mErrorScopeTracker = std::make_unique<ErrorScopeTracker>(this);
mDynamicUploader = std::make_unique<DynamicUploader>(this);

View File

@ -15,6 +15,7 @@
#include "dawn_wire/client/Device.h"
#include "common/Assert.h"
#include "common/Log.h"
#include "dawn_wire/client/ApiObjects_autogen.h"
#include "dawn_wire/client/Client.h"
#include "dawn_wire/client/ObjectAllocator.h"
@ -23,6 +24,27 @@ namespace dawn_wire { namespace client {
Device::Device(Client* client, uint32_t initialRefcount, uint32_t initialId)
: ObjectBase(this, initialRefcount, initialId), mClient(client) {
#if defined(DAWN_ENABLE_ASSERTS)
mErrorCallback = [](WGPUErrorType, char const*, void*) {
static bool calledOnce = false;
if (!calledOnce) {
calledOnce = true;
dawn::WarningLog() << "No Dawn device uncaptured error callback was set. This is "
"probably not intended. If you really want to ignore errors "
"and suppress this message, set the callback to null.";
}
};
mDeviceLostCallback = [](char const*, void*) {
static bool calledOnce = false;
if (!calledOnce) {
calledOnce = true;
dawn::WarningLog() << "No Dawn device lost callback was set. This is probably not "
"intended. If you really want to ignore device lost "
"and suppress this message, set the callback to null.";
}
};
#endif // DAWN_ENABLE_ASSERTS
// Get the default queue for this device.
auto* allocation = mClient->QueueAllocator().New(this);
mDefaultQueue = allocation->object.get();