зеркало из 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;
|
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
|
namespace vk
|
||||||
{
|
{
|
||||||
MemoryReport::MemoryReport()
|
MemoryReport::MemoryReport()
|
||||||
|
|
|
@ -405,7 +405,9 @@ class RendererVk : angle::NonCopyable
|
||||||
|
|
||||||
SamplerCache &getSamplerCache() { return mSamplerCache; }
|
SamplerCache &getSamplerCache() { return mSamplerCache; }
|
||||||
SamplerYcbcrConversionCache &getYuvConversionCache() { return mYuvConversionCache; }
|
SamplerYcbcrConversionCache &getYuvConversionCache() { return mYuvConversionCache; }
|
||||||
vk::ActiveHandleCounter &getActiveHandleCounts() { return mActiveHandleCounts; }
|
|
||||||
|
void onAllocateHandle(vk::HandleType handleType);
|
||||||
|
void onDeallocateHandle(vk::HandleType handleType);
|
||||||
|
|
||||||
bool getEnableValidationLayers() const { return mEnableValidationLayers; }
|
bool getEnableValidationLayers() const { return mEnableValidationLayers; }
|
||||||
|
|
||||||
|
@ -639,6 +641,7 @@ class RendererVk : angle::NonCopyable
|
||||||
SamplerYcbcrConversionCache mYuvConversionCache;
|
SamplerYcbcrConversionCache mYuvConversionCache;
|
||||||
angle::HashMap<VkFormat, uint32_t> mVkFormatDescriptorCountMap;
|
angle::HashMap<VkFormat, uint32_t> mVkFormatDescriptorCountMap;
|
||||||
vk::ActiveHandleCounter mActiveHandleCounts;
|
vk::ActiveHandleCounter mActiveHandleCounts;
|
||||||
|
std::mutex mActiveHandleCountsMutex;
|
||||||
|
|
||||||
// Tracks resource serials.
|
// Tracks resource serials.
|
||||||
vk::ResourceSerialFactory mResourceSerialFactory;
|
vk::ResourceSerialFactory mResourceSerialFactory;
|
||||||
|
|
|
@ -3829,7 +3829,7 @@ void SamplerYcbcrConversionCache::destroy(RendererVk *rendererVk)
|
||||||
ASSERT(!yuvSampler.isReferenced());
|
ASSERT(!yuvSampler.isReferenced());
|
||||||
yuvSampler.get().destroy(device);
|
yuvSampler.get().destroy(device);
|
||||||
|
|
||||||
rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::SamplerYcbcrConversion);
|
rendererVk->onDeallocateHandle(vk::HandleType::SamplerYcbcrConversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &iter : mVkFormatPayload)
|
for (auto &iter : mVkFormatPayload)
|
||||||
|
@ -3838,7 +3838,7 @@ void SamplerYcbcrConversionCache::destroy(RendererVk *rendererVk)
|
||||||
ASSERT(!yuvSampler.isReferenced());
|
ASSERT(!yuvSampler.isReferenced());
|
||||||
yuvSampler.get().destroy(device);
|
yuvSampler.get().destroy(device);
|
||||||
|
|
||||||
rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::SamplerYcbcrConversion);
|
rendererVk->onDeallocateHandle(vk::HandleType::SamplerYcbcrConversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
mExternalFormatPayload.clear();
|
mExternalFormatPayload.clear();
|
||||||
|
@ -3871,8 +3871,7 @@ angle::Result SamplerYcbcrConversionCache::getYuvConversionImpl(
|
||||||
vk::RefCountedSamplerYcbcrConversion &insertedYuvConversion = insertedItem.first->second;
|
vk::RefCountedSamplerYcbcrConversion &insertedYuvConversion = insertedItem.first->second;
|
||||||
yuvConversionOut->set(&insertedYuvConversion);
|
yuvConversionOut->set(&insertedYuvConversion);
|
||||||
|
|
||||||
context->getRenderer()->getActiveHandleCounts().onAllocate(
|
context->getRenderer()->onAllocateHandle(vk::HandleType::SamplerYcbcrConversion);
|
||||||
vk::HandleType::SamplerYcbcrConversion);
|
|
||||||
|
|
||||||
return angle::Result::Continue;
|
return angle::Result::Continue;
|
||||||
}
|
}
|
||||||
|
@ -3948,7 +3947,7 @@ void SamplerCache::destroy(RendererVk *rendererVk)
|
||||||
ASSERT(!sampler.isReferenced());
|
ASSERT(!sampler.isReferenced());
|
||||||
sampler.get().get().destroy(device);
|
sampler.get().get().destroy(device);
|
||||||
|
|
||||||
rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::Sampler);
|
rendererVk->onDeallocateHandle(vk::HandleType::Sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
mPayload.clear();
|
mPayload.clear();
|
||||||
|
@ -3976,7 +3975,7 @@ angle::Result SamplerCache::getSampler(ContextVk *contextVk,
|
||||||
vk::RefCountedSampler &insertedSampler = insertedItem.first->second;
|
vk::RefCountedSampler &insertedSampler = insertedItem.first->second;
|
||||||
samplerOut->set(&insertedSampler);
|
samplerOut->set(&insertedSampler);
|
||||||
|
|
||||||
contextVk->getRenderer()->getActiveHandleCounts().onAllocate(vk::HandleType::Sampler);
|
contextVk->getRenderer()->onAllocateHandle(vk::HandleType::Sampler);
|
||||||
|
|
||||||
return angle::Result::Continue;
|
return angle::Result::Continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -890,7 +890,7 @@ void GarbageObject::destroy(RendererVk *renderer)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer->getActiveHandleCounts().onDeallocate(mHandleType);
|
renderer->onDeallocateHandle(mHandleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT *label)
|
void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT *label)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче