Core: ClampRangeSize fixes (#3555)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions

* Swap !IsFree() for IsMapped()

IsFree only checks if the VMAType == Free. As is, that means ClampRangeSize will include memory that is Reserved or PoolReserved, and neither of those types are GPU mapped.

This fixes this bug, may help with some non-GPU memory asserts.

* Apply ClampRangeSize to vertex buffers

Helps with some cases encountered by UE and Minecraft.
This commit is contained in:
Stephen Miller 2025-09-07 22:27:40 -05:00 committed by GitHub
parent eb9a7e8fbd
commit 133f4b9187
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -82,7 +82,7 @@ u64 MemoryManager::ClampRangeSize(VAddr virtual_addr, u64 size) {
++vma;
// Keep adding to the size while there is contigious virtual address space.
while (!vma->second.IsFree() && clamped_size < size) {
while (vma->second.IsMapped() && clamped_size < size) {
clamped_size += vma->second.size;
++vma;
}

View File

@ -283,7 +283,8 @@ void BufferCache::BindVertexBuffers(const Vulkan::GraphicsPipeline& pipeline) {
// Map buffers for merged ranges
for (auto& range : ranges_merged) {
const auto [buffer, offset] = ObtainBuffer(range.base_address, range.GetSize(), false);
const u64 size = memory->ClampRangeSize(range.base_address, range.GetSize());
const auto [buffer, offset] = ObtainBuffer(range.base_address, size, false);
range.vk_buffer = buffer->buffer;
range.offset = offset;
}