зеркало из https://github.com/AvaloniaUI/angle.git
Vulkan: Lock around handle counter.
TSAN showed we could have a data race when multiple threads were releasing objects because of the singleton handle counter. Bug: angleproject:6714 Change-Id: I23b5d343bec421a663198e7efc30c78dab2bde8f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3288328 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Родитель
8700d9ccb7
Коммит
5f755c2906
|
@ -3617,6 +3617,18 @@ angle::Result RendererVk::getFormatDescriptorCountForExternalFormat(ContextVk *c
|
|||
return angle::Result::Stop;
|
||||
}
|
||||
|
||||
void RendererVk::onAllocateHandle(vk::HandleType handleType)
|
||||
{
|
||||
std::lock_guard<std::mutex> localLock(mActiveHandleCountsMutex);
|
||||
mActiveHandleCounts.onAllocate(handleType);
|
||||
}
|
||||
|
||||
void RendererVk::onDeallocateHandle(vk::HandleType handleType)
|
||||
{
|
||||
std::lock_guard<std::mutex> localLock(mActiveHandleCountsMutex);
|
||||
mActiveHandleCounts.onDeallocate(handleType);
|
||||
}
|
||||
|
||||
namespace vk
|
||||
{
|
||||
MemoryReport::MemoryReport()
|
||||
|
|
|
@ -405,7 +405,9 @@ class RendererVk : angle::NonCopyable
|
|||
|
||||
SamplerCache &getSamplerCache() { return mSamplerCache; }
|
||||
SamplerYcbcrConversionCache &getYuvConversionCache() { return mYuvConversionCache; }
|
||||
vk::ActiveHandleCounter &getActiveHandleCounts() { return mActiveHandleCounts; }
|
||||
|
||||
void onAllocateHandle(vk::HandleType handleType);
|
||||
void onDeallocateHandle(vk::HandleType handleType);
|
||||
|
||||
bool getEnableValidationLayers() const { return mEnableValidationLayers; }
|
||||
|
||||
|
@ -639,6 +641,7 @@ class RendererVk : angle::NonCopyable
|
|||
SamplerYcbcrConversionCache mYuvConversionCache;
|
||||
angle::HashMap<VkFormat, uint32_t> mVkFormatDescriptorCountMap;
|
||||
vk::ActiveHandleCounter mActiveHandleCounts;
|
||||
std::mutex mActiveHandleCountsMutex;
|
||||
|
||||
// Tracks resource serials.
|
||||
vk::ResourceSerialFactory mResourceSerialFactory;
|
||||
|
|
|
@ -3829,7 +3829,7 @@ void SamplerYcbcrConversionCache::destroy(RendererVk *rendererVk)
|
|||
ASSERT(!yuvSampler.isReferenced());
|
||||
yuvSampler.get().destroy(device);
|
||||
|
||||
rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::SamplerYcbcrConversion);
|
||||
rendererVk->onDeallocateHandle(vk::HandleType::SamplerYcbcrConversion);
|
||||
}
|
||||
|
||||
for (auto &iter : mVkFormatPayload)
|
||||
|
@ -3838,7 +3838,7 @@ void SamplerYcbcrConversionCache::destroy(RendererVk *rendererVk)
|
|||
ASSERT(!yuvSampler.isReferenced());
|
||||
yuvSampler.get().destroy(device);
|
||||
|
||||
rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::SamplerYcbcrConversion);
|
||||
rendererVk->onDeallocateHandle(vk::HandleType::SamplerYcbcrConversion);
|
||||
}
|
||||
|
||||
mExternalFormatPayload.clear();
|
||||
|
@ -3871,8 +3871,7 @@ angle::Result SamplerYcbcrConversionCache::getYuvConversionImpl(
|
|||
vk::RefCountedSamplerYcbcrConversion &insertedYuvConversion = insertedItem.first->second;
|
||||
yuvConversionOut->set(&insertedYuvConversion);
|
||||
|
||||
context->getRenderer()->getActiveHandleCounts().onAllocate(
|
||||
vk::HandleType::SamplerYcbcrConversion);
|
||||
context->getRenderer()->onAllocateHandle(vk::HandleType::SamplerYcbcrConversion);
|
||||
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
@ -3948,7 +3947,7 @@ void SamplerCache::destroy(RendererVk *rendererVk)
|
|||
ASSERT(!sampler.isReferenced());
|
||||
sampler.get().get().destroy(device);
|
||||
|
||||
rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::Sampler);
|
||||
rendererVk->onDeallocateHandle(vk::HandleType::Sampler);
|
||||
}
|
||||
|
||||
mPayload.clear();
|
||||
|
@ -3976,7 +3975,7 @@ angle::Result SamplerCache::getSampler(ContextVk *contextVk,
|
|||
vk::RefCountedSampler &insertedSampler = insertedItem.first->second;
|
||||
samplerOut->set(&insertedSampler);
|
||||
|
||||
contextVk->getRenderer()->getActiveHandleCounts().onAllocate(vk::HandleType::Sampler);
|
||||
contextVk->getRenderer()->onAllocateHandle(vk::HandleType::Sampler);
|
||||
|
||||
return angle::Result::Continue;
|
||||
}
|
||||
|
|
|
@ -890,7 +890,7 @@ void GarbageObject::destroy(RendererVk *renderer)
|
|||
break;
|
||||
}
|
||||
|
||||
renderer->getActiveHandleCounts().onDeallocate(mHandleType);
|
||||
renderer->onDeallocateHandle(mHandleType);
|
||||
}
|
||||
|
||||
void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT *label)
|
||||
|
|
Загрузка…
Ссылка в новой задаче