Commit e1f7e2de by Courtney Goeltzenleuchter Committed by Commit Bot

Vulkan: lock around accesses to mSharedGarbage

Bug: b/168744476 Change-Id: I26205e7d29260ffdefbd5b2971b570c8bff7187f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2416236 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 fbab23e1
...@@ -480,7 +480,13 @@ RendererVk::~RendererVk() ...@@ -480,7 +480,13 @@ RendererVk::~RendererVk()
{ {
mAllocator.release(); mAllocator.release();
mPipelineCache.release(); mPipelineCache.release();
ASSERT(mSharedGarbage.empty()); ASSERT(!hasSharedGarbage());
}
bool RendererVk::hasSharedGarbage()
{
std::lock_guard<std::mutex> lock(mGarbageMutex);
return !mSharedGarbage.empty();
} }
void RendererVk::onDestroy() void RendererVk::onDestroy()
...@@ -503,7 +509,7 @@ void RendererVk::onDestroy() ...@@ -503,7 +509,7 @@ void RendererVk::onDestroy()
// Then assign an infinite "last completed" serial to force garbage to delete. // Then assign an infinite "last completed" serial to force garbage to delete.
mLastCompletedQueueSerial = Serial::Infinite(); mLastCompletedQueueSerial = Serial::Infinite();
(void)cleanupGarbage(true); (void)cleanupGarbage(true);
ASSERT(mSharedGarbage.empty()); ASSERT(!hasSharedGarbage());
for (PendingOneOffCommands &pending : mPendingOneOffCommands) for (PendingOneOffCommands &pending : mPendingOneOffCommands)
{ {
...@@ -2271,7 +2277,7 @@ bool RendererVk::hasFormatFeatureBits(VkFormat format, const VkFormatFeatureFlag ...@@ -2271,7 +2277,7 @@ bool RendererVk::hasFormatFeatureBits(VkFormat format, const VkFormatFeatureFlag
angle::Result RendererVk::cleanupGarbage(bool block) angle::Result RendererVk::cleanupGarbage(bool block)
{ {
std::lock_guard<decltype(mGarbageMutex)> lock(mGarbageMutex); std::lock_guard<std::mutex> lock(mGarbageMutex);
for (auto garbageIter = mSharedGarbage.begin(); garbageIter != mSharedGarbage.end();) for (auto garbageIter = mSharedGarbage.begin(); garbageIter != mSharedGarbage.end();)
{ {
......
...@@ -83,6 +83,7 @@ class RendererVk : angle::NonCopyable ...@@ -83,6 +83,7 @@ class RendererVk : angle::NonCopyable
void notifyDeviceLost(); void notifyDeviceLost();
bool isDeviceLost() const; bool isDeviceLost() const;
bool hasSharedGarbage();
std::string getVendorString() const; std::string getVendorString() const;
std::string getRendererDescription() const; std::string getRendererDescription() const;
...@@ -226,6 +227,7 @@ class RendererVk : angle::NonCopyable ...@@ -226,6 +227,7 @@ class RendererVk : angle::NonCopyable
{ {
if (!sharedGarbage.empty()) if (!sharedGarbage.empty())
{ {
std::lock_guard<std::mutex> lock(mGarbageMutex);
mSharedGarbage.emplace_back(std::move(use), std::move(sharedGarbage)); mSharedGarbage.emplace_back(std::move(use), std::move(sharedGarbage));
} }
} }
......
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