gpu: take GPU timestamps when the host GPU executes them #1282

Open
github-bot wants to merge 21 commits from github-bot/gh-1282 into main AGit
Owner

@⁠NeySlim on GitHub · 2026-10-09 07:24 UTC · original
NeySlim:fix/gpu-clock-at-execution → main · +1789 −43 · 17 files · 21 commits · open

Problem

RELEASE_MEM / EVENT_WRITE_EOP with the GPU clock (data_sel 3) and COPY_DATA from the GPU clock write Sync::ReadReferenceClock() (the host TSC scaled to 100 MHz) into guest memory while the GPU thread parses the packet. The value is the parse time, not the time the GPU finished the work before the packet, so the durations a game measures between two timestamps are the time Kyty spends recording commands.

God of War Ragnarök (PPSA08332, 05.005) writes about 1500 of them per second (roughly 150 per frame, 530 slots, rewritten every frame), around its render passes, and reads some of them back on a game thread. Its main passes render at 2688x1512 or 2560x1440 and switch between the two every few seconds (dynamic resolution at its lower steps).

Change

  • New GpuTimestamps, owned by RenderContext. A GPU clock write records vkCmdWriteTimestamp2 into a query (all commands for end-of-pipe events, top of pipe for COPY_DATA). Timestamps can be recorded inside a render pass.
  • Before a command buffer is submitted (new CommandScheduler::SetBeforeSubmit), the queries of that batch are copied to a host-readable buffer and reset. A priority completion, queued at the first entry of the batch, converts the results and stores them in guest memory, in packet order.
  • The store uses the backing mapping (no fault from the completion thread). When a cache watches the page (cached copy or GPU data not read back yet), or the range has no backing alias (program data, stacks), the value goes to the GPU thread instead: the completion queues a store there, which runs as soon as the GPU thread is between packets (also at every GPU clock or label packet and before an unmap), with a normal write so the caches see it. One thread stores at a time.
  • Completion order: once a value is left to the GPU thread, everything guest-visible after it waits behind it, in order:
    • later values, from the same or later batches;
    • EOP interrupts (TriggerEopEventAtEndOfPipe, and the interrupt of a flip with interrupt): they go through GpuTimestamps::Signal and run on the GPU thread right after the values before them. A game woken by an interrupt reads the values written before it. Flip completion itself and the suspend-point release are not held: the GPU thread waits for them (flip queue slots), so holding them behind a GPU-thread store could deadlock.
  • End-of-pipe labels (immediate data of RELEASE_MEM / EVENT_WRITE_EOP, flip labels): when a GPU clock value recorded before them is not stored yet, they are stored after it at completion (or on the GPU thread behind it); otherwise they are still written when parsed, as before. A label a game polls therefore never becomes visible before the timestamps written before it. The GDS end-of-pipe path, which already waits for the GPU, first stores the pending values. GPU-side reads recorded after such a label (WAIT_REG_MEM, COND_EXEC, COND_INDIRECT_BUFFER, boolean predication) see it at once, also when they read another width (a 32-bit wait on half of a 64-bit label, a 64-bit compare over a 32-bit one). They saw it at once before this change too, as labels were written when parsed: all guest queues are parsed on one thread and recorded into one host queue, so the order between queues stays as it was, and a queue waiting for another queue's label does not wait for the GPU. Other reads of the label memory (shaders, DMA_DATA or COPY_DATA from memory) see it only once it is stored at completion: those recorded before that read the previous value. A queue suspended on WAIT_REG_MEM for another value polls again as soon as a completion stores one (GuestGpu::NotifyGuestWrite), instead of after the 100 ms idle wait.
  • This changes the completion path: in a game that writes timestamps all the time, end-of-pipe labels now become visible when the GPU completes the work before them, as on the hardware, not when Kyty parses them. WRITE_DATA and other CP writes keep their parse-time behaviour. A CP write to bytes of a label or GPU clock value not stored yet (WRITE_DATA, the destination of DMA_DATA or COPY_DATA, DUMP_CONST_RAM, GET_LOD_STATS, occlusion dumps) comes after it: those bytes are dropped from the pending value, so later GPU-side reads see the new write and the completion does not store over it. A shader write to a label address recorded after a deferred label is not ordered this way: the label still lands over it at completion.
  • 4096 queries are in flight; one more waits for the oldest batches to complete.
  • Conversion: reference = base + (ticks - device_base) * rate / 2^32, in the same 100 MHz TSC-based clock ReadReferenceClock returns.
    • With VK_KHR_calibrated_timestamps or VK_EXT_calibrated_timestamps, the device clock is sampled against the reference clock every 2 s, through the entry points of the extension the device enabled. The rate is measured from the first sample: the masked tick intervals between samples are summed, so counters with fewer than 64 valid bits wrap without error. A sample more than a quarter of a counter period after the previous one measures again from there. Each new segment starts 1 s after its sample and continues the previous one: a batch submitted before the sample and run within that second converts with the same function as the batches before it, so values stay monotonic across a correction.
    • Without the extension, a timestamp read back at startup anchors the clock and the reported period gives the rate; the segment base then moves along that line every 2 s so that narrow counters stay within half a period of it. The drift of the reported period is not corrected in this case.
    • Without timestamp support on the queue, the parse time is kept.
  • RADV reports a 10.019 ns period for the Radeon 8060S, but the counter runs at exactly 1/30 of the 3 GHz TSC (10 ns), measured over 20 s with calibrated timestamps; hence the measured rate.

Test

  • GpuCommandLane: two RELEASE_MEM timestamps recorded while the GPU timeline is blocked must read back times after the GPU is released 20 ms later (on main they hold the parse time and the check fails). The end-of-pipe clock with interrupt and the compute-queue clock interrupt read their values from guest memory after completion.
  • GpuCommandLane also records 4196 timestamps over 1000 slots in one go (more than the queries in flight): every slot holds the time of its last write, in recording order.
  • A priority completion queued right after a timestamp packet must see the stored value.
  • A timestamp to a range with GPU data not read back yet (ObtainBuffer with a write) must land through the GPU thread and survive the readback; a lone one must land without another GPU clock write.
  • A timestamp to AllocateProgramMemory memory (no backing alias) must land (exits on the previous version of this PR); memory_tracker_tests checks that StoreUnwatched refuses a range without backing and writes nothing.
  • An EOP clock write with interrupt to a watched page, followed by a label: while the GPU thread is busy, the interrupt must not be delivered and the label must not be written; once it is free, both arrive with the value stored. Fails without the interrupt ordering or without the label ordering.
  • A label recorded after a pending timestamp must not be written at parse time, must be seen at once by WAIT_REG_MEM (32 and 64-bit, on half of a 64-bit label and over a 32-bit one), COND_EXEC, COND_INDIRECT_BUFFER and boolean predication packets, and must hold its value after completion; labels with nothing pending are still written at parse time (existing checks).
  • A WRITE_DATA after a deferred label (full and half of a 64-bit one), a DMA_DATA fill after one, and a WRITE_DATA after a pending timestamp: WAIT_REG_MEM and COND_EXEC see the new value and memory holds it after completion. Fails without the change (each part checked by reverting it).
  • Host checks GpuClockSegments (exact scaling for 100 MHz, 1 GHz and 19.2 MHz counters, continuity across a segment change) and GpuClockCalibration: a simulated 36-bit, 19.2 MHz counter running 50 ppm off its reported period, over 3 hours (three wraps), calibrated every 2 s with one skewed sample, then after a 40 min gap: converted times stay within 1 us, monotonic, with the measured rate; uncalibrated, the same counter followed over 2 hours. Each fails when its part of the change is reverted.
  • shader_recompiler_compute_tests, one case per process: 613 of 623 pass; the 10 others fail on main too on this setup (same list on a clean main build). memory_tracker, page_manager, resource_tracking and resource_materialization pass.

Validation

Linux, Ryzen AI Max+ 395, Radeon 8060S, Mesa RADV 26.2.3.

  • God of War Ragnarök, new game to the sled ride, about 6 minutes of gameplay: no hang or error.
  • Frame rate, one run each (title-bar frame counter over two windows of gameplay, 0-180 s and 180-340 s; run-to-run variation is large): 18.2 and 10.1 fps with this version, 10.6 and 13.0 fps with the previous version of this PR, 16.2 and 13.0 fps with this version but labels written when parsed.
  • With labels at completion but without the GPU-side read of deferred labels, it dropped to 5.3 and 3.5 fps: the command thread suspended on every cross-queue label wait until the GPU completed.

Earlier version of this PR (timestamps only, labels written when parsed):

  • God of War Ragnarök, new game to the sled ride, about 6 minutes of gameplay per run: no hang or error, the timestamps advance with the GPU (values sampled every 250 ms advance by 250 ms). About half of the completion stores hit pages a cache watches and go through the GPU thread.
  • The game's dynamic resolution follows these timestamps. With the parse-time clock its main passes switch between 2688x1512 (55% of 2 s windows) and 2560x1440 (45%). With GPU execution times they stay at 2560x1440 (96%): on this setup the GPU timeline of a frame includes the gaps where the GPU waits for Kyty to record the next commands, so the game now sees that time instead of the parse time.

Not tested on Windows or macOS (CI builds them). The change uses core Vulkan queries and VK_KHR/EXT_calibrated_timestamps when present; ReadReferenceClock is the existing TSC-based clock on every platform.

AI use

I used Claude Code (AI agent) to check how the game uses these timestamps, write the change and the tests, and run the measurements and tests above on my machine. I reviewed the diff and the results before opening this PR.

**@⁠NeySlim** on GitHub · 2026-10-09 07:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282) `NeySlim:fix/gpu-clock-at-execution` → `main` · +1789 −43 · 17 files · 21 commits · open ## Problem `RELEASE_MEM` / `EVENT_WRITE_EOP` with the GPU clock (`data_sel` 3) and `COPY_DATA` from the GPU clock write `Sync::ReadReferenceClock()` (the host TSC scaled to 100 MHz) into guest memory while the GPU thread parses the packet. The value is the parse time, not the time the GPU finished the work before the packet, so the durations a game measures between two timestamps are the time Kyty spends recording commands. God of War Ragnarök (PPSA08332, 05.005) writes about 1500 of them per second (roughly 150 per frame, 530 slots, rewritten every frame), around its render passes, and reads some of them back on a game thread. Its main passes render at 2688x1512 or 2560x1440 and switch between the two every few seconds (dynamic resolution at its lower steps). ## Change - New `GpuTimestamps`, owned by `RenderContext`. A GPU clock write records `vkCmdWriteTimestamp2` into a query (all commands for end-of-pipe events, top of pipe for `COPY_DATA`). Timestamps can be recorded inside a render pass. - Before a command buffer is submitted (new `CommandScheduler::SetBeforeSubmit`), the queries of that batch are copied to a host-readable buffer and reset. A priority completion, queued at the first entry of the batch, converts the results and stores them in guest memory, in packet order. - The store uses the backing mapping (no fault from the completion thread). When a cache watches the page (cached copy or GPU data not read back yet), or the range has no backing alias (program data, stacks), the value goes to the GPU thread instead: the completion queues a store there, which runs as soon as the GPU thread is between packets (also at every GPU clock or label packet and before an unmap), with a normal write so the caches see it. One thread stores at a time. - Completion order: once a value is left to the GPU thread, everything guest-visible after it waits behind it, in order: - later values, from the same or later batches; - EOP interrupts (`TriggerEopEventAtEndOfPipe`, and the interrupt of a flip with interrupt): they go through `GpuTimestamps::Signal` and run on the GPU thread right after the values before them. A game woken by an interrupt reads the values written before it. Flip completion itself and the suspend-point release are not held: the GPU thread waits for them (flip queue slots), so holding them behind a GPU-thread store could deadlock. - End-of-pipe labels (immediate data of `RELEASE_MEM` / `EVENT_WRITE_EOP`, flip labels): when a GPU clock value recorded before them is not stored yet, they are stored after it at completion (or on the GPU thread behind it); otherwise they are still written when parsed, as before. A label a game polls therefore never becomes visible before the timestamps written before it. The GDS end-of-pipe path, which already waits for the GPU, first stores the pending values. GPU-side reads recorded after such a label (`WAIT_REG_MEM`, `COND_EXEC`, `COND_INDIRECT_BUFFER`, boolean predication) see it at once, also when they read another width (a 32-bit wait on half of a 64-bit label, a 64-bit compare over a 32-bit one). They saw it at once before this change too, as labels were written when parsed: all guest queues are parsed on one thread and recorded into one host queue, so the order between queues stays as it was, and a queue waiting for another queue's label does not wait for the GPU. Other reads of the label memory (shaders, `DMA_DATA` or `COPY_DATA` from memory) see it only once it is stored at completion: those recorded before that read the previous value. A queue suspended on `WAIT_REG_MEM` for another value polls again as soon as a completion stores one (`GuestGpu::NotifyGuestWrite`), instead of after the 100 ms idle wait. - This changes the completion path: in a game that writes timestamps all the time, end-of-pipe labels now become visible when the GPU completes the work before them, as on the hardware, not when Kyty parses them. `WRITE_DATA` and other CP writes keep their parse-time behaviour. A CP write to bytes of a label or GPU clock value not stored yet (`WRITE_DATA`, the destination of `DMA_DATA` or `COPY_DATA`, `DUMP_CONST_RAM`, `GET_LOD_STATS`, occlusion dumps) comes after it: those bytes are dropped from the pending value, so later GPU-side reads see the new write and the completion does not store over it. A shader write to a label address recorded after a deferred label is not ordered this way: the label still lands over it at completion. - 4096 queries are in flight; one more waits for the oldest batches to complete. - Conversion: reference = base + (ticks - device_base) * rate / 2^32, in the same 100 MHz TSC-based clock `ReadReferenceClock` returns. - With `VK_KHR_calibrated_timestamps` or `VK_EXT_calibrated_timestamps`, the device clock is sampled against the reference clock every 2 s, through the entry points of the extension the device enabled. The rate is measured from the first sample: the masked tick intervals between samples are summed, so counters with fewer than 64 valid bits wrap without error. A sample more than a quarter of a counter period after the previous one measures again from there. Each new segment starts 1 s after its sample and continues the previous one: a batch submitted before the sample and run within that second converts with the same function as the batches before it, so values stay monotonic across a correction. - Without the extension, a timestamp read back at startup anchors the clock and the reported period gives the rate; the segment base then moves along that line every 2 s so that narrow counters stay within half a period of it. The drift of the reported period is not corrected in this case. - Without timestamp support on the queue, the parse time is kept. - RADV reports a 10.019 ns period for the Radeon 8060S, but the counter runs at exactly 1/30 of the 3 GHz TSC (10 ns), measured over 20 s with calibrated timestamps; hence the measured rate. ## Test - `GpuCommandLane`: two `RELEASE_MEM` timestamps recorded while the GPU timeline is blocked must read back times after the GPU is released 20 ms later (on main they hold the parse time and the check fails). The end-of-pipe clock with interrupt and the compute-queue clock interrupt read their values from guest memory after completion. - `GpuCommandLane` also records 4196 timestamps over 1000 slots in one go (more than the queries in flight): every slot holds the time of its last write, in recording order. - A priority completion queued right after a timestamp packet must see the stored value. - A timestamp to a range with GPU data not read back yet (`ObtainBuffer` with a write) must land through the GPU thread and survive the readback; a lone one must land without another GPU clock write. - A timestamp to `AllocateProgramMemory` memory (no backing alias) must land (exits on the previous version of this PR); `memory_tracker_tests` checks that `StoreUnwatched` refuses a range without backing and writes nothing. - An EOP clock write with interrupt to a watched page, followed by a label: while the GPU thread is busy, the interrupt must not be delivered and the label must not be written; once it is free, both arrive with the value stored. Fails without the interrupt ordering or without the label ordering. - A label recorded after a pending timestamp must not be written at parse time, must be seen at once by `WAIT_REG_MEM` (32 and 64-bit, on half of a 64-bit label and over a 32-bit one), `COND_EXEC`, `COND_INDIRECT_BUFFER` and boolean predication packets, and must hold its value after completion; labels with nothing pending are still written at parse time (existing checks). - A `WRITE_DATA` after a deferred label (full and half of a 64-bit one), a `DMA_DATA` fill after one, and a `WRITE_DATA` after a pending timestamp: `WAIT_REG_MEM` and `COND_EXEC` see the new value and memory holds it after completion. Fails without the change (each part checked by reverting it). - Host checks `GpuClockSegments` (exact scaling for 100 MHz, 1 GHz and 19.2 MHz counters, continuity across a segment change) and `GpuClockCalibration`: a simulated 36-bit, 19.2 MHz counter running 50 ppm off its reported period, over 3 hours (three wraps), calibrated every 2 s with one skewed sample, then after a 40 min gap: converted times stay within 1 us, monotonic, with the measured rate; uncalibrated, the same counter followed over 2 hours. Each fails when its part of the change is reverted. - `shader_recompiler_compute_tests`, one case per process: 613 of 623 pass; the 10 others fail on main too on this setup (same list on a clean main build). `memory_tracker`, `page_manager`, `resource_tracking` and `resource_materialization` pass. ## Validation Linux, Ryzen AI Max+ 395, Radeon 8060S, Mesa RADV 26.2.3. - God of War Ragnarök, new game to the sled ride, about 6 minutes of gameplay: no hang or error. - Frame rate, one run each (title-bar frame counter over two windows of gameplay, 0-180 s and 180-340 s; run-to-run variation is large): 18.2 and 10.1 fps with this version, 10.6 and 13.0 fps with the previous version of this PR, 16.2 and 13.0 fps with this version but labels written when parsed. - With labels at completion but without the GPU-side read of deferred labels, it dropped to 5.3 and 3.5 fps: the command thread suspended on every cross-queue label wait until the GPU completed. Earlier version of this PR (timestamps only, labels written when parsed): - God of War Ragnarök, new game to the sled ride, about 6 minutes of gameplay per run: no hang or error, the timestamps advance with the GPU (values sampled every 250 ms advance by 250 ms). About half of the completion stores hit pages a cache watches and go through the GPU thread. - The game's dynamic resolution follows these timestamps. With the parse-time clock its main passes switch between 2688x1512 (55% of 2 s windows) and 2560x1440 (45%). With GPU execution times they stay at 2560x1440 (96%): on this setup the GPU timeline of a frame includes the gaps where the GPU waits for Kyty to record the next commands, so the game now sees that time instead of the parse time. Not tested on Windows or macOS (CI builds them). The change uses core Vulkan queries and `VK_KHR/EXT_calibrated_timestamps` when present; `ReadReferenceClock` is the existing TSC-based clock on every platform. ## AI use I used Claude Code (AI agent) to check how the game uses these timestamps, write the change and the tests, and run the measurements and tests above on my machine. I reviewed the diff and the results before opening this PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:51:18 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 07:31 UTC · original · edited 2026-10-21 05:15 UTC

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

  • Last reviewed commit: db44c099a230c6df7acfa6dd8610572d8f2c9e14
  • Latest commit, not reviewed: 668de5e997

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 807c30aa-34dd-4181-ad43-70e5f6aebac6
📥 Commits

Reviewing files that changed from the base of the PR and between da3021014568238fd4585c10febbe6cb7cf26aa6 and db44c099a230c6df7acfa6dd8610572d8f2c9e14.

📒 Files selected for processing (5)
  • src/graphics/guest_gpu/command_processor/pm4Handlers.cpp
  • src/graphics/guest_gpu/graphicsRun.cpp
  • src/graphics/host_gpu/renderer/gpuTimestamps.cpp
  • src/graphics/host_gpu/renderer/gpuTimestamps.h
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The change adds calibrated GPU timestamp sampling, conversion, query resolution, and deferred guest-memory storage. Guest GPU timestamp and label paths use the timestamp interface, and pending labels can be read by GPU commands. RenderContext and PageManager provide completion-time stores that reject watched memory and support retries. Vulkan setup selects calibrated-timestamp support when available. Tests cover clock conversion, timestamp ordering, storage, retries, and interrupt sequencing. Command submission can report when the GPU no longer accepts work.

Suggested reviewers: claxten10

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to db44c

The change takes GPU timestamps at the time the GPU executes the commands and keeps the ordering of timestamp, label and interrupt writes. No outstanding merge-blocking issues were found in the supplied context.

Pre-merge checks | Passed 4 | Inconclusive 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 6.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 94 functions across 17 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely states the main change: recording GPU timestamps when the host GPU executes the work.
Description check Passed The description directly explains the timestamping problem, implementation, ordering behavior, tests, and validation for the changeset.
Full details: Docstring Coverage

Explanation

Docstring coverage is 6.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 94 functions across 17 files. (1 skipped: 1 too large.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 07:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#issuecomment-6076513141) · edited 2026-10-21 05:15 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1282?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the `reviews.auto_review.auto_pause_after_reviewed_commits` setting. > > - Last reviewed commit: db44c099a230c6df7acfa6dd8610572d8f2c9e14 > - Latest commit, not reviewed: 668de5e99782087c83dcc157868b09ede1ebe959 > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. > > Use the checkboxes below for quick actions: > - [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `807c30aa-34dd-4181-ad43-70e5f6aebac6` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between da3021014568238fd4585c10febbe6cb7cf26aa6 and db44c099a230c6df7acfa6dd8610572d8f2c9e14. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (5)</strong></summary> <dl> <dd> * `src/graphics/guest_gpu/command_processor/pm4Handlers.cpp` * `src/graphics/guest_gpu/graphicsRun.cpp` * `src/graphics/host_gpu/renderer/gpuTimestamps.cpp` * `src/graphics/host_gpu/renderer/gpuTimestamps.h` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough The change adds calibrated GPU timestamp sampling, conversion, query resolution, and deferred guest-memory storage. Guest GPU timestamp and label paths use the timestamp interface, and pending labels can be read by GPU commands. RenderContext and PageManager provide completion-time stores that reject watched memory and support retries. Vulkan setup selects calibrated-timestamp support when available. Tests cover clock conversion, timestamp ordering, storage, retries, and interrupt sequencing. Command submission can report when the GPU no longer accepts work. **Suggested reviewers:** `claxten10` </dd> </dl> </details> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"db44c099a230c6df7acfa6dd8610572d8f2c9e14" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>db44c</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `db44c` --> <!-- final_review_risk_coverage:{"sourceCommitId":"db44c099a230c6df7acfa6dd8610572d8f2c9e14","coveredCommitId":"db44c099a230c6df7acfa6dd8610572d8f2c9e14","kind":"reviewed"} --> The change takes GPU timestamps at the time the GPU executes the commands and keeps the ordering of timestamp, label and interrupt writes. No outstanding merge-blocking issues were found in the supplied context. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v1.svg" width="14" height="17" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 6.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 94 functions across 17 files. (1 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------- | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely states the main change: recording GPU timestamps when the host GPU executes the work. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the timestamping problem, implementation, ordering behavior, tests, and validation for the changeset. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 6.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 94 functions across 17 files. (1 skipped: 1 too large.) </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1282)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -0,0 +607,4 @@
});
stored++;
}
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 07:31 UTC · original · edited 2026-10-09 07:51 UTC

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Fix StoreRetries so it does not drop retried writes to unmapped destinations.

