gpu: host fixes for My First Gran Turismo (formats, EQAA, depth, blend, 3D images, view rebind) #1033
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!1033
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1033/head"
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?
@defektu on GitHub · 2026-10-04 01:02 UTC · original
defektu:pr/mfgt-host→main· +437 −49 · 16 files · 17 commits · closed without mergingThis is one of a few PRs that together get My First Gran Turismo (PPSA24156) running: #1030 (font), #1031 (hle), #1032 (tess), #1033 (host), #1034 (shader), and the draft #1035 (mixed sample counts), which the game also needs to get past the loading screen after "Start" (without it the game stops with "mixed color/depth sample counts are unsupported"). Each PR builds and passes the tests on its own; the title only works with all of them.
Checked by hand on a combined branch (all of the above) on an RTX 5060 Ti, Windows 11, clean save data: intro, title screen (car, lighting, reflections), main menu and the License Center screen. The individual PRs were not run in the game on their own.
Note: on current
mainthis title waits at the "Sign in to PlayStation Network" dialog untilCancelis pressed; that comes from the sign-in dialog change, not from this PR.Commits
Body
Small host-side fixes, one per commit, each reached by My First Gran Turismo:
from the device instead of assumed;
PARTIALLY_RESIDENTignored, sampled depth views through a compatible format;("texture requires rediscovery");
session ("attempted to access invalid address"; the License Center screen of the title hits it), since an
unbacked range reads zero and drops writes on the hardware.
Review notes
NumFramesBeforeRemoval, memory threshold). It may no longer be neededafter the rebind fix and can be dropped if reviewers prefer.
8b0cc79a); theytouch the same area but apply without conflicts.
Testing: builds, 23 test executables pass.
🤖 Generated with Claude Code
Resolving all images first and then asking for views left a window where a later resolve could free an earlier image ("texture requires rediscovery"). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> (cherry picked from commit f346d1f27540b3ccd2a48ea933ec94d970b75a7e)A buffer descriptor or vertex buffer whose base the kernel has not committed made ClampRangeSize EXIT ("attempted to access invalid address"), which took the session down as soon as the License Center screen of My First Gran Turismo was entered (a 160 MiB range at an unbacked address). On the hardware an unbacked range reads zero and drops writes, so binding nothing reproduces it. TryClampRangeSize is the non-exiting query (0 for a range that starts outside committed memory); ClampRangeSize keeps its behaviour on top of it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>The GC headroom change made the collector's trigger a fixed 0.5 GiB (threshold = budget - 1 GiB, trigger = (budget - threshold) / 2) so it ran on almost every tick and freed clean textures that then had to be re-uploaded. The view rebind fix covers the failure it was meant for ("texture requires rediscovery"). The same commit also carried an unused flag and a verbose rediscovery diagnostic. textureCache.cpp is now main plus the 2D/3D mismatch handling only. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original · edited 2026-10-04 02:48 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
5d7b479e-9c9c-4867-a248-bbe3dbf599de📥 Commits
Reviewing files that changed from the base of the PR and between
09d65c5d32andf470440493.📒 Files selected for processing (6)
src/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/pipeline/blendMapping.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/shaders.cppsrc/graphics/host_gpu/vulkanCommon.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
📝 Walkthrough
Walkthrough
The changes expand guest and Vulkan texture-format handling, including scaled-format image conversion. They update image creation, texture-cache behavior, and render-target validation. They add read-only storage-buffer recovery and change image rebinding order. Blend mapping, vertex input, polygon draws, mesh draw data, and memory-range handling also change.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🟡 Moderate · up to
f4704Specific format, blending, cache-replacement, and buffer-range cases can render incorrectly, lose GPU-written texture contents, or terminate the emulator. These are bounded paths, but they warrant correction or explicit acceptance before merging.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
f4704The reviewed changes do not demonstrate increased host privileges or a new external attack surface. However, replacing a resource can discard its latest data, and incomplete coverage leaves some recovery guarantees unproven.
Retained concerns
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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-10-04 01:09 UTC · original · edited 2026-10-04 02:30 UTC
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 162 (outdated):🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
The new threshold makes the GC trigger a fixed 0.5 GiB.
thresholdis nowbudget - 1 GiB. The trigger is computed as(budget - threshold) / 2, so it is always 0.5 GiB, whatever the budget. The old code cappedthresholdat 8 GiB, so the trigger grew with large budgets.With this change,
RunGarbageCollectorruns on almost every tick once usage passes 0.5 GiB. Each run collects images older than 16 ticks. Clean textures are then freed and re-uploaded over and over. This contradicts the comment, which says the collector should start later.Compute
m_trigger_gc_memoryfrom a value that grows with the budget, for example a fraction ofbudget.Proposed fix
✅ Addressed in commits
96350b9tof470440@ -1294,0 +1298,4 @@// Reusing a 2D image for a 3D view (or the reverse) builds an incompatible view,// so drop it and insert a fresh image sized for the requested dimensionality.FreeImage(result);result = {};@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
This path discards GPU-written content on a 2D/3D mismatch.
FreeImageclearsGpuModifiedbefore it deletes the image. The replacement is then built from guest memory. If a render target or storage write produced the 2D image, the GPU content is lost. The 3D view then samples stale guest bytes.ResolveDepthOverlapcopies data into its replacement, but this path does not. Before you free an image that hasIsGpuModified(), download it withDownloadImageMemory, or copy it into the new image.@ -37,0 +51,4 @@// with different equations the channel that moved into the alpha slot gets the alpha equation// and the logical alpha gets the colour one. It is the closest fixed-function blending gets;// switching blending off instead would overwrite every channel.if (alpha_differs && !permutation) {@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Keep differing alpha equations unsupported when alpha moves.
If a permutation moves alpha and
alpha_differsis true, this condition now permits blending. Vulkan still applies the alpha equation to the output alpha slot, not to the slot that received the shader’s logical alpha. Supplying logical alpha through a second source does not move that equation. The affected component therefore gets the wrong blend result. Keep this caseUnsupportedunless pipeline setup can implement the permuted equations.@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original · edited 2026-10-04 02:30 UTC
On
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppline 740 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Require an active target-0 alpha remap before using the second source.
If MRT1 is already active,
GetGraphicsProgramsdoes not enablealpha_blend_source_remap. A permuted target 0 nevertheless passes this blend check, and Line 753 makes its source-alpha factors readSrc1Colorwithout the matching shader remap. For a permuted nonzero target, Line 753 also changes target 0’s factors, although the blend setup only supports second-source remapping on target 0. Gate second-source blending on the actual target-0 shader remap. Otherwise, retain the unsupported-mapping fallback.Also applies to: 753-753
✅ Addressed in commits
96350b9tof470440@ -123,0 +129,4 @@LOGF("InputFormat: reading PS5 buffer format 52 (64xU64) as vk::Format::eR64Uint\n");logged_52 = true;}format = vk::Format::eR64Uint;@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original · edited 2026-10-04 01:50 UTC
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9525
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 36502
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 17739
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7555
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6857
Check
eR64Uintvertex-buffer support before pipeline creation.When raw format
52reachesGetInputFormat, it selectsvk::Format::eR64Uintfor the vertex attribute. Device selection does not check this format’sbufferFeaturesforVK_FORMAT_FEATURE_VERTEX_BUFFER_BIT. On a device without that feature, the vertex-input description violates VUID-VkVertexInputAttributeDescription-format-00623, and pipeline creation can fail. Check the feature and handle unsupported devices before creating the pipeline.✅ Addressed in commits
96350b9to7728fcc@ -49,0 +50,4 @@// TextureGetRenderTargetFormat applies as a component mapping on top of the host formats below// (B10G11R11, A2B10G10R10). A plain texture or buffer view of these layouts would see its// fields in the other order.{Prospero::BufferFormat::k10_11_11Float, vk::Format::eB10G11R11UfloatPack32},@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Do not map
k10_11_11Floatdirectly toeB10G11R11UfloatPack32.The guest format places its 10-bit component in bits 0–9. Vulkan places the 10-bit B component in bits 22–31. This mapping decodes texels with the wrong component widths and offsets. Repack the bits or use a conversion path before sampling. (docs.vulkan.org)
@ -49,0 +54,4 @@{Prospero::BufferFormat::k2_10_10_10UNorm, vk::Format::eA2B10G10R10UnormPack32},{Prospero::BufferFormat::k2_10_10_10SNorm, vk::Format::eA2B10G10R10SnormPack32},{Prospero::BufferFormat::k2_10_10_10UInt, vk::Format::eA2B10G10R10UintPack32},{Prospero::BufferFormat::k2_10_10_10SInt, vk::Format::eA2B10G10R10SintPack32},@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Convert
k2_10_10_10before using these Vulkan formats.Guest format metadata places the two-bit component at bit offset 0. Every mapped
A2B10G10R10format places its two-bit A component in bits 30–31. A component swizzle cannot correct the different field boundaries. Repack the texels or select a backing representation that preserves the guest layout. (docs.vulkan.org)@ -399,0 +418,4 @@Prospero::TextureNumericClass::Float) {return {};}return info;@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original · edited 2026-10-04 01:50 UTC
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Handle scaled formats in
UnpackImageGather.A scaled 2D gather now passes this validation and returns a float vector from the normalized backing image.
UnpackImageGatherstill emitsOpCompositeExtractwithTypeU32for that vector. The generated SPIR-V has a result type that does not match the extracted component. Add a float gather path that rescales each lane and applies the selector, or reject scaled gathers before emission. (registry.khronos.org)🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14569
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 35561
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 20201
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 23667
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4007
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3003
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5076
🌐 Web query:
SPIR-V specification OpCompositeExtract result type must match type of extracted component💡 Result:
Reject scaled storage writes or pack their float components.
ValidateStorageTextureaccepts scaled formats asFloatstorage formats. ForImageWrite,StoreTexelbuilds anF32vector, thenPackImageTexelextracts each component asU32. This can emit invalid SPIR-V becauseOpCompositeExtractmust return the selected component type. Implement float-to-normalized packing for scaled writes, or reject those writes during storage validation.✅ Addressed in commits
96350b9to7728fcc@coderabbitai[bot] on GitHub · 2026-10-04 01:09 UTC · original · reviewed
Actionable comments posted: 9
ℹ️ Review info
⚙️ Run configuration
c24ef177-2a12-43b6-a321-d1ef5d1de09c📥 Commits
Reviewing files that changed from the base of the PR and between
db17585277anddeecc8f11d.📒 Files selected for processing (14)
src/graphics/guest_gpu/gpu_format.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/colorRenderTarget.cppsrc/graphics/host_gpu/renderer/depthRenderTarget.cppsrc/graphics/host_gpu/renderer/image/image.cppsrc/graphics/host_gpu/renderer/image/imageView.hsrc/graphics/host_gpu/renderer/pipeline/blendMapping.cppsrc/graphics/host_gpu/renderer/pipeline/blendMapping.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/shaders.cppsrc/graphics/host_gpu/renderer/renderDraw.cppsrc/graphics/host_gpu/vulkanCommon.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
@ -726,0 +732,4 @@"base=0x%016" PRIx64 " size=0x%016" PRIx64 "\n",i, range.base_address, range.RequestedSize());}range.acquired_end = range.base_address;@coderabbitai[bot] on GitHub · 2026-10-04 01:28 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Bind a null vertex buffer when the range is uncommitted.
If
TryClampRangeSizereturns zero for a nonempty vertex descriptor, this branch leavesacquired_endequal tobase_address. The slot search at Line 758 cannot match that range.AcquireVertexBuffersthen exits at Line 764, so the new nonfatal path still ends the session. Handle the empty acquired range during slot reconstruction and supply a valid null-buffer binding.@coderabbitai[bot] on GitHub · 2026-10-04 01:28 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
8149b1b5-5040-4391-9274-391d51af1785📥 Commits
Reviewing files that changed from the base of the PR and between
deecc8f11dand09d65c5d32.📒 Files selected for processing (4)
src/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/renderDraw.cppsrc/kernel/memory.cppsrc/kernel/memory.hIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.
@dammitjeff on GitHub · 2026-10-04 10:02 UTC · original
Seems like this PR fixes the persistent loading screen crashes in Kena: Bridge of Spirits (PPSA01746, v1.016)
Right after trying to load in a new came or continue, we'd get an error every time:
Memory: attempted to access invalid address 0x0000350000000400 with size 0x00000000000000d8in src/kernel/memory.cpp:901Now the game consistently loads into gameplay and has stayed in game across several boots including cutscenes!! Performance still sucks haha, and character textures are missing but that's awesome this PR got the crashing fixed as a side effect of getting GT running :)

Tested on Windows 11, RTX 5080, Ryzen 9 7900x.
@defektu on GitHub · 2026-10-04 13:17 UTC · original
Thanks for the info and tests @dammitjeff . I am having similar error in GT after starting a track sometimes.
Will check that out.
@Nmzik on GitHub · 2026-10-04 23:05 UTC · original
@defektu Thanks. Most of changes are in main. Credited
@defektu on GitHub · 2026-10-13 11:31 UTC · original
@Nmzik closing this PR and tagging you for to check.
Pull request closed