tests: cover BDA fault resolution and retry #1074

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

@⁠MehmetCambaz on GitHub · 2026-10-05 17:06 UTC · original
MehmetCambaz:test/bda-fault-resolve-retry → main · +306 −0 · 2 files · 1 commits · closed without merging

Summary

Adds end-to-end GPU coverage for unresolved scalar BDA accesses.

The test verifies the complete production lifecycle for both low and extended guest addresses:

  • unresolved scalar BDA access emits the expected fault bitmap;
  • the first unresolved access returns the defined zero result;
  • FaultManager processes the real GPU fault;
  • BufferCache resolves the guest page and publishes the BDA translation;
  • a subsequent normal dispatch completes without the target fault;
  • the retry returns the exact original guest-memory value.

No production behavior is changed.

What is covered

The scalar offset is supplied through runtime SGPR state so current resource planning cannot flatten the access into SRT before the shader reaches the BDA path.

The fixture also keeps its observable output in a separate noncontiguous guest mapping so descriptor preparation cannot resolve the intended target before the first dispatch.

Before the initial access, the test verifies that the target has no cached owner, no registered target region, and a zero BDA page-table entry.

Why this test matters

The individual shader, fault-manager, BufferCache, and page-table components can behave correctly in isolation while the full fault-resolution lifecycle is broken.

This regression exercises the production integration path from a real unresolved shader access through fault handling and BDA publication to a successful later dispatch.

Regression proof

Two temporary mutations were used:

  1. Disabling RecordBdaFault removes the expected fault bit (0x00000000 instead of 0x00010000) and fails the real-fault assertion.
  2. Disabling the normal FaultManager → FindBuffer resolution transition preserves the expected fault bit but fails during fault resolution.

Both mutations were reverted before the final commit.

Validation

  • bda_fault_resolution_retry — 10/10 passes
  • command_scheduler_timeline — pass
  • stream_buffer_ring — pass
  • buffer_cache_ranges — pass
  • focused VK_LAYER_KHRONOS_validation run — pass
  • git diff --check — pass

resource_tracking_tests could not be built in the current clang-cl test configuration because its exception-enabled source is compiled without -fexceptions; this is unrelated to KT-02.

Notes

  • Test-only change.
  • Independent of PR #1065.
  • No production behavior is modified.

AI assistance was used for codebase investigation, implementation support, and test execution. I reviewed the production lifecycle, final diff, mutation results, and validation results before submission.

**@⁠MehmetCambaz** on GitHub · 2026-10-05 17:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1074) `MehmetCambaz:test/bda-fault-resolve-retry` → `main` · +306 −0 · 2 files · 1 commits · closed without merging ## Summary Adds end-to-end GPU coverage for unresolved scalar BDA accesses. The test verifies the complete production lifecycle for both low and extended guest addresses: - unresolved scalar BDA access emits the expected fault bitmap; - the first unresolved access returns the defined zero result; - `FaultManager` processes the real GPU fault; - `BufferCache` resolves the guest page and publishes the BDA translation; - a subsequent normal dispatch completes without the target fault; - the retry returns the exact original guest-memory value. No production behavior is changed. ## What is covered The scalar offset is supplied through runtime SGPR state so current resource planning cannot flatten the access into SRT before the shader reaches the BDA path. The fixture also keeps its observable output in a separate noncontiguous guest mapping so descriptor preparation cannot resolve the intended target before the first dispatch. Before the initial access, the test verifies that the target has no cached owner, no registered target region, and a zero BDA page-table entry. ## Why this test matters The individual shader, fault-manager, BufferCache, and page-table components can behave correctly in isolation while the full fault-resolution lifecycle is broken. This regression exercises the production integration path from a real unresolved shader access through fault handling and BDA publication to a successful later dispatch. ## Regression proof Two temporary mutations were used: 1. Disabling `RecordBdaFault` removes the expected fault bit (`0x00000000` instead of `0x00010000`) and fails the real-fault assertion. 2. Disabling the normal `FaultManager` → `FindBuffer` resolution transition preserves the expected fault bit but fails during fault resolution. Both mutations were reverted before the final commit. ## Validation - `bda_fault_resolution_retry` — 10/10 passes - `command_scheduler_timeline` — pass - `stream_buffer_ring` — pass - `buffer_cache_ranges` — pass - focused `VK_LAYER_KHRONOS_validation` run — pass - `git diff --check` — pass `resource_tracking_tests` could not be built in the current clang-cl test configuration because its exception-enabled source is compiled without `-fexceptions`; this is unrelated to KT-02. ## Notes - Test-only change. - Independent of PR #1065. - No production behavior is modified. AI assistance was used for codebase investigation, implementation support, and test execution. I reviewed the production lifecycle, final diff, mutation results, and validation results before submission.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:05 +00:00
github-bot closed this pull request 2026-11-26 09:42:05 +00:00
Author
Owner

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

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 39ce2cc6-c13f-43f9-a476-5982ed7a0433
📥 Commits

