Ensure no VVL message is ignored and doesn't cause test failures.

Messages could be ignored if:
 - They are not associated to any device (for example an issue around
   instance or adapter operations)
 - They happened between the last Tick() and device destruction.

Fix both cases to print the error to the dawn::ErrorLog and crash in
debug so that the errors are visible.

Bug: chromium:1258986
Change-Id: I9a88cd078c60b42deb2336da038902639f9a35ae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104360
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Corentin Wallez 2022-10-03 23:07:23 +00:00 committed by Dawn LUCI CQ
parent 40b5d01b06
commit 4ff00cc470
3 changed files with 29 additions and 4 deletions

View File

@ -134,11 +134,10 @@ OnDebugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
return VK_FALSE;
}
dawn::ErrorLog() << pCallbackData->pMessage;
if (pUserData == nullptr) {
return VK_FALSE;
}
VulkanInstance* instance = reinterpret_cast<VulkanInstance*>(pUserData);
// Look through all the object labels attached to the debug message and try to parse
// a device debug prefix out of one of them. If a debug prefix is found and matches
@ -150,12 +149,16 @@ OnDebugUtilsCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
continue;
}
VulkanInstance* instance = reinterpret_cast<VulkanInstance*>(pUserData);
if (instance->HandleDeviceMessage(std::move(deviceDebugPrefix), pCallbackData->pMessage)) {
break;
return VK_FALSE;
}
}
// We get to this line if no device was associated with the message. Crash so that the failure
// is loud and makes tests fail in Debug.
dawn::ErrorLog() << pCallbackData->pMessage;
UNREACHABLE();
return VK_FALSE;
}

View File

@ -14,6 +14,7 @@
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/common/Log.h"
#include "dawn/common/NonCopyable.h"
#include "dawn/common/Platform.h"
#include "dawn/native/BackendConnection.h"
@ -978,6 +979,21 @@ void Device::AppendDebugLayerMessages(ErrorData* error) {
}
}
void Device::CheckDebugMessagesAfterDestruction() const {
if (!GetAdapter()->GetInstance()->IsBackendValidationEnabled() || mDebugMessages.empty()) {
return;
}
dawn::ErrorLog()
<< "Some VVL messages were not handled before dawn::native::vulkan::Device destruction:";
for (const auto& message : mDebugMessages) {
dawn::ErrorLog() << " - " << message;
}
// Crash in debug
UNREACHABLE();
}
MaybeError Device::WaitForIdleForDestruction() {
// Immediately tag the recording context as unused so we don't try to submit it in Tick.
// Move the mRecordingContext.used to mUnusedCommands so it can be cleaned up in
@ -1127,6 +1143,11 @@ void Device::DestroyImpl() {
ASSERT(mVkDevice != VK_NULL_HANDLE);
fn.DestroyDevice(mVkDevice, nullptr);
mVkDevice = VK_NULL_HANDLE;
// No additonal Vulkan commands should be done by this device after this function. Check for any
// remaining Vulkan Validation Layer messages that may have been added during destruction or not
// handled prior to destruction.
CheckDebugMessagesAfterDestruction();
}
uint32_t Device::GetOptimalBytesPerRowAlignment() const {

View File

@ -166,6 +166,7 @@ class Device final : public DeviceBase {
MaybeError CheckDebugLayerAndGenerateErrors();
void AppendDebugLayerMessages(ErrorData* error) override;
void CheckDebugMessagesAfterDestruction() const;
void DestroyImpl() override;
MaybeError WaitForIdleForDestruction() override;