refactor(recompiler): share the SPIR-V emission failure helper #832

Merged
MathiasDevelopes merged 1 commit from upstream-pr/832 into main 2026-10-07 07:34:21 +00:00
MathiasDevelopes commented 2026-10-06 08:13:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-06T08:13:43Z.


What

Nine SPIR-V backend sources each defined the same helper in an anonymous namespace:

[[noreturn]] void FailEmit(const std::string& reason) {
    throw std::runtime_error("SPIR-V module emission failed: " + reason);
}
  • FailEmit is declared once in SpirvEmitterHelpers.hpp and defined in SpirvEmitterHelpers.cpp; the exception type and message are unchanged
  • The copies in SpirvBufferAccess.cpp, SpirvConstants.cpp, SpirvDescriptors.cpp, SpirvFormatConvert.cpp, SpirvInputOutput.cpp, SpirvModuleSetup.cpp, SpirvSubgroup.cpp and SpirvTypes.cpp are removed
  • Sources that did not include SpirvEmitterHelpers.hpp now include it
  • In SpirvConstants.cpp and SpirvFormatConvert.cpp the anonymous namespace held only FailEmit and is removed

No behaviour change.

Tested

Linux, GCC 13.3. No title tested; the full build and ctest were not run.

  • All nine changed sources compile with -std=c++20 -Wall -Wextra -fsyntax-only against the pinned SPIRV-Headers (01e05779); the only warning (SpirvBufferAccess.cpp:118, -Wextra enum/non-enum conditional) is unchanged by this PR
  • FailEmit is defined once in the repository, in a source the recompiler target already builds

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4756024246 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/832). Originally posted by [MathiasDevelopes](https://github.com/MathiasDevelopes) on 2026-10-06T08:13:43Z. --- ### What Nine SPIR-V backend sources each defined the same helper in an anonymous namespace: ```cpp [[noreturn]] void FailEmit(const std::string& reason) { throw std::runtime_error("SPIR-V module emission failed: " + reason); } ``` - `FailEmit` is declared once in `SpirvEmitterHelpers.hpp` and defined in `SpirvEmitterHelpers.cpp`; the exception type and message are unchanged - The copies in `SpirvBufferAccess.cpp`, `SpirvConstants.cpp`, `SpirvDescriptors.cpp`, `SpirvFormatConvert.cpp`, `SpirvInputOutput.cpp`, `SpirvModuleSetup.cpp`, `SpirvSubgroup.cpp` and `SpirvTypes.cpp` are removed - Sources that did not include `SpirvEmitterHelpers.hpp` now include it - In `SpirvConstants.cpp` and `SpirvFormatConvert.cpp` the anonymous namespace held only `FailEmit` and is removed No behaviour change. ### Tested Linux, GCC 13.3. No title tested; the full build and `ctest` were not run. - All nine changed sources compile with `-std=c++20 -Wall -Wextra -fsyntax-only` against the pinned SPIRV-Headers (`01e05779`); the only warning (`SpirvBufferAccess.cpp:118`, `-Wextra` enum/non-enum conditional) is unchanged by this PR - `FailEmit` is defined once in the repository, in a source the recompiler target already builds ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-06 08:13:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-06T08:13:49Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5425589966 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/832#pullrequestreview-5425589966). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-06T08:13:49Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
MathiasDevelopes commented 2026-10-07 06:06:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-07T06:06:34Z.


Rebased onto latest main (now a single commit on top of a9ec7be2).

There was one conflict in SpirvFormatConvert.cpp: main added a new UnormToF32Bits helper in the same anonymous namespace as the file's local FailEmit copy. I kept UnormToF32Bits and dropped the local FailEmit, so the file now uses the shared one from SpirvEmitterHelpers.hpp like the rest of the SPIR-V backend. No other changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6032067942 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/832#issuecomment-6032067942). Originally posted by [MathiasDevelopes](https://github.com/MathiasDevelopes) on 2026-10-07T06:06:34Z. --- Rebased onto latest `main` (now a single commit on top of a9ec7be2). There was one conflict in `SpirvFormatConvert.cpp`: `main` added a new `UnormToF32Bits` helper in the same anonymous namespace as the file's local `FailEmit` copy. I kept `UnormToF32Bits` and dropped the local `FailEmit`, so the file now uses the shared one from `SpirvEmitterHelpers.hpp` like the rest of the SPIR-V backend. No other changes.
adriadam10 commented 2026-10-07 07:34:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T07:34:18Z.


Checked: the nine removed copies are identical to the shared one (same exception type and message), one definition left in core/shader; full build + ctest (385/385) on the PR merged onto current main, no new FailEmit copies in other open PRs. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6033222301 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/832#issuecomment-6033222301). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T07:34:18Z. --- Checked: the nine removed copies are identical to the shared one (same exception type and message), one definition left in `core/shader`; full build + ctest (385/385) on the PR merged onto current `main`, no new `FailEmit` copies in other open PRs. Merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!832
No description provided.