Uncharted - LOFC boot to gameplay, fix rendering and frame rate #1430
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1430
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1430"
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?
@Almo7aya on GitHub · 2026-10-11 20:39 UTC · original
Almo7aya:fix/uncharted-cleanup→main· +6150 −694 · 65 files · 24 commits · openUncharted: Legacy of Thieves Collection (PPSA05389): boot to gameplay, fix rendering and frame rate
Game
Uncharted: Legacy of Thieves Collection (PPSA05389, 01.002.000).
Problem
On
mainthe game does not reach gameplay:libSceVdecswmodule asserts.computes ("buffer descriptor is not a valid runtime value").
Past those, rendering is wrong:
The frame rate is in single digits.
Result
correctly.
RDNA 2 buffer rules. They are not keyed on shader hashes.
Commits
libSceVdecsw for video playback and asserted on the unresolved module. Vdecsw shares
Videodec2's ABI and drives the FFmpeg software decoder.
guest view in several steps. Faults and GPU page watches during those steps were lost or handed
to the wrong owner. Watches and protections now survive remapping, transient faults are
retried, and code pages stay executable.
descriptor by a GPU-computed key (a masked table byte, a bit scan, a counting loop) were
rejected. The key's values are now enumerated from guest memory at dispatch, and the candidates
are selected per lane.
reads descriptors on paths the GPU does not take with the current data. Unmapped memory and
unmapped tables there now read as zero or null, instead of faulting or exiting.
tables null the candidates an operation cannot use, including those of the wrong dimension, and
get a canonical padded layout that grows in large steps. Changing table contents no longer
recompiles shaders, which removes the compile stalls.
0x800stopped the emulator. Unknown markerids are skipped and reported once.
of these formats were dropped, so targets kept stale contents (the glare). Matching fill
shaders run as image clears too.
aspect, so guest copies of a depth buffer had stale stencil.
device addresses returned zeros whenever it reached unbacked pages (the ocean flicker). Bases
the host can evaluate are backed before the dispatch.
and failed waits name the shader, resource and condition.
evaluation was dominated by out-of-line one-line accessors.
clear) and copy kernels many times a frame. Their GPU-written results made CPU reads drain the
GPU. Kernels proven from the IR to only fill or copy run as DMA fills and copies. They must
pass the RDNA 2 format,
DST_SEL,OOB_SELECTand overlap checks.thread, and the device-address sweep before a draw covers only queued regions.
frame, so the buffer and texture caches aged resources out almost immediately.
command processor's largest cost. It now evaluates a precompiled tape.
re-initialised for every draw, and the redundant pipeline bind and checks are skipped.
descriptions and their texture-cache lookups are reused while the cache's lookup generation is
unchanged.
MIN_LODpastLAST_LEVELis clamped instead of exiting. A 256-bit T# with zero DWORDs 4–7 is read like a128-bit one.
VK_EXT_device_faultreport is printed, along with the last draws and dispatches the GPUreached (NVIDIA checkpoints, always on, about 1% FPS).
thousands of watched pages a second. Page-watch protection now takes the address-space lock
shared.
GPU thread ran on efficiency cores and shared its core with spinning guest workers.
everything recorded so far, one page at a time. It downloads a 1 MiB window and submits sooner.
page fails and returned zero bytes without an error. This was the root cause of the
intermittent boot failures and of corrupted data.
mainrejectsnon-constant sample offsets, and one of the game's shaders computes them per lane, so the game
stopped at boot. With
VK_KHR_maintenance8the offset is emitted natively. Otherwise alevel-zero sample moves its coordinates by the offset.
Testing
ctest: 53/54. The one failure,kernel_file_system's socket-options check, fails onmaintoo.
VK_KHR_maintenance8path.standing and while moving.
AI use
This work was developed with AI assistance
@coderabbitai[bot] on GitHub · 2026-10-11 20:47 UTC · original
📝 Walkthrough
Walkthrough
The changes add GPU command scheduling and diagnostics, update buffer and texture cache behavior, and add draw and compute execution paths. Shader resource analysis gains bounded descriptor enumeration, fill and copy recognition, and SRT evaluation support. Guest-memory fault handling now accounts for GPU page watches and mapping replacements. File reads use chunked transfers. A shared video-decoder ABI, decoder drain support, and a Vdecsw software-decoder API are added.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🟡 Moderate · up to
db876A memory remapping that overlaps GPU work can hang the emulator. On NVIDIA hardware, diagnostic markers that are always on can reduce performance. Descriptor evaluation and loop-bound handling in the shader paths can produce wrong results or exits in edge cases. Address these issues before merging.
Pre-merge checks |
4 |
1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 17.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 317 functions across 50 files. (15 skipped: 1 unsupported, 14 over the file limit.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -140,0 +281,4 @@}(*chunk)[mib & ChunkMask] = tick;}}@coderabbitai[bot] on GitHub · 2026-10-11 20:47 UTC · original
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Guard
NoteWriteagainst a zero-size range.If
size == 0,vaddr + size - 1uevaluates tovaddr - 1. Whenvaddris MiB-aligned, the loop then touches no MiB, which is harmless. Whenvaddr == 0, the expression wraps toUINT64_MAX. The loop then runs until theEXIT_IFbound check stops the process. The current callers pass nonzero sizes, so add an early return forsize == 0as a cheap safeguard for the new public API.Proposed fix
📝 Committable suggestion
@ -55,0 +175,4 @@}VULKAN_HPP_DEFAULT_DISPATCHER.vkCmdSetCheckpointNV(command, reinterpret_cast<const void*>(static_cast<uintptr_t>(sequence)));}@coderabbitai[bot] on GitHub · 2026-10-11 20:47 UTC · original
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
Gate
SetCheckpointbehind a debug option. Do not enable it on every device that has the extension.checkpoints_enabledis set whenever the device advertisesVK_NV_device_diagnostic_checkpoints. NVIDIA drivers generally advertise this extension. On those drivers, every draw and every dispatch recordsvkCmdSetCheckpointNV.Every indirect dispatch also records two more commands:
eAllCommands→eTransfermemory barriercopyBufferinto the host-visible args ringThat barrier drains all earlier GPU work before each indirect dispatch. This serializes compute work in normal gameplay on NVIDIA hardware, which works against the PR's frame-rate goal. The data serves only device-lost diagnostics.
Enable checkpoints only through an explicit config flag, such as an existing GPU debug option. As an alternative, keep the marker but skip the barrier and the args copy unless a debug flag is set.
Proposed gating in `src/graphics/presentation/window/vulkanWindow.cpp`
@ -1530,0 +1568,4 @@(cop == ValueOpcode::ULessThan32 || cop == ValueOpcode::SLessThan32) &&ValidateRuntimeValue(m_program, compare->Arg(1), RuntimeValueType::Integer)) {range.begin = Value(start);range.end = compare->Arg(1).Resolve();@coderabbitai[bot] on GitHub · 2026-10-11 20:47 UTC · original
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
A signed ascending bound becomes an unsigned range, so a zero-trip loop can stop the emulator.
CountingLoopRangeaccepts bothSLessThan32andULessThan32as the bound. It stores the bound as[start, bound)and does not record which comparison it came from.KeySetEvaluator::Run(ResourceMaterialization.cpp Lines 226-239) evaluatesbeginandendas unsigned values.Example: the guard is
SLessThan32(counter, count)andcountis negative at runtime, such as0xFFFFFFFF.end - beginexceedsMaxValues, soRunreturns false.dword_count != 8),MaterializeIndirectDescriptorthen fails with "GPU-selected descriptor key has no bounded value set".pipelineCache.cppturns that failure intoEXIT.Fix: record the comparison's signedness in
InductionRange. InRun, treat a signed range whose signedendis at or below its signedbeginas empty.Proposed fix
In
KeySetEvaluator::Run:Add
bool is_signed = false;toDescriptorSource::IndirectDescriptor::InductionRange, and copy it inExtractResourcePlan.📝 Committable suggestion
@ -1070,0 +1502,4 @@values[index] = tape->nodes[index].immediate;}}}@coderabbitai[bot] on GitHub · 2026-10-11 20:47 UTC · original
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42449
The shared
srt_tape_valuesvector can be overwritten by anotherSrtWalkerbefore the first walker callsEvaluateDescriptor.RefreshFlatBufferwrites this plan-level vector, whileEvaluateDescriptorreads it without checking the walker context. Store tape values inEvaluationContextor otherwise prevent interleaved refreshes on the same plan.@ -795,0 +929,4 @@if (!replacing() && m_replacement_generation == generation) {return false;}m_replacement_done.wait(lock, [&] { return !replacing(); });@coderabbitai[bot] on GitHub · 2026-10-11 20:47 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2619
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 25005
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5640
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 19407
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42289
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1741
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2253
Bound the replacement wait in the fault handler.
When a transient fault reaches
ResolveTransientFaultduring a fixed replacement, the resolver waits without a deadline.ReplaceFixedRangeWithReservedcallsUnmapGpuRangewhileReplacementWindowis active. From a non-GPU thread,SendCommandSyncthen waits for the GPU command to finish. If that command faults in the replacement range, its fault handler waits forEndReplacement, while the replacement thread waits for the command. This can deadlock. The 250 ms deadline inHandleMemoryFaultis checked only afterResolveTransientFaultreturns.Bound the condition-variable wait and return
falsewhen it expires.Suggested bounded wait
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-11 20:47 UTC · original · reviewed
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
d06d07b2-3018-41eb-ae88-83d872870d9e📥 Commits
Reviewing files that changed from the base of the PR and between
e51de54ee4anddb8760c7ef.📒 Files selected for processing (65)
src/common/threads.cppsrc/common/threads.hsrc/graphics/guest_gpu/command_processor/pm4Handlers.cppsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/graphicContext.hsrc/graphics/host_gpu/memoryTracker.cppsrc/graphics/host_gpu/memoryTracker.hsrc/graphics/host_gpu/pageManager.cppsrc/graphics/host_gpu/pageManager.hsrc/graphics/host_gpu/rangeSet.hsrc/graphics/host_gpu/regionManager.hsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.hsrc/graphics/host_gpu/renderer/cache/streamBuffer.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/colorRenderTarget.cppsrc/graphics/host_gpu/renderer/commandScheduler.cppsrc/graphics/host_gpu/renderer/commandScheduler.hsrc/graphics/host_gpu/renderer/context.cppsrc/graphics/host_gpu/renderer/depthRenderTarget.cppsrc/graphics/host_gpu/renderer/image/blitHelper.cppsrc/graphics/host_gpu/renderer/image/imageInfo.hsrc/graphics/host_gpu/renderer/masterSemaphore.cppsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/render.hsrc/graphics/host_gpu/renderer/renderCompute.cppsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/renderContext.hsrc/graphics/host_gpu/renderer/renderDraw.cppsrc/graphics/host_gpu/vma.cppsrc/graphics/presentation/window/vulkanWindow.cppsrc/graphics/shader/recompiler/ShaderRecompiler.cppsrc/graphics/shader/recompiler/ShaderRecompiler.hsrc/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cppsrc/graphics/shader/recompiler/backend/spirv/SpirvEmitter.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/ir/ResourceSnapshot.hsrc/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/Value.cppsrc/graphics/shader/recompiler/ir/Value.hsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cppsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.hsrc/graphics/shader/recompiler/ir/passes/ResourceTracking.cppsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cppsrc/graphics/shader/recompiler/ir/passes/SrtWalker.cppsrc/graphics/shader/recompiler/ir/passes/SrtWalker.hsrc/kernel/fileSystem.cppsrc/kernel/memory.cppsrc/kernel/memory.hsrc/kernel/memoryAddressSpace.incsrc/libs/libVdecsw.cppsrc/libs/libVideoDec2.cppsrc/libs/libs.cppsrc/libs/videoDec2.hsrc/libs/videoDec2Decoder.cppsrc/libs/videoDec2Decoder.hsrc/loader/runtimeLinker.cpptests/ResourceTrackingTests.cpptests/ShaderRecompilerComputeTests.cpptests/VirtualMemoryAllocationTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@Crispy81 on GitHub · 2026-10-11 21:55 UTC · original
Look forward to this being merged.
@Almo7aya on GitHub · 2026-10-16 14:00 UTC · original
@Nmzik Hey, any chance we can get this commit into main?
e9dbf19Uncharted (PPSA05389) doesn't boot on current main without it, it dies at boot with
condition (!Active()) is truein commandScheduler.cpp:325. I cherry-picked it on top of9e41d83and it applies clean and gets the game to the title screen.The crash is because HandleFault sends every fault in GPU-visible memory to the caches, even ones no page watch caused (guest-protected pages, or pages that are briefly gone while Windows remaps a view), so the caches try to record before there's any command buffer. The commit makes the caches only take faults their own watches caused.
It also fixes a few related Windows remapping issues: faults that hit mid-remap get retried instead of killing the thread, view splits keep their page protections, backing reads/writes don't race splits, and watched code pages stay executable.
I know it touches a core part of the emulator but I tried to validate it as much as possible with all the games I have
@Almo7aya on GitHub · 2026-10-24 16:41 UTC · original
@Nmzik don't forget me :(, should I rebase this PR and drop the already implemented commits?
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.