Fix GTA V boot-time text glyph loss #449

Closed
github-bot wants to merge 1 commit from gh-pr/449/head into gh-pr/449/base
Owner

@⁠CheesyPoofs346 on GitHub · 2026-09-02 00:41 UTC · original
CheesyPoofs346:gta5-text-fix → main · +335 −3 · 6 files · 1 commits · closed without merging

Summary

  • Fix GTA V boot-time text glyph loss by materializing the boot font's BDA-backed source pages before its one-shot compute dispatch.
  • Keep incompatible storage and sampled R8 atlas views separate, publishing storage-written atlas bytes before the sampled view is created.
  • Add focused coverage for BDA range prefetch and the 2048x4096 R8 Standard64KB text-atlas layout.

Problem

In Grand Theft Auto V (PPSA04264), the boot/legal screen and the UI shown before gameplay rendered only scattered glyphs. Characters remained at their correct positions, but most glyphs were invisible; for example, Performance appeared as f manc. The in-game settings screen could render correctly, so this was not a missing-font-file problem.

The same font atlas was available to other text draws in the same frame, which ruled out missing glyph assets. The surviving characters also preserved their original spacing, ruling out displaced geometry. The failure was specific to the boot-time rendering path.

Cause

The boot font compute shader reads its glyph source through buffer device address (BDA). During the one-shot boot atlas build, dynamically referenced source pages could be read before they had been materialized in the buffer cache. Those reads returned unavailable or zero data, leaving the affected glyphs invisible.

A second cache issue could merge the atlas storage image and its differently formatted sampled view. The text atlas uses an R8 integer storage view and an R8 normalized sampled view; treating those as one image owner could leave the sampled view with stale or incorrectly interpreted contents.

Fix

  • Add PrepareBdaRange, which page-aligns and materializes only mapped pages in a bounded range before synchronizing BDA resources.
  • Apply that prefetch to the identified GTA V boot-font compute dispatch, deriving the source address from the dispatch user data.
  • Prevent incompatible R8 storage/sampled atlas owners from being merged.
  • Publish GPU-written storage-image contents before separating the cache owners.

The prefetch is bounded and targeted to the identified boot-font dispatch; normal DMA dispatches retain the existing BDA preparation path.

Verification

  • Built with clang-cl/Ninja:
    • ninja -C _Build/profile-buffer-readback shader_recompiler_compute_tests
    • ninja -C _Build/profile-buffer-readback kyty_emulator
  • Focused regression test passed:
    • shader_recompiler_compute_tests.exe --bda-prefetch-only
  • Launched GTA V through the save-backed test launcher; save slots were detected and backed up before launch.
  • Verified in GTA V that the previously missing boot/start text renders, while the in-game settings text remains correct.

AI assistance was used for this change.

**@⁠CheesyPoofs346** on GitHub · 2026-09-02 00:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449) `CheesyPoofs346:gta5-text-fix` → `main` · +335 −3 · 6 files · 1 commits · closed without merging ## Summary - Fix GTA V boot-time text glyph loss by materializing the boot font's BDA-backed source pages before its one-shot compute dispatch. - Keep incompatible storage and sampled R8 atlas views separate, publishing storage-written atlas bytes before the sampled view is created. - Add focused coverage for BDA range prefetch and the 2048x4096 R8 Standard64KB text-atlas layout. ## Problem In Grand Theft Auto V (PPSA04264), the boot/legal screen and the UI shown before gameplay rendered only scattered glyphs. Characters remained at their correct positions, but most glyphs were invisible; for example, `Performance` appeared as `f manc`. The in-game settings screen could render correctly, so this was not a missing-font-file problem. The same font atlas was available to other text draws in the same frame, which ruled out missing glyph assets. The surviving characters also preserved their original spacing, ruling out displaced geometry. The failure was specific to the boot-time rendering path. ## Cause The boot font compute shader reads its glyph source through buffer device address (BDA). During the one-shot boot atlas build, dynamically referenced source pages could be read before they had been materialized in the buffer cache. Those reads returned unavailable or zero data, leaving the affected glyphs invisible. A second cache issue could merge the atlas storage image and its differently formatted sampled view. The text atlas uses an R8 integer storage view and an R8 normalized sampled view; treating those as one image owner could leave the sampled view with stale or incorrectly interpreted contents. ## Fix - Add `PrepareBdaRange`, which page-aligns and materializes only mapped pages in a bounded range before synchronizing BDA resources. - Apply that prefetch to the identified GTA V boot-font compute dispatch, deriving the source address from the dispatch user data. - Prevent incompatible R8 storage/sampled atlas owners from being merged. - Publish GPU-written storage-image contents before separating the cache owners. The prefetch is bounded and targeted to the identified boot-font dispatch; normal DMA dispatches retain the existing BDA preparation path. ## Verification - Built with clang-cl/Ninja: - `ninja -C _Build/profile-buffer-readback shader_recompiler_compute_tests` - `ninja -C _Build/profile-buffer-readback kyty_emulator` - Focused regression test passed: - `shader_recompiler_compute_tests.exe --bda-prefetch-only` - Launched GTA V through the save-backed test launcher; save slots were detected and backed up before launch. - Verified in GTA V that the previously missing boot/start text renders, while the in-game settings text remains correct. AI assistance was used for this change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:21:25 +00:00
github-bot closed this pull request 2026-11-26 09:21:25 +00:00
Author
Owner

@⁠CheesyPoofs346 on GitHub · 2026-09-02 00:44 UTC · original

Closing this GTA V-specific version; a generalized BDA prefetch implementation will replace it.

**@⁠CheesyPoofs346** on GitHub · 2026-09-02 00:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#issuecomment-5502617932) Closing this GTA V-specific version; a generalized BDA prefetch implementation will replace it.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-09-02 00:45 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 942e7914b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-09-02 00:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#pullrequestreview-5084527064) · **reviewed** ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `942e7914b6` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
@ -334,3 +334,3 @@
FindBuffers(bindings);
if (program.info.uses_dma) {
m_context.GetGpuResources().PrepareBda();
if (sh_ctx.GetCs().cs_regs.data_addr == 0x0000000242d47200ull &&
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-09-02 00:45 UTC · original

P2 Badge Identify the font shader independently of its runtime address

When another GTA V build or runtime allocation places this same compute shader at a different guest virtual address, the equality check fails and the dispatch falls back to ordinary PrepareBda(), so the source pages responsible for the missing glyphs are never materialized. The already-available program.shader_hash or stable shader characteristics should identify this dispatch instead of the observed address from one executable layout.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-09-02 00:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#discussion_r3909742047) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Identify the font shader independently of its runtime address** When another GTA V build or runtime allocation places this same compute shader at a different guest virtual address, the equality check fails and the dispatch falls back to ordinary `PrepareBda()`, so the source pages responsible for the missing glyphs are never materialized. The already-available `program.shader_hash` or stable shader characteristics should identify this dispatch instead of the observed address from one executable layout. Useful? React with 👍 / 👎.
@ -337,0 +342,4 @@
if (source >= prefetch_before) {
m_context.GetGpuResources().PrepareBdaRange(
source - prefetch_before, prefetch_before + prefetch_after);
}
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-09-02 00:45 UTC · original

P2 Badge Preserve BDA preparation when the source is below the prefix

For this selected shader, if the decoded source is nonzero but below 0x40000, this branch performs neither PrepareBdaRange() nor the previous PrepareBda(). A dispatch using a mapped low BDA address therefore loses all BDA synchronization, not merely the optional preceding-range prefetch; this path should fall back to normal BDA preparation when the prefix cannot be subtracted.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-09-02 00:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#discussion_r3909742053) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve BDA preparation when the source is below the prefix** For this selected shader, if the decoded source is nonzero but below `0x40000`, this branch performs neither `PrepareBdaRange()` nor the previous `PrepareBda()`. A dispatch using a mapped low BDA address therefore loses all BDA synchronization, not merely the optional preceding-range prefetch; this path should fall back to normal BDA preparation when the prefix cannot be subtracted. Useful? React with 👍 / 👎.
@ -337,0 +345,4 @@
}
} else {
m_context.GetGpuResources().PrepareBda();
}
Author
Owner

@⁠Copilot on GitHub · 2026-09-02 00:46 UTC · original

When the GTA V boot-font dispatch is detected but the computed source is below prefetch_before, no BDA preparation is performed at all (the inner if (source >= prefetch_before) falls through without calling PrepareBdaRange or PrepareBda). This leaves the DMA path without the required BDA synchronization for that dispatch.

**@⁠Copilot** on GitHub · 2026-09-02 00:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#discussion_r3909746196) When the GTA V boot-font dispatch is detected but the computed `source` is below `prefetch_before`, no BDA preparation is performed at all (the inner `if (source >= prefetch_before)` falls through without calling `PrepareBdaRange` or `PrepareBda`). This leaves the DMA path without the required BDA synchronization for that dispatch.
@ -7000,0 +7031,4 @@
auto &buffers = resources.GetBufferCache();
Require(name, "mapped source pages",
buffers.IsRegionRegistered(base + 0x4000, 0x10000),
"BDA source pages were not materialized before dispatch");
Author
Owner

@⁠Copilot on GitHub · 2026-09-02 00:46 UTC · original

IsRegionRegistered() only checks whether any cached buffer intersects the range, so this assertion can pass even if only a single page was materialized. To validate PrepareBdaRange, the test should verify that every page covering [source, source+size) is registered.

**@⁠Copilot** on GitHub · 2026-09-02 00:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#discussion_r3909746220) `IsRegionRegistered()` only checks whether *any* cached buffer intersects the range, so this assertion can pass even if only a single page was materialized. To validate `PrepareBdaRange`, the test should verify that every page covering `[source, source+size)` is registered.
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-09-02 00:46 UTC · original · reviewed

The DMA dispatch path can skip BDA preparation in a valid control-flow case, and the new tests include assertions that don’t reliably validate the intended publication/materialization behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR addresses GTA V boot-time text glyph loss by ensuring buffer device address (BDA) source pages are materialized before a one-shot compute dispatch, and by preventing R8 storage-image and R8 sampled-view cache owners from being merged when their numeric formats differ.

Changes:

  • Adds GpuResourceManager::PrepareBdaRange() and applies a targeted prefetch for the identified GTA V boot-font DMA compute dispatch.
  • Separates incompatible R8 storage vs sampled atlas cache ownership and publishes storage-written bytes before separation.
  • Adds focused compute tests for BDA range prefetch and the GTA V 2048×4096 R8 Standard64KB atlas layout.
File summaries
File Description
tests/ShaderRecompilerComputeTests.cpp Adds targeted regression tests for BDA prefetch and storage/sampled atlas separation plus atlas layout coverage.
src/graphics/host_gpu/renderer/renderCompute.cpp Adds GTA V-specific BDA prefetch path for a one-shot compute dispatch.
src/graphics/host_gpu/renderer/cache/textureCache.h Declares helper to prepare for storage/sampled overlap handling.
src/graphics/host_gpu/renderer/cache/textureCache.cpp Implements storage/sampled format mismatch detection and overlap separation with publication of GPU-written bytes.
src/graphics/host_gpu/renderer/cache/gpuResourceManager.h Exposes PrepareBdaRange() API.
src/graphics/host_gpu/renderer/cache/gpuResourceManager.cpp Implements page-aligned, mapped-only BDA range materialization prior to normal BDA synchronization.
Review details

Suppressed comments (1)

tests/ShaderRecompilerComputeTests.cpp:7125

  • As written, the "storage contents publication" check still passes even if no publication occurs, because the guest backing is pre-filled with 0x7f. Consider forcing a guest/GPU divergence (modify guest backing after image creation and mark the storage image GPU-written) so that separation must publish GPU bytes to make the assertion pass.
  • Files reviewed: 6/6 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-09-02 00:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#pullrequestreview-5084531157) · **reviewed** ### 🟡 Changes recommended The DMA dispatch path can skip BDA preparation in a valid control-flow case, and the new tests include assertions that don’t reliably validate the intended publication/materialization behavior. *Once you've addressed the issues Copilot identified, you can request another Copilot review.* <details> <summary>Pull request overview</summary> This PR addresses GTA V boot-time text glyph loss by ensuring buffer device address (BDA) source pages are materialized before a one-shot compute dispatch, and by preventing R8 storage-image and R8 sampled-view cache owners from being merged when their numeric formats differ. **Changes:** - Adds `GpuResourceManager::PrepareBdaRange()` and applies a targeted prefetch for the identified GTA V boot-font DMA compute dispatch. - Separates incompatible R8 storage vs sampled atlas cache ownership and publishes storage-written bytes before separation. - Adds focused compute tests for BDA range prefetch and the GTA V 2048×4096 R8 Standard64KB atlas layout. </details> <details> <summary>File summaries</summary> | File | Description | | ---- | ----------- | | tests/ShaderRecompilerComputeTests.cpp | Adds targeted regression tests for BDA prefetch and storage/sampled atlas separation plus atlas layout coverage. | | src/graphics/host_gpu/renderer/renderCompute.cpp | Adds GTA V-specific BDA prefetch path for a one-shot compute dispatch. | | src/graphics/host_gpu/renderer/cache/textureCache.h | Declares helper to prepare for storage/sampled overlap handling. | | src/graphics/host_gpu/renderer/cache/textureCache.cpp | Implements storage/sampled format mismatch detection and overlap separation with publication of GPU-written bytes. | | src/graphics/host_gpu/renderer/cache/gpuResourceManager.h | Exposes `PrepareBdaRange()` API. | | src/graphics/host_gpu/renderer/cache/gpuResourceManager.cpp | Implements page-aligned, mapped-only BDA range materialization prior to normal BDA synchronization. | </details> <details> <summary>Review details</summary> ### Suppressed comments (1) **tests/ShaderRecompilerComputeTests.cpp:7125** * As written, the "storage contents publication" check still passes even if no publication occurs, because the guest backing is pre-filled with 0x7f. Consider forcing a guest/GPU divergence (modify guest backing after image creation and mark the storage image GPU-written) so that separation must publish GPU bytes to make the assertion pass. - **Files reviewed:** 6/6 changed files - **Comments generated:** 4 - **Review effort level:** Lite </details> --- 💡 <a href="/KytyPS5/KytyPS5/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a `code-review` agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
@ -7000,0 +7075,4 @@
&mapped, allocation_size, 0x3, 0x10, direct_offset,
0x200000) == 0 && mapped == reinterpret_cast<void *>(base),
"storage/sample fixed mapping failed");
std::memset(mapped, 0x7f, atlas_size);
Author
Owner

@⁠Copilot on GitHub · 2026-09-02 00:46 UTC · original

This initializes the guest backing to 0x7f, which makes the later "publication" assertion indistinguishable from the initial state. Initializing to 0 makes it possible to detect whether a later publication/readback actually overwrote guest memory.

This issue also appears on line 7121 of the same file.

**@⁠Copilot** on GitHub · 2026-09-02 00:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#discussion_r3909746236) This initializes the guest backing to 0x7f, which makes the later "publication" assertion indistinguishable from the initial state. Initializing to 0 makes it possible to detect whether a later publication/readback actually overwrote guest memory. This issue also appears on line 7121 of the same file.
@ -3,1 +3,4 @@
#include "common/assert.h"
#include <cstdio>
#include <chrono>
#include <atomic>
Author
Owner

@⁠Copilot on GitHub · 2026-09-02 00:46 UTC · original

The newly added standard headers (, , ) are unused in this translation unit, and should be removed to avoid unnecessary includes and potential warning noise.

**@⁠Copilot** on GitHub · 2026-09-02 00:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/449#discussion_r3909746262) The newly added standard headers (<cstdio>, <chrono>, <atomic>) are unused in this translation unit, and should be removed to avoid unnecessary includes and potential warning noise.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.