зеркало из https://github.com/AvaloniaUI/angle.git
Vulkan: need to serialize access to mFenceRecycler
It's possible for multiple threads to touch mFenceRecycler so need to protect it with a mutex to prevent race conditions. Bug: b/168744476 Change-Id: I9898d2e9ebf0974581a1074cbda5be41a09cd790 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2415401 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
This commit is contained in:
Родитель
512059a99c
Коммит
3c64fe30ca
|
@ -512,7 +512,10 @@ void RendererVk::onDestroy()
|
|||
|
||||
mOneOffCommandPool.destroy(mDevice);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mFenceRecyclerMutex);
|
||||
mFenceRecycler.destroy(mDevice);
|
||||
}
|
||||
|
||||
mPipelineLayoutCache.destroy(mDevice);
|
||||
mDescriptorSetLayoutCache.destroy(mDevice);
|
||||
|
@ -2205,19 +2208,27 @@ VkResult RendererVk::queuePresent(egl::ContextPriority priority,
|
|||
angle::Result RendererVk::newSharedFence(vk::Context *context,
|
||||
vk::Shared<vk::Fence> *sharedFenceOut)
|
||||
{
|
||||
bool gotRecycledFence = false;
|
||||
vk::Fence fence;
|
||||
if (mFenceRecycler.empty())
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mFenceRecyclerMutex);
|
||||
if (!mFenceRecycler.empty())
|
||||
{
|
||||
mFenceRecycler.fetch(&fence);
|
||||
gotRecycledFence = true;
|
||||
}
|
||||
}
|
||||
if (gotRecycledFence)
|
||||
{
|
||||
ANGLE_VK_TRY(context, fence.reset(mDevice));
|
||||
}
|
||||
else
|
||||
{
|
||||
VkFenceCreateInfo fenceCreateInfo = {};
|
||||
fenceCreateInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||
fenceCreateInfo.flags = 0;
|
||||
ANGLE_VK_TRY(context, fence.init(mDevice, fenceCreateInfo));
|
||||
}
|
||||
else
|
||||
{
|
||||
mFenceRecycler.fetch(&fence);
|
||||
ANGLE_VK_TRY(context, fence.reset(mDevice));
|
||||
}
|
||||
sharedFenceOut->assign(mDevice, std::move(fence));
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
|
|
@ -200,6 +200,7 @@ class RendererVk : angle::NonCopyable
|
|||
angle::Result newSharedFence(vk::Context *context, vk::Shared<vk::Fence> *sharedFenceOut);
|
||||
inline void resetSharedFence(vk::Shared<vk::Fence> *sharedFenceIn)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mFenceRecyclerMutex);
|
||||
sharedFenceIn->resetAndRecycle(&mFenceRecycler);
|
||||
}
|
||||
|
||||
|
@ -336,6 +337,7 @@ class RendererVk : angle::NonCopyable
|
|||
|
||||
bool mDeviceLost;
|
||||
|
||||
std::mutex mFenceRecyclerMutex;
|
||||
vk::Recycler<vk::Fence> mFenceRecycler;
|
||||
|
||||
std::mutex mGarbageMutex;
|
||||
|
|
Загрузка…
Ссылка в новой задаче