AGC: one draw resolves a 21,489-entry image table into 14.6 GiB of textures and runs the device out of memory #6890
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-16T16:45:28Z.
One draw's bindless image table is resolved into 21,489 sampled textures (14.6 GiB), and the device runs out of memory while that draw's resources are still being built.
Setup: Linux, RTX 5080 (NVIDIA 615.78.08), 16 GiB. Death Stranding 2 (PPSA02015) on its loading screen. The title does not get this far on
mainalone: the run ismain5d9dcc42dplus open PRs 6437, 6297, 6277, 6196, 6530, 6300, 6727, 6492, 6174, 6794 and local changes for EQAA targets.resolveImageTableson currentmain66e290f1cmakes a texture for every element of the table the same way.A counter at the end of the draw's image phase (
APS5_PROFILE_DRAW=1), one run each:Smaller draws in the same runs bind about 1,600 table textures each (about 460 MiB), all of them also in the texture cache.
While the big set is built, the sampled cache evicts entries that set still holds (21,338 of its textures were marked released), so evictions free nothing, and the recorder's kept-bytes budget counts only
CopiedBytes(), not textures. The out-of-memory release from #6174 does not help either, since the cache is locked by the build. The stop:#6481 checks each entry against the device's limits; nothing bounds what one table may hold in total. Is resolving only the elements a draw can reach, or a byte limit per table that throws, the direction you want here?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T18:24:23Z.
I traced the current
resolveImageTables()path. It iterates everybinding.countentry and resolves each texture before dispatch; I do not see an existing per-draw set of the descriptor indices the shader will actually sample.imageTableReadRangesis guest-memory address ranges used later byfinishImageTables()for write-overlap/fault handling, not a list of sampled image indices, so it cannot directly prune this loop. That makes a per-table resource budget with explicit failure the immediately supportable guard; resolving only reachable entries would need new index-usage tracking through recompiler/runtime execution. This is a source-path observation, not a recommendation to silently skip entries.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T20:55:56Z.
One integration point from a current-main check: #6481 is still open and modifies
ShaderResources::resolveImageTables()to validate individual image-table entries. That is distinct from the aggregate resource growth in this report, but any table-wide budget would touch the same resolver and should be composed with #6481 rather than duplicating its per-entry checks. The existing cache policy uses a 2 GiB floor / one-quarter of the largest device-local heap as a cache budget; I have not treated that as an approved per-draw limit, since applying it to a live table could reject valid workloads.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T02:51:10Z.
I checked the resolver and the existing #6481 work. There is no list of descriptor indices the shader may sample, so pruning to reachable entries would need new recompiler/runtime tracking. A table-wide cap is a distinct option, but I don't see an existing threshold or defined failure behavior: for example, whether to reject the draw or make entries fault only if selected, and whether the limit is fixed or derived from available device memory. Choosing those semantics arbitrarily could reject valid workloads. If a maintainer has a preferred limit and failure contract, I can evaluate a focused follow-up against it; otherwise I don't think an aggregate cap is ready to submit.
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-17T19:11:18Z.
I measured how the entries of that table overlap in guest memory, on the same stack as the report (two runs, one big table each, logged before any texture is made):
Almost every entry has its own base (12,285 distinct bases of 12,319), and only 18 bases hold more than one entry. So the overlap is not the same surface viewed in several formats. It is different resources over shared memory, many of them 3840x2160 single-mip targets of 32 MiB, with each guest byte covered about 3.6 times. One host copy per entry is what turns 3 GiB of guest memory into more than the device holds. Sharing images by view would cover only the 18 shared bases.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T20:21:00Z.
Thanks for measuring the range overlap. The 12,285 distinct bases and roughly 3.6x coverage confirm that ordinary same-base view reuse would address only a small part of this growth; the dominant cost is separate textures over overlapping guest bytes. I still do not see a defined per-table budget or guest-visible failure contract, so I am not proposing an arbitrary cap. The measurements narrow the likely fix space and are useful evidence for deciding whether the resolver should share overlapping backing or reject/limit a table.
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-17T20:23:29Z.
I agree a cap is the wrong contract, and sharing backing doesn't cover it either. With every element that lies inside another element's range rejected, DS2 still samples them (42 sampled faults in one run), and different formats over the same bytes need different decoded data.
What I'm working on instead is sampling table elements in the shader straight from guest memory, so an element gets no host image at all and the footprint stays at the 3.0 GiB already mapped. Anything not implemented throws through the existing fault path.
A standalone kernel for RGBA8 UNORM 2D (linear and SW_64KB_S, point and bilinear, clamp and wrap) matches a Radeon 610M bit for bit: 0 mismatches in 98,304 values on each of an RTX 5080, RADV and lavapipe. The filter rules were measured on that gfx1036 part, so gfx1013 matching is an assumption. BC7 with mips and trilinear come next, since those are the entries DS2 samples.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:08:00Z.
Thanks for checking both rejected-entry filtering and same-backing reuse against the title workload. The new RGBA8 kernel results are useful for the sampled values/layouts you measured, while the reported DS2 demand for BC7, mips and multiple formats remains outside that validation. Since you are actively developing the guest-memory sampling path, I won’t start a parallel implementation; this looks like a substantive feature that should be reviewed as one coherent path when ready.
Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-20T16:07:56Z.
Same stop on a 12 GB card, with a split of where the image phase goes
Setup: Linux, Ryzen 9 5950X, RTX 3080 Ti 12 GB (NVIDIA 615.71.09). Death Stranding 2 (PPSA02015) 01.015.000, no input, default settings.
Build:
mainb50976750+ #5426, #7978, #8015, #8115 (with #7985), a 3D gather fix (fix/volume-gather-lzon my fork) and local, env-gated changes to get past EQAA and aliased multisample depth stops. Not a clean-mainresult.Two runs (497 s and 200 s), one big table draw each time:
allocate+imagein the[texture]totals, cumulative over the run until thenvkAllocateMemoryfor those images (local timing probe, same span)vkAllocateMemory buffer slab ... -2) at 497 s and before 200 svkAllocateMemory(AllocateImageMemory→BufferPool::AllocateMemory). Image creation and allocation together are at most about half of the 129 s, the allocation calls alone under a fifth; the rest is per-entry work inresolveImageTables.AI-assisted; the runs are from my machine(s).
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-21T20:00:41Z.
Second title on the same resolver: Ghost of Yōtei (PPSA26344) rebuilds a 33,677-entry table on every plan after the first OOM
Setup: Linux (kernel 7.2.11), RTX 3080 Ti 12 GB (NVIDIA 615.78.08), 32 GB RAM. Ghost of Yōtei (PPSA26344), first ~70 minutes from launch,
APS5_PROFILE_DRAW=1 APS5_SKIP_REFUSED_DRAWS=1 APS5_NO_PIPELINE_JOURNAL=1.Build:
main80565c594plus local GoY carry commits (an RG32F filter-minmax channel copy, touchingTextureKey,cachedTextureand theresolveImageBindingcall site, and an undo of #7726).resolveImageTables,FindReusedTableandCachedTableTexturesare as onmain(same body on7202f120dtoday). Not a clean-mainresult. Two runs: A with the default budget, B withAPS5_TEXTURE_CACHE_MIB=2048(which forces both the sampled and the storage budget).One draw's bindless image table has 33,677 elements (
bda 1; a second shape with 33,659 elements,bda 0, also appears):The first full resolve (frame 832 in B, 834 in A) takes
vkmem liveto 24.5 GB on a 12 GB device, and the firstvkAllocateMemory ... initialResult=-2is in that same frame, as in the report. From there frames take 50–190 s each (before it they advance faster than the 10 s probe), which is the "looks frozen" phase mrfelek described. The OOM itself is the first resolve; the crawl after it is the same resolve repeated:APS5_TEXTURE_CACHE_MIB=2048)image tables N reused, M resolvedat the endused uncachedshare of texture uses after 847initialResult=-2 ... recoveredlinesSo 60 % / 74 % of the image phase in the crawl is this one table being rebuilt; the rest is the smaller tables of the other draws, which by the
used uncachedshare also miss the cache once the big resolve has evicted them (not checked per table).Why the remembered table is not taken:
resolveImageTablesreuses a table only whenFindReusedTable && TableCurrent && CachedTableTexturesall hold.CachedTableTextureswalks every non-rejected element and returnsfalseas soon as one element's texture is not in the sampled cache (or is a different object than the one remembered). The sampled cache never held 33,677 entries in either run at a 10 s reading (21,655 and 7,734 at most), so for a table this size the check fails and the build goes to the resolved path. The resolve fills the cache and then evicts it (run A's[texture-cache]readings swing 0 ↔ 5.6 GB between consecutive 10 s windows; run B's budget stays at 2,048 MiB and the cache sits at it in about two-thirds of the readings). That is also why the smaller forced budget did not shorten the crawl: the frame 847 → 859 span is 1,275 s in both runs, and run B hits the cache less. The profile lines do not name the owning shader, so "every build of this table is resolved, never reused" is inferred from the build counts, not read from a per-table counter.What this adds: fma-rc's measurement is of one resolve holding more than the device has; this title shows the resolve is then repeated for the rest of the run, because reuse needs every element resident and the table is larger than the sampled cache ever is. A path that makes no host image per element (the guest-memory sampling above) would cover both, since there is then nothing to keep resident. Short of that, the two places this run hits are the reuse check (every element resident) and the budget (smaller than one table's working set); I am not proposing which one changes. If the rebuild-on-every-plan part is better tracked separately I can open it as its own issue and link it here.
Logs are 13.1 M / 13.8 M lines; I can attach the
[resources],[texture-cache]and[mem-probe]extracts if useful.AI-assisted; the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-21T21:03:51Z.
Correction to my comment above: the table is never remembered; the resident-cache check is never reached
I added an env-gated log line to
resolveImageTables(samemain80565c594+ carry build as above; diff on request) that prints, for every table of ≥30,000 elements that is not reused, which reuse gate refused it and whether the fresh build was eligible to be remembered. One run on the same machine, ~1,330 s, frames 831–841:15 such lines from two fragment shaders (
imageTableShader0x800034f300, 11 builds, one in every frame of the window; 0x80003bdb00, 4 builds). They are the33677 textures/33659 textures[resources]lines of the earlier comment (33,657 table elements plus the shader's other textures). All 15 say the same thing:FindReusedTable(not-remembered);TableCurrentandCachedTableTexturesare never reached;reusablechain goes false atlooked->source == nullptr, i.e. at least one element's texture was created from aStorageTexture(a GPU-written image, no snapshot). The line records the first element that fails, so later elements may fail for other reasons too.So what I wrote above — reuse fails because the sampled cache never holds all entries, and the "reuse needs every element resident" reasoning in the paragraph after it — is not what happens on this title. The table is rebuilt on every bind because it is never eligible to be remembered; cache residency is never tested. I withdraw those two parts; the build counts and timings stand.
Shape, since fma-rc gave DS2's: 33,657 distinct base addresses over 33,657 elements (×1.00, nothing shared), 8,658–8,665 MiB of guest range per table, 0 DCC, 0 rejected before texture lookup. Each build took 32.5–62.1 s (the
[resources] images tookline that follows each[table-stats]line). DS2's 12,285 bases over 21,489 entries (×3.6) is a different shape; here there is nothing to deduplicate.The
source != nullptrexclusion is what keeps this table out of reuse; I have not measured which element(s) carry a storage source or whether it is the same one(s) every frame, and I have not read why the exclusion is there, so I am not proposing it change.Extract of the 15 lines and the diff on request. AI-assisted; the run is from my machine.