Cache staging buffer used for texture download

This commit is contained in:
Billy Laws 2022-11-25 12:34:05 +00:00
parent 8c5e6d2bb4
commit af7c54297f
2 changed files with 6 additions and 3 deletions

View File

@ -825,15 +825,16 @@ namespace skyline::gpu {
WaitOnBacking();
if (tiling == vk::ImageTiling::eOptimal || !std::holds_alternative<memory::Image>(backing)) {
auto stagingBuffer{gpu.memory.AllocateStagingBuffer(surfaceSize)};
if (!downloadStagingBuffer)
downloadStagingBuffer = gpu.memory.AllocateStagingBuffer(surfaceSize);
WaitOnFence();
auto lCycle{gpu.scheduler.Submit([&](vk::raii::CommandBuffer &commandBuffer) {
CopyIntoStagingBuffer(commandBuffer, stagingBuffer);
CopyIntoStagingBuffer(commandBuffer, downloadStagingBuffer);
})};
lCycle->Wait(); // We block till the copy is complete
CopyToGuest(stagingBuffer->data());
CopyToGuest(downloadStagingBuffer->data());
} else if (tiling == vk::ImageTiling::eLinear) {
// We can optimize linear texture sync on a UMA by mapping the texture onto the CPU and copying directly from it rather than using a staging buffer
WaitOnFence();

View File

@ -406,6 +406,8 @@ namespace skyline::gpu {
std::vector<TextureViewStorage> views;
std::shared_ptr<memory::StagingBuffer> downloadStagingBuffer{};
u32 lastRenderPassIndex{}; //!< The index of the last render pass that used this texture
texture::RenderPassUsage lastRenderPassUsage{texture::RenderPassUsage::None}; //!< The type of usage in the last render pass