feat(shader): support MODE status bitfields in s_getreg_b32 #25959

Merged
Kikoarl merged 1 commit from upstream-pr/25959 into main 2026-11-27 18:39:05 +00:00
Kikoarl commented 2026-11-23 01:02:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-11-23T01:02:50Z.


What

Support reading static status bitfields from HW_REG_MODE (id = 1) in s_getreg_b32:

  • DX10_CLAMP (bit 8)
  • IEEE (bit 9)
  • FP16_OVFL (bit 23)

Changes in 0561d51345 (rebased onto origin/main 115a7036e2):

  • Narrow accepted HW_REG_MODE s_getreg_b32 windows in ScalarInstructions.cpp strictly to modeled bits 0..9 (offset + size <= 10u) and FP16_OVFL bit 23 (offset == 23u && size == 1u), rejecting unmodeled bits 10..22 and 24..31.
  • Remove the unreachable size == 32u ? 0xffffffffu : ... dead branch in ScalarInstructions.cpp.
  • Pin refusal of s_setreg_imm32_b32 writes to MODE bits 8+ (0xba800201u, 0xba800241u, 0xba8005c1u, 0xba80f801u), dynamic s_setreg_b32 MODE bits 8+ writes, and non-MODE s_setreg_b32 ignore behavior in ShaderModeRegisters.cpp, alongside verifyStatusBitfieldReads and verifyUnsupportedReads.
  • Restore the two pre-existing caveats from docs/dev/debt/shader.md#L133 in docs/dev/debt/changes/feat-shader-mode-bitfields.md and accurately document that s_setreg* writes to MODE bits 8+ throw (matching RoundingMode.cpp) while non-MODE s_setreg_b32 is ignored.

Provenance: AMD RDNA 2 ISA §§5.8, 6.4 Table 24 (MODE register bit layout: DX10_CLAMP bit 8, IEEE bit 9, FP16_OVFL bit 23), §12.3 SOPK S_GETREG_B32 Table 39 (Hardware Register IDs), and LLVM 20.1.8 AMDGPU AMDGPUBaseInfo.h / SIModeRegister.cpp.

Tested

  • Linux x86_64 Release RAM-disk build in /tmp/anyps5_verify_build (-DBUILD_TESTING=ON), rebased onto origin/main (115a7036e2, PR head 0561d51345).
  • ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir /tmp/anyps5_verify_build --output-on-failure -R "^(agc_shader_mode_register|agc_driver_scalar_getreg)$":
    • agc_shader_mode_register: Passed (0.57 s, all 23 unit checks including verifyOutputModifierRounding, verifyStatusBitfieldReads, verifyUnsupportedReads, verifyDynamicWrites, and verifyImmediateWrites).
    • agc_driver_scalar_getreg: Passed (1.38 s on Intel RPL-S Vulkan).
  • python3 tools/debt_fold.py --check and python3 tools/check_conventions.py --base origin/main: Passed cleanly.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Intel(R) Graphics (RPL-S), Mesa Vulkan, Linux x86_64
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5445321327 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25959). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-11-23T01:02:50Z. --- ### What Support reading static status bitfields from `HW_REG_MODE` (`id = 1`) in `s_getreg_b32`: - `DX10_CLAMP` (bit 8) - `IEEE` (bit 9) - `FP16_OVFL` (bit 23) Changes in `0561d51345` (rebased onto `origin/main` `115a7036e2`): - Narrow accepted `HW_REG_MODE` `s_getreg_b32` windows in `ScalarInstructions.cpp` strictly to modeled bits `0..9` (`offset + size <= 10u`) and `FP16_OVFL` bit `23` (`offset == 23u && size == 1u`), rejecting unmodeled bits `10..22` and `24..31`. - Remove the unreachable `size == 32u ? 0xffffffffu : ...` dead branch in `ScalarInstructions.cpp`. - Pin refusal of `s_setreg_imm32_b32` writes to MODE bits 8+ (`0xba800201u`, `0xba800241u`, `0xba8005c1u`, `0xba80f801u`), dynamic `s_setreg_b32` MODE bits 8+ writes, and non-MODE `s_setreg_b32` ignore behavior in `ShaderModeRegisters.cpp`, alongside `verifyStatusBitfieldReads` and `verifyUnsupportedReads`. - Restore the two pre-existing caveats from `docs/dev/debt/shader.md#L133` in `docs/dev/debt/changes/feat-shader-mode-bitfields.md` and accurately document that `s_setreg*` writes to MODE bits 8+ throw (matching `RoundingMode.cpp`) while non-MODE `s_setreg_b32` is ignored. Provenance: AMD RDNA 2 ISA §§5.8, 6.4 Table 24 (MODE register bit layout: `DX10_CLAMP` bit 8, `IEEE` bit 9, `FP16_OVFL` bit 23), §12.3 SOPK `S_GETREG_B32` Table 39 (Hardware Register IDs), and [LLVM 20.1.8 AMDGPU `AMDGPUBaseInfo.h`](https://github.com/llvm/llvm-project/blob/87f0227cb60147a26a1eeb4fb06e3b505e9c7261/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h) / `SIModeRegister.cpp`. ### Tested - Linux x86_64 Release RAM-disk build in `/tmp/anyps5_verify_build` (`-DBUILD_TESTING=ON`), rebased onto `origin/main` (`115a7036e2`, PR head `0561d51345`). - `ANYPS5_NO_SHADER_CACHE=1 ctest --test-dir /tmp/anyps5_verify_build --output-on-failure -R "^(agc_shader_mode_register|agc_driver_scalar_getreg)$"`: - `agc_shader_mode_register`: Passed (0.57 s, all 23 unit checks including `verifyOutputModifierRounding`, `verifyStatusBitfieldReads`, `verifyUnsupportedReads`, `verifyDynamicWrites`, and `verifyImmediateWrites`). - `agc_driver_scalar_getreg`: Passed (1.38 s on Intel RPL-S Vulkan). - `python3 tools/debt_fold.py --check` and `python3 tools/check_conventions.py --base origin/main`: Passed cleanly. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Intel(R) Graphics (RPL-S), Mesa Vulkan, Linux x86_64 - [x] AI-assisted: yes
MarcZX10 commented 2026-11-23 01:25:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T01:25:11Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the remaining checks were not run in this review.

What I ran

Reviewed head ca141eb9fcf876cfd9986eeba1358f2a7ee95c66 using the prepared diff and pinned repository reader. No test or build commands were run.

Results

Check Result Note
Diff and changed behavior passed MODE reads now include status fields
Local tests and build not run No command execution available
Author-reported checks not run Reported as passed in the PR description

Findings

Blocking

None.

Non-blocking

None.

Not verified

The PR description reports Linux x86_64 unit and execution checks and two Python checks as passed; I did not run them. The included changed files were read: ShaderModeRegisters.cpp, ScalarGetreg.cpp, ScalarInstructions.cpp, and feat-shader-mode-bitfields.md. No changed files were excluded. I reviewed the MODE register decoding and status-bit assembly, including the related float-mode accessors; I did not read unrelated portions of those files or independently verify the ISA and LLVM references.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015613568 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25959#pullrequestreview-6015613568). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T01:25:11Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the remaining checks were not run in this review. ## What I ran Reviewed head `ca141eb9fcf876cfd9986eeba1358f2a7ee95c66` using the prepared diff and pinned repository reader. No test or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed behavior | passed | MODE reads now include status fields | | Local tests and build | not run | No command execution available | | Author-reported checks | not run | Reported as passed in the PR description | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The PR description reports Linux x86_64 unit and execution checks and two Python checks as passed; I did not run them. The included changed files were read: `ShaderModeRegisters.cpp`, `ScalarGetreg.cpp`, `ScalarInstructions.cpp`, and `feat-shader-mode-bitfields.md`. No changed files were excluded. I reviewed the MODE register decoding and status-bit assembly, including the related float-mode accessors; I did not read unrelated portions of those files or independently verify the ISA and LLVM references. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-23 05:47:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:47:28Z.

Review: APPROVED


Reviewed — looks good

The change adds reads of known MODE status bits using the configured float mode, and the inspected code and tests support the stated behavior.

What I ran

Reviewed head 413c05030be2a0dcd8426b62bab657843ac93abd using repo_read.py search and file reads. No tests or build commands were run in this review; test results in the PR description are author-reported.

Results

Check Result Note
Changed code review passed All four changed files read
Tests and build not run PR reports tests; not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported test and convention-check results were not independently run. No other repository files were inspected beyond targeted context. files.json was unavailable; the manifest lists four changed files, all included and read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6017076670 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25959#pullrequestreview-6017076670). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T05:47:28Z. **Review:** APPROVED --- # Reviewed — looks good The change adds reads of known MODE status bits using the configured float mode, and the inspected code and tests support the stated behavior. ## What I ran Reviewed head `413c05030be2a0dcd8426b62bab657843ac93abd` using `repo_read.py` search and file reads. No tests or build commands were run in this review; test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All four changed files read | | Tests and build | not run | PR reports tests; not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author-reported test and convention-check results were not independently run. No other repository files were inspected beyond targeted context. `files.json` was unavailable; the manifest lists four changed files, all included and read. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-23 06:21:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T06:21:10Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected implementation and added coverage support the described MODE status bitfield reads.

What I ran

Reviewed head a1370b7242653eaf67d20882f8e2df81447aa875 against the prepared diff. No tests or build commands were run; the checks listed in the PR description are author-reported.

Results

Check Result Note
Diff and changed lines passed All four changed files read
Targeted source context passed Read MODE state and configuration accessors
Tests/build not run PR description reports test results

Findings

Blocking

None.

Non-blocking

None.

Not verified

Did not run the reported unit tests, execution tests, conventions check, or debt check; their results are author-reported. Did not verify behavior on physical hardware. Read ShaderModeRegisters.cpp, ScalarGetreg.cpp, ScalarInstructions.cpp, feat-shader-mode-bitfields.md, and targeted ranges of RoundingMode.cpp, TranslationContext.hpp, and Recompiler.hpp. No changed files were excluded; all four reviewed files were included in the prepared bundle.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6017330016 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25959#pullrequestreview-6017330016). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T06:21:10Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected implementation and added coverage support the described MODE status bitfield reads. ## What I ran Reviewed head `a1370b7242653eaf67d20882f8e2df81447aa875` against the prepared diff. No tests or build commands were run; the checks listed in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All four changed files read | | Targeted source context | passed | Read MODE state and configuration accessors | | Tests/build | not run | PR description reports test results | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Did not run the reported unit tests, execution tests, conventions check, or debt check; their results are author-reported. Did not verify behavior on physical hardware. Read `ShaderModeRegisters.cpp`, `ScalarGetreg.cpp`, `ScalarInstructions.cpp`, `feat-shader-mode-bitfields.md`, and targeted ranges of `RoundingMode.cpp`, `TranslationContext.hpp`, and `Recompiler.hpp`. No changed files were excluded; all four reviewed files were included in the prepared bundle. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-24 23:17:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-24T23:17:30Z.

Review: COMMENTED


Reviewed — no blocking findings

The reviewed change at d57aa92948a0702117af451ed9323d05b936371f adds MODE status-bit reads with bounded supported fields; the inspected code and tests support merging.

What I ran

No commands were run; this review used the prepared diff and pinned-head reader.

Results

Check Result Note
Source review passed All four changed files were read.
Test execution not run Test results in the PR description were author-reported.
Reviewed inventory not run review/files.json was unavailable through the reader.

Findings

Blocking

None.

Non-blocking

None.

Not verified

I could not inspect the run’s files.json inventory, so I could not independently confirm whether every file marked reviewed was read. No tests or convention checks were run in this review. The PR description reports successful targeted tests and convention checks; these results were not independently verified.

Files read: description.md, commits.md, manifest.json, diff.patch, ShaderModeRegisters.cpp, ScalarGetreg.cpp, ScalarInstructions.cpp, RoundingMode.cpp, and TranslationContext.hpp. The diff and manifest list four changed files, all included in files/; none was excluded by the manifest. files.json was unavailable.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6048939642 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25959#pullrequestreview-6048939642). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-24T23:17:30Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The reviewed change at `d57aa92948a0702117af451ed9323d05b936371f` adds MODE status-bit reads with bounded supported fields; the inspected code and tests support merging. ## What I ran No commands were run; this review used the prepared diff and pinned-head reader. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | All four changed files were read. | | Test execution | not run | Test results in the PR description were author-reported. | | Reviewed inventory | not run | `review/files.json` was unavailable through the reader. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I could not inspect the run’s `files.json` inventory, so I could not independently confirm whether every file marked reviewed was read. No tests or convention checks were run in this review. The PR description reports successful targeted tests and convention checks; these results were not independently verified. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `ShaderModeRegisters.cpp`, `ScalarGetreg.cpp`, `ScalarInstructions.cpp`, `RoundingMode.cpp`, and `TranslationContext.hpp`. The diff and manifest list four changed files, all included in `files/`; none was excluded by the manifest. `files.json` was unavailable.
MarcZX10 commented 2026-11-26 11:51:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T11:51:30Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected implementation reads MODE status bits from the supplied shader metadata and rejects unsupported reads and writes as described.

What I ran

Reviewed head 0561d51345e347a0fb6238d421aae8814d52cb73 using the prepared diff and repo_read.py source reader. No tests or build commands were run; reported test results are from the PR description.

Results

Check Result Note
Changed code review passed Implementation and changed lines inspected
Reported checks not run Description reports selected tests and convention checks passed

Findings

Blocking

None.

Non-blocking

None.

Not verified

No test or build was run in this review. The files listed as reviewed in the manifest were all read: core/libs/prx/libSceAgcDriver/tests/ShaderModeRegisters.cpp, core/libs/prx/libSceAgcDriver/tests/execution/ScalarGetreg.cpp, core/shader/recompiler/Translation/src/ScalarInstructions.cpp, and docs/dev/debt/changes/feat-shader-mode-bitfields.md. No files were excluded by the prepared review folder. Physical-console behavior was not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6073654274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25959#pullrequestreview-6073654274). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T11:51:30Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected implementation reads MODE status bits from the supplied shader metadata and rejects unsupported reads and writes as described. ## What I ran Reviewed head `0561d51345e347a0fb6238d421aae8814d52cb73` using the prepared diff and `repo_read.py` source reader. No tests or build commands were run; reported test results are from the PR description. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Implementation and changed lines inspected | | Reported checks | not run | Description reports selected tests and convention checks passed | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No test or build was run in this review. The files listed as reviewed in the manifest were all read: `core/libs/prx/libSceAgcDriver/tests/ShaderModeRegisters.cpp`, `core/libs/prx/libSceAgcDriver/tests/execution/ScalarGetreg.cpp`, `core/shader/recompiler/Translation/src/ScalarInstructions.cpp`, and `docs/dev/debt/changes/feat-shader-mode-bitfields.md`. No files were excluded by the prepared review folder. Physical-console behavior was not verified. ## To get this to a good state Nothing is required.
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!25959
No description provided.