Complete sets deferred = true after the first watched store, or when older retries are pending. After that point, every later write in the batch goes to m_retries. This includes destinations where IsMapped returns false. RenderContext::StoreAtCompletion writes those destinations directly with memcpy. StoreRetries skips any retry where IsMapped is false, so the timestamp value for those destinations is never written. A guest that polls that address can then read a stale value or wait forever.

To fix this, write every retry in order. Use a plain store for both mapped and unmapped destinations, as in the existing direct path.

🐛 Proposed fix
--- "a/src/graphics/host_gpu/renderer/gpuTimestamps.cpp"
+++ "b/src/graphics/host_gpu/renderer/gpuTimestamps.cpp"
@@ -338,11 +338,9 @@
 			m_retrying = true;
 		}
 		// Plain stores fault here like other GPU-thread writes, so the watching caches see them.
 		for (const auto& retry: retries) {
-			if (m_context.IsMapped(retry.vaddr, retry.size)) {
-				std::memcpy(reinterpret_cast<void*>(retry.vaddr), &retry.value, retry.size);
-			}
+			std::memcpy(reinterpret_cast<void*>(retry.vaddr), &retry.value, retry.size);
 		}
 	}
 }
 
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		for (const auto& retry: retries) {
			std::memcpy(reinterpret_cast<void*>(retry.vaddr), &retry.value, retry.size);
		}

✅ Confirmed as addressed by @⁠NeySlim

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 07:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#discussion_r4227749830) · edited 2026-10-09 07:51 UTC **🗄️ Data Integrity & Integration** | **🟠 Major** | **⚡ Quick win** **Fix `StoreRetries` so it does not drop retried writes to unmapped destinations.** `Complete` sets `deferred = true` after the first watched store, or when older retries are pending. After that point, every later write in the batch goes to `m_retries`. This includes destinations where `IsMapped` returns false. `RenderContext::StoreAtCompletion` writes those destinations directly with `memcpy`. `StoreRetries` skips any retry where `IsMapped` is false, so the timestamp value for those destinations is never written. A guest that polls that address can then read a stale value or wait forever. To fix this, write every retry in order. Use a plain store for both mapped and unmapped destinations, as in the existing direct path. <details> <summary>🐛 Proposed fix</summary> ```diff --- "a/src/graphics/host_gpu/renderer/gpuTimestamps.cpp" +++ "b/src/graphics/host_gpu/renderer/gpuTimestamps.cpp" @@ -338,11 +338,9 @@ m_retrying = true; } // Plain stores fault here like other GPU-thread writes, so the watching caches see them. for (const auto& retry: retries) { - if (m_context.IsMapped(retry.vaddr, retry.size)) { - std::memcpy(reinterpret_cast<void*>(retry.vaddr), &retry.value, retry.size); - } + std::memcpy(reinterpret_cast<void*>(retry.vaddr), &retry.value, retry.size); } } } ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion for (const auto& retry: retries) { std::memcpy(reinterpret_cast<void*>(retry.vaddr), &retry.value, retry.size); } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d4145544637e3e817e5dbda0 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠NeySlim <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 07:31 UTC · original · edited 2026-10-09 07:50 UTC
On src/graphics/host_gpu/renderer/renderContext.cpp line 94 (outdated):

@@ -79,6 +82,19 @@ bool RenderContext::InvalidateMemory(uint64_t vaddr, uint64_t size) {
 	return true;
 }
 
+bool RenderContext::StoreAtCompletion(uint64_t vaddr, const void* data, uint64_t size) {
+	if (!IsMapped(vaddr, size)) {
+		std::memcpy(reinterpret_cast<void*>(vaddr), data, size);
+		return true;
+	}
+	// Cached copies cannot be invalidated here; unwatched pages have none that a write can stale.
+	if (m_page_manager.IsWatched(vaddr, 1) || m_page_manager.IsWatched(vaddr + size - 1, 1)) {
+		return false;
+	}
+	LibKernel::Memory::WriteBacking(vaddr, data, size);

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect watcher registration and completion-callback synchronization.
rg -n -C 5 'UpdatePageWatchers|UpdatePageWatchersForRegion|StoreAtCompletion\(|DeferPriorityOperation\(|WriteBacking\(' src/graphics/host_gpu

Repository: KytyPS5/KytyPS5

Length of output: 27465


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- pageManager.cpp ---'
sed -n '1,360p' src/graphics/host_gpu/pageManager.cpp
printf '%s\n' '--- regionManager.h ---'
sed -n '1,220p' src/graphics/host_gpu/regionManager.h
printf '%s\n' '--- commandScheduler.cpp ---'
sed -n '180,310p' src/graphics/host_gpu/renderer/commandScheduler.cpp
printf '%s\n' '--- gpuTimestamps.cpp ---'
sed -n '220,345p' src/graphics/host_gpu/renderer/gpuTimestamps.cpp
printf '%s\n' '--- watcher update callers ---'
rg -n -C 4 -F -- 'UpdatePageWatchers<' src/graphics/host_gpu

Repository: KytyPS5/KytyPS5

Length of output: 32684


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- commandScheduler.h ---'
sed -n '1,180p' src/graphics/host_gpu/renderer/commandScheduler.h
printf '%s\n' '--- commandScheduler.cpp setup and operation execution ---'
sed -n '1,190p' src/graphics/host_gpu/renderer/commandScheduler.cpp
sed -n '300,390p' src/graphics/host_gpu/renderer/commandScheduler.cpp
printf '%s\n' '--- texture-cache tracking declarations and callers ---'
rg -n -C 8 -F -- 'TrackImage(' src/graphics/host_gpu/renderer
rg -n -C 8 -F -- 'TrackImageHead(' src/graphics/host_gpu/renderer
rg -n -C 8 -F -- 'TrackImageTail(' src/graphics/host_gpu/renderer
rg -n -C 8 -F -- 'UntrackImage(' src/graphics/host_gpu/renderer
printf '%s\n' '--- scheduler construction and GPU timestamp ownership ---'
rg -n -C 8 -F -- 'CommandScheduler(' src/graphics/host_gpu/renderer
rg -n -C 8 -F -- 'GpuTimestamps' src/graphics/host_gpu/renderer

Repository: KytyPS5/KytyPS5

Length of output: 41983


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- scheduler priority execution with line numbers ---'
nl -ba src/graphics/host_gpu/renderer/commandScheduler.cpp | sed -n '232,320p'
printf '%s\n' '--- texture cache callers with line numbers ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '580,710p'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '900,1030p'
printf '%s\n' '--- direct TrackImage and watcher-related callers ---'
rg -n -C 5 -F -- 'TrackImage(' src/graphics/host_gpu/renderer --glob '*.cpp'
rg -n -C 5 -F -- 'UntrackImage(' src/graphics/host_gpu/renderer --glob '*.cpp'

Repository: KytyPS5/KytyPS5

Length of output: 33812


Synchronize the watcher check with the backing write.

GpuTimestamps::Complete runs on CommandScheduler's priority thread, while texture-cache operations can update watchers directly through TrackImage. StoreAtCompletion releases the page lock when IsWatched returns, then calls WriteBacking. A watcher can be added in this gap, leaving the cached image stale.

Make the watcher decision and backing write atomic with respect to watcher registration.

✅ Confirmed as addressed by @⁠NeySlim

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 07:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#discussion_r4227749871) · edited 2026-10-09 07:50 UTC On `src/graphics/host_gpu/renderer/renderContext.cpp` line 94 (outdated): ```diff @@ -79,6 +82,19 @@ bool RenderContext::InvalidateMemory(uint64_t vaddr, uint64_t size) { return true; } +bool RenderContext::StoreAtCompletion(uint64_t vaddr, const void* data, uint64_t size) { + if (!IsMapped(vaddr, size)) { + std::memcpy(reinterpret_cast<void*>(vaddr), data, size); + return true; + } + // Cached copies cannot be invalidated here; unwatched pages have none that a write can stale. + if (m_page_manager.IsWatched(vaddr, 1) || m_page_manager.IsWatched(vaddr + size - 1, 1)) { + return false; + } + LibKernel::Memory::WriteBacking(vaddr, data, size); ``` **🗄️ Data Integrity & Integration** | **🟠 Major** | **🏗️ Heavy lift** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash # Inspect watcher registration and completion-callback synchronization. rg -n -C 5 'UpdatePageWatchers|UpdatePageWatchersForRegion|StoreAtCompletion\(|DeferPriorityOperation\(|WriteBacking\(' src/graphics/host_gpu ``` Repository: KytyPS5/KytyPS5 Length of output: 27465 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- pageManager.cpp ---' sed -n '1,360p' src/graphics/host_gpu/pageManager.cpp printf '%s\n' '--- regionManager.h ---' sed -n '1,220p' src/graphics/host_gpu/regionManager.h printf '%s\n' '--- commandScheduler.cpp ---' sed -n '180,310p' src/graphics/host_gpu/renderer/commandScheduler.cpp printf '%s\n' '--- gpuTimestamps.cpp ---' sed -n '220,345p' src/graphics/host_gpu/renderer/gpuTimestamps.cpp printf '%s\n' '--- watcher update callers ---' rg -n -C 4 -F -- 'UpdatePageWatchers<' src/graphics/host_gpu ``` Repository: KytyPS5/KytyPS5 Length of output: 32684 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- commandScheduler.h ---' sed -n '1,180p' src/graphics/host_gpu/renderer/commandScheduler.h printf '%s\n' '--- commandScheduler.cpp setup and operation execution ---' sed -n '1,190p' src/graphics/host_gpu/renderer/commandScheduler.cpp sed -n '300,390p' src/graphics/host_gpu/renderer/commandScheduler.cpp printf '%s\n' '--- texture-cache tracking declarations and callers ---' rg -n -C 8 -F -- 'TrackImage(' src/graphics/host_gpu/renderer rg -n -C 8 -F -- 'TrackImageHead(' src/graphics/host_gpu/renderer rg -n -C 8 -F -- 'TrackImageTail(' src/graphics/host_gpu/renderer rg -n -C 8 -F -- 'UntrackImage(' src/graphics/host_gpu/renderer printf '%s\n' '--- scheduler construction and GPU timestamp ownership ---' rg -n -C 8 -F -- 'CommandScheduler(' src/graphics/host_gpu/renderer rg -n -C 8 -F -- 'GpuTimestamps' src/graphics/host_gpu/renderer ``` Repository: KytyPS5/KytyPS5 Length of output: 41983 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- scheduler priority execution with line numbers ---' nl -ba src/graphics/host_gpu/renderer/commandScheduler.cpp | sed -n '232,320p' printf '%s\n' '--- texture cache callers with line numbers ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '580,710p' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '900,1030p' printf '%s\n' '--- direct TrackImage and watcher-related callers ---' rg -n -C 5 -F -- 'TrackImage(' src/graphics/host_gpu/renderer --glob '*.cpp' rg -n -C 5 -F -- 'UntrackImage(' src/graphics/host_gpu/renderer --glob '*.cpp' ``` Repository: KytyPS5/KytyPS5 Length of output: 33812 --- </details> **Synchronize the watcher check with the backing write.** `GpuTimestamps::Complete` runs on `CommandScheduler`'s priority thread, while texture-cache operations can update watchers directly through `TrackImage`. `StoreAtCompletion` releases the page lock when `IsWatched` returns, then calls `WriteBacking`. A watcher can be added in this gap, leaving the cached image stale. Make the watcher decision and backing write atomic with respect to watcher registration. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d107b4ec92c78bc77dff13ff --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠NeySlim <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 07:31 UTC · original · reviewed

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9694cfb5-5ac9-4383-8f9e-473dbd5eb09d
📥 Commits

Reviewing files that changed from the base of the PR and between 7b9997baea and 690c71713fb06866a198d2497eb70b9f447c429a.

📒 Files selected for processing (12)
  • src/graphics/guest_gpu/graphicsRun.cpp
  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/pageManager.cpp
  • src/graphics/host_gpu/pageManager.h
  • src/graphics/host_gpu/renderer/commandScheduler.cpp
  • src/graphics/host_gpu/renderer/commandScheduler.h
  • src/graphics/host_gpu/renderer/gpuTimestamps.cpp
  • src/graphics/host_gpu/renderer/gpuTimestamps.h
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/host_gpu/renderer/renderContext.h
  • src/graphics/presentation/window/vulkanWindow.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 07:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#pullrequestreview-5467146436) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `9694cfb5-5ac9-4383-8f9e-473dbd5eb09d` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7b9997baea0d385e9e8fc2bd3abeb02110bc4148 and 690c71713fb06866a198d2497eb70b9f447c429a. </details> <details> <summary>📒 Files selected for processing (12)</summary> * `src/graphics/guest_gpu/graphicsRun.cpp` * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/pageManager.cpp` * `src/graphics/host_gpu/pageManager.h` * `src/graphics/host_gpu/renderer/commandScheduler.cpp` * `src/graphics/host_gpu/renderer/commandScheduler.h` * `src/graphics/host_gpu/renderer/gpuTimestamps.cpp` * `src/graphics/host_gpu/renderer/gpuTimestamps.h` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `src/graphics/host_gpu/renderer/renderContext.h` * `src/graphics/presentation/window/vulkanWindow.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=555c2745-64a0-4542-8421-96e5fc7ce213 attempt=31db6ce7-6894-407d-a4e3-315c1174083e batch=1/1 -->
@ -0,0 +607,4 @@
});
stored++;
}
}
Author
Owner

@⁠NeySlim on GitHub · 2026-10-09 07:50 UTC · original

Fixed in 23fb2cf7. StoreRetries now writes every retry in order, mapped or not. The IsMapped check guarded against a retry landing after its range was unmapped, so RenderContext::UnmapMemory now stores the pending retries on the GPU thread before it drops the range. GpuCommandLane covers both: a timestamp to GPU-invisible memory deferred behind a watched one is stored by the next timestamp, and one to a range being unmapped is stored by the unmap.

**@⁠NeySlim** on GitHub · 2026-10-09 07:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#discussion_r4227888520) Fixed in 23fb2cf7. StoreRetries now writes every retry in order, mapped or not. The IsMapped check guarded against a retry landing after its range was unmapped, so RenderContext::UnmapMemory now stores the pending retries on the GPU thread before it drops the range. GpuCommandLane covers both: a timestamp to GPU-invisible memory deferred behind a watched one is stored by the next timestamp, and one to a range being unmapped is stored by the unmap.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-09 07:50 UTC · original
On src/graphics/host_gpu/renderer/renderContext.cpp line 94 (outdated):

@@ -79,6 +82,19 @@ bool RenderContext::InvalidateMemory(uint64_t vaddr, uint64_t size) {
 	return true;
 }
 
+bool RenderContext::StoreAtCompletion(uint64_t vaddr, const void* data, uint64_t size) {
+	if (!IsMapped(vaddr, size)) {
+		std::memcpy(reinterpret_cast<void*>(vaddr), data, size);
+		return true;
+	}
+	// Cached copies cannot be invalidated here; unwatched pages have none that a write can stale.
+	if (m_page_manager.IsWatched(vaddr, 1) || m_page_manager.IsWatched(vaddr + size - 1, 1)) {
+		return false;
+	}
+	LibKernel::Memory::WriteBacking(vaddr, data, size);

Fixed in ebdecd95. PageManager::StoreUnwatched replaces IsWatched plus WriteBacking: it holds the region locks of the pages (at most two, in address order, created if absent) across the watcher check and the backing write, so a registration either completes before the store, and its upload reads the stored bytes, or waits for it. The caches register their watchers before reading guest memory (TrackImage before UploadImage, ForEachUploadRange protects before copying), so this closes the gap. MemoryTrackerTests covers it: a watcher registering during the store is blocked until it lands, and watched pages, including the second page of a crossing store, refuse it.

**@⁠NeySlim** on GitHub · 2026-10-09 07:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#discussion_r4227888668) On `src/graphics/host_gpu/renderer/renderContext.cpp` line 94 (outdated): ```diff @@ -79,6 +82,19 @@ bool RenderContext::InvalidateMemory(uint64_t vaddr, uint64_t size) { return true; } +bool RenderContext::StoreAtCompletion(uint64_t vaddr, const void* data, uint64_t size) { + if (!IsMapped(vaddr, size)) { + std::memcpy(reinterpret_cast<void*>(vaddr), data, size); + return true; + } + // Cached copies cannot be invalidated here; unwatched pages have none that a write can stale. + if (m_page_manager.IsWatched(vaddr, 1) || m_page_manager.IsWatched(vaddr + size - 1, 1)) { + return false; + } + LibKernel::Memory::WriteBacking(vaddr, data, size); ``` Fixed in ebdecd95. PageManager::StoreUnwatched replaces IsWatched plus WriteBacking: it holds the region locks of the pages (at most two, in address order, created if absent) across the watcher check and the backing write, so a registration either completes before the store, and its upload reads the stored bytes, or waits for it. The caches register their watchers before reading guest memory (TrackImage before UploadImage, ForEachUploadRange protects before copying), so this closes the gap. MemoryTrackerTests covers it: a watcher registering during the store is blocked until it lands, and watched pages, including the second page of a crossing store, refuse it.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 07:51 UTC · original
On src/graphics/host_gpu/renderer/renderContext.cpp line 94 (outdated):

@@ -79,6 +82,19 @@ bool RenderContext::InvalidateMemory(uint64_t vaddr, uint64_t size) {
 	return true;
 }
 
+bool RenderContext::StoreAtCompletion(uint64_t vaddr, const void* data, uint64_t size) {
+	if (!IsMapped(vaddr, size)) {
+		std::memcpy(reinterpret_cast<void*>(vaddr), data, size);
+		return true;
+	}
+	// Cached copies cannot be invalidated here; unwatched pages have none that a write can stale.
+	if (m_page_manager.IsWatched(vaddr, 1) || m_page_manager.IsWatched(vaddr + size - 1, 1)) {
+		return false;
+	}
+	LibKernel::Memory::WriteBacking(vaddr, data, size);

@NeySlim, thanks for the fix and the explanation. Holding the page-region locks across the watcher check and backing write closes the registration race. The reported MemoryTrackerTests coverage also checks registration blocking and refusal when the second page is watched.


✏️ Learnings added
Learnt from: NeySlim
Repo: KytyPS5/KytyPS5 PR: 1282
File: src/graphics/host_gpu/renderer/renderContext.cpp:0-0
Timestamp: 2026-10-09T07:50:49.512Z
Learning: In KytyPS5's C++ GPU caches, watcher registration precedes guest-memory reads: TrackImage precedes UploadImage in the texture cache, and ForEachUploadRange protects memory before copying in the buffer cache. PageManager::StoreUnwatched in src/graphics/host_gpu/pageManager.cpp holds page-region locks across the watcher check and backing write, which synchronizes completion-time stores with watcher registration.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 07:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#discussion_r4227892491) On `src/graphics/host_gpu/renderer/renderContext.cpp` line 94 (outdated): ```diff @@ -79,6 +82,19 @@ bool RenderContext::InvalidateMemory(uint64_t vaddr, uint64_t size) { return true; } +bool RenderContext::StoreAtCompletion(uint64_t vaddr, const void* data, uint64_t size) { + if (!IsMapped(vaddr, size)) { + std::memcpy(reinterpret_cast<void*>(vaddr), data, size); + return true; + } + // Cached copies cannot be invalidated here; unwatched pages have none that a write can stale. + if (m_page_manager.IsWatched(vaddr, 1) || m_page_manager.IsWatched(vaddr + size - 1, 1)) { + return false; + } + LibKernel::Memory::WriteBacking(vaddr, data, size); ``` `@NeySlim`, thanks for the fix and the explanation. Holding the page-region locks across the watcher check and backing write closes the registration race. The reported `MemoryTrackerTests` coverage also checks registration blocking and refusal when the second page is watched. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: NeySlim Repo: KytyPS5/KytyPS5 PR: 1282 File: src/graphics/host_gpu/renderer/renderContext.cpp:0-0 Timestamp: 2026-10-09T07:50:49.512Z Learning: In KytyPS5's C++ GPU caches, watcher registration precedes guest-memory reads: TrackImage precedes UploadImage in the texture cache, and ForEachUploadRange protects memory before copying in the buffer cache. PageManager::StoreUnwatched in src/graphics/host_gpu/pageManager.cpp holds page-region locks across the watcher check and backing write, which synchronizes completion-time stores with watcher registration. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Close%20GPU%20cache%20races%20by%20locking%20watcher%20checks%20with%20backing%20writes%E2%80%94new%20registrations%20can%E2%80%99t%20leave%20stale%20images%2C%20even%20across%20page%20boundaries.%20%40coderabbitai%20helps%20catch%20the%20tricky%20bugs%20%F0%9F%94%92%F0%9F%A6%80&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1282%23discussion_r4227749871)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
@ -0,0 +607,4 @@
});
stored++;
}
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 07:51 UTC · original

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
git rev-parse HEAD
ast-grep outline src/graphics/host_gpu/renderer/gpuTimestamps.cpp --match StoreRetries --view expanded
ast-grep outline src/graphics/host_gpu/renderer/renderContext.cpp --match UnmapMemory --view expanded
ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match GpuCommandLane --view expanded
git show --format=fuller --stat 23fb2cf7
git show --format= --no-ext-diff 23fb2cf7 -- src/graphics/host_gpu/renderer/gpuTimestamps.cpp src/graphics/host_gpu/renderer/gpuTimestamps.h src/graphics/host_gpu/renderer/renderContext.cpp tests/ShaderRecompilerComputeTests.cpp

Length of output: 8826


🏁 Script executed:

#!/bin/bash
set -euo pipefail
git merge-base --is-ancestor 23fb2cf7 HEAD && echo "Fix commit is an ancestor of HEAD"
sed -n '328,355p' src/graphics/host_gpu/renderer/gpuTimestamps.cpp
sed -n '107,150p' src/graphics/host_gpu/renderer/renderContext.cpp
rg -n -C3 'timestamps retried behind a watched one|unmapped_at_unmap =|cpu_early =' tests/ShaderRecompilerComputeTests.cpp

Length of output: 4463


@NeySlim, verified 23fb2cf7 and the current PR code. StoreRetries now writes every retry in order. RenderContext::UnmapMemory drains retries before removing the range. The GpuCommandLane regression tests cover both cases you described. I did not run the tests.

Thanks for clarifying the unmap lifetime requirement.


✏️ Learnings added
Learnt from: NeySlim
Repo: KytyPS5/KytyPS5 PR: 1282
File: src/graphics/host_gpu/renderer/gpuTimestamps.cpp:342-344
Timestamp: 2026-10-09T07:51:08.195Z
Learning: In KytyPS5's C++ GPU timestamp path, GPU-invisible guest memory can still be a valid CPU-store destination. GpuTimestamps::StoreRetries in src/graphics/host_gpu/renderer/gpuTimestamps.cpp must write all deferred timestamps in order, without filtering by RenderContext::IsMapped. RenderContext::UnmapMemory in src/graphics/host_gpu/renderer/renderContext.cpp drains pending completion operations and timestamp retries on the GPU thread before removing the range, to prevent retry stores after unmap.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 07:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#discussion_r4227894333) <details> <summary>🧩 Analysis chain</summary> 🏁 Script executed: ```shell #!/bin/bash set -euo pipefail git rev-parse HEAD ast-grep outline src/graphics/host_gpu/renderer/gpuTimestamps.cpp --match StoreRetries --view expanded ast-grep outline src/graphics/host_gpu/renderer/renderContext.cpp --match UnmapMemory --view expanded ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match GpuCommandLane --view expanded git show --format=fuller --stat 23fb2cf7 git show --format= --no-ext-diff 23fb2cf7 -- src/graphics/host_gpu/renderer/gpuTimestamps.cpp src/graphics/host_gpu/renderer/gpuTimestamps.h src/graphics/host_gpu/renderer/renderContext.cpp tests/ShaderRecompilerComputeTests.cpp ``` Length of output: 8826 --- 🏁 Script executed: ```shell #!/bin/bash set -euo pipefail git merge-base --is-ancestor 23fb2cf7 HEAD && echo "Fix commit is an ancestor of HEAD" sed -n '328,355p' src/graphics/host_gpu/renderer/gpuTimestamps.cpp sed -n '107,150p' src/graphics/host_gpu/renderer/renderContext.cpp rg -n -C3 'timestamps retried behind a watched one|unmapped_at_unmap =|cpu_early =' tests/ShaderRecompilerComputeTests.cpp ``` Length of output: 4463 --- </details> `@NeySlim`, verified `23fb2cf7` and the current PR code. `StoreRetries` now writes every retry in order. `RenderContext::UnmapMemory` drains retries before removing the range. The `GpuCommandLane` regression tests cover both cases you described. I did not run the tests. Thanks for clarifying the unmap lifetime requirement. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: NeySlim Repo: KytyPS5/KytyPS5 PR: 1282 File: src/graphics/host_gpu/renderer/gpuTimestamps.cpp:342-344 Timestamp: 2026-10-09T07:51:08.195Z Learning: In KytyPS5's C++ GPU timestamp path, GPU-invisible guest memory can still be a valid CPU-store destination. GpuTimestamps::StoreRetries in src/graphics/host_gpu/renderer/gpuTimestamps.cpp must write all deferred timestamps in order, without filtering by RenderContext::IsMapped. RenderContext::UnmapMemory in src/graphics/host_gpu/renderer/renderContext.cpp drains pending completion operations and timestamp retries on the GPU thread before removing the range, to prevent retry stores after unmap. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Unmapped%20timestamp%20retries%20could%20vanish%2C%20leaving%20guests%20with%20stale%20reads.%20%40coderabbitai%20helped%20catch%20the%20fix%3A%20flush%20before%20unmap%2C%20then%20store%20every%20retry%20in%20order.%20Try%20%40coderabbitai%20%F0%9F%90%87&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1282%23discussion_r4227749830)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠NeySlim on GitHub · 2026-10-09 08:33 UTC · original

Problem: when a completed timestamp targets a page a cache watches, its value is left to the GPU thread, which only stored it at its next GPU clock write (or at an unmap). A game that writes a single timestamp to such a page and then waits for it, with no further timestamp packet, waited until something unrelated happened.

Fix: the completion that defers a value now queues a store on the GPU thread (new GuestGpu::TrySendCommand, reached through RenderContext::PostGpuCommand, which tolerates a GPU that is shutting down since completions can outlive it). The GPU thread stores all pending retries, in order, as soon as it is between packets; one queued store covers every retry left until it runs. Writes and unmaps still store them too, so ordering is unchanged: later values wait behind earlier deferred ones, and a drain in progress still defers the completions that overlap it. Interrupts of the same packets are unchanged: they already run after the completion, and a deferred value lands on the GPU thread shortly after rather than at the next clock write.

Test: GpuCommandLane writes one timestamp to a page with GPU data not read back yet, submits it and records no further GPU clock write; the value must appear within 2 s. Without the fix it never does (checked by reverting the fix alone). ctest memory_tracker and resource_* pass; the GPU suite one case per process gives the same results as before the change.

**@⁠NeySlim** on GitHub · 2026-10-09 08:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#issuecomment-6077405579) Problem: when a completed timestamp targets a page a cache watches, its value is left to the GPU thread, which only stored it at its next GPU clock write (or at an unmap). A game that writes a single timestamp to such a page and then waits for it, with no further timestamp packet, waited until something unrelated happened. Fix: the completion that defers a value now queues a store on the GPU thread (new `GuestGpu::TrySendCommand`, reached through `RenderContext::PostGpuCommand`, which tolerates a GPU that is shutting down since completions can outlive it). The GPU thread stores all pending retries, in order, as soon as it is between packets; one queued store covers every retry left until it runs. Writes and unmaps still store them too, so ordering is unchanged: later values wait behind earlier deferred ones, and a drain in progress still defers the completions that overlap it. Interrupts of the same packets are unchanged: they already run after the completion, and a deferred value lands on the GPU thread shortly after rather than at the next clock write. Test: `GpuCommandLane` writes one timestamp to a page with GPU data not read back yet, submits it and records no further GPU clock write; the value must appear within 2 s. Without the fix it never does (checked by reverting the fix alone). ctest memory_tracker and resource_* pass; the GPU suite one case per process gives the same results as before the change.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-09 11:52 UTC · original

Review fixes pushed (the description is updated):

  • Completion order: once a value is left to the GPU thread, the EOP interrupts after it run on the GPU thread right after it, so a game woken by an interrupt reads the new value. End-of-pipe labels recorded after a GPU clock value not stored yet are stored after it at completion (otherwise still at parse time); GPU-side reads of such labels (WAIT_REG_MEM, COND_INDIRECT_BUFFER, predication) use the deferred value at once, as the host queue runs later commands after it. Without that, frame rate in God of War Ragnarök halved.
  • Program data and stacks have no backing alias: their values now go through the GPU thread instead of exiting.
  • The calibrated-timestamp entry points come from the extension the device enabled (KHR or EXT).
  • Counters with fewer than 64 valid bits: the rate sums the masked intervals and measures again after a long gap; without calibration the segment base follows the counter.
  • An unresolved batch at completion is now an EXIT_IF; one thread stores deferred values at a time.
  • page_manager_tests stubs TryWriteBacking, so it links again.

Each change has a test that fails without it. GPU suite one case per process: same failures as main.

**@⁠NeySlim** on GitHub · 2026-10-09 11:52 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#issuecomment-6080311972) Review fixes pushed (the description is updated): - Completion order: once a value is left to the GPU thread, the EOP interrupts after it run on the GPU thread right after it, so a game woken by an interrupt reads the new value. End-of-pipe labels recorded after a GPU clock value not stored yet are stored after it at completion (otherwise still at parse time); GPU-side reads of such labels (`WAIT_REG_MEM`, `COND_INDIRECT_BUFFER`, predication) use the deferred value at once, as the host queue runs later commands after it. Without that, frame rate in God of War Ragnarök halved. - Program data and stacks have no backing alias: their values now go through the GPU thread instead of exiting. - The calibrated-timestamp entry points come from the extension the device enabled (KHR or EXT). - Counters with fewer than 64 valid bits: the rate sums the masked intervals and measures again after a long gap; without calibration the segment base follows the counter. - An unresolved batch at completion is now an `EXIT_IF`; one thread stores deferred values at a time. - `page_manager_tests` stubs `TryWriteBacking`, so it links again. Each change has a test that fails without it. GPU suite one case per process: same failures as main.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-09 12:18 UTC · original

Review fixes pushed (the description is updated):

  • GPU-side reads of deferred labels: a read of another width missed them (a 32-bit WAIT_REG_MEM on half of a 64-bit label, or the 64-bit compare of COND_INDIRECT_BUFFER over a 32-bit label) and read the old memory, so a wait suspended until completion and a branch took the wrong side. Reads now apply every deferred label they overlap, byte by byte, over memory read after the lookup.
  • COND_EXEC read guest memory directly and skipped its packets on a deferred label; it now reads it like the other packets.
  • Cross-queue order: all guest queues are parsed on one thread and recorded into one host queue, and these reads saw labels at parse time before this change too, so the order between queues is unchanged. Other reads of label memory (shaders, DMA_DATA/COPY_DATA from memory) see the label at completion; the description says so.
  • Windows build: a test helper named near clashed with the windef.h macro; renamed.

Tests: GpuCommandLane now goes through the packets (WAIT_REG_MEM 32/64-bit across widths, COND_EXEC, COND_INDIRECT_BUFFER, boolean predication) on labels deferred behind a pending timestamp; each check fails when its fix, or the ReadLabel call in its packet, is reverted. memory_tracker, page_manager and resource_* pass; GPU suite one case per process: 595 of 604 pass, the same failures as main.

The Linux CI failure (ResourceMaterializationTests.cpp:246, IndirectDescriptor not default-constructible) comes from main, not from this branch.

**@⁠NeySlim** on GitHub · 2026-10-09 12:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#issuecomment-6080722924) Review fixes pushed (the description is updated): - GPU-side reads of deferred labels: a read of another width missed them (a 32-bit `WAIT_REG_MEM` on half of a 64-bit label, or the 64-bit compare of `COND_INDIRECT_BUFFER` over a 32-bit label) and read the old memory, so a wait suspended until completion and a branch took the wrong side. Reads now apply every deferred label they overlap, byte by byte, over memory read after the lookup. - `COND_EXEC` read guest memory directly and skipped its packets on a deferred label; it now reads it like the other packets. - Cross-queue order: all guest queues are parsed on one thread and recorded into one host queue, and these reads saw labels at parse time before this change too, so the order between queues is unchanged. Other reads of label memory (shaders, `DMA_DATA`/`COPY_DATA` from memory) see the label at completion; the description says so. - Windows build: a test helper named `near` clashed with the `windef.h` macro; renamed. Tests: `GpuCommandLane` now goes through the packets (`WAIT_REG_MEM` 32/64-bit across widths, `COND_EXEC`, `COND_INDIRECT_BUFFER`, boolean predication) on labels deferred behind a pending timestamp; each check fails when its fix, or the `ReadLabel` call in its packet, is reverted. memory_tracker, page_manager and resource_* pass; GPU suite one case per process: 595 of 604 pass, the same failures as main. The Linux CI failure (`ResourceMaterializationTests.cpp:246`, `IndirectDescriptor` not default-constructible) comes from main, not from this branch.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-09 15:04 UTC · original

Rebased on main and fixed the write-after-label ordering:

  • A CP write made at parse time (WRITE_DATA, DMA_DATA/COPY_DATA destination, DUMP_CONST_RAM, GET_LOD_STATS, occlusion dumps) to bytes of a deferred label or a pending GPU clock value now drops those bytes from it. GPU-side reads after the write (WAIT_REG_MEM, COND_EXEC, COND_INDIRECT_BUFFER, predication) see the new value, and the completion stores only the bytes nothing overwrote, so it no longer replaces the newer value in memory. The completion store and the update hold the same lock, so either order ends with the later write. Labels still need no GPU wait, so the frame rate fix is unchanged.
  • New GpuCommandLane check through packets: WRITE_DATA after a 32-bit label, after half of a 64-bit label, a DMA_DATA fill after a label, WRITE_DATA after a pending timestamp. It fails when the overwrite tracking, the masked read or the masked store is reverted.
  • Description: the limitation on other reads is stated more precisely (reads recorded before the completion store see the previous value), and a shader write after a deferred label is listed as not ordered.

GPU suite one case per process: same 10 failures as a clean main build (610 cases). memory_tracker, page_manager and resource_* pass.

**@⁠NeySlim** on GitHub · 2026-10-09 15:04 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#issuecomment-6083568433) Rebased on main and fixed the write-after-label ordering: - A CP write made at parse time (`WRITE_DATA`, `DMA_DATA`/`COPY_DATA` destination, `DUMP_CONST_RAM`, `GET_LOD_STATS`, occlusion dumps) to bytes of a deferred label or a pending GPU clock value now drops those bytes from it. GPU-side reads after the write (`WAIT_REG_MEM`, `COND_EXEC`, `COND_INDIRECT_BUFFER`, predication) see the new value, and the completion stores only the bytes nothing overwrote, so it no longer replaces the newer value in memory. The completion store and the update hold the same lock, so either order ends with the later write. Labels still need no GPU wait, so the frame rate fix is unchanged. - New `GpuCommandLane` check through packets: `WRITE_DATA` after a 32-bit label, after half of a 64-bit label, a `DMA_DATA` fill after a label, `WRITE_DATA` after a pending timestamp. It fails when the overwrite tracking, the masked read or the masked store is reverted. - Description: the limitation on other reads is stated more precisely (reads recorded before the completion store see the previous value), and a shader write after a deferred label is listed as not ordered. GPU suite one case per process: same 10 failures as a clean main build (610 cases). memory_tracker, page_manager and resource_* pass.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-12 02:09 UTC · original

Rebased on main after 5b730d4d; no behaviour change. The end-of-pipe writes it inlined in graphicsRun.cpp now carry the change directly: GPU clock values go through GpuTimestamps::Write and labels through WriteLabel in write32/write64 and the flip paths, and the interrupts of TriggerEopEventAtEndOfPipe and of a flip with interrupt still run behind the values written before them (GpuTimestamps::Signal). The GDS end-of-pipe path still stores pending values first.

memory_tracker, page_manager and resource_* pass; --gpu-command-lane-only passes 10 runs out of 10, and the timestamp, interrupt, label and WAIT_REG_MEM checks still fail when their part is reverted. GPU suite one case per process: 613 of 623 pass, the same 10 failures as a clean main build.

**@⁠NeySlim** on GitHub · 2026-10-12 02:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1282#issuecomment-6116497900) Rebased on main after 5b730d4d; no behaviour change. The end-of-pipe writes it inlined in `graphicsRun.cpp` now carry the change directly: GPU clock values go through `GpuTimestamps::Write` and labels through `WriteLabel` in `write32`/`write64` and the flip paths, and the interrupts of `TriggerEopEventAtEndOfPipe` and of a flip with interrupt still run behind the values written before them (`GpuTimestamps::Signal`). The GDS end-of-pipe path still stores pending values first. memory_tracker, page_manager and resource_* pass; `--gpu-command-lane-only` passes 10 runs out of 10, and the timestamp, interrupt, label and `WAIT_REG_MEM` checks still fail when their part is reverted. GPU suite one case per process: 613 of 623 pass, the same 10 failures as a clean main build.
This pull request has changes conflicting with the target branch.
  • src/graphics/guest_gpu/command_processor/commandProcessor.h
  • src/graphics/guest_gpu/command_processor/pm4Handlers.cpp
  • src/graphics/guest_gpu/graphicsRun.cpp
  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/pageManager.cpp
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/host_gpu/renderer/renderContext.h
  • src/graphics/presentation/window/vulkanWindow.cpp
  • tests/ShaderRecompilerComputeTests.cpp
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.
git fetch -u origin '+refs/pull/1282/head:github-bot/gh-1282'
git switch 'github-bot/gh-1282'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1282'
git switch 'github-bot/gh-1282'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1282'
git switch 'github-bot/gh-1282'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1282'
git switch 'main'
git merge --squash 'github-bot/gh-1282'
git switch 'main'
git merge --ff-only 'github-bot/gh-1282'
git switch 'main'
git merge 'github-bot/gh-1282'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.