protonscr

[Question]Does the fall back to system memory actually work as intended?

dxvkclosed question
doitsujin/dxvk#5313 · opened 2025-11-05 by rrPKrr · updated 2025-11-06 · 4 comments · github
RrrPKrr 2025-11-05 github

Once again the question is related to GTAIV... Sorry guys, I know you like this game a lot. :>

As was briefly mentioned by @doitsujin in https://github.com/doitsujin/dxvk/issues/5216 when ReBAR is disabled on both of my Nvidia systems, apparently my drivers (on both 10 series and 40 series gpus) allocate only ~100mb of vram.

So I was watching dxvk.hud graphs and numbers closely, and what I noticed is that actually at some point my drivers allocate double that amount. But then, abruptly half of allocated vram vanishes and stays at 100mb indefinitely.

Could you possibly explain in more detail what exactly does this code supposed to do? https://github.com/doitsujin/dxvk/blob/master/src/dxvk/dxvk_memory.cpp#L1211C1-L1215C6

Edit: To be more specific, could some resources that were meant to be in vram end up being relocated to system memory, even if there was enough budget?

KK0bin maintainer 2025-11-06 github

So I was watching dxvk.hud graphs and numbers closely, and what I noticed is that actually at some point my drivers allocate double that amount. But then, abruptly half of allocated vram vanishes and stays at 100mb indefinitely.

Spikes are not unexpected. DXVK uses rebar memory for temporary staging buffers and it will defragment memory if possible.

The problem with GTA IV in particular is that it allocates almost all geometry in D3DPOOL_DEFAULT + DYNAMIC buffers. DXVK puts those into directly CPU-accessible VRAM (bar memory)

RrrPKrr 2025-11-06 github

I see. I understood that from your previous explanation in https://github.com/doitsujin/dxvk/issues/5216

But what about Nvidia drivers? For example if I delete this block of code https://github.com/doitsujin/dxvk/blob/master/src/dxvk/dxvk_memory.cpp#L1211C1-L1215C6 and recompile DXVK, the driver (?) allocates ~200+ mb of vram (and as a result I get an improved performance in game). When this code is not present, does DXVK over-allocate memory? Or is it actually the opposite, and the code relocates stuff into ram "under-allocating" vram as a result?

Edit: Or does it do something completely different that I do not understand?

KK0bin maintainer 2025-11-06 github

That block you removed is basically the driver telling DXVK how much memory it can use and trying to adhere to that limit.

RrrPKrr 2025-11-06 github

That block you removed is basically the driver telling DXVK how much memory it can use and trying to adhere to that limit.

Ok, so there is nothing more to it in the end. Thanks for the clarification.

The reason I asked this is that for some odd reason no matter how I modify the condition:

!next && type.heap->enforceBudget && (getMemoryStats(type.heap->index).memoryAllocated + size > type.heap->memoryBudget

The result is always true, and driver always sets limit to exactly the same value.

Upstream links