Commit 7d70a62f by Courtney Goeltzenleuchter Committed by Commit Bot

Vulkan: refactor error info

Consolidate error info into a structure in preparation of threading work. Also preserves the meaning of the data until it's rendered to a string for consumption by GL. Bug: b/154030730 Change-Id: I8cde7133c817d77fdb117efc1c11edc94f615da3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2468537 Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent d4b35199
...@@ -26,6 +26,7 @@ DisplayVk::DisplayVk(const egl::DisplayState &state) ...@@ -26,6 +26,7 @@ DisplayVk::DisplayVk(const egl::DisplayState &state)
: DisplayImpl(state), : DisplayImpl(state),
vk::Context(new RendererVk()), vk::Context(new RendererVk()),
mScratchBuffer(1000u), mScratchBuffer(1000u),
mSavedError({VK_SUCCESS, "", "", 0}),
mHasSurfaceWithRobustInit(false) mHasSurfaceWithRobustInit(false)
{} {}
...@@ -267,14 +268,15 @@ void DisplayVk::handleError(VkResult result, ...@@ -267,14 +268,15 @@ void DisplayVk::handleError(VkResult result,
{ {
ASSERT(result != VK_SUCCESS); ASSERT(result != VK_SUCCESS);
std::stringstream errorStream; mSavedError.mErrorCode = result;
errorStream << "Internal Vulkan error (" << result << "): " << VulkanResultString(result) mSavedError.mFile = file;
<< ", in " << file << ", " << function << ":" << line << "."; mSavedError.mFunction = function;
mStoredErrorString = errorStream.str(); mSavedError.mLine = line;
if (result == VK_ERROR_DEVICE_LOST) if (result == VK_ERROR_DEVICE_LOST)
{ {
WARN() << mStoredErrorString; WARN() << "Internal Vulkan error (" << result << "): " << VulkanResultString(result)
<< ", in " << file << ", " << function << ":" << line << ".";
mRenderer->notifyDeviceLost(); mRenderer->notifyDeviceLost();
} }
} }
...@@ -282,7 +284,14 @@ void DisplayVk::handleError(VkResult result, ...@@ -282,7 +284,14 @@ void DisplayVk::handleError(VkResult result,
// TODO(jmadill): Remove this. http://anglebug.com/3041 // TODO(jmadill): Remove this. http://anglebug.com/3041
egl::Error DisplayVk::getEGLError(EGLint errorCode) egl::Error DisplayVk::getEGLError(EGLint errorCode)
{ {
return egl::Error(errorCode, 0, std::move(mStoredErrorString)); std::stringstream errorStream;
errorStream << "Internal Vulkan error (" << mSavedError.mErrorCode
<< "): " << VulkanResultString(mSavedError.mErrorCode) << ", in "
<< mSavedError.mFile << ", " << mSavedError.mFunction << ":" << mSavedError.mLine
<< ".";
std::string errorString = errorStream.str();
return egl::Error(errorCode, 0, std::move(errorString));
} }
void DisplayVk::populateFeatureList(angle::FeatureList *features) void DisplayVk::populateFeatureList(angle::FeatureList *features)
......
...@@ -140,7 +140,7 @@ class DisplayVk : public DisplayImpl, public vk::Context ...@@ -140,7 +140,7 @@ class DisplayVk : public DisplayImpl, public vk::Context
mutable angle::ScratchBuffer mScratchBuffer; mutable angle::ScratchBuffer mScratchBuffer;
std::string mStoredErrorString; vk::Error mSavedError;
bool mHasSurfaceWithRobustInit; bool mHasSurfaceWithRobustInit;
}; };
......
...@@ -151,6 +151,14 @@ void AddToPNextChain(VulkanStruct1 *chainStart, VulkanStruct2 *ptr) ...@@ -151,6 +151,14 @@ void AddToPNextChain(VulkanStruct1 *chainStart, VulkanStruct2 *ptr)
localPtr->pNext = reinterpret_cast<VkBaseOutStructure *>(ptr); localPtr->pNext = reinterpret_cast<VkBaseOutStructure *>(ptr);
} }
struct Error
{
VkResult mErrorCode;
const char *mFile;
const char *mFunction;
unsigned int mLine;
};
// Abstracts error handling. Implemented by both ContextVk for GL and DisplayVk for EGL errors. // Abstracts error handling. Implemented by both ContextVk for GL and DisplayVk for EGL errors.
class Context : angle::NonCopyable class Context : angle::NonCopyable
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment