VK: Fix memory corruption in VulkanExternalImageManager (#9116)
When calling setExternalSamplerVkSet the recycle function lambda captured some variables allocated on the stack, which are out of scope by the time the function is called. Change the capture to be done by value instead of by ref to avoid this problem.
This commit is contained in:
@@ -191,9 +191,11 @@ void VulkanExternalImageManager::updateSetAndLayout(
|
||||
VkDescriptorSet const srcSet = oldSet != VK_NULL_HANDLE ? oldSet : set->getVkSet();
|
||||
copySet(mPlatform->getDevice(), srcSet, newSet, copyBindings);
|
||||
|
||||
set->setExternalSamplerVkSet(newSet, [&](VulkanDescriptorSet*) {
|
||||
mDescriptorSetCache->manualRecycle(layout->count, newLayout, newSet);
|
||||
});
|
||||
set->setExternalSamplerVkSet(newSet,
|
||||
[&descriptorSetCache = mDescriptorSetCache, layoutCount = layout->count, newLayout,
|
||||
newSet](VulkanDescriptorSet*) {
|
||||
descriptorSetCache->manualRecycle(layoutCount, newLayout, newSet);
|
||||
});
|
||||
if (oldLayout != newLayout) {
|
||||
layout->setExternalSamplerVkLayout(newLayout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user