Skip to content

fix(videoout): read the open param as the service thread's priority and affinity - #297

Merged
boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:fix/videoout-open-param-service-thread
Oct 3, 2026
Merged

boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:fix/videoout-open-param-service-thread

Conversation

@oneandonlydean

@oneandonlydean oneandonlydean commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What

Follow-up to #128, which guessed wrong on two points. The first word of the sceVideoOutOpen param is not its size, and PPSA21564 does not pass a zeroed param. Its main port is opened with:

Offset Value Meaning
+0 16 unknown
+4 1 set priority
+8 0x100 priority
+12 1 set affinity
+16 0x1FFF (u64) CPU affinity mask
+24..+88 0 unknown

It also calls sceVideoOutOpen(0xff, 0, 0, NULL) once. On main the open with this param throws param options not implemented, so PPSA21564 cannot open its video port and fails at startup.

The layout matches shadPS4's ServiceThreadParams (src/core/libraries/videoout/driver.h: unknown, set_priority, priority, set_affinity, affinity), i.e. the scheduling settings of libSceVideoOut's service thread. The call site in PPSA21564 agrees: it zeroes the stack block, stores the first 16 bytes from a constant (16, 1, 0x100, 1) and then movq $0x1fff at offset 16 before the call. 256..767 is the thread priority range (256 highest), and 0x1FFF covers the 13 CPUs available to a title.

Changes:

  • VideoOutOpenParam describes the five fields; VIDEO_OUT_OPEN_PARAM_SIZE becomes VIDEO_OUT_OPEN_PARAM_FIRST_WORD.
  • validateOpenParam throws for a first word other than 16, a flag other than 0 or 1, a priority outside 256..767 when its flag is set, and an affinity mask that is 0 or has bits outside 0x1FFF when its flag is set. It reads the u64 at offset 16 only when the affinity flag is set, so a 16-byte param with both flags clear is still read in bounds.
  • TechnicalDebt: the priority and affinity are validated but not applied (the port's present and vblank threads are host threads), listed under silent stubs. The first word and whether the param continues past offset 24 are listed under unknown function info.

Tested

  • Linux (CachyOS, GCC). video_out_flip_tests controls (not part of ctest) gains testOpenParam: eight invalid params throw (first word 24, a priority flag of 2, an affinity flag of 0x101, priority 255 and 768, affinity 0, 0x2000 and a bit above 32), and a 16-byte param with both flags clear, a priority of 767 and an affinity of 1 open a port. The controls themselves now run on a port opened with PPSA21564's exact 88-byte param. On main the test fails at the first valid param (param options not implemented).
  • ctest: 105/105 pass.
  • PPSA21564 on my integration branch: with this change it starts, and my visual regression check (from the intro video through the title and save menu into gameplay; checkpoint frames, flicker, video tearing and FPS) passes twice in a row.

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
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 1, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 2, 2026
…nd affinity

and throws for any non-zero word after it. Its layout matches shadPS4's
ServiceThreadParams instead: an unknown first word (16), a set-priority flag
and a priority (256..767), a set-affinity flag and a 64-bit CPU mask at
offset 16. PPSA21564 passes 16, 1, 0x100, 1 and 0x1FFF, so it stops at
startup on main.

sceVideoOutOpen now validates each field and reads the mask only when its
flag is set, so a 16-byte param with both flags clear still works. The
priority and affinity are not applied, since the present and vblank threads
are host threads; this and the unknown first word are listed in the
technical debt.
@oneandonlydean
oneandonlydean force-pushed the fix/videoout-open-param-service-thread branch from 712ac9c to 151fec7 Compare October 2, 2026 08:12
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 2, 2026
@boykopovar
boykopovar merged commit 29a8d01 into boykopovar:main Oct 3, 2026
3 checks passed
@oneandonlydean
oneandonlydean deleted the fix/videoout-open-param-service-thread branch October 3, 2026 07:02
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 3, 2026
…oykopovar#304 boykopovar#305 boykopovar#306 boykopovar#322 boykopovar#409 boykopovar#416, boykopovar#276 boykopovar#277 boykopovar#275 boykopovar#307, shader ops boykopovar#226 boykopovar#255 boykopovar#260 boykopovar#280 boykopovar#308 boykopovar#309 boykopovar#311 boykopovar#318 boykopovar#320 boykopovar#324 boykopovar#326 boykopovar#379 boykopovar#384 boykopovar#399, boykopovar#261, kernel boykopovar#335 boykopovar#341 boykopovar#349 boykopovar#355, libs boykopovar#227 boykopovar#244 boykopovar#245 boykopovar#273 boykopovar#274 boykopovar#279 boykopovar#286 boykopovar#287 boykopovar#289 boykopovar#296 boykopovar#300 boykopovar#328 boykopovar#358 boykopovar#402) into astrobot

Where our PR merged in a revised form, main's version is taken; where
astrobot carries the same work plus later local commits, astrobot's code
stays and main's additions appear once.

Conflicts:
- AvPlayer (Export.cpp both libs, include/AvPlayer.hpp, src/Player.cpp,
  src/Source.cpp, AvPlayerLibrary.cmake, CMakeLists.txt, SceTypes.hpp,
  tests/GuestAvPlayer.cpp): main's boykopovar#307 (our reviewed squash, which carries
  9c8e7fd e9ea5c8 adcede3 fb4eeb9 953057c ac456ee). It links the
  shared ffmpeg-core target, so astrobot's second FFmpeg build goes:
  3rdparty/FFmpeg submodule, core/libs/FFmpeg.cmake and src/Exports.cpp.
- libScePngEnc: main's boykopovar#227 (supersedes OverkillLabs' encoder).
- libScePad Export.cpp: main's boykopovar#287 tilt correction (supersedes 49d45f5).
- libSceAudioPropagation Export.cpp: astrobot's object model, which
  defines every function boykopovar#289 declares as a stub.
- libSceSaveData.native Export.cpp: both (SaveDataHoldWrites and boykopovar#289's
  unknown exports).
- VideoOutDriver.cpp: astrobot's (2546bd1 counters around boykopovar#416's
  lastFlipVblank store, same value). tests/Flip.cpp: boykopovar#416's pacing test and
  boykopovar#417's after-GPU test both kept.
- boykopovar#278 files (DisplayFormat, VulkanDevice, GpuColorTransfer,
  ResidentPresent, agc CMakeLists): main's comment-free boykopovar#278 plus
  astrobot's P5 present-direct (b29728d), which removed DetileImage,
  ResidentPresent.hpp and the recorder-test hook; the resident present test
  stays its own executable.
- VulkanDevice.cpp/.hpp: astrobot's GDS, local memory probe, sample dumps
  and P5 code; boykopovar#303/boykopovar#409 comments as main has them; main's shader clock
  (boykopovar#324) and DepthSurface-free includes.
- RequestSerializer.cpp: version stays 8 (6 mesh passthrough, 7
  nonConstantImageOffsets, 8 astrobot's later field). boykopovar#303's auto-merged
  second write and read of nonConstantImageOffsets removed.
- SpirvEmitter.hpp, SpirvEmitterState.hpp, Recompiler.hpp/.cpp, StageIO.hpp,
  SpirvOptimizer.cpp, InstructionTranslator.cpp, ShaderReplay.cpp: local
  fields kept, boykopovar#303/boykopovar#305 comments as main has them.
- SpirvAluEmitterMath.cpp: v_readlane keeps the split-wave path and takes
  boykopovar#322's wrap at the wave size for the others.
- SpirvEmitter.cpp: astrobot's single-lane layout check.
- SpirvFlowEmitter.cpp: boykopovar#304 as merged (the second lane emits a shared
  value itself when the first lane defined nothing).
- SpirvImageEmitter.cpp: main's Offset operand placed before MinLod.
- boykopovar#304: main's WaveUniformValues (SpirvAnalysis.cpp) replaces astrobot's
  copy in SpirvWaveExchange.cpp.
- Recorder.hpp/.cpp, Draw.hpp, Graphics Draw.cpp, ShaderResources.cpp:
  astrobot's boykopovar#276/boykopovar#277 with its later snapshot work (per-use budgets,
  stale-snapshot refresh, profile counters, boykopovar#410, boykopovar#424, fan GS); boykopovar#409/boykopovar#306
  comments as main has them.
- PacketMemory.cpp: boykopovar#409 as merged plus astrobot's two opt-outs.
- tests: ShaderMemory.cpp takes boykopovar#303's and boykopovar#304's new tests; Recorder.cpp
  takes boykopovar#409's afterRecordedWorkTests and drops main's copies of the
  boykopovar#276/boykopovar#277 tests astrobot already has; Structurizer.cpp keeps boykopovar#413's case.

boykopovar#143 (NGG passthrough) stays as on astrobot: upstream did not touch its
files since the boykopovar#258 revert.
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.

2 participants