Reviewing files that changed from the base of the PR and between 77d7722173 and a325663c0c.

📒 Files selected for processing (2)
  • CMakeLists.txt
  • tests/ShaderRecompilerComputeTests.cpp

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


📝 Walkthrough

Walkthrough

Adds a compute test for address-only scalar loads from low and extended guest-memory regions. The test checks initial page-table state, verifies that the first dispatch faults on the target page, and confirms that a retry loads the expected value without another fault. The test runs in the normal compute-test sequence and through a dedicated command-line option registered as a CTest case.

Suggested reviewers: nmzik, defektu

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to a3256

This change adds regression coverage for BDA fault resolution and retry, plus a dedicated CTest case. Runtime behavior is unchanged, and no merge-blocking risk was found.

Architecture Summary

Architecture risk: 🔵 Low · up to a3256

The change affects 2 systems.

Changed systems: CMakeLists.txt, tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — CMakeLists.txt (service) was modified; 1 changed file maps to changed impact.
  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in CMakeLists.txt: Adds the bda_fault_resolution_retry test, invoking the compute test executable with the --bda-fault-retry-only option.
  • observed — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: Adds CheckBdaFaultResolutionRetry. For low and extended memory targets, it establishes an uncached page with a zero table entry, dispatches an address-only load, and checks that the first access faults on exactly that page and returns zero. It then verifies the faulted page is cached and its BDA table entry points to the resolved buffer; a second dispatch must record no fault and return the region’s expected value. The test maps and initializes backing and output memory, and releases GPU mappings and direct allocations afterward.
  • observed — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: Adds the --bda-fault-retry-only option, which creates a Vulkan harness, runs CheckBdaFaultResolutionRetry, and exits successfully afterward.
  • observed — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: Adds CheckBdaFaultResolutionRetry to the normal compute-test sequence.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: tests for BDA fault resolution and retry.
