Skip to content

Commit

Permalink
vk/dma: Initialize COW DMA block contents to avoid leaks
Browse files Browse the repository at this point in the history
- It is possible to lose data when uploading since the result of map_dma can change types and handles.
- Consider sync-on-exit for inherited spans

Not a problem when using passthrough DMA, but this extension does not work properly on NVIDIA + windows
  • Loading branch information
kd-11 committed Feb 16, 2022
1 parent abd8bd6 commit 254ddca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rpcs3/Emu/RSX/VK/VKDMA.cpp
Expand Up @@ -70,6 +70,14 @@ namespace vk
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, 0,
VMM_ALLOCATION_POOL_UNDEFINED);

// Initialize memory contents. This isn't something that happens often.
// Pre-loading the contents helps to avoid leakage when mixed types of allocations are in use (NVIDIA)
// TODO: Fix memory lost when old object goes out of use with in-flight data.
auto dst = allocated_memory->map(0, size);
auto src = vm::get_super_ptr(base_address);
std::memcpy(dst, src, size);
allocated_memory->unmap();

s_allocated_dma_pool_size += allocated_memory->size();
}

Expand Down

0 comments on commit 254ddca

Please sign in to comment.