Wolverine: renderer threading, caches, AMPR/AJM and shader recompiler fixes #937
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!937
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-937"
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?
@itsmemac on GitHub · 2026-09-30 00:03 UTC · original
itsmemac:wolverine→main· +7166 −1038 · 118 files · 54 commits · openSummary
Work that gets Marvel's Wolverine (PPSA03671) running, as 54 single-topic commits so any subset can
be cherry-picked. Each commit keeps its own author. The branch is rebased on current upstream/main
(
e51de54e) and no longer depends on #780. The research diagnostics are stripped out.ShaderFunctions scalar-call expansion)
Earlier versions of this PR carried about 30 more commits (bindless, mesh culling and clip/cull
distances, GPU-read indirect draws, the software BVH path and others). They were dropped in this
rebase because upstream now has an equivalent or conflicting implementation. See "Not included".
Commits, by area
Renderer and GPU thread
them, which fixes sampling of freed memory after a guest unmap
exiting
read as zero
printed on fatal errors
surface capabilities are skipped
Shader recompiler
vertex fetches
block-compressed volumes on AMD
inactive sources
SDWA byte destinations
0.8 s)
Kernel, memory, libraries
lookups
fsync, equeue timeouts, timed condition waits
Not included
Dropped from earlier versions of this PR, because upstream has overlapping infrastructure or the
change depends on code that was removed:
--bindless)buffers
(
KYTY_IGNORE_WRITTEN_OVERLAPand similar)Testing
AI was used in development
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original · edited 2026-10-11 20:31 UTC
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
Walkthrough
The pull request adds GPU bindless image and sampler handling, indirect draw and dispatch paths, GPU memory-fault recovery, and device-loss diagnostics. It expands shader decoding, translation, resource tracking, and SPIR-V emission, including multi-pass mesh work and shader-function expansion. It also changes kernel and library services for file flushing, save-data conversion, audio queue tracking, and command-buffer submission. Tests cover the updated graphics, shader, audio, and Windows x64 load-emulation paths.
Suggested reviewers:
nmzikPriority: ➖ Normal
Merge Risk: 🟠 High · up to
41c7bThis change touches core rendering and shader compilation, and several default-on paths can cause incorrect rendering, stale data, or crashes. Some of these paths also affect titles other than the target game. Fix the listed issues before merging.
Security Architecture Review
Security architecture risk: 🟡 Moderate · up to
3fa2bThe change expands how guest workloads access memory and publish completion state. Address and mapping checks constrain the inspected read path, but ownership and recovery guarantees for delayed writes remain unresolved. No privilege escalation or isolation escape was established.
Retained concerns
Security review details
Security Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
Pre-merge checks |
4 |
1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 10.21% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 529 functions across 78 files. (71 skipped: 7 unsupported, 64 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.@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/guest_gpu/graphicsRun.cppline 1090 (outdated):🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4811
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42875
Preserve the persistent instance count for GPU indirect draws.
The GPU branches pass
instance_count = 1and return without updatingm_num_instances. A laterDrawIndexorDrawIndexAutowithinstance_count == 0can therefore use the count from before the indirect draw. Preserve the state update, or retain the CPU path when the GPU path cannot provide it. Remove the unreachable non-indexed CPU branch.@ -1433,0 +1581,4 @@LibKernel::Memory::WriteBacking(reinterpret_cast<uint64_t>(dst), &data, bytes);renderer.GetGpu().Wake();});}@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Deferred label callbacks can run after
GuestGpuis destroyed.Two callbacks run on the scheduler priority thread and use
GuestGpu:PublishLabelAtCompletioncallsrenderer.GetGpu().Wake().DeferLabelWrite(Lines 179-188) capturesthisand callsTrySendCommand.RenderContext::ShutdownGpu(src/graphics/host_gpu/renderer/renderContext.cpp, Lines 37-49) callsm_gpu->Shutdown()and thenm_gpu.reset(). It callsm_command_scheduler.DrainPriorityOperations()only after that.ThreadRunstops withBufferWait()→Finish(), andFinish()does not wait for priority operations.A label callback that is queued or running when
m_gpu.reset()executes has two outcomes:GetGpu()exits becausem_gpu == nullptr.TrySendCommandruns on a freedGuestGpu(use-after-free).This happens at shutdown whenever
KYTY_LABELS_AFTER_GPUorKYTY_LABELS_AT_COMPLETIONis set. Drain the priority operations after the GPU thread joins and beforem_gpu.reset().TrySendCommandalready returns false oncem_acceptingis false, so a late label write is dropped safely.🐛 Proposed fix (src/graphics/host_gpu/renderer/renderContext.cpp)
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/host_gpu/memoryTracker.hline 41 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1748
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42296
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42040
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12256
Create missing tracker regions in
ForEachMaybeCpuDirtyRegion.When
ForEachMaybeCpuDirtyRegionencounters an uncreated region, it skips that region.BufferCache::Registerdoes not create a tracker region, while a newRegionManagerstarts with all CPU pages dirty. Therefore,PrepareBdacan miss a newly registered buffer and mark the CPU-dirty epoch as synchronized without uploading its contents.Use
Iterate<true>so the helper creates missing regions and processes their initial CPU-dirty state.🐛 Suggested fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/host_gpu/pageManager.cppline 300 (outdated):🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Read
access_watchersatomically; the unlocked read is a data race.CanServeCleanReadis documented as callable from any thread. It callsIsReadWatched, which reads theaccess_watchersbit-field withoutregion->lock.UpdateRegionWatcherschanges the same byte underSpinGuardon another thread. The byte also holdswrite_watchers. The header comment calls the result "a hint", but a concurrent non-atomic read and write of the same memory location is undefined behavior in C++. It is not only a stale value.Read the whole
PageStatebyte withstd::atomic_ref<uint8_t>(relaxed) and extract the bit. Make every writer use the same atomic view, or do all writes under the lock while readers useatomic_ref. Do not take the spin lock here, because the function can run inside a fault handler.Based on learnings: "when a non-atomic type ... is written by one thread and read by another without a mutex, atomic wrapper, or other explicit synchronization, this is a genuine data race (undefined behavior)".
Source: Learnings
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/bindlessTable.cppline 601 (outdated):🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7367
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42932
🤖 get_repo_knowledge executed:
get_repo_knowledge KytyPS5/KytyPS5 /tmp/coderabbit-repo-knowledge/kytyps5-kytyps5-b6cddd0b/architectureLength of output: 42532
Defer bindless slot retirement until pending work completes.
TextureCache::UnregisterImagecallsOnImageUnregisteredimmediately. That function updates the descriptor and translation for each referenced slot. A submitted draw may still use the slot.eUpdateUnusedWhilePendingdoes not permit updates to descriptors used by pending work.Defer the complete slot retirement, including the placeholder descriptor write, translation update, and state cleanup, until the scheduler confirms that the last submission using the slot has retired.
DeleteImagealready defers image destruction while the scheduler is active, but that does not make the descriptor update safe.@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/descriptors.cppline 838 (outdated):🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
BindlessCompatibledoes not filter every descriptor that makesResolveTextureexit.The comment says that incompatible entries stay on the placeholder "rather than reaching ResolveTexture, which exits". The filter checks only null, the float numeric class, and the image type.
ResolveTexturestill callsEXITorEXIT_NOT_IMPLEMENTEDin these cases:base_level > last_levelMinLod() > LastLevel()*256ResolveTextureMipViewfailuresheap.resource.numeric_classdiffers from the format classHeap keys come from shader feedback. A stale or garbage guest heap entry therefore terminates the emulator. This is the crash that the placeholder path is meant to prevent.
Fix: add these same checks to
BindlessCompatibleso that bad entries fall back to the placeholder. As an alternative, add a non-fatal validation mode toResolveTexturethat returns an invalid binding.@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/descriptors.cppline 855 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Bindless cube slots receive a 2D-array view, but the placeholders in the same binding are cube views.
BindlessBindingForsendsresource.cubetoBindlessImagesCube.CreatePlaceholdersfills that binding withvk::ImageViewType::eCubeviews. However,ResolveTexturebuildsdesc.view_infothroughTextureViewInfo, which has no cube case. A cube resource has dimensionDim2DArray, so the resolved view ise2DArray.WriteSlotthen puts ane2DArrayview into the cube array. The shader declaration can match only one of the two view types. The other one is a descriptor/view-type mismatch, which is invalid in Vulkan and gives wrong sampling.Fix: for
heap.binding == BindlessImagesCube, setbinding.desc.view_info.type = vk::ImageViewType::eCubebeforeFindTexture. The layer count must be a multiple of 6. Also confirm that the texture cache creates such images witheCubeCompatible.Proposed fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/host_gpu/renderer/pipeline/descriptors.cppline 979 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
The code skips the SRT patch when heap allocation fails, but the comment says the result is region 0 and count 0.
When
use.imageis out of range orFindOrCreateHeapreturns null, the loop continues without pushing a patch.RebindBuffersthen uploads the unpatchedsnapshot.flattened_srt. If no other patch exists, the whole upload is unpatched.BindlessSlotreads base and count frommapping_offset. It then gets guest data instead of{0, 0}, and it indexes arbitrary translation and feedback entries. The sampler path already pushes{use.mapping_offset, 0, 0}in the same situation.Proposed fix
📝 Committable suggestion
@ -646,0 +683,4 @@diagnostics_config.pNext = &diagnostics_features;create_info.pNext = &diagnostics_config;}}@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Put the NV diagnostics configuration behind a debug option.
This block enables
eEnableShaderDebugInfo | eEnableResourceTracking | eEnableShaderErrorReportingon every NVIDIA device that exposes the extension. These are Aftermath-style debugging flags, and they add runtime overhead to all rendering. Every user on an NVIDIA GPU pays this cost, even without a device-loss investigation.Fix: enable the flags only when a debug option is set, for example
Config::GraphicsDebugDumpEnabled()or a dedicated switch.@ -526,0 +533,4 @@const auto vector_type = uint_output ? TypeU32Vector(state, 4): sint_output ? TypeI32Vector(state, 4): TypeF32Vector(state, 4);auto value = ExportVector(ctx, data, exp, uint_output || sint_output);@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
The pixel MRT store type and the declared output type use different predicates.
DefineOutputspicks the output variable type only fromtarget_uint_maskandtarget_sint_mask.EmitSetAttributealso treatsMrtOutputMode == 7(UINT16_ABGR) asuint_output. For a format-7 export to a float or SINT attachment, the stored vector type differs from the variable type. This produces invalid SPIR-V.src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp#L533-L541: deriveuint_outputandsint_outputfrom the same masks asDefineOutputs, so that they are mutually exclusive. Use format 7 only to choose the rawExportVectorunpacking, then convert the value to the attachment type before the store.src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp#L660-L668: keep the mask-based type as the only source of truth, and share one helper withEmitSetAttribute.📍 Affects 2 files
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp#L533-L541(this comment)src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp#L660-L668@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppline 202 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Some bindless image types go to set-1 bindings of a different shape.
The binding selection gives these images the wrong binding:
Dim1D,Dim1DArrayandDim2DMsaafall through toBindlessImages2D.Dim2DMsaaArraygoes toBindlessImages2DArray.ImageType(state, image)still declares the realDim,ArrayedandMSvalues for these images. The runtime array then aliases a binding whose views are 2D or 2D-array and not multisampled. Vulkan requires the view type to match theOpTypeImagedimensionality, arrayness and multisampling. A mismatch is undefined behavior and can cause device loss.Reject these dimensions for bindless images before materialization, so they keep the enumerated path. The other option is separate bindings for them.
Proposed guard
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppline 343 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Gate the 4096-iteration cutoffs or raise the limit: legitimate long loops now end early with no error.
Both watchdogs are always on:
uses_dma.LoopWatchdogLimit = 4096caps a loop at 4096 iterations.MaxDispatcherTransitions = 4096counts block transitions, not iterations. A loop body of three blocks is therefore cut after about 1365 iterations.Correct shaders can exceed these limits. Examples are list walks over large buffers, per-element compute loops, and long blur or search loops. When a loop is cut, the invocation writes wrong results and nothing is reported. The emulator logs nothing and the draw or dispatch is not skipped.
The PR description says new behavior is opt-in except crash and hang fixes. This is a hang fix, but it applies to every qualifying shader.
Recommended changes:
watchdog_reportsalready is.Also applies to: 934-950
@ -506,0 +521,4 @@}m_failed = true;return;}@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Nonfatal
FailletsPlanScalarReadsindexmemory_infoout of bounds.Failused to exit, so code after aFailcall could assume the call never returned. InTranslationNonFatal()mode it now setsm_failedand returns. Several callers written for the old behavior keep executing after the failure.In
PlanScalarReads, lines 862-866 run:if (flags.index >= m_program.memory_info.size()) Fail(...)const auto& memory = m_program.memory_info[flags.index];With an out-of-range index, that reference is out of bounds and
memory.kindreads past the vector. Line 865 has the same problem: after theNumArgsfailure, the loop still readsinst.Arg(arg).Run()checksm_failedonly afterPlanIndirectImages(). Every block ofPlanScalarReads, thenEliminateDeadCode, thenPlanIndirectImagesruns on the bad state first.Fix: return or skip after each
Failcall inPlanScalarReads, and checkm_failedright afterPlanScalarReads()inRun().Proposed fix
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/graphics/shader/recompiler/ir/passes/ResourceTracking.cppline 2464 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Use
MakeSourceinPlanDefaultSamplers, or valid samplers get replaced by the default sampler.PlanDefaultSamplersdecides whether a sampler is valid by callingLowerDescriptorPhion each raw dword.CollectandPlanBindlessSamplersuseMakeSource, which also does three things this check skips:NativeDescriptorSource.CanonicalizeSampleAdjustDword3whenImageSampleFlagAdjustis set.Without these steps, some samplers fail
ValidateSourcehere even thoughGetHandlewould accept them. For example, a SampleAdjust sampler whose dword 3 carries lane-dependent reserved scratch bits fails this check.TestSampleAdjustSamplerScratchcovers that shape.In nonfatal mode,
PlanDefaultSamplersoverwrites such a sampler with the fixed sampler and marks its reads planning-only. The game's filtering and addressing are lost, and nothing reports a failure.Build the descriptor the same way
PlanBindlessSamplersdoes.Proposed fix
@ -1241,0 +1284,4 @@LOGF_COLOR(flushed ? Log::Color::Green : Log::Color::Red, "\tFsync: %s, %s\n",Common::PathToString(file->real_name).c_str(), flushed ? "[ok]" : "[flush failed]");return OK;@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Return an error when the flush fails.
When
file->f.Flush()returns false,KernelFsyncstill returnsOK. The new POSIX wrapper also receives success. This hides a failed synchronization from guest code that relies onfsyncbefore treating a save as durable. FreeBSD specifies an error return when synchronization fails. (man.freebsd.org)Return
KERNEL_ERROR_EIOfor a failed flush.Proposed fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
On
src/libs/libPngEnc.cppline 229 (outdated):🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Include the PNG filter byte in the height bound.
The guard at Line 227 checks
height > 0x7fffffff / min_pitch, somin_pitch * heightstays withinINT_MAX.stbi_write_png_to_memneeds more space than that. It computes(x*n+1) * yinintarithmetic at Line 1144 of3rdparty/stb/stb_image_write.h. It computes the same product again asy*(x*n+1)forstbi_zlib_compressat Line 1176. Each row has one extra filter byte.Take RGBA input with
width = 1andheight = 0x1fffffff. The guard accepts these values. The requiredimage_mem_sizeis about 2 GiB, and auint32_tcan hold that. stb then computes5 * 0x1fffffff, which is greater thanINT_MAX. Signed overflow is undefined behavior. On common targets, the result wraps to a negative value, andmallocfails. The encode returnsPNG_ENC_ERROR_FATAL, but the code still relies on undefined behavior. The guest controlsimage_widthandimage_height.Bound
heightby the stb row size that includes the filter byte:🐛 Proposed fix
📝 Committable suggestion
@ -1196,0 +1214,4 @@int KYTY_SYSV_ABI SaveDataConvert(const SaveDataConvertParam* convert) {PRINT_NAME();if (convert == nullptr || convert->src_dir_name == nullptr) {@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟠 Major | ⚡ Quick win
Path Traversal
Reachability: External
Exploitability: Moderate
CWE: CWE-22 — Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Validate both directory names before constructing host paths.
A guest can supply an existing source save and
dst_dir_name = "../../victim".save_directorypreserves the traversal components. The recursive copy can then overwrite matching files in a host directory outside_SaveData. Boundedstrnlendoes not enforce path containment. The filesystem copy options permit recursive copying and replacement of existing files. (eel.is)Use
valid_path_componentfor the source and any explicit destination, as the mount and delete APIs already do.Proposed validation
View in Security blast radius
@ -1196,0 +1234,4 @@std::filesystem::copy(from, save_directory(get_title_id(), dst_name, convert->user_id),std::filesystem::copy_options::recursive |std::filesystem::copy_options::overwrite_existing,ec);@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Persist the destination allocation specified by
dst_blocks.If a source save has 48 blocks and conversion requests 96 blocks, this copy retains the source
sce_sys/blocks.bin. Conversion reports success, butSaveDataGetMountInfostill reports 48 blocks. In-place conversion also leaves the allocation unchanged.Validate the requested allocation and update the destination metadata with
write_save_file. Report any metadata-write failure through the conversion event.@coderabbitai[bot] on GitHub · 2026-09-30 00:19 UTC · original · reviewed
Actionable comments posted: 18
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
4888c092-8472-4d20-95a8-efdb21888a8e📥 Commits
Reviewing files that changed from the base of the PR and between
05057c9441and d6ec3a42ed19d0f16bb3e184ca57e20cce8d5176.📒 Files selected for processing (144)
3rdparty/stb/stb_image_write.hCMakeLists.txtsrc/common/CMakeLists.txtsrc/common/assert.cppsrc/common/assert.hsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/graphics/guest_gpu/command_processor/commandProcessor.hsrc/graphics/guest_gpu/command_processor/pm4Handlers.cppsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/guest_gpu/graphicsRun.hsrc/graphics/host_gpu/diagnosticCheckpoints.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/regionManager.hsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.hsrc/graphics/host_gpu/renderer/cache/faultManager.cppsrc/graphics/host_gpu/renderer/cache/faultManager.hsrc/graphics/host_gpu/renderer/cache/streamBuffer.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/commandScheduler.cppsrc/graphics/host_gpu/renderer/context.cppsrc/graphics/host_gpu/renderer/image/image.hsrc/graphics/host_gpu/renderer/image/imageInfo.hsrc/graphics/host_gpu/renderer/image/imageView.hsrc/graphics/host_gpu/renderer/indirectDispatch.cppsrc/graphics/host_gpu/renderer/indirectDispatch.hsrc/graphics/host_gpu/renderer/masterSemaphore.cppsrc/graphics/host_gpu/renderer/pipeline/bindlessTable.cppsrc/graphics/host_gpu/renderer/pipeline/bindlessTable.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/pipeline/descriptors.hsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/host_gpu/renderer/pipeline/shaders.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/shaders/dispatch_indirect_groups.compsrc/graphics/host_gpu/vma.cppsrc/graphics/presentation/videoOut.cppsrc/graphics/presentation/videoOut.hsrc/graphics/presentation/window/swapchain.cppsrc/graphics/presentation/window/vulkanWindow.cppsrc/graphics/shader/recompiler/ShaderRecompiler.cppsrc/graphics/shader/recompiler/ShaderRecompiler.hsrc/graphics/shader/recompiler/Tessellation.cppsrc/graphics/shader/recompiler/Tessellation.hsrc/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cppsrc/graphics/shader/recompiler/backend/spirv/SpirvEmitter.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterAnalysis.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMesh.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cppsrc/graphics/shader/recompiler/frontend/decode/ImageOps.cppsrc/graphics/shader/recompiler/frontend/decode/MemoryOps.cppsrc/graphics/shader/recompiler/frontend/decode/ScalarAluOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/decode/ShaderFunctions.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderFunctions.hsrc/graphics/shader/recompiler/frontend/decode/VectorAluOps.cppsrc/graphics/shader/recompiler/frontend/translate/Bvh.cppsrc/graphics/shader/recompiler/frontend/translate/Compare.cppsrc/graphics/shader/recompiler/frontend/translate/Control.cppsrc/graphics/shader/recompiler/frontend/translate/Dispatch.cppsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/frontend/translate/Scalar.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.cppsrc/graphics/shader/recompiler/frontend/translate/Translator.hsrc/graphics/shader/recompiler/frontend/translate/Vector.cppsrc/graphics/shader/recompiler/ir/BindlessBindings.hsrc/graphics/shader/recompiler/ir/Program.cppsrc/graphics/shader/recompiler/ir/ResourceSnapshot.hsrc/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/graphics/shader/recompiler/ir/passes/BindingLayout.cppsrc/graphics/shader/recompiler/ir/passes/ConstantPropagation.cppsrc/graphics/shader/recompiler/ir/passes/ConstantPropagation.hsrc/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cppsrc/graphics/shader/recompiler/ir/passes/DeadCodeElimination.hsrc/graphics/shader/recompiler/ir/passes/LocalAddressStores.cppsrc/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cppsrc/graphics/shader/recompiler/ir/passes/ReadLaneElimination.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/ResourceTracking.hsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cppsrc/graphics/shader/recompiler/ir/passes/SrtWalker.cppsrc/graphics/shader/recompiler/ir/passes/SrtWalker.hsrc/graphics/shader/shader.cppsrc/graphics/shader/shader.hsrc/graphics/shader/shaderCompiler.hsrc/kernel/eventQueue.cppsrc/kernel/fileSystem.cppsrc/kernel/fileSystem.hsrc/kernel/memory.cppsrc/kernel/memory.hsrc/launcher/forms/configuration_edit_dialog.uisrc/launcher/include/configuration.hsrc/launcher/src/configurationEditDialog.cppsrc/launcher/src/mainDialog.cppsrc/libs/acm.cppsrc/libs/acm.hsrc/libs/agc.cppsrc/libs/ajm.cppsrc/libs/ajm/atrac9_decoder.hsrc/libs/ajm/opus_decoder.hsrc/libs/dialog.cppsrc/libs/libAmpr.cppsrc/libs/libAudio.cppsrc/libs/libKernel.cppsrc/libs/libNet.cppsrc/libs/libPngEnc.cppsrc/libs/libSaveData.cppsrc/libs/libVideoOut.cppsrc/libs/libs.cppsrc/loader/runtimeLinker.cppsrc/loader/x64InstructionEmulator.cppsrc/loader/x64InstructionEmulator.hsrc/main.cpptests/ResourceTrackingTests.cpptests/ScalarProvenanceTests.cpptests/ShaderRayTracingTests.inctests/ShaderRecompilerComputeTests.cpptests/X64LoadEmulationTests.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.
@coderabbitai[bot] on GitHub · 2026-10-01 07:53 UTC · original
On
src/graphics/host_gpu/renderer/renderContext.cppline 140 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9107
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 43507
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42542
Synchronize buffers registered during the current submission.
FindBuffersruns beforePrepareBdafor DMA dispatches.BufferCache::Registerincrementsg_cpu_dirty_epoch, but it does not advanceg_guest_submission_seq. A later dispatch in the same submission can therefore register a new or enlarged buffer, then return fromPrepareBdabecause the submission sequence is unchanged.JoinOverlapcopies only existing overlap contents. The uncovered pages still require guest-memory synchronization. Without it, a BDA read can observe uninitialized device memory instead of guest data.Track registrations separately. Set the flag from
Register, and clear it only afterPrepareBdasynchronizes the mapped ranges. Do not skip synchronization while the flag is set.@coderabbitai[bot] on GitHub · 2026-10-01 07:53 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Include the high VGPR of
V_CMP_EQ_F64invector_limit.This PR adds
V_CMP_EQ_F64, andEmitFloat64Equalreads 64-bit source pairs. OnlyV_CMP_LE_F64,V_CMPX_LE_F64, andV_CMPX_GE_F64extend both sources by 2 here. If the high half of anEQ_F64source is the highest VGPR in the shader,vector_limitdoes not cover it.Proposed fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-01 07:53 UTC · original
On
src/libs/libAudio2.cppline 550 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Measure the device queue across all device ports, not only the first port with PCM.
audioout2_device_queued_usreturns the queued time of the first port in the context that has a positiveaudio_handleand non-emptypcm_data. All push pacing now depends on that one value.The selected port can be an
AUDIO_OUT_PORT_TYPE_PADSPKport with an open SDL stream. When a DualSense is connected,Audio::AudioOutOutputssends that port's PCM toDualSenseHaptics::Queueand never callsQueueSdlAudio. The port's SDL queue therefore stays empty, andAudioOutQueuedUsreturns0.With
device_us == 0, these effects follow:audioout2_level_lockedalways reports level 0, so a non-blocking push is never refused.audioout2_queue_context_audiois called withblocking == false. As a result,QueueSdlAudiodoes not pace the main port, and thePADSPKsleep is skipped.0 <= full_us.The SDL queue of the main port in the same context then grows without a bound. Audio latency increases until the 200 ms clear in a later blocking push, which can only occur on the timer path.
Use the largest queued time over all device-backed ports in the context. A port that does not feed SDL then cannot hide the backlog of a port that does.
Proposed fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-01 07:53 UTC · original · reviewed
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
00ffb172-dcfc-4fff-8f44-567325be7547📥 Commits
Reviewing files that changed from the base of the PR and between d6ec3a42ed19d0f16bb3e184ca57e20cce8d5176 and 3fa2b06dda4c7acfe64f33d8eef6c636405a76dd.
📒 Files selected for processing (45)
CMakeLists.txtsrc/graphics/guest_gpu/command_processor/commandProcessor.hsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/guest_gpu/graphicsRun.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/textureCache.cppsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/host_gpu/renderer/pipeline/shaders.cppsrc/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/presentation/window/vulkanWindow.cppsrc/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/frontend/decode/ImageOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/decode/VectorAluOps.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.cppsrc/graphics/shader/recompiler/frontend/translate/Vector.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/SrtWalker.hsrc/graphics/shader/shader.cppsrc/graphics/shader/shader.hsrc/kernel/memory.cppsrc/kernel/memory.hsrc/kernel/memoryAddressSpace.incsrc/kernel/pthread.cppsrc/libs/audio.cppsrc/libs/audio_internal.hsrc/libs/libAmpr.cppsrc/libs/libAudio2.cpptests/AudioOut2PortTests.cpptests/ResourceTrackingTests.cpptests/ShaderRecompilerComputeTests.cpp💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@ronith256 on GitHub · 2026-10-11 09:44 UTC · original
Linux confirmation for PPSA03671 on PR head
41c7b27:kyty_emulatorlocally with Clang 22.1.8 and glslangValidator 16.2.0.KYTY_IGNORE_WRITTEN_OVERLAP=1 KYTY_LABELS_AFTER_GPU=1 ./kyty_emulator --game /path/to/eboot.bin --bindless --tessellation --readback-linear-images true --amd-cpu --screen-width 1600 --screen-height 900 --shader-validation falsepc 0x0000114cseen on currentmaindid not recur. The game reached its visible opening screen and screen-reader accessibility prompt. The emulator remained running at that prompt.--redzoneis rejected as an unknown option on Linux; the flag is Windows-only insrc/main.cpp, so the Linux command above omits it.@ -1089,0 +1200,4 @@PublishLabelAtCompletion(dst, data, sizeof(data), false);} else if (at_completion) {m_renderer.GetGpu().DeferLabelWrite(reinterpret_cast<uint64_t>(dst), data,sizeof(data));@coderabbitai[bot] on GitHub · 2026-10-11 18:57 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Route the other label conditions through
ReadLabel.With
KYTY_LABELS_AT_COMPLETION=1,DeferLabelWritekeeps the new value pending while backing memory retains the old value.CpOpCondExecstill dereferences its comparison address directly at Line 1444 ofsrc/graphics/guest_gpu/command_processor/pm4Handlers.cpp. BooleanCommandProcessor::SetPredicationdoes the same at Line 929 ofsrc/graphics/guest_gpu/graphicsRun.cpp. If either packet follows a deferred EOP write to that address, it can execute the wrong command path. Use the pending-label-aware read for these conditions too. The scheduler runs the write callback only after its recorded tick. (raw.githubusercontent.com)@ -336,0 +359,4 @@EXIT_NOT_IMPLEMENTED(m_worker_buffer.begin(&begin_info) != vk::Result::eSuccess);});return m_command;}@coderabbitai[bot] on GitHub · 2026-10-11 18:57 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Invalidate the dynamic state in the threaded
BeginCommandpath.The non-threaded path calls
m_dynamic_state.Invalidate()after it begins a new command buffer. The threaded path returns at Line 361 without that call.RenderContextenables the recording thread unconditionally, so every guest command buffer takes this path.A new Vulkan command buffer inherits no dynamic state.
DynamicState::Commitemits only dirty fields. The first draw in each new command buffer is therefore recorded without viewport, scissor, depth, stencil, blend-constant, or color-write state when those values did not change since the previous command buffer. This is undefined behavior in Vulkan: validation errors, wrong rendering, or device loss.Proposed fix
📝 Committable suggestion
@ -336,0 +357,4 @@vk::CommandBufferBeginInfo begin_info {};begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;EXIT_NOT_IMPLEMENTED(m_worker_buffer.begin(&begin_info) != vk::Result::eSuccess);});@coderabbitai[bot] on GitHub · 2026-10-11 18:57 UTC · original
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4111
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41550
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 36798
🌐 Web query:
Vulkan vkGetSemaphoreCounterValue host synchronization requirement vkWaitSemaphores vkGetSemaphoreCounterValue official specification💡 Result:
Serialize
vkGetSemaphoreCounterValuecalls inMasterSemaphore.m_gpu_tickis atomic, so it does not have the proposed C++ data race. However,CommandPool::Commitcan callm_master.Refresh()on the recording thread while scheduler paths callRefresh()concurrently.Refresh()callsvkGetSemaphoreCounterValuewithout external synchronization. Vulkan requires host access for this operation to be externally synchronized.Suggested fix
@ -387,0 +528,4 @@void CommandScheduler::DispatchChunk() {if (m_chunk == nullptr || m_chunk->first == nullptr) {return;}@coderabbitai[bot] on GitHub · 2026-10-11 18:57 UTC · original
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Allocatecan destroy a chunk that holds live stashed data.DispatchChunkreturns without queuing whenm_chunk->first == nullptr. At Lines 519-522,Allocatethen assignsm_chunk = take(). That assignment destroys the old chunk, but the old chunk can already hold arrays fromStashcalls of the command that is being built.Trigger: a fresh chunk receives stash data before its first
Record, and the command's stash data exceeds the remaining space. One example isStashWritesfor a large descriptor or bindless write array. The pointers that were already returned byStashthen dangle. The recording thread later reads freed memory.Fix: dispatch the chunk whenever
used != 0, not only when it holds commands.RecordingThreadalready handles a chunk with an empty command list, and the retention window keeps the chunk alive. Also note that the comment "up to two chunks before" holds only when one command's stash data spans at most two chunks.Proposed fix
📝 Committable suggestion
@ -343,0 +356,4 @@if (!skip_device && !TryGetSurfaceCapabilities(device, surface, candidate_capabilities)) {LOGF("Surface capabilities unavailable, skipping device\n");skip_device = true;}@coderabbitai[bot] on GitHub · 2026-10-11 18:57 UTC · original
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Record the surface-capability failure as a device rejection.
This branch sets
skip_devicedirectly and does not callreject. If this is the only candidate device,out_rejectionsstays empty.CreateVulkanthen exits with "Could not find suitable device:" and gives no reason. Userejectso that the fatal message names the cause.Proposed fix
📝 Committable suggestion
@ -1077,0 +1278,4 @@const auto& b = args[1];switch (op) {case ValueOpcode::IAdd32: out = {a.lo + b.lo, a.hi + b.hi}; break;case ValueOpcode::IMul32: out = {a.lo * b.lo, a.hi * b.hi}; break;@coderabbitai[bot] on GitHub · 2026-10-11 18:57 UTC · original
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 44544
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 25280
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 21804
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 16349
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6350
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10063
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4565
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2286
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2659
Reject wrapped buffer-address extents.
CalculateBufferAddressperforms the buffer additions asuint32_t. A valid store can wrap to a low address and passEmitMemoryElementInBounds.ComputeBufferWriteExtentsuses 64-bit arithmetic instead, so it can setbeginandendto the descriptor limit and report an empty or incomplete range. The overlap check can then miss the store.The
IAdd32andIMul32interval checks already reject results whose upper bound exceedsUINT32_MAX. Add the guard before computing the extent:Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-11 18:57 UTC · original · reviewed
Actionable comments posted: 6
🧹 Nitpick comments (5)
ℹ️ Review info
⚙️ Run configuration
c9d83972-ae0d-467e-83d3-192314b9a485📥 Commits
Reviewing files that changed from the base of the PR and between 41c7b27b738ce882c93108e8b882405e33a78d8d and cc6c83e34c404e2197c4d7b7c5ddc217b8ccda9c.
📒 Files selected for processing (94)
CMakeLists.txtsrc/common/CMakeLists.txtsrc/common/cpuAffinity.cppsrc/common/cpuAffinity.hsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/common/threads.cppsrc/graphics/guest_gpu/command_processor/commandProcessor.hsrc/graphics/guest_gpu/command_processor/pm4Handlers.cppsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/graphicContext.hsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.hsrc/graphics/host_gpu/renderer/cache/faultManager.cppsrc/graphics/host_gpu/renderer/cache/streamBuffer.cppsrc/graphics/host_gpu/renderer/cache/streamBuffer.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/commandRecorder.hsrc/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/dynamicState.cppsrc/graphics/host_gpu/renderer/dynamicState.hsrc/graphics/host_gpu/renderer/image/blitHelper.cppsrc/graphics/host_gpu/renderer/image/image.cppsrc/graphics/host_gpu/renderer/image/image.hsrc/graphics/host_gpu/renderer/image/imageInfo.hsrc/graphics/host_gpu/renderer/image/tiler.cppsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/host_gpu/renderer/pipeline/shaderResourceBarrier.cppsrc/graphics/host_gpu/renderer/pipeline/shaderResourceBarrier.hsrc/graphics/host_gpu/renderer/pipeline/shaders.cppsrc/graphics/host_gpu/renderer/render.hsrc/graphics/host_gpu/renderer/renderCompute.cppsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/renderDraw.cppsrc/graphics/host_gpu/renderer/sync.cppsrc/graphics/presentation/window/swapchain.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/spirvEmitterAlu.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterAluHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cppsrc/graphics/shader/recompiler/frontend/decode/ImageOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/translate/Attribute.cppsrc/graphics/shader/recompiler/frontend/translate/Integer.cppsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/frontend/translate/Scalar.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.cppsrc/graphics/shader/recompiler/frontend/translate/Translator.hsrc/graphics/shader/recompiler/ir/ResourceSnapshot.hsrc/graphics/shader/recompiler/ir/ShaderIR.hsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/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/graphics/shader/shader.cppsrc/graphics/shader/shader.hsrc/kernel/eventQueue.cppsrc/kernel/fileSystem.cppsrc/kernel/fileSystem.hsrc/kernel/memory.cppsrc/kernel/memory.hsrc/libs/agc.cppsrc/libs/avPlayer.cppsrc/libs/dialog.cppsrc/libs/libAmpr.cppsrc/libs/libKernel.cppsrc/libs/libNet.cppsrc/main.cpptests/AvPlayerFileTests.cpptests/ResourceTrackingTests.cpptests/ScalarProvenanceTests.cpptests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@ -1143,0 +1270,4 @@value, sizeof(value));} else {std::memcpy(dst, &value, sizeof(value));}@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 16202
Skip the Sync data write when labels are published at completion.
Sync::WriteAtEndOfPipe64and its writeback variants write the supplied packet value todst. WhenLabelsAfterGpu()andclock_valueare both true,PublishLabelAtCompletionschedules the completion-time timestamp, but the Sync write can overwrite that timestamp with the raw packet payload. Ensure these paths signal or interrupt without performing a second data write.@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/host_gpu/renderer/renderContext.cppline 23 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Clear
on_bindless_unregisterbefore the members are destroyed. Otherwise shutdown can crash.m_bindless_tableis declared afterm_texture_cache, so it is destroyed first.~TextureCachethen callsUnregisterImagefor every registered image. For an image withbindless_pinnedset,UnregisterImageinvokes the callback. The callback callsm_bindless_table.OnImageUnregisteredon the destroyed table. That call reads the freedm_image_refs. It then callsWriteSloton the destroyed set and pool, andSetTranslationdereferences the resetm_translation.This happens at every shutdown with
--bindlessafter at least one key has resolved.Proposed fix
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/host_gpu/renderer/renderContext.cppline 149 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
PrepareBdaskips BDA synchronization after writes that the command processor makes in the current submission.When only
g_cpu_dirty_epochhas advanced within a submission, the function returns without synchronizing. Some writes in a submission are ordered before later dispatches by the command processor itself:BufferCache::CopyBuffer(CPUmemcpypath)FillBuffer(std::fillpath)WriteDatafallback (memcpy)These writes take write faults on tracked pages. The faults mark the pages CPU-dirty and advance the epoch. A later
uses_dmadispatch in the same submission then reads the stale device copy through BDA. Normal bindings are not affected, becauseObtainBufferuploads CPU-dirty ranges.This is a different trigger from the
Registercase in the earlier review comment. Do not skip synchronization when the epoch change came from the GPU thread. For example, keep a separate counter thatChangeState<Cpu, true>advances whenGuestGpu::IsGpuThread()is true. Then require synchronization whenever that counter has changed.@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/presentation/window/vulkanWindow.cppline 533 (outdated):🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Also limit the bindless sampled-image count by the per-stage update-after-bind limit.
BindlessTablecreates four arrays ofm_images_per_array = min(16384, bindless_max_sampled_images / 4)sampled images. The arrays useeAllstages, and every bindless pipeline layout includes them.maxPerStageDescriptorUpdateAfterBindSampledImageslimits the total sampled images in one stage, including the images in set 0. This code checks onlymaxDescriptorSetUpdateAfterBindSampledImages. On a device with a smaller per-stage limit, the pipeline layout exceeds the limit. The sampler limit on the next lines already takes the minimum of the two limits.Proposed fix
Reserve headroom for the set 0 images too. For example, subtract a fixed per-stage budget before dividing by
ImageArrays.📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppline 1249 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8126
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 13780
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8408
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10130
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10045
Preserve descriptor words for
gpu_recordsbuffers.CompileProgramzeroes allGetBufferResourcearguments unless the resource is anIndirectBuffer. Agpu_recordsresource remains aBuffer, soPrepareIndirectBufferAccessreceives zero descriptor words. Itsvalid_formatpredicate is then false, which disables loads and stores throughEnabledAccess; load and atomic results become zero, and stores are skipped.🐛 Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cppline 125 (outdated):🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
64-bit buffer atomics compare a qword index against a dword length.
access.lengthis nowmemory_dword_lengths[...], which counts dwords.EmitBufferAtomic64(src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp, Lines 1463-1468) computes a qword index (byte_address >> 3) and passes it toEmitMemoryElementInBoundswith this length. Before this change,OpArrayLengthon the u64 runtime array returned a qword count. Now the check allows indices up to twice the bound range. An out-of-bounds guest atomic can then change memory beyond the buffer instead of being dropped.Scale the length when the pointer type is the u64 array.
Proposed fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/shader/recompiler/frontend/translate/Memory.cppline 657 (outdated):🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
FLAT_APERTUREemits LDS accesses in stages without workgroup LDS, which brings back the 8192-dword per-invocation array.Every segment-0 flat access now also emits
LoadSharedU*orWriteSharedU*with the raw addresslow. In a vertex or pixel shader,AnalyzeProgramRequirementssetsfunction_ldsfor these accesses.UpperBoundU32(low)has no bound, sofunction_lds_unboundedis true.LdsDwordCountthen falls back to 8192 dwords of Function storage per invocation. The comment inSpirvEmitter.cpp(Line 263-265) says this costs several GB of local memory across the GPU on NVIDIA. Before this change, flat accesses did not create any function LDS.Emit the shared path only when the stage has workgroup LDS (
ShaderWorkgroupInput(...) != nullptr). In other stages, treat the shared aperture as returning zero or as not supported.Also applies to: 675-676
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/shader/recompiler/frontend/translate/Translate.cppline 142 (outdated):🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🌐 Web query:
RDNA2 ISA SRC_SHARED_BASE 32-bit operand returns high 32 bits aperture💡 Result:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 19605
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 16091
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2568
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1620
Preserve 64-bit aperture pairs while fixing 32-bit base reads.
ReadU32reachesReadRawU32, so 32-bitSRC_SHARED_BASEandSRC_PRIVATE_BASEreads currently return zero. These operands provide the aperture high word. Return the matching aperture constant for direct 32-bit reads.ReadU32Pairalso usesReadRawU32as the low word. Keep that low word zero for 64-bit aperture reads, or the aperture high word will be written into both halves.Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/graphics/shader/recompiler/ShaderRecompiler.cppline 548 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
UserDataSourcemisses writes from multi-dword instructions.The
writeslambda checks onlyoperand.reg == regandoperand.reg + 1u == reg. An instruction that writes more than two SGPRs, such asS_LOAD_DWORDX4 s[8:11], overwritess10but does not stop the backward scan. The scan then continues past the overwrite and returns an earlierS_MOV_B32 s10, sNas the source.InlineSubroutineCallsthen reads the callee from the wrong user-data address and inlines the wrong code. Before this change, such calls stayed unsupported. Now the GPU runs code the guest did not call, which can hang it.Use the destination width:
Proposed fix
Then call
writes(inst.dst, inst.data_dwords)andwrites(inst.dst2, 2u).@ -548,0 +729,4 @@const auto command_buffer_addr = reinterpret_cast<uint64_t>(command_buffer);const auto id =AprShared::AllocateSubmissionId(command_buffer_addr, reinterpret_cast<uint64_t>(result));@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
Submissions with a result but no ID leak their tracking entries.
SubmitCommandBufferAndGetResultalways callsAllocateSubmissionId, even whenout_submission_idis null. With a nullout_submission_id, the guest gets no ID and cannot callWaitCommandBuffer.CompleteSubmissionis the only path that erases a completed entry. As a result, every such submission leaves oneSubmissionStateing_submissionspermanently. A title that submits this way every frame grows the map without bound.AmmSubmitCommandBufferAndGetResult(lines 3181-3183) has the same defect. The result already reaches the guest throughExecute, which callsWriteResultwithsubmission.result. Also, if the finalWriteGuestof the ID fails, the entry is never retired.Allocate an ID only when the caller can receive it. Otherwise pass
0.Proposed fix
Apply the same change in
AmmSubmitCommandBufferAndGetResult. Guard eachDiscardSubmission(id)call withid != 0.📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original
On
src/libs/libAudio2.cppline 599 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Blocking device pushes can wait forever if the device stops draining.
A device-backed push now calls
AudioOutOutputswithblocking == false. This bypasses the 200 msSDL_ClearAudioStreamfallback inAudio::QueueSdlAudio. After that, the loop at lines 594-598 sleeps untilAudioOutQueuedUsdrops tofull_usor below. The loop has no timeout.The SDL queue stops draining in these cases:
In those cases the queued time stays above
full_us. The guest audio thread then hangs insideAudioOut2ContextPush. The outer loop at lines 569-608 has the same problem: while the device level stays atqueue_depth, a blocking push sleeps in 1 ms steps indefinitely.Add a deadline to both waits, for example about 200 ms, to match the old backend behavior. When the deadline passes, return or clear the stream.
Proposed fix (post-push wait)
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-11 19:31 UTC · original · reviewed
Actionable comments posted: 11
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
574f992b-462b-4755-b7bd-dcba69b1b021📥 Commits
Reviewing files that changed from the base of the PR and between cc6c83e34c404e2197c4d7b7c5ddc217b8ccda9c and 41c7b27b738ce882c93108e8b882405e33a78d8d.
📒 Files selected for processing (122)
CMakeLists.txtsrc/common/CMakeLists.txtsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/graphics/guest_gpu/command_processor/commandProcessor.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/regionManager.hsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.hsrc/graphics/host_gpu/renderer/cache/faultManager.cppsrc/graphics/host_gpu/renderer/cache/faultManager.hsrc/graphics/host_gpu/renderer/cache/streamBuffer.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/commandScheduler.cppsrc/graphics/host_gpu/renderer/context.cppsrc/graphics/host_gpu/renderer/image/image.hsrc/graphics/host_gpu/renderer/image/imageInfo.hsrc/graphics/host_gpu/renderer/image/imageView.hsrc/graphics/host_gpu/renderer/indirectDispatch.cppsrc/graphics/host_gpu/renderer/indirectDispatch.hsrc/graphics/host_gpu/renderer/pipeline/bindlessTable.cppsrc/graphics/host_gpu/renderer/pipeline/bindlessTable.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/pipeline/descriptors.hsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/host_gpu/renderer/pipeline/shaders.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/shaders/dispatch_indirect_groups.compsrc/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/spirvEmitterAnalysis.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMemoryHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterMesh.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cppsrc/graphics/shader/recompiler/frontend/decode/ImageOps.cppsrc/graphics/shader/recompiler/frontend/decode/MemoryOps.cppsrc/graphics/shader/recompiler/frontend/decode/ScalarAluOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/decode/VectorAluOps.cppsrc/graphics/shader/recompiler/frontend/translate/Bvh.cppsrc/graphics/shader/recompiler/frontend/translate/Compare.cppsrc/graphics/shader/recompiler/frontend/translate/Control.cppsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/frontend/translate/Scalar.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.cppsrc/graphics/shader/recompiler/frontend/translate/Translator.hsrc/graphics/shader/recompiler/frontend/translate/Vector.cppsrc/graphics/shader/recompiler/ir/BindlessBindings.hsrc/graphics/shader/recompiler/ir/Program.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/opcodes/ValueOpcodes.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/graphics/shader/recompiler/ir/passes/BindingLayout.cppsrc/graphics/shader/recompiler/ir/passes/ConstantPropagation.cppsrc/graphics/shader/recompiler/ir/passes/ConstantPropagation.hsrc/graphics/shader/recompiler/ir/passes/DeadCodeElimination.cppsrc/graphics/shader/recompiler/ir/passes/DeadCodeElimination.hsrc/graphics/shader/recompiler/ir/passes/LocalAddressStores.cppsrc/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/graphics/shader/shader.cppsrc/graphics/shader/shader.hsrc/kernel/eventQueue.cppsrc/kernel/fileSystem.cppsrc/kernel/fileSystem.hsrc/kernel/memory.cppsrc/kernel/memory.hsrc/kernel/memoryAddressSpace.incsrc/launcher/forms/configuration_edit_dialog.uisrc/launcher/include/configuration.hsrc/launcher/src/configurationEditDialog.cppsrc/launcher/src/mainDialog.cppsrc/libs/agc.cppsrc/libs/audio.cppsrc/libs/audio_internal.hsrc/libs/dialog.cppsrc/libs/libAmpr.cppsrc/libs/libAudio2.cppsrc/libs/libKernel.cppsrc/libs/libNet.cppsrc/loader/runtimeLinker.cppsrc/loader/x64InstructionEmulator.cppsrc/loader/x64InstructionEmulator.hsrc/main.cpptests/AudioOut2PortTests.cpptests/ResourceTrackingTests.cpptests/ScalarProvenanceTests.cpptests/ShaderRayTracingTests.inctests/ShaderRecompilerComputeTests.cpptests/X64LoadEmulationTests.cpptests/shaderCfgTests.cpp💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
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.