Description check ✅ Passed The description explains the end-to-end BDA fault-resolution test, its coverage, and reported validation. It is directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
  • Autopilot · 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-05 17:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1074#issuecomment-5999312609) <!-- 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/1074?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> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `39ce2cc6-c13f-43f9-a476-5982ed7a0433` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 77d772217310dc734ce53289110c9be0885a0577 and a325663c0c8394684c02229082adad3637150d91. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `CMakeLists.txt` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough Adds a compute test for address-only scalar loads from low and extended guest-memory regions. The test checks initial page-table state, verifies that the first dispatch faults on the target page, and confirms that a retry loads the expected value without another fault. The test runs in the normal compute-test sequence and through a dedicated command-line option registered as a CTest case. **Suggested reviewers:** `nmzik`, `defektu` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"a325663c0c8394684c02229082adad3637150d91" --> **Change:** Other <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `a3256` <!-- final_review_risk_coverage:{"sourceCommitId":"a325663c0c8394684c02229082adad3637150d91","coveredCommitId":"a325663c0c8394684c02229082adad3637150d91","kind":"reviewed"} --> This change adds regression coverage for BDA fault resolution and retry, plus a dedicated CTest case. Runtime behavior is unchanged, and no merge-blocking risk was found. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Architecture Summary **Architecture risk:** _🔵 Low_ · up to `a3256` The change affects 2 systems. **Changed systems:** `CMakeLists.txt`, `tests` **Architecture concerns** No architecture-level concerns identified. <details> <summary>Review details</summary> **Systems and components** - _observed_ — CMakeLists.txt (service) was modified; 1 changed file maps to changed impact. - _observed_ — tests (service) was modified; 1 changed file maps to changed impact. **Before / after behavior** - _observed_ — Modified behavior in CMakeLists.txt: Adds the `bda_fault_resolution_retry` test, invoking the compute test executable with the `--bda-fault-retry-only` option. - _observed_ — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: Adds `CheckBdaFaultResolutionRetry`. For low and extended memory targets, it establishes an uncached page with a zero table entry, dispatches an address-only load, and checks that the first access faults on exactly that page and returns zero. It then verifies the faulted page is cached and its BDA table entry points to the resolved buffer; a second dispatch must record no fault and return the region’s expected value. The test maps and initializes backing and output memory, and releases GPU mappings and direct allocations afterward. - _observed_ — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: Adds the `--bda-fault-retry-only` option, which creates a Vulkan harness, runs `CheckBdaFaultResolutionRetry`, and exits successfully afterward. - _observed_ — Modified behavior in tests/ShaderRecompilerComputeTests.cpp: Adds `CheckBdaFaultResolutionRetry` to the normal compute-test sequence. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 5</summary> <details> <summary>✅ Passed checks (5 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly summarizes the main change: tests for BDA fault resolution and retry. | | Description check | ✅ Passed | The description explains the end-to-end BDA fault-resolution test, its coverage, and reported validation. It is directly related to the changeset. | | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0… | | 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. | </details> </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">Autopilot</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=1074)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [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) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠overlordxrz-source on GitHub · 2026-10-06 00:13 UTC · original

Validated locally (read the diff, built on x86_64 macOS no-Qt Release):

  • shader_recompiler_compute_tests builds clean with the new CheckBdaFaultResolutionRetry fixture. Couldn't execute it here (needs a real Vulkan device; no loader in this environment — same pre-existing limitation as clean main), so this is compile + code review only.
  • Test design looks right: separate noncontiguous output mapping (prevents descriptor prep from resolving the target early), runtime-SGPR offset (defeats SRT flattening), and the full lifecycle in one place — fault bitmap, defined-zero first result, real FaultManager processing, page resolution + BDA publication, clean second dispatch, exact-value retry. The --bda-fault-retry-only filter is a nice touch for iterating on fault-path work without running the whole compute suite.
  • Pairs naturally with #1065 (init-before-first-use); together they pin both ends of the unowned-page lifecycle. No production change here, low risk. Looks good to me.
**@⁠overlordxrz-source** on GitHub · 2026-10-06 00:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1074#issuecomment-6006212708) Validated locally (read the diff, built on x86_64 macOS no-Qt Release): - `shader_recompiler_compute_tests` builds clean with the new `CheckBdaFaultResolutionRetry` fixture. Couldn't execute it here (needs a real Vulkan device; no loader in this environment — same pre-existing limitation as clean main), so this is compile + code review only. - Test design looks right: separate noncontiguous output mapping (prevents descriptor prep from resolving the target early), runtime-SGPR offset (defeats SRT flattening), and the full lifecycle in one place — fault bitmap, defined-zero first result, real `FaultManager` processing, page resolution + BDA publication, clean second dispatch, exact-value retry. The `--bda-fault-retry-only` filter is a nice touch for iterating on fault-path work without running the whole compute suite. - Pairs naturally with #1065 (init-before-first-use); together they pin both ends of the unowned-page lifecycle. No production change here, low risk. Looks good to me.

Pull request closed

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