[Runtime correctness] Complete shader modes, Linux exception delivery, and thread cancellation #1668

Closed
opened 2026-10-08 16:03:08 +00:00 by Sanjaysrinivas · 1 comment
Sanjaysrinivas commented 2026-10-08 16:03:08 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Sanjaysrinivas on 2026-10-08T16:03:08Z.


Split from #1659. Category: runtime correctness and completeness across Windows and Linux.

Problem and desired result

A title can convert and resolve its imports while still depending on shader or kernel behavior the emulator does not implement correctly. This tracker covers three concrete areas from the review: per-shader floating-point modes, guest exception delivery, and thread cancellation.

The goal is verified observable behavior with clear support limits. A successful API return, an exported symbol, or one title getting farther is not sufficient evidence that the general behavior is correct.

Baseline and evidence boundaries

Source baseline: upstream 4b005b229e24be9ec3f185def9e59cbc03aa9e4a.

The source gaps below are present at that commit. Existing reports and proposed fixes are linked for coordination; their claims retain their original evidence level. This issue does not assert that every title uses these features or that the unconfirmed Windows lock report has been reproduced.

Workstream A: shader floating-point modes

Use existing issue #981 as the detailed implementation/semantics discussion rather than creating a parallel competing specification.

That issue records the need to carry IEEE_MODE, DX10_CLAMP, FLOAT_MODE, and FP16_OVFL, with hardware measurements tied to the actual mode. A shader can also change mode during execution. ScalarInstructions.cpp currently accepts only round-to-nearest-even for s_round_mode and explicitly rejects s_denorm_mode.

  • Decode the initial mode for each supported shader stage and carry it through the recompile request, any serialized request/capture, and cache identity. A mode change must not reuse incompatible compiled output.
  • Establish mode-specific expected results using console/hardware measurements or exact authoritative implementation/ISA references, following CONTRIBUTING.md and #843.
  • Implement supported combinations using host capabilities deliberately. Where Vulkan float controls are needed, query and record their support; avoid leaving behavior accidentally dependent on the host driver.
  • Track supported immediate runtime mode changes. Explicitly reject dynamic or otherwise unsupported cases until their behavior is implemented and verified.
  • Test affected instruction families with mode-sensitive values: NaNs, infinities, signed zero, denormals, rounding boundaries, and f16 overflow where applicable. Apply a comparison rule appropriate to the instruction, rather than requiring bit equality where the reference allows variation.
  • Add a cache regression that changes only the relevant mode and verifies distinct/correct behavior.

Validation evidence must state the guest mode, reference/hardware source, input/expected output, host GPU/driver, and observed result. Default-mode measurements must not be presented as evidence for every mode.

Workstream B: guest exception delivery

sceKernelRaiseException dispatches through RaiseOn on Windows, while the Linux branch calls NotImplemented_nid_no_patch. Windows support already exists from #760; this is not a request to implement it from scratch.

  • Implement the supported Linux delivery contract, including target-thread handler execution and the required guest context/stack state.
  • Verify supported signal values, missing handler behavior, invalid targets, finished targets, self-delivery, and cross-thread delivery.
  • Exercise running targets, semaphore/address-wait targets, and targets exiting concurrently. Confirm that handler delivery does not lose the original wake-up, invent a wake-up, or turn a bounded wait into a hang.
  • Verify repeated/nested delivery according to the established contract, including what happens to outstanding deliveries during thread teardown.
  • Review Windows robustness work with #1421 and #1562. Treat #1488 as an unconfirmed scenario until reproduced; create a deterministic regression if it is confirmed.
  • Reuse applicable cases in GuestRaiseException.cpp, which already checks actual handler thread identity and wait interactions.

Tests should coordinate thread states with barriers/events rather than assume a sleep makes a race occur. Record accepted delivery counts and the contract for rejected deliveries; do not equate a zero return with handler execution.

Workstream C: thread cancellation

scePthreadCancel currently calls the unimplemented-operation helper.

  • Establish the guest contract from console evidence or authoritative references: supported cancellation states/types, cancellation points, pending requests, cleanup behavior, join result, and invalid/exited targets.
  • Map that contract onto the existing guest-thread lifecycle and host synchronization model on both OSes. Do not assume terminating a host thread implements guest cancellation correctly.
  • Implement the supported behavior and explicit diagnostics for unsupported cases, retaining the repository's rule that unimplemented behavior must not silently succeed.
  • Test cancellation of a running/waiting thread where the contract allows it, disabled/deferred cancellation where applicable, cleanup and resource ownership, join completion, and exit/cancel races.
  • Verify that cancellation does not strand a host/emulator lock or leave the process unable to create and join subsequent guest threads.

Shared validation matrix

Area Required observable evidence Host coverage
Initial shader mode Correct result and appropriate cache identity for each supported mode Supported Vulkan devices; driver/capability metadata recorded
Runtime mode change Correct affected operations or a precise unsupported diagnostic Same supported modes/devices
Exception to self/running peer Correct target handler/context; valid return/error behavior Windows and Linux
Exception during guest wait Wait/delivery semantics preserved; bounded completion Windows and Linux
Concurrent exception/exit Defined delivery/rejection outcome; no hang or invalid state Windows and Linux
Cancellation and cleanup Contract-correct termination, cleanup, join and subsequent usability Windows and Linux

Implement separate, reviewable PRs per subsystem or semantic family, following the repository's one-topic branch rule. The category issue coordinates progress; it does not require one enormous runtime PR.

Use reproducible title/homebrew reports to prioritize actual blockers. #1578 documents missing-import startup failures and #1497 documents a loader/import problem; they are related title evidence, not proof that the three workstreams above caused those failures. Link each symptom to its diagnosed implementation issue.

Acceptance criteria

  • Each listed workstream has verified supported behavior, with unsupported portions explicitly documented and linked rather than silently treated as implemented.
  • Tests assert actual values, handler context, cleanup, or thread progress and remain meaningful in Release.
  • Concurrency regressions complete within a bounded test timeout and include repeated execution where useful.
  • Shader results identify their semantic source and mode; host-specific discrepancies remain visible.
  • Windows/Linux results identify the exact commit, toolchain, GPU/driver when relevant, commands, and unresolved limitations.
  • Title-level improvements are linked to reproducible reports with tested scope. Subsystem completion alone does not award a game a completed compatibility status.
  • Release, concurrency, and GPU execution evidence: #1669.
  • Per-title blockers and observed behavior: #1671.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5765002907 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1668). Originally posted by [Sanjaysrinivas](https://github.com/Sanjaysrinivas) on 2026-10-08T16:03:08Z. --- Split from #1659. Category: **runtime correctness and completeness** across Windows and Linux. ## Problem and desired result A title can convert and resolve its imports while still depending on shader or kernel behavior the emulator does not implement correctly. This tracker covers three concrete areas from the review: per-shader floating-point modes, guest exception delivery, and thread cancellation. The goal is verified observable behavior with clear support limits. A successful API return, an exported symbol, or one title getting farther is not sufficient evidence that the general behavior is correct. ## Baseline and evidence boundaries Source baseline: upstream `4b005b229e24be9ec3f185def9e59cbc03aa9e4a`. The source gaps below are present at that commit. Existing reports and proposed fixes are linked for coordination; their claims retain their original evidence level. This issue does not assert that every title uses these features or that the unconfirmed Windows lock report has been reproduced. ## Workstream A: shader floating-point modes Use existing issue #981 as the detailed implementation/semantics discussion rather than creating a parallel competing specification. That issue records the need to carry `IEEE_MODE`, `DX10_CLAMP`, `FLOAT_MODE`, and `FP16_OVFL`, with hardware measurements tied to the actual mode. A shader can also change mode during execution. [`ScalarInstructions.cpp`](https://github.com/boykopovar/AnyPS5/blob/4b005b229e24be9ec3f185def9e59cbc03aa9e4a/core/shader/recompiler/Translation/src/ScalarInstructions.cpp#L412) currently accepts only round-to-nearest-even for `s_round_mode` and explicitly rejects `s_denorm_mode`. - [ ] Decode the initial mode for each supported shader stage and carry it through the recompile request, any serialized request/capture, and cache identity. A mode change must not reuse incompatible compiled output. - [ ] Establish mode-specific expected results using console/hardware measurements or exact authoritative implementation/ISA references, following `CONTRIBUTING.md` and #843. - [ ] Implement supported combinations using host capabilities deliberately. Where Vulkan float controls are needed, query and record their support; avoid leaving behavior accidentally dependent on the host driver. - [ ] Track supported immediate runtime mode changes. Explicitly reject dynamic or otherwise unsupported cases until their behavior is implemented and verified. - [ ] Test affected instruction families with mode-sensitive values: NaNs, infinities, signed zero, denormals, rounding boundaries, and f16 overflow where applicable. Apply a comparison rule appropriate to the instruction, rather than requiring bit equality where the reference allows variation. - [ ] Add a cache regression that changes only the relevant mode and verifies distinct/correct behavior. Validation evidence must state the guest mode, reference/hardware source, input/expected output, host GPU/driver, and observed result. Default-mode measurements must not be presented as evidence for every mode. ## Workstream B: guest exception delivery [`sceKernelRaiseException`](https://github.com/boykopovar/AnyPS5/blob/4b005b229e24be9ec3f185def9e59cbc03aa9e4a/core/libs/prx/libkernel/System/src/Exception.cpp#L286) dispatches through `RaiseOn` on Windows, while the Linux branch calls `NotImplemented_nid_no_patch`. Windows support already exists from #760; this is not a request to implement it from scratch. - [ ] Implement the supported Linux delivery contract, including target-thread handler execution and the required guest context/stack state. - [ ] Verify supported signal values, missing handler behavior, invalid targets, finished targets, self-delivery, and cross-thread delivery. - [ ] Exercise running targets, semaphore/address-wait targets, and targets exiting concurrently. Confirm that handler delivery does not lose the original wake-up, invent a wake-up, or turn a bounded wait into a hang. - [ ] Verify repeated/nested delivery according to the established contract, including what happens to outstanding deliveries during thread teardown. - [ ] Review Windows robustness work with #1421 and #1562. Treat #1488 as an unconfirmed scenario until reproduced; create a deterministic regression if it is confirmed. - [ ] Reuse applicable cases in [`GuestRaiseException.cpp`](https://github.com/boykopovar/AnyPS5/blob/4b005b229e24be9ec3f185def9e59cbc03aa9e4a/core/libs/tests/GuestRaiseException.cpp), which already checks actual handler thread identity and wait interactions. Tests should coordinate thread states with barriers/events rather than assume a sleep makes a race occur. Record accepted delivery counts and the contract for rejected deliveries; do not equate a zero return with handler execution. ## Workstream C: thread cancellation [`scePthreadCancel`](https://github.com/boykopovar/AnyPS5/blob/4b005b229e24be9ec3f185def9e59cbc03aa9e4a/core/libs/prx/libkernel/Pthread/src/Thread.cpp#L432) currently calls the unimplemented-operation helper. - [ ] Establish the guest contract from console evidence or authoritative references: supported cancellation states/types, cancellation points, pending requests, cleanup behavior, join result, and invalid/exited targets. - [ ] Map that contract onto the existing guest-thread lifecycle and host synchronization model on both OSes. Do not assume terminating a host thread implements guest cancellation correctly. - [ ] Implement the supported behavior and explicit diagnostics for unsupported cases, retaining the repository's rule that unimplemented behavior must not silently succeed. - [ ] Test cancellation of a running/waiting thread where the contract allows it, disabled/deferred cancellation where applicable, cleanup and resource ownership, join completion, and exit/cancel races. - [ ] Verify that cancellation does not strand a host/emulator lock or leave the process unable to create and join subsequent guest threads. ## Shared validation matrix | Area | Required observable evidence | Host coverage | | --- | --- | --- | | Initial shader mode | Correct result and appropriate cache identity for each supported mode | Supported Vulkan devices; driver/capability metadata recorded | | Runtime mode change | Correct affected operations or a precise unsupported diagnostic | Same supported modes/devices | | Exception to self/running peer | Correct target handler/context; valid return/error behavior | Windows and Linux | | Exception during guest wait | Wait/delivery semantics preserved; bounded completion | Windows and Linux | | Concurrent exception/exit | Defined delivery/rejection outcome; no hang or invalid state | Windows and Linux | | Cancellation and cleanup | Contract-correct termination, cleanup, join and subsequent usability | Windows and Linux | ## Delivery plan and related title evidence Implement separate, reviewable PRs per subsystem or semantic family, following the repository's one-topic branch rule. The category issue coordinates progress; it does not require one enormous runtime PR. Use reproducible title/homebrew reports to prioritize actual blockers. #1578 documents missing-import startup failures and #1497 documents a loader/import problem; they are related title evidence, not proof that the three workstreams above caused those failures. Link each symptom to its diagnosed implementation issue. ## Acceptance criteria - [ ] Each listed workstream has verified supported behavior, with unsupported portions explicitly documented and linked rather than silently treated as implemented. - [ ] Tests assert actual values, handler context, cleanup, or thread progress and remain meaningful in Release. - [ ] Concurrency regressions complete within a bounded test timeout and include repeated execution where useful. - [ ] Shader results identify their semantic source and mode; host-specific discrepancies remain visible. - [ ] Windows/Linux results identify the exact commit, toolchain, GPU/driver when relevant, commands, and unresolved limitations. - [ ] Title-level improvements are linked to reproducible reports with tested scope. Subsystem completion alone does not award a game a `completed` compatibility status. ## Related category issues - Release, concurrency, and GPU execution evidence: #1669. - Per-title blockers and observed behavior: #1671.
oneandonlydean commented 2026-10-09 20:26:49 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:26:49Z.


Closing: the concrete work here is already tracked in #981, #1488 and the linked PRs. File a separate issue for a specific failure with its log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088691415 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1668#issuecomment-6088691415). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:26:49Z. --- Closing: the concrete work here is already tracked in #981, #1488 and the linked PRs. File a separate issue for a specific failure with its log line.
Sign in to join this conversation.
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#1668
No description provided.