Skip to content

fix(libSceVideoOut): refuse the output status with VRR for a handle without buffers - #17812

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
xXPBSXx:k/videoout-withvrr-fresh
Nov 15, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
xXPBSXx:k/videoout-withvrr-fresh

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

What

sceVideoOutGetOutputStatusWithVrr filled the 80-byte status for a handle that has no buffer registered. A PS5 returns 0x8029001C and writes nothing for it. It now does the same, with the check sceVideoOutClearFlipMaster already uses. The tests pin the refusal on a fresh handle and that the call succeeds once a buffer is registered. The debt entry for sceVideoOutGetOutputStatusWithVrr (docs/dev/debt/libSceVideoOut.md) said the console's 0x8029001C check "tests states that are not modelled and are never reported"; the entry now states the measured result for a fresh handle and keeps the 0x8029001B object-field check as not modelled. Titles are not affected as far as measured: the title measurement (firmware 13.40) called it after its buffers were registered; no title is known to call it on a fresh handle.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-09 at 08:24 UTC; the console's own clock read about 1 h 41 min more (see the first comment). A title process may differ.

call on a handle from sceVideoOutOpen(0xff, 0, 0, NULL) with no buffer registered PS5, payload process, firmware 11.60 main before here now
sceVideoOutGetOutputStatusWithVrr(handle, &status) return 0x8029001C 0 0x8029001C
bytes of status written 0 80 0

On Windows 10 Pro with MinGW GCC (WinLibs), a Release build, ANYPS5_REQUIRE_VULKAN=1 and a shader cache off, on main 67092e70b5 the test commit alone fails video_out_flip_resolution_override, guest_video_out_resolution_status and guest_video_out_hdr (3 of 3), and with the fix commit on the same main all three pass. tools/check_conventions.py --base upstream/main passes. The runs used no Vulkan validation layer, because the added check returns before any Vulkan call.

Overlap: the 24 other open pull requests that change docs/dev/debt/libSceVideoOut.md, Output.cpp, Flip.cpp, GuestVideoOutHdr.cpp or GuestVideoOutResolutionStatus.cpp (listed by update time) were checked on 2026-11-09 between 16:30 UTC and 16:38 UTC against main f6ed718e10. Four already conflict with main without this change (#4040 and #14212 in the debt file, #12315 and #5021 in other files). #16463 (a documentation sync of 39 files, a different author) conflicts in GuestVideoOutHdr.cpp only with this change, because both touch that test file; whichever merges second needs a small rebase. The other nineteen merge cleanly with and without it, among them #17696, #17763, #16584 and #14106, which edit other entries of the debt file.

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 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: NVIDIA GeForce RTX 4080 SUPER, Windows driver version 32.0.16.1074, Windows 10 Pro
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

xXPBSXx and others added 3 commits November 9, 2026 11:57
…RR of a handle without buffers

On a PS5 (firmware 11.60, payload process) sceVideoOutGetOutputStatusWithVrr
on a handle that was just opened, with no buffer registered, returns
0x8029001c and writes nothing. The tests that read the status register a
buffer first.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ithout buffers

sceVideoOutGetOutputStatusWithVrr returns 0x8029001c and writes nothing for
a handle that has never had buffers registered, as sceVideoOutClearFlipMaster
already does and as a PS5 does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…handle without buffers

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Probe source (built with ps5-payload-sdk v0.45; PROBE_BUILD is the first 12 hex digits of the source's SHA-256, here 388c1dceb5a2) and its raw output. The clock in the PROBE line is the console's own clock, which was about 1 h 41 min ahead of the host clock (run at 08:24 UTC on 2026-11-09). The status buffer is a 128-byte buffer filled with 0x5a; changed=0 means no byte was written.

sceVideoOutGetOutputStatusWithVrr probe.c (run at 08:24 UTC)
/* Probe E: sceVideoOutGetOutputStatusWithVrr, sceVideoOutIsOutputSupported, sceVideoOutGetResolutionStatus and the
   Delete*Event calls on a port that is not open, payload process, firmware 11.60 (debt libSceVideoOut.md:20, :27,
   :28 and :18: what a payload process on a PS5 returns is not measured). It follows the earlier payload run that
   opened the main bus: sceVideoOutOpen(0xff, 0, 0, NULL), only reads, and sceVideoOutClose on the probe's own
   handle. No buffer is registered, no flip, mode or flip rate is changed, no event is added. The status buffers
   are 128-byte marker buffers; only the return code, the number of changed bytes and a few numeric fields (the
   resolution and dynamic range words, the refresh rate, the three 16-bit values at bytes 48, 50 and 52, and the
   words of the resolution status) are printed. The Delete*Event cases use an equeue created by the probe and the
   closed handle of the probe's own port. Nothing is written, nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h>   /* only for kernel_get_fw_version() */

#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
   itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif

static void probe_alarm(int sig) {
  static const char msg[] = "TIMEOUT\tprobe self limit\n";
  (void)sig;
  (void)!write(1, msg, sizeof msg - 1);
  _exit(124);
}

/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
   thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
   as a second safeguard. */
static void* probe_watchdog(void* arg) {
  static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
  unsigned left = PROBE_MAX_S;
  (void)arg;
  while (left) left = sleep(left);
  (void)!write(1, msg, sizeof msg - 1);
  _exit(124);
  return 0;
}

static void probe_watchdog_start(void) {
  pthread_t t;
  if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}

static int cases = 0;

static void probe_header(void) {
  char utc[32];
  time_t now = time(0);
  probe_watchdog_start();
  struct tm tmv;
  gmtime_r(&now, &tmv);
  strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
  printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
         getpid(), utc);
  fflush(stdout);
}

static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
  printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
  fflush(stdout);
  cases++;
}

static void probe_end(void) {
  printf("END\t%d\n", cases);
  fflush(stdout);
}








typedef int (*fn_open)(int, int, int, const void*);
typedef int (*fn_close)(int);
typedef int (*fn_status)(int, void*);
typedef int (*fn_supported)(int, unsigned long, const void*, void*, unsigned long);
typedef int (*fn_delete)(void*, int);
typedef int (*fn_ceq)(void**, const char*);
typedef int (*fn_deq)(void*);

#define BUF 128

static void rc_case(const char* id, const char* call, long r, int e) {
  char extra[32];
  snprintf(extra, sizeof extra, "0x%08x", (unsigned)r);
  probe_case(id, call, r, e, extra);
}

int main(void) {
  signal(SIGALRM, probe_alarm);
  alarm(PROBE_MAX_S);
  probe_header();

  errno = 0;
  void* vo = dlopen("libSceVideoOut.sprx", RTLD_LAZY);
  probe_case("0", "load libSceVideoOut.sprx", vo ? 0 : -1, errno, vo ? "loaded" : dlerror());
  if (!vo) { probe_end(); return 0; }
  fn_open open_ = (fn_open)dlsym(vo, "sceVideoOutOpen");
  fn_close close_ = (fn_close)dlsym(vo, "sceVideoOutClose");
  fn_status withVrr = (fn_status)dlsym(vo, "sceVideoOutGetOutputStatusWithVrr");
  fn_supported supported = (fn_supported)dlsym(vo, "sceVideoOutIsOutputSupported");
  fn_status resolution = (fn_status)dlsym(vo, "sceVideoOutGetResolutionStatus");
  fn_delete delFlip = (fn_delete)dlsym(vo, "sceVideoOutDeleteFlipEvent");
  fn_delete delVblank = (fn_delete)dlsym(vo, "sceVideoOutDeleteVblankEvent");
  fn_delete delPre = (fn_delete)dlsym(vo, "sceVideoOutDeletePreVblankStartEvent");
  fn_delete delMode = (fn_delete)dlsym(vo, "sceVideoOutDeleteOutputModeEvent");
  fn_delete delVrr = (fn_delete)dlsym(vo, "sceVideoOutDeleteVrrActiveStatusEvent");
  fn_ceq ceq = (fn_ceq)dlsym(RTLD_DEFAULT, "sceKernelCreateEqueue");
  fn_deq deq = (fn_deq)dlsym(RTLD_DEFAULT, "sceKernelDeleteEqueue");
  char extra[160];
  snprintf(extra, sizeof extra, "open=%d close=%d vrr=%d supported=%d resolution=%d delete=%d%d%d%d%d equeue=%d%d",
           open_ != 0, close_ != 0, withVrr != 0, supported != 0, resolution != 0, delFlip != 0, delVblank != 0,
           delPre != 0, delMode != 0, delVrr != 0, ceq != 0, deq != 0);
  probe_case("0b", "dlsym of the VideoOut and equeue functions", 0, 0, extra);
  if (!open_ || !close_ || !withVrr || !supported || !resolution) { probe_end(); return 0; }

  errno = 0;
  long h = open_(0xff, 0, 0, 0);
  rc_case("1", "sceVideoOutOpen(0xff, 0, 0, NULL)", h, errno);
  if (h < 0) { probe_end(); return 0; }

  static unsigned char buf[BUF];
  int changed, last;

  memset(buf, 0x5a, sizeof buf);
  errno = 0;
  long r = withVrr((int)h, buf);
  int e = errno;
  changed = 0; last = -1;
  for (int b = 0; b < BUF; ++b) if (buf[b] != 0x5a) { changed++; last = b; }
  unsigned short w48, w50, w52;
  unsigned res, dyn;
  unsigned long refresh;
  memcpy(&res, buf, 4); memcpy(&dyn, buf + 4, 4); memcpy(&refresh, buf + 8, 8);
  memcpy(&w48, buf + 48, 2); memcpy(&w50, buf + 50, 2); memcpy(&w52, buf + 52, 2);
  snprintf(extra, sizeof extra, "0x%08x changed=%d last_offset=%d resolution=0x%x dynamic_range=0x%x refresh=0x%lx u16_48=%u u16_50=%u u16_52=%u",
           (unsigned)r, changed, last, res, dyn, refresh, w48, w50, w52);
  probe_case("2", "sceVideoOutGetOutputStatusWithVrr(handle, &status)", r, e, extra);

  static const unsigned long modes[] = {1, 15};
  static unsigned char options[64];
  for (int m = 0; m < 2; ++m) {
    char id[16], call[96];
    memset(options, 0, sizeof options);
    errno = 0;
    r = supported((int)h, modes[m], options, 0, 0);
    snprintf(id, sizeof id, "3.%d", m + 1);
    snprintf(call, sizeof call, "sceVideoOutIsOutputSupported(handle, mode %lu, zero options, NULL, 0)", modes[m]);
    rc_case(id, call, r, errno);
  }

  memset(buf, 0x5a, sizeof buf);
  errno = 0;
  r = resolution((int)h, buf);
  e = errno;
  changed = 0; last = -1;
  for (int b = 0; b < BUF; ++b) if (buf[b] != 0x5a) { changed++; last = b; }
  unsigned fw, fh, pw, ph, flagsw, size_bits;
  unsigned long rr;
  float inch;
  memcpy(&fw, buf, 4); memcpy(&fh, buf + 4, 4); memcpy(&pw, buf + 8, 4); memcpy(&ph, buf + 12, 4);
  memcpy(&rr, buf + 16, 8); memcpy(&inch, buf + 24, 4); memcpy(&size_bits, buf + 24, 4); memcpy(&flagsw, buf + 28, 4);
  snprintf(extra, sizeof extra, "0x%08x changed=%d last_offset=%d full=%ux%u pane=%ux%u refresh=0x%lx screen_size_bits=0x%08x word7=0x%08x",
           (unsigned)r, changed, last, fw, fh, pw, ph, rr, size_bits, flagsw);
  probe_case("4", "sceVideoOutGetResolutionStatus(handle, &status)", r, e, extra);

  errno = 0;
  long c = close_((int)h);
  rc_case("5", "sceVideoOutClose(own handle)", c, errno);

  if (ceq && deq && delFlip && delVblank && delPre && delMode && delVrr) {
    void* eq = 0;
    errno = 0;
    long q = ceq(&eq, "probe_e");
    rc_case("6", "sceKernelCreateEqueue(&eq, name)", q, errno);
    if (q == 0 && eq) {
      errno = 0; r = delFlip(eq, (int)h);   rc_case("7.1", "sceVideoOutDeleteFlipEvent(eq, closed handle)", r, errno);
      errno = 0; r = delVblank(eq, (int)h); rc_case("7.2", "sceVideoOutDeleteVblankEvent(eq, closed handle)", r, errno);
      errno = 0; r = delPre(eq, (int)h);    rc_case("7.3", "sceVideoOutDeletePreVblankStartEvent(eq, closed handle)", r, errno);
      errno = 0; r = delMode(eq, (int)h);   rc_case("7.4", "sceVideoOutDeleteOutputModeEvent(eq, closed handle)", r, errno);
      errno = 0; r = delVrr(eq, (int)h);    rc_case("7.5", "sceVideoOutDeleteVrrActiveStatusEvent(eq, closed handle)", r, errno);
      errno = 0; r = deq(eq);               rc_case("8", "sceKernelDeleteEqueue(eq)", r, errno);
    }
  } else {
    probe_case("6", "Delete*Event cases", -1, 0, "skipped: symbol missing");
  }

  probe_end();
  return 0;
}
raw output (run at 08:24 UTC)
PROBE	sceVideoOutGetOutputStatusWithVrr	fw=0x11600005	build=388c1dceb5a2	pid=109	utc=2026-11-09T10:05:38Z
CASE	0	load libSceVideoOut.sprx	0	3	loaded
CASE	0b	dlsym of the VideoOut and equeue functions	0	0	open=1 close=1 vrr=1 supported=1 resolution=1 delete=11111 equeue=11
CASE	1	sceVideoOutOpen(0xff, 0, 0, NULL)	1309671680	3	0x4e100100
CASE	2	sceVideoOutGetOutputStatusWithVrr(handle, &status)	-2144796644	0	0x8029001c changed=0 last_offset=-1 resolution=0x5a5a5a5a dynamic_range=0x5a5a5a5a refresh=0x5a5a5a5a5a5a5a5a u16_48=23130 u16_50=23130 u16_52=23130
CASE	3.1	sceVideoOutIsOutputSupported(handle, mode 1, zero options, NULL, 0)	-2144796671	0	0x80290001
CASE	3.2	sceVideoOutIsOutputSupported(handle, mode 15, zero options, NULL, 0)	-2144796671	0	0x80290001
CASE	4	sceVideoOutGetResolutionStatus(handle, &status)	0	0	0x00000000 changed=48 last_offset=47 full=3840x2160 pane=3840x2160 refresh=0x3 screen_size_bits=0x42700000 word7=0x00000000
CASE	5	sceVideoOutClose(own handle)	0	0	0x00000000
CASE	6	sceKernelCreateEqueue(&eq, name)	0	0	0x00000000
CASE	7.1	sceVideoOutDeleteFlipEvent(eq, closed handle)	-2144796661	0	0x8029000b
CASE	7.2	sceVideoOutDeleteVblankEvent(eq, closed handle)	-2144796661	0	0x8029000b
CASE	7.3	sceVideoOutDeletePreVblankStartEvent(eq, closed handle)	-2144796661	0	0x8029000b
CASE	7.4	sceVideoOutDeleteOutputModeEvent(eq, closed handle)	-2144796661	0	0x8029000b
CASE	7.5	sceVideoOutDeleteVrrActiveStatusEvent(eq, closed handle)	-2144796661	0	0x8029000b
CASE	8	sceKernelDeleteEqueue(eq)	0	0	0x00000000
END	15

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@milescoviello milescoviello left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read cee35fd34c against main.

  • The check: isFreshHandle (Output.cpp:304) is !cfg->buffersEverRegistered under the config mutex, the same test sceVideoOutClearFlipMaster uses (:321) for the same 0x8029001C. It takes and releases the lock before sceVideoOutGetOutputStatusWithVrr takes it again, so there's no nested locking.
  • Order: the null-status (INVALID_ADDRESS) and handle checks still come first. A fresh handle returns before the status is filled, which gives the measured "0 bytes written".
  • Scope: a handle that registered buffers and then unregistered them still reports, because buffersEverRegistered stays set. That case wasn't in the measurement, so keeping main's answer for it is right.
  • Tests: the existing tests that read the VRR status now register a buffer first, and each first pins the measured refusal on the fresh handle.

AI-assisted: yes (Claude Code)

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4040 core/libs/prx/libSceVideoOut/src/Output.cpp
docs/dev/debt/libSceVideoOut.md
PR 14106 core/libs/prx/libSceVideoOut/src/Output.cpp
core/libs/tests/GuestVideoOutResolutionStatus.cpp
docs/dev/debt/libSceVideoOut.md
PR 17259 docs/dev/debt/libSceVideoOut.md
PR 20315 core/libs/prx/libSceVideoOut/tests/Flip.cpp

@oneandonlydean
oneandonlydean merged commit 790e9a3 into boykopovar:main Nov 15, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants