Attach Texture to Cycle in Texture::TransitionLayout

Not doing so could result in the texture being destroyed before the completion of a transition and lead to undefined behavior.
This commit is contained in:
PixelyIon 2022-03-06 21:00:47 +05:30
parent 3268b3779a
commit 7532eaf050

View File

@ -377,8 +377,8 @@ namespace skyline::gpu {
TRACE_EVENT("gpu", "Texture::TransitionLayout"); TRACE_EVENT("gpu", "Texture::TransitionLayout");
if (layout != pLayout) if (layout != pLayout) {
cycle = gpu.scheduler.Submit([&](vk::raii::CommandBuffer &commandBuffer) { auto lCycle{gpu.scheduler.Submit([&](vk::raii::CommandBuffer &commandBuffer) {
commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eBottomOfPipe, {}, {}, {}, vk::ImageMemoryBarrier{ commandBuffer.pipelineBarrier(vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eBottomOfPipe, {}, {}, {}, vk::ImageMemoryBarrier{
.image = GetBacking(), .image = GetBacking(),
.srcAccessMask = vk::AccessFlagBits::eNoneKHR, .srcAccessMask = vk::AccessFlagBits::eNoneKHR,
@ -393,7 +393,10 @@ namespace skyline::gpu {
.layerCount = layerCount, .layerCount = layerCount,
}, },
}); });
}); })};
lCycle->AttachObject(shared_from_this());
cycle = lCycle;
}
} }
void Texture::SynchronizeHost(bool rwTrap) { void Texture::SynchronizeHost(bool rwTrap) {