Skip to content

fix(pad): timestamp fresh controller samples when read - #6337

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
JJenkx:fix/pad-read-timestamps-upstream
Nov 8, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
JJenkx:fix/pad-read-timestamps-upstream

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Fresh scePadReadState samples and the empty-queue fallback of scePadRead reuse the timestamp of the last input change. Holding a button or stick therefore returns a frozen timestamp across later reads. Stamp these newly generated samples with the current process time; queued samples retain their capture timestamps and order.

Two production lines change. The regression checks advancing timestamps with unchanged buttons/sticks in both paths and verifies that draining the queued sample retains its earlier capture time. Existing latched presses, trigger values and latch reset are preserved. The refresh retains merged #8138 touchpad resolution changes and its controller regressions, including both <cstdio> and <cstring> in the fixture and both functional debt entries. This does not implement hardware sampling cadence or idle sample batching; those limits remain in the library debt file.

Based on main 2dc85609fc1f70965ca88829560a73ad3c363493, head 8e30de03174899b4aa104cdf52c44bf12bdb9b98, with two linear topic commits and no merge commits. Current main has per-controller slots: the two fresh-sample calls now use now in BuildData(slot, slot.state, now, now, injected, port). Resolution preserves all current-main slot discovery, initialization, latched input and queued/scripted-overlay timestamp handling. The existing regression and main's added controller cases are retained. No new Windows run is claimed.

Open overlap review (2026-10-22): #7881 rewrites both paths for per-port state. Either merge order must keep current-time timestamps for fresh samples and capture-time timestamps for queued entries. Author coordination. The #7881 author reports a local combination passing all 15 pad/user-service tests, including CheckHeldSampleTimes; I have not independently repeated that combined run. #9878 adds disconnected special-port handling and does not change either timestamp site in PadState.cpp. Its CheckSpecialPort test and this PR's CheckHeldSampleTimes are inserted at the same position in GuestPad.cpp; a three-way fixture merge at heads bdd7a52c and 7678df54 conflicts there. Resolve by retaining both function definitions and both calls; neither replaces the other. This is a static overlap review, not a combined build/runtime result. Neither PR is a code dependency. #9770, which included the same ReadState correction, was closed without merging as an accidental fork sync; its implementation is not a dependency.

Tested

Current Linux x86-64 Release validation on 8e30de03174899b4aa104cdf52c44bf12bdb9b98: fresh build of libScePad, guest_pad_tests and guest_pad_vibration_mode_tests; both focused groups pass. With only the two production timestamp edits reverted, guest_pad fails with the expected stale-held-input diagnostic while vibration-mode checks pass. Restoring the exact clean head and rebuilding gives 2/2 passes on three consecutive runs. Conventions against current main and origin/main and whitespace checks pass. Logs, patch and negative-control receipt (SHA-256 8218028ba0e3951182f4a5a475fd714fb0708558e7c70576fdaf186773720009). No new Windows, title, GPU or FPS result is claimed.

Historical Windows 11, GCC 15.2 (UCRT), Release evidence on previous head bbd9164413ae23a90bac2ad2eb90d26cb8d3f693 / main 938812df1403f9616dba71744216725891ca4979:

  • Built guest_pad_tests and guest_pad_vibration_mode_tests in a fresh build directory; ctest -R '^guest_pad(_vibration_mode)?$' three times: 2/2 pass each run, 0 not run, no skips.
  • Negative control: the same tree with only core/libs/prx/libScePad/src/PadState.cpp restored from main, built in a separate fresh directory: guest_pad fails with scePadReadState returned a stale timestamp for held input (abort).
  • python tools/check_conventions.py --base 938812df14 --head HEAD: passed.

Earlier Linux results on base a6646f8464, kept for history:

Linux x86-64, GCC 16.2.1, Ryzen 9 7950X, previous head bdd7a52c1b:

  • Configured a fresh Release build and built guest_pad_tests.
  • SDL_VIDEODRIVER=dummy ctest --test-dir build -R '^guest_pad$' -V --timeout 60 --repeat until-fail:3: all three runs pass, no skips. The fixture covers held-input timestamps, captured queue timestamps and the existing touchpad/latch regressions.
  • Negative control: replaced only PadState.cpp with the base revision, rebuilt, and reran the fixture. It failed at scePadReadState returned a stale timestamp for held input. Restoring the candidate source, rebuilding and rerunning passed. Source is clean and still at the tested head.
  • python3 tools/check_conventions.py --base a6646f8464140180351e4c08694dccdd55b2814d and git diff --check: passed during the linear rebase review.

Earlier revisions had broader controller/library checks and independent negative controls for both production lines; those are historical evidence, not tests of this refreshed head. No native game, Windows runtime, full runtime suite, GPU or performance result is claimed for this head.

Pinned validation logs and negative control, SHA-256 264ef40273a4e022f4409e01b6c8c9e02106e6c3896c924b43fedb988ce25686.

The touch-ID ordering agreement in the review remains applicable if #6485 is reopened or resubmitted: merge its prerequisite and touch-ID change first, then retain both captured touch IDs and now for fresh samples. That closed PR is not a current code dependency; queued samples retain their captured IDs and times.

Supplemental qualification (2026-11-01)

Merged main 93dbd0f82aea into the branch, preserving the original history. New head: ee1696711b51fce4473a501c3524a53c29cb7d70.

Resolved PadState.cpp by keeping main's withdrawn-port decision and WithdrawnData(slot.timestamp) path; only fresh non-withdrawn BuildData calls use now for the sample timestamp. Queued samples retain their capture timestamps. Main's injected-title-input handling and the combined fixture, including CheckSpecialPort and CheckHeldSampleTimes, remain.

Linux Release exact-head guest_pad and guest_pad_vibration_mode pass three times each. A production-only negative replacing PadState.cpp with current main fails guest_pad with “scePadReadState returned a stale timestamp for held input”. Restoring the candidate rebuilds and both focused groups pass. Conventions and whitespace checks pass; submodule pins match main. No new Windows or title execution is claimed; previous Windows/title reports remain historical.

Evidence: frozen source and qualification receipts (SHA-256 e40b9e4b51b918651e5061b7ca78903741cf1886e27a6def8ec6565b8fb7acd2, downloaded bytes and internal manifest verified).
AI-assisted: yes.

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: n/a; controller CPU tests
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 15, 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 5038 docs/dev/debt/libScePad.md
PR 8260 core/libs/tests/GuestPad.cpp
docs/dev/debt/libScePad.md
PR 12310 docs/dev/debt/libScePad.md
PR 12311 docs/dev/debt/libScePad.md
PR 12312 docs/dev/debt/libScePad.md
PR 14124 core/libs/tests/GuestPad.cpp
docs/dev/debt/libScePad.md
PR 14212 docs/dev/debt/libScePad.md
PR 14634 core/libs/tests/GuestPad.cpp
PR 15895 core/libs/tests/GuestPad.cpp
PR 15905 core/libs/tests/GuestPad.cpp
PR 16289 core/libs/tests/GuestPad.cpp

@Ondra97

Ondra97 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

I opened #6485 for a separate touch-contact identity bug. The changes meet at the two fresh-sample BuildData calls.

I propose #6485 first, after its shared Windows build prerequisite #6452, then rebasing this timestamp change while retaining both now for fresh sample timestamps and the captured touchIds. Queued samples keep their capture timestamp and IDs.

I manually composed this PR at 279fee87a077f413daa950deb73c2940232f0a3b with the contact-ID sources from 68c8a853 on main 92e50418. Those two Pad source blobs are unchanged in the published #6485 head. On Ubuntu24.04.5/GCC13.3, all four input tests passed; the timestamp regression failed when its two-line timestamp correction was omitted. Restoring the standalone contact-ID sources passed four tests again. This is Linux CPU composition evidence, not a combined Windows, GPU or game result.

Would this integration order work for you?

AI-assisted: yes (Codex).

@JJenkx

JJenkx commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

I agree with the proposed order if the touch-ID change is reopened or resubmitted: #6452, then the touch-contact fix, then #6337 rebased to preserve both the captured touch IDs and now for fresh-sample timestamps. Queued samples must retain their captured IDs and times. I see #6485 is currently closed without merging, so I will not treat its code as present on main. The latest #6337 validation remains independent of that change.

Your four-test Linux composition result is useful evidence; I have not independently repeated that touch-ID combination or claimed a combined Windows result.

@JJenkx

JJenkx commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Temporarily closing to stay within the 20-open-PR author cap while submitting a verified Cocoon startup fix. This timestamp work is preserved at 279fee8 on JJenkx/AnyPS5 branch fix/pad-read-timestamps-upstream; it is not withdrawn on technical grounds. The ordering notes already in the description remain applicable when a slot is available.

@JJenkx JJenkx closed this Oct 16, 2026
@JJenkx JJenkx reopened this Oct 19, 2026
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@JJenkx
JJenkx force-pushed the fix/pad-read-timestamps-upstream branch from 279fee8 to 05878ce Compare October 19, 2026 02:24
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 19, 2026
@JJenkx
JJenkx force-pushed the fix/pad-read-timestamps-upstream branch from 05878ce to 90b204c Compare October 19, 2026 16:29
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@JJenkx
JJenkx force-pushed the fix/pad-read-timestamps-upstream branch from 90b204c to 554b813 Compare October 19, 2026 20:57
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@JJenkx
JJenkx force-pushed the fix/pad-read-timestamps-upstream branch from 554b813 to 3ca580f Compare October 20, 2026 17:28
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@JJenkx
JJenkx force-pushed the fix/pad-read-timestamps-upstream branch from 3ca580f to bb56f95 Compare October 20, 2026 17:30
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@JJenkx
JJenkx force-pushed the fix/pad-read-timestamps-upstream branch from bbd9164 to 8e30de0 Compare October 24, 2026 20:09
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 24, 2026
Current state and an empty-queue read reused the last input-change timestamp while reporting a fresh sample. Timestamp those samples at the read, preserving capture timestamps of queued input. Add a held-state regression covering both APIs and queued chronology. Full integration build, guest_pad and patched_libraries pass; the new regression fails before the change. Sample-time meaning follows device-tested PS5 input research bda3543a; host sampling cadence is still approximate and documented.
@JJenkx
JJenkx force-pushed the fix/pad-read-timestamps-upstream branch from 8e30de0 to 92f795b Compare October 26, 2026 12:27
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 26, 2026
@fogydes

fogydes commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

OK

1. Freshness Envelope

  • Head SHA: 92f795b3420f7e82088af97decba5796167e566d
  • Merge-base SHA: 2db37cf1de46fd7b133fc5d0be1e395340f0fd2c
  • Behind origin/main: 4,489 commits
  • Merge-tree status: exit code 0 (clean merge against origin/main, tree SHA 91227e988fffd4f8d73b338b53c95e19ee19c984)

2. Findings

  1. [verified] Clean merge tree with origin/main: git merge-tree --write-tree origin/main 92f795b3420f7e82088af97decba5796167e566d exits with code 0 (no conflicts).
  2. [verified] Conventions clean against merge-base: python tools/check_conventions.py --base 2db37cf1de46fd7b133fc5d0be1e395340f0fd2c in an isolated scratch worktree reported 0 findings.
  3. [read-only] Full template checklist compliance: PR description adheres to .github/pull_request_template.md with all checklist lines populated (Fixes: none, Unblocks: none, GPUs tested: n/a; controller CPU tests).
  4. [author-reported] Reported Linux x86-64 and historical Windows 11 / GCC 15.2 test verification with negative control diagnostics on reverting timestamp generation.

3. Cross-PR Ledger

@MarcZX10 MarcZX10 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.

Re-checked — new head, looks good

I reviewed head 92f795b3420f7e82088af97decba5796167e566d; its only commit since the previously tested 8e30de03174899b4aa104cdf52c44bf12bdb9b98 changes the two regression failure messages, while the timestamp implementation and assertions are unchanged. The author-reported focused Linux tests and negative control are for 8e30de0, not this exact head; the the latest reported merge preview against current main (f7f03daf52f11191174b1be089a56e268390a707) and conventions check are clean, and I did not independently build or run CTest. No blocking issue is visible in this diagnostic-only update.

@JJenkx

JJenkx commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged main 93dbd0f82aea into the branch, preserving the original history. New head: ee1696711b51fce4473a501c3524a53c29cb7d70.

Resolved PadState.cpp by keeping main's withdrawn-port decision and WithdrawnData(slot.timestamp) path; only fresh non-withdrawn BuildData calls use now for the sample timestamp. Queued samples retain their capture timestamps. Main's injected-title-input handling and the combined fixture, including CheckSpecialPort and CheckHeldSampleTimes, remain.

Linux Release exact-head guest_pad and guest_pad_vibration_mode pass three times each. A production-only negative replacing PadState.cpp with current main fails guest_pad with “scePadReadState returned a stale timestamp for held input”. Restoring the candidate rebuilds and both focused groups pass. Conventions and whitespace checks pass; submodule pins match main. No new Windows or title execution is claimed; previous Windows/title reports remain historical.

Evidence: frozen source and qualification receipts (SHA-256 e40b9e4b51b918651e5061b7ca78903741cf1886e27a6def8ec6565b8fb7acd2, downloaded bytes and internal manifest verified).
AI-assisted: yes.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 2, 2026
@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 4, 2026
@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head ee16967 merged onto main 4639eff · tested 2026-11-05 07:55 UTC · 19 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 1,226 passed · 5 failed (0 new, 4 also fail on main, 1 unstable on main) · 9 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 1,240 of 3,962 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (570 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.4 s, ⚠️ agc_driver_image_sample_unnormalized 55.0 s, ⚠️ agc_driver_lazy_resolved_abi 53.6 s, ⚠️ public_headers 52.4 s, ⚠️ agc_driver_sample_multisample_target 52.3 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 9 of the last 10 main runs
Failing on main too (4, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
agc_driver_submit_progress
Validation IDs already present on main (4 IDs in 487 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (487 tests): agc_driver_address_draw_space_reuse, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 479 more
VUID-vkCmdCopyImage-srcImage-01548 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-vkCmdCopyImage-srcImage-01551 (4 tests): agc_driver_depth_clear_hle, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (9)
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_recorded_draw_staging: skipped, the device does not keep host imports write-watched, so the target is never resident
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
Reproduce
git fetch origin ee1696711b51fce4473a501c3524a53c29cb7d70 4639eff7f4c23325a916875a0e37f1e312fa18f4
git checkout 4639eff7f4c23325a916875a0e37f1e312fa18f4 && git merge --no-ff ee1696711b51fce4473a501c3524a53c29cb7d70
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
# Conflicts:
#	docs/dev/debt/libScePad.md
@JJenkx

JJenkx commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged main e1d8b9c00c into the branch, preserving its history. New head: bb23089386.

The only conflict was docs/dev/debt/libScePad.md, where this PR's controller-timestamp entry and main's new trigger-effect entries (scePadDisableTriggerEffect, scePadSetTriggerEffectStrength and others) were added at the same place. Both are kept; no code changed in the merge.

Linux 7.2.11, GCC 16.2.1, Release: the 30 libScePad, guest_pad*, pad_* and pad-route tests: 29 pass in 3 of 3 runs each (ctest --repeat until-fail:3); audio_out_vibration_pad_control was not built in this selection.

AI-assisted: yes

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@adriadam10
adriadam10 merged commit 4adb9f3 into boykopovar:main Nov 8, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked the new head: it only merges main, and the only conflict was the docs/dev/debt/libScePad.md adjacency, with both entries kept. ReadState and the empty-queue Read stamp fresh samples with the current process time, queued samples keep their capture time, and CheckHeldSampleTimes fails on the old code. Debt line is under Functional; checks green; merged.

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.

8 participants