fix(libSceVideoOut): accept an output mode left at any in every field #22517

Merged
adam25136 merged 1 commit from upstream-pr/22517 into main 2026-11-17 19:35:54 +00:00
adam25136 commented 2026-11-17 18:36:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adam25136 on 2026-11-17T18:36:10Z.


What

On main, sceVideoOutConfigureOutputMode_ checks its arguments in firmware 13.42's order (#19293) and then throws for every mode record that passes them. With this change, on a main-bus port, it returns 0 and changes nothing for a record whose first word is 0x20 and whose bytes 4 to 0x1f are all 0xff (every field "any", which is how sceVideoOutModeSetAny_ fills it), when the fourth argument is null. Any other record whose first word is 0x20, and a non-null fourth argument, still throw.

  • Why 0 for this record: in BunnyFl's run of firmware 13.42's validator (#15134 comment, a PC harness, not a console), this record passes with the flags word clear; no result for it with flags set is reported. The module then checks that no other handle owns the output, which cannot fail here because each bus has one handle (VideoOutDriver::Open gives bus n handle n + 1). It then sends the request to libSceAvSetting and returns that module's reply, mapped to VideoOut codes; what comes back through libSceAvSetting's IPC was not read. So the 0 is inferred, as the new Unknown function info entry says. The run called the validator directly with five imports stubbed to return 0, among them sceKernelGetPs4CompiledSdkVersion; it read firmware 13.42's PS5 module, and PS4 firmware's libSceVideoOut was not read.
  • Why a silent stub is acceptable here: every field of this record is "any", so it asks for no particular mode. The effects of the call that were read are the request to libSceAvSetting (after its one-time setup), the handle recorded as the output's owner, and a 16-byte cached copy on the port that the result keeps or rolls back. main keeps none of them, and returning 0 leaves what it does model (the output mode sceVideoOutConfigureOutput stores, host HDR) as it is and posts no set-mode event. What the console does with such a request is not known, and a record that asks for a value still throws. Other no-op display calls under Silent stubs, such as sceVideoOutVrrPegToFixedRate and sceVideoOutSetWindowModeMargins, are the same kind.
  • Who calls it this way: inFAMOUS Second Son (CUSA00223 01.07). Both of its call sites fill the record with sceVideoOutModeSetAny_(&mode, 0x20) after registering the display buffers. They then write only +6: 0x0c or 0xff (what sceVideoOutModeSetAny_ put there), chosen by a flag that also picks the buffers' pixel format (0x88740000 with 0x0c). The call is (handle, 0, &mode, 0, 0x20, 0x10), and its result is not checked.
  • Earlier work: #10531 (DealPotato, closed by the open-PR limit) returned 0 for every record. zaryabzip's #19293 added the argument checks main has now and left the function throwing; after BunnyFl's run they kept it throwing because what the validator accepts depends on the flag bits; this covers only the record that passed with them clear. I asked them on #15134 before opening this and have had no answer.
  • Technical debt: a fragment rewrites the sceVideoOutGetDeviceInfoEx_, sceVideoOutConfigureOutputMode_ entry and adds a Silent stubs entry and an Unknown function info entry for this record.

Tested

Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 (r7), CMake 4.3.1, Release, this branch on main 4b83e9d223. main's own agc_driver_upload_cache_read_only_flush_tests does not build with MinGW (setenv; open #19899 fixes it), so the builds went on past it.

  • guest_video_out_output_mode_checks: passes, with its new checks. A record left at any returns 0, and the same record with its first word 0x1f still returns 0x80290016. These calls still throw: the record with any one of bytes 4 to 0x1f set to 0 (28 calls), the record with colorimetry 0x0c, and the record left at any with a non-null fourth argument. Each throw must be sceVideoOutConfigureOutputMode_ not implemented, counted once by NotImplementedCalls_nid_no_patch. Without the InventoryExports.cpp change it fails with sceVideoOutConfigureOutputMode_ not implemented, and each of 7 further deliberate breaks fails it: accepting every record whose first word is 0x20, ignoring the fourth argument, skipping byte 4, skipping the last byte, checking only byte 6, checking only bytes 4, 6 and 0x1f, and moving the new check above the first-word check. It also passes in a build configured with -DANYPS5_ENABLE_SPIRV_TOOLS=ON.
  • The 1,186 tests tools/select_tests.py selects for the 3 changed files (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), on main and on this branch: 1,184 pass on both. performance_runner_PerformanceRunTests fails on both, because a clean performance capture refuses ANYPS5_NO_SHADER_CACHE, and guest_video_out_wqhd_detection_no_vulkan is skipped on both (it points the Vulkan loader at a missing driver file).
  • With VK_LAYER_KHRONOS_validation 1.4.367 (VK_ADD_LAYER_PATH=<the layer's folder> VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer VK_LOADER_LAYERS_DISABLE=~implicit~ ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1), the 63 tests matching video_out|videoout, ctest -V, on main and on this branch: each log has 49 Insert instance layer "VK_LAYER_KHRONOS_validation" lines from 48 tests, no "was not found" line and no VUID- message. 62 pass on both, and guest_video_out_wqhd_detection_no_vulkan is skipped on both, as above.
  • inFAMOUS Second Son (CUSA00223 01.07, my own dump), unwrapped by main's tools/unwrap_self.py and converted with --windows --registry --trace-imports. Both starts ran on main be4613dd73 with #18235, #17711 and #18184 merged locally (#17711's one conflicting file, libSceGnmDriverForNeoMode/Export.cpp, kept main's version) and a local answer for libSceDiscMap's fJgP+wqifno (asked about on #10531); the load needs all of them. One traced start each:
    • without this change: stops 8.1 s in with sceVideoOutConfigureOutputMode_ not implemented, before the first frame;
    • with it (an earlier form of the same condition, written with std::all_of): gets past the call, so its record was all 0xff; presents its first frame and stops 26.7 s in on an AGC driver error, a separate gap. The image descriptor of compute shader 0x2f2fa2500 (format 22) matches none of the image modes of its static interface.
  • python tools/check_conventions.py --base origin/main with this title and description: all checks passed.
  • python tools/pr_overlap.py --branch: no overlap with open pull requests; the two that share files or exports with this branch merge cleanly with it.

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: CUSA00223 #8214
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 621.14, Windows 10 22H2
  • AI-assisted: yes

AI-assisted: Claude Code found the title's call sites in its executable, wrote the change and its test, ran the tests and the inFAMOUS starts, and drafted this description; separate review agents checked it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5362776936 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22517). Originally posted by [adam25136](https://github.com/adam25136) on 2026-11-17T18:36:10Z. --- ### What On `main`, `sceVideoOutConfigureOutputMode_` checks its arguments in firmware 13.42's order (#19293) and then throws for every mode record that passes them. With this change, on a main-bus port, it returns 0 and changes nothing for a record whose first word is 0x20 and whose bytes 4 to 0x1f are all 0xff (every field "any", which is how `sceVideoOutModeSetAny_` fills it), when the fourth argument is null. Any other record whose first word is 0x20, and a non-null fourth argument, still throw. - **Why 0 for this record:** in BunnyFl's run of firmware 13.42's validator ([#15134 comment](https://github.com/boykopovar/AnyPS5/issues/15134#issuecomment-6907373767), a PC harness, not a console), this record passes with the flags word clear; no result for it with flags set is reported. The module then checks that no other handle owns the output, which cannot fail here because each bus has one handle (`VideoOutDriver::Open` gives bus `n` handle `n + 1`). It then sends the request to libSceAvSetting and returns that module's reply, mapped to VideoOut codes; what comes back through libSceAvSetting's IPC was not read. So the 0 is inferred, as the new Unknown function info entry says. The run called the validator directly with five imports stubbed to return 0, among them `sceKernelGetPs4CompiledSdkVersion`; it read firmware 13.42's PS5 module, and PS4 firmware's libSceVideoOut was not read. - **Why a silent stub is acceptable here:** every field of this record is "any", so it asks for no particular mode. The effects of the call that were read are the request to libSceAvSetting (after its one-time setup), the handle recorded as the output's owner, and a 16-byte cached copy on the port that the result keeps or rolls back. `main` keeps none of them, and returning 0 leaves what it does model (the output mode `sceVideoOutConfigureOutput` stores, host HDR) as it is and posts no set-mode event. What the console does with such a request is not known, and a record that asks for a value still throws. Other no-op display calls under Silent stubs, such as `sceVideoOutVrrPegToFixedRate` and `sceVideoOutSetWindowModeMargins`, are the same kind. - **Who calls it this way:** inFAMOUS Second Son (CUSA00223 01.07). Both of its call sites fill the record with `sceVideoOutModeSetAny_(&mode, 0x20)` after registering the display buffers. They then write only `+6`: 0x0c or 0xff (what `sceVideoOutModeSetAny_` put there), chosen by a flag that also picks the buffers' pixel format (0x88740000 with 0x0c). The call is `(handle, 0, &mode, 0, 0x20, 0x10)`, and its result is not checked. - **Earlier work:** #10531 (DealPotato, closed by the open-PR limit) returned 0 for every record. zaryabzip's #19293 added the argument checks `main` has now and left the function throwing; after BunnyFl's run they [kept it throwing](https://github.com/boykopovar/AnyPS5/issues/15134#issuecomment-6910945198) because what the validator accepts depends on the flag bits; this covers only the record that passed with them clear. [I asked them on #15134](https://github.com/boykopovar/AnyPS5/issues/15134#issuecomment-6924476664) before opening this and have had no answer. - **Technical debt:** a fragment rewrites the `sceVideoOutGetDeviceInfoEx_, sceVideoOutConfigureOutputMode_` entry and adds a Silent stubs entry and an Unknown function info entry for this record. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 10 Pro 22H2 (19045), NVIDIA GeForce RTX 5080 (driver 621.14), WinLibs GCC 15.2.0 (r7), CMake 4.3.1, Release, this branch on `main` `4b83e9d223`. `main`'s own `agc_driver_upload_cache_read_only_flush_tests` does not build with MinGW (`setenv`; open #19899 fixes it), so the builds went on past it. - **`guest_video_out_output_mode_checks`:** passes, with its new checks. A record left at any returns 0, and the same record with its first word 0x1f still returns 0x80290016. These calls still throw: the record with any one of bytes 4 to 0x1f set to 0 (28 calls), the record with colorimetry 0x0c, and the record left at any with a non-null fourth argument. Each throw must be `sceVideoOutConfigureOutputMode_ not implemented`, counted once by `NotImplementedCalls_nid_no_patch`. Without the `InventoryExports.cpp` change it fails with `sceVideoOutConfigureOutputMode_ not implemented`, and each of 7 further deliberate breaks fails it: accepting every record whose first word is 0x20, ignoring the fourth argument, skipping byte 4, skipping the last byte, checking only byte 6, checking only bytes 4, 6 and 0x1f, and moving the new check above the first-word check. It also passes in a build configured with `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`. - **The 1,186 tests `tools/select_tests.py` selects for the 3 changed files** (`ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`), on `main` and on this branch: 1,184 pass on both. `performance_runner_PerformanceRunTests` fails on both, because a clean performance capture refuses `ANYPS5_NO_SHADER_CACHE`, and `guest_video_out_wqhd_detection_no_vulkan` is skipped on both (it points the Vulkan loader at a missing driver file). - **With `VK_LAYER_KHRONOS_validation`** 1.4.367 (`VK_ADD_LAYER_PATH=<the layer's folder> VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer VK_LOADER_LAYERS_DISABLE=~implicit~ ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`), the 63 tests matching `video_out|videoout`, `ctest -V`, on `main` and on this branch: each log has 49 `Insert instance layer "VK_LAYER_KHRONOS_validation"` lines from 48 tests, no "was not found" line and no `VUID-` message. 62 pass on both, and `guest_video_out_wqhd_detection_no_vulkan` is skipped on both, as above. - **inFAMOUS Second Son** (CUSA00223 01.07, my own dump), unwrapped by `main`'s `tools/unwrap_self.py` and converted with `--windows --registry --trace-imports`. Both starts ran on `main` `be4613dd73` with #18235, #17711 and #18184 merged locally (#17711's one conflicting file, `libSceGnmDriverForNeoMode/Export.cpp`, kept `main`'s version) and a local answer for libSceDiscMap's `fJgP+wqifno` (asked about on #10531); the load needs all of them. One traced start each: - without this change: stops 8.1 s in with `sceVideoOutConfigureOutputMode_ not implemented`, before the first frame; - with it (an earlier form of the same condition, written with `std::all_of`): gets past the call, so its record was all 0xff; presents its first frame and stops 26.7 s in on an AGC driver error, a separate gap. The image descriptor of compute shader `0x2f2fa2500` (format 22) matches none of the image modes of its static interface. - **`python tools/check_conventions.py --base origin/main`** with this title and description: all checks passed. - **`python tools/pr_overlap.py --branch`:** no overlap with open pull requests; the two that share files or exports with this branch merge cleanly with it. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: CUSA00223 #8214 <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver 621.14, Windows 10 22H2 <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> AI-assisted: Claude Code found the title's call sites in its executable, wrote the change and its test, ran the tests and the inFAMOUS starts, and drafted this description; separate review agents checked it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!22517
No description provided.