Repository navigation
Conversation
|
Thanks for the numbers. Leaving the top mips of large BC textures unbacked is a reasonable last resort for cards that cannot hold the working set, and we would like to have it. It needs some changes first:
On why these textures are pinned in the first place: the heap resolves every entry of a bindless table, read or not, and each resolved entry holds its image ( |
simnJS
left a comment
There was a problem hiding this comment.
Please register KYTY_PARTIAL_TEXTURE_MB in Settings.cpp and use a generic title reference in the commit body. A view limited to an omitted mip still selects that mip, and Image::CopyImage transfers from level zero. Please handle views and transfers that touch omitted levels, using fully backed images where residency cannot be guaranteed. Cover both cases under Vulkan validation with a fully backed control. Use current device-local budget and allocator headroom for the default, document the lifetime of omitted levels, and measure or batch the per-image fence waits.
…mips under memory pressure Past the device-local budget less the cache reserve, large BC textures are sparse-resident without mip 0 (or 0-1); any use beyond sampling backs and uploads those mips first. On an 8 GB card this saved 2-3 GB of VRAM in the first 3D scene of a title.
bbba3c8 to
9a2d4ff
Compare
simnJS
left a comment
There was a problem hiding this comment.
The new omitted-only view and copy cases cover the earlier examples. A shader can also use OpImageFetch at mip 0 through a sampled view that spans all mips. Vulkan returns zero or poison for integer fetches below the view’s minLod. Please make the mip resident before that path can read it and compare a shader fetch against the fully backed control. Offline CI reports the fixture’s skip as unexpected. Please report a specific optional sparse capability limitation when it applies and fail other Vulkan initialization errors. Please also rerun the memory-pressure comparison with the default threshold and batched binds on this head.
|
Before pushing the next revision I measured the fetch rule in the scene, and it changes the picture, so I would like your view on the direction first. What the local revision does (not pushed yet):
Scene data (the same first 3D scene of the title, RTX 2070 SUPER 8 GB, default threshold, batched binds, a temporary counter per promotion reason):
The cause is granularity: Two directions I can see:
I lean to 1. Which would you rather have in this PR? |
What
On 8 GB cards the first scene of PPSA38500 pins 2.5-5.3 GB of textures through the bindless heap (
heap_refs), ~93% of the bytes in textures >= 512 px; the texture GC cannot free them and VRAM overflows (guard kill or device loss). This is a last resort for cards too small for the scene; the heap fix itself belongs to the #168 rework.VK_EXT_memory_budgetbudget minus the reserve the caches keep below it (GetTotalMemoryBudget: an eighth, at most 1 GiB), BC 2D textures >= 512 px with >= 3 mips drop mip 0; past halfway from there to the budget, mips 0-1.KYTY_PARTIAL_TEXTURE_MBoverrides the start (0 = off). A 12-24 GB card that is not short never drops a mip.CreatePartialImagequeues its binds;CommandScheduler::QueueSubmitflushes every queued bind in onevkQueueBindSparsethat signals a timeline semaphore, and that submit and later ones wait on it on the GPU.minLod. Every other use first binds memory for the omitted mips and uploads them from guest memory (TextureCache::MakeResident): a sampled view of omitted mips only, storage and attachment views,CopyImage/CopyImageMip(source and destination), clears,BeginColorRendering, and downloads/write-back.Image::Download,CopyImage,CopyImageWithBuffer,CopyMip,ResolveandFindViewstop on a partial image that reaches them anyway. The device also needsresidencyNonResidentStrict.KYTY_PARTIAL_TEXTURE_MBregistered inSettings.cpp.kyty_shim_partial_textures: a 2048 px BC1 texture with 12 mips created partially resident; a view of every mip keeps it partial, a view of mip 0 only backs it and its contents match a fully backed control; a copy from a partial texture matches the same copy from a fully backed control. The sharedTextureCacheTestAccessmoved to a header (both tests link intolibSceAgcDriver).Tested
Windows 10, RTX 2070 SUPER 617.42.
ctest -R "kyty_shim_(partial_textures|image_write_back_alias)" -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, layer 1.4.363: onAnyKyty(90a4845)image_write_back_aliaspasses; on this branch both pass. Each log shows the loader insertingVK_LAYER_KHRONOS_validation, neither haswas not found but was requested, and neither has aVUID-line. First version, same scene of PPSA38500: 769-3073 textures made partial per run, 134 MiB bound instead of 452 MiB up to 567 MiB instead of 3747 MiB, peak VRAM 6.66 GB vs a guard kill at 7.9 GB. The scene was not re-run with this revision.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)