Author SHA1 Message Date
Federico Marras 5601f8824c feat(libSceLibreSsl): decompress EC points on NIDs 712 and 713 (#27417)
* feat(libSceLibreSsl): decompress EC points on NIDs 712 and 713
* test(libSceLibreSsl3): expect a non-residue compressed point to be rejected
2026-11-27 08:17:55 +13:00
Dean 1dff9f49a2 Merge pull request #26778 from akkadbakkad89/agc-draw-relocation-decode-reads
perf(agc): learn draw relocation shapes from data donors
2026-11-27 08:11:34 +13:00
Dean 21e1e006c3 Merge pull request #27231 from pushkarreddyy/fix/regmgr-string-pointer-probing
fix(libSceRegMgr): probe guest pointers in sceRegMgrStrncpy and sceRegMgrMemset
2026-11-27 08:01:04 +13:00
chitters2004 5325912480 fix(agc): record CPU stores to pages that leave the write watch during a capture (#22028)
* fix(agc): record CPU stores to pages that leave the write watch during a capture
* fix(agc): decide compared-page erasure under the write-watch lock
2026-11-27 07:58:11 +13:00
Dean 131a4e57da Merge pull request #27224 from pushkarreddyy/fix/posixwebkit-freeaddrinfo-probing
fix(libScePosixForWebKit): probe guest AddressInfo nodes in freeaddrinfo
2026-11-27 07:52:54 +13:00
Dean 6ed4010d4e Merge pull request #27140 from kiansaeidnia/feat/libkernel-sa-siginfo-delivery
feat(libkernel): deliver SA_SIGINFO handlers with siginfo and ucontext, as FreeBSD 11 does
2026-11-27 07:52:31 +13:00
Dean f7cfb96c4e Merge pull request #27258 from kiansaeidnia/fix/libc-qsort-r-small-inputs
fix(libc): return from qsort_r for fewer than two elements or zero-size elements below 7, as FreeBSD 11 does
2026-11-27 07:41:16 +13:00
Dean 68f3c9077c Merge pull request #27358 from gurtgg/feat-contentsearch-metadata-offline
feat(libSceContentSearch): implement offline application index, metadata checks, and AV event enable
2026-11-27 07:20:56 +13:00
Dean 6c3d1c123b Merge pull request #27439 from kteal/goodwin/pr-sparse-snapshot-reuse
perf(agc): reuse read-only sparse upload snapshots
2026-11-27 07:18:07 +13:00
Dean a116408ab7 Merge pull request #27304 from david-ojah/feat/check-compile-option-grammar
feat(tools): model compiler options and save-temps safely
2026-11-27 07:17:32 +13:00
Dean 10d41598e6 Merge pull request #27203 from milescoviello/fix/audioout-bounded-device-reopen
fix(libSceAudioOut): reopen a stopped or missing output device on a host thread
2026-11-27 07:17:08 +13:00
Eagle 1f86401ae0 fix(agc): write back BDA stores into writable heap mirrors (#12840)
* fix(agc): write back BDA stores into writable heap mirrors
* fix(agc): note only the stored runs of address-store spans as written back
* perf(agc): compare only the pages BDA stores hit in heap mirror spans
* perf(agc): copy heap mirror write-back references on the GPU
* feat(shader): redirect BDA stores into unbound heap mirror blocks to store pages
* fix(agc): store into resident heap mirrors without binding, copying or reading back the span
* fix(agc): write back copy-backed heap mirrors by per-byte store masks
* perf(agc): reuse store page pools across address-based builds
* fix(agc): write back stores into unbound heap mirror blocks by their store masks
* test(agc): pin store page exhaustion of heap mirror stores at the pool size
* test(agc): store to 1,025 heap mirror pages against the default store page pool
* fix(agc): race the journal replay against a journal that holds every raced pipeline
* test(agc): size the journal watermark case's records from the rewrite target
* test(agc): expect copy-backed heap mirror stores as production masks and reports them
* test(agc): check that an over-limit store page dispatch writes nothing, without pinning its refusal
* docs(debt): state what a use past the BDA store page pool gets
* test(agc): check a build's private fault slot leaves the arena with it
* fix(agc): build the store-page overflow message only on overflow
* fix(agc): reuse the merged writes without address stores
2026-11-27 07:16:44 +13:00
Dean c136f2d58b Merge pull request #21208 from talha-devp/feat/finisher-drain-timing
feat(agc): time the queue worker's waits for the draw finisher
2026-11-27 07:13:40 +13:00
Dean eb2e3e1cf7 Merge pull request #20635 from Ketz7/feat/shader-pk-fma-f16-directed
feat(shader): allow directed rounding modes for packed f16 fma
2026-11-27 07:13:17 +13:00
Dean edf0b1b842 Merge pull request #27217 from alexander-src/perf/import-audit-fast-scan
perf(tools): fast-scan conditional stubs in import_audit
2026-11-27 07:07:01 +13:00
Dean c1a89b944c Merge pull request #27256 from david-ojah/fix/libkernel-getdtablesize-console-cap
fix(libkernel): cap getdtablesize at the console file limit
2026-11-27 07:04:18 +13:00
Dean 659481ea9d Merge pull request #27254 from birdmarty/perf/agc-slice-aware-pass-hazards
perf(agc): track per-slice attachment hazards in PassHazards
2026-11-27 07:03:53 +13:00
Dean d9a4e3769e Merge pull request #27252 from birdmarty/perf/agc-fill-buffer-joined-host-import
perf(agc): fall back to joined host imports in VulkanDevice::FillBuffer
2026-11-27 07:03:24 +13:00
Dean d886ac5127 Merge pull request #27246 from david-ojah/feat/libkernel-print-backtrace
feat(libkernel): print a host backtrace with module info
2026-11-27 07:02:49 +13:00
Dean 8b1896c66f Merge pull request #20344 from xXPBSXx/fix/agc-screenshot-trigger-held-open
fix(agc): do not abort on a screenshot trigger that another process holds open
2026-11-27 07:02:25 +13:00
Dean 4628a01aae Merge pull request #20324 from lgqdaxia/codex/test-windows-depth-allocations
test(agc): count depth view allocations on Windows
2026-11-27 07:02:00 +13:00
Dean 2ae7945591 Merge pull request #25817 from malekaifa/prime-f/fix-ci-runtime-library-tests-20261122
fix(ci): run guest tests of changed runtime libraries
2026-11-27 06:56:30 +13:00
Finley LaempeandDean bf9cdc1e50 feat(libSceNKWebKit): implement the WebCore::SecurityOriginData fromFrame and isolatedCopy exports (#23109)
* feat(libSceNKWebKit): implement the WebCore::SecurityOriginData fromFrame and isolatedCopy exports
* fix(libSceNKWebKit): start the tuple lifetime in the null-frame SecurityOriginData
* docs(debt): state that the SecurityOriginData return convention is fixed by the ABI

Co-authored-by: Dean <158058829+oneandonlydean@users.noreply.github.com>
2026-11-27 06:56:00 +13:00
Callimann8 4a04780f0a feat(libSceLibreSsl): implement SSL_set_SSL_CTX (#23088) 2026-11-27 06:55:36 +13:00
Daniel Fischer M. Sc. 3b0d709887 feat(libSceLibreSsl3): print an X509 certificate (#23066)
* feat(libSceLibreSsl3): print an X509 certificate
* docs(libSceLibreSsl3): keep the X509_print debt bullet under the length limit
* fix(libSceLibreSsl3): print a serial of minus one in decimal and hexadecimal
2026-11-27 06:55:12 +13:00
Dean a81731e944 Merge pull request #23682 from gameguys919/docs/readme-de
docs: add German README
2026-11-27 06:34:30 +13:00
Dean 9f52918eb0 Merge pull request #27401 from xXPBSXx/fix/cescs-sjis-error-outputs
fix(libSceCesCs): set the outputs of the failing Shift-JIS and JIS X 0208 helpers as the console does
2026-11-27 06:13:51 +13:00
Dean 78514e7a0d Merge pull request #23995 from xXPBSXx/e/docs-libsceworkspace-load-failure
docs(libSceWorkspace): record that libSceWorkspace.sprx did not load in a payload process on firmware 11.60
2026-11-27 06:13:20 +13:00
gnavarro24 be2f2f3655 feat(libc): implement hcreate, hsearch and hdestroy (#26215)
* feat(libc): implement hcreate, hsearch and hdestroy
* fix(libc): register the guest_hash_search test by fragment
* fix(libc): size the hsearch table for a low load factor
* perf(libc): compare the stored hash before copying a hsearch key
* test(libc): cover the 16-slot minimum of hcreate
2026-11-27 06:07:03 +13:00
Dean ac449d9a87 Merge pull request #21704 from Krille2004zzz/feat/libsce-libcinternal-hypot
feat(libSceLibcInternal): implement _Hypot, _FHypot and _LHypot
2026-11-27 05:54:09 +13:00
Dean 4e90b6ebce Merge pull request #22752 from Akshay82480sharma/test/relinker-cli-options
test(relinker): cover rpath and verify-patches repetition and trace-imports in cli parser
2026-11-27 05:51:20 +13:00
Dean a86c5cd26d Merge pull request #22750 from MichonGoddijn231849/fix-d16-image-reads-round-toward-zero
fix(shader): pack D16 image reads toward zero and saturate 32-bit integers as RDNA2 does
2026-11-27 05:50:57 +13:00
KianandClaude Opus 5.5 f7ee939467 fix(libkernel): call SA_SIGINFO test handlers through their exact type and bound the timer wait
Give the test callbacks the UserUcontext* parameter libkernel calls them
with, bound the pending-timer loop as the other waits in the file are,
and describe the sigsuspend null set and the per-thread mask in the
debt entry as the code behaves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 02:47:54 +10:00
Dean 23f6bcf7c7 Merge pull request #27399 from angrysandhill/feat/libSceSharePlay-disconnected
fix(libSceSharePlay): report a disconnected service after initialization
2026-11-27 05:40:56 +13:00
Dean fc064c69c4 Merge pull request #22595 from DerKarussellbremser/fix/patch-advisor-symlink
fix(relinker): compare the advisor's patch path resolved in its JSON test
2026-11-27 05:30:40 +13:00
Dean e55b89a03d Merge pull request #8939 from EagleBearerYS/fix/shader-pointer-key-lane-masks
fix(shader): take lane-mask arms and a merged high word in a pointer-keyed record pointer
2026-11-27 05:30:14 +13:00
Dean 9bab15825c Merge pull request #27365 from cocoa55/fix/systemlogger2-event-guard-page
test(libSceSystemLogger2): check an event record that runs into a guard page
2026-11-27 05:27:24 +13:00
Dean 136bb4f7d0 Merge pull request #27396 from xXPBSXx/test/libkernel-pin-address-sanitizer-query
test(libkernel): pin sceKernelIsAddressSanitizerEnabled to the value measured on a PS5
2026-11-27 05:22:16 +13:00
Dean 421aa1a9c1 Merge pull request #27429 from zaryabzip/docs/libkernel-rdup-stale-entry
docs(debt): keep the rfork_thread entry to rfork_thread now that sceKernelRdup is implemented
2026-11-27 05:12:13 +13:00
Dean a96b2b060c Merge pull request #24782 from HBake/feat/net-interface-stats
feat(libSceNet): implement sceNetGetInterfaceStats
2026-11-27 05:09:26 +13:00
zarmstrong 45d8797428 fix(shader): call load_bda_span outside read_bda_span's per-lane selection (#22774) 2026-11-27 05:06:38 +13:00
chitters2004 531a975064 fix(agc): clean up what a discarded batch leaves behind (#20186)
* fix(agc): delist a discarded batch's copied writers
* fix(agc): restore occlusion samples a discarded batch folded and drop its own
* fix(agc): refuse native depth sampling after a discarded HTILE clear
* fix(agc): latch a deferred completion's submit failure before waking idle waiters
* fix(agc): keep discard actions exception-safe from registration to run
* test(agc): restore samples a discarded batch folded from queued dumps or at capacity
* test(agc): check a discarded HTILE clear dispatch is undone on every host
* test(agc): show a deferred completion latches its failure before waking idle waiters
* test(agc): fail a discarded HTILE clear dispatch only on its own batch
* fix(agc): undo only a discarded batch's own HTILE clear dispatches
2026-11-27 05:06:14 +13:00
gnavarro24 32b9da6bc0 feat(libScePosixForWebKit): implement mkstemps (#26354)
* feat(libScePosixForWebKit): implement mkstemps
* fix(libScePosixForWebKit): apply the FreeBSD mkstemps suffix bounds
* fix(libScePosixForWebKit): restore the mkstemps test block after the merge
* test(libScePosixForWebKit): reject unreplaced X characters in mkstemps names
2026-11-27 05:03:09 +13:00
Miles Coviello 5c0372a9bf test(libc): check the fundamental and pointer type_info records (#26869) 2026-11-27 04:57:54 +13:00
Dean 10fef81d2a Merge pull request #27414 from NobleBrains/docs/trim-abstract-twitter-debt
docs(debt): shorten libSceAbstractTwitter entry below 1000 chars
2026-11-27 04:47:53 +13:00
Dean 0b16257796 Merge pull request #27386 from u-instinct11/fix/pad-preview-regular-command
fix(tools): reject nonregular controller preview paths
2026-11-27 04:42:34 +13:00
Dean a79ef992de Merge pull request #27385 from u-instinct11/fix/main-sync-spaced-worktree
fix(tools): preserve whitespace in branch sync worktree paths
2026-11-27 04:39:50 +13:00
Miles Coviello 2ba56d12a0 test(libc): check the exception globals, uncaught-exception queries and dependent exceptions (#26871)
* test(libc): check the exception ABI entry points that no test called
* test(libc): run the exception throw helper checks on Linux only
* test(libc): leave the throw helpers and std::uncaught_exceptions to the open tests that check them
2026-11-27 04:37:00 +13:00
Dean b58bb2024e Merge pull request #27407 from JJenkx/docs/trace-summary-interpretation-20261126
docs: clarify trace loss and inclusive performance totals
2026-11-27 04:29:07 +13:00
Dean 41dfbe4d8e Merge pull request #21119 from slopgobblercobbler/slopgobblercobbler/pr-libkernel-sysctl-kern-debug-nodes
test(libkernel): audit sysctl kern and debug MIB nodes and subnode bounds
2026-11-27 04:23:56 +13:00
Dean 5e33c29526 Merge pull request #20587 from milescoviello/fix/libc-probe-gets-s-buffer
fix(libc): safely probe the buffer of gets_s
2026-11-27 04:23:33 +13:00
Dean 0942072058 Merge pull request #26866 from Ducengarth/codex/freetype-ot-sfnt-table
fix(libSceFreeTypeOt): forward FT_Get_Sfnt_Table on Windows
2026-11-27 04:15:22 +13:00
Dean 33e26a19eb Merge pull request #25781 from jagrat04/feat/libscenkwebkit-page-back-forward-navigation
feat(libSceNKWebKit): implement WKPage back-forward navigation controls
2026-11-27 04:14:55 +13:00
Ryuzaki 3ddd8d5e05 feat(libc): add integer libc++ to_string (#25766)
* feat(libc): add integer libc++ to_string
* build(libc): move integer string registration
* build(libc): avoid string registration overlap
2026-11-27 04:14:30 +13:00
Dean 24bdb0565c Merge pull request #26663 from Kerutzuu/kerutzuu-open-pull-request
feat(libSceNKWebKit): implement UTF-16 grapheme counts
2026-11-27 04:04:17 +13:00
Dean a4ed870149 Merge pull request #27375 from cookie42073-cmd/patch-1
fix(test): restore standalone shared-memory test linking
2026-11-27 03:39:05 +13:00
Dean af6a58c4d3 Merge pull request #27406 from suganthan2005/codex/trace-diff-event-loss
fix(tools): retain event-loss warnings in whole-capture trace diffs
2026-11-27 03:28:43 +13:00
Dean 0837c5581e Merge pull request #27259 from kiansaeidnia/fix/libkernel-getrusage-host-fields
fix(libkernel): fill getrusage children and ru_maxrss from the host, as FreeBSD 11.4 does
2026-11-27 03:20:52 +13:00
Dean 7c2327a239 Merge pull request #27404 from daniel-madrid-07/fix/pr-overlap-name-whitespace
fix(tools): refuse pr_overlap --names with whitespace or control characters
2026-11-27 03:18:03 +13:00
KianandClaude Opus 5.5 c200c89a16 feat(libkernel): deliver SA_SIGINFO handlers with siginfo and ucontext, as FreeBSD 11 does
raise, kill, pthread_kill, pause, sigsuspend and unblocking a pending
signal now call an SA_SIGINFO handler as handler(sig, info, uc) instead
of throwing. info is the 80-byte siginfo_t sigtimedwait already fills
(SI_LWP, SI_USER or the queued code such as SI_TIMER). uc is captured
with getcontext at the delivery point and carries the mask from before
the delivery; under sigsuspend that is the mask sigsuspend replaced plus
the blocks of an outer handler, as FreeBSD's td_oldsigmask. A changed
uc_sigmask becomes the mask on return, as FreeBSD 11's sendsig and
sys_sigreturn do. A changed uc_mcontext that switches to another context
is resumed through sigreturn after the handler's blocks are released;
one that keeps the %rip or %rsp of the delivery point throws, since
those registers are libkernel's and not the system call's. sigsuspend
puts its previous mask back when a delivery throws. A host signal still
does not reach an SA_SIGINFO handler; the debt entries say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 00:07:20 +10:00
Dean 3dd06de43c Merge pull request #27400 from xXPBSXx/docs/opus-ctl-cancel-zero-state-measured
docs(debt): record measured Opus encoder Ctl and SilkEncCancel state errors
2026-11-27 02:57:14 +13:00
Dean 72cd624367 Merge pull request #27324 from kiansaeidnia/feat/libscelibcinternal-reclaim-telldir
feat(libSceLibcInternal): implement _reclaim_telldir, as FreeBSD 11.4 does
2026-11-27 02:56:50 +13:00
Dean 4a5119349f Merge pull request #25809 from rodydacruz/feat/libcinternal-strcollx
feat(libSceLibcInternal): implement _Strcollx
2026-11-27 02:48:47 +13:00
Dean c7e99ec0d3 Merge pull request #20114 from c1b3r-p3d1a/test/shader-gather4h-pck-r8-rg8
test(shader): run image_gather4h_pck on R8 and RG8 textures
2026-11-27 02:48:23 +13:00
Dean 5713f3d4c2 Merge pull request #20090 from c1b3r-p3d1a/test/shader-sdwa-f32-rounding-special
test(shader): check SDWA f32 rounding and frexp destinations on special inputs
2026-11-27 02:48:00 +13:00
Dean df8a02ebce Merge pull request #20085 from XIIYAZ/fix/agc-moltenvk-sample-mask-in-shader
fix(agc): apply a uniform sample mask in the pixel shader on MoltenVK, whose static mask does not stop shading
2026-11-27 02:47:36 +13:00
Dean 81ff76a0c0 Merge pull request #27397 from xXPBSXx/docs/pngdec-partial-rows-measured
docs(libScePngDec): record the rows written for truncated IDAT streams on firmware 11.60
2026-11-27 02:24:37 +13:00
Danny Oppenheimer dca0206073 fix(tools): verify saved CTest test identities (#26358)
* fix(tools): check saved CTest test identities
* fix(tools): reject saved CTest selections past the registered tests
2026-11-27 02:14:14 +13:00
Dean c636b0cf15 Merge pull request #27345 from milescoviello/test/agc-fuse-unversioned
test(libSceAgc): check that unversioned sceAgcFuseShaderHalves fuses geometry halves like the _0200 entry
2026-11-27 02:11:23 +13:00
Dean 7624c6b5f9 Merge pull request #27326 from kiansaeidnia/fix/libkernel-cpu-clock-resolution
fix(libkernel): read CLOCK_VIRTUAL and CLOCK_PROF from getrusage on POSIX hosts, as FreeBSD 11.4 does
2026-11-27 02:11:00 +13:00
Dean d2409cef70 Merge pull request #10645 from rocklouis055/feat/equeue-pipe-write-lowat-on9099
feat(libkernel): add pipe write events and socket low watermarks to sceKernelAdd*Event
2026-11-27 02:10:22 +13:00
Gordon 7098176271 feat(libSceNKWebKit): implement WebCore::AsyncFileStream (#26439)
* feat(libSceNKWebKit): implement WebCore::AsyncFileStream
* fix(libSceNKWebKit): close the stream when the seek of openForRead fails
2026-11-27 02:02:35 +13:00
mihai1859 c324c1e755 feat(libc): implement libc++ regex name lookups (#25839) 2026-11-27 02:01:54 +13:00
Dean 6781655de6 Merge pull request #22996 from Callimann8/feat/libcurl-formget
feat(libcurl): implement curl_formget
2026-11-27 02:01:31 +13:00
Dean a3f8ec4e0c Merge pull request #27271 from birdmarty/perf/agc-skip-index-scan-without-vertex-attribs
perf(agc): skip CPU index range scan for in-place draws without vertex attributes
2026-11-27 01:45:45 +13:00
Dean f0f208dc7a Merge pull request #27268 from birdmarty/perf/agc-shared-prepared-mesh-windows
perf(agc): reuse PreparedDraw across layered mesh output windows
2026-11-27 01:45:21 +13:00
Dean 87acabfb97 Merge pull request #27253 from birdmarty/perf/agc-lock-free-shadow-overlap
perf(agc): read thread-local live shadow ranges in AnyShadowedOverlaps
2026-11-27 01:44:58 +13:00
Dean 31343579ba Merge pull request #27251 from birdmarty/perf/agc-after-recorded-work-no-break-proofs
perf(agc): do not break guest memory proofs in Recorder::AfterRecordedWork
2026-11-27 01:44:34 +13:00
gameguys919 f9bbc2299d docs: add German README
Translate README.md into German as docs/user/README.de.md and add the language link to README.md and every translated README under docs/user.
2026-11-26 13:43:37 +01:00
Dean fae9876e97 Merge pull request #27354 from gurtgg/feat-discmap-unknown-no-bitmap
feat(libSceDiscMap): return no-bitmap error in 5+vOlukvkfg
2026-11-27 01:39:08 +13:00
Dean 35d3474ef0 Merge pull request #27219 from alexander-src/perf/progress-fast-analysis
perf(tools): speed up stub reachability and linkage scanning in progress
2026-11-27 01:36:14 +13:00
Dean 085d5137ab Merge pull request #27392 from u-instinct11/docs/performance-csv-selectors
docs(tracing): explain selecting captures for performance CSV
2026-11-27 01:33:15 +13:00
Dean 4a11eb7d57 Merge pull request #27391 from u-instinct11/docs/configure-seed-filter-precedence
docs(build): explain configure seed filter matching
2026-11-27 01:32:48 +13:00
Dean c476d55349 Merge pull request #27390 from u-instinct11/docs/pe-inventory-addresses
docs(reversing): explain address fields in PE symbol inventories
2026-11-27 01:32:20 +13:00
Dean 2c082de95f Merge pull request #27389 from u-instinct11/docs/catalog-validation-json
docs(usage): document patch catalog validation JSON
2026-11-27 01:31:56 +13:00
Dean 8ed928edb9 Merge pull request #27363 from LenoreSlate/fix/input-mapper-setting-hints
fix(input-mapper): show the range and built-in value of each setting
2026-11-27 01:31:33 +13:00
Dean 873cc3d671 Merge pull request #27362 from LenoreSlate/fix/input-mapper-french-settings-wording
fix(input-mapper): use consistent French terms in the settings editors
2026-11-27 01:31:09 +13:00
Dean 22619a94ad Merge pull request #27344 from milescoviello/test/imebackend-caret-next
test(libSceImeBackend): check that sceImeBackendModeCaretNext moves the caret one character right
2026-11-27 01:30:47 +13:00
Dean b8e474d445 Merge pull request #20432 from malekaifa/prime-c/fix-trace-append-20261115
fix(libSceAgcDriver): serialize trace summary appends
2026-11-27 01:29:12 +13:00
Dean 37749b6cd5 Merge pull request #27444 from oneandonlydean/lead/revert-27278
revert: fix(libSceNgs2): fix natural-order packing and header layout in FFT exports (#27278)
2026-11-27 01:07:45 +13:00
Dean 79e4f35199 Merge pull request #27388 from u-instinct11/docs/pad-preview-sequence
docs(input): explain what pulse preview reads from the command file
2026-11-27 00:56:32 +13:00
Dean 2a2ba92148 Merge pull request #27387 from u-instinct11/docs/main-sync-strict
docs(testing): explain strict branch sync checks
2026-11-27 00:56:11 +13:00
Dean 161e33a8d1 revert: fix(libSceNgs2): fix natural-order packing and header layout in FFT exports (#27278)
This reverts commit 11062d5d7d, reversing changes made to 9931d320d9.

ngs2_core_routing fails on main since it landed: the forward natural-order output and the inverse path no longer match the existing Ngs2Routing test.
2026-11-27 00:51:37 +13:00
Dean 9415030dfe Merge pull request #27340 from Ducengarth/fix/libfreetype-color-layer-invalid-outputs
fix(libfreetype): write invalid COLR layer indices as FreeType does
2026-11-27 00:32:50 +13:00
Dean dd26d32754 Merge pull request #24666 from CodingBreadd/feat/libscexml-serialize
feat(libSceXml): implement Document::serialize as firmware 13.40 does
2026-11-27 00:29:54 +13:00
Dean 97319cf0b9 Merge pull request #26349 from vishnuvardhan3333/fix/cescs-unicode-guest-access
fix(libSceCesCs): access Unicode conversion buffers through guest copies
2026-11-27 00:11:16 +13:00
Dean 115a7036e2 Merge pull request #27249 from birdmarty/perf/agc-target-memo-3d-volume-slices
perf(agc): reuse TargetMemo across 3D volume slices and reject overlapping pending targets
2026-11-26 23:52:32 +13:00
MrSourceee 4dfb9dc037 feat(icu): compare counted StringPiece byte strings (#23063) 2026-11-26 23:52:08 +13:00
hedi trigui a2e598876c feat(libSceLibreSsl3): implement SSL_CTX_add0_chain_cert and SSL_CTX_clear_chain_certs (#23029)
* feat(libSceLibreSsl3): implement SSL_CTX_add0_chain_cert and SSL_CTX_clear_chain_certs
* fix(libSceLibreSsl3): detach extraCerts before certificate release in SSL_CTX_clear_chain_certs
2026-11-26 23:51:43 +13:00
Dean 2d2765487d Merge pull request #22898 from FinleyLaempe/feat/nkwebkit-history-item
feat(libSceNKWebKit): implement the WebCore::HistoryItem constructors and mutation exports
2026-11-26 23:51:18 +13:00
Dean 871ef968fb Merge pull request #22775 from milescoviello/fix/webrtc-audioframe-guest-copies
fix(libwebrtc): read and write the AudioFrame fields through checked guest copies
2026-11-26 23:50:54 +13:00
Dean 0ff35eb00a Merge pull request #20763 from edubox/feat/npcpp-activities-instantiations
feat(libSceNpCppWebApi): export the Leaderboards instantiations the titles import
2026-11-26 23:50:30 +13:00
kteal 51271bae6e perf(agc): reuse read-only sparse upload snapshots 2026-11-26 02:48:53 -08:00
Dean 79e34a9833 Merge pull request #27320 from magnub/fix/libcxx-regex-error-test-macos
fix(libc): build the libc++ regex_error test with clang
2026-11-26 23:46:43 +13:00
Dean d7ec3dfd6d Merge pull request #27311 from relativespace2K/fix/webrtc-crop-scale-limit
fix(libwebrtc): cap the scaler crop at the largest size libyuv handles
2026-11-26 23:46:20 +13:00
Dean 420c5808a3 Merge pull request #27310 from relativespace2K/fix/jsc-persistence-string-allocation
fix(libSceJsc): allocate a whole StringImpl when decoding a short string
2026-11-26 23:45:55 +13:00
Dean 911092fa01 Merge pull request #27296 from nexus1692/test/usb-storage-export-guards
test(libSceUsbStorage): pin the shell-core mount point guards
2026-11-26 23:45:32 +13:00
Dean 4cb5396d2a Merge pull request #27280 from gurtgg/feat-vdecshevc-1360-exports
fix(libSceVdecShevc): check inner decoder pointer in no-decoder gate
2026-11-26 23:45:07 +13:00
Dean 11062d5d7d Merge pull request #27278 from gurtgg/fix/ngs2-fft-natural-order-1360
fix(libSceNgs2): fix natural-order packing and header layout in FFT exports
2026-11-26 23:44:43 +13:00
Dean ad2fd81b61 Merge pull request #27238 from fromthemoonx/libressl-rsa-verify-asn1-errors
fix(libSceLibreSsl): queue LibreSSL's ASN.1 errors when RSA_verify rejects a DigestInfo
2026-11-26 23:44:01 +13:00
Mohamed Malek Aifa 3defcc821a fix(libSceAudio3d): preserve PS4 port-open parameter side effects (#27222) 2026-11-26 23:43:26 +13:00
Dean abb81fa419 Merge pull request #27145 from xXPBSXx/fix/libsceft-ot-measured-console-1160
fix(libSceFreeType): return +180 degrees from FT_Atan2 for dx < 0 and dy = 0
2026-11-26 23:43:01 +13:00
Dean dee8e5cfa3 Merge pull request #27138 from gurtgg/feat-xml-sax-doctype-entities-boundaries
feat(libSceXml): support SAX DOCTYPE, entity resolution, chunk splits, and boundary errors
2026-11-26 23:42:37 +13:00
Dean 68fe867c4a Merge pull request #26790 from MarcZX10/docs/fix-env-reference-rule
docs(contributing): state the ENVIRONMENT.md row rule for new variables
2026-11-26 23:42:07 +13:00
Dean ce6b6b0cce Merge pull request #26149 from IvanFogel/feat/20261123/font-agc-render-target
feat(font): initialize AGC font render target surfaces
2026-11-26 23:41:42 +13:00
Dean 9190a875b1 Merge pull request #25110 from ashwin280802/feat/libscelibcinternal-atqexit-atthreadexit
feat(libSceLibcInternal): implement _Atqexit and _Atthreadexit
2026-11-26 23:41:18 +13:00
Stephen Cork 891a174005 test(libSceFiber): audit switch register preservation, stack canaries, and roundtrips (#21611) 2026-11-26 23:40:54 +13:00
Dean 430b7e499d Merge pull request #20251 from Remi-Bon/perf/shader-formatted-load-loop
perf(shader): convert runtime-format buffer components at their run-time width
2026-11-26 23:40:19 +13:00
Dean 9931d320d9 Merge pull request #26110 from IvanFogel/fix/20261123/ngs2-compressor-key
fix(ngs2): route a native submixer compressor side-chain input
2026-11-26 23:36:54 +13:00
Dean 873bf45425 Merge pull request #25900 from MarrasFederico/test/jxr-wmp-lossy-formats
test(libSceJxr): cover lossy quantization, tiling, overlap, and pixel formats against jxrlib
2026-11-26 23:36:29 +13:00
Dean 5e59511e29 Merge pull request #25738 from JJenkx/fix/libSceNKWebKit-storagemap-guest-pointers
fix(libSceNKWebKit): validate guest pointers in WebCore::StorageMap exports
2026-11-26 23:35:54 +13:00
Dean 7a99aceaad Merge pull request #25616 from kattkaries/fix/pad-protect-replay-recording
fix(libScePad): protect replay files from recording overwrite
2026-11-26 23:35:30 +13:00
Dean c8d68bb042 Merge pull request #25520 from olegon85/feat/libSceAvSetting-preinit-answers-1360
feat(libSceAvSetting): answer the pre-initialization checks measured on 13.60
2026-11-26 23:35:07 +13:00
Dean 628a6c565f Merge pull request #25354 from kessler-drift/fix/libscelibressl3-mac-key-errors
fix(libSceLibreSsl3): queue errors for types EVP_PKEY_new_mac_key rejects
2026-11-26 23:34:43 +13:00
Dean c2acea5ca5 Merge pull request #23852 from opxdelwin/feat/libscepngparser-read-metadata
feat(libScePngParser): read PNG metadata through the firmware 13.42 MBQfjtzRyh0 call
2026-11-26 23:34:07 +13:00
Dean 37c33ad6b0 Merge pull request #23422 from gurtgg/fix-npwebapi2-context-request-validation
fix(libSceNpWebApi2): validate user contexts, requests, and multipart types per firmware 13.60
2026-11-26 23:33:43 +13:00
Dean bdf8ab7244 Merge pull request #23358 from plentilha/fix/freetype-ot-glyph-slot-guest-copy
fix(libSceFreeTypeOt): copy glyph slot records through guest memory
2026-11-26 23:33:19 +13:00
Dean 1bc45d0dac Merge pull request #23290 from benjaminmathias/fix/freetype-outline-render
fix(libSceFreeType): copy FT_Outline_Render guest pointers safely
2026-11-26 23:32:55 +13:00
Dean f5ff724fcd Merge pull request #22776 from milescoviello/fix/webrtc-audiobuffer-copy-guest-copies
fix(libwebrtc): copy AudioBuffer::CopyFrom and CopyTo samples through checked guest copies
2026-11-26 23:32:37 +13:00
Dean 423d25adeb Merge pull request #22541 from relativespace2K/fix/6898-avplayer
fix(libSceAvPlayer): hold handed-out video frames with optional extra buffers
2026-11-26 23:32:13 +13:00
Dean 19fa0c6bd0 Merge pull request #22504 from milescoviello/fix/npmanager-value-class-guest-copies
fix(libSceNpManager): copy the sce::np value-class objects through checked guest copies
2026-11-26 23:31:49 +13:00
Dean 200446119c Merge pull request #22361 from zaryabzip/fix/npmanager-request-ids
fix(npmanager): give out request ids and refuse bad ids as firmware 13.42 does
2026-11-26 23:31:26 +13:00
Hdn d57377b584 fix(libSceMsgDialog): probe guest message parameters (#20374)
* fix(libSceMsgDialog): probe guest message parameters
* docs(libSceMsgDialog): move guest parser debt into change fragment
* fix(libSceMsgDialog): use PRX unwind for parser test
* fix(libSceMsgDialog): accept short text at guarded page end
* fix(libSceMsgDialog): fail closed on unsupported host reads
* fix(libSceMsgDialog): fail closed on checked read exceptions
2026-11-26 23:31:00 +13:00
Dean bd49ef1199 Merge pull request #21952 from slopgobblercobbler/slopgobblercobbler/pr-libscepad-motion-sensor-state-bounds
test(libScePad): verify motion sensor state output sequence in GuestPad
2026-11-26 23:27:47 +13:00
Dean e02d7fb790 Merge pull request #21945 from slopgobblercobbler/slopgobblercobbler/pr-libscepad-controller-info-connection-states
test(libScePad): audit controller information layout, unopened handles, and special handle zeroing
2026-11-26 23:27:24 +13:00
RTGGandDean 842737adf3 fix(libSceNetCtl): validate result writability before throwing in sceNetCtlGetResult (#21711)
* fix(libSceNetCtl): guard sceNetCtlGetResultV6 against uninitialized calls
* test(libSceNetCtl): call sceNetCtlGetResultV6 with a valid event type
* fix(libSceNetCtl): avoid clobbering output before throw in sceNetCtlGetResult and preserve errno
* test(libSceNetCtl): fix ClobberWriteErrno hook callback signature

Co-authored-by: Dean <158058829+oneandonlydean@users.noreply.github.com>
2026-11-26 23:27:01 +13:00
Dean 29e4640295 Merge pull request #21652 from slopgobblercobbler/slopgobblercobbler/pr-libscepad-getdata-read-bounds
test(libScePad): audit scePadRead pre-initialization bounds
2026-11-26 23:26:37 +13:00
Dean 1a557321f3 Merge pull request #21456 from Zyylon/fix/libwebrtc-packet-guest-pointers
fix(libwebrtc): harden packet, buffer, and error guest pointers
2026-11-26 23:26:13 +13:00
Waleed Ali Tahir 027f55531a feat(libwebrtc): implement AudioDecoderOpusImpl constructor and destructor (#21347)
* feat(libwebrtc): implement AudioDecoderOpusImpl constructor and destructor
* fix(libwebrtc): bound AudioDecoderOpusImpl decode capacity
* fix(libwebrtc): clean up ParsePayload frames and preserve payload on failure
2026-11-26 23:25:49 +13:00
Waleed Ali Tahir c71be87c9d fix(libwebrtc): copy RTCP packet guest pointers safely (#21330)
* fix(libwebrtc): copy RTCP packet guest pointers safely
* fix(libwebrtc): cap RTCP allocations and make multi-vector Parse atomic
2026-11-26 23:25:21 +13:00
Dean 162d18c7c3 Merge pull request #21305 from Zyylon/fix/libwebrtc-wav-file-guest-pointers
fix(libwebrtc): copy WavReader and FileWrapper guest pointers safely
2026-11-26 23:24:56 +13:00
Dean e17dd1c40f Merge pull request #21265 from gurtgg/fix-jpegdec-create-aligned-bounds-rollback
fix(libSceJpegDec): preserve live context and stream when sceJpegDecCreate fails
2026-11-26 23:24:31 +13:00
Dean ea9ff32229 Merge pull request #20502 from Mcm190/feat/libcairo-font-pipeline
feat(libcairo): implement native font pipeline and device destruction
2026-11-26 23:24:08 +13:00
Matteo Donato a66a17e6c6 feat(libfontconfig): implement FcFontRenderPrepare (#20181)
* feat(libfontconfig): implement FcFontRenderPrepare
* fix(libfontconfig): keep a font value when every match score is NaN
* docs(libfontconfig): move the debt changes to a fragment
2026-11-26 23:23:12 +13:00
Brett M. Howell 47de32f506 feat(libSceNKWebKit): implement WTF thread compilation and GC flags (#19780)
* feat(libSceNKWebKit): implement WTF thread compilation and GC flags
* docs(debt): move debt entries into a fragment
2026-11-26 23:22:48 +13:00
Dean d8da7c4b44 Merge pull request #19182 from c1b3r-p3d1a/feat/jxr-file-stream
feat(libSceJxr): open file streams from the PKFactory slot
2026-11-26 23:22:18 +13:00
Dean effab7885d Merge pull request #18247 from amazedturnip/fix/libSceJxr-validate-alloc-free-pointers
fix(libSceJxr): validate guest memory pointers in WMPAlloc and WMPFree
2026-11-26 23:22:01 +13:00
Dean 23f655c17d Merge pull request #18237 from amazedturnip/fix/libSceAjm-wvorbis-header-param-validation
fix(libSceAjm.native): validate guest pointers in sceAjmDecWVorbisCreateHeaderPacket
2026-11-26 23:21:38 +13:00
Dean 83e709515e Merge pull request #27209 from u-instinct11/fix/trace-gzip-uppercase
fix(tools): read traces with uppercase gzip suffixes
2026-11-26 23:04:21 +13:00
Dean a6b6cbf170 Merge pull request #27204 from Ducengarth/codex/freetype-ot-char-variant-default
fix(libSceFreeTypeOt): forward FT_Face_GetCharVariantIsDefault on Windows
2026-11-26 23:03:58 +13:00
Dean 0af6efad52 Merge pull request #27313 from u-instinct11/fix/bug-report-object-input
fix(tools): reject non-object bug reports
2026-11-26 22:34:54 +13:00
Dean 9e7e9051b4 Merge pull request #26034 from birdmarty/fix/agc-settle-imports-before-depth-fill
fix(agc): settle host imports under a native depth fill before its watch check
2026-11-26 22:34:31 +13:00
Dean 188eb09f03 Merge pull request #25791 from DannyOppenheimer/feat/libkernel-windows-socketpair-rights
feat(libkernel): pass descriptors over socketpairs on Windows
2026-11-26 22:34:07 +13:00
Dean db0fc66ad1 Merge pull request #21978 from malekaifa/prime-b/fix-flock-queued-upgrade-20261115
fix(libkernel): prioritize queued flock upgrades
2026-11-26 22:33:42 +13:00
zaryabzipandClaude Opus 5.5 8fd4135745 docs(debt): keep the rfork_thread entry to rfork_thread now that sceKernelRdup is implemented
The Unknown function info entry still said rfork_thread and sceKernelRdup
both throw. #24240 implemented sceKernelRdup for the caller's pid and gave
it its own entry; rfork_thread still throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 14:33:40 +05:00
mihai1859 ee7bad6e84 test(agc): verify capture trace DLL teardown at process exit (#21646)
* test(agc): verify capture trace DLL teardown at process exit
* test(agc): keep the detach receipt control private to tests
2026-11-26 22:33:17 +13:00
Dean d50db9eaa2 Merge pull request #19567 from bxon11/fix-windows-output-preservation
fix(io): preserve existing relinker outputs on Windows
2026-11-26 22:32:53 +13:00
Dean 08a856ac6f Merge pull request #27314 from u-instinct11/fix/sanitizer-report-single-snapshot
fix(tools): read sanitizer test results from one JUnit snapshot
2026-11-26 22:29:59 +13:00
Dean 72301aee82 Merge pull request #27416 from oneandonlydean/lead/fix-rudp-debt-fold-2
docs(libSceRudp): keep one change fragment for the process, flush and receive entry
2026-11-26 22:21:18 +13:00
Dean 36fa60e6ee Merge pull request #26280 from zedekvdb/test/split-test-registration
test(tools): split test_registration by test class
2026-11-26 22:19:00 +13:00
Dean 8c2d3766ee Merge pull request #22623 from 011010/fix/macos-guest-listen-queue
fix(libSceNet): model the guest listen queue past its backlog on macOS
2026-11-26 22:18:37 +13:00
Stephen Cork 646240cbcc test(libSceFiber): audit green threading, context parameters, stack guard pages, and run error bounds (#20947) 2026-11-26 22:18:13 +13:00
Dean aec3e24f58 Merge pull request #20372 from JJenkx/fix/agc-gpu-trace-capacity-20261114
fix(agc): honor the requested GPU trace capacity
2026-11-26 22:17:50 +13:00
Alexander edb6b3dee0 fix(tools): register progress fast analysis CTest and handle grouped static ABI declarations 2026-11-26 08:55:46 +00:00
Alexander 004b971b9c test(tools): nest Tests fixture dir for case-insensitive filesystems 2026-11-26 08:54:28 +00:00
Dean e09d1349b5 Merge pull request #22717 from MichonGoddijn231849/fix-refuse-unsupported-10-10-10-2-signed
fix(agc): refuse 10_10_10_2 signed and 4_4 textures the device cannot sample
2026-11-26 21:54:01 +13:00
Dean 0e9fec8576 Merge pull request #22688 from MichonGoddijn231849/fix-trig-preop-denormal-flush
fix(shader): flush denormal v_trig_preop_f64 results in the f64 flush modes
2026-11-26 21:53:38 +13:00
Dean 7ab3479ddb docs(libSceRudp): keep one change fragment for the process, flush and receive entry
Two fragments both changed the sceRudpProcessEvents, sceRudpNetFlush and
sceRudpNetReceived entry after #25988, so debt_fold --check failed on main.
The internal I/O thread fragment now carries the whole entry, including
the write and read result and the PPSA03490 call pattern.
2026-11-26 21:53:28 +13:00
Philip Ludwig 0d81fb4b25 feat(libSceIme): drive sceImeOpen with the controller keyboard (#22186)
* feat(libSceIme): drive sceImeOpen with the controller keyboard
* fix(libSceIme): open the keyboard from the validated parameters
2026-11-26 21:53:14 +13:00
Dean 341a9eec16 Merge pull request #22683 from rgvxsthi/fix/libc-case-insensitive-unsupported-query
fix(libc): treat directories as case-insensitive when the host cannot report case sensitivity
2026-11-26 21:29:43 +13:00
Dean fbe1357755 Merge pull request #22665 from JJenkx/fix/agc-sampler-reduction-mode-3-blends
fix(agc): sample S# filter mode 3 as a weighted average
2026-11-26 21:29:19 +13:00
Luk Hicken 0ad621e974 docs(debt): shorten libSceAbstractTwitter entry below 1000 chars 2026-11-26 09:09:03 +01:00
Dean 7ceb9af236 Merge pull request #27293 from u-instinct11/fix/debt-report-label-filter
fix(tools): reject unknown technical debt report labels
2026-11-26 21:01:16 +13:00
LizardKing 87f0e47be5 fix(avplayer): use precise waits for video buffer recycling (#21718)
* fix(avplayer): use precise waits for video buffer recycling
* test(avplayer): check video buffer wait accuracy
* fix(avplayer): export wait observer on ELF hosts
2026-11-26 20:48:15 +13:00
Dean 71dc93ee86 Merge pull request #27289 from u-instinct11/fix/trace-diff-markdown-names
fix(tools): preserve trace diff table cells for multiline names
2026-11-26 20:42:49 +13:00
Dean b44a8d362a Merge pull request #23060 from oneandonlydean/fix/audio-out-port-bounds-dummy-driver
fix(libSceAudioOut): run guest_audio_out_port_bounds with the dummy audio driver
2026-11-26 20:34:26 +13:00
Dean 9ea334b918 Merge pull request #27334 from Ducengarth/docs/libfontconfig-nonfinite-format
docs(libfontconfig): record host-dependent negative NaN formatting
2026-11-26 20:16:00 +13:00
Dean 347e125709 Merge pull request #27332 from ThomasRuss/fix/guest-pointer-audit-closing-paren
fix(tools): audit dereferences after a closing parenthesis
2026-11-26 20:15:37 +13:00
Dean 8e53bb8c80 Merge pull request #27318 from u-instinct11/docs/sanitizer-report-json-status
docs(build): document sanitizer triage output and exit codes
2026-11-26 20:15:10 +13:00
Dean 03273f598b Merge pull request #27317 from u-instinct11/docs/progress-diff-state-changes
docs(progress): explain symbol transitions in snapshot diffs
2026-11-26 20:14:45 +13:00
Dean 4cfb4c4609 Merge pull request #27316 from u-instinct11/docs/offline-module-symbol-json
docs(reversing): show how to extract module symbols as JSON
2026-11-26 20:14:17 +13:00
Dean 70cf5d5117 Merge pull request #27315 from u-instinct11/docs/bug-report-preview
docs(usage): document bug report bundle preview
2026-11-26 20:13:53 +13:00
Scushi 0f49b14b0f feat(relinker): route ps5-payload-dev pathconf stub to libkernel export (#10792)
* feat(relinker): route ps5-payload-dev pathconf stub to libkernel export
* feat(relinker): route ps5-payload-dev pathconf stub in bundled guest modules
* feat(relinker): restrict pathconf route candidates to zero-addend function pointers
* refactor(relinker): share the pathconf import matchers between main and guest routes
* fix(relinker): drop the ordinary trap mirror into the NID filter text copy
* test(relinker): cover game patches overlapping the routed pathconf stub
2026-11-26 20:02:17 +13:00
Dean 4f2aade172 Merge pull request #27349 from aKazm1/docs/shader-null-image-gfx1013
docs(shader): record image_load through null and type 0/1 descriptors on gfx1013
2026-11-26 19:59:23 +13:00
0a2b81ed60 feat(libSceIcu): implement the uhash hash table exports (#20373)
* feat(libSceIcu): implement the uhash hash table exports
* docs(libSceIcu): carry the ICU notices of uhash_us.cpp, ustring.cpp and uhash.h in HashTable.cpp
* fix(libSceIcu): rename the guest deleter alias so it does not clash with ICU's UObjectDeleter

Co-authored-by: pr-review4 <pr-review4@users.noreply.github.com>
Co-authored-by: Dean <158058829+oneandonlydean@users.noreply.github.com>
2026-11-26 19:56:31 +13:00
adriaespiiandDean Galvin 2139209b0e feat(libSceNKWebKit): implement WKFormSubmissionListenerContinue (#15184)
* feat(libSceNKWebKit): implement WKFormSubmissionListenerContinue
* fix(libSceNKWebKit): drop the stray conflict marker above TestAuthentication

Co-authored-by: Dean Galvin <dean.galvin@live.com>
2026-11-26 19:56:08 +13:00
JJenkx 4888406e7c docs: clarify trace loss and inclusive performance totals 2026-11-26 01:52:20 -05:00
david-ojah 566a099e93 fix(tools): accept only bare compiler wrapper prefixes 2026-11-26 12:12:26 +05:30
gurtgg b1203944cb feat(libSceContentSearch): implement offline application index, metadata checks, and AV event enable 2026-11-26 07:41:40 +01:00
Suganthan 2720f4ba47 fix(tools): retain event-loss warnings in whole-capture trace diffs 2026-11-26 12:00:40 +05:30
david-ojah c9264b675a fix(tools): reject wrapper management modes and malformed forwarding 2026-11-26 11:45:05 +05:30
Daniel 6e6c378313 fix(tools): refuse pr_overlap --names with whitespace or control characters
A name that carries a line ending or other whitespace matches no export, so the lookup answered 'no matching PS5 export' and 'no matching PS5 export changes' for it, which reads as nobody working on the function. Names read from a CRLF file through command substitution arrive this way. The lookup now stops before any request and lists the arguments.
2026-11-26 07:05:08 +01:00
Dean f171065f7e Merge pull request #27262 from oneandonlydean/diag/agc-epoch-proof-counts
feat(agc): print the resource proof counts with APS5_PIPELINE_STATS
2026-11-26 18:54:48 +13:00
Dean 0f5a22da0a Merge pull request #27216 from aKazm1/feat/audiopropagation-source-render
feat(libSceAudioPropagation): render three-point material paths from console measurements
2026-11-26 18:54:25 +13:00
Dean 05774d2901 Merge pull request #27006 from mcarkade/feat/frame-replay-sweep-report
feat(tools): summarize saved frame replay sweeps
2026-11-26 18:53:52 +13:00
theGodspeed 281042c4b0 fix(libSceLibreSsl3): re-land the ASN.1 and EC guest pointer copies without the Windows failures (#22448)
* fix(libSceLibreSsl3): re-land the ASN.1 and EC guest pointer copies without the Windows failures
* fix(libSceLibreSsl3): read d2i_ASN1_INTEGER content from guest memory in 64 KiB chunks
* fix(libSceLibreSsl3): refuse EC DER lengths the guest copy cannot take and follow the private naming rule
* fix(libSceLibreSsl3): refuse EC DER ranges that wrap the address space and keep the cursor on failed decodes
* fix(libSceLibreSsl3): refuse a guest range that wraps the address space in the ASN.1 input reader
* fix(libSceLibreSsl3): bound EC input copies and probe guest writes before changing state
* fix(libSceLibreSsl3): keep the caller's EC key and ASN.1 outputs unchanged when a decode fails
* fix(libSceLibreSsl3): stage caller-visible changes of the ASN.1 and EC decoders until the input has been validated
* fix(libSceLibreSsl3): read only the bytes an EC parameters encoding needs and fix the debt fragment
* fix(libSceLibreSsl3): reset a released ASN.1 integer before freeing it
* test(libSceLibreSsl3): cover d2i_ECParameters with caller pointers that cannot be written
* fix(libSceLibreSsl3): advance the o2i_ECPublicKey cursor by the bytes it validated
* refactor(libSceLibreSsl3): return the decoded EC group as an owning pointer
* fix(libSceLibreSsl3): write the d2i_ECParameters cursor last so a faulting write leaves it unchanged
* fix(libSceLibreSsl3): write the d2i_ASN1_INTEGER cursor last so a faulting write leaves it unchanged
* fix(libSceLibreSsl3): report a failed restore of a caller slot instead of ignoring it
* fix(libSceLibreSsl3): check the EC point and key allocations before using them
* fix(libSceLibreSsl3): check the DER length limit before multiplying so an oversized length field cannot overflow
* fix(libSceLibreSsl3): return a malloc error for a failed staging buffer, preflight outputs without reading them, stop the EC length scan at an invalid header
* test(libSceLibreSsl3): drop the allocation hook that cannot reach the library and note the unexercised path
* test(libressl3): cover unwritable cursor in ASN1_get_object; link upstream commits in licence headers
* docs(libressl3): name the derived LibreSSL commit and the pinned licence commit in IntegerDecoder.cpp
2026-11-26 18:53:28 +13:00
Dean fd6813883a Merge pull request #22432 from milescoviello/fix/spanned-report-root
fix(shader): name the per-invocation value behind a spanned-wave fallback
2026-11-26 18:53:05 +13:00
Dean 9829a8d6ce Merge pull request #22384 from NWProgramming00/fix/shader-f64-transcendental-denormals
fix(shader): flush v_rcp_f64, v_rsq_f64 and v_sqrt_f64 denormals by the f64 field
2026-11-26 18:52:42 +13:00
Dean 53707503a3 Merge pull request #22383 from NWProgramming00/fix/shader-transcendental-f32-output-modifier
fix(shader): apply the output modifier on f32 transcendentals with denormals kept
2026-11-26 18:52:18 +13:00
JJenkxandDean Galvin 252ca8cbc8 fix(libc): ignore the scan lengths the bundled libc.prx ignores (#18768)
* fix(libc): ignore the scan lengths the bundled libc.prx ignores
* fix(libc): store a float for wide floating scans with other lengths
* test(libc): cover ignored scan lengths through plain sscanf and vsscanf
* docs(libc): end the scan length debt sentence and split a test line

Co-authored-by: Dean Galvin <dean.galvin@live.com>
2026-11-26 18:51:54 +13:00
Ondřej 85e6513669 fix(libc): preserve errno in Windows floating string scans (#18405) 2026-11-26 18:51:30 +13:00
Dean 3cbefe23e5 Merge pull request #18193 from akkadbakkad89/feat/npcommon-heap-alloc-utf8
feat(libSceNpCommon): implement heap, allocator and UTF-8 helpers
2026-11-26 18:51:07 +13:00
Dean 87d2a6998a Merge pull request #17493 from slopgobblercobbler/slopgobblercobbler/pr-libkernel-madvise-flags
test(libkernel): audit madvise advice flags and memory alignment boundaries
2026-11-26 18:50:44 +13:00
Dean d5b7dccd75 Merge pull request #27247 from malekaifa/prime-e/fix-move-open-validation-precedence-20261125
fix(libSceMove): preserve sceMoveOpen validation precedence
2026-11-26 18:40:35 +13:00
Dean 11952ab7d1 Merge pull request #20800 from babuakhil/fix/libscesdma-reject-unknown-handles
fix(libSceSdma): reject handles sceSdmaOpen did not return
2026-11-26 18:27:44 +13:00
Dean 74e0544c5e Merge pull request #27267 from LeandroLP23/refactor/nkwreq-guest-copy-errno
refactor(nkwebkitrequirements): drop errno saves around guest copies
2026-11-26 18:15:11 +13:00
Dean 16b4745e6b Merge pull request #26386 from RuiRDA/codex/nkwebkit-webvtt-json
feat(libSceNKWebKit): serialize ISO WebVTT cues to JSON
2026-11-26 18:14:49 +13:00
Dean 08499618b9 Merge pull request #27266 from LeandroLP23/refactor/videoout-guest-copy-errno
refactor(videoout): drop errno saves around guest copies
2026-11-26 18:07:06 +13:00
Dean f66f29a8c7 Merge pull request #27265 from LeandroLP23/refactor/ime-guest-copy-errno
refactor(ime): drop errno saves around guest copies
2026-11-26 17:56:36 +13:00
AngrySandhillandCursor 2e9ad2176d fix(libSceSharePlay): shorten the disconnected-export debt entry
The additional-export note was over the debt length limit.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-25 23:44:47 -05:00
Dean f6a952a390 Merge pull request #27221 from zaryabzip/feat/content-export-progress-checks
feat(libSceContentExport): local checks for GetProgress, ValidateContents and two exports
2026-11-26 17:44:06 +13:00
AngrySandhillandCursor d2358a9de7 fix(libSceSharePlay): report a disconnected service after initialization
The host never connects, so the calls that wait for connection state 2 keep returning 0x810E0004, and 6egMR0eB8RU keeps returning 1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-25 23:44:05 -05:00
Dean 8deb9bf1d8 Merge pull request #27261 from LeandroLP23/refactor/ajmn-guest-copy-errno
refactor(ajm): drop errno saves around guest copies
2026-11-26 17:36:21 +13:00
GabbeHags ae71b314d2 perf(shader): keep specialized SPIR-V in the shader disk cache (#26800)
* perf(shader): keep specialized SPIR-V in the shader disk cache
* fix(shader): key specialized SPIR-V on recompiler switches and image offsets
* fix(shader): key specialized SPIR-V on vertex patches and stencil references
2026-11-26 17:27:49 +13:00
Capmare David Nicusor 188b331cb0 perf(agc): keep a reused image table's cache entries while none was erased (#25443)
* perf(agc): keep a reused image table's cache entries while none was erased
* test(agc): let the entry memo test reuse the table before it counts memo hits
2026-11-26 17:27:21 +13:00
Federico Marras a688704386 feat(libSceLibcInternal): complete global locale lifecycle (#22370)
* feat(libSceLibcInternal): complete global locale lifecycle
* fix(libSceLibcInternal): keep the global locale alive while its facets are used
2026-11-26 17:26:57 +13:00
Dean 79671599ba Merge pull request #22309 from NWProgramming00/fix/shader-rcp-f32-denormal-result
fix(shader): flush v_rcp_f32 denormal results to a signed zero
2026-11-26 17:26:33 +13:00
VicRasterandembersas 1c185cb8fa fix(agc): ignore unchanged import touches in stored-range checks (#22306)
* fix(agc): publish multisample depth over pages only an import window touched
* fix(agc): ignore import window touches beside stored pages in depth publication
* fix(agc): ignore unchanged import touches in stored-range checks
* test(agc): respect host import watch policy
* test(agc): drain recorder before import-touch skip
* docs(agc): keep import-touch debt entries concise

Co-authored-by: embersas <30363137+embersas@users.noreply.github.com>
2026-11-26 17:26:10 +13:00
Dean fe7b36bba5 Merge pull request #22291 from Gruzzberry/claude/libcinternal-initonce-guest-ptr-ed41d2
fix(libSceLibcInternal): copy __std_init_once_begin_initialize pending out-param through GuestCopyOut
2026-11-26 17:23:11 +13:00
Dean 475af66f0a Merge pull request #22212 from Kikoarl/fix/libSceAgc-create-shader-dst-pointer
fix(libSceAgc): validate and safely copy shader destination pointer in sceAgcCreateShader
2026-11-26 17:22:49 +13:00
Coco 74b96e4473 feat(libkernel): share a ksem semaphore across dup, dup2 and F_DUPFD, as FreeBSD 11.4 does (#22191)
* feat(libkernel): share a ksem semaphore across dup, dup2 and F_DUPFD, as FreeBSD 11.4 does
* fix(libkernel): keep IsKsemDescriptor for the callers outside Stdio.cpp
* fix(libkernel): stat and chmod a destroyed ksem through its other descriptors
* fix(libkernel): recheck a ksem's dead mark under its lock
2026-11-26 17:22:25 +13:00
xXPBSXx 7a83873efb fix(libc): fpurge keeps the logical read position and the pushed-back bytes as the console does (#22143)
* test(libc): pin fpurge keeping the logical read position and the pushback as measured on the console
* fix(libc): fpurge keeps the logical read position and the pushed-back bytes as the console does
* docs(debt): state the console result for fpurge and what it left open
2026-11-26 17:22:02 +13:00
Dean 4c69f9cd8d Merge pull request #22138 from domx4q/fix/gnm-draw-guest-pointers
fix(libSceGnmDriver): write draw packets through guest copies
2026-11-26 17:21:39 +13:00
Dean 00e486017c Merge pull request #22067 from nicolasabosch/fix/agc-poll-sleep-timer-close
fix(agc): close the poll sleep timer when its thread exits
2026-11-26 17:21:16 +13:00
Dean 8c3c49fc33 Merge pull request #22066 from nicolasabosch/fix/agc-idle-epoch-under-mutex
fix(agc): publish the idle epoch under the driver mutex before waking waiters
2026-11-26 17:20:53 +13:00
chitters2004 40f4779538 fix(agc): read an awaited slot only while its wait is still published (#22026)
* fix(agc): read an awaited slot only while its wait is still published
* fix(agc): count queues as parked only if no worker moved during the check
2026-11-26 17:20:30 +13:00
Dean fb0e5f3b76 Merge pull request #19060 from mjnhbg3/codex/ampr-native-file-reads
feat(libSceAmpr): record and execute native file reads
2026-11-26 17:20:08 +13:00
MauriceSiriusandMauriceSirius 9fcb92db32 fix(libSceAgc): write the console's pop marker tag (#19051)
* fix(libSceAgc): write the console's pop marker tag
* test(libSceAgcDriver): recalibrate job manager compute pins for the console pop marker tag

Co-authored-by: MauriceSirius <MauriceSirius@users.noreply.github.com>
2026-11-26 17:19:45 +13:00
Dean e7a7f42b67 Merge pull request #27264 from david-ojah/fix/gfx1013-reference-form-invariant
fix(tools): reject gfx1013 modified forms without a base form
2026-11-26 17:16:59 +13:00
Robbie AcostaandClaude Opus 5.5 f777c5ef8f test(libSceSystemLogger2): check an event record that runs into a guard page
The debt file still said the Set*EventAsync entry points read the event
record in place and crash on a partially mapped record, but #19627 moved
validation to guest copies. Nothing tested that case beyond pointer 0x10.

The new check ends the readable bytes inside the inline entry name at
+0xD0: a name terminated just before the guard page is accepted, and one
running into it returns 0x818C0002 without writing the status or
changing errno. The guard page setup of the timestamp check is shared.

The debt fragment removes the stale entry and records the coverage.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:50:47 -05:00
Dean caea6ce5ce Merge pull request #27213 from u-instinct11/docs/interval-csv-spreadsheets
docs(tracing): explain spreadsheet-safe interval exports
2026-11-26 16:37:02 +13:00
Dean cc0d460db4 Merge pull request #27212 from u-instinct11/docs/script-registration-audit
docs(build): explain the Python test registration audit
2026-11-26 16:36:38 +13:00
Dean 4a1190ffb1 Merge pull request #27211 from u-instinct11/fix/nid-symbol-file-error-path
fix(tools): identify invalid NID symbol lists
2026-11-26 16:36:15 +13:00
Dean d58ecf4310 Merge pull request #27007 from mcarkade/feat/reproducible-release-archives
feat(package): reproduce native and web release archives
2026-11-26 16:35:52 +13:00
xXPBSXxandClaude Sonnet 5.5 e27c8d26e1 docs(debt): record the measured error outputs of the SJIS to UTF-8 and JIS X 0208 helpers
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 04:32:32 +01:00
xXPBSXxandClaude Sonnet 5.5 a14a2662e9 fix(libSceCesCs): write the measured error outputs of the SJIS to UTF-8 and JIS X 0208 helpers
sceCesSJisToUtf8 answers INVALID_PROFILE for a null profile and clears both
lengths for a null profile or a null source. sceCesSJisCodeToJisX0208 zeroes ku
and ten on failure and answers UNSUPPORTED_CODE for 0x0020. sceCesJisX0208ToSJisCode
answers 0x805C0015 and zeroes the code for the measured cells (0, 1), (1, 0),
(1, 95) and (93, 95) and stores 0xF040 for (95, 1); other cells are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 04:32:29 +01:00
xXPBSXxandClaude Sonnet 5.5 c988c12008 docs(debt): record measured Opus encoder Ctl and SilkEncCancel state errors
Amend the existing feat-opus-encoder-ctl fragment (no second fragment): a PS5
(firmware 11.60, payload process; a title process may differ) rejected a
zero-filled 512 byte state with 0x813F0016 (Celt) and 0x81770015 (Silk) for
-1, 4000 to 4003, 4028 and 4031, and a null state with 0x813F0001 and
0x81770001, writing nothing; sceOpusSilkEncCancel with a zero-filled state
returned 0x80930001 with errno 49 where this throws. Prototypes assumed, n=1,
not a real encoder state; request values and GET writes against a valid state
stay unmeasured.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 04:32:11 +01:00
xXPBSXxandClaude Sonnet 5.5 17c75f2c40 test(libSceCesCs): pin the measured error outputs of the SJIS to UTF-8 and JIS X 0208 helpers
Pins what the console wrote in two identical runs of libSceCesCs_sjis_eucjp
(payload process, firmware 11.60, cases g.4, g.5, f.3, f.5, f.9, f.10, f.11,
f.12, f.14): sceCesSJisToUtf8 with a NULL profile answers INVALID_PROFILE and
clears the length outputs, with a NULL source it clears them too, the JIS X 0208
helpers zero their outputs on failure, 0x0020 answers UNSUPPORTED_CODE, and the
measured out-of-range cells answer 0x805C0015 (the single (95, 1) point also
stores 0xF040).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 04:28:00 +01:00
Getulioandpr-review3 716366d58b feat(libSceLibreSsl3): implement d2i_ASN1_SEQUENCE_ANY (#18284)
* feat(libSceLibreSsl3): implement d2i_ASN1_SEQUENCE_ANY
* docs(libSceLibreSsl3): count the additional exports once and drop resurrected rows after merging main

Co-authored-by: pr-review3 <pr-review3@ps5team>
2026-11-26 16:05:43 +13:00
Dean b7e8918ab5 Merge pull request #27294 from u-instinct11/docs/windows-sample-windows
docs(tracing): show how to isolate a Windows sampling window
2026-11-26 15:57:27 +13:00
Dean 63c4e66d17 Merge pull request #27292 from u-instinct11/docs/compile-database-variants
docs(build): explain compilation database inventory variants
2026-11-26 15:57:04 +13:00
Dean 9d82f69557 Merge pull request #27291 from u-instinct11/docs/pad-preview-repeat-timing
docs(input): explain repeat timing in controller previews
2026-11-26 15:56:41 +13:00
Siddhant Singh 427c2a67de docs(tracing): explain selecting captures for performance CSV 2026-11-26 08:25:23 +05:30
Dean a5bd6fad0d Merge pull request #27290 from u-instinct11/docs/trace-diff-scene-windows
docs(testing): explain how to align trace comparison windows
2026-11-26 15:53:46 +13:00
gnavarro24 65eaf885f8 feat(libkernel): implement execl, execle and execlp (#26238)
* feat(libkernel): implement execl, execle and execlp
* fix(libkernel): throw NotImplemented for execl, execle and execlp on Windows
* fix(libkernel): read execl, execle and execlp arguments in place and implement them on Windows
* test(libkernel): cover execl arguments past the register slots
* chore: rerun the checks
2026-11-26 15:52:45 +13:00
Dean 9a34ca56fa Merge pull request #21965 from kurexw/test/agc-recorder-portability-subset-once
test(agc): enable VK_KHR_portability_subset once in the Recorder test device
2026-11-26 15:52:23 +13:00
Dean f15ddb4c3e Merge pull request #21963 from muhmuhkuh/crew/ds2-perf/ab-multi-arm
feat(agc): run more than two arms in the APS5_AB schedule
2026-11-26 15:52:01 +13:00
klosixgaming-arch 1532d7c59b fix(agc): capture GPU-only allocations in frame captures (#21931) 2026-11-26 15:51:40 +13:00
Dean 0d3b9652d8 Merge pull request #21925 from AlfaRojo/fix/shader-buffer-short-dword-straddle
fix(shader): read a 16-bit buffer load that crosses a dword boundary from both dwords
2026-11-26 15:51:18 +13:00
Dean 186d689d42 Merge pull request #21165 from zaryabzip/fix/videoout-display-position-checks
fix(videoout): check the display-position event calls as firmware 13.42 does
2026-11-26 15:50:51 +13:00
Siddhant Singh baa525906a docs(build): explain configure seed filter matching 2026-11-26 08:20:39 +05:30
Siddhant Singh e0ddd584dc docs(reversing): explain address fields in PE symbol inventories 2026-11-26 08:20:39 +05:30
Siddhant Singh 8e548e347d docs(usage): document patch catalog validation JSON 2026-11-26 08:20:39 +05:30
Siddhant Singh 93d029710d fix(tools): reject nonregular controller preview paths 2026-11-26 08:20:38 +05:30
Siddhant Singh 1f42cacc1f fix(tools): preserve whitespace in branch sync worktree paths 2026-11-26 08:20:38 +05:30
Siddhant Singh f9d4a9d698 docs(input): explain what pulse preview reads from the command file 2026-11-26 08:20:38 +05:30
Siddhant Singh 69194282dd docs(testing): explain strict branch sync checks 2026-11-26 08:20:38 +05:30
Dean 1e237d296f Merge pull request #21912 from amazedturnip/fix/libkernel-spinlock-guest-pointer
fix(libkernel): validate guest spin lock pointer in pthread_spin_trylock and pthread_spin_lock
2026-11-26 15:42:59 +13:00
Dean 42ec806821 Merge pull request #21773 from dantdmdarealguy/agent/winwarn3
fix(agc): give the device-lost hook lambda an empty parameter list
2026-11-26 15:42:37 +13:00
Dean 1ec7889fd9 Merge pull request #27192 from milescoviello/test/http-create-named-children
test(libSceHttp): check sceHttpCreateConnection, sceHttpCreateRequest and sceHttpCreateRequestWithURL2
2026-11-26 15:39:45 +13:00
xXPBSXx 33f94ac4e0 fix(libSceAudioOut): refuse a null attribute list in sceAudioOut2ContextSetAttributes with the console code (#18401)
* test(libSceAudioOut): pin the console answer of sceAudioOut2ContextSetAttributes for a null attribute list
* fix(libSceAudioOut): refuse a null attribute list in sceAudioOut2ContextSetAttributes with the console code
* docs(libSceAudioOut): record the sceAudioOut2ContextSetAttributes measurement
* test(libSceAudioOut): expect the console answer for a null attribute list in the device state and timing tests
2026-11-26 15:39:12 +13:00
Dean 8a4371011a Merge pull request #18380 from Ondra97/codex/fix-windows-sscanf-hex-prefix
fix(libc): reject incomplete hex prefixes in Windows sscanf
2026-11-26 15:38:49 +13:00
Dean 8697dade49 Merge pull request #18245 from Kikoarl/feat/shader-sdwa-v-cvt-norm-u16-f16
feat(shader): accept SDWA byte destination selectors on v_cvt_norm_u16_f16
2026-11-26 15:38:27 +13:00
Dean fa112a44c7 Merge pull request #18139 from 011010/fix/agc-fs-table-macos-pr
fix(libSceAgcDriver): link FS table calls on macOS
2026-11-26 15:38:04 +13:00
Dean ea4aadc321 Merge pull request #25575 from JJenkx/fix/libSceJson2-object-guest-pointers
fix(libSceJson2): validate guest pointers in Object, Pair and Object::iterator exports
2026-11-26 15:15:45 +13:00
Zaryab Gohar 71e6452fcf feat(sysmodule): answer IsCameraPreloaded and forward UnloadModuleByNameInternal (#22362)
* feat(sysmodule): answer IsCameraPreloaded and forward UnloadModuleByNameInternal
* test(sysmodule): check IsCameraPreloaded with the by-name rows, clear of #18184
* test(sysmodule): keep main's final unload row so the test merges with #18184
* refactor(sysmodule): move the libkernel_sys include clear of #27111's hunk
2026-11-26 15:13:04 +13:00
Zaryab Gohar 821a1cd7e0 feat(padtracker): answer Init, Term, Calibrate and ReadState from the firmware checks (#22349)
* feat(padtracker): answer Init, Term, Calibrate and ReadState from the firmware checks
* test(padtracker): align the working memory at run time so the test builds on Windows
2026-11-26 15:12:41 +13:00
Herolias 397655dac0 feat(libc): wire the numpunct<char> facet vtable and its members (#21930)
* feat(libc): wire the numpunct<char> facet vtable and its members
* refactor(libc): check the numpunct<char> string block before copying
2026-11-26 15:12:19 +13:00
Dean a667242651 Merge pull request #27381 from oneandonlydean/lead/fix-kernelweb-gpi
fix(libkernel_web): answer __sceKernelGetGPI without importing its own export
2026-11-26 15:04:52 +13:00
Dean a0f9b2b7ac fix(libkernel_web): answer __sceKernelGetGPI without importing its own export
libkernel_web forwarded __sceKernelGetGPI to the libkernel_sys export of
the same NID, which it also exports, so patched_self_imports failed on main
since #26609. Call sceKernelGetGPI, which the libkernel_sys export returns.
2026-11-26 14:57:23 +13:00
xXPBSXxandClaude Sonnet 5.5 7e30c657b2 docs(libScePngDec): record the rows written for truncated IDAT streams on firmware 11.60
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 02:55:20 +01:00
Yunus Shaikh 9e5960f6b2 Merge main into fix/shader-pointer-key-lane-masks 2026-11-25 17:53:03 -08:00
Dean f924e4f454 Merge pull request #21762 from AasishDairelSahayaGrinspan/fix/relinker-rosetta-wide-stores
fix(relinker): lower unaligned 256-bit stores for --to-rosetta
2026-11-26 14:39:06 +13:00
Dean e1eafc481a Merge pull request #21728 from AasishDairelSahayaGrinspan/fix/relinker-macos-qualified-imports
fix(relinker): emit module-qualified guest imports in macOS output
2026-11-26 14:38:43 +13:00
Dean 03a9ad0b3f Merge pull request #19577 from Nawid3333/feat/integer-dpp-sdwa-source-modifiers-r2
feat(shader): accept neg/abs on 32-bit integer DPP and SDWA sources
2026-11-26 14:38:20 +13:00
hugodearaujo 19d95af86d fix(shader): charge nested parent records once per scan of the same records (#19564) 2026-11-26 14:37:52 +13:00
Dean 0f07aca237 Merge pull request #19542 from edubox/feat/libSceHubAppUtil-not-available
feat(libSceHubAppUtil): reproduce the firmware not-available returns
2026-11-26 14:37:29 +13:00
Dean 702322f402 Merge pull request #26782 from MarcZX10/fix/tests-cmake-windows-paths
test(tools): pass CMake compiler and Ninja paths with forward slashes
2026-11-26 14:34:43 +13:00
Dean 199cb26112 Merge pull request #27215 from heditrigui/feat/freetype-ot-variant-selectors-forward
feat(libSceFreeTypeOt): forward FT_Face_GetCharsOfVariant, FT_Face_GetVariantSelectors and FT_Face_GetVariantsOfChar on Windows
2026-11-26 14:31:57 +13:00
Dean 029741c05a Merge pull request #21720 from XIIYAZ/fix/libc-stream-scan-malformed-float-macos
fix(libc): fail a stream float scan of an empty hex prefix or a truncated infinity on macOS
2026-11-26 14:31:34 +13:00
Stephen Cork 9112746dfe test(libkernel): audit socket type, error, and boolean option bounds (#21024) 2026-11-26 14:31:12 +13:00
Stephen Cork f802dc507e test(libSceSaveData): audit progress polling, cancel recovery, and mount result layout (#20860) 2026-11-26 14:30:49 +13:00
Dean 57b9df8c59 Merge pull request #18476 from THEMANnt/fix/libkernel-accept-sce-net
fix(libkernel): accept connections on libSceNet sockets
2026-11-26 14:30:26 +13:00
Dean 0960aae522 Merge pull request #27378 from oneandonlydean/lead/fix-ftw-self-imports
fix(libScePosixForWebKit): walk directories without importing the library's own exports
2026-11-26 14:14:48 +13:00
Dean f9494a2f01 Merge pull request #26998 from malekaifa/prime-d/pe-import-null-descriptor-20261125
fix(nid): validate PE import terminator
2026-11-26 14:10:03 +13:00
Dean 6d99aa96a5 Merge pull request #26884 from heditrigui/feat/nkwebkit-bundle-node-handle-autofill-button-type
feat(libSceNKWebKit): implement WKBundleNodeHandle autofill button type operations
2026-11-26 14:09:41 +13:00
Dean fe5d474052 Merge pull request #26883 from malekaifa/prime-d/nid-rela-layout-20261125
fix(nid): validate relocation section layout
2026-11-26 14:09:19 +13:00
Dean fb12b51efd Merge pull request #26618 from Zedas030/feat/libc-numeric-limits
feat(libc): export the std::numeric_limits constants
2026-11-26 14:08:57 +13:00
nexus7super-ship-itandpr-review3 ae1ecaf41d feat(libSceLibcInternal): implement std::exception::_Set_raise_handler (#19767)
* feat(libSceLibcInternal): implement std::exception::_Set_raise_handler
* docs(libSceLibcInternal): drop the older ctype bullet that main replaced after the facet-table fix

Co-authored-by: pr-review3 <pr-review3@ps5team>
2026-11-26 14:08:35 +13:00
Dean 680b92fc3b Merge pull request #25296 from mcarkade/fix/guest-tests-changed-python-wrappers
fix(tools): run the tests whose Python wrapper a change touches
2026-11-26 14:00:54 +13:00
Dean 4648690d8b Merge pull request #25095 from gurtgg/fix-libressl3-object-nid-before-zero-length
fix(libSceLibreSsl3): check ASN1_OBJECT nid before length in ObjectNid
2026-11-26 14:00:26 +13:00
Dean 15d71d9bb1 fix(libScePosixForWebKit): walk directories without importing the library's own exports
ftw called libc opendir, readdir and closedir, whose NIDs this library
also exports, so patched_self_imports failed on main since #26505. Use the
internal directory helpers, as the other walker in this library does.
2026-11-26 13:58:18 +13:00
Blazing Cook c14d6b3753 fix(test): restore standalone shared-memory test linking
Add CopyGuestPath_nid_no_patch function to copy string paths with validation.
2026-11-26 00:53:45 +00:00
Dean 9575c64efe Merge pull request #26609 from shripad-jyothinath/feat/libkernel-sys-get-gpi
feat(libkernel_sys): implement __sceKernelGetGPI export and web forward
2026-11-26 13:39:42 +13:00
Gordon 8a770ff1cd feat(libSceJsc): implement WTFLogAlwaysV (#26413)
* feat(libSceJsc): implement WTFLogAlwaysV
* fix(libSceJsc): include WtfAssertionsExports.hpp from the library umbrella
2026-11-26 13:39:18 +13:00
Dean 6db3df7477 Merge pull request #26253 from DiogoPCastelos/fix/icu-delete-uobject-guest-abi
fix(libSceIcu): delete guest UObjects through their System V vtable
2026-11-26 13:38:56 +13:00
Federico Marras f2198b4245 fix(libSceAppContent): preserve ownership of shared add-on mount aliases (#26229)
* fix(libSceAppContent): preserve ownership of shared add-on mount aliases
* test(libSceAppContent): cover ASCII case folding in mount alias collision
* test(libSceAppContent): remount the trailing-slash alias after the case-folded one
2026-11-26 13:38:38 +13:00
Dean b965a151a1 Merge pull request #26153 from IvanFogel/feat/20261123/pfs-stored-block-reads
feat(pfs): read stored blocks from PFSC v2 and v3 images
2026-11-26 13:38:10 +13:00
Dean d1e105fe8b Merge pull request #25988 from malekaifa/prime-f/fix-rudp-internal-io-thread-state-20261123
fix(libSceRudp): track internal I/O thread state
2026-11-26 13:37:46 +13:00
Dean e95dfb87b5 Merge pull request #25857 from mihai1859/codex/implement-libcxx-regex-dot
feat(libc): implement libc++ narrow regex dot matcher
2026-11-26 13:37:22 +13:00
Dean 15cd49fe86 Merge pull request #27208 from u-instinct11/fix/memory-trace-error-location
fix(tools): name corrupt memory trace files
2026-11-26 13:34:34 +13:00
RavenCurseBurg cb041fc82a test(libkernel): touch resident pages and allow an earlier RSS peak
AI-assisted: Codex + GPT-6.2 Astra (xhigh)
2026-11-26 10:31:39 +10:00
Dean fd472ded36 Merge pull request #27205 from milescoviello/test/kernel-get-proc-param
test(libkernel): check that sceKernelGetProcParam returns the process parameter block
2026-11-26 13:24:07 +13:00
Dean 4eee650043 Merge pull request #25090 from MarrasFederico/test/libc-runtime-combined
test(libc): cover file locks and atomic compare-exchange widths
2026-11-26 13:23:45 +13:00
Jagrat Singh c260d53897 feat(libSceNKWebKit): implement WKUserMediaPermissionCheckSetUserMediaAccessInfo (#24457) 2026-11-26 13:23:23 +13:00
Dean cf76855f20 Merge pull request #27206 from muhmuhkuh/fix/videoout-resting-mouse-keeps-pad-stick
fix(libSceVideoOut): keep the controller stick while the mouse rests in mouse mode
2026-11-26 13:01:01 +13:00
Dean 56bdd0efd9 Merge pull request #27198 from JJenkx/windows/shader-med3-f16-key-median
perf(shader): order v_med3_f16 operands once in the integer key domain
2026-11-26 13:00:39 +13:00
Dean 23a77dca5e Merge pull request #27187 from oneandonlydean/fix/performance-compare-summary-every
fix(tools): compare periodic summary rows without their first present counter
2026-11-26 13:00:17 +13:00
Dean b5ed908ae3 Merge pull request #24889 from alexander-src/perf/nid-names-scan
perf(tools): scan non-code tokens and skip ignored scopes in nid_names
2026-11-26 12:47:29 +13:00
Dean 684ee92a95 Merge pull request #26718 from root-over/perf/agc-label-imports
perf(agc): record unimported labels in large allocations through a 64 KiB import window
2026-11-26 12:32:32 +13:00
Dean 65ff3ae335 Merge pull request #23347 from Thimo188/fix/posix-pthread-setschedparam-np
fix(libScePosixForWebKit): implement SCHED_OTHER wrapper
2026-11-26 12:22:04 +13:00
Dean 3aebc15679 Merge pull request #21658 from milescoviello/fix/font-guest-copies
fix(libSceFont): read and write guest font records through checked copies
2026-11-26 12:14:14 +13:00
Dean 5887173f70 Merge pull request #21598 from bobczan/fix/libressl-cmac-guest-buffers
fix(libSceLibreSsl): copy the CMAC message and tag through guest copies
2026-11-26 12:13:52 +13:00
VicRaster fc46c987ef fix(agc): import undrawn R_X DCC textures and their colour-target state (#21479)
* fix(agc): import initial R-swizzled multisample DCC texture clears
* fix(agc): let an undrawn texture DCC owner take its colour-target state
2026-11-26 12:13:28 +13:00
Adam FrankeandDean Galvin f7862cac59 feat(libkernel_sys): notify aio completions by signal or kevent and queue aio on sockets (#21463)
* feat(libkernel_sys): notify aio completions by signal or kevent and queue aio on sockets
* fix(libkernel_sys): take back an aio completion signal on free and finish cancelled socket requests
* docs(debt): name the SIGPIPE target in the aio entry
* test(libkernel_sys): fill the socket before the partial-write cancel check
* docs(debt): fold the aio_suspend EFAULT fragment into the aio entry
* test(libkernel_sys): drain the filled socket before checking a partial aio write
* test(libkernel_sys): let partial socket writes pass on hosts that take a whole write at once
* fix(libkernel): rebind an existing aio knote to the new request

Co-authored-by: Dean Galvin <dean.galvin@live.com>
2026-11-26 12:13:05 +13:00
db949debe9 fix(input-mapper): name setting fields without their hints
The setting hints sat inside the label that wraps each field, so screen
readers announced the range and built-in value as part of the field
name and again as its description. Name each field by its setting name
with aria-labelledby, keeping the hint and help text as description.

MouseSensitivity accepts values above 0 but its hint read 0–10. Replace
its special case with a generic exclusive minimum, used both by the
validation and by the hint, which now reads 0 < x ≤ 10. The error
message is unchanged.

Co-authored-by: RavenCurseBurg <360931527+RavenCurseBurg@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted: yes
2026-11-26 00:10:34 +01:00
gnavarro24 e136d87da8 feat(libScePosixForWebKit): implement ftw (#26505)
* feat(libScePosixForWebKit): implement ftw
* fix(libScePosixForWebKit): end ftw with ELOOP on a directory cycle
* docs(libScePosixForWebKit): describe the ftw cycle result
* fix(libScePosixForWebKit): report ftw directory read and close errors
2026-11-26 12:10:13 +13:00
Rody Da Cruz 550d05381e feat(libSceLibcInternal): implement _Strcollx 2026-11-25 22:07:58 -01:00
androidbaklava 42967e7ebb fix(agc): back large pixel LDS with the storage buffer on Intel's Windows driver (#21683) 2026-11-26 12:07:15 +13:00
Dean 294adacc21 Merge pull request #21528 from brumskysb/docs/agc-packed16-gfx1036
docs(debt): measure packed 16-bit store rounding and 4_4 nibbles on gfx1036
2026-11-26 12:06:52 +13:00
Dean cb3fb879bf Merge pull request #21451 from MarcZX10/fix/relinker-strict-pt-null
fix(relinker): skip PT_NULL headers in strict filter validation
2026-11-26 12:06:29 +13:00
Dean 15a4ed5ff9 Merge pull request #21376 from AdriaanBoshoff/fix/libSceAgc-cb-branch-console-encoding
fix(libSceAgc): encode sceAgcCbBranch register arguments as the console does
2026-11-26 12:06:07 +13:00
Dean 0c1be567b1 Merge pull request #21223 from MarcZX10/fix/relinker-report-scan-warning
fix(relinker): warn when the unconverted-module scan stops early
2026-11-26 12:05:43 +13:00
Dean b6f751e741 Merge pull request #21221 from MarcZX10/fix/relinker-skip-unreadable-candidates
fix(relinker): skip an unreadable sce_module file instead of aborting the conversion
2026-11-26 12:05:20 +13:00
Stephen Cork 247af7c5c4 test(libSceFiber): audit context attachment validation, multiple attachments, and post-detach state (#21145) 2026-11-26 12:04:57 +13:00
Stephen Cork 4954659d99 test(libkernel): audit socket options bounds and length validation (#20957) 2026-11-26 12:04:35 +13:00
Dean 4733605014 Merge pull request #22252 from fogydes/perf/tools-progress-multiprocessing
perf(tools): parallelize progress scanning and skip fetching present commits
2026-11-26 11:49:30 +13:00
gnavarro24 98f7c5d99f feat(libc): implement tsearch, tfind, tdelete and twalk (#26214)
* feat(libc): implement tsearch, tfind, tdelete and twalk
* fix(libc): register the tree search test by fragment
* fix(libc): return null from tsearch, tfind and tdelete for a null rootp
* test(libc): check twalk levels and the tdelete parent slot
* chore: rerun the checks
* test(libc): check that tdelete returns the parent slot two levels down
2026-11-26 11:46:43 +13:00
Dean 3f23e9df7d Merge pull request #27005 from mcarkade/feat/frame-replay-recipe-preflight
feat(tools): preflight pinned frame replay recipes
2026-11-26 11:41:33 +13:00
Dean 92c8d8be42 Merge pull request #27004 from mcarkade/feat/check-compile-ninja-headers
feat(tools): check header changes against Ninja dependencies
2026-11-26 11:38:25 +13:00
Dean 98d3c1ed3a Merge pull request #27003 from mcarkade/feat/ninja-compile-timing-inventory
feat(tools): add Ninja timings to compile inventory
2026-11-26 11:38:02 +13:00
Dean 1339dc06f9 Merge pull request #26838 from cookie42073-cmd/fix/progress-integrated-dependencies-20261124
fix(tools): skip stale dependencies for integrated PR heads
2026-11-26 11:37:40 +13:00
Dean 790711ecbf Merge pull request #26825 from cookie42073-cmd/fix/timeline-svg-label-text-20261124
fix(tools): sanitize text in trace timeline SVGs
2026-11-26 11:37:17 +13:00
Dean 60e8d83bd3 Merge pull request #24487 from brajankw/fix/libkernel-ksem-read-write-seek
fix(libkernel): fail read, write and seek on a ksem id as FreeBSD 11.4's ksem_ops does
2026-11-26 11:36:55 +13:00
Dean 499d5cb699 Merge pull request #27199 from Ducengarth/codex/freetype-ot-attach-file
fix(libSceFreeTypeOt): forward FT_Attach_File on Windows
2026-11-26 11:26:56 +13:00
RTGG 0e40ba0a61 feat(libSceDiscMap): return no-bitmap error in 5+vOlukvkfg 2026-11-25 23:22:17 +01:00
Dean 2b5ad7e79e Merge pull request #27197 from milescoviello/test/npcommon-global-allocator-pointer-random
test(libSceNpCommon): check sceNpGlobalHeapGetAllocatorPtr and sceNpGetRandom
2026-11-26 10:57:18 +13:00
LenoreSlateandClaude Opus 5.5 fb85b5e90e fix(input-mapper): show the range and built-in value of each setting
The input settings editor listed only the setting names, with every
field blank. Nothing told the user which values are accepted or what
AnyPS5 uses when a field is left blank, so the only feedback was the
error after typing an out-of-range value.

Each setting now shows its accepted range and its built-in value under
the field, linked to it with aria-describedby. The built-in label reuses
the existing translated "builtin" string, so no locale needs new keys.
The range is isolated from the text direction so it reads the same in
right-to-left locales. A test checks the built-in values against the
native InputSettings defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted: yes
2026-11-25 22:54:29 +01:00
Abdulrahman Al-KazmiandClaude Opus 5.5 d09f2bf552 docs(shader): record image_load through null and type 0/1 descriptors on gfx1013
On a PS5 (firmware 13.00) image_load through a 2D T# with TYPE=0 and any
nonzero bit in dwords 0-3 left the destination registers unchanged, dwords 0-3
all zero returned zeros, an unset format or an all-ones T# returned zeros, and
TYPE=1 faulted the GPU. The debt entry said gfx1013 was unverified; the
implementation still returns zeros in both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:51:06 +03:00
DucengarthandClaude Opus 5.5 970781eb0a fix(libfreetype): write invalid COLR layer indices as FreeType does
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:47:59 +01:00
milescovielloandClaude Opus 5.5 fd3979247d test(libSceAgc): check that unversioned sceAgcFuseShaderHalves fuses geometry halves like the _0200 entry
The unversioned entry, given the same geometry halves as sceAgcFuseShaderHalves_0200 and its own register memory, returns 0 and a GS whose code and size are the _0200 result's, with the fused register list copied into the caller's memory and equal to the _0200 list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:41:16 -05:00
LenoreSlateandClaude Opus 5.5 19e334abaa fix(input-mapper): use consistent French terms in the settings editors
The French labels of the input settings and controller button editors
used "saisie", which the French locale writes "entrée" elsewhere, and
"Paramètres", already the name of the application settings menu. The
infinitive "Hériter" also read as an action rather than as the value
that applies when a field is left blank. Use "Réglages d’entrée",
"Valeur héritée" and "Affectation héritée", and describe the blank
field as keeping the inherited value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AI-assisted: yes
2026-11-25 22:40:48 +01:00
milescovielloandClaude Opus 5.5 d6f6f1065a test(libSceImeBackend): check that sceImeBackendModeCaretNext moves the caret one character right
After sceImeBackendModeCaretPrevious moves the caret from 3 to 2 in "HiA", sceImeBackendModeCaretNext returns 0 and sceImeBackendGetCaretIndex reads 3 again; a second sceImeBackendModeCaretPrevious brings it back to 2 so the rest of the editing checks run unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:40:14 -05:00
DucengarthandClaude Fable 5.2 31e41e09fb docs(libfontconfig): record host-dependent negative NaN formatting
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-25 22:11:29 +01:00
ThomasRussandClaude Opus 5.5 9a1c4e8b24 fix(tools): audit dereferences after a closing parenthesis
Report `if (out) *out = 0;` and `(long long)*value`, and leave an operand
followed by `->` or `[` out of the dereference kind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:10:43 +01:00
Dean 63b2e14408 Merge pull request #27117 from oneandonlydean/perf/agc-guestmem-caller-counter
perf(agc): take guest memory caller samples only under APS5_PROFILE_DRAW
2026-11-26 10:03:01 +13:00
HenriksA 0318b52da8 feat(libSceGnmDriver): share mode-independent command writers (#17711)
* feat(libSceGnmDriver): share mode-independent command writers
* fix(libSceGnmDriver): disambiguate provider host exports
* fix(libSceGnmDriver): guard shared writers with guest copies
* refactor(libSceGnmDriver): namespace shared shader copy helper
* test(libSceGnmDriver): align Neo HS fixture with packet reservation
* fix(libSceGnmDriver): preserve inherited HS reservation in shared writers
2026-11-26 10:02:38 +13:00
DariusandClaude Opus 5.5 c2eecbdcaa feat(libSceXml): implement Document::serialize as firmware 13.40 does
Write the document from its root element through the existing reader,
with the module's closing-tag, comment and reference quirks, and keep
the result in the Document until the next serialize.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 22:58:59 +02:00
Rui Rodrigues de Andrade 9945d39da3 test(libSceNKWebKit): cover invalid WebVTT cue string storage 2026-11-25 20:50:36 +00:00
Rui Rodrigues de Andrade 2956185721 feat(nkwebkit): serialize ISO WebVTT cues to JSON 2026-11-25 20:50:16 +00:00
Magnus 038792eb11 fix(libc): build the libc++ regex_error test with clang 2026-11-25 21:40:38 +01:00
Siddhant Singh f123fbcbc3 docs(build): document sanitizer triage output and exit codes 2026-11-26 01:57:33 +05:30
KianandClaude Opus 5.5 6bc0fdc790 fix(libkernel): read CLOCK_VIRTUAL and CLOCK_PROF from getrusage on POSIX hosts, as FreeBSD 11.4 does
On Linux and macOS clock_gettime ids 1 and 2, and id 21 built on id 2,
came from times(), which counts in _SC_CLK_TCK ticks (usually 10 ms),
and threw when times() failed. They now read getrusage(RUSAGE_SELF)
ru_utime and ru_stime in microseconds and set the guest errno on
failure, as FreeBSD 11.4 kern_clock_gettime does through calcru and
TIMEVAL_TO_TIMESPEC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 06:26:11 +10:00
KianandClaude Opus 5.5 2697d5d9d3 feat(libSceLibcInternal): implement _reclaim_telldir, as FreeBSD 11.4 does
_reclaim_telldir takes FreeBSD 11.4's void _reclaim_telldir(DIR*) from
lib/libc/gen/telldir.c, which frees the stream's ddloc records. telldir
here returns raw positions and keeps no records, so a valid stream is
left as it is and a null stream sets EBADF, as telldir and seekdir do.
The stub moves from InventoryExports6.cpp to Directory.cpp beside
_seekdir, and guest_opendir2 checks both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 06:26:10 +10:00
Siddhant Singh 722f3f8bd8 fix(tools): reject non-object bug reports 2026-11-26 01:53:22 +05:30
Siddhant Singh 528e9f60f8 docs(progress): explain symbol transitions in snapshot diffs 2026-11-26 01:53:03 +05:30
Siddhant Singh e9bdf6220d docs(reversing): show how to extract module symbols as JSON 2026-11-26 01:53:03 +05:30
Siddhant Singh 8842adc8e8 docs(usage): document bug report bundle preview 2026-11-26 01:53:03 +05:30
Siddhant Singh 6a52f94c17 fix(tools): read sanitizer test results from one JUnit snapshot 2026-11-26 01:53:02 +05:30
Abdulrahman Al-KazmiandClaude Opus 5.5 2458de0c6f fix(libSceAudioPropagation): copy source PCM when the attribute is set and use it for one render
A console probe (firmware 13.00) shows the PCM record is read when attribute 4
is set: changing the buffer afterwards does not reach the output, and a render
without a new PCM attribute reads silence instead of the buffer again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:21:25 +03:00
gurtgg 9881c0cffa fix(libSceVdecShevc): check inner decoder pointer in no-decoder gate 2026-11-25 21:17:13 +01:00
gurtgg f8c5131430 fix(libSceNgs2): fix natural-order packing and header layout in FFT exports 2026-11-25 21:15:48 +01:00
Dean ff5b409dda Merge pull request #25071 from gurtgg/fix-libc-rune-locale-extended-ranges
fix(libc): evaluate extended rune ranges in wide classification and case conversion
2026-11-26 09:15:46 +13:00
pedro 2e35484e7b fix(libwebrtc): cap the scaler crop at the largest size libyuv handles
libyuv's fixed-point scaler shifts the source dimension by 16 and adds the step in an int. A 32768 pixel dimension overflows that arithmetic. Reject 32768 and keep 32767 as the largest accepted crop, and move the boundary tests to it.
2026-11-25 17:05:53 -03:00
pedro f7116967e7 fix(libSceJsc): allocate a whole StringImpl when decoding a short string
The persistence decoder allocated charactersOffset + byteLength bytes and then placement-newed a StringImpl over them. StringImpl is 24 bytes, so a 1-3 byte string left 1-3 bytes of the object past the allocation. Allocate at least sizeof(StringImpl), as the NKWebKit string builder already does.
2026-11-25 17:05:52 -03:00
Dean eba6750e46 Merge pull request #27168 from cookie42073-cmd/fix/trace-diff-worker-totals-v2
fix(tools): combine trace diff timings for threads with the same name
2026-11-26 08:58:19 +13:00
Dean e8daa4b6c6 Merge pull request #21181 from CPritch/fix/finisher-capture-order
fix(agc): make the draw finisher's pending-write queries see writes queued in the draw pipeline
2026-11-26 08:52:55 +13:00
MarcZX10 9f78b2f738 fix(libSceNgs2.native): write the rack info through guest copies in sceNgs2RackGetInfo (#21141)
* fix(libSceNgs2.native): fill the rack info header through a guest copy in sceNgs2RackGetInfo
* test(libSceNgs2.native): cover the rack info header output in sceNgs2RackGetInfo
* fix(libSceNgs2.native): write the custom rack info extension through a guest copy in sceNgs2RackGetInfo
* test(libSceNgs2.native): cover an unwritable custom rack info tail in sceNgs2RackGetInfo
2026-11-26 08:52:19 +13:00
Dean c804316c85 Merge pull request #21078 from TL-WN/codex/reject-output-directory-collisions
fix(relinker): reject output files needed as directories
2026-11-26 08:51:55 +13:00
Dean 8e06a9fd6a Merge pull request #21061 from kali113/fix/libkernel-sema
fix(libkernel): stop sceKernelSignalSema at a waiter that needs more tokens
2026-11-26 08:51:32 +13:00
Dean 0e0dab4979 Merge pull request #21018 from Kikoarl/fix/shader-recompiler-binding-layout-initializers
fix(shader): initialize BindingLayout fields with zero defaults
2026-11-26 08:51:08 +13:00
Dean 91a79a94ae Merge pull request #20900 from Queuse/codex/fix-lea-address-size-20261114
fix(relinker): wrap address-size LEA roots
2026-11-26 08:50:45 +13:00
Stephen Cork 95bca64461 test(libkernel): audit sceKernelGetCpumode and thread priority ceiling error boundaries (#20865) 2026-11-26 08:50:20 +13:00
Dean 71780d88bd Merge pull request #20622 from milescoviello/fix/kernel-probe-dlsym-name
fix(libkernel): safely probe the symbol name of dlsym
2026-11-26 08:49:57 +13:00
Dean 0f8400cd85 Merge pull request #20614 from PrivacyOnion/fix/videodec2-guest-copy
fix(libSceVideodec2): safely copy guest decode and flush buffers
2026-11-26 08:49:34 +13:00
Dean 3e7d68d2ab Merge pull request #20611 from Gag21/fix/guest-os-lifecycle-tags
fix(relinker): support OS dynamic lifecycle tags in guest modules
2026-11-26 08:49:08 +13:00
birdmarty a54624e100 fix(agc): preserve empty-draw shortcut for primitive restart 2026-11-25 21:32:34 +02:00
david-ojah 1da9426c6d feat(tools): model compiler options and saved temporaries 2026-11-26 00:40:48 +05:30
Dean 5fb72d46f6 Merge pull request #27210 from u-instinct11/docs/offline-nid-lookup
docs(reversing): document offline NID lookups
2026-11-26 08:02:48 +13:00
nexus1692 8ef41d1096 test(libSceUsbStorage): pin the shell-core mount point guards
sceUsbStorageGetMountPointOfShellCore refuses a null mount point with
SCE_USBSTORAGE_ERROR_INVALID_ARGUMENT and an absent device with
SCE_USBSTORAGE_ERROR_DEVICE_NOT_FOUND, but no test read either answer.
The suite now covers both, and checks that the absent-device path
leaves the guest buffer untouched. These are AnyPS5 host-safety
answers, not behaviour measured on a 13.42 console.

AI-assisted: yes (FreeBuff). Adds the missing shell-core mount point guard cases to guest_usb_storage.
2026-11-25 19:58:59 +01:00
Siddhant Singh b3144179d9 fix(tools): reject unknown technical debt report labels 2026-11-26 00:25:13 +05:30
Siddhant Singh 7b10c62feb docs(tracing): show how to isolate a Windows sampling window 2026-11-26 00:24:20 +05:30
Dean 6329c2edc8 Merge pull request #27155 from cookie42073-cmd/fix/next100-summary-widths-20261125
fix(tools): validate native performance summary fields
2026-11-26 07:47:56 +13:00
Siddhant Singh 09c202647c docs(build): explain compilation database inventory variants 2026-11-26 00:14:29 +05:30
Siddhant Singh b79a10242c docs(input): explain repeat timing in controller previews 2026-11-26 00:14:29 +05:30
Siddhant Singh cbe94db5ea docs(testing): explain how to align trace comparison windows 2026-11-26 00:14:29 +05:30
Siddhant Singh 83f931f776 fix(tools): preserve trace diff table cells for multiline names 2026-11-26 00:14:28 +05:30
Dean 1c920edace Merge pull request #26821 from u-instinct11/fix/ab-csv-log-errors
fix(tools): identify malformed A/B CSV input logs
2026-11-26 07:40:13 +13:00
birdmarty 3867c1e89c fix(agc): select per-window pipeline for reused mesh layer draws 2026-11-25 20:20:31 +02:00
Dean 1afab89d42 Merge pull request #26824 from u-instinct11/docs/memory-trace-encodings
docs(tracing): list supported memory trace encodings
2026-11-26 07:20:22 +13:00
Dean dffee8a2d9 Merge pull request #26823 from u-instinct11/docs/skip-report-modes
docs(build): explain skip checker output modes
2026-11-26 07:20:00 +13:00
Dean ac05ab02c3 Merge pull request #26822 from u-instinct11/docs/progress-csv-gfx1013
docs(progress): describe gfx1013 history CSV columns
2026-11-26 07:19:37 +13:00
Dean a4164d14f2 Merge pull request #26151 from alexander-src/perf/env-reference-fast-scan
perf(tools): fast-scan C++ sources and readers in env_reference
2026-11-26 07:19:15 +13:00
Abdulrahman Al-KazmiandClaude Opus 5.5 9418db2a63 fix(libSceAudioPropagation): derive material bands and throw on unmeasured render input
Generate the six material band filters from sine crossovers on a 1024-point
grid under a Hamming window instead of a recovered table, erase render state
on system destroy and material unregister, and throw on portal paths,
unreadable PCM, non-finite source distances and delays beyond the history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 21:11:13 +03:00
Federico Marras 66f88154a4 test(pad): cover PadSubmitAudioHapticsForPort merge window (#25086) 2026-11-26 07:01:43 +13:00
Dean 925f7b7800 Merge pull request #26827 from u-instinct11/fix/skip-junit-path
fix(tools): name malformed skip reports
2026-11-26 06:58:56 +13:00
Dean 1481534665 Merge pull request #26877 from gurtgg/feat-razorcpu-initialize-internal
feat(libSceRazorCpu): implement sceRazorCpuInitializeInternal and initialized query paths
2026-11-26 06:51:12 +13:00
Dean ded989a418 Merge pull request #26836 from cookie42073-cmd/fix/benchmark-reserialized-capture-refresh-20261124
fix(tools): identify reserialized benchmark captures
2026-11-26 06:50:50 +13:00
Dean dbf0be5fbb Merge pull request #26833 from u-instinct11/fix/trace-summary-option-validation
fix(tools): validate trace digest input options before reading
2026-11-26 06:50:28 +13:00
Dean d12a22df51 Merge pull request #26826 from cookie42073-cmd/fix/bisect-tracked-build-cleanup-20261124
fix(tools): protect tracked files during bisect cleanup
2026-11-26 06:50:05 +13:00
Mohamed Malek Aifa 47b25d18fe fix(libSceMove): preserve sceMoveOpen validation precedence 2026-11-25 18:08:45 +01:00
david-ojah b4c14eed85 fix(tools): reject gfx1013 modified forms without a base form 2026-11-25 22:16:32 +05:30
david-ojah d85c9a399f docs(libkernel): record why the backtrace uses the unwind wrapper 2026-11-25 22:06:58 +05:30
Dean 102cad67da Merge pull request #27136 from magnub/feat/audit-dump-relinker-options
feat(tools): pass relinker conversion flags through audit_dump
2026-11-26 05:32:50 +13:00
Dean f44e385392 Merge pull request #27128 from xXPBSXx/fix/libressl3-set-flags-policy
fix(libSceLibreSsl3): add POLICY_CHECK when X509_VERIFY_PARAM_set_flags sets a policy flag
2026-11-26 05:32:27 +13:00
xXPBSXxandClaude Sonnet 5.5 9ea278f723 docs(libkernel): record the PS5 measurement of sceKernelIsAddressSanitizerEnabled
The entry said what the native query reads was not measured. A payload process
on a PS5 (firmware 11.60) returned 0 in ten calls, five in the main thread and
five in a second thread. What the query returns while a sanitizer is active,
and in a title process, stays unmeasured. The change goes into the fragment
that already targets this entry, as the fragment check allows one per entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 17:31:21 +01:00
xXPBSXxandClaude Sonnet 5.5 de0df3e4d2 test(libkernel): pin sceKernelIsAddressSanitizerEnabled to the value measured on a PS5
A payload process on a PS5 (firmware 11.60) returned 0 in ten calls of
sceKernelIsAddressSanitizerEnabled, five in the main thread and five in a
second thread. No test pinned the return value. The test is green from the
start; it keeps the measured value from changing unnoticed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 17:31:18 +01:00
david-ojah d538c46916 docs(libkernel): correct the Windows backtrace API in the debt note 2026-11-25 21:42:06 +05:30
david-ojah 81c9bac0cb fix(libkernel): cap getdtablesize at the console file limit 2026-11-25 21:28:01 +05:30
birdmarty 83800e1313 perf(agc): skip CPU index range scan for in-place draws without vertex attributes 2026-11-25 17:56:54 +02:00
birdmarty c139321586 perf(agc): reuse PreparedDraw across layered mesh output windows 2026-11-25 17:50:10 +02:00
Dean 6b59b8f5e7 Merge pull request #26775 from Gonic0/perf/agc-index-behind-writer-vertex-attributes
perf(agc): bind indices behind a GPU writer for draws with vertex attributes
2026-11-26 04:40:17 +13:00
Dean fd62df380d Merge pull request #26765 from nikmparis217-ux/fix/relinker-libscessl2-alias
fix(relinker): load a libSceSsl2 dependency as libSceSsl
2026-11-26 04:39:53 +13:00
Dean d4553d2b62 Merge pull request #26601 from gccody/fix/shader-uniform-quad-perm-broadcast
fix(shader): read a uniform quad_perm with one quad broadcast
2026-11-26 04:39:30 +13:00
Dean 5b4e6d4da4 Merge pull request #26597 from JJenkx/windows/agc-draw-cache-entries
perf(agc): hold 262144 draw-cache entries by default
2026-11-26 04:39:01 +13:00
Dean e37d1227e3 Merge pull request #25852 from Remi-Bon/perf/shader-keep-specialized-spirv
perf(shader): keep recently specialized SPIR-V for reuse
2026-11-26 04:38:37 +13:00
Dean 6c79267ac6 Merge pull request #25061 from gurtgg/fix-ime-filter-text-pointer-guards-overlap
fix(libSceIme): guard guest pointers and overlapping buffers in ime_filter::FilterText
2026-11-26 04:38:13 +13:00
Dean f44efa2a47 Merge pull request #20081 from AlexFigas/feat/shader-replay-stage-inputs
feat(agc): print pixel inputs and vertex fetch resources in agc_shader_replay --mem
2026-11-26 04:37:49 +13:00
Dean 9aeea79cac Merge pull request #20072 from c1b3r-p3d1a/fix/agc-force-degamma-unchanged-formats
fix(agc): sample more formats that FORCE_DEGAMMA leaves unchanged without it
2026-11-26 04:37:27 +13:00
birdmarty bcc139379e perf(agc): do not break guest memory proofs in Recorder::AfterRecordedWork 2026-11-25 17:35:09 +02:00
Dean d28f9808ac Merge pull request #20070 from c1b3r-p3d1a/feat/shader-interp-f16-float-modes
feat(shader): follow split denormal fields and f16 rounding in 16-bit interpolation
2026-11-26 04:34:19 +13:00
polka.dom d5115bc767 fix(relinker): preserve jump tables formed by 32-bit LEA (#19569) 2026-11-26 04:33:56 +13:00
birdmarty 205937ad7e perf(agc): track per-slice attachment hazards in PassHazards 2026-11-25 17:32:06 +02:00
fromthemoonxandClaude Opus 5.5 998a0750cb test(libSceLibreSsl): check the stack of a truncated DigestInfo parameter header
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:31:35 -03:00
Dean f64a8fe842 feat(agc): print the resource proof counts with APS5_PIPELINE_STATS
The [epoch-proofs] line (resource proofs reused and made by the draw finisher's epoch proofs) was printed only with APS5_PROFILE_DRAW or APS5_VERIFY_DRAW_PIPELINE. The first finishes every draw on the reading thread and the second runs the full checks, so neither shows the counts of a normal run. Print the line with APS5_PIPELINE_STATS as well. No behaviour changes without the switch.
2026-11-26 04:30:48 +13:00
Dean d237f5d065 Merge pull request #20021 from xXPBSXx/fix/kernel-sanitizer-replace-tables-null
fix(kernel): return null from the sanitizer replace-table getters
2026-11-26 04:29:13 +13:00
Dean 3516d04831 Merge pull request #20018 from slopezjur/fix/agc-bound-pointerless-dispatch-writes
fix(agc): bound the writes of dispatches that cannot store through pointers
2026-11-26 04:28:42 +13:00
Dean 5aa5707e14 Merge pull request #20001 from pushkarreddyy/fix/agcdriver-hs-offchip-tf-ring-pointer-probing
fix(libSceAgcDriver): safely probe output parameters in sceAgcDriverGetHsOffchipParam and sceAgcDriverGetTFRing
2026-11-26 04:27:52 +13:00
birdmarty 9f1e09af87 perf(agc): read thread-local live shadow ranges in AnyShadowedOverlaps 2026-11-25 17:27:40 +02:00
Dean bbb4a06285 Merge pull request #19999 from pushkarreddyy/fix/agcdriver-query-user-memory-pointer-probing
fix(libSceAgcDriver): safely probe output memory size in sceAgcDriverQueryResourceRegistrationUserMemoryRequirements
2026-11-26 04:27:28 +13:00
Dean d72479f314 Merge pull request #19967 from blawesom/fix/agc-pixel-interlock-gfx11-race
feat(shader): dump recompiled SPIR-V modules with APS5_DUMP_SPIRV
2026-11-26 04:27:05 +13:00
Dean d3a34e4001 Merge pull request #19899 from Sankalp7317/fix/agc-upload-cache-test-windows-env
fix(tests): set the upload cache test's environment with _putenv_s on Windows
2026-11-26 04:26:41 +13:00
Zaryab Gohar d1ceef3948 fix(libSceVideoOut): return the firmware's codes from the other event pairs (#19832)
* fix(libSceVideoOut): return the firmware's codes from the other event pairs
* test(libSceVideoOut): expect the firmware codes in #15902's other event rows
2026-11-26 04:26:18 +13:00
Dean e8ec08405e Merge pull request #19827 from Ethan-Hainline/guestptr/videoout
fix(libSceVideoOut): copy guest pointer parameters through GuestPtr
2026-11-26 04:25:54 +13:00
david-ojah 480c5a290f feat(libkernel): print a host backtrace with module info 2026-11-25 20:55:42 +05:30
angrysandhill bd4a71415b fix(shader): translate v_sin_f32 and v_cos_f32 in f32 denormal modes 1 and 2 (#19608)
* fix(shader): translate v_sin_f32 and v_cos_f32 in f32 denormal modes 1 and 2
* test(shader): allow one ulp on host sin and cos results in the f32 denormal mode test
* docs(shader): move the sin and cos debt change to a fragment and drop a test comment
2026-11-26 04:25:32 +13:00
Dean bbea704398 Merge pull request #19605 from Nawid3333/fix/f16-omod-after-rounding-r2
fix(shader): apply the f16 output modifier after rounding and the FP16_OVFL clamp
2026-11-26 04:25:09 +13:00
Dean c7bc02604f Merge pull request #18954 from pushkarreddyy/fix/appcontent-pointer-probing
fix(libSceAppContent): safely probe guest initialization and query pointers
2026-11-26 04:24:28 +13:00
birdmarty 5163b0d90d perf(agc): fall back to joined host imports in VulkanDevice::FillBuffer 2026-11-25 17:22:12 +02:00
Dean 485f88c3a6 Merge pull request #17908 from akkadbakkad89/feat/kernel-set-process-property
feat(libkernel): implement sceKernelSetProcessProperty
2026-11-26 04:21:30 +13:00
LeandroLP23andClaude Opus 5.5 3922d0ff97 refactor(nkwebkitrequirements): drop errno saves around guest copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:20:52 +01:00
LeandroLP23andClaude Opus 5.5 bae4fbc7c2 refactor(videoout): drop errno saves around guest copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:20:52 +01:00
LeandroLP23andClaude Opus 5.5 6ec37430b9 refactor(ime): drop errno saves around guest copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:20:51 +01:00
LeandroLP23andClaude Opus 5.5 724278b7de refactor(ajm): drop errno saves around guest copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:20:50 +01:00
Dean 2d8e4b5ccf Merge pull request #26995 from mcarkade/feat/input-mapper-native-settings
feat(input-mapper): edit native input settings
2026-11-26 04:11:40 +13:00
Ashwin e86cd41215 feat(libSceLibcInternal): implement _Atqexit and _Atthreadexit 2026-11-25 20:37:44 +05:30
birdmarty 0773e801d3 perf(agc): reuse TargetMemo across 3D volume slices and reject overlapping pending targets 2026-11-25 17:04:23 +02:00
Dean c032ba7c52 Merge pull request #26147 from MarrasFederico/test/jpeg-progressive-stream-scaling
test(libSceJpegDec): cover scaled progressive streamed decoding
2026-11-26 03:49:14 +13:00
Dean 30944bef2d Merge pull request #24003 from MarcZX10/feat/borderless-window-mode
feat(videoout): add borderless window mode on F2 and ANYPS5_WINDOW_MODE
2026-11-26 03:48:51 +13:00
Dean 629b132c78 Merge pull request #23874 from MarrasFederico/feat/jsc-inspector-parse-enum
feat(libSceJsc): implement InspectorHelpers::parseEnumValueFromString
2026-11-26 03:48:30 +13:00
zaryabzipandClaude Opus 5.5 76a6c20cea refactor(libSceVideoOut): move the Equeue include clear of #19827's hunk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:29:38 +05:00
Dean 29d1afef41 fix(libSceJson2): destroy a Pair's key when its value cannot be built
The default Pair constructor used to destroy the key it had built when
constructing the value threw; the guest-pointer rework dropped that
rollback. Restore it, and give the keyed constructor the same rollback
around copying the value.
2026-11-26 03:28:26 +13:00
Dean c75a81520b Merge pull request #26785 from MarcZX10/docs/fix-input-language-count
docs(input): correct the number of interface and FAQ languages to 24
2026-11-26 03:27:57 +13:00
Dean 0a642df2cc Merge pull request #26194 from Ducengarth/fix/pngdec-short-idat
fix(libScePngDec): preserve rows from truncated IDAT data
2026-11-26 03:27:34 +13:00
Dean af40235276 Merge pull request #25146 from pinewhite/feat/libressl3-bio-vfree
feat(libSceLibreSsl3): implement BIO_vfree
2026-11-26 03:27:10 +13:00
Dean 981953b0cc fix(agc): name a bare APS5_AB arm by its trimmed switches
A bare arm such as 'APS5_NO_GUARD_SPANS + APS5_NO_OWNED_DRAW_INPUTS'
parsed its switches with the spaces trimmed but kept the raw token as
its name, so the phase markers printed a name with spaces that
tools/ab_split.py's PHASE pattern does not accept. Join the parsed
switch names with '+' instead, and cover the spaced form.
2026-11-26 03:19:57 +13:00
zaryabzipandClaude Opus 5.5 2edb799778 feat(libSceContentExport): local checks for GetProgress, ValidateContents and two exports
Follows the firmware 9.20 reading on #25863. GetProgress reports idle
and ended sessions by caller SDK, ValidateContents and the title-id list
and data-with-thumbnail exports run their checks before the service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:17:14 +05:00
KianandClaude Opus 5.5 07a6dd1512 fix(libc): return from qsort_r for fewer than two elements or zero-size elements below 7, as FreeBSD 11 does
qsort_r now returns before validating its arguments when the count is
below two, or the element size is zero with fewer than 7 elements: FreeBSD
11 qsort.c's insertion-sort branch then never calls the comparator or
reads the array. A zero element size with 7 or more elements still throws,
where FreeBSD's partition loop never ends, and a null comparator or base
with two or more elements still throws. The debt entry records both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:10:19 +10:00
KianandClaude Opus 5.5 c00db61baa fix(libkernel): fill getrusage children and ru_maxrss from the host, as FreeBSD 11.4 does
getrusage(RUSAGE_CHILDREN) on Linux and macOS returned an all-zero
rusage. It now returns the host getrusage(RUSAGE_CHILDREN), which holds
the children reaped by wait4, as FreeBSD 11.4 kern_getrusage returns
p_cru. ru_maxrss on macOS is converted from bytes to kilobytes, the unit
of FreeBSD getrusage(2), for getrusage and wait4 usage. On Windows
RUSAGE_SELF and RUSAGE_THREAD report ru_maxrss from the peak working set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:10:18 +10:00
pushkarreddyy 26bf588b18 docs(dev): add debt fragment for freeaddrinfo guest pointer probing 2026-11-25 19:38:48 +05:30
pushkarreddyy ff31704665 test(libScePosixForWebKit): cover null and unmapped pointers in freeaddrinfo 2026-11-25 19:38:48 +05:30
pushkarreddyy ceea15cfa5 fix(libScePosixForWebKit): probe guest AddressInfo nodes in freeaddrinfo 2026-11-25 19:38:47 +05:30
pushkarreddyy b04ce62407 docs(dev): record guest pointer probing fallback for libSceRegMgr string helpers 2026-11-25 19:37:32 +05:30
pushkarreddyy 43bb170856 test(libSceRegMgr): cover guest pointer probing in sceRegMgrStrncpy and sceRegMgrMemset 2026-11-25 19:36:51 +05:30
pushkarreddyy 9702d12005 fix(libSceRegMgr): probe guest pointers in sceRegMgrStrncpy and sceRegMgrMemset 2026-11-25 19:36:50 +05:30
fromthemoonxandClaude Opus 5.5 cebda01ee9 docs(libSceLibreSsl): state the RSA_verify gaps first in its debt entry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:03:44 -03:00
fromthemoonxandClaude Opus 5.5 c3fac12faf test(libSceLibreSsl): check the ASN.1 error stacks of rejected DigestInfos
Covers a 5-byte and a 9-byte DER length, a SET instead of a SEQUENCE,
an empty SEQUENCE, an end-of-contents field, trailing data, a NULL,
SEQUENCE and object parameter that the X509_SIG decode rejects, and a
SEQUENCE parameter it accepts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:03:44 -03:00
fromthemoonxandClaude Opus 5.5 3883ea398f fix(libSceLibreSsl): queue LibreSSL's ASN.1 errors when RSA_verify rejects a DigestInfo
RSA_verify decodes the X509_SIG through a mirror of LibreSSL 2.5.4's
tasn_dec.c template decoder for X509_SIG and X509_ALGOR, so a rejected
DigestInfo queues the library 13 reasons and the nested errors in
LibreSSL's order. DER lengths are read as 64-bit values, as the LP64
library reads them. The Wycheproof test now compares every queued code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 11:03:44 -03:00
Dean 098c73473f Merge pull request #23299 from gurtgg/fix-videoout-frame-timing-log-shutdown-and-validation
fix(libSceVideoOut): synchronize FrameTimingLog stop signaling, close on failure, and reject empty reports
2026-11-26 03:02:06 +13:00
Dean 77f57b931b Merge pull request #23295 from gurtgg/fix-ime-clipboard-utf8-bound-continuation
fix(libSceIme): keep complete UTF-8 and stray continuation bytes at the 64 KiB clipboard cap
2026-11-26 03:01:43 +13:00
RavenCurseBurg 6dde1c9cb0 test(libSceNKWebKit): check Unicode grapheme break conformance
Read the pinned ICU GraphemeBreakTest data. Exercise both exported WebKit helpers for every sequence and verify every expected boundary as a UTF-16 code-unit offset, including supplementary characters.

AI-assisted: Codex + GPT-6.2 Astra (xhigh)
2026-11-25 22:01:22 +08:00
Dean b8e832d2fb Merge pull request #23246 from Callimann8/feat/nkwebkit-mediatime-tostring
feat(libSceNKWebKit): implement WTF::MediaTime::toString
2026-11-26 03:01:19 +13:00
Giuseppe Magliano b1c9409abd test(agc): check that a normal import replacing a label window gets no credit for it 2026-11-25 14:55:56 +01:00
Giuseppe Magliano 420c0dfcdc fix(agc): leave label windows out of the bytes a normal import replaces 2026-11-25 14:54:46 +01:00
Dean 74952ba8d3 Merge pull request #26811 from catminou4/fix/agc-test-split-checkout-path
fix(tools): keep the checkout path of agc_test_split when it ends in whitespace
2026-11-26 02:46:16 +13:00
RavenCurseBurg eebcd0da64 fix(libSceAudioOut): share the device reopen wait across a batch
Start the steady-clock deadline when the first replacement worker is launched. Reuse it for the remaining ports in that guest output call so simultaneous missing devices cannot accumulate a 100 ms wait apiece.

AI-assisted: Codex + GPT-6.2 Astra (xhigh)
2026-11-25 21:42:23 +08:00
RavenCurseBurg 193241dce2 test(libSceAudioOut): cover simultaneous slow batch reopens
Open sixteen virtual ports, bring the endpoint back, and hold all replacement device opens until the guest batch returns. Allow one second for the 100 ms recovery budget and check each port launches one attempt.

AI-assisted: Codex + GPT-6.2 Astra (xhigh)
2026-11-25 21:42:23 +08:00
Alexander 42d70592bc perf(tools): speed up stub reachability and linkage scanning in progress 2026-11-25 13:38:30 +00:00
RavenCurseBurg fb9a76c711 perf(shader): reflect negative half encodings into signed order keys
Leave encodings below 0x8000 unchanged. For negative half encodings, subtract the bits from 0x7fff to produce signed keys from -1 to -32768. Applying the same reflection to the selected key recovers all sixteen original bits.

AI-assisted: Codex + GPT-6.2 Astra (xhigh)
2026-11-25 08:38:08 -05:00
Alexander 06d4d93ae0 perf(tools): fast-scan conditional stubs in import_audit 2026-11-25 13:30:19 +00:00
Hedi Trigui 39a6694223 feat(libSceFreeTypeOt): forward FT_Face_GetCharsOfVariant, FT_Face_GetVariantSelectors and FT_Face_GetVariantsOfChar on Windows 2026-11-25 14:25:33 +01:00
Abdulrahman Al-KazmiandClaude Opus 5.5 c4a1f69019 feat(libSceAudioPropagation): render three-point material paths from console measurements
sceAudioPropagationSourceRender adds a path's first-order ambisonic
contribution for format 0, 1024-sample frames and float or int16 PCM,
following impulse responses measured on a console's own module
(firmware 13.00, sceKernelGetSystemSwVersion 13.590.001): delay, OpenAL
rolloff and cone, gains, ACN/SN3D axes, the measured material band
filters and a one-frame ramp. Other active paths still throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 16:22:19 +03:00
Siddhant Singh 2406f902a1 docs(tracing): explain spreadsheet-safe interval exports 2026-11-25 18:40:00 +05:30
Siddhant Singh f8538f2515 fix(tools): identify invalid NID symbol lists 2026-11-25 18:39:52 +05:30
Siddhant Singh 17516fb20c docs(reversing): document offline NID lookups 2026-11-25 18:35:25 +05:30
Siddhant Singh 3da583cc35 docs(build): explain the Python test registration audit 2026-11-25 18:35:24 +05:30
Siddhant Singh 82def31059 fix(tools): read traces with uppercase gzip suffixes 2026-11-25 18:35:23 +05:30
Siddhant Singh cbbf7e2729 fix(tools): name corrupt memory trace files 2026-11-25 18:35:22 +05:30
Dean fd653794a1 Merge pull request #26774 from MarcZX10/test/select-tests-build
test(tools): cover select_tests Build graph queries
2026-11-26 01:48:45 +13:00
Dean 949ba395db Merge pull request #26773 from cookie42073-cmd/fix/env-audit-cpp-integer-literals-20261124
fix(tools): read C++ integer bounds in environment audits
2026-11-26 01:48:22 +13:00
Dean f996d80e83 Merge pull request #26760 from cookie42073-cmd/fix/performance-thread-loss-20261124
fix(tools): reject contradictory trace loss metadata
2026-11-26 01:47:54 +13:00
Dean 9d4f39d670 Merge pull request #26421 from ToRaNek/feat/libressl3-x509v3-ext-d2i-basic-decoders
feat(libSceLibreSsl3): decode basicConstraints, extendedKeyUsage and privateKeyUsagePeriod in X509V3_EXT_d2i
2026-11-26 01:47:31 +13:00
Dean 60895223c2 Merge pull request #26419 from ToRaNek/fix/libressl3-crl-indirect-entries
fix(libSceLibreSsl3): stop answering for CRL entries with certificateIssuer
2026-11-26 01:47:08 +13:00
Dean 730ca4396e Merge pull request #26144 from IvanFogel/fix/cloud-storage-slot-parameters
feat(npcppwebapi): build cloud storage slot request parameters
2026-11-26 01:46:46 +13:00
Dean fbd2175e5c Merge pull request #26989 from kiansaeidnia/feat/libscelibcinternal-wide-getloctxt
feat(libSceLibcInternal): implement _Getloctxt over wide istreambuf input
2026-11-26 01:05:10 +13:00
milescovielloandClaude Opus 5.5 1ad712e255 test(libkernel): check that sceKernelGetProcParam returns the process parameter block
Every title I run calls sceKernelGetProcParam, and no test called it.
Install a process parameter block with ProcessParametersFixture, as the
other process-parameter tests do, and check that sceKernelGetProcParam
returns that block, the same one on a second call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:58:24 -05:00
Ducengarth 4c721d25c8 fix(libSceFreeTypeOt): forward FT_Face_GetCharVariantIsDefault on Windows 2026-11-25 12:45:59 +01:00
Dean c3aae2e8fb Merge pull request #27002 from mcarkade/feat/trace-diff-scene-windows
feat(tools): compare independent trace scene windows
2026-11-26 00:43:24 +13:00
muhmuhkuh cff28ee95b fix(libSceVideoOut): keep the controller stick while the mouse rests in mouse mode 2026-11-25 12:40:47 +01:00
muhmuhkuh 72ed8c745b test(libSceVideoOut): a resting mouse in mouse mode keeps the controller sticks 2026-11-25 12:40:47 +01:00
Dean 24db5a53d4 Merge pull request #27001 from mcarkade/feat/performance-bisect-checkpoint
feat(tools): resume interrupted performance bisects
2026-11-26 00:38:12 +13:00
Dean 2773423d7d Merge pull request #26999 from mcarkade/feat/title-run-saved-comparison
feat(tools): compare saved title smoke runs
2026-11-26 00:37:50 +13:00
milescovielloandClaude Opus 5.5 e1d4450042 fix(libSceAudioOut): reopen a stopped or missing output device on a host thread
sceAudioOutOutput and sceAudioOutOutputs reopen a port's host device
when SDL has stopped it, and retry every 2 s when the port has none.
They did so on the guest thread, holding the global AudioOut mutex.
When no PipeWire server is reachable, every open fails, so a port
repeats the failing open every 2 s, and one of those opens blocked in
pw_thread_loop_stop inside SDL's ALSA open. While it does, the calling
guest thread stops, and so does every other port's output, because each
waits on the same mutex.

Open the replacement device on a host thread instead. The guest thread
releases the mutex and waits up to 100 ms. An open that returns in time
is installed before the call goes on, as before. Otherwise the port
keeps its timed virtual output until the open returns.

The host thread installs the device only if the port is still the one
it opened for; each sceAudioOutOpen gives the port a new generation. If
the port changed, the host thread closes the device. A port starts no
other open while one is in flight, and the stopped device is closed on
the host thread too. Vibration ports keep the synchronous path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:35:19 -05:00
Dean d86eb41b9c Merge pull request #26997 from mcarkade/feat/windows-sample-comparison
feat(tools): compare saved Windows sample captures
2026-11-26 00:35:08 +13:00
Dean 3215980b89 Merge pull request #25067 from gurtgg/fix-videodec2-hevc-sei-vcl-validation
fix(libSceVideodec2): validate HEVC SEI placement and VCL slice NAL syntax
2026-11-26 00:34:46 +13:00
Dean 86d2d3b542 Merge pull request #25037 from gurtgg/fix-libc-libcxx-condvar-noexcept
fix(libc): ignore pthread errors in noexcept libc++ condition_variable methods
2026-11-26 00:34:22 +13:00
Dean 3358475e8a Merge pull request #24770 from kessler-drift/fix/libscelibressl3-conf-seqwrap
fix(libSceLibreSsl3): wrap X509V3_EXT_conf_nid ASN1 values in SEQWRAP, SETWRAP, BITWRAP and OCTWRAP
2026-11-26 00:34:00 +13:00
Dean 2b2dc348f3 Merge pull request #26996 from mcarkade/feat/bug-report-archive-preview
feat(tools): preview sanitized bug report archives
2026-11-26 00:31:19 +13:00
Dean c040a44ae7 Merge pull request #26994 from mcarkade/feat/run-report-triage
feat(tools): triage saved runtime reports together
2026-11-26 00:26:19 +13:00
JJenkxandClaude Opus 5.5 c0316f4e60 perf(shader): order v_med3_f16 operands once in the integer key domain
The non-NaN median of v_med3_f16 was built from four nested minMaxF16Bits
calls. Each outer call re-derived the sign-magnitude order key of an
intermediate select, which value numbering cannot share. Compute the three
operand keys once, take the median with SMin/SMax on the keys, and map the
median key back with the same involution masked to 16 bits. The order is
a bijection on 16-bit patterns, so the selected bits are identical, -0
still sorts below +0, and the NaN path is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:18:18 -05:00
brajankwandClaude Opus 5.5 f78c18f92a fix(libkernel): fail read, write and seek on a ksem id as FreeBSD 11.4's ksem_ops does
A ksem id is backed by a host null device descriptor here, so read
returned 0, write the length, and lseek and pread 0. FreeBSD 11.4's
ksem_ops reads and writes through invfo_rdwr, which fails with
EOPNOTSUPP after dofileread finishes a zero-length read with 0, and
lacks DFLAG_SEEKABLE, so lseek, pread, pwrite and their vector forms
fail with ESPIPE. kern_lseek answers ESPIPE before fo_seek looks at
whence, so lseek on a ksem id no longer checks whence first. A ksem id
now answers these as a kqueue already does, and a null buffer no
longer turns the read or write into EFAULT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:16:31 +01:00
Dean 11c9e7764e Merge pull request #24706 from olegon85/fix/libkernel-posix-mlock-locks-mapped-pages
fix(libkernel): posix mlock and munlock lock mapped pages like the console
2026-11-26 00:16:07 +13:00
Dean 14e9b90825 Merge pull request #24699 from Script-hpp/codex/ime-extended-text
feat(libSceVideoOut): preserve extended IME preedit text
2026-11-26 00:15:44 +13:00
Dean ba5743023c Merge pull request #24672 from olegon85/fix/libkernel-app-category-unknown-pid-esrch
fix(libkernel): answer ESRCH for unused pids in sceKernelGetAppCategoryType
2026-11-26 00:15:21 +13:00
Dean f3d126a3ad Merge pull request #24665 from CodingBreadd/fix/libscexml-builder-skip-whitespace
fix(libSceXml): skip ignorable white space by default as firmware 13.40 does
2026-11-26 00:14:57 +13:00
Dean 7aab07e62d Merge pull request #24546 from jagrat04/feat/libscenkwebkit-page-lifecycle
feat(libSceNKWebKit): implement WKPage close and DOM animation suspension controls
2026-11-26 00:14:34 +13:00
Ducengarth 7758fb94a9 fix(libSceFreeTypeOt): forward FT_Attach_File on Windows 2026-11-25 12:13:58 +01:00
Dean f9b5d5faef chore: merge main 2026-11-26 00:04:03 +13:00
milescovielloandClaude Opus 5.5 7aeca467ae test(libSceNpCommon): check sceNpGlobalHeapGetAllocatorPtr and sceNpGetRandom
guest_np_common_runtime checked the global heap allocator through
sceNpGlobalHeapGetAllocator, sceNpGlobalHeapGetAllocatorEx and
sceNpGlobalHeapGetAllocatorExPtr, but no test called
sceNpGlobalHeapGetAllocatorPtr or sceNpGetRandom.

Check that sceNpGlobalHeapGetAllocatorPtr returns the global heap
allocator, with the same context and allocate function as the Ex
pointer, and that it allocates and frees. Check that 16 sceNpGetRandom
calls do not all return the same value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:03:19 -05:00
Remi-BonandClaude Opus 5.5 7d2c4bcc0d test(agc): check 8-bit SNORM -64 selected at run time converts to -64/127
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 12:01:06 +01:00
milescovielloandClaude Opus 5.5 39d14e3ac7 test(libSceHttp): check sceHttpCreateConnection, sceHttpCreateRequest and sceHttpCreateRequestWithURL2
guest_http_options builds every connection and request with
sceHttpCreateConnectionWithURL and sceHttpCreateRequestWithURL, so no
test called sceHttpCreateConnection, sceHttpCreateRequest or
sceHttpCreateRequestWithURL2. Four of the titles I run import
sceHttpCreateRequestWithURL2.

Build a connection and two requests with them from a template that has
authentication and a raw cookie value set. Check that each gets a new
id and takes its parent's options, and that changing one request leaves
its sibling and its connection as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 05:52:29 -05:00
Dean c23868f5e6 fix(tools): compare periodic summary rows without their first present counter
Two APS5_TRACE_SUMMARY_EVERY rows of separate runs never start at the same present, so performance_compare reported window.first_present as a configuration difference and the labels check kept 'perf numbers missing' on a pull request that pasted both rows. Rows with the spec 'summary_every N' are now compared like 'seconds A:B' windows: the spec must match, the counter is not configuration. Any other spec keeps the counter check.
2026-11-25 23:31:55 +13:00
Ducengarth dc956738fd feat(libSceJpegDec): decode pixel format 10 as packed Y8U8Y8V8 (#26193)
* feat(libSceJpegDec): decode pixel format 10 as packed Y8U8Y8V8
* docs(debt): merge the Y8U8Y8V8 stream entry into the stream-header fragment
2026-11-25 23:29:10 +13:00
Dean e670eff632 Merge pull request #26152 from IvanFogel/fix/20261123/vdecsw-picture-metadata
fix(libSceVdecsw): deliver parsed AVC and HEVC picture metadata
2026-11-25 23:28:47 +13:00
Dean f101943e86 Merge pull request #26124 from IvanFogel/feat/20261123/audiodec-context
feat(libSceAudiodec.native): expose the module context and release decoder instances
2026-11-25 23:28:24 +13:00
Dean b942139fb7 Merge pull request #26226 from GeremC/fix/nkwebkit-jsc-prototype-uaf
fix(libSceNKWebKit): stop freeing a prototype twice when a set finds a data property on it
2026-11-25 23:13:47 +13:00
Dean 732ccc466d Merge pull request #26859 from GabbeHags/perf/sampled-import-segments
perf(agc): view straddling sampled surfaces through their allocations' imports
2026-11-25 23:05:55 +13:00
Dean 1cab33c601 Merge pull request #25528 from pinewhite/feat/icu-string-utf16-find
feat(libSceIcu): search UTF-16 strings through guest copies
2026-11-25 23:05:20 +13:00
Dean 68249cf9b6 Merge pull request #25266 from gurtgg/fix-nputility-request-table-cap
fix(libSceNpUtility): bound AppLaunchLink and ServiceChecker request tables
2026-11-25 23:04:56 +13:00
Dean 853d529fc8 Merge pull request #25075 from gurtgg/fix-msgdialog-decode-utf8-maximal-subpart
fix(libSceMsgDialog): consume maximal invalid UTF-8 subparts once
2026-11-25 23:04:33 +13:00
Dean 50fd545585 Merge pull request #25036 from gurtgg/fix-libressl3-pkcs7-free-object
fix(libSceLibreSsl3): delegate PKCS7 ASN1_OBJECT teardown to ASN1_OBJECT_free
2026-11-25 23:04:09 +13:00
Dean 4551093100 Merge pull request #16054 from stuart-russell/fix/agc-register-offset-sentinel
fix(agc): a 0xffffffff register offset names no register
2026-11-25 23:03:42 +13:00
Dean e3ad7b845d Merge pull request #25986 from milescoviello/fix/npcommon-dbg-dump-text-guest-copies
fix(libSceNpCommon): read sceNpDbgDumpText's text through checked guest copies
2026-11-25 22:48:51 +13:00
Federico Marras 928de99352 test(libc): cover C++ rethrow, exception_ptr and _Doraise (#25087)
* test(libc): test __cxa_rethrow and dependent exceptions
* test(libc): test exception_ptr refcount and lifetime
* test(libc): test _Doraise and system_error copy
2026-11-25 22:48:29 +13:00
Dean 42f4db3a14 Merge pull request #24969 from ashwin280802/feat/libsce-libcinternal-tgamma
feat(libSceLibcInternal): implement _Tgamma, _FTgamma and _LTgamma
2026-11-25 22:48:06 +13:00
Codex 0f3a43147c fix(tools): combine trace diff timings for threads with the same name 2026-11-25 09:44:24 +00:00
KerutzuuandCopilot App aeafe8ac96 chore(icu): avoid unnecessary CMake overlap
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-25 10:26:02 +01:00
Dean 1cd6df7381 Merge pull request #26123 from behkha/test/pfs-single-block-command-precedence
test(libScePfs): parenthesize the v3 single block command's third field check
2026-11-25 22:23:27 +13:00
Dean 79943841b0 Merge pull request #26102 from malekaifa/prime-f/test-systemservice-pending-return-codes-20261123
test(libSceSystemService): cover pending return codes
2026-11-25 22:23:04 +13:00
Dean 2da3e8b9dc Merge pull request #26093 from shripad-jyothinath/feat/libkernel-sys-rdup-socketclose
feat(libkernel_sys): implement __sys_rdup syscall wrapper
2026-11-25 22:22:42 +13:00
Dean 4c78185f02 Merge pull request #15948 from HabibUrRehmanBhattii/feat/fmask-16-sample-current
fix(agc): read 16-sample FMASK across every storage width
2026-11-25 22:22:19 +13:00
Codex f044ffaefb test(font): check AGC surface format and color registers 2026-11-25 10:17:50 +01:00
Codex f0d1798c5a test(ngs2): cover compressor mode changes and third input 2026-11-25 10:14:37 +01:00
Blazing Cook 80f288b414 fix(tools): validate native performance summary fields 2026-11-25 09:01:38 +00:00
Siddhant Singh 490a530dd6 ci: retry Windows checks after test timeout 2026-11-25 14:27:41 +05:30
Dean 9c0d60cbfb Merge pull request #27000 from mcarkade/feat/web-conversion-receipts
feat(web): record release provenance in exports
2026-11-25 21:55:43 +13:00
Dean 8abd1ec2f8 Merge pull request #25103 from gurtgg/fix-pad-haptic-buffer-upsampling-and-phase
fix(libScePad): emit all upsampled frames and guard phase in PadHapticBuffer
2026-11-25 21:53:01 +13:00
Dean 2e2b8779cd Merge pull request #26993 from mcarkade/feat/pages-input-mapper
feat(pages): publish the input mapper
2026-11-25 21:48:07 +13:00
Dean 6f1eae9654 Merge pull request #26886 from B-Howell/claude/http2-callback-setters
fix(libSceHttp2): reject contexts and cookie boxes in the redirect and SSL callback setters
2026-11-25 21:45:28 +13:00
Siddhant Singh a915407344 test(tools): run malformed JUnit regression under CTest 2026-11-25 14:03:36 +05:30
Dean 44eccbf1b0 Merge pull request #26865 from malekaifa/prime-d/pe-export-table-raw-bounds-20261125
fix(nid): bound PE export tables to raw data
2026-11-25 21:32:54 +13:00
Dean fcd24644ec Merge pull request #25423 from cookie42073-cmd/fix/literal-changed-paths
fix(tools): preserve literal paths in changed-file lists
2026-11-25 21:32:32 +13:00
Dean 9f31840226 Merge pull request #26876 from johnohhh1/fix/main-sync-fetch-scope
fix(tools): skip submodule fetches when checking main sync
2026-11-25 21:29:48 +13:00
Dean 05aec9b699 Merge pull request #26268 from sash2kk/perf/pass-staging
perf(agc): keep a draw's staged buffer in one shadow for the open render pass under APS5_PASS_STAGING
2026-11-25 21:27:04 +13:00
Dean d384d22326 Merge pull request #26259 from MarrasFederico/feat/icu-locale-table-fallback
feat(libSceIcu): implement uloc_getTableStringWithFallback
2026-11-25 21:26:42 +13:00
Dean 10f08e62a8 Merge pull request #26257 from jagrat04/feat/libscenkwebkit-bundle-user-content
feat(libSceNKWebKit): implement WKBundle user content and style sheet location controls
2026-11-25 21:26:19 +13:00
Dean 8f758b6e38 Merge pull request #26873 from milescoviello/test/libc-standard-exception-type-records
test(libc): check the standard exception type_info records and vtables
2026-11-25 21:16:34 +13:00
Dean 3a76b99731 Merge pull request #26318 from xXPBSXx/fix/audio-propagation-numpoints-invalid-path
fix(libSceAudioPropagation): return ErrorInvalidHandle for an unknown path in PathGetNumPoints
2026-11-25 21:16:12 +13:00
JJenkx a935cad40a feat(agc): group GPU draw timings by complete shader stage sets (#15572)
* feat(agc): group GPU draw timings by complete shader stage sets
* test(agc): include stage timing keys in the default build
* test(agc): check stage grouping through recorded draws
2026-11-25 21:15:42 +13:00
Dean be8e78cdde Merge pull request #26870 from milescoviello/test/libc-multibyte-locale-helpers
test(libc): check _Btowc, _Wctob, the per-thread multibyte states and __mb_cur_max
2026-11-25 21:05:38 +13:00
Dean 3d24879527 Merge pull request #26862 from Ducengarth/codex/freetype-ot-multi-master
fix(libSceFreeTypeOt): forward FT_Get_Multi_Master on Windows
2026-11-25 20:57:46 +13:00
Dean 6b8680d9f7 Merge pull request #26480 from fromthemoonx/test-libressl-wycheproof-rsa-pkcs1
test(libSceLibreSsl): cover Wycheproof RSA PKCS#1 v1.5 signature vectors
2026-11-25 20:57:24 +13:00
Dean cc96a55700 Merge pull request #26228 from gnavarro24/feat/libkernel-mkfifo
feat(libkernel): implement mkfifo
2026-11-25 20:57:00 +13:00
gnavarro24 d5a78affe1 feat(libScePosixForWebKit): implement mkdtemp and getpwnam (#25921)
* feat(libScePosixForWebKit): implement mkdtemp and getpwnam
* fix(libScePosixForWebKit): copy the getpwnam name through the guest helper
* fix(libScePosixForWebKit): give mkdtemp the mkstemp template rules
2026-11-25 20:56:36 +13:00
Dean 3385c1225c Merge pull request #25076 from gurtgg/fix-npparty-create-reserved-offset-and-init-order
fix(libSceNpParty): validate CreateParam 0x2CA padding, blob readability, and init version ordering
2026-11-25 20:56:13 +13:00
Dean f7948d080a Merge pull request #26755 from malekaifa/prime-d/pr-overlap-no-merge-base-current-20261123
fix(tools): handle pull requests without merge bases
2026-11-25 20:39:27 +13:00
RTGG 07815ef1ea feat(libSceXml): support SAX DOCTYPE, entity resolution, chunk splits, and boundary errors 2026-11-25 08:38:36 +01:00
Federico Marras 58537b4585 test(libc): verify recursive file lock contention deterministically 2026-11-25 08:33:25 +01:00
Dean 5df833f508 Merge pull request #26792 from nikmparis217-ux/fix/systemservice-ps4-enter-button
fix(libSceSystemService): answer the enter button assignment to PS4 titles
2026-11-25 20:29:15 +13:00
Dean de121d3857 Merge pull request #26688 from gurtgg/feat-videocore-interface-preinit-gates
feat(libSceVideoCoreInterface): return NOT_INITIALIZED before init in SetFunctionTable and MainLoop
2026-11-25 20:28:52 +13:00
Dean 6af8d3b78f Merge pull request #26687 from gurtgg/feat-video-native-ext-query-validation
feat(libSceVideoNativeExtEssential): validate codec 2 and 4 profile/level in iwAQhvb9BvY
2026-11-25 20:28:30 +13:00
Dean 1db8d568fd Merge pull request #26681 from meh7an/perf/agc-repeat-storage-surface
perf(agc): answer repeated depth-surface lookups from a per-thread miss memo
2026-11-25 20:28:08 +13:00
Dean aeafc2fa93 Merge pull request #26867 from milescoviello/test/libc-libatomic-sized-and-legacy-fetch
test(libc): check the sized __atomic_* and the legacy _Fetch_* exports
2026-11-25 20:25:31 +13:00
Dean bdd2c6fa94 Merge pull request #26861 from ynkmyz233/feat/libsceicu-resource-locales
feat(libSceIcu): implement resource bundle locale exports
2026-11-25 20:22:49 +13:00
Dean 29126f7fba Merge pull request #25469 from DonRyuzaki/codex/libcxx-regex-error-20261122
feat(libc): implement libc++ regex_error
2026-11-25 20:22:08 +13:00
Dean d1ade0c961 Merge pull request #24577 from jagrat04/feat/libscenkwebkit-bundle-origin-access-allow-lists
feat(libSceNKWebKit): implement WKBundle origin access allow list controls
2026-11-25 20:21:44 +13:00
Dean 5fa54b09d2 Merge pull request #25273 from mcarkade/fix/select-tests-bad-regex
fix(tools): report ctest's diagnostic for a malformed select_tests targets regex
2026-11-25 20:07:14 +13:00
Giuseppe Magliano d2d884ab94 test(agc): check that a normal import fits its budget while the label windows are full 2026-11-25 07:58:49 +01:00
Giuseppe Magliano 1f5177db5d test(agc): leave an unregistered gap after each block of the label import window test 2026-11-25 07:58:49 +01:00
Giuseppe Magliano 27bee6cace fix(agc): keep label windows out of the normal host import budget and its eviction 2026-11-25 07:58:39 +01:00
Dean 43524d1c46 Merge pull request #26818 from TheExtreMeLeGend/fix/libc-copy-no-progress
fix(libc): stop file copies that make no write progress
2026-11-25 19:57:18 +13:00
Dean 982634fbbe Merge pull request #26799 from vishnuvardhan3333/feat/opus-enc-priority-float-timeout
feat(libSceOpusCeltEnc,libSceOpusSilkEnc): implement float-priority and infinite-timeout encode
2026-11-25 19:56:57 +13:00
RTGG fe4a8770f9 test(libSceRazorCpu): cover 192-byte InitDataTags extent and clarify debt model 2026-11-25 07:55:27 +01:00
gnavarro24 9345b0b9c7 feat(libc): implement the double complex trigonometric, exponential and power functions (#26283)
* feat(libc): implement the double complex trigonometric, exponential and power functions
* fix(libc): register the guest_complex_trig test by fragment
* test(libc): cover casinh, catanh and a signed zero in the complex trig test
* style(libc): remove a doubled blank line in FloatBuiltins.cpp
* fix(libc): restore the complex double functions cut off by the merge
* chore: rerun the Windows changed-tests job
2026-11-25 19:51:56 +13:00
Dean aa872b1799 Merge pull request #25522 from ErenYeager1836/feat/net-config-up-down-interface
feat(libSceNet): implement loopback up/down interface
2026-11-25 19:49:19 +13:00
Dean dbaebd80f4 Merge pull request #25515 from mnoori11/fix/libc-fclose-errno
fix(libc): translate the host errno of a failed fclose
2026-11-25 19:49:03 +13:00
Dean c408775cb2 Merge pull request #20271 from Ducengarth/fix/conventions-event-without-title
fix(tools): report a pull request event without a title as a usage error
2026-11-25 19:48:43 +13:00
Magnus 6c882c1a9b feat(tools): pass relinker conversion flags through audit_dump 2026-11-25 07:47:33 +01:00
akkadbakkad89 21db7bb556 perf(agc): learn draw relocation shapes from data donors 2026-11-25 12:16:26 +05:30
Dean 7a1c9bbccf Merge pull request #26830 from gurtgg/fix-ngs2-pcm-float-no-throw
fix(libSceNgs2.native): pass through float and double PCM samples as in firmware 13.60
2026-11-25 19:34:25 +13:00
Dean 30412af66c Merge pull request #26260 from LeandroLP23/refactor/webrtc-errno-guards
refactor(webrtc): drop errno guards around guest copies
2026-11-25 19:26:44 +13:00
Dean faf49d37f8 Merge pull request #26222 from GeremC/fix/jsc-stack-limit-asan-fake-stack
fix(libSceNKWebKit): measure JS and regular expression stack use from the frame address
2026-11-25 19:26:23 +13:00
Dean e43cbf618c Merge pull request #26218 from LeandroLP23/refactor/font-guest-copy-errno
refactor(font): drop errno saves around guest copies
2026-11-25 19:26:01 +13:00
Dean d9ce88edfc Merge pull request #25622 from u-instinct11/fix/windows-ci-git-paths
fix(ci): preserve changed paths for Windows test selection
2026-11-25 19:25:40 +13:00
Dean 03f2aa53e7 Merge pull request #23759 from heditrigui/feat/nkwebkit-page-remote-inspection-and-pending-url
feat(libSceNKWebKit): implement WKPage remote inspection, pending URL, and configuration accessors
2026-11-25 19:25:18 +13:00
Dean 9d20f77c00 Merge pull request #22813 from slopgobblercobbler/test/pad-haptics-bounds
test(libScePad): audit vibration parameters, adaptive trigger effects, and handle bounds
2026-11-25 19:24:57 +13:00
Dean 3cab484efb Merge pull request #26857 from Ducengarth/codex/freetype-ot-validator-error
feat(libSceFreeTypeOt): implement ft_validator_error
2026-11-25 18:53:58 +13:00
Dean 4b70bf1201 Merge pull request #26848 from malekaifa/prime-d/pe-iat-write-bounds-20261125
fix(nid): bound PE import address entries
2026-11-25 18:42:03 +13:00
xXPBSXxandClaude Sonnet 5.5 15604d6136 docs(libSceFreeType): record the FT_List behavior measured in libSceFreeTypeOt on firmware 11.60
A PS5 payload process on firmware 11.60 ran FT_List_Add, Insert, Find,
Remove, Up, Iterate and Finalize of libSceFreeTypeOt.sprx on its own list,
nodes and callbacks (run 2026-11-25T040604Z): the order of the nodes, the
Find results, the callback order and result of Iterate and the destroy and
free calls of Finalize equal what AnyPS5 does. The entry now says that
and keeps the cases that were not measured.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 06:37:34 +01:00
xXPBSXxandClaude Sonnet 5.5 20b9a328a5 docs(libSceFreeType): record the FT_Atan2, geometry and outline results measured in libSceFreeTypeOt on firmware 11.60
A PS5 payload process on firmware 11.60 ran FT_Atan2, FT_Vector_Transform,
FT_Matrix_Multiply, FT_Matrix_Invert, FT_Outline_Check, FT_Outline_Get_CBox,
FT_Outline_Reverse and FT_Outline_Translate of libSceFreeTypeOt.sprx on its
own memory, twice (runs 2026-11-25T033607Z/040546Z and 033616Z/040555Z,
identical). The entries now name what was measured and what is not matched
in this change: FT_Outline_Check returns 6 on the console and 20 here,
FT_Outline_Reverse reverses the first point of each contour too, and inputs
outside signed 32 bits are computed in 64 bits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 06:37:33 +01:00
xXPBSXxandClaude Sonnet 5.5 f57a8db7eb fix(libSceFreeType): return +180 degrees from FT_Atan2 for dx < 0 and dy = 0
FT_Atan2 of libSceFreeTypeOt.sprx on a PS5 with firmware 11.60 returns
+180 degrees (0xb40000) for dx < 0 and dy = 0, where the bundled FreeType
returns -180 degrees. The adapter now returns +180 degrees in that case.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 06:37:33 +01:00
xXPBSXxandClaude Sonnet 5.5 0ba8092bb3 test(libSceFreeType): pin FT_Atan2 of dx < 0 and dy = 0 measured in libSceFreeTypeOt on firmware 11.60
A PS5 payload process on firmware 11.60 returned +180 degrees (0xb40000)
from FT_Atan2 of libSceFreeTypeOt.sprx for dx < 0 and dy = 0 (dx = -0x10000
and dx = -0x80000000); the bundled FreeType returns -180 degrees for
-0x10000. The test now expects +180 degrees there and pins the eleven other
in-range results measured on the console.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 06:37:29 +01:00
Dean 61d110125e Merge pull request #26851 from TheExtreMeLeGend/fix/zlib-inflate-publication-rollback
fix(libSceZlib): discard unpublished inflate results
2026-11-25 18:32:22 +13:00
Dean 9b2592c9f4 Merge pull request #25705 from JJenkx/test/sleepwake-assert-diagnostics-20261122
test(libkernel): report sleep-wake assertion call sites
2026-11-25 18:32:00 +13:00
Dean c4540e0444 Merge pull request #26844 from malekaifa/prime-d/nid-dynamic-entry-size-20261124
fix(nid): validate ELF dynamic section layout
2026-11-25 18:24:25 +13:00
cochcoder 92394c800e fix(libSceFont): define fixed-point rounding overflow (#24844) 2026-11-25 18:24:02 +13:00
Dean 1fdd5c3a5f Merge pull request #24833 from u-instinct11/feat/gif-write-metadata
feat(libSceGifParser): write title and comment metadata
2026-11-25 18:23:40 +13:00
Hedi Trigui 81e353d12f feat(libSceNKWebKit): implement WKBundleNodeHandle autofill button type operations 2026-11-25 06:16:50 +01:00
Dean af7bf00717 Merge pull request #26645 from JJenkx/windows/shader-color-compare-gather
fix(shader): emulate comparison gathers of color textures
2026-11-25 18:15:59 +13:00
hamb3r ebabe36d6b fix(libSceAgcDriver): quantize fallback D16_UNORM_S8_UINT depth clears, writes and bounds (#17899)
* fix(libSceAgcDriver): quantize fallback D16_UNORM_S8_UINT depth clears
* fix(libSceAgcDriver): quantize fallback D16_UNORM_S8_UINT depth writes and bounds
* test(libSceAgcDriver): cover D16_UNORM_S8_UINT fallback depth precision
* test(libSceAgcDriver): cover multi-step depth bias on fallback D16_UNORM_S8_UINT
2026-11-25 18:15:37 +13:00
Dean 704b929e85 Merge pull request #26841 from cookie42073-cmd/fix/env-audit-signed-fallbacks-20261124
fix(tools): preserve signed environment fallback values
2026-11-25 18:12:57 +13:00
Dean 7df43031f4 Merge pull request #26875 from B-Howell/claude/docs-aio-download0-sources
docs(debt): record why pending AIO delete and download0 size 0 stay unimplemented
2026-11-25 18:10:17 +13:00
Dean f4461db2cc Merge pull request #25772 from mcarkade/fix/pad-modal-hotkeys
fix(pad): rearm controller hotkeys after modal capture
2026-11-25 18:09:54 +13:00
nikmparis217-ux 64497547d6 fix(relinker): load a libSceSsl2 dependency as libSceSsl 2026-11-25 07:09:35 +02:00
Abhinav Pullela 128c5b5899 fix(input-mapper): compare restored settings in definition order 2026-11-25 10:31:00 +05:30
Dean 4f39d4f73d Merge pull request #26829 from gurtgg/fix-agc-condexec-patch-firmware-behavior
fix(libSceAgc): match firmware 13.60 CondExec patcher error return and bit-masking
2026-11-25 17:57:36 +13:00
Dean 2005ee3fc6 Merge pull request #25074 from gurtgg/test-savedata-restore-check-backup-bounds
test(libSceSaveData): fix foreign title ID check and audit RestoreBackupData and CheckBackupData bounds
2026-11-25 17:55:01 +13:00
Dean a39b73ebe0 Merge pull request #25049 from gurtgg/fix-libkernel-macos-guest-tls-tp-alignment
fix(libkernel): align macOS guest TLS thread pointer and validate layout
2026-11-25 17:33:42 +13:00
Dean 883e5f093e Merge pull request #24994 from birdmarty/fix/agc-metadata-pass-claims-msaa-memory
fix(agc): claim multisampled memory in a CB metadata pass over a single-sample target
2026-11-25 17:33:20 +13:00
Dean 3a4805f0c4 Merge pull request #24992 from rudranshcoolhai-boop/fix/nkwebkit-string-argument-alignment
fix(libSceNKWebKit): copy String arguments from their address, not from &impl
2026-11-25 17:32:57 +13:00
Dean 7daca46677 Merge pull request #24960 from birdmarty/fix/libkernel-file-calls-set-errno
fix(libkernel): set guest errno on failure in sceKernel file calls
2026-11-25 17:32:33 +13:00
Dean ff3f76c879 Merge pull request #24942 from GiannisG1/feat/libcinternal-messages-getcat
feat(libSceLibcInternal): implement messages<char> and messages<wchar_t>::_Getcat
2026-11-25 17:32:11 +13:00
Dean 6acbecf239 Merge pull request #24914 from 0x70776c/feat/libpad-get-data-internal
feat(libScePad): implement scePadGetDataInternal
2026-11-25 17:31:49 +13:00
Dean 1d38858b35 Merge pull request #24899 from 0x70776c/feat/libcinternal-wide-time-put-init
feat(libSceLibcInternal): implement wide time_put::_Init
2026-11-25 17:31:27 +13:00
Dean 763df12d02 Merge pull request #26803 from xXPBSXx/docs/libkernel-sys-module-list-internal-console-1160
docs(libkernel_sys): record the module list sceKernelGetModuleListInternal and the check order of sceKernelGetModuleInfoInternal on firmware 11.60
2026-11-25 17:28:46 +13:00
Dean ed47b0b818 Merge pull request #26783 from cozejarr/test/icu-utf-conversions-scalar-batches
test(libSceIcu): convert the scalar sweep in runs instead of one call per scalar
2026-11-25 17:28:24 +13:00
Dean 53ae0bd932 Merge pull request #26722 from cookie42073-cmd/fix/progress-snapshot-input-errors-20261124
fix(tools): identify invalid progress snapshot inputs
2026-11-25 17:28:02 +13:00
Dean 72a366bbe4 Merge pull request #25194 from gurtgg/fix-libc-renamedot-null-and-root-length
fix(libc): preserve UTF-8 roots and ENOTDIR errors in RenameDot
2026-11-25 17:24:22 +13:00
Dean 8ca369e6f8 Merge pull request #25066 from gurtgg/fix-audiodec-m4aac-bsi-writeback-on-pcm-error
fix(libSceAudiodec): avoid mutating M4AAC BSI info on PCM size or pointer errors
2026-11-25 17:23:59 +13:00
Dean 7ebd44a29d Merge pull request #25064 from gurtgg/fix-entitlements-ini-parsing-edge-cases
fix(libSceNpEntitlementAccess): handle empty env var, BOM, directories, and empty labels in EntitlementsIni
2026-11-25 17:23:36 +13:00
Dean 23fd976ed7 Merge pull request #25063 from gurtgg/fix-libc-feraise-reject-unsupported-bits
fix(libc): reject unsupported exception bits in _Feraise
2026-11-25 17:23:14 +13:00
Dean dee205645d Merge pull request #25062 from gurtgg/fix-ime-psn-dialog-notice-backward-cooldown
fix(libSceIme): suppress backward timestamps during PsnDialogNotice cooldown
2026-11-25 17:22:52 +13:00
Dean ed0ca4f0f7 Merge pull request #25060 from gurtgg/fix-libc-realpath-expand-after-parent-escape
fix(libc): resume relative symlink expansion in realpath after ascending out of an absolute symlink
2026-11-25 17:22:30 +13:00
Dean 302ae13bb6 Merge pull request #25059 from gurtgg/fix-libc-symlink-prefix-eloop
fix(libc): return ELOOP for paths below symlink loops and deep symlink chains
2026-11-25 17:22:07 +13:00
Dean 776b13a047 Merge pull request #25054 from gurtgg/fix-systemservice-open-url-decline-cooldown-clock
fix(libSceSystemService): start URL decline cooldown from post-dialog clock time
2026-11-25 17:21:45 +13:00
Dean 17818be53f Merge pull request #24949 from heditrigui/feat/nkwebkit-bundle-node-handle-autofill-available
feat(libSceNKWebKit): implement WKBundleNodeHandleSetHTMLInputElementAutoFillAvailable
2026-11-25 17:21:22 +13:00
xXPBSXxandClaude Sonnet 5.5 b9ba0a3e0e docs(debt): record the measured POLICY_CHECK behaviour of X509_VERIFY_PARAM_set_flags
The entry no longer says the console's choice is unknown: a PS5 payload process
(firmware 11.60) added POLICY_CHECK in two runs. It names what the probe did not
cover (a module-created object, X509_VERIFY_PARAM_get_flags, later calls, the
prototype and offset 24 as assumptions).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 04:36:21 +01:00
xXPBSXxandClaude Sonnet 5.5 3506ed3b30 fix(libSceLibreSsl3): add POLICY_CHECK when X509_VERIFY_PARAM_set_flags sets a policy flag
On a PS5 payload process (firmware 11.60), setting EXPLICIT_POLICY, INHIBIT_ANY
or INHIBIT_MAP returned 1 and added POLICY_CHECK, in two runs. The function
threw NotImplemented in that case when POLICY_CHECK was neither set nor
requested. It now adds POLICY_CHECK, as LibreSSL 2.5.4 does, and returns 1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 04:33:21 +01:00
Abhinav Pullela b63a0cb48d feat(web): record release provenance in exports 2026-11-25 08:55:25 +05:30
Abhinav Pullela a36b59749d feat(tools): resume interrupted performance bisects 2026-11-25 08:54:33 +05:30
Dean 21940f44a5 Merge pull request #25168 from pinewhite/feat/wpe-pasteboard-string-lifetime
feat(libSceNKWebKitRequirements): implement the WPE pasteboard string helpers
2026-11-25 16:21:47 +13:00
Abhinav Pullela e67150159b feat(tools): check header changes against Ninja dependencies 2026-11-25 08:50:52 +05:30
xXPBSXxandClaude Sonnet 5.5 1edc6fdf5d test(libSceLibreSsl3): pin the console's POLICY_CHECK addition in X509_VERIFY_PARAM_set_flags
On a PS5 payload process (firmware 11.60), setting EXPLICIT_POLICY, INHIBIT_ANY or
INHIBIT_MAP with POLICY_CHECK neither set nor requested returned 1 and added
POLICY_CHECK (0x100 -> 0x180, 0x200 -> 0x280, 0x400 -> 0x480; a following 0x1 gave
0x181), in two runs. main throws NotImplemented there and leaves the parameter
unchanged. The test pins these measured cases and one unrelated flag.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-25 04:19:51 +01:00
Delwin Mathew 6f1f93e4f0 test(libScePngParser): pin a full inline path and the descriptor close on a failed read 2026-11-25 08:47:19 +05:30
Delwin Mathew e64a223b4a docs(libScePngParser): fold the read call's debt change into the writer's fragment 2026-11-25 08:47:19 +05:30
Delwin Mathew d9694c69db test(libScePngParser): pin the descriptor close, the IEND stop, the inline size check and the libSceRtc unload 2026-11-25 08:47:19 +05:30
Delwin Mathew fc4dcf4b0f fix(libScePngParser): close the file descriptor on every exit from the read call 2026-11-25 08:47:19 +05:30
Delwin Mathew bd857c66af feat(libScePngParser): read PNG metadata through the firmware 13.42 MBQfjtzRyh0 call 2026-11-25 08:47:18 +05:30
Abhinav Pullela ea4436e4e7 feat(tools): compare saved Windows sample captures 2026-11-25 08:46:41 +05:30
Abhinav Pullela b83a8875c6 feat(tools): summarize saved frame replay sweeps 2026-11-25 08:33:44 +05:30
Abhinav Pullela 40cdd74b42 fix(tools): build all executable targets of selected Python wrappers 2026-11-25 08:32:17 +05:30
Dean 5c42b37d96 style(agc): drop the comment on the guest memory caller samples 2026-11-25 15:55:59 +13:00
Abhinav Pullela b72fddb7db feat(tools): preview sanitized bug report archives 2026-11-25 08:25:58 +05:30
Abhinav Pullela f25ad43226 feat(tools): preflight pinned frame replay recipes 2026-11-25 08:25:54 +05:30
Abhinav Pullela 6d3f35134a feat(input-mapper): edit native input settings 2026-11-25 08:25:42 +05:30
Abhinav Pullela ea97e9c9cf feat(package): reproduce native and web release archives 2026-11-25 08:25:38 +05:30
Abhinav Pullela d687a326b8 feat(tools): triage saved runtime reports together 2026-11-25 08:25:35 +05:30
Abhinav Pullela c048abe1df feat(tools): add Ninja timings to compile inventory 2026-11-25 08:25:33 +05:30
Abhinav Pullela 8122239771 feat(tools): compare independent trace scene windows 2026-11-25 08:25:30 +05:30
Abhinav Pullela 9958a32d90 feat(tools): compare saved title smoke runs 2026-11-25 08:25:27 +05:30
Abhinav Pullela cc7115030e feat(pages): publish the input mapper 2026-11-25 08:25:24 +05:30
Dean efa58e8429 Merge pull request #26795 from catminou4/fix/debt-split-checkout-path
fix(tools): keep the checkout path of debt_split when it ends in whitespace
2026-11-25 15:37:00 +13:00
Mohamed Malek Aifa 71188e9468 fix(nid): validate PE import terminator 2026-11-25 03:35:07 +01:00
Mohamed Malek Aifa ad86703068 fix(nid): validate relocation section layout 2026-11-25 03:22:40 +01:00
Dean 28c31c06a0 Merge pull request #25068 from gurtgg/fix-socket-host-error-mappings
fix(libkernel): map missing Windows and POSIX socket errors to FreeBSD errnos
2026-11-25 15:17:48 +13:00
Dean fb9ef74375 Merge pull request #26791 from MarcZX10/docs/fix-find-package-exceptions
docs(agents): name the find_package exceptions the checker allows
2026-11-25 15:14:48 +13:00
Dean 88b3c464ce Merge pull request #26788 from MarcZX10/docs/fix-draw-pipeline-enable-value
docs(usage): state that any value enables APS5_DRAW_PIPELINE
2026-11-25 15:14:19 +13:00
Dean 0854acb68a Merge pull request #26787 from MarcZX10/docs/fix-input-sdl-commit
docs(input): point the key catalogue reference at the pinned SDL commit
2026-11-25 15:13:58 +13:00
Dean 1e1cfc993b Merge pull request #26786 from MarcZX10/docs/fix-input-title-id-limit
docs(input): document the 32-character limit for title IDs
2026-11-25 15:13:42 +13:00
Dean 04b03988fc Merge pull request #26781 from nikmparis217-ux/feat/texttospeech-ps4-init-without-server
feat(libSceTextToSpeech): answer a PS4 title's initialization as firmware 13.52 does without a text-to-speech server
2026-11-25 15:13:27 +13:00
Dean 1293915815 Merge pull request #26780 from milescoviello/test/kernel-cpp-exception-info-name-limit
test(libkernel): check sceKernelDebugWriteCppExceptionInfo at the 64 KiB name limit
2026-11-25 15:13:05 +13:00
Roman Tonn cca5b6c7f5 test(libwebrtc): zero the address unions in the NetworkManager test (#26729)
* test(libwebrtc): zero the whole IPv6 address in the NetworkManager test
* test(libwebrtc): zero every address union in the NetworkManager test and check a middle byte
2026-11-25 15:12:42 +13:00
Gordon ebc9fea155 feat(libwebrtc): implement VideoFrameBuffer::CropAndScale on libyuv (#26446)
* feat(libwebrtc): implement VideoFrameBuffer::CropAndScale on libyuv
* fix(libwebrtc): measure a flipped crop by its magnitude in CropAndScale
* fix(libwebrtc): halve the scaled width without overflow in CropAndScale
* fix(libwebrtc): check every CropAndScale argument before allocating
2026-11-25 15:12:20 +13:00
Dean 90c248ef7b Merge pull request #26271 from mihiii1337/fix/agc-test-split-bracket-initial-newline
fix(tools): honor initial newlines in AGC bracket arguments
2026-11-25 15:12:00 +13:00
Dean ccec32b9fa Merge pull request #26784 from MarcZX10/docs/debt-entry-length
docs(contributing): state the 1000-character limit for debt entries
2026-11-25 15:09:12 +13:00
Dean bd636ff949 Merge pull request #26779 from Helldiverr/docs/build-defender-agc-signature
docs(build): name the real cause of Defender's ShellCode.MKA!MTB on AGC tests
2026-11-25 15:08:51 +13:00
Dean 16bc127765 Merge pull request #26776 from nikmparis217-ux/feat/videoout-ps4-vr-option
feat(libSceVideoOut): accept the VR option of PS4 buffer registrations
2026-11-25 15:08:30 +13:00
RTGG 2c3e1864b4 feat(libSceRazorCpu): implement sceRazorCpuInitializeInternal and initialized query paths 2026-11-25 03:08:28 +01:00
Dean a090ed8749 Merge pull request #26770 from nikmparis217-ux/feat/videorecording-setinfo
feat(libSceVideoRecording): answer sceVideoRecordingSetInfo for PS4 titles
2026-11-25 15:07:50 +13:00
Dean 3e591fefc6 Merge pull request #26769 from nexus1692/feat/pr-test-coverage
test(libSceBgft): pin the alias ladder and the unread parameter fields
2026-11-25 15:07:28 +13:00
Abhinav Pullela f95a703323 fix(tools): run the tests whose Python wrapper a change touches 2026-11-25 07:36:44 +05:30
Dean 717adc706a Merge pull request #26762 from cookie42073-cmd/fix/title-run-cache-path-20261124
fix(tools): preserve Unicode CMake checkout paths for title runs
2026-11-25 15:06:38 +13:00
johnohhh1 ee992be736 fix(tools): skip submodule fetches when checking main sync 2026-11-24 21:06:27 -05:00
Dean cfb4314c07 Merge pull request #26761 from cookie42073-cmd/fix/env-audit-loop-bound-20261124
fix(tools): honor exclusive loop bounds in environment audits
2026-11-25 15:06:16 +13:00
Dean 74d1a51584 Merge pull request #26757 from cookie42073-cmd/fix/nonfinite-performance-summary-20261124
fix(tools): reject nonfinite values in performance summaries
2026-11-25 15:05:53 +13:00
Dean 101594cc52 Merge pull request #26754 from LeandroLP23/refactor/libc-tests-drop-platform-includes
refactor(libc): drop the unused platform includes of the boundary tests
2026-11-25 15:05:25 +13:00
Dean b189ab5bc0 Merge pull request #26753 from xXPBSXx/docs/libsceagc-gsprimpayload-search
docs(libSceAgc): record how sceAgcGetGsPrimPayload searches the IDX_FORMAT registers on firmware 11.60
2026-11-25 15:05:03 +13:00
Dean db669ee169 Merge pull request #26748 from magnub/fix/import-audit-bundled-libc-internal
fix(tools): drop the host libc fallback for a bundled libSceLibcInternal
2026-11-25 15:04:41 +13:00
Dean 578197c3a8 Merge pull request #26725 from marick-py/fix/ces-sjis-null-output
fix(libSceCesCs): report Shift-JIS lengths without an output buffer
2026-11-25 15:04:07 +13:00
Dean b4690dd1c9 Merge pull request #26629 from cookie42073-cmd/fix/mingw-cmake-reply-validation-20261124
fix(tools): diagnose ambiguous MinGW CMake replies
2026-11-25 15:03:50 +13:00
Dean 1a8fdbd4f9 Merge pull request #26583 from muhmuhkuh/crew/k1/up-19131-inplace-checks
fix(agc): read a moved dispatch buffer in place only with the checks of a moved draw element
2026-11-25 15:03:28 +13:00
Dean 5f01044686 Merge pull request #26581 from consolelogout/perf/host-import-change-log
perf(agc): reconcile host imports from logged allocation changes
2026-11-25 15:03:06 +13:00
Dean Galvin a86d409288 test(libSceAppContent): drop host-dependent write-only bootParam case
On x86-64 Linux a PROT_WRITE-only page is still readable, so the default
guest copy succeeds and Initialize returns 0. The check only held with
APS5_GUEST_COPY_SYSCALL=1. The legacy write-only case stays.
2026-11-25 07:30:50 +05:30
pushkarreddyy 32c7d72c06 docs(dev): document legacy bootParam probing behavior in libSceAppContent technical debt 2026-11-25 07:30:50 +05:30
pushkarreddyy 4f3b7ab728 test(libSceAppContent): verify unreadable bootParam succeeds under older SDK versions 2026-11-25 07:30:50 +05:30
pushkarreddyy f5e27b4d88 fix(libSceAppContent): preserve legacy unreadable bootParam behavior on older SDKs 2026-11-25 07:30:50 +05:30
pushkarreddyy 445e32bfb3 docs(dev): document write-only buffer refusal in libSceAppContent technical debt 2026-11-25 07:30:50 +05:30
pushkarreddyy 161d467964 test(libSceAppContent): verify unmapped initParam succeeds under older SDK versions 2026-11-25 07:30:49 +05:30
pushkarreddyy a3eb22aa8b fix(libSceAppContent): restrict initParam probing to modern SDK versions 2026-11-25 07:30:49 +05:30
Dean e3c5b31733 Merge pull request #26199 from malekaifa/prime-f/test-npmanager-silent-stubs-20261123
test(libSceNpManager): cover silent stubs
2026-11-25 15:00:24 +13:00
Dean 1bad65f0fe test(libSceMsgDialog): write supplementary characters as universal character names 2026-11-25 14:59:59 +13:00
Dean 544d7522d6 Merge pull request #26138 from IvanFogel/feat/leaderboards-ranking-models
fix(npcppwebapi): construct and retain leaderboard ranking requests
2026-11-25 14:59:46 +13:00
Mohamed Malek Aifa bd6e861d77 fix(libSceHttp2): copy response metadata through guest memory (#25731) 2026-11-25 14:59:24 +13:00
Dean be84073e7f Merge pull request #25658 from Jazeupoi/agc-user-data-tail-shapes
fix(shader): link user-data tails through copied pointers, branching bodies and geometry fronts
2026-11-25 14:59:02 +13:00
pushkarreddyy 61d16de021 docs(dev): document unmapped pointer fallback for libSceAppContent initialization and queries 2026-11-25 07:28:44 +05:30
pushkarreddyy f88b5b8e97 test(libSceAppContent): verify unmapped pointer probing across initialization and queries 2026-11-25 07:28:44 +05:30
pushkarreddyy 1cdf5885e2 fix(libSceAppContent): safely probe guest initialization and query pointers 2026-11-25 07:28:44 +05:30
Dean 5ea6d232fb Merge pull request #25133 from pinewhite/feat/libressl3-obj-txt2obj
feat(libSceLibreSsl3): implement OBJ_txt2obj
2026-11-25 14:58:33 +13:00
pushkarreddyy 6dd0603e31 docs(dev): document fallback for probed pointers in libSceAgcDriver 2026-11-25 07:28:16 +05:30
pushkarreddyy bf0173f0f0 test(libSceAgcDriver): cover unwritable output pointer in sceAgcDriverQueryResourceRegistrationUserMemoryRequirements 2026-11-25 07:28:16 +05:30
pushkarreddyy 124827dec7 fix(libSceAgcDriver): safely probe output memory size in sceAgcDriverQueryResourceRegistrationUserMemoryRequirements 2026-11-25 07:28:16 +05:30
pushkarreddyy 5932586310 docs(dev): document fallback for probed configuration outputs in libSceAgcDriver 2026-11-25 07:28:02 +05:30
pushkarreddyy 7aa22ade15 test(libSceAgcDriver): cover unwritable output pointers in sceAgcDriverGetHsOffchipParam and sceAgcDriverGetTFRing 2026-11-25 07:28:02 +05:30
pushkarreddyy 019800586a fix(libSceAgcDriver): safely probe output parameters in sceAgcDriverGetHsOffchipParam and sceAgcDriverGetTFRing 2026-11-25 07:28:01 +05:30
pinewhite 8e80cf5df4 feat(libSceLibcInternal): implement wide ctype do_scan_is (#25111)
* feat(libSceLibcInternal): implement wide ctype do_scan_is
* docs(libSceLibcInternal): record wide ctype scan debt in a fragment
2026-11-25 14:57:59 +13:00
Dean 70e6c4d221 Merge pull request #25089 from MarrasFederico/test/libc-locale-combined
test(libc): cover classic numpunct<char> and thread-local mbstate
2026-11-25 14:57:37 +13:00
Federico Marras 8ada784602 test(glslim): cover texture units, viewport limits and eglSwapInterval (#25088)
* test(glslim): cover texture unit isolation and parameter validation
* test(glslim): cover glViewport limits, errors, and queries
* test(glslim): cover eglSwapInterval, eglBindAPI, and eglGetError
2026-11-25 14:57:15 +13:00
Federico Marras 50bb5ee018 test(freetypeot): cover stream fixed-width readers, skip, and frames (#25084) 2026-11-25 14:56:53 +13:00
Dean f094da07f5 Merge pull request #25083 from mrb-eel/codex/pngdec-preserve-indexed-output
fix(libScePngDec): preserve indexed pixel and palette bytes
2026-11-25 14:56:29 +13:00
Dean f17874e22a Merge pull request #25073 from gurtgg/fix-savedata-file-reject-invalid-target-paths
fix(libSceSaveData): reject non-file and directory paths in SaveDataFile replace_file_with
2026-11-25 14:56:06 +13:00
Dean e03a8e5794 Merge pull request #25069 from gurtgg/fix-select-deadline-signed-overflow
fix(libkernel): prevent signed overflow in select deadline saturation
2026-11-25 14:55:43 +13:00
Federico Marras e9048eb353 test(libSceNKWebKitRequirements): verify inflate custom allocator OOM retry (#24385) 2026-11-25 14:55:20 +13:00
Dean 5cb08d6d07 Merge pull request #21196 from roboterspinne/fix/libsceimedialog-star-state-copy-out
fix(libSceImeDialog): return INVALID_ADDRESS from sceImeDialogGetCurrentStarState for an unwritable state
2026-11-25 14:54:59 +13:00
Stephen Cork 4c1486cb76 test(relinker): cover augmentation length overflow in eh_frame CIE record (#14573) 2026-11-25 14:54:37 +13:00
RTGG 8658644003 docs(libSceNpUtility): keep debt bullets under 1000 characters 2026-11-25 02:40:58 +01:00
RTGG 4c7a4d032c test(libScePad): cover zero-frame rate change and sub-1500Hz upsampling in PadHapticBuffer 2026-11-25 02:40:37 +01:00
RTGG 21b684c1ab test(libSceNpParty): cover legacy CreateParam nonzero count with null data 2026-11-25 02:40:17 +01:00
RTGG ee401097e2 test(libSceMsgDialog): cover valid UTF-8 scalar boundaries including U+10FFFF 2026-11-25 02:40:14 +01:00
RTGG f824ef98bf test(libSceLibreSsl3): cover stack-owned dynamic strings in PKCS7_free 2026-11-25 02:40:05 +01:00
milescovielloandClaude Opus 5.5 b2c9b634fd test(libc): check the standard exception type_info records and vtables
No test read the type_info records of most standard exceptions, or
their vtables. Check that the std::exception and std::ios_base records
have no base, and that every derived exception record names its class
and points at the base the C++ standard gives it (logic_error,
runtime_error, bad_alloc or exception). Check also that the records of
each kind share one type_info vtable, and that each exception vtable
has a zero offset, its own type record and all three members.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:36:24 -05:00
milescovielloandClaude Opus 5.5 1033070a3e test(libc): check _Btowc, _Wctob, the per-thread multibyte states and __mb_cur_max
No test called the Dinkumware entry points _Btowc, _Wctob,
_Getpmbstate or _Getpwcstate, or read the __mb_cur_max variable. Check
that _Btowc and _Wctob agree with btowc and wctob, including EOF, WEOF
and a character a byte cannot hold; that the two state pointers are
distinct, stable within a thread and different on another thread; and
that the C locale's maximum is 1 from both the variable and
___mb_cur_max.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:33:48 -05:00
Ducengarth 087701d945 fix(libSceFreeTypeOt): forward FT_Get_Sfnt_Table on Windows 2026-11-25 02:32:44 +01:00
RTGG 9165d500d7 fix(libSceVideodec2): allow suffix SEI between slices per H.265 7.4.2.4.4 2026-11-25 02:31:52 +01:00
RTGG 87f860fc70 test(libSceLibreSsl3): move zero-length nid test into X509Accessors and update expectation 2026-11-25 02:31:45 +01:00
milescovielloandClaude Opus 5.5 4fcdcce53c test(libc): check the sized __atomic_* and the legacy _Fetch_* exports
guest_dinkumware_atomics covered the _Atomic_* calls and some of the
sized __atomic_* calls, but no test called __atomic_store_1/4,
__atomic_load_2/4, __atomic_exchange_1/2, most __atomic_fetch_* sizes,
or the legacy _Fetch_*_seq_cst_1/2/4 and _Fetch_*_8 calls. Check each
one's returned old value and the stored result, including wrap-around.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:25:37 -05:00
B-HowellandClaude Opus 5.5 b5478095e4 fix(libSceHttp2): reject contexts and cookie boxes in the redirect and SSL callback setters
sceHttp2SetRedirectCallback returns 0x817B1100 for a context or cookie
box id, and sceHttp2SetSslCallback for a cookie box id, as the other
option and callback setters do on the 13.42 module, instead of throwing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:20:13 -05:00
Mohamed Malek Aifa c3e80577e9 fix(nid): bound PE export tables to raw data 2026-11-25 02:16:40 +01:00
B-HowellandClaude Opus 5.5 8317b21d82 docs(debt): record why pending AIO delete and download0 size 0 stay unimplemented
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:16:22 -05:00
Ducengarth 86dec168ee fix(libSceFreeTypeOt): forward FT_Get_Multi_Master on Windows 2026-11-25 02:13:43 +01:00
Codex 5157a6a0ab feat(libSceIcu): implement resource bundle locale exports 2026-11-25 08:56:20 +08:00
Gustavo Navarro 99fb02dfb8 Merge remote-tracking branch 'upstream/main' into feat/libkernel-mkfifo 2026-11-24 19:54:10 -05:00
GabbeHagsandClaude Opus 5.5 a10bb470b1 perf(agc): view straddling sampled surfaces through their allocations' imports
A sampled surface that crosses two guest allocations, each with its own host
import, was joined into one new import before its storage image could serve
it. The join pins and watches the whole run again: in Mafia: Definitive
Edition's city load, two cube arrays (233 and 467 MiB) joined 668 and 680 MiB
runs, ~150 ms each on the queue worker, the second one re-pinning the first.

Block-unit storage images already upload, refresh and store through import
segments, so a surface that the existing imports cover piece by piece now
counts as host-imported: HostImportSegmentsCover checks the cover without
making an import, SampledFromStorageEligible accepts such a block-unit
surface, and PresyncSurfaces treats it as GPU-direct like a single import.
APS5_NO_IMPORT_SEGMENT_VIEWS=1 joins as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 01:52:03 +01:00
Mohamed Malek Aifa 92b6aa3b96 fix(libkernel): prioritize queued flock upgrades 2026-11-25 01:50:21 +01:00
Dean 214d3c72d1 Merge pull request #26856 from oneandonlydean/fix/nkwebkit-inspector-regex-test-lifetime
fix(libSceNKWebKit): keep inspector regex test strings alive
2026-11-25 13:47:53 +13:00
Ducengarth e23b23902c feat(libSceFreeTypeOt): implement ft_validator_error 2026-11-25 01:42:47 +01:00
Dean cc25449add perf(agc): take guest memory caller samples only under APS5_PROFILE_DRAW
GuestMemory::Read, ReadCommitted and the write path sampled their caller on
every 256th (16th for writes) call: a dladdr and a mutex on the calling
thread. The samples feed only the [guestmem] line, which is printed under
APS5_PROFILE_DRAW, so without the switch nothing read them.
2026-11-25 13:41:27 +13:00
Dean 9ca3cec822 Merge pull request #26854 from oneandonlydean/fix/debt-libressl3-fragment-overlap
fix(docs): drop the libSceLibreSsl3 debt section #25319 superseded
2026-11-25 13:38:16 +13:00
Dean ad74b806df fix(docs): drop the libSceLibreSsl3 debt section #25319 superseded
#25319 rewrote the SSL and SSL_SESSION retains entry in its own fragment
while the older SSL_CTX_new fragment still carried the previous text, so
debt_fold --check failed on main. Keep the newer text only.
2026-11-25 13:36:06 +13:00
Dean a33d227a0f fix(libSceNKWebKit): keep inspector regex test strings alive
Latin1 and Utf16 take a const reference, so a StringImpl built from a
literal pointed into a temporary string that was gone before the regex
read it. The wide pattern case read freed stack and failed on Linux.
Name the backing strings so they outlive the StringImpl.
2026-11-25 13:35:05 +13:00
Nabil El Bak 8644eef296 fix(libSceZlib): discard unpublished inflate results 2026-11-24 19:27:10 -05:00
JJenkxandClaude Opus 5.5 8c0d924948 perf(agc): keep the draw key sightings at the previous entry cap
The admission filters were sized from the entry cap, so raising the
cap to 262144 also quadrupled them: far more draw keys counted as seen
before and were admitted. On Trails in the Sky the 2nd Chapter the
cache then filled to its byte limit and churned up to ~75% more
inserts per 10 s, costing ~5% of frames. Size both filters from
min(entries, 65536) instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:22:54 -05:00
JJenkxandClaude Opus 5.5 5a39c4a6f5 test(agc): check the default draw cache entry cap directly
The 70000-draw case took about 60 s under the validation layer, over the
30 s limit for tests. The default cap is now public as DrawCacheEntries,
and the test requires it to be 262144 with APS5_DRAW_CACHE_ENTRIES unset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:22:54 -05:00
JJenkxandClaude Opus 5.5 a999bd51a3 perf(agc): hold 262144 draw-cache entries by default
The draw cache's default entry count goes from 65536 to 262144. The
byte budget (APS5_DRAW_CACHE_BYTES, 256 MiB) is unchanged and still
bounds what the cache holds; APS5_DRAW_CACHE_ENTRIES=65536 restores the
previous default.

agc_driver_draw_cache_capacity keeps its 4352-draw reuse case and adds
a case that sights and inserts 70000 more distinct draws: it requires no
eviction and more than 65536 entries held. With main's default it fails
with 6814 to 6974 evictions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 19:22:54 -05:00
Mohamed Malek Aifa e18ab9a011 fix(nid): bound PE import address entries 2026-11-25 01:16:54 +01:00
Mohamed Malek Aifa d35f150d3a fix(nid): validate dynamic section layout 2026-11-25 00:59:54 +01:00
Codex 9400c4aca4 fix(tools): preserve signed environment fallback values 2026-11-24 23:58:01 +00:00
Codex ec082c19fb fix(tools): skip stale dependencies for integrated PR heads 2026-11-24 23:56:34 +00:00
Blazing Cook 941641efd6 fix(tools): identify reserialized benchmark captures 2026-11-24 23:56:33 +00:00
RTGG a57fbd3dfe fix(libSceNgs2.native): pass through float and double PCM samples as in firmware 13.60 2026-11-25 00:55:00 +01:00
RTGG cd682578ca fix(libSceAgc): match firmware 13.60 CondExec patcher error return and bit-masking 2026-11-25 00:54:54 +01:00
Siddhant Singh 76aece9871 fix(tools): validate trace digest input options before reading 2026-11-25 05:23:16 +05:30
Codex 94fa5578ab fix(tools): sanitize text in trace timeline SVGs 2026-11-24 23:49:39 +00:00
Siddhant Singh 67190334e9 fix(tools): name malformed skip reports 2026-11-25 05:19:26 +05:30
Codex b2159ac623 fix(tools): protect tracked files during bisect cleanup 2026-11-24 23:48:50 +00:00
Siddhant Singh 9da5eae257 docs(progress): describe gfx1013 history CSV columns 2026-11-25 05:16:18 +05:30
Siddhant Singh d8d630a95c docs(tracing): list supported memory trace encodings 2026-11-25 05:16:17 +05:30
Siddhant Singh 5e2d83c735 docs(build): explain skip checker output modes 2026-11-25 05:16:17 +05:30
Siddhant Singh 7303ee70f9 fix(tools): identify malformed A/B CSV input logs 2026-11-25 05:16:16 +05:30
Codex 7730bf495a fix(tools): keep pipe support in progress snapshot comparisons 2026-11-24 23:38:54 +00:00
Nabil El Bak 311506b9c8 fix(libc): stop file copies that make no write progress 2026-11-24 18:34:54 -05:00
RTGG 483a90f839 docs(libSceNpWebApi2): align context-limit and header-cap debt entries and test 0x7FFF wrap 2026-11-25 00:26:33 +01:00
RTGG 4a8d92e2eb fix(libSceVideodec2): allow prefix user-data SEI between slices, isolate reserved VCL test, and update debt 2026-11-25 00:26:29 +01:00
RTGG d27d75e131 fix(libSceNpUtility): wrap sceNpAppInfoIntCreateRequest IDs at 0x7FFFFFFF and verify unwritable rollback 2026-11-25 00:18:45 +01:00
RTGG 9c0a68c34f test(libc): cover null checks, handle teardown, and wait error propagation in GuestLibcxxCondition 2026-11-25 00:16:53 +01:00
RTGG f72c5d1a81 docs(libSceVideoCoreInterface): update Unknown function info entry for sceVideoCoreIfMainLoop 2026-11-25 00:15:03 +01:00
RTGG 281e799e5e test(libSceVideoNativeExtEssential): cover accepted profile/level pairs, truncation, and exact debt levels 2026-11-25 00:14:59 +01:00
Mohamed Malek Aifa b144dee454 fix(tools): fail closed on truncated PR file lists 2026-11-25 00:13:33 +01:00
RTGG 3ca9bb6822 fix(libSceJpegDec): preserve errno around handle HostWrite probe in sceJpegDecCreate 2026-11-25 00:12:56 +01:00
Louis FaustandDevin AI 7e2e77be87 test(tools): keep the checkout path test away from other open edits
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-24 23:11:34 +00:00
Louis FaustandDevin AI 34d8c71606 fix(tools): keep the checkout path of agc_test_split when it ends in whitespace
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-24 23:07:03 +00:00
fc54d18d8d test(libc): cover __atomic_compare_exchange_2 on a match and a mismatch (#21235)
* test(libc): cover __atomic_compare_exchange_2 on a match
* test(libc): cover __atomic_compare_exchange_2 on a mismatch
* fix(libc): scope each atomic check in its own block so the test compiles
* test(libc): match guest_atomic_2 Windows test setup to its neighbours

Co-authored-by: pr-review4 <pr-review4@ps5team>
Co-authored-by: MarcZX100 <marczxrr@gmail.com>
2026-11-25 12:06:14 +13:00
Dean bcd8870c2f Merge pull request #21035 from slopgobblercobbler/slopgobblercobbler/pr-libsceaudioout-volume-channel-precedence-bounds
test(libSceAudioOut): audit volume bounds across 8 channels, pointer error precedence, and padspk mix levels
2026-11-25 12:05:47 +13:00
Dean 9f80f78b1a Merge pull request #26592 from Dr-Coconut/fix/libkernel-connect-pending-race
fix(libkernel): keep a TCP connect pending until every connect on the socket leaves the host
2026-11-25 12:03:07 +13:00
Dean a0bd939b2e Merge pull request #26469 from ynkmyz233/feat/libsceicu-default-encoding-decode
feat(libSceIcu): decode default-encoded copies as UTF-16
2026-11-25 12:02:46 +13:00
Dean 7213d0095e Merge pull request #25319 from kessler-drift/fix/libscelibressl3-ssl-up-ref-forwarded
fix(libSceLibreSsl3): count SSL_CTX_up_ref and SSL_up_ref at the forwarded objects' offsets
2026-11-25 12:02:24 +13:00
Dean 8170c102d4 Merge pull request #26747 from xXPBSXx/docs/libkernel-pthread-once-console-1160
docs(libkernel): record that pthread_once faults for an unreadable or unwritable control pointer on firmware 11.60
2026-11-25 11:47:55 +13:00
Dean d3770e0ada Merge pull request #26735 from cookie42073-cmd/fix/round200-benchmark-capture-evidence-20261124
fix(tools): validate benchmark capture evidence and build identity
2026-11-25 11:47:33 +13:00
Dean 1f8b6a1a34 Merge pull request #26730 from xXPBSXx/docs/libsceagc-acb-jump-rewind-size-measured
docs(libSceAgc): record the values sceAgcAcbJumpGetSize and sceAgcAcbRewindGetSize returned on firmware 11.60
2026-11-25 11:47:05 +13:00
KianandClaude Opus 5.5 8666bdf5cf feat(libSceLibcInternal): implement _Getloctxt over wide istreambuf input
std::_Getloctxt<wchar_t, istreambuf_iterator<wchar_t>> (i4J5FvRPG-w) and
std::_Getloctxt<char, istreambuf_iterator<wchar_t>> (FX+eS2YsEtY) were
inventory placeholders that threw. They now run the field walk of the
implemented char form, read from the firmware module in #22452, on
16-bit input: GetLocaleText takes separate table and input element
types, and a char table byte is compared with the input element by
integral value, sign-extended as Dinkumware's _Ptr[_Off] != *_First
promotes it. Null arguments return -2 as the char form does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 08:41:00 +10:00
Dean 2cb2ded70b Merge pull request #26724 from cookie42073-cmd/fix/header-manifest-stable-inputs-20261124
fix(tools): reject changing header manifest inputs
2026-11-25 11:30:15 +13:00
Dean fbab2e63a7 Merge pull request #26715 from xXPBSXx/test/libkernel-pin-QueryMemoryProtection-null-outputs
test(libkernel): pin the sceKernelQueryMemoryProtection results with NULL outputs measured on a PS5
2026-11-25 11:29:55 +13:00
Dean fb098ec8eb Merge pull request #26714 from kripotker/fix/scandir-sort
fix(libc): sort scandir results in place with qsort_r, as FreeBSD 11.4 does
2026-11-25 11:29:34 +13:00
Dean 4be7999d63 Merge pull request #26711 from cookie42073-cmd/fix/review-queue-metadata-pages-20261124
fix(tools): keep incomplete review metadata out of the queue
2026-11-25 11:29:13 +13:00
Dean 296ddf18fc Merge pull request #26710 from cookie42073-cmd/fix/release-notes-file-validation-20261124
fix(tools): verify release note files without unbounded reads
2026-11-25 11:28:52 +13:00
Dean c0bad9b310 Merge pull request #26707 from Ducengarth/fix/pr-overlap-out-oserror
fix(tools): report pr_overlap output errors without traceback
2026-11-25 11:28:31 +13:00
Dean 8609c228c5 Merge pull request #26703 from Ducengarth/fix/agc-test-split-git-error
fix(tools): report agc_test_split git and file errors without a traceback
2026-11-25 11:28:09 +13:00
Dean 202c1b473b Merge pull request #26677 from olegon85/feat/libscecamera-set-focus-register-1360
feat(libSceCamera): implement Set*/Focus/Register answers measured on 13.60
2026-11-25 11:27:49 +13:00
Dean 3f55fe5ea6 Merge pull request #26464 from marick-py/fix/select-test-build-inputs
fix(tools): reject copied build caches in test selection
2026-11-25 11:27:28 +13:00
Dean d57a135787 Merge pull request #26424 from ToRaNek/fix/nkwebkit-layout-rect-saturation
fix(libSceNKWebKit): saturate LayoutRect sums and fix two geometry tests against WebKit
2026-11-25 11:27:07 +13:00
Dean cc2e43451f Merge pull request #25332 from kessler-drift/fix/libscelibressl3-x509-sign-params
fix(libSceLibreSsl3): re-encode the signature algorithm before X509_sign signs
2026-11-25 11:07:53 +13:00
Dean adbb133c84 Merge pull request #25329 from kessler-drift/fix/libscelibressl-bn-negative-zero
fix(libSceLibreSsl): keep negative zero in BN_bin2bn and the zero-word BN_add_word and BN_sub_word
2026-11-25 11:07:38 +13:00
cozejarrandClaude Opus 5.5 0ad66daf9f test(libSceIcu): check the lenient run's buffer past its terminator
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 22:06:18 +00:00
vishnuvardhan3333 3e2d6f5dc0 feat(libSceOpusCeltEnc,libSceOpusSilkEnc): implement float-priority and infinite-timeout encode 2026-11-25 03:34:21 +05:30
Dean a40a1399b5 Merge pull request #25323 from amazedturnip/fix/libwebrtc-rtp-packet-received-extensions
fix(libwebrtc): validate guest extensions pointer in RtpPacketReceived ctor
2026-11-25 11:00:17 +13:00
Dean 0959cb35a3 Merge pull request #25320 from AltewamaPrime/feat/libwebrtc-audio-device-buffer-lifecycle
feat(libwebrtc): implement AudioDeviceBuffer playout and recording start and stop
2026-11-25 10:59:55 +13:00
gccodyandClaude Opus 5.5 b4002cce37 test(shader): draw quad_perm [0,0,0,0] and [3,3,3,3] in the pixel helper test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 16:59:24 -05:00
gnavarro24 acf5d4397a feat(libScePosixForWebKit): implement lockf (#26517)
* feat(libScePosixForWebKit): implement lockf
* test(libScePosixForWebKit): check lockf on a read-only descriptor and negative sizes
2026-11-25 10:52:29 +13:00
Dean 5f1d85611e Merge pull request #20211 from Kikoarl/fix/libSceFont-getEffectSlant-copyout
fix(libSceFont): safely copy out slant ratio in sceFontGetEffectSlant
2026-11-25 10:52:04 +13:00
Louis FaustandDevin AI f1276b98b1 fix(tools): keep the checkout path of debt_split when it ends in whitespace
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-24 21:48:12 +00:00
MarcZX10 9c1a2266a4 docs(agents): name the find_package exceptions the checker allows 2026-11-24 22:45:59 +01:00
MarcZX10 8f8440ba8d docs(contributing): state the ENVIRONMENT.md row rule for new variables 2026-11-24 22:45:51 +01:00
MarcZX10 9c7dfcd5f2 docs(usage): state that any value enables APS5_DRAW_PIPELINE 2026-11-24 22:40:37 +01:00
MarcZX10 6a9ec0a8dc docs(input): point the key catalogue reference at the pinned SDL commit 2026-11-24 22:40:29 +01:00
MarcZX10 8399746fdb docs(input): document the 32-character limit for title IDs 2026-11-24 22:40:21 +01:00
MarcZX10 ad05d6d09d docs(input): correct the number of interface and FAQ languages to 24 2026-11-24 22:40:13 +01:00
Dean 4f7f71fbe4 Merge pull request #18867 from slopgobblercobbler/slopgobblercobbler/worker189-libkernel-soc-thermal
test(libkernel): audit sceKernelGetSocPowerConsumption and sceKernelGetSocSensorTemperature bounds
2026-11-25 10:39:41 +13:00
xXPBSXx f6005b11cd fix(libkernel): fcntl F_GETOWN and F_SETOWN store and return the owner of a pipe (#18457)
* test(libkernel): pin fcntl F_GETOWN and F_SETOWN on a pipe
* fix(libkernel): keep the owner F_SETOWN sets on a pipe and return it from F_GETOWN
* docs(debt): state the F_GETOWN and F_SETOWN results of a PS5 payload process
* test(libkernel): pin that a pipe duplicated before the first F_SETOWN shares its owner
* fix(libkernel): create the owner of a pipe before a duplicate can share it
* docs(debt): state that dup, dup2 and F_DUPFD share the owner of a pipe
2026-11-25 10:39:19 +13:00
Dean 286e3becd9 Merge pull request #15330 from MarcZX10/r2/r48-npcommon
fix(libSceNpCommon): keep split UTF-8 lead bytes and saturate callout deadlines
2026-11-25 10:38:57 +13:00
nikmparis217-ux 298bbec0e9 fix(libSceSystemService): answer the enter button assignment to PS4 titles 2026-11-24 23:37:34 +02:00
MarcZX10 c8e2c3d82c docs(debt): link the entry length rule from the technical debt page 2026-11-24 22:35:00 +01:00
MarcZX10 db47ce82f8 docs(contributing): state the 1000-character limit for debt entries 2026-11-24 22:35:00 +01:00
MarcZX10 8d2b8dfa6d test(tools): normalize the compiler path in test_select_tests on Windows
Same CMake cache-parsing failure as the other tests in this branch: the
compiler path from shutil.which reaches -DCMAKE_C_COMPILER with backslashes
on native Windows. Use forward slashes in the five fixtures.
2026-11-24 22:28:33 +01:00
MarcZX10 93701b72b4 test(tools): pass CMake compiler and Ninja paths with forward slashes
shutil.which returns native Windows paths. Passed to cmake as -D values
they break CMake's cache parsing on Windows ("Invalid character escape
'\M'"). Normalize the paths with Path.as_posix() in the four tests that
pass them to cmake: test_configure_seed, test_package_release,
test_build_changed_guest_tests and test_check_compile.
2026-11-24 22:25:51 +01:00
Dean 7c44e0ba9d Merge pull request #26723 from cookie42073-cmd/fix/configure-cache-effective-entries-20261124
fix(tools): use effective configure cache assignments
2026-11-25 10:24:43 +13:00
Dean 8203ed4a84 Merge pull request #26708 from kripotker/feat/nftw-mount-chdir
feat(libScePosixForWebKit): implement nftw FTW_MOUNT and FTW_CHDIR
2026-11-25 10:22:09 +13:00
Roman Tonn bd3a694f2b fix(libSceFreeTypeOt): refuse misaligned guest records in ft_module_get_service (#26673)
* fix(libSceFreeTypeOt): refuse misaligned guest records in ft_module_get_service
* test(libSceFreeTypeOt): reject module records aligned to 4 but not to 8
* test(libSceFreeTypeOt): reject module classes and libraries aligned to 4 but not to 8
2026-11-25 10:17:13 +13:00
Roman Tonn 4c96a599f4 test(libSceJsc,libSceLibreSsl3): skip memcmp for empty ranges in two tests (#26661) 2026-11-25 10:16:51 +13:00
cozejarrandClaude Opus 5.5 2e22f7b851 test(libSceIcu): convert the scalar sweep in runs instead of one call per scalar
guest_icu_utf_conversions converted each of the 1,112,064 Unicode scalars
with three separate calls. Since the conversions copy their operands through
guest memory, that takes about 9 s on Windows and 9.5 s on a 4-core Linux
container against the test's 10 s timeout, and it times out under parallel
load. The sweep now converts the scalars in runs of about 8 KiB of UTF-8,
comparing every unit of each run in all three directions, and keeps the
single-scalar checks, with their canaries, at every UTF-8 and UTF-16 width
boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 21:15:31 +00:00
Helldiverr a6de4a9617 docs(build): name the real cause of Defender's ShellCode.MKA!MTB on AGC tests 2026-11-24 22:14:52 +01:00
nikmparis217-ux 734b70a1aa feat(libSceTextToSpeech): answer a PS4 title's initialization as firmware 13.52 does without a text-to-speech server 2026-11-24 23:12:40 +02:00
Eduardo Ruiz Peña c2a0c13039 feat(libSceAbstractYoutube): export the unnamed NIDs of the 13.40 module (#19711) 2026-11-25 10:09:36 +13:00
Dean a71c16927b Merge pull request #25343 from gurtgg/fix-libressl-ssl-ctx-callbacks-guest-memory
fix(libSceLibreSsl): validate guest memory access in SSL_CTX callback setters
2026-11-25 10:06:38 +13:00
Dean 92a36fa65f Merge pull request #25340 from amazedturnip/fix/libwebrtc-rtp-transceiver-init-guest-guard
fix(libwebrtc): validate RtpTransceiverInit ctor guest init pointer
2026-11-25 10:06:18 +13:00
Nicolas GonzalezandClaude Opus 5.5 4b3f8d4402 perf(agc): bind indices behind a GPU writer for draws with vertex attributes
APS5_INDEX_IN_PLACE_BEHIND_WRITER refused every draw whose vertex shader
has fixed vertex attributes, because sizing the vertex buffer copies needs
the highest index, which the CPU cannot read while the GPU still writes the
indices. Those draws fell back to a CPU wait for the writer, taken under
the GPU mutex.

Take them behind the writer too and read each vertex attribute from its
whole buffer descriptor, as an indirect draw already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 18:04:19 -03:00
Dean 95702cd8d8 Merge pull request #26702 from u-instinct11/docs/interval-csv-empty-captures
docs(tracing): explain empty interval CSV exports
2026-11-25 10:03:39 +13:00
Dean 02cbc28a52 Merge pull request #26701 from u-instinct11/fix/ab-uppercase-hex-prefix
fix(tools): accept uppercase A/B program key prefixes
2026-11-25 10:03:16 +13:00
Dean 2795fe6c7c Merge pull request #25174 from DORON1346/test/atomic-wait-deadline-workdir
test(libSceLibcInternal): run atomic_wait_deadline in its own working directory
2026-11-25 10:02:54 +13:00
Dean 685b72623b Merge pull request #25170 from XFlawless1/feat/nkwebkit-inspector-content-search-regex
feat(libSceNKWebKit): implement Inspector::ContentSearchUtilities::createRegularExpressionForSearchString and countRegularExpressionMatches
2026-11-25 10:02:33 +13:00
Dean 46610c5119 Merge pull request #19579 from edubox/feat/sceabstractyoutube-immediate-returns
feat(libSceAbstractYoutube): return 0x809E0005 from Folder Open and Close
2026-11-25 10:02:11 +13:00
milescovielloandClaude Opus 5.5 475bf2f817 test(libkernel): check sceKernelDebugWriteCppExceptionInfo at the 64 KiB name limit
The test never passed a type name or message near the 65536-byte limit of
the checked copies, so counting a too-long type as copied, or printing
the what() prefix for a message that did not fit, still passed. Check
that a 65535-character type prints in full, that a 65536-character type
prints as (unknown) and that a 65536-character message is left out. From
Helldiverr's Windows mutation run on #25985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:59:23 -05:00
nikmparis217-ux 6be0029fdf feat(libSceVideoOut): accept the VR option of PS4 buffer registrations as firmware 13.52 does 2026-11-24 22:56:04 +02:00
Dean 893b2b7f23 Merge pull request #26584 from DerKarussellbremser/fix/erfc-large-negative-flags
fix(libc): erfc raises no flag from -28 down
2026-11-25 09:52:27 +13:00
Dean fe9ba39249 Merge pull request #17475 from slopgobblercobbler/slopgobblercobbler/pr-libsceuserservice-foreground-user
test(libSceUserService): audit foreground user query and pointer validation
2026-11-25 09:52:04 +13:00
Dean 5c15521244 fix(icu): drop unused uprops.icu from embedded common data
ICU4C never opens uprops at runtime. Grapheme and InCB properties come
from the compiled in uchar_props_data.h and ExtPict from uemoji.icu,
which is already embedded. Also update the debt note, which still
described break iteration.
2026-11-25 09:49:11 +13:00
MarcZX100 53f6ce0e48 test(tools): cover select_tests Build query, walk, leaves and outputs 2026-11-24 21:49:10 +01:00
Codex 4f2c825da5 fix(tools): keep computed environment bounds with expressions unresolved 2026-11-24 20:42:31 +00:00
Codex 10665922c0 fix(tools): resolve C++ integer literals in computed environment names 2026-11-24 20:41:43 +00:00
xXPBSXxandClaude Sonnet 5.5 9d8433e605 docs(libkernel_sys): record the module list sceKernelGetModuleListInternal and the check order of sceKernelGetModuleInfoInternal on firmware 11.60
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 21:40:35 +01:00
Codex 7016ead6e4 fix(tools): reject contradictory trace loss metadata 2026-11-24 20:39:49 +00:00
nikmparis217-ux dd135facc5 feat(libSceVideoRecording): answer sceVideoRecordingSetInfo for PS4 titles as firmware 13.52 does without a capture service 2026-11-24 22:38:11 +02:00
Dean 61cce6e86b Merge pull request #26704 from kripotker/fix/nftw-follow-root
fix(libScePosixForWebKit): follow the nftw starting path under FTW_PHYS and reject an empty one
2026-11-25 09:18:31 +13:00
KerutzuuandCopilot App e9078ebffc fix(libSceNKWebKit): use embedded Unicode grapheme data
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-24 21:17:09 +01:00
Dean 748665080d Merge pull request #25384 from olegon85/fix/libsceaudioin-negative-type-gates
fix(libSceAudioIn): reject negative types in the mic-level device gate
2026-11-25 09:15:51 +13:00
nexus1692 6aaa8e4362 test(libSceBgft): pin the alias ladder and the unread parameter fields
The official guest_bgft suite covered the Ex registration checks but not
the alias ordering (null params before the init gate), the parameter
fields the module never reads, or the task id staying unwritten. These
assertions pin the firmware 13.42 ladder recorded in
docs/dev/debt/libSceBgft.md so a later change cannot start rejecting
titles on unread strings.

AI-assisted: yes (FreeBuff). Adds coverage for the documented sceBgftServiceIntDownloadRegisterTaskByStorage ladder.
2026-11-24 21:11:07 +01:00
Dean bb35a6487c Merge pull request #25371 from kessler-drift/fix/libsceicu-resource-utf8-empty-string
fix(libSceIcu): read resource 0 as the empty string in the UTF-8 resource accessors
2026-11-25 09:08:12 +13:00
Dean ded9f19efd Merge pull request #25368 from kessler-drift/fix/libscelibressl3-pkey-rsa-cms-ctrl
fix(libSceLibreSsl3): accept CMS controls on RSA EVP_PKEY_CTX
2026-11-25 09:07:51 +13:00
Dean c1a90ebe4d Merge pull request #25357 from amazedturnip/fix/libSceNKWebKit-authentication-challenge-nullify
fix(libSceNKWebKit): validate guest AuthenticationChallenge in nullify
2026-11-25 09:07:25 +13:00
Dean ffc99f0085 Merge pull request #25356 from kessler-drift/fix/libscelibressl3-i2d-x509-empty-bitstring
fix(libSceLibreSsl3): write no unused bits for an empty BIT STRING in i2d_X509
2026-11-25 09:07:04 +13:00
Codex 8a2b8fa0f4 fix(tools): preserve Unicode CMake checkout paths for title runs 2026-11-24 20:06:59 +00:00
Codex 50c493f648 fix(tools): honor exclusive loop bounds in environment audits 2026-11-24 20:06:58 +00:00
Codex f0400a12c4 fix(tools): report recorded thread event loss in performance comparisons 2026-11-24 20:06:58 +00:00
Codex 975f3ad3e6 fix(tools): reject nonfinite values in performance summaries 2026-11-24 20:06:57 +00:00
Dean 6ee5b70d31 Merge pull request #25353 from DonRyuzaki/codex/libcxx-thread-state-20261121
feat(libc): implement libc++ thread state
2026-11-25 09:06:43 +13:00
Dean 495eed70ef Merge pull request #25349 from gurtgg/fix-npmanager-ticket-clear-before-release
docs(libSceNpManager): record NpTicket::Clear store order and test idempotence
2026-11-25 09:06:21 +13:00
Dean b649f34ab4 Merge pull request #25348 from gurtgg/fix-libc-sony-localeconv-thread-local-reset
test(libc): cover SonyLocaleconv C-locale defaults in GuestCrt
2026-11-25 09:06:00 +13:00
milescovielloandClaude Opus 5.5 f9ec5c4032 fix(libSceFont): check the handle and record outputs under the host write their copy opens
sceFontMemoryTerm, sceFontDestroyLibrary, sceFontDestroyRenderer, the
sceFontOpenFont* handle slot and sceFontDeleteGlyph checked their output
with GuestWritable_nid_no_patch alone. On Windows a guest page armed for
write tracking is read-only until a host write opens it, so a valid call
on such a page returned SCE_FONT_ERROR_INVALID_PARAMETER, and
sceFontDeleteGlyph kept the glyph. Use Font::OutputWritable, which opens
the same GuestArena::HostWrite first. guest_font_output_pointers_watched
runs each of these calls with its output on a write-watched page. The
Writing records debt line now describes the local record and the early
check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:01:53 -05:00
LeandroLP23andClaude Opus 5.5 558eb72ac0 refactor(libc): drop the unused platform includes of the boundary tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 20:57:19 +01:00
Codex 0809a8111a test(tools): exercise CMake reply recursion limits on Python 3.14 2026-11-24 19:52:11 +00:00
Codex e9e79e384f fix(tools): diagnose ambiguous MinGW CMake replies 2026-11-24 19:52:11 +00:00
KerutzuuandCopilot App 85e33db4df fix(libSceNKWebKit): retain grapheme text for ICU
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-24 20:48:50 +01:00
KerutzuuandCopilot App 33be1bbd02 feat(libSceNKWebKit): implement UTF-16 grapheme counts
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-11-24 20:48:47 +01:00
Kikoarl 1f1d9cd2ee fix(libSceAgc): validate and safely copy shader destination pointer in sceAgcCreateShader 2026-11-24 20:44:41 +01:00
Dean 5f04682cef Merge pull request #25416 from malekaifa/prime-f/test-https-ssl-error-guest-pointers-20261122
test(libSceHttp): cover SSL error guest outputs
2026-11-25 08:18:22 +13:00
Dean ca9c5bd58b Merge pull request #25414 from heditrigui/feat/nkwebkit-icon-database
feat(libSceNKWebKit): implement WKIconDatabase and context icon database operations
2026-11-25 08:18:00 +13:00
Dean d195a925c0 Merge pull request #25390 from kessler-drift/fix/libscelibressl3-key-ber-lengths
fix(libSceLibreSsl3): accept BER long-form lengths in the key decoders
2026-11-25 08:17:38 +13:00
Dean a2e3c0cacf Merge pull request #25388 from kessler-drift/feat/libsceicu-data-swap
feat(libSceIcu): implement the collation, normalization, alias, name, break and dictionary data swappers
2026-11-25 08:17:16 +13:00
Dean 2711791787 Merge pull request #26712 from Ducengarth/codex/suggest-patches-sha-cache
perf(tools): reuse target SHA-256 digests within a patch advisor run
2026-11-25 08:07:34 +13:00
Magnus 928cb99a51 fix(tools): drop the host libc fallback for a bundled libSceLibcInternal 2026-11-24 20:05:16 +01:00
Dean 89aad367ae Merge pull request #25487 from DonRyuzaki/codex/libcxx-string-find-20261122
feat(libc): add libc++ character searches
2026-11-25 07:59:21 +13:00
Dean 88bf680224 Merge pull request #25448 from Filip722/filip722/rtx-push-fragment-image-metadata
perf(shader): push image metadata that fits the stage range
2026-11-25 07:58:44 +13:00
Dean 17251340ce Merge pull request #25442 from JJenkx/fix/libScePosixForWebKit-fnmatch-guest-pointers
fix(libScePosixForWebKit): copy guest strings safely in fnmatch
2026-11-25 07:58:21 +13:00
Dean 921b5c1aa2 Merge pull request #25440 from mnoori11/fix/libkernel-open-creat-directory
fix(libkernel): look the path up for open with O_CREAT and O_DIRECTORY
2026-11-25 07:57:48 +13:00
Dean 26dd27366f Merge pull request #25438 from DonRyuzaki/codex/libcxx-bad-weak-ptr-20261122
feat(libc): add libc++ bad_weak_ptr
2026-11-25 07:57:25 +13:00
Dean 96b017e578 Merge pull request #25437 from kessler-drift/fix/libscejxr-bitio-no-access-page
test(libSceJxr): probe unreadable bit I/O state through a no-access page
2026-11-25 07:57:03 +13:00
Dean b96b75b409 Merge pull request #25427 from cookie42073-cmd/fix/duplicate-saved-test-graph-keys-blazingcook-20261121
fix(tools): reject duplicate keys in test graph JSON
2026-11-25 07:56:42 +13:00
Dean 31088e9ad0 Merge pull request #26443 from ToRaNek/feat/nkwebkit-websocket-frame-constructor
feat(libSceNKWebKit): implement the 3.20 WebSocketFrame constructor
2026-11-25 07:54:01 +13:00
Dean 36c5b944a3 Merge pull request #25117 from Fernando-Laydner/fix/web-locale-dynamic
fix(web): update progress text on language changes
2026-11-25 07:53:39 +13:00
Dean a58187d9b1 Merge pull request #20036 from Krille2004zzz/feat/libwebrtc-rtp-packet-parse
feat(libwebrtc): implement RtpPacket::Parse
2026-11-25 07:53:18 +13:00
Dean 03064c281f Merge pull request #20441 from milescoviello/fix/npcommon-probe-heap-allocator-outputs
fix(libSceNpCommon): safely probe the allocator outputs of the heap getters
2026-11-25 07:43:26 +13:00
Dean aae1ec1424 Merge pull request #25506 from mnoori11/fix/libc-strtod-hex-subnormal-rounding
fix(libc): round hexadecimal subnormal strtod results correctly
2026-11-25 07:28:15 +13:00
Dean 52e74b8d79 Merge pull request #25507 from XFlawless1/fix/ult-queue-copy-failure-handoff
fix(libSceUlt): hand off queue wakeups after failed buffer copies
2026-11-25 07:25:00 +13:00
Dean 8682b131b9 Merge pull request #25494 from mauroalvare/fix/libcurl-unix-socket-guest-path
fix(libcurl): resolve CURLOPT_UNIX_SOCKET_PATH as a guest path
2026-11-25 07:24:19 +13:00
Kikoarl a27cbc3956 fix(libSceFont): safely copy out slant ratio in sceFontGetEffectSlant 2026-11-24 19:22:13 +01:00
xXPBSXxandClaude Sonnet 5.5 b215c3ab0b docs(libSceAgc): record how sceAgcGetGsPrimPayload searches the IDX_FORMAT registers on firmware 11.60
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 19:18:34 +01:00
Dean d855484eab Merge pull request #26360 from JJenkx/windows/agc-stencil-expand-no-drain
perf(agc): do not drain for a stencil-only expand without a clear
2026-11-25 07:16:49 +13:00
Dean bc90bf5dcd Merge pull request #26302 from aKazm1/fix/relinker-fs-sweep-zero-padding
fix(relinker): sweep fs accesses past zero padding that crosses a 16-byte boundary
2026-11-25 07:16:27 +13:00
Dean 4c0cefb341 Merge pull request #26273 from Gonic0/fix/agc-store-drawn-linear-lock-order
fix(agc): check host imports outside the pending storage image mutex when storing drawn linear targets
2026-11-25 07:16:05 +13:00
Dean 20fdc3b1c1 Merge pull request #26115 from meh7an/perf/agc-compare-hook-guard
perf(agc): read the compare hook only when one is installed
2026-11-25 07:15:40 +13:00
Codex f5687c8764 fix(tools): validate benchmark capture evidence and build identity 2026-11-24 18:15:09 +00:00
Kikoarl 872dddd7d5 feat(shader): accept SDWA byte destination selectors on v_cvt_norm_u16_f16 2026-11-24 19:08:36 +01:00
Dean f5d7f0ddbd Merge pull request #25519 from amazedturnip/fix/libSceJsc-error-message-for-transfer-validate-buffer
fix(libSceJsc): validate guest array buffer pointer in errorMesasgeForTransfer
2026-11-25 07:00:10 +13:00
Dean 70d55478ab Merge pull request #25518 from u-instinct11/fix/jpeg-parser-cancel-reentrant-init
fix(libSceJpegParser): cancel initialization on reentrant Finalize
2026-11-25 06:59:48 +13:00
Dean 462b783977 Merge pull request #25510 from mnoori11/fix/libkernel-stat-lookup-before-efault
fix(libkernel): report the lookup error before EFAULT from stat, lstat and fstatat with a null buffer
2026-11-25 06:59:24 +13:00
Dean b7cbb321de Merge pull request #25663 from malekaifa/prime-f/http2-status-guest-output-20261122
fix(libSceHttp2): copy status output through guest memory
2026-11-25 06:54:00 +13:00
Dean 30cea8d6fc Merge pull request #26726 from oneandonlydean/fix/debt-fold-rudp
docs(debt): fold the two libSceRudp fragments into one
2026-11-25 06:51:38 +13:00
Dean d972d0d700 Merge pull request #26684 from Treamyracle/fix-libressl3-evp-cipher-final-guest-pointers
fix(libSceLibreSsl3): validate EVP_CipherFinal guest pointers before access
2026-11-25 06:50:44 +13:00
Dean acd85d6985 Merge pull request #26678 from gccody/fix/http2-resolve-wait-unanswered
fix(libSceHttp2): wait out a slow host lookup and report an unanswered one
2026-11-25 06:50:15 +13:00
Dean 096734d3c0 Merge pull request #26485 from TheExtreMeLeGend/fix/libc-current-set
fix(libSceLibcInternal): implement filesystem current directory setter
2026-11-25 06:49:52 +13:00
Dean 9f972c0e99 Merge pull request #25582 from JJenkx/fix/libSceJson2-parser-guest-pointers
fix(libSceJson2): validate guest pointers in Parser::parse exports
2026-11-25 06:49:13 +13:00
Dean a55caa2021 Merge pull request #25551 from mcarkade/test/host-performance-refusal-exit
test(kernel): honor host performance refusal test exit status
2026-11-25 06:48:50 +13:00
Dean 03d86abef1 Merge pull request #25543 from zaryabzip/fix/keyboard-key2char-order
fix(keyboard): check sceKeyboardGetKey2Char's arguments before its handle, as firmware 9.20 does
2026-11-25 06:48:28 +13:00
Dean 170c649268 Merge pull request #25539 from mauroalvare/fix/httpcache-unmerged-header-prefixes
fix(libSceHttpCache): exclude unmerged 304 header prefixes
2026-11-25 06:48:02 +13:00
Dean fbd564a33b Merge pull request #25533 from mauroalvare/fix/libkernel-win-multicast-addr
fix(libkernel): reject 0.0.0.0/8 multicast interface addresses on Windows with EADDRNOTAVAIL
2026-11-25 06:47:41 +13:00
sash2kkandClaude Opus 5.5 abb24b7d89 test(agc): cover a pass shadow owed two written ranges
A draw that stores through two overlapping buffer descriptors stages
one region and owes its pass shadow both written ranges. The new case
checks that both reach guest memory through the one copy-back at the
pass end, which fails if the owed ranges are not merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 18:47:39 +01:00
sash2kkandClaude Opus 5.5 9263e7ed1a perf(agc): keep a draw's staged buffer in one shadow for the open render pass under APS5_PASS_STAGING
Recorded draws that store to one staged buffer each ended the open
render pass twice, once for the copy-in and once for the copy-back.
With APS5_PASS_STAGING the builds of recorded draws bind one
device-local shadow per staged range, a draw whose shadow is still
current records no copy-in and keeps the pass open, and the changed
copy-back is recorded once when the pass ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 18:47:38 +01:00
Dean 9d1ae71ff6 Merge pull request #25526 from pinewhite/feat/icu-string-utf8-conversions
feat(libSceIcu): copy the UTF-8 conversion operands through guest memory
2026-11-25 06:47:19 +13:00
muhmuhkuhandClaude Sonnet 5.5 e60ea38da2 fix(agc): limit APS5_AB arm names to what tools/ab_split.py reads
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 18:45:38 +01:00
muhmuhkuhandClaude Sonnet 5.5 79c9a17366 feat(tools): split the arms of a rotated or multi-arm APS5_AB log in ab_split.py
ab_split.py reads arm names beyond A and B and gives each arm other than A
its own rows. With more than two arms or with APS5_AB_ROTATE, the noise column
compares each phase of an arm with the A phases of its own cycle, whose length
the [ab] header gives, so the drift cancels over the rotated orders. The two-arm
form without rotation keeps its neighbour pairing.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 18:45:38 +01:00
muhmuhkuhandClaude Sonnet 5.5 a495f2ef6b feat(agc): rotate the arm order of APS5_AB at every cycle with APS5_AB_ROTATE
With APS5_AB_ROTATE set, cycle k of the plan begins with arm k modulo the
number of arms, so no arm always comes first. The [ab] header says so, and the
phase lines still name the arm of each phase.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 18:45:38 +01:00
muhmuhkuhandClaude Sonnet 5.5 dff27450a3 feat(agc): run more than two arms in the APS5_AB schedule
APS5_AB takes <seconds>:<arm>|<arm>[|...] besides the two-arm list. An arm
is A (the environment's settings), a named group <name>=<switch>[+...] or
a name defined earlier, and phase k uses arm k modulo the arm count. The
[ab] lines carry the arm's name; the two-arm form still prints A and B.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 18:45:37 +01:00
Oleg 37ceaaf48f fix(libSceCamera): throw SetForceActivate for open handles per Helldiverr 2026-11-24 22:40:18 +05:00
Dean 8cd922d1d8 fix(libSceNKWebKit): drop duplicate WKBundleBackForwardListClear stub
NoOpExports.cpp already defines it with the void signature declared in
InventoryExports.hpp.
2026-11-25 06:35:41 +13:00
Oleg 4fedc40644 fix(libSceCamera): debt file + guest_camera test for 13.60 measurements 2026-11-24 22:30:52 +05:00
fromthemoonxandClaude Opus 5.5 73d8b206b2 test(libSceLibreSsl): cover Wycheproof RSA PKCS#1 v1.5 signature vectors
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXR27cF7vWGYhHAKkch19V
2026-11-24 14:30:36 -03:00
Dean b1c89b54e1 docs(debt): fold the two libSceRudp fragments into one
fix-rudp-unconnected-read-write.md and fix-rudp-net-received-checks.md
both changed the sceRudpProcessEvents, sceRudpNetFlush and
sceRudpNetReceived entry, so tools/debt_fold.py --check fails on main.
One fragment now keeps the change for sceRudpProcessEvents and
sceRudpNetFlush, the sceRudpWrite and sceRudpRead entry, and the
sceRudpNetReceived silent stub from 7fb2d48038.
2026-11-25 06:29:48 +13:00
Dean 17220db6a3 Merge pull request #25637 from MarrasFederico/fix/net-detached-thread-leak
fix(libSceNet): create threads without an output detached
2026-11-25 06:27:28 +13:00
Dean ea1ba34731 Merge pull request #25627 from mcarkade/test/run-report-revision-exit
test(run-report): check the revision generator exit status
2026-11-25 06:26:59 +13:00
Dean a0445a3335 Merge pull request #25593 from mnoori11/fix/libc-ungetc-flush-errno
fix(libc): translate the host errno when ungetc and ungetwc fail to flush pending output
2026-11-25 06:26:37 +13:00
Dean 44f6d1a214 Merge pull request #25590 from mcarkade/fix/select-tests-cmake-env
fix(tools): recognize cmake env wrapped tests in the selector
2026-11-25 06:26:14 +13:00
Codex fdd560baa2 fix(tools): reject changing header manifest inputs 2026-11-24 17:25:49 +00:00
Riccardo Mariani e4222ca4ee fix(libSceCesCs): report Shift-JIS lengths without an output buffer 2026-11-24 18:25:05 +01:00
Codex 31da818e7a fix(tools): use effective configure cache assignments 2026-11-24 17:24:58 +00:00
amazedturnip ed58359a11 fix(libkernel): validate guest spin lock pointer in pthread_spin_trylock and pthread_spin_lock 2026-11-24 11:24:53 -06:00
Codex 2f647f7985 fix(tools): identify invalid progress snapshot inputs 2026-11-24 17:24:03 +00:00
Dean b43fc14465 Merge pull request #15899 from slopgobblercobbler/slopgobblercobbler/squad3-worker21-os-debt
test(libSceAudioIn): audit open-ex format bounds, per-path silent state, and buffer guard boundaries
2026-11-25 06:21:14 +13:00
Dean 7a0de821ab Merge pull request #26676 from xXPBSXx/fix/regmgr-getversion-measured-value
fix(libSceRegMgr): return the value sceRegMgrGetVersion gave on a PS5
2026-11-25 06:10:54 +13:00
Dean b341e2490e Merge pull request #26667 from gurtgg/feat-remoteplay-preinit-gates
feat(libSceRemoteplay): gate 37 firmware 13.60 exports before initialization
2026-11-25 06:10:32 +13:00
Dean 4733dc7223 Merge pull request #26656 from shripad-jyothinath/feat/libkernel-sys-socketclose
feat(libkernel_sys): implement __sys_socketclose export and web forward
2026-11-25 06:10:09 +13:00
Dean 940402de3a Merge pull request #24231 from heditrigui/feat/nkwebkit-plugin-information-keys
feat(libSceNKWebKit): implement WKPluginInformation string keys
2026-11-25 06:09:46 +13:00
Gordon d1d700affa feat(libwebrtc): implement cricket::CreateVideoCodec and Codec::~Codec (#26400)
* feat(libwebrtc): implement cricket::CreateVideoCodec and Codec::~Codec
* fix(libwebrtc): use the optional string type main now declares
2026-11-25 06:01:47 +13:00
jagrat Singh 2617b6125b feat(libSceNKWebKit): implement WKPage close and DOM animation suspension controls 2026-11-24 22:30:58 +05:30
Dean bc4cddf422 Merge pull request #26657 from edubox/ci-timing-phases
ci(tools): report each changed-test phase's elapsed time
2026-11-25 05:58:19 +13:00
Dean 1b852ce1e9 Merge pull request #26654 from Fernando-Laydner/fix/sanitizer-junit-diagnostics
fix(tools): read sanitizer diagnostics from JUnit failures
2026-11-25 05:57:56 +13:00
Eduardo Ruiz Peña 4d8ae5a21a feat(libSceVoiceQoS): give remote endpoints their voice port (#26648) 2026-11-25 05:57:32 +13:00
Dean b5b0608746 Merge pull request #25682 from mcarkade/test/wtf-data-log-temp-dir
test(libSceJsc): give each WTF data-log test its own directory
2026-11-25 05:57:10 +13:00
Dean 5c5b9dde60 Merge pull request #25667 from ysaiahdh/test/nid-compute-unit-tests
test(nid): add unit tests for SHA-1 and NID computation
2026-11-25 05:56:48 +13:00
Dean ae3836be64 Merge pull request #25664 from u-instinct11/fix/tiny-sinhl-flags
fix(libc): preserve exception flags for tiny sinhl inputs
2026-11-25 05:56:21 +13:00
Dean b50c00c8a1 Merge pull request #10416 from MarcZX10/feat/libc-rtti-callbacks
fix(libc): implement RTTI cast result callbacks
2026-11-25 05:55:59 +13:00
Dean 23562e14f9 Merge pull request #26683 from u-instinct11/docs/ab-csv-windows-capture
docs(tracing): show how to capture A/B logs on Windows
2026-11-25 05:53:08 +13:00
Dean c4fa6e8335 Merge pull request #26682 from u-instinct11/fix/ab-utf32-diagnostic
fix(tools): identify UTF-32 A/B logs
2026-11-25 05:52:40 +13:00
Dean 9e055cc2e8 Merge pull request #26675 from rickyalvarez185/fix/tools-run-report-fps-domain
fix(tools): reject invalid run FPS metrics
2026-11-25 05:51:53 +13:00
kripotkerandClaude Opus 5.5 c2515c48c4 fix(libc): sort scandir results in place with qsort_r, as FreeBSD 11.4 does
scandir sorted with std::sort, which needs a strict weak ordering and passed the
comparison pointers to locals. A guest comparison that always returns -1 crashed
the host. Sort the returned array with qsort_r through a thunk, as FreeBSD 11.4
scandir.c does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 18:51:37 +02:00
Dean b24baa2ce6 Merge pull request #26669 from PolkadotDom/fix/skip-absolute-export-labels
fix(tools): exclude absolute ELF symbols from image labels
2026-11-25 05:51:30 +13:00
Dean 642c4d360f Merge pull request #26668 from mrvlajnic/docs/libkernel-asan-flag-title-imports
docs(libkernel): record the titles importing sceKernelIsAddressSanitizerEnabled
2026-11-25 05:51:07 +13:00
Dean e78271fbba Merge pull request #26666 from u-instinct11/docs/performance-csv-context
docs(tracing): clarify performance CSV context checks
2026-11-25 05:50:33 +13:00
jagrat Singh aea598caf3 feat(libSceNKWebKit): implement WKBundle origin access allow list controls 2026-11-24 22:20:13 +05:30
Dean 15b18e2576 Merge pull request #26665 from u-instinct11/fix/trace-summary-decode-path
fix(tools): identify invalid trace summary files
2026-11-25 05:50:12 +13:00
Dean 5b460b68bc Merge pull request #26664 from malekaifa/prime-d/unwrap-self-inner-elf-scan-20261124
fix(tools): find valid inner ELF header
2026-11-25 05:49:50 +13:00
Dean 5f2bbe859b Merge pull request #26651 from xXPBSXx/e/docs-libsceuserservice-event-callback-preinit
docs(libSceUserService): record the answers of the event callback exports before initialization on firmware 11.60
2026-11-25 05:49:10 +13:00
Dean b5601c24b2 Merge pull request #26046 from klosixgaming-arch/fix/dcc-mipmapped-color-target-fast-clear
fix(agc): fast-clear the viewed mip of a 2D mipmapped DCC colour target
2026-11-25 05:48:47 +13:00
Dean 94c71ecf54 Merge pull request #25821 from MarrasFederico/test/jxr-wmp-encode-roundtrip
test(libSceJxr): cover WMP encode roundtrips for RGB, gray and odd sizes against jxrlib
2026-11-25 05:48:25 +13:00
Ducengarth 1772e5d866 perf(tools): reuse target SHA-256 digests within a patch advisor run
Cache the digest of each resolved path while its file identity and metadata stay the same. Compute a new digest when the signature changes and reject a target that changes during hashing. Each candidate still goes through the relinker independently.
2026-11-24 17:46:35 +01:00
Codex b2bf3027a1 fix(tools): keep incomplete review metadata out of the queue 2026-11-24 16:46:08 +00:00
Codex cf5803c649 fix(tools): verify release note files without unbounded reads 2026-11-24 16:44:36 +00:00
gnavarro24 6417a957a6 feat(libc): implement fmtmsg (#26373)
* feat(libc): implement fmtmsg
* test(libc): capture fmtmsg output at the descriptor level
* test(libc): include sys/stat.h for the fmtmsg capture on Windows
* fix(libc): follow FreeBSD for fmtmsg output and return codes
2026-11-25 05:44:19 +13:00
Dean dad6acd1b8 Merge pull request #26054 from ShootanoJumper/test/savedata-wide-executable-path
test(savedata): spawn the recovery child through its wide path on Windows
2026-11-25 05:43:14 +13:00
Dean 102b7f7fc6 Merge pull request #25876 from amazedturnip/fix/libSceNKWebKit-TrackPrivateBase-null-self
fix(libSceNKWebKit): validate null self in TrackPrivateBase constructor
2026-11-25 05:42:51 +13:00
Dean e9b74b147f Merge pull request #25872 from birdmarty/fix/agc-expanded-after-whole-depth-publication
fix(agc): take a whole native depth publication as an in-place expand
2026-11-25 05:42:33 +13:00
Dean c9949d8bcf Merge pull request #25829 from dkdhanda8/feat/libSceAppInstUtil-nid-names
feat(libSceAppInstUtil): name the callable export aliases the NID databases resolve
2026-11-25 05:42:04 +13:00
Dean c7cc986140 Merge pull request #25805 from MarrasFederico/test/libressl-file-bio-ctrl
test(libSceLibreSsl): cover file BIO open modes, puts and EOF
2026-11-25 05:41:06 +13:00
Dean 529267265f Merge pull request #25800 from mcarkade/fix/pad-watch-state
fix(pad): publish keyboard pad state after input mapping reload
2026-11-25 05:40:43 +13:00
Dean 03fd0969ea Merge pull request #25698 from mauroalvare/fix/npcommon-getnthchar-guest-input
fix(libSceNpCommon): guard guest text reads in sceNpUtilGetNthChar
2026-11-25 05:40:13 +13:00
Dean 6ef2e4535e Merge pull request #25696 from malekaifa/prime-f/fix-rudp-unconnected-read-write-20261122
fix(libSceRudp): match unconnected read and write errors
2026-11-25 05:39:33 +13:00
Dean eface70fde Merge pull request #25691 from mcarkade/fix/camera-attachment-index
fix(libSceCamera): accept camera index 1 in sceCameraIsAttached
2026-11-25 05:39:08 +13:00
xXPBSXxandClaude Sonnet 5.5 5551bbfb9e docs(libkernel): record that pthread_once faults for an unreadable or unwritable control pointer on firmware 11.60
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 17:38:57 +01:00
Dean adbff2fce7 Merge pull request #25346 from gurtgg/fix-libkernel-sleepwake-falsy-env
test(libkernel): cover APS5_NO_SLEEP_WAKE presence switch in GuestSleepWake
2026-11-25 05:38:42 +13:00
Dean 9c7c411d62 Merge pull request #23218 from gurtgg/fix-audio3d-outputs-bed-guest-bounds
fix(libSceAudio3d): guard pointer wraparound and unmapped bed allocations in Export
2026-11-25 05:38:10 +13:00
Giuseppe Magliano d71f6b1da4 test(agc): run the label import window test with pipelined draws 2026-11-24 17:35:19 +01:00
Giuseppe Magliano a97d23a0fb test(agc): check the label window bytes in the host import report 2026-11-24 17:35:19 +01:00
Giuseppe Magliano 8144375dc7 test(agc): check the label window limit and its least recently used retire
Labels fill the label windows to 16 MiB. Before any build every window is
held, so the next label keeps its CPU path and the windows do not grow.
After a build the next label is recorded on the GPU: the least recently
used window (the first case's) is retired, the newer ones stay and every
label lands.
2026-11-24 17:35:19 +01:00
Giuseppe Magliano 4591aae0ca test(agc): check that a label in a small allocation keeps its CPU path
A label in a 64 KiB allocation must still return reason 7 without making
an import, as #7464 requires for the small blocks titles map per frame.
2026-11-24 17:35:19 +01:00
Giuseppe Magliano 7bdccf5380 test(agc): check that a label in an allocation over the budget uses a window
agc_driver_label_import_window lowers the import budget below a 1 MiB
allocation and stores a label in it. The label must be recorded on the
GPU (reason 0) through one 64 KiB label window, pin exactly that window,
count it as label bytes and land without touching its neighbours.
2026-11-24 17:35:19 +01:00
Giuseppe Magliano 61071eb9cb feat(agc): report the bytes of label windows with the host import counts
HostImportCounts carries the live bytes of label windows, and the host
import report appends them when there are any.
2026-11-24 17:35:19 +01:00
Giuseppe Magliano 4012c6fff4 perf(agc): keep label windows outside the host import budget
The budget refuses a label window exactly when the label's allocation was
refused, so the window rarely imported. Label windows now bypass the
budget, its eviction and the remembered refusals, and have a limit of
their own: at most 16 MiB of windows are live. A window past the limit
retires the least recently used label window that the import eviction
rule would let go (not held by a build, not used in the current or the
previous frame) and rewatches what it unwatched, as retireLeastRecent
does; when no window can go the label keeps the CPU path. Retiring and
clearing the imports keep the label bytes in step.
2026-11-24 17:35:19 +01:00
kripotkerandClaude Opus 5.5 9a4e755ed4 feat(libScePosixForWebKit): implement nftw FTW_MOUNT and FTW_CHDIR
FTW_MOUNT reports a directory on another device than the starting path
once and does not enter it, as fts's FTS_XDEV does. FTW_CHDIR, which
fts honours only for a physical walk, runs each callback in the
directory holding its entry and restores the starting directory; a
directory that opens but cannot be entered reports its entries as
FTW_NS and ends the walk with -1, as FTS_ERR does in nftw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 18:29:46 +02:00
xXPBSXxandClaude Sonnet 5.5 0660d58d7c docs(libSceAgc): record the values sceAgcAcbJumpGetSize and sceAgcAcbRewindGetSize returned on firmware 11.60
A PS5 payload process on firmware 11.60 returned 16 from
sceAgcAcbJumpGetSize and 8 from sceAgcAcbRewindGetSize in three calls
each, also with the argument registers 0, 1, 2, 3, which equals the
values AnyPS5 returns (run 2026-11-24T153625Z). The two existing
entries now say that the return value is measured and that the size of
a written packet is not.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 17:25:15 +01:00
kripotkerandClaude Opus 5.5 f52e1697bb fix(libScePosixForWebKit): follow the nftw starting path under FTW_PHYS and reject an empty one
FreeBSD's nftw opens its fts walk with FTS_COMFOLLOW, so the starting
path is stat'ed (falling back to lstat for FTS_SLNONE) even with
FTW_PHYS, and fts_open rejects a zero-length path with ENOENT. A
starting link to a directory was reported as FTW_SL and not walked, a
dangling one as FTW_SL, and an empty path called the callback with
FTW_NS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 18:21:58 +02:00
DucengarthandClaude Haiku 5.5 0eb1170ca7 fix(tools): report pr_overlap output errors without traceback
Creating the --out directory or writing a report could raise an uncaught
OSError. Handle those filesystem errors in write_reports and exit with
the same pr_overlap diagnostic used by the CLI for other errors.

Cover the failure with a test that points --out at an existing file and
mocks the GitHub and Git operations.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-24 17:21:10 +01:00
Siddhant Singh bc19b57258 docs(tracing): explain empty interval CSV exports 2026-11-24 21:44:31 +05:30
Siddhant Singh 4eac5f72e0 fix(tools): accept uppercase A/B program key prefixes 2026-11-24 21:44:30 +05:30
DucengarthandClaude Haiku 5.5 eede17750b fix(tools): report agc_test_split git and file errors without a traceback
main ran git rev-parse without catching its failure, so running the tool
outside a git checkout ended in a CalledProcessError traceback, although
debt_split.py reports the same situation as a usage error. A missing
CMakeLists.txt (a checkout without the AGC library, or the wrong
directory) also escaped the command handlers as a FileNotFoundError
traceback, because only SplitError was caught.

Reproduction: from a directory outside any repository,
agc_test_split.py refactor printed a Traceback ending in
"CalledProcessError: ... 'git', 'rev-parse', '--show-toplevel' ... 128".
In a git repository without the file, it printed a Traceback ending in
"FileNotFoundError ... CMakeLists.txt". Both now exit 1 with a one-line
message and no traceback.

Tests: CommandErrorTests in test_agc_test_split.py; both cases produced a
Traceback before the change.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-24 17:12:36 +01:00
jagrat Singh a61836cc48 feat(libSceNKWebKit): implement WKBundle user content and style sheet location controls 2026-11-24 21:41:24 +05:30
Dean 45fc4e23bb Merge pull request #26697 from oneandonlydean/fix/posix-nftw-self-import
fix(libScePosixForWebKit): walk nftw directories through the module's own entry points
2026-11-25 05:08:31 +13:00
Ashwin 5ebaaaf254 feat(libSceLibcInternal): implement _Tgamma, _FTgamma and _LTgamma 2026-11-24 21:31:29 +05:30
Ashwin 31fac27092 feat(libSceLibcInternal): implement _Tgamma, _FTgamma and _LTgamma 2026-11-24 21:31:28 +05:30
Dean 1bfc86372a fix(libScePosixForWebKit): walk nftw directories through the module's own entry points
FileTree.cpp called libc's opendir, readdir and closedir, so the module
imported three names it also exports and patched_self_imports failed on
main. Use the directory helpers the module's own exports use instead.
2026-11-25 05:00:59 +13:00
milescovielloandClaude Opus 5.5 deb6867fdf test(libSceNpCommon): check sceNpDbgDumpText with text that ends before an unreadable page
The test's texts were readable heap strings or a fully unmapped address,
so copying whole 4096-byte chunks without aligning them still passed.
Print the last bytes of a readable page that has an inaccessible page
after it, with an exact, a longer and a negative length. From Helldiverr's
Windows probe on #25986.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:55:49 -05:00
milescovielloandClaude Opus 5.5 09131a8ceb test(libkernel): check the dlerror text for an unreadable dlsym name
An unreadable name and an empty name both return null and set a dlerror
message, so the test could not tell them apart. Check that the message
for an unreadable name says so. From Helldiverr's Windows mutation run
on #20622.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:50:23 -05:00
milescovielloandClaude Opus 5.5 ede0079fb9 test(libc): check gets_s with an unwritable buffer for a line that fits
Every unwritable-buffer call in the test took the short-buffer or
end-of-file path, so ignoring a failed copy of a line that fits still
passed. Add a line that fits and read it into an unwritable buffer. From
Helldiverr's Windows mutation run on #20587.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:50:20 -05:00
milescovielloandClaude Opus 5.5 e4dff7bfd0 test(libSceNpCommon): check that sceNpMemoryHeapGetAllocator writes a writable output
The test called sceNpMemoryHeapGetAllocator only with an unwritable output,
so skipping its write still passed. Call it with a writable output while
the memory heap is alive and check the allocator it writes. From
Helldiverr's Windows mutation run on #20441.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:50:19 -05:00
milescovielloandClaude Opus 5.5 9142922558 fix(libSceFont): check that the writing record is writable before the first glyph lookup
sceFontWritingInit builds its record locally and copies it out at the end,
so an unwritable record was only found after PopulateWritingStep had looked
up the first glyph. Check the record first, under the same GuestArena host
write the final copy opens, so an unwritable record fails before any font
access again. The final checked copy stays for a page that changes later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:48:23 -05:00
Dean adacf0bd83 Merge pull request #26647 from cryst4lpepsi/fix/hw-oracle-comgr-isa
test(tools): skip hw-oracle comgr targets the driver does not list
2026-11-25 04:47:14 +13:00
Dean 9d30396b7a Merge pull request #26644 from Fernando-Laydner/fix/perf-pad-record
fix(tools): exclude controller recording from performance captures
2026-11-25 04:46:51 +13:00
Dean f7e5b032c6 Merge pull request #23222 from Thimo188/feat/npwebapi-get-error-code
feat(npwebapi): implement error code parsing
2026-11-25 04:41:10 +13:00
gccodyandClaude Opus 5.5 93508bec28 docs(libSceHttp2): retried lookups share the overall deadline
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:40:25 -05:00
Dean c14fbcd77e Merge pull request #26638 from kattkaries/fix/libc-vasprintf-guest-output
fix(libc): probe vasprintf destination pointer before writing
2026-11-25 04:35:45 +13:00
Dean 4ac6833b2c Merge pull request #26637 from Buraddomoon/refactor/sdk-json-coredump
refactor(libs): share SDK reads in Json2 and coredump
2026-11-25 04:35:19 +13:00
Dean eb95c044bd Merge pull request #26635 from gurtgg/feat-npcommon-util-settings-exports
feat(libSceNpCommon): implement firmware 13.60 utility setting getters in PendingExports
2026-11-25 04:34:57 +13:00
gnavarro24 b9d82bfbdf feat(libkernel): implement sigset and sigpause (#26381)
* feat(libkernel): implement sigset and sigpause
* fix(libkernel): make sigpause take a mask and sigset install without SA_RESTART
2026-11-25 04:34:35 +13:00
Dean 63c6d0b770 Merge pull request #22266 from domx4q/fix/nkwebkit-color-guest-pointers
fix(libSceNKWebKit): copy WebCore::Color guest objects safely
2026-11-25 04:34:00 +13:00
Roman Tonn 66328cd1ff test(tools): split pr_overlap_branch_scan into two CTest entries (#26574) 2026-11-25 04:26:03 +13:00
Dean c047ca4250 Merge pull request #25835 from marick-py/test/ces-cp858-console-table
test(libSceCesCs): verify every CP858 mapping against PS5 measurements
2026-11-25 04:25:41 +13:00
Dean 7720a5cb94 Merge pull request #25834 from msaber07/codex/webrtc-thread-quit
feat(libwebrtc): implement Thread::Quit
2026-11-25 04:25:19 +13:00
RTGG 25fdca0719 feat(libSceVideoCoreInterface): return NOT_INITIALIZED before init in SetFunctionTable and MainLoop 2026-11-24 16:23:50 +01:00
RTGG 0507fb1efa feat(libSceVideoNativeExtEssential): validate codec 2 and 4 profile/level in iwAQhvb9BvY 2026-11-24 16:23:44 +01:00
Dean 950661f52a Merge pull request #24989 from heditrigui/feat/nkwebkit-bundle-hit-test-frame-and-image
feat(libSceNKWebKit): implement WKBundleHitTestResult frame and image accessors
2026-11-25 04:21:55 +13:00
Dean c19d1820bf Merge pull request #24962 from nexus1692/fix/systemservice-title-id-guest-read
fix(libSceSystemService): read guest title ID safely via GuestCopyIn
2026-11-25 04:21:22 +13:00
Dean 430f3ed265 Merge pull request #17347 from MarcZX10/feat/host-keep-screen-awake
feat(videoout): keep the host screen awake while a title runs
2026-11-25 04:20:59 +13:00
Giuseppe Magliano f648b171ad perf(agc): record an unimported label in a large allocation through a window
A queue-0 label whose memory no import covers synced the recorder and was
stored on the CPU (#7464). That is cheap for the small blocks it was made
for, which the title maps every frame, but a label in a large allocation
that the import budget refuses waits for every batch in flight each time.
In Cult of the Lamb (PPSA06465) on a Renoir APU, whose import budget is
586 MiB, the labels land in 16 MiB allocations and the sync costs about
60 ms per frame in gameplay.

Such a label now requests a 64 KiB window of its allocation (Label
requester) and is recorded on the GPU when the window imports. An
allocation no larger than the window keeps the CPU path, so the small
blocks of #7464 are still not imported.
2026-11-24 16:17:20 +01:00
Giuseppe Magliano d05978d815 feat(agc): count host imports requested for labels on their own
ImportRequester gains Label, named "label" in the host import report,
for imports a label store makes so it can be recorded on the GPU. No
import is requested with it yet; the report test now lists it.
2026-11-24 16:17:19 +01:00
Giuseppe Magliano f57a860c9e refactor(agc): take the import window as a parameter of the window helpers
importWindowBounds and windowRun read rangeImportWindow themselves. They
now take the window as a parameter that defaults to it, so a caller can
import a narrower window of a large registered range. No caller changes.
2026-11-24 16:17:19 +01:00
Siddhant Singh d011357dd4 docs(tracing): show how to capture A/B logs on Windows 2026-11-24 20:38:09 +05:30
Siddhant Singh c8a22a10ae fix(tools): identify UTF-32 A/B logs 2026-11-24 20:38:09 +05:30
Arif Athaya Harahap 3325330cd1 fix(libSceLibreSsl3): validate EVP_CipherFinal guest pointers before access 2026-11-24 22:06:53 +07:00
Dean 6fde67a5eb Merge pull request #25871 from birdmarty/fix/agc-sample-htile-stencil-after-expand
fix(agc): sample a stencil kept in HTILE without metadata after an in-place expand
2026-11-25 04:00:43 +13:00
Dean bc9ed4bb24 Merge pull request #25859 from mauroalvare/fix/icu-converter-name-guest-pointers
fix(libSceIcu): guard converter name normalization guest pointers
2026-11-25 04:00:21 +13:00
gccodyandClaude Opus 5.5 8ed56c749f fix(libSceHttp2): wait out a slow host lookup and report an unanswered one
A host lookup that took longer than the request's resolve timeout threw
"request timed out; console error mapping is unknown". On a PS5 the
resolve timeout does not end a lookup: with a 1 s timeout an unanswered
lookup kept resending queries and failed with 0x804101E2 only after
30 s (measurement in docs/dev/debt/libSceHttp2.md). A lookup now waits
for the host resolver until the request's overall deadline, and a lookup
the host resolver reports as unanswered (EAI_AGAIN) returns 0x804101E2
instead of the NXDOMAIN code 0x804101E6.

LEGO Batman: Legacy of the Dark Knight (PPSA16833) sets a short resolve
timeout for its telemetry requests and aborted when one host lookup was
slow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:00:01 -05:00
Dean 2c69e22db9 Merge pull request #25854 from marick-py/fix/ces-console-compat
fix(libSceCesCs): report lengths for rejected UTF-8 to Shift-JIS characters
2026-11-25 03:59:59 +13:00
Dean 3a967a3664 Merge pull request #25847 from mauroalvare/fix/libscelibcinternal-windows-statvfs-paths
fix(libSceLibcInternal,libkernel): use Windows verbatim paths in statvfs, statfs and fstatfs
2026-11-25 03:59:37 +13:00
Dean fb10954e08 Merge pull request #25846 from mauroalvare/fix/libcinternal-multiprecision-guest-words
fix(libSceLibcInternal): copy multiprecision guest word arrays safely
2026-11-25 03:59:15 +13:00
Dean 13be6afb21 Merge pull request #25845 from PostMalloy/feat/libcinternal-wide-num-put-c1
feat(libSceLibcInternal): implement num_put<wchar_t>'s complete-object constructor
2026-11-25 03:58:51 +13:00
Dean c12f958c01 Merge pull request #26591 from gccody/fix/nkwebkit-date-parse-dst-gap
fix(libSceNKWebKit): convert a parsed local date to UTC only once
2026-11-25 03:45:42 +13:00
gnavarro24 b142a4aeba feat(libc): implement sys_errlist and sys_nerr (#26518)
* feat(libc): implement sys_errlist and sys_nerr
* test(libc): pin sys_errlist entries 30 and 95 and state the one difference from FreeBSD
2026-11-25 03:45:18 +13:00
DIMITRIS BEKASandoneandonlydean d270db974f feat(libSceMove): validate type against SDK version in sceMoveOpen (#26195)
* feat(libSceMove): validate type against SDK version in sceMoveOpen
* fix(libSceMove): call ApplicationCompiledSdkVersion after the main rename

Co-authored-by: oneandonlydean <158058829+oneandonlydean@users.noreply.github.com>
2026-11-25 03:44:53 +13:00
Stephen Cork 0ef01db1fa test(libSceFios2): audit debug dump formatting and timestamp error boundaries (#20848) 2026-11-25 03:44:27 +13:00
Dean e742f14e47 Merge pull request #26589 from JJenkx/perf/agc-keep-hot-storage-images
perf(agc): keep storage images used in the last two presents out of the memory release
2026-11-25 03:41:31 +13:00
Dean 37145e1628 Merge pull request #26579 from birdmarty/fix/agc-layered-stencil-plane-sampling
fix(agc): assemble layered stencil plane views through DepthPlaneCopy
2026-11-25 03:41:08 +13:00
Dean 9bb867e0ef Merge pull request #26578 from birdmarty/fix/agc-ucp-cull-only-without-clip-planes
fix(agc): accept PA_CL_CLIP_CNTL UCP_CULL_ONLY_ENA without active clip planes
2026-11-25 03:40:42 +13:00
RTGG ffee9afa4a test(libkernel): cover APS5_NO_SLEEP_WAKE presence switch in GuestSleepWake 2026-11-24 15:40:04 +01:00
RTGG f3cf44266b fix(libSceAudio3d): guard pointer wraparound and unmapped bed allocations in Export 2026-11-24 15:39:57 +01:00
RTGG 455e1793bc fix(libSceJpegDec): preserve live context and stream when sceJpegDecCreate fails 2026-11-24 15:39:53 +01:00
Oleg 9b175685cc feat(libSceCamera): implement Set*/Focus/Register answers measured on 13.60 2026-11-24 19:39:43 +05:00
xXPBSXxandClaude Sonnet 5.5 c6c553ca5d docs(debt): record that sceKernelQueryMemoryProtection skips NULL outputs on a PS5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 15:37:07 +01:00
Dean fa86dfcd3b Merge pull request #26412 from ToRaNek/feat/libscejsc-url-constructor-set-password
feat(libSceJsc): implement the URL(base, relative, encoding) constructor and URL::setPassword
2026-11-25 03:30:46 +13:00
Dean 19de17de4d Merge pull request #26141 from IvanFogel/fix/20261123/jpeg-stream-header
fix(libSceJpegDec): stop header callbacks at the first scan
2026-11-25 03:30:25 +13:00
Dean 8758ba9223 Merge pull request #24957 from imp87/feat/nkwebkit-fixed-formatting
feat(libSceNKWebKit): implement fixed decimal formatting
2026-11-25 03:30:08 +13:00
Tweacked 3f8834b4dd feat(libSceNKWebKit): implement HTTPHeaderMap isolated copy (#23947) 2026-11-25 03:29:45 +13:00
rickyalvarez185 aaa7eebc94 fix(tools): reject invalid run FPS metrics 2026-11-24 15:28:33 +01:00
Dean e5de756897 Merge pull request #26640 from marick-py/fix/diagnostic-scan
fix(tools): batch host-only test targets on Windows
2026-11-25 03:24:30 +13:00
Mehran 3271af0723 perf(agc): answer repeated depth-surface lookups from a per-thread miss memo
DepthSurfaceStorage scanned every depth surface under the registry mutex
on each call. RepeatStorageSurface calls it for each resident color
target of each draw, and the answer is almost always that no depth
surface holds the address.

Each thread now remembers the device and address pairs the scan found
unclaimed, together with the registry serial it read under the mutex. The
serial moves whenever a surface is created or a retired one is bound
again; a surface never changes address or device and only loses its
active flag, so an unclaimed answer holds until the serial moves.

DepthSurfaceStorageScans counts the calls that reached the scan, for the
test.
2026-11-24 17:15:23 +03:00
Dean 7f99fbd60d Merge pull request #26641 from Fernando-Laydner/fix/presentmon-exact-counts
fix(tools): preserve exact PresentMon counts in Markdown
2026-11-25 03:13:35 +13:00
Dean 2a42cde02b Merge pull request #26449 from hamdanpor-ctrl/icu-normalizer2-accessors
feat(libSceIcu): implement the Normalizer2 factory accessors and Normalizer2Impl queries
2026-11-25 03:13:13 +13:00
Dean 89460e0c76 Merge pull request #25975 from cookie42073-cmd/fix/rebase-validation-paths
fix(tools): preserve Git paths and text in rebase verification
2026-11-25 03:12:57 +13:00
Callimann8 47d255af23 feat(libwebrtc): implement four rtc::NetworkManagerBase address helpers (#24668)
* feat(libwebrtc): implement four rtc::NetworkManagerBase address helpers
* fix(libwebrtc): lay out rtc::Network with the 40-byte guest strings
2026-11-25 03:12:35 +13:00
e5ec880151 test(tools): cover the check_conventions checker and its helpers (#22170)
* chore(tools): make check_compile.py executable as its shebang says
* chore(tools): make nid_names.py executable as its shebang says
* chore(tools): make stubgen.py executable as its shebang says
* chore(tools): make unwrap_self.py executable as its shebang says
* test(tools): cover check_compile.validate_arguments rejecting malformed argument lists
* test(tools): cover check_compile.entry_key for relative and outside sources
* test(tools): cover check_compile.command_arguments splitting a POSIX command line
* test(tools): cover check_compile.entries rejecting a missing build directory
* test(tools): cover check_conventions.integer_literal C++ literal forms
* test(tools): cover check_conventions.symbol_nid exclusions
* test(tools): cover check_conventions debt file and fragment paths
* test(tools): cover check_conventions.utf8 decodability
* test(tools): register the check_conventions helper tests in ctest
* test(tools): import check_conventions as a module in the comment tests
* test(tools): cover check_conventions.python_comments comment lines
* test(tools): cover check_conventions.cmake_comments block and line comments
* test(tools): cover check_conventions.flow_mapping YAML flow maps
* test(tools): cover check_conventions.link_syntax keeping ordinary links
* test(tools): cover check_conventions.link_syntax blanking fenced code
* test(tools): cover check_conventions.block child lines of a YAML key
* test(tools): cover check_conventions.field joining continuation lines
* test(tools): cover check_conventions.pull_request_filtered trigger forms
* test(tools): cover check_conventions.brace_scopes nested namespaces
* test(tools): cover check_conventions.scope_chain innermost-first lookup
* test(tools): cover check_conventions.constant_value visible definitions only
* test(tools): cover check_conventions.asm_exports line-keyed assembly names
* test(tools): cover check_conventions.asm_exports ignoring invalid and commented definitions
* test(tools): cover check_conventions.listed accepting an exact or same-library entry
* test(tools): cover check_conventions.listed refusing unrelated names and libraries
* test(tools): cover check_conventions.cpp_pieces keeping source width
* test(tools): cover check_conventions.cpp_pieces masking string literals
* test(tools): cover check_conventions.nid_symbols exported names
* test(tools): cover check_skips.environment_loader_retention exact reason
* test(tools): cover check_skips.symlink_privilege_limitation for the two symlink tests only
* test(tools): cover check_main_sync.render clean and conflict lines
* test(tools): cover check_skips.skips refusing a non-JUnit root
* test(tools): cover check_skips.skips refusing a duplicated test name
* test(tools): cover check_conventions.debt_entries listing items and not headings
* test(tools): cover check_conventions.library for a prx source file
* test(tools): cover check_skips.device_limitations matching device patterns
* test(tools): cover check_skips.high_refresh_limitation 120 Hz message
* test(tools): cover check_main_sync.resolve_base for an existing and a missing ref
* test(tools): cover check_main_sync.lines on git output
* test(tools): cover check_main_sync.names on a tracked tree
* test(tools): cover check_conventions.jobs needs and if fields
* test(tools): cover check_conventions.jobs with no jobs section
* test(tools): cover check_main_sync.git_version returning major and minor numbers
* test(tools): cover check_skips.skips refusing an empty report when tests are required
* test(tools): drop check_conventions and check_skips cases main already covers
* test(tools): register HighRefreshLimitationTests in the check_skips ctest entries

Co-authored-by: MarcZX100 <marczxrr@gmail.com>
Co-authored-by: Dean <158058829+oneandonlydean@users.noreply.github.com>
2026-11-25 03:12:12 +13:00
Federico Marras 6231d37206 test(libc): cover successful wide atomic compare-exchange 2026-11-24 15:08:45 +01:00
Fernando Laydner Júnior 99afaa08d6 fix(tools): allow launcher recording for scripted performance captures 2026-11-24 11:07:56 -03:00
RTGG d99b2ffb5a feat(libSceRemoteplay): gate 37 firmware 13.60 exports before initialization 2026-11-24 15:07:50 +01:00
dom e1f1097205 fix(tools): exclude absolute ELF symbols from image labels 2026-11-24 09:07:49 -05:00
Dean 59ed7bdc41 Merge pull request #25796 from kessler-drift/fix/libsceicu-resource-utf8-index-non-string
fix(libSceIcu): read a non-string item as the empty string in ures_getUTF8StringByIndex
2026-11-25 03:04:26 +13:00
Siddhant Singh 9f1b8092fd docs(tracing): clarify performance CSV context checks 2026-11-24 19:33:04 +05:30
Siddhant Singh 8e371f1ada fix(tools): identify invalid trace summary files 2026-11-24 19:33:03 +05:30
gnavarro24 5e9ad5f57b feat(libScePosixForWebKit): implement nftw (#26362)
* feat(libScePosixForWebKit): implement nftw
* fix(libScePosixForWebKit): match FreeBSD nftw callback order and trailing-slash base
2026-11-25 03:01:49 +13:00
Mohamed Malek Aifa 9d04ffe5d3 fix(tools): find valid inner ELF header 2026-11-24 15:01:30 +01:00
Dean ca62ad8d2b Merge pull request #26288 from HorizonCoding/feat/libc-internal-mbtowc-wctomb
feat(libSceLibcInternal): implement _Mbtowc and _Wctomb
2026-11-25 03:01:27 +13:00
Boris Vlajnić 479f2a8f27 docs(libkernel): record the titles importing sceKernelIsAddressSanitizerEnabled 2026-11-24 15:00:06 +01:00
boykopovar 199c91cf36 Merge pull request #26660 from boykopovar/ci/buffer-spans-tests-timeout
test(agc): raise runtime buffer span test timeouts to 120 seconds
2026-11-24 16:58:06 +03:00
Dean 13c41f1ab5 Merge pull request #26484 from marick-py/test/ces-cp1254-cp1258-wide
test(libSceCesCs): cover measured CP1254 and CP1258 string conversions
2026-11-25 02:57:29 +13:00
Dean 6c2d6f33c3 Merge pull request #26466 from marick-py/test/ces-cp864-measurements
test(libSceCesCs): verify CP864 against the measured PS5 table
2026-11-25 02:57:04 +13:00
Dean a246c178f5 Merge pull request #22685 from Treamyracle/fix-fontconfig-freetype-face-guest-read
fix(libfontconfig): read FreeType face and charmap through guest memory
2026-11-25 02:56:39 +13:00
MarcZX100 1a7634ca14 docs(videoout): record the unverified host keep-awake in a debt fragment
The debt file is edited through a fragment in docs/dev/debt/changes/, not
directly, so the entry moves there and the Focus pause for rumble bullet
keeps its place in the file.
2026-11-24 14:51:46 +01:00
MarcZX100 90c5e0cc99 refactor(videoout): keep the host screen awake only through SDL's default
Drop the keep-awake holder, its SDL backend and its tests. SDL already
disables the screen saver when its video subsystem starts, and main sets
no hint that lets it run. ANYPS5_KEEP_AWAKE=0 now sets
SDL_VIDEO_ALLOW_SCREENSAVER=1 before SDL's video subsystem starts, so the
host screen saver can run; any other value keeps SDL's default.
2026-11-24 14:51:46 +01:00
MarcZX100 de31d36e4d docs(libSceVideoOut): keep the focus pause bullet under its heading; drop an unrelated build line 2026-11-24 14:49:19 +01:00
MarcZX10 8a835fb681 build(libSceRandom): build the extent test after the random test 2026-11-24 14:49:19 +01:00
MarcZX10 64d8df9458 fix(videoout): build the keep-awake backend into libSceVideoOut 2026-11-24 14:49:19 +01:00
MarcZX10 de6cf9f37d docs(videoout): note unverified Windows and X11 keep-awake limits in the debt file 2026-11-24 14:49:19 +01:00
MarcZX10 4f8c065ff0 docs(videoout): note unverified macOS keep-awake in the debt file 2026-11-24 14:49:19 +01:00
MarcZX10 57cda539d4 docs(videoout): note unverified Wayland keep-awake in the debt file 2026-11-24 14:49:18 +01:00
MarcZX10 bb7ad22b32 feat(videoout): release the host keep-awake hold when the display window closes 2026-11-24 14:49:18 +01:00
MarcZX10 20c92490b3 feat(videoout): keep the host screen awake while the display window is open 2026-11-24 14:49:18 +01:00
MarcZX10 3ad198c305 refactor(videoout): give the display window a host keep-awake holder 2026-11-24 14:49:18 +01:00
MarcZX10 d84fa81cfe docs(videoout): document ANYPS5_KEEP_AWAKE in the environment reference 2026-11-24 14:49:18 +01:00
MarcZX10 3ed6533563 feat(videoout): read ANYPS5_KEEP_AWAKE from the environment 2026-11-24 14:49:18 +01:00
MarcZX10 f685242834 feat(videoout): declare the ANYPS5_KEEP_AWAKE reader 2026-11-24 14:49:18 +01:00
MarcZX10 7d5e1c2dea test(videoout): cover a refused inhibit 2026-11-24 14:49:18 +01:00
MarcZX10 405a950830 feat(videoout): log instead of failing when the host refuses the inhibit 2026-11-24 14:49:18 +01:00
MarcZX10 57f2fe0ca5 test(videoout): cover the SDL backend without video 2026-11-24 14:49:17 +01:00
MarcZX10 d15d09c42f feat(videoout): inhibit the host screen saver through SDL 2026-11-24 14:49:17 +01:00
MarcZX10 f50f9576d9 build(videoout): link SDL into the keep-awake test 2026-11-24 14:49:17 +01:00
MarcZX10 aa2c3a24af feat(videoout): declare the SDL keep-awake backend 2026-11-24 14:49:17 +01:00
MarcZX10 9e815c2019 test(videoout): cover acquire and release of the holder 2026-11-24 14:49:17 +01:00
MarcZX10 6d9eca6882 feat(videoout): implement the host keep-awake holder 2026-11-24 14:49:17 +01:00
MarcZX10 56436259d9 feat(videoout): declare the host keep-awake holder 2026-11-24 14:49:17 +01:00
MarcZX10 017a01c0f7 test(videoout): cover ANYPS5_KEEP_AWAKE parsing and register the test 2026-11-24 14:49:17 +01:00
MarcZX10 a165d3d3f4 feat(videoout): parse ANYPS5_KEEP_AWAKE values 2026-11-24 14:49:17 +01:00
Eduardo Ruiz 92674f5dce ci(tools): report each changed-test phase's elapsed time
The Windows pull-request lane builds `libs`, links the selected test
targets and runs CTest inside one step, so the log cannot say which
phase spent the minutes. `build_changed_guest_tests.py` now prints a
`[ci-timing]` line with the elapsed seconds and the target or test
count after each phase: the libs build, the selected and additional
test links, the CTest discovery and the CTest run, plus a total. The
lines print from `finally`, so a failed build or test still leaves them,
and the compiler-cache counters are printed before CTest so they survive
a test failure or timeout. The Windows job also reports ccache
statistics at the end, as the Linux job already does.
2026-11-24 14:48:23 +01:00
Thimo Franken 76565d3550 fix(libSceNpWebApi): use compiled SDK helper 2026-11-24 14:42:02 +01:00
Thimo Franken 2cc42705b5 feat(npwebapi): implement error code parsing 2026-11-24 14:42:02 +01:00
Fernando Laydner Júnior af4f9865ee fix(tools): read sanitizer diagnostics from JUnit failures 2026-11-24 10:41:07 -03:00
Dominik Fuchs cf4313c258 fix(libSceNKWebKit): check the moved-from Color is writable before writing self 2026-11-24 14:36:27 +01:00
Dominik Fuchs c4f28ca1b7 fix(libSceNKWebKit): copy WebCore::Color guest objects safely
The Color constructors, assignments and the colorWithAlpha, darkened,
lightened, lightness and luminance accessors read and wrote the guest
Color objects directly. They now copy the object in with
GuestCopyIn_nid_no_patch, compute on the host copy and copy the result
out with GuestCopyOut_nid_no_patch; an unreadable or unwritable object
fails through NotImplementedAt_nid_no_patch instead of faulting. The
assignment exports return the object pointer, which is the same value
the reference return passed back.
2026-11-24 14:36:19 +01:00
cryst4lpepsi ebbe21feee test(tools): skip hw-oracle comgr targets the driver does not list
test_assembles_both_wave_sizes_with_the_driver_comgr assembles for
gfx1201 since 2640fbc65a. AMD's Windows driver 23.19 lists targets up to
gfx1103, so amd_comgr_action_info_set_isa_name returns status 2 and
hardware_oracle fails there. The test now reads the targets comgr lists
and skips one it does not list. It requires gfx1010, so an empty list
fails instead of skipping every target.

AI-assisted: yes
2026-11-24 18:56:47 +05:30
Hedi Trigui 0c09f087a6 feat(libSceNKWebKit): implement WKBundleNodeHandleSetHTMLInputElementAutoFillAvailable 2026-11-24 14:20:16 +01:00
JJenkxandClaude Opus 5.5 66edf9eb97 fix(shader): emulate comparison gathers of color textures
A comparison gather (image_gather4_c and its _lz/_o forms) of a texture
the device cannot compare natively was marked unsupported, so no
emulated comparison mode was prepared and the draw was refused at
descriptor time.

The emulated color comparison now has a gather form: it reads the
bilinear footprint and returns the four per-texel comparison results in
gather order, through the same per-texel comparison as the emulated
sample. Horizontal gathers stay refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 08:13:24 -05:00
Fernando Laydner Júnior 8ff0946f19 fix(tools): exclude controller recording from performance captures 2026-11-24 10:07:23 -03:00
xXPBSXxandClaude Sonnet 5.5 70fc2edd6d fix(libSceRegMgr): return the value sceRegMgrGetVersion gave on a PS5
sceRegMgrGetVersion threw NotImplemented_nid_no_patch. A PS5 payload
process on firmware 11.60 returned 0x01140001 in five calls in each of
two character-identical runs, with the argument registers 0, with 1 as
the first and with 0, 1, 2, 3. The export now returns that value; the
int (void) prototype is an assumption of the probe and a title process
or other firmware may differ. The debt fragment of the existing entry
is changed in place.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 14:01:27 +01:00
xXPBSXxandClaude Sonnet 5.5 32643faf8f test(libSceRegMgr): pin sceRegMgrGetVersion to the value measured on a PS5
sceRegMgrGetVersion returned 0 through NotImplemented_nid_no_patch. A PS5
payload process on firmware 11.60 returned 0x01140001 in two runs
(2026-11-20T120411Z and 2026-11-20T130342Z, character-identical) for the
argument sets 0, 0, 0, 0; 1, 0, 0, 0; and 0, 1, 2, 3.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 13:57:52 +01:00
Riccardo Mariani 2601b8ea6a fix(tools): batch host-only test targets on Windows 2026-11-24 13:56:42 +01:00
Fernando Laydner Júnior 5909d42577 fix(tools): preserve exact PresentMon counts in Markdown 2026-11-24 09:48:56 -03:00
ruby_sc ca4412dd99 refactor(libs): share SDK reads in Json2 and coredump 2026-11-24 09:46:19 -03:00
RTGG d60ec67441 feat(libSceNpCommon): implement firmware 13.60 utility setting getters in PendingExports 2026-11-24 13:36:06 +01:00
anyps5developer 8bb35191d8 fix(libc): probe vasprintf destination pointer before writing 2026-11-24 13:07:42 +01:00
HorizonCoding 75f2afacf8 feat(libSceLibcInternal): implement _Mbtowc and _Wctomb 2026-11-24 13:53:03 +02:00
Zedas030 3d771d28ac feat(libc): export the std::numeric_limits constants 2026-11-24 12:45:10 +01:00
RTGG ac68a0c69f test(libScePad): verify queued 3 kHz haptic frames are preserved across rate change 2026-11-24 12:45:10 +01:00
RTGG e95f71ea50 test(libc): wrap symlink prefix test cleanup in RAII guard 2026-11-24 12:45:05 +01:00
RTGG 161f52916c fix(libc): explicitly guard rune values above INT32_MAX in GuestRune 2026-11-24 12:43:21 +01:00
RTGG 3bce6c2200 fix(libSceIme): use page-safe chunked guest reads in ime_filter::FilterText 2026-11-24 12:43:16 +01:00
console logout b2d741e3cb perf(agc): check logged refusals before leasing host imports
refreshedFromLoggedChanges leased the imports of the changed windows and
compared them before it looked for a failed, refused, growth or sparse-run
entry in those windows, which makes it give up. Those checks need only the
merged spans, so they now come first, and a failed attempt costs a span
lookup instead of a lease. A pending import that the window walk already
checked is no longer checked a second time.
2026-11-24 12:40:47 +01:00
xXPBSXxandClaude Sonnet 5.5 5f418236a0 test(libkernel): pin the sceKernelQueryMemoryProtection results with NULL outputs measured on a PS5
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 12:39:55 +01:00
Shripad 28de5382c2 feat(libkernel_sys): implement __sys_socketclose export and web forward 2026-11-24 17:06:47 +05:30
xXPBSXxandClaude Sonnet 5.5 6f78e2ea8b docs(libSceUserService): record the answers of the event callback exports before initialization on firmware 11.60
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 12:19:13 +01:00
Shripad 9ec7d087ba feat(libkernel_sys): implement __sceKernelGetGPI export and web forward 2026-11-24 16:29:48 +05:30
gccodyandClaude Opus 5.5 5352373c8c fix(shader): read a uniform quad_perm with one quad broadcast
A DPP quad_perm read in a pixel shader broadcast all four lanes of the
quad and selected the source lane with a chain of OpSelect, even when
the control names the same lane for all four (0x00, 0x55, 0xaa, 0xff),
as the neighbour reads of an emulated derivative do. Such a read is now
one OpGroupNonUniformQuadBroadcast of that lane; the result is the same.

NVIDIA's compiler (driver 580.178.04, RTX 3080) segfaults building the
pipeline of a LEGO Batman: Legacy of the Dark Knight (PPSA16833) pixel
shader that holds 114 of these four-broadcast reads, so the title
crashed when it left the title screen. With one broadcast per read the
pipeline builds and the title reaches its main menu and a new game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 05:01:21 -05:00
Oleg cec421cd5e feat(libSceAvSetting): answer the pre-initialization checks measured on 13.60 2026-11-24 14:52:30 +05:00
muhmuhkuhandClaude Opus 5.5 7119408adc fix(agc): read a moved dispatch buffer in place only with the checks of a moved draw element
A cache hit whose read-only dispatch buffers moved bound each moved buffer straight from HostImportView. That view skips what every other host import lookup does: it does not reconcile a guest allocation registry that changed since the imports were made, and nothing refused the in-place read when a label the queue has not recorded yet, a queued store or a copied writer still targets the range. The dispatch now asks movedInPlace, the check a moved draw element read in place already passes, and binds the element through the draw path's in-place snapshot, which notes the read on the recorder at once. The prefilter without a recorder only asks whether an import exists. The draw path's moved-in-place counters stay the draw path's own.

DrawBindings no longer carries its own in-place list and read ranges, and MarkGpuWrites and the barrier validation no longer take them; the dispatch record keeps snapshot bytes only for snapshots with their own buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 09:15:56 +01:00
gccodyandClaude Opus 5.5 821525c9e2 fix(libSceNKWebKit): convert a parsed local date to UTC only once
Date.parse and new Date(string) built a local time with the Date
constructor and then always called setFullYear(year), which reads the
date's local time back and converts it again. In a daylight saving gap
that local time is not the parsed one, so a string such as
"Mar 14 2021 02:30" in America/New_York or "Mar 28 2021 02:30" in
Europe/Berlin parsed one hour away from new Date(2021, 2, 14, 2, 30).
Years 0 to 99 went through a 1900 to 1999 date, so 0000-02-29 became
1 March.

A year outside 0 to 99 now takes the constructor's value. A year in 0 to
99 starts from noon on a fixed day, sets the date with setFullYear and
the time with setHours, so the requested fields are converted once.

nkwebkit_jscdateparsing passed only where the host zone has no daylight
saving time. It now also runs under TZ=EST5EDT and
TZ=CET-1CEST,M3.5.0,M10.5.0/3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 03:06:06 -05:00
zaryabzipandClaude Opus 5.5 0757012274 test(npmanager): run CheckRequestIds after the offline getters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 12:50:26 +05:00
CocoandClaude Opus 5.5 5270aa00e2 fix(libkernel): keep a TCP connect pending until every connect on the socket leaves the host
connect marked a stream socket pending before the host connect, but a
send in between polled the still unconnected descriptor, which Linux
reports writable with POLLHUP, and cleared the mark; the connect then
went into SYN_SENT and later sends reached the host. A second connect
that failed at once while the first was entering the host cleared it
too. Count the connects inside the host call: send answers ENOTCONN
while any is there, a host connect that returns in progress sets the
mark, and one that fails clears it only when no other connect is in the
host and the socket is not in SYN_SENT. A test-only hook runs inside
connect before the host call so the test can send and connect there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 12:54:52 +05:30
Eduardo Ruiz 75477d13c1 Merge remote-tracking branch 'origin/main' into HEAD 2026-11-24 08:09:01 +01:00
JJenkxandClaude Opus 5.5 0233b26334 perf(agc): keep storage images used in the last two presents out of the memory release
When a device allocation does not fit, ReleaseTextureCaches evicts cached
storage images. An image used since the last scan was spared once and then
evicted on the rescan, so a large request freed images the title uses every
frame, which were made and uploaded again on the next frame. Record the
present of each cached storage image's last lookup, and leave images used in
the current or previous present to host placement instead. Before the first
present the release behaves as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 01:45:46 -05:00
DerKarussellbremserandClaude Opus 5.5 4d50dc8cea fix(libc): erfc raises no flag from -28 down
The SDK 5.00 libc raises inexact for erfc(x) only for -28 < x <= -6;
at -28 and below it returns 2 with no flag in every rounding mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
2026-11-24 07:27:36 +01:00
Hedi Trigui 41c970f1a9 feat(libSceNKWebKit): implement WKIconDatabase and context icon database operations 2026-11-24 07:17:27 +01:00
birdmarty 3ac03c6d52 fix(agc): assemble layered stencil plane views through DepthPlaneCopy 2026-11-24 07:47:31 +02:00
fogydesandClaude Opus 5.5 bbdcd2aefe perf(tools): parallelize progress scanning and skip fetching present commits
Scan libraries for tools/progress.py in a process pool, and let
tools/pr_overlap.py --names skip fetching pull request heads that the
local repository already has. Rebuilt as one commit on current main,
keeping the per-commit fetch fallback for heads that move during a run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 10:59:41 +05:30
klosixgaming-arch d76afb017b fix(agc): end a storage image's clear-fill hold when a new pending set starts 2026-11-23 22:45:14 -06:00
klosixgaming-arch bb993de537 docs(agc): move the mipmapped DCC debt entry to a fragment 2026-11-23 22:44:53 -06:00
klosixgaming-arch 38c40d84ba refactor(agc): drop the mipmapped DCC clear's comments and run its GPU tests on Windows 2026-11-23 22:44:52 -06:00
klosixgaming-arch 38dd82a207 fix(agc): place a mipmapped DCC target's key slice after the shared mip-tail block, register APS5_NO_DCC_MIP_FAST_CLEAR as a runtime switch 2026-11-23 22:37:10 -06:00
klosixgaming-arch d10c0aea58 fix(agc): take the mipmapped DCC fast clear while the key fill is pending
When the game's DCC key fill is still a recorded GPU write at bind, the
old path synced it (CurrentDccKeys) and ClearMip's pending-write refusal
still fired over the surface's key extent, so the bind fell back to the
CPU store (a full memset of the viewed mip plus a re-upload, every frame
the game re-clears the target). Answer the keys from the recorded writes
instead (LandedDccKeys, no sync): every pending writer a fill leaving one
fillable clear code takes the GPU clear with the clear recorded after the
fill in the same queue; a fill of 0xff clears nothing; mixed, partial or
an unknown writer falls back to the current keys, as before. ClearMip now
skips its pending-write checks when the caller passed a verified code
clear. Remove the temporary MIPCLEAR-PROF profiling counter.

Tests: three pending-fill scenarios next to the existing mipmapped clear
test -- a pending clear-code fill must take the GPU clear with no sync and
no guest write at bind (it fails without the change: ClearMip refuses, the
CPU fallback writes the guest at bind), a pending 0xff fill must not
materialize a clear, and a pending partial fill takes the fallback path
and stays correct.
2026-11-23 22:36:50 -06:00
klosixgaming-arch d2233b1045 fix(agc): clear a mipmapped DCC color target's viewed mip on the GPU
Replace the per-draw CPU settle (store the clear over the whole mip and
re-upload it) with a GPU clear of the viewed mip's subresource: the image
holds the clear, the guest bytes follow through the write-back, which now
stores the filled mip whole (holdsClearFill). The single-level DCC path
already serves a uniform clear from the image; this extends it to the
mipmapped target whose chain image otherwise starts from the stored texels.

The test for the draw reads the guest buffer directly: the GuestMemory
access hook would store the pending clear (the very write-back under test)
before a hooked read could observe the pre-write-back state.
2026-11-23 22:36:50 -06:00
klosixgaming-arch d42e64b481 fix(agc): fast-clear a 2D mipmapped DCC color target from its viewed mip's key slice
A 2D mipmapped pipe-aligned DCC color target carries the whole chain's
metadata, but only the viewed mip is written; the driver parked the key
address in chainDccAddress and ignored the keys, so the target uploaded
the stored texels (an alias's bytes) instead of starting from the fast
clear. Give the viewed mip its own key range -- the AMD addrlib
HwlComputeDccInfo layout, small mips first, each a whole number of
4096-key blocks, the viewed mip's slice last -- and settle its range to
the clear colour before the resident lookup when that slice is one clear
code, so the draw starts from the clear like a single-level target.
Arrays and 3D keep the chain address and the existing log line.

The key reads keep the historical per-256-bytes count; the viewed mip's
padded extent sizes the marks and overlap checks, as the padded console
extent already did for single-level targets. APS5_NO_DCC_MIP_FAST_CLEAR
turns the fix off.

Adds RunMipmappedClearDraw: a 128x128 8-mip R64KBX chain with a 0000
clear over stale texels in the viewed mip's slice; a 0.5 premultiplied
draw must see 128 inside the scissor and the clear outside, and the
viewed mip's keys must end uncompressed. It fails with
APS5_NO_DCC_MIP_FAST_CLEAR=1.
2026-11-23 22:36:50 -06:00
Shripad c73ca11997 feat(libkernel_sys): implement __sys_rdup syscall wrapper 2026-11-24 10:00:31 +05:30
Dean 4706a6e4f9 docs(nkwebkit): file the WKPage inspection and configuration accessors under silent stubs 2026-11-24 05:14:54 +01:00
Hedi Trigui 6ed78bbe19 feat(libSceNKWebKit): implement WKPage remote inspection, pending URL, and configuration accessors 2026-11-24 05:14:54 +01:00
console logout bc7af2bbec perf(agc): reconcile host imports from logged allocation changes 2026-11-24 03:52:26 +01:00
Riccardo Mariani aa94394adc test(libSceCesCs): cover measured CP1254 and CP1258 string conversions 2026-11-24 03:21:22 +01:00
Nabil El Bak 57136efc00 fix(libSceLibcInternal): implement filesystem current directory setter 2026-11-23 21:10:09 -05:00
AnyPS5 verification 5900476cb1 fix(shader): keep the native two-sample FMASK expansion unreplicated 2026-11-23 19:41:14 -05:00
AnyPS5 verification 8a366a71ac docs(shader): record measured short FMASK expansions 2026-11-23 19:41:14 -05:00
AnyPS5 verification 9802c74c44 fix(shader): replicate short FMASK expansions across the dword 2026-11-23 19:41:14 -05:00
AnyPS5 verification db5ef3e687 docs(shader): state the measured FMASK fragment rule 2026-11-23 19:41:14 -05:00
AnyPS5 verification d707526c59 fix(shader): expand FMASK fragments as index plus unknown bit 2026-11-23 19:41:14 -05:00
AnyPS5 verification 59af880cea docs(shader): record gfx1013 FMASK measurements 2026-11-23 19:41:14 -05:00
AnyPS5 verification 54870e7b38 fix(shader): match measured FMASK expansion and channel duplication 2026-11-23 19:41:14 -05:00
AnyPS5 verification e6233e25ea fix(agc): read 64-bit-storage 16-sample FMASK 2026-11-23 19:41:14 -05:00
AnyPS5 verification 4378fc98c9 fix(agc): read 16-sample FMASK of 16- and 32-bit storage 2026-11-23 19:41:14 -05:00
Riccardo Mariani 1cc7c15163 test(libSceCesCs): verify CP864 against the measured PS5 table 2026-11-24 01:37:38 +01:00
Riccardo Mariani e6d588ebf9 fix(tools): reject copied build caches in test selection 2026-11-24 01:30:58 +01:00
Codex cdd937c4aa feat(libSceIcu): decode default-encoded copies as UTF-16 2026-11-24 08:26:32 +08:00
JJenkx dabf7580d3 test(libScePosixForWebKit): cover a multi-page literal fnmatch pattern 2026-11-23 19:06:19 -05:00
JJenkx eeb740692c test(libSceJson2): preserve a live read-only iterator on destruction 2026-11-23 18:56:45 -05:00
hamdanpor-ctrlandClaude Opus 5.5 a1d2633208 feat(libSceIcu): implement the Normalizer2 factory accessors and Normalizer2Impl queries
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 02:48:57 +04:00
MarcZX100 0301d9d308 fix(libSceNpCommon): keep buffered UTF-8 bytes when a split lead is invalid
When an invalid UTF-8 sequence is split over more than two calls, the JSON
reader marked the buffered bytes as consumed and then discarded them. The
bytes after the lead were lost, and in some splits bytes were emitted twice.

Buffer only UTF-8 continuation bytes, emit an invalid lead alone, and replay
the buffered bytes that follow it on the next reads. Add three-chunk split
regressions for a lead followed by an ASCII byte and for a valid partial
prefix followed by an ASCII byte.
2026-11-23 23:47:50 +01:00
MarcZX100andClaude Haiku 5.5 6e6d667e2e fix(input-mapper): add ToggleBorderless with its F2 default
The mapper lacked the ToggleBorderless action that the native parser
accepts, so the action-name and conflict-catalogue tests failed.
The action is keyboard-only, as in the native parser.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-23 23:42:38 +01:00
MarcZX100andClaude Haiku 5.5 1301e08e04 fix(libc): keep a downcast through one of several subobjects of the destination
The multiple-subobject ambiguity check ran before the downcast branch, so a
downcast whose destination appears in several subobjects (one per base of a
derived class) returned null even when only one of them contains the source.
Apply the check after the downcast branch so it only governs the cross-cast
path, and cover the shared-Mid shape in both base orders.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-23 23:37:23 +01:00
Mohamed Malek Aifa d618b4d5dd fix(tools): handle pull requests without merge bases 2026-11-23 23:06:02 +01:00
Diogo Piteira Castelos 33a50f193c fix(libSceIcu): delete guest UObjects through their System V vtable
uprv_deleteUObject forwarded the guest pointer to the bundled ICU's
uprv_deleteUObject, whose delete calls the guest's deleting destructor
with the host C++ calling convention. A guest vtable holds System V
functions, so on Windows that call breaks the System V contract; it
only worked because the export left the object in rdi.

Read the vtable through checked guest copies and call slot 1, the
deleting destructor that ICU 68.2's delete uses, as an APS5_VABI
function. An unreadable object or vtable and a null slot throw.
2026-11-23 21:38:23 +00:00
vishnuvardhan3333 43d61534e7 test(libSceCesCs): pass per-endian character constants to little-endian entry points 2026-11-24 02:25:14 +05:30
Codex 9906ab6ef4 fix(tools): make rebase verification portable across platforms 2026-11-23 14:13:49 -06:00
vishnuvardhan3333 b03629d3e3 fix(libSceCesCs): access Unicode conversion buffers through guest copies 2026-11-24 00:50:30 +05:30
Nicolas GonzalezandClaude Opus 5.5 d752271438 docs(agc): name the unwatch hook check that APS5_ASSERT_LOCK_ORDER also enables
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:13:53 -03:00
JJenkxandClaude Opus 5.5 5701d91506 perf(agc): do not drain for a stencil-only expand without a clear
DepthRenderControlDrains drained the draw pipeline for every multisampled
DB_RENDER_CONTROL with STENCIL_COMPRESS_DISABLE or DEPTH_COMPRESS_DISABLE,
so that NoteDepthRenderControl finds a surface a queued draw registers.
NoteDepthRenderControl changes a surface's expanded state only for a depth
expand (with a stencil expand or no stencil plane) or a clear. A control
with only the stencil expand bit and no clear bit changes nothing but the
renderControl value that one diagnostic prints, so it no longer drains.
Depth expands and clears drain as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 14:10:47 -05:00
THEMANnt 7038be4e73 fix(libkernel): separate forwarded accept capacity from peer size 2026-11-23 21:55:45 +03:00
Federico Marras 3eb469710e fix(libSceIcu): match ICU pLength semantics in uloc_getTableStringWithFallback 2026-11-23 19:08:11 +01:00
Federico Marras af9b82da32 test(libSceJpegDec): enlarge progressive fixture to cover streamed decode continuation 2026-11-23 18:37:27 +01:00
birdmarty ac715a8b41 fix(agc): accept PA_CL_CLIP_CNTL UCP_CULL_ONLY_ENA without active clip planes 2026-11-23 19:24:25 +02:00
Hedi Trigui 7d4ca6224f feat(libSceNKWebKit): implement WKPluginInformation string keys
# Conflicts:
#	core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp
#	core/libs/prx/libSceNKWebKit/src/ConstantExports.cpp
#	core/libs/prx/libSceNKWebKit/tests/Constants.cpp
2026-11-23 18:04:40 +01:00
Hedi Trigui b6c15e8ea9 feat(libSceNKWebKit): implement WKBundleHitTestResult frame and image accessors
# Conflicts:
#	core/libs/prx/libSceNKWebKit/Export.cpp
#	core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp
2026-11-23 17:58:48 +01:00
NWProgramming00andClaude Opus 5.5 a45a4f2a71 test(shader): keep measured zeros exact in the output modifier test
After the exact-equality check, Agrees only rejected a pair of opposite
zeros, so a measured zero accepted a minimum subnormal of either sign once
the scale divide rounded it to zero. Reject when either value has zero
magnitude, and check on the host that zero against the signed minimum
subnormal is rejected while a 1 ulp drift on a normal result still passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:57:34 +01:00
011010 0cb8b9d7be fix(libSceAgcDriver): link FS table calls on macOS
macOS reserves the console's 0xfe0000000, so the AGC driver block and the
FS table inside it move to 0xee0000000 there. A shader that builds the table
address from two s_mov_b32 literals still loaded it from 0xfe0040000, which
macOS cannot map, so those dispatches could not link: the callee lookup read
the descriptor from the console address and the shader loaded from it too.

The driver now rewrites those two literals to the moved address, for the
callee lookup and for the code the GPU runs, and ComputeFsTableCalls runs on
macOS.
2026-11-23 10:56:28 -06:00
aKazm1 2d3901218a fix(relinker): sweep fs accesses past zero padding that crosses a 16-byte boundary 2026-11-23 19:36:45 +03:00
Nawid3333andClaude Opus 5.5 39a6881057 docs(shader): change the output modifier debt entry through a fragment
The pull request edited docs/dev/debt/shader.md directly. Debt entries are
changed through a fragment in docs/dev/debt/changes/, so the edit to the
output modifier entry moves there unchanged and shader.md is left as on
main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:31:41 +01:00
Nawid3333andClaude Opus 5.5 38fd7514b4 docs(shader): add the integer source modifier debt entry through a fragment
The pull request edited docs/dev/debt/shader.md directly. Debt entries are
added through a fragment in docs/dev/debt/changes/, so the entry moves
there unchanged and shader.md is left as on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:31:09 +01:00
Gustavo NavarroandClaude Haiku 5.5 d1c56fa45d fix(libkernel): register the guest_mkfifo test by fragment
CONTRIBUTING.md requires new libkernel test executables to be registered in tests/cmake/<executable>.cmake. The test moves there unchanged.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-23 11:28:53 -05:00
Dean 77d2f9e355 fix(tools): find the ctest regex diagnostic on the JSON closing line 2026-11-24 05:13:52 +13:00
zedekvdbandClaude Opus 5.5 6bd6bce7d7 test(tools): split test_registration by test class
test_registration ran all six classes of test_test_registration.py in
one CTest test. It took 29.0 s on the Windows CI runner (run
45139610913) and 83 to 100 s on an i7-8750H laptop, where it timed out
at 120 s when it shared the CPU with other tests.

test_registration now runs RegistrationTests, and every other class is
its own test_registration_<class> test, as conventions_wrapped_declarations
does. The longest class, DisabledScriptRegistrationTests, takes 25 s on
the same laptop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 17:02:41 +01:00
Dean 845546c987 fix(shader): return one type from the kept SPIR-V budget lambda 2026-11-24 05:00:59 +13:00
xXPBSXxandClaude Sonnet 5.5 26126ce2b2 fix(libSceAudioPropagation): return ErrorInvalidHandle for an unknown path in PathGetNumPoints
A console returned 0x8A700002 for the path handles 0 and -1 with a valid
count variable, and for the handle 0 with a null and an unmapped count
pointer, leaving the count unchanged. An unknown path handle now returns
ErrorInvalidHandle before the count pointer is read, as
sceAudioPropagationSourceGetAudioPath already does for the same handles,
instead of throwing.

Two existing test lines changed: the paths of a destroyed source and of a
destroyed system (GuestAudioPropagation.cpp, "path survived source
destruction" and "path survived system destruction") expected a thrown
invalid_argument and now expect ErrorInvalidHandle, because a destroyed
path leaves the registry like an unknown handle. Only the handles 0 and -1
were measured; the answer for a destroyed handle is assumed from the same
lookup.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 16:53:47 +01:00
Abhinav Pullela 975f8e133c fix(tools): report ctest's diagnostic for a malformed select_tests targets regex 2026-11-23 21:08:54 +05:30
Ondra97 a41d7fe7ba fix(libc): sync Windows scan prefix with main 2026-11-23 16:33:21 +01:00
mihiii1337 a943097498 fix(tools): honor initial newlines in AGC bracket arguments 2026-11-23 16:16:05 +01:00
Nicolas GonzalezandClaude Opus 5.5 2913fe82f8 fix(agc): check host imports outside the pending storage image mutex when storing drawn linear targets
StoreDrawnLinear asked HostImportCovers, which takes the host imports
mutex, while it held the pending storage image mutex. ImportMappedRanges
holds the imports mutex and then takes the pending mutex through
AnyPendingOverlaps, so the two threads could each wait for the other.
The pending mutex is a leaf lock.

StoreDrawnLinear now keeps the trap candidates alive, releases the
pending mutex, asks HostImportCovers, and takes the pending mutex again
to set the traps on the candidates still drawn and dirty, as
StoreSmallPending already does. Taking the imports mutex under a leaf
lock now aborts when lock order is checked, and APS5_ASSERT_LOCK_ORDER
checks it without the GpuMutex assertions of APS5_ASSERT_GPU_LOCK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 12:11:12 -03:00
Federico Marras b47b9b838d feat(libSceIcu): implement uloc_getTableStringWithFallback 2026-11-23 15:59:47 +01:00
LeandroLP23andClaude Opus 5.5 03a6188f3c refactor(webrtc): drop errno guards around guest copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 15:51:15 +01:00
Eduardo Ruiz 3cf6812367 test(libSceHubAppUtil): assert each not-available notice
The three exports print a fixed notice before returning 0x818D0001, and the
test only checked the return values. Each notice is now its own ctest entry
that runs the binary for that export and matches the string as regular
expression, so a missing or reworded notice fails the test.

main's guest_hub_app_util test, which expects the old returns, is folded
into this one instead of staying beside it.
2026-11-23 15:36:34 +01:00
Eduardo Ruiz ed500e3829 feat(libSceNpCppWebApi): export the Leaderboards instantiations the titles import
Eleven mangled exports over Leaderboards::V1 were still missing from the
library, so the relinker could not resolve them: Entry's IntrusivePtr copy
constructor and destructor, Vector<IntrusivePtr<Entry>>::operator[] and the
IntrusivePtr<Vector<Entry>>::get accessor, TransactionBase::abort and
Transaction::hasResponse over the GetRanking, RecordScore and
GetBoardDefinition response bodies, and hasResponse over the Activities
GetUsersActivities response body.

They answer like the instantiations already present: hasResponse returns 0,
abort returns TransactionNotStarted, Entry's copy constructor and destructor
count references, get answers nullptr over an empty handle, and
Vector<IntrusivePtr<Entry>>::operator[] still throws when it cannot read the
title-provided vector, as its siblings do.

The other twenty-five exports this branch used to add are now in main.
2026-11-23 15:27:17 +01:00
Gustavo NavarroandClaude Haiku 5.5 b4de495688 fix(libkernel): run the mkfifo test on Windows by expecting NotImplemented
The Windows CI check requires every test executable to run under ctest, and a disabled test does not. On Windows the test now checks that mkfifo throws NotImplemented, and the POSIX checks are compiled out there.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-23 09:26:49 -05:00
edubox 7938b99782 feat(libSceHubAppUtil): reproduce the firmware not-available returns
All three exports print the firmware's own notice and return 0x818D0001.
In the 13.40 module each body is 23 bytes: one constant string passed to the
libc puts import, then the error code, without reading an argument, so the
behaviour is the same for every input and the parameterless declarations stay
valid as import-resolution placeholders. Read from disassembly, not measured on
a console.

The test calls the three exports and checks the return value. The notice was
compared against the strings in the module.
2026-11-23 15:15:45 +01:00
Gustavo NavarroandClaude Haiku 5.5 5835eb91d8 feat(libkernel): implement mkfifo
Creates a FIFO at the path that mkdir resolves, through the host mkfifo with the same mode handling as mkdir, and reports host errors as the guest's errno values. Windows has no FIFOs, so it throws NotImplemented. The test checks that the new entry is a FIFO, that a second call reports EEXIST, and that a missing parent reports ENOENT.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-23 09:02:48 -05:00
GeremyCandClaude Opus 5.5 edb81ece13 fix(libSceNKWebKit): stop freeing a prototype twice when a set finds a data property on it
CallbackExoticSetProperty walks the prototype chain of a callback object.
When a prototype has the property as a data property, it freed curProto
and broke out of the loop, and the loop's exit freed curProto again. Each
such assignment dropped one reference of the prototype, which QuickJS
then freed while objects still used it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014W1f1RvDMX4BmYudy9J2Vj
2026-11-23 14:59:36 +01:00
Alexander f46fc59420 test(tools): derive dot-file expectations from Path.suffix in env_reference 2026-11-23 13:57:45 +00:00
GeremyCandClaude Opus 5.5 7357cbb90b fix(libSceNKWebKit): measure JS and regular expression stack use from the frame address
Under ASan with detect_stack_use_after_return, a local's address lies on
the heap-allocated fake stack, so the QuickJS stack limit set at VM entry
and the libregexp stack budget were computed from the wrong stack and
every script or regular expression reported a stack overflow.
__builtin_frame_address(0) always points at the real stack, as QuickJS's
own js_get_stack_pointer does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014W1f1RvDMX4BmYudy9J2Vj
2026-11-23 14:55:58 +01:00
LeandroLP23andClaude Opus 5.5 d9fd99d527 refactor(font): drop errno saves around guest copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 14:46:30 +01:00
Mohamed Malek Aifa 25fbda54bb test(libSceNpManager): cover silent stubs 2026-11-23 13:51:31 +01:00
Ducengarth 71eaad9998 fix(libScePngDec): preserve rows from truncated IDAT data 2026-11-23 13:32:25 +01:00
Alexander 99f794660e fix(tools): preserve Path.suffix classification in env_reference 2026-11-23 11:27:31 +00:00
Codex f612d8c0e2 fix(vdecsw): scale HEVC windows by source chroma subsampling 2026-11-23 12:26:57 +01:00
Codex ba611937ae fix(pfs): validate stored blocks against the image data region 2026-11-23 12:23:34 +01:00
Codex cf4633d3c5 fix(libSceVdecsw): deliver parsed AVC and HEVC picture metadata 2026-11-23 12:22:56 +01:00
Codex 07dd7e51f1 fix(pfs): distinguish v3 block and boundary counts 2026-11-23 12:17:58 +01:00
Codex d15761759c fix(pfs): bound stored reads to the final v2 half 2026-11-23 12:13:02 +01:00
Codex 20288366c8 fix(ajm): keep bundled codec archives private in MinGW builds 2026-11-23 12:11:51 +01:00
Codex a45b29e961 feat(libSceAudiodec.native): expose the module context and release decoder instances 2026-11-23 12:09:15 +01:00
Codex c5e98c18fe test(npcppwebapi): verify explicit cloud parameter termination 2026-11-23 12:04:50 +01:00
Codex 46b66297a9 test(npcppwebapi): verify leaderboard parameter destructor ownership 2026-11-23 12:03:42 +01:00
Codex 053b49bb88 fix(npcppwebapi): construct and retain leaderboard ranking requests 2026-11-23 12:03:27 +01:00
Codex d280ec02da fix(libSceJpegDec): validate the first scan before ending header input 2026-11-23 11:53:44 +01:00
Codex 8edb31fec1 fix(libSceJpegDec): stop header callbacks at the first scan 2026-11-23 11:53:44 +01:00
Filip Michalski 0b39e3cd87 test(agc): verify push and spill layouts for image metadata 2026-11-23 11:52:17 +01:00
Codex 591e0e87a4 feat(pfs): read stored blocks from PFSC v2 and v3 images 2026-11-23 11:50:49 +01:00
Alexander 42e62cb433 perf(tools): fast-scan C++ sources and readers in env_reference 2026-11-23 10:46:30 +00:00
Codex bd6b818df4 feat(font): initialize AGC font render target surfaces 2026-11-23 11:34:39 +01:00
Federico Marras 3c71e66eb8 test(libSceJpegDec): cover scaled progressive streamed decoding 2026-11-23 11:32:59 +01:00
Codex 134b376a4d feat(npcppwebapi): build cloud storage slot request parameters 2026-11-23 11:21:53 +01:00
Remi-BonandClaude Sonnet 5.5 f560d7bd55 fix(shader): validate the kept SPIR-V budget and test kept modules in both release tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 10:53:29 +01:00
Mcm190 8ccf83f3bf fix(libcairo): bound glyph conversion staging by output size 2026-11-23 09:25:58 +00:00
Codex 2c0b0cda4a fix(ngs2): route a native submixer compressor side-chain input 2026-11-23 09:56:38 +01:00
behkha 2370bcadd2 test(libScePfs): parenthesize the v3 single block command's third field check 2026-11-23 12:12:13 +03:30
Mohamed Malek Aifa 1abbd1d08d test(libSceSystemService): cover pending return codes 2026-11-23 09:31:40 +01:00
Mehran f88f3e206a perf(agc): read the compare hook only when one is installed 2026-11-23 11:10:55 +03:00
birdmartyandClaude Opus 5.5 15c841ab73 fix(agc): settle only the import owner's host imports under a depth fill
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 09:56:18 +02:00
Mcm190 486b1df27b fix(libcairo): return explicit errors for null scaled font arguments 2026-11-23 07:53:57 +00:00
milescovielloandClaude Opus 5.5 1ca8a9b814 fix(libSceFont): build the writing record locally and copy it out once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 02:00:48 -05:00
pinewhite 288fb0c66d fix(libSceNKWebKitRequirements): terminate WPE pasteboard strings 2026-11-23 14:56:43 +08:00
milescovielloandClaude Opus 5.5 62bf6b570e fix(libSceNpCommon): return -1 when sceNpDbgDumpText's stdout write fails
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:53:05 -05:00
JJenkx 3972ceb8ad test(agc): close GPU trace summary before cleanup 2026-11-23 01:35:38 -05:00
JJenkx 37a6f444cf fix(agc): honor the requested GPU trace capacity 2026-11-23 01:35:36 -05:00
ShootanoJumperandClaude Opus 5.5 d4b8652b99 test(savedata): spawn the recovery child through its wide path on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 01:33:17 -05:00
Dean 048218f1e1 test(agc): register the pending import depth fill test on Windows only 2026-11-23 18:29:14 +13:00
Federico Marras 0df02a0f44 test(libc): name the wcrtomb check after what it covers 2026-11-23 05:08:30 +01:00
ToRaNekandClaude Fable 5.2 4654bdd663 feat(libSceNKWebKit): implement the 3.20 WebSocketFrame constructor
Implement the 3.20 WebCore::WebSocketFrame constructor (C1 and C2) from
the 2020 WebSocketFrame.cpp, with the frame laid out as in the header.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-23 04:26:50 +01:00
Mohamed Malek Aifa f1f97b6967 fix(libSceRudp): track internal I/O thread state 2026-11-23 04:12:28 +01:00
Mohamed Malek Aifa 7185e6a7cb fix(libSceAgcDriver): serialize trace summary appends 2026-11-23 04:07:18 +01:00
milescovielloandClaude Opus 5.5 242634ade3 fix(libSceNpCommon): read sceNpDbgDumpText's text through checked guest copies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:02:42 -05:00
Codex 33bfe3b7cf fix(tools): preserve Git paths and text in rebase verification 2026-11-23 02:10:39 +00:00
DannyOppenheimerandClaude Opus 5.5 1250520f2a feat(libkernel): pass descriptors over socketpairs on Windows
sendmsg with SCM_RIGHTS threw on Windows, where socket pairs are loopback
TCP and UDP sockets. A SOCK_STREAM or SOCK_SEQPACKET pair end now queues
guest duplicates of the passed descriptors on its peer, keyed to the
stream byte or record their data starts at, and recv, recvfrom, recvmsg,
read and readv keep that queue in step with the data under one lock.
Delivery follows FreeBSD 11.4: a stream read and MSG_WAITALL stop where a
message with descriptors starts, each SCM_RIGHTS message stays separate,
messages that do not fit are closed with MSG_CTRUNC, and a receive
without a control buffer, SHUT_RD or closing the receiving end closes
them. SOCK_DGRAM pairs still throw, as Windows drops datagrams sent to a
full receiver.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:10:46 -05:00
anyps5maintainer dc2fb3953a fix(libScePad): open the record file only after the replay initializes
The recording writer was a separate function-local static whose
initializer could run on a call where the replay static had already
been constructed, so the guarantee that the APS5_PAD_RECORD output was
opened with trunc only once the replay had loaded rested on the two
declarations staying in order and on the exception from the failed
player initializer skipping the writer declaration. Make the
dependency explicit control flow: the replay pair is built on first
success and the writer, including its same-file guard, is only
constructed once the replay has been built. Retry semantics are
unchanged: a failed replay or writer construction is retried on the
next call from the current environment, a completed one never re-runs,
and the equivalent/exists guard keeps failing closed on opaque
comparison errors while recording to an existing file stays allowed
when the replay path is absent.

Extend the recording harness to hold APS5_PAD_REPLAY and
APS5_PAD_RECORD set across repeated refused reads, for both a missing
and an invalid replay file, and require the preexisting record file to
stay byte-for-byte unchanged after every refused read; a writer that
opens ahead of a successful replay build fails this assertion.
2026-11-23 01:30:21 +01:00
Federico Marras 739437c4fc test(libSceJxr): require both lossy decoders to succeed 2026-11-23 00:29:33 +01:00
Federico Marras c5603ffc8a test(libSceJxr): compare and decode the whole lossy JPEG XR stream 2026-11-23 00:29:15 +01:00
Federico Marras 350f1d2906 test(libSceJxr): exercise frequency bitstreams and tiling in the lossy format test 2026-11-23 00:21:26 +01:00
birdmartyandClaude Opus 5.5 6c4114784f fix(agc): settle host imports under a native depth fill before its watch check
A whole HTILE fill over a native multisampled depth target refused with
"metadata fill over unwatched memory" while a host import of the HTILE
was still waiting for its deferred settle, although the memory is
watched again once that import settles. Settle the imports under the
fill for each device with a sampled native depth target there, after
taking the GPU mutex and before the depth surface lock, so the import
lock is never taken under the surface lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:11:01 +02:00
u-instinct11andClaude Opus 5.5 52693570cd docs(libc): fold the sinhl tiny-input note into the shared msun entry
The standalone [sinhl] fragment matched no libc entry, and the shared
[expl, sinhl, coshl and tanhl] entry is already changed by
fix-expl-ld-exp.md, so add the sinhl sentence there instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 03:10:54 +05:30
Krille2004zzz 6dff21185f ci: retrigger 2026-11-22 21:40:50 +01:00
Krille2004zzz d3773c67a0 feat(libSceLibcInternal): implement _Hypot, _FHypot and _LHypot 2026-11-22 21:40:35 +01:00
Federico Marras c1e4429504 test(libSceJxr): cover lossy quantization, tiling, overlap, and pixel formats against jxrlib 2026-11-22 21:14:54 +01:00
anyps5maintainer 7d82600ede fix(libScePad): allow recording when the replay path does not exist
std::filesystem::equivalent sets an error when either path is missing, so the writer guard threw cannot-compare and blocked recording to an existing APS5_PAD_RECORD whenever APS5_PAD_REPLAY pointed at a path absent from disk. Check that the replay path exists before comparing; keep failing closed on opaque comparison errors and on same-file aliases via equivalent.
2026-11-22 20:52:29 +01:00
Devin fc21f79de0 refactor(libkernel): merge the process-property debt ops into the tool-memory fragment
The tool-memory fragment on main already changes the six-name throwing
entry and removes the libkernel_sys tool-memory row; a second fragment
targeting the same base entries cannot fold. Update its change op to
produce the implemented sceKernelSetProcessProperty entry directly.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-23 01:12:50 +05:30
amazedturnip 07d88339c3 fix(libSceNKWebKit): validate null self in TrackPrivateBase constructor 2026-11-22 13:41:39 -06:00
JJenkx 5f75dcf9fe fix(libSceNKWebKit): harden StorageMap alias and copy-on-write publication 2026-11-22 14:35:09 -05:00
Riccardo Mariani 2d3906d56e fix(libSceCesCs): report lengths for rejected UTF-8 to Shift-JIS characters 2026-11-22 20:23:49 +01:00
Mauro Alvarez 5d59af1cac fix(libSceIcu): guard converter name normalization guest pointers 2026-11-22 16:22:18 -03:00
Remi-BonandClaude Opus 5.5 2a16f18467 perf(shader): keep recently specialized SPIR-V for reuse
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:19:48 +01:00
Mauro Alvarez 7d5892bd9c fix(libSceLibcInternal,libkernel): use Windows verbatim paths in statvfs, statfs and fstatfs 2026-11-22 16:18:37 -03:00
Mauro Alvarez 45ef974cbf fix(libSceLibcInternal): copy multiprecision guest word arrays safely 2026-11-22 16:16:52 -03:00
PostMalloyandClaude Opus 5.5 fab3c46ec4 feat(libSceLibcInternal): implement num_put<wchar_t>'s complete-object constructor
num_put<wchar_t>::num_put(const _Locinfo&, size_t) had its base-object
constructor (C2) implemented but its complete-object constructor (C1)
was still the inventory stub libSceLibcInternalInventory_133, which threw.
num_put has no virtual bases, so under the Itanium ABI C1 does the same
work as C2; it now runs the C2 export with the same arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 14:14:56 -05:00
Dean f0677633a4 docs(nkwebkit): file the WKPage back-forward requests under silent stubs 2026-11-23 08:08:37 +13:00
birdmartyandClaude Opus 5.5 e87f7644a7 fix(agc): sample a stencil kept in HTILE without metadata after an in-place expand
The stencil plane of a native multisampled D32S8 target was sampled
through a descriptor without metadata only when the HTILE held depth
alone; with the stencil in HTILE every such read threw "native
multisample depth sampled metadata or XOR mismatch". With the stencil
in HTILE the plane in memory is compressed until an in-place expand,
which is why the read was refused. Depth reads without metadata are
already accepted after an observed in-place expand of depth and, with a
stencil plane, stencil (DEPTH_COMPRESS_DISABLE and
STENCIL_COMPRESS_DISABLE). The stencil read now follows the same rule,
until the same HTILE clears, fills and clear draws that end it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 21:04:19 +02:00
Mihai 2804ac3abb feat(libc): implement libc++ narrow regex dot matcher 2026-11-22 20:58:13 +02:00
Shadow 80145ceac7 feat(libwebrtc): implement Thread::Quit 2026-11-22 21:47:01 +03:00
Riccardo Mariani 3658109903 test(libSceCesCs): verify every CP858 mapping against PS5 measurements
Use the UTF-32 results reported by the firmware 11.60 probe for all 256 bytes. A swap of bytes 0x81 and 0x82 passed the previous suite and failed the new check.

Reference: https://github.com/boykopovar/AnyPS5/pull/23338#issuecomment-6992953222
2026-11-22 19:46:05 +01:00
dkdhanda8 667111160a docs(libSceAppInstUtil): name the two service-checked exports in the debt tables 2026-11-23 00:07:32 +05:30
birdmartyandClaude Opus 5.5 b3da3af975 fix(agc): take a whole native depth publication as an in-place expand
A native multisampled depth target with HTILE accepted a descriptor
without metadata only after an observed in-place expand draw; any other
such read threw "native multisample depth sampled metadata or XOR
mismatch". Publishing the target to guest memory writes every HTILE
word expanded and the planes from the host samples, which is the state
an in-place expand leaves. When every plane was committed whole and
unchanged by the guest, the target is now taken as expanded, until the
same clears and fills that end an expand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 20:37:11 +02:00
Script-hppandClaude Opus 5.5 1ce65ca63d fix(libSceVideoOut): free extended preedit text once, after every event handler
The event loop now owns the SDL_TEXTEDITING_EXT allocation and releases it after all handlers ran, so later handlers never see freed text and a throwing handler does not leak it. ImeTextInput only reads the text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016k2buKhRwzEctC4cJhXum3
2026-11-22 19:36:55 +01:00
Script-hpp aacc1e4fc0 feat(libSceVideoOut): preserve extended IME preedit text 2026-11-22 19:36:55 +01:00
dkdhanda8 33fad18588 feat(libSceAppInstUtil): name the callable export aliases the NID databases resolve 2026-11-23 00:06:54 +05:30
jagrat Singh 09c81f366f fix(libSceNKWebKit): disambiguate String constructor in PageNavigation tests 2026-11-23 00:03:03 +05:30
Federico Marras 982b24b194 test(libSceJxr): cover WMP encode roundtrips for RGB, gray and odd sizes against jxrlib 2026-11-22 19:29:04 +01:00
Mohamed Malek Aifa fa63d48976 fix(ci): run guest tests of changed runtime libraries 2026-11-22 19:17:13 +01:00
Federico Marras 825ad019f1 test(libSceLibreSsl): cover file BIO open modes, puts and EOF 2026-11-22 19:05:33 +01:00
Federico Marras 258ac74b68 docs(libSceNet): note that the detached sceNetThreadCreate thread is unmeasured 2026-11-22 18:59:31 +01:00
Abhinav Pullela c41b3b8acf fix(pad): publish keyboard pad state after input mapping reload 2026-11-22 23:25:20 +05:30
kessler-driftandClaude Fable 5.2 a10b2c64b5 fix(libSceIcu): read a non-string item as the empty string in ures_getUTF8StringByIndex
ICU's ures_getStringByIndex hands a table or array item to res_getString,
which returns no string and leaves the status for an item that is not a
string, so ures_toUTF8String returns the empty string. The accessor
reported U_RESOURCE_TYPE_MISMATCH instead.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 18:52:29 +01:00
jagrat Singh 1722256455 feat(libSceNKWebKit): implement WKPage back-forward navigation controls 2026-11-22 22:57:47 +05:30
Abhinav Pullela 3be6bc4467 fix(pad): rearm controller hotkeys after modal capture 2026-11-22 22:30:52 +05:30
slopgobblercobbler d5fe95de09 test(libScePad): audit vibration parameters, adaptive trigger effects, and handle bounds 2026-11-22 17:28:08 +01:00
akkadbakkad89 9310255551 refactor(libkernel): move tool-memory and process-property registrations to fragments 2026-11-22 21:43:30 +05:30
akkadbakkad89andDevin 7f1b706967 feat(libkernel): implement sceKernelSetProcessProperty
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-22 21:43:21 +05:30
JJenkx b6f55fb142 fix(libSceNKWebKit): validate guest pointers in WebCore::StorageMap exports 2026-11-22 11:07:08 -05:00
JJenkx e4f661f536 fix(libSceJson2): keep Object::~Object no-op on null items 2026-11-22 10:29:23 -05:00
JJenkx fb4aa6deca test(libkernel): report sleep-wake assertion call sites 2026-11-22 10:08:14 -05:00
0x70776c 23e2685273 feat(libSceLibcInternal): implement wide time_put::_Init 2026-11-22 16:07:10 +01:00
Mauro Alvarez c0819ee65d fix(libSceNpCommon): guard guest text reads in sceNpUtilGetNthChar 2026-11-22 12:02:34 -03:00
Mohamed Malek Aifa f0b07221b2 fix(libSceRudp): match unconnected read and write errors 2026-11-22 16:01:57 +01:00
Abhinav Pullela 46aeb8a464 fix(libSceCamera): accept camera index 1 in sceCameraIsAttached 2026-11-22 20:26:00 +05:30
Abhinav Pullela 764a04c80a test(libSceJsc): give each WTF data-log test its own directory 2026-11-22 20:03:51 +05:30
Dean db4c7f574a docs(libc): note sinhl tiny inputs raise no inexact flag 2026-11-23 03:31:42 +13:00
Ysaïah DH e4bc8860a3 test(nid): add unit tests for SHA-1 and NID computation 2026-11-22 15:07:37 +01:00
Siddhant Singh 7f4d065d29 fix(libc): preserve exception flags for tiny sinhl inputs 2026-11-22 19:23:22 +05:30
Jazeupoi 6f6fdf0897 fix(shader): link user-data tails through copied pointers, branching bodies and geometry fronts
XashPS5 stops at three raw shader tails: a vertex prolog run as the front of a geometry draw (mesh stage), fragment tails that jump through an s_mov_b32 copy of the user-data low half, and fragment tails whose body branches with s_cbranch_execz to an exp/s_endpgm exit placed after the s_setpc_b64. Accept the mesh stage in both tail gates, accept one copy of unchanged user data when the high half is an immediate, and accept forward branches into a branch-free trailing exit ending in s_endpgm, which the linker keeps by jumping over it to the continuation.
2026-11-22 14:32:56 +01:00
Mohamed Malek Aifa 36c8f92b34 fix(libSceHttp2): copy status output through guest memory 2026-11-22 14:26:33 +01:00
Abhinav Pullela 51ab52db44 test(run-report): check the revision generator exit status 2026-11-22 17:50:44 +05:30
Federico Marras e78d60d20c fix(libSceNet): create threads without an output detached 2026-11-22 13:13:19 +01:00
Siddhant Singh 52b15f0cce fix(ci): preserve changed paths for Windows test selection 2026-11-22 17:40:00 +05:30
kattkaries ba57da517c fix(libScePad): protect replay files from recording overwrite 2026-11-22 12:52:48 +01:00
Dean 3a24890189 chore: merge main and bump shader disk cache FormatVersion to 97 2026-11-23 00:49:31 +13:00
Abhinav Pullela 4e437ca694 fix(tools): recognize cmake env wrapped tests in the selector 2026-11-22 16:33:48 +05:30
Dean 739bcf2704 fix(libSceJson2): report overlap rejects with their location and drop per-step write probes
Iterator increment and advance already fail through StoreGuest when the state is not writable, so the extra GuestWritable probe only added a syscall per step. The new overlap and aliasing rejects now use NotImplementedAt like the other guest-access failures in this file.
2026-11-22 23:43:51 +13:00
MoandClaude Fable 5.2 b0f18797eb fix(libc): translate the host errno when ungetc and ungetwc fail to flush pending output
ungetc and ungetwc switch a read/write stream to reading before they
push the character back. When that switch cannot flush pending output
(a full non-blocking socket, for example) they returned EOF or WEOF
with the host's errno still in place, so on Linux a guest read 11
where its own EAGAIN is 35.

Both now use the pattern #14560 gave fgetc, getc_unlocked, fgets and
fread: save the caller's errno, clear it, switch, translate the host
value on failure and restore the caller's errno on success.

The socketpair loop in file_streams gains a row for each function.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 02:34:44 -08:00
Remi-BonandClaude Opus 5.5 3aec2e2fa3 perf(shader): convert runtime-format buffer components at their run-time width
The component loop of genericFormattedLoad converted each component once per (type, bit width) pair found in the format table. Unorm, snorm, scaled and integer components now take the component width at run time, so one conversion per type remains; float and d16 conversions keep one per width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:15:19 +01:00
JJenkx ded5abb845 fix(libSceJson2): validate guest pointers in Parser::parse exports 2026-11-22 04:41:04 -05:00
JJenkx c895db15f7 fix(libSceJson2): validate guest pointers in Object, Pair and Object::iterator exports 2026-11-22 04:30:26 -05:00
Abhinav Pullela 65ae551220 test(kernel): honor host performance refusal test exit status 2026-11-22 14:05:44 +05:30
Krille2004zzz 4ddbad5b00 docs(libwebrtc): recount the exports after rebasing onto main 2026-11-22 09:33:55 +01:00
Dean Galvin 96337921fc docs(libwebrtc): count the exports from main's 219 minus the stubs this PR removes 2026-11-22 09:33:35 +01:00
pr-review2 5b54660ca0 docs(libwebrtc): name the WebRTC sources RtpPacket::Parse derives from 2026-11-22 09:33:35 +01:00
Krille2004zzz 0bc3876c46 feat(libwebrtc): implement RtpPacket::Parse 2026-11-22 09:33:35 +01:00
Dean 1476b1e39a fix(libSceIcu): keep UTF-16 unit alignment across page chunks
A NUL scan resumed at the chunk start, so an operand at an odd address that crossed a page boundary was scanned at the wrong byte parity. Resume at the last even offset so the scan always steps whole code units from the start of the operand.
2026-11-22 21:28:07 +13:00
zaryabzipandClaude Opus 5.5 a67e78c196 fix(keyboard): check sceKeyboardGetKey2Char's arguments before its handle, as firmware 9.20 does
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:06:29 +05:00
Mauro Alvarez 4ad11d42a1 fix(libSceHttpCache): exclude unmerged 304 header prefixes 2026-11-22 04:58:54 -03:00
Mauro Alvarez 6c387b8aa1 fix(libkernel): reject 0.0.0.0/8 multicast interface addresses on Windows with EADDRNOTAVAIL 2026-11-22 04:44:45 -03:00
pinewhite d20a820d2e feat(libSceIcu): search UTF-16 strings through guest copies
u_strFindFirst and u_strFindLast passed guest addresses to the linked
ICU routines and pre-measured a NUL-terminated operand with a local loop
that threw NotImplemented_nid_no_patch once the length no longer fit
INT32_MAX. Both operands are now copied in through GuestCopyIn in
page-sized chunks, the search runs on the copies, and the result is
translated back to the guest string, so an unreadable operand raises
std::invalid_argument and neither export reaches
NotImplemented_nid_no_patch; tools/progress.py counts both.

The null, negative-count and empty-needle shortcuts keep ICU's order and
results, and a -1 length keeps the terminator in the copy so ICU takes
the same NUL-terminated paths as before.

Tested: contract, long-operand and page-crossing cases over mmap pages
pass, the pre-change body faults on an unreadable operand where the new
one throws, and 60,000 randomized cases return the same offset as host
ICU 74.
2026-11-22 15:27:28 +08:00
pinewhite a9e370a789 feat(libSceIcu): copy the UTF-8 conversion operands through guest memory
u_strFromUTF8, u_strFromUTF8WithSub, u_strToUTF8 and u_strToUTF8WithSub
dereferenced the guest source directly and wrote the destination unit by
unit behind a GuestArena::HostWrite guard that threw
NotImplemented_nid_no_patch when it could not open. They now read the
source through GuestCopyIn in page-sized chunks, build the result in a
host vector and write it once through GuestCopyOut, so an unreadable
guest buffer raises std::invalid_argument and no conversion path reaches
NotImplemented_nid_no_patch; tools/progress.py counts the four as
implemented.

The substitution count and the destination length are stored before
termination, and the status word is re-read the way ICU's aliased
pointers see it. Error codes, termination and the truncated-substitution
geometry follow ICU 68.2 ustrtrns.cpp, with malformed sequences decoded
by the in-tree utf8_nextCharSafeBody that Utf8.cpp implements from
utf_impl.cpp. u_strFromUTF8Lenient keeps its body because #22460
rewrites that function.

Tested: a host runner over UtfConversions.cpp and Utf8.cpp with the guest
copy seams shimmed; the guest test file passes against the new and the
pre-change object; 20,000 randomized cases and 200 aliased-scalar layouts
match host ICU 74; the pre-change body faults on an unmapped source page
where the new one throws.
2026-11-22 15:23:45 +08:00
ErenYeager1836 78b227baa4 feat(libSceNet): implement loopback up/down interface 2026-11-22 12:40:45 +05:30
amazedturnip f379f06861 fix(libSceJsc): validate guest array buffer pointer in errorMesasgeForTransfer 2026-11-22 01:03:44 -06:00
Siddhant Singh f436174117 fix(libSceJpegParser): cancel initialization on reentrant Finalize 2026-11-22 12:20:40 +05:30
MoandClaude Fable 5.2 480ba6b3a7 fix(libc): translate the host errno of a failed fclose
fclose returned the host fclose result and left the host errno in
place. When the final flush failed, the guest saw the host's number:
on a full non-blocking pipe glibc reports EAGAIN 11, which is EDEADLK
for the guest, whose EAGAIN is 35. fflush, fwrite, fputs and fputc
already translate it.

fclose now saves the caller's errno, clears it before the close and
translates the host value only when the close fails and the host set
one, in the shape of fflush. In every other case the caller's errno is
kept, so a successful close does not change errno, as on FreeBSD.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 22:28:05 -08:00
MoandClaude Fable 5.2 dfb2c01464 fix(libkernel): report the lookup error before EFAULT from stat, lstat and fstatat with a null buffer
stat, lstat and fstatat with AT_SYMLINK_NOFOLLOW rejected a null buffer
before looking the path up, so stat("missing", NULL) failed with EFAULT
where FreeBSD 11.4 reports ENOENT: sys_stat, sys_lstat and sys_fstatat
call kern_statat first and copy the result out only when the lookup
succeeded. sceKernelStat already looks the path up first.

The three early checks are removed. An existing path with a null
buffer still fails with EFAULT, from the copy to the guest buffer, and
nothing is written through the null pointer.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 22:18:23 -08:00
XFlawless1 9ea6006f85 fix(libSceUlt): hand off queue wakeups after failed buffer copies 2026-11-22 06:06:48 +00:00
MoandClaude Fable 5.2 ad6d1c2e8a fix(libc): round hexadecimal subnormal strtod results correctly
Hexadecimal strtod and wcstod results of at least 2^-1074 in the
subnormal range came from the host strtod, and glibc rounds some of
them a unit low: 0x3ffffffffffff5p-1077 gave 0x0007fffffffffffe where
the measured libc.prx (PPSA08329) and correct rounding give
0x0007ffffffffffff.

These results are now rounded from the parsed significand and exponent
with integer rounding at 2^-1074 in the current rounding mode. errno,
the end pointer, normal results and results below 2^-1074 are
unchanged, and strtof and strtold are not touched.

The debt entry loses the sentence about the host rounding a unit low
and records that results below 2^-1074 still ignore the rounding mode.
The unscaled hexadecimal conversion entry records that _Stodx can end
one unit from strtod.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 21:54:43 -08:00
Shrey RatnaandClaude Opus 5.5 08da9a0774 feat(libSceNKWebKit): implement Inspector::ContentSearchUtilities::createRegularExpressionForSearchString and countRegularExpressionMatches
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:15:13 +05:30
Mauro Alvarez 2e49345e78 fix(libcurl): resolve CURLOPT_UNIX_SOCKET_PATH as a guest path 2026-11-22 02:43:26 -03:00
talha-devpandClaude Opus 5.5 937ac09453 feat(agc): count the queue worker's finisher drain waits as busy
Driver.FinisherDrain was listed with the phases, but worker_busy_pct and the
frame timing's worker_accounted_ms left it out, so a worker blocked on the
draw finisher still looked idle. It now counts with the other worker scopes,
and BUILD.md and USAGE.md list it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtFtGr39oKL1zCtAwH7vGx
2026-11-22 07:29:09 +03:00
talha-devpandClaude Opus 5.5 9394c5a199 feat(agc): time the queue worker's waits for the draw finisher
The queue worker drains the draw finisher at the packet gate, before a packet that cannot run
beside it, and at the end of every queue-0 submission. Both waits sit outside Driver.Packet and
Driver.EndSubmission, so worker_busy_pct and the phase totals did not show them. They are now timed
as Driver.FinisherDrain, which the trace summary lists with the other phases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtFtGr39oKL1zCtAwH7vGx
2026-11-22 07:28:58 +03:00
Ryuzaki 07f9e2083e feat(libc): add libc++ character searches
Refs #5927
2026-11-22 04:25:13 +00:00
Ryuzaki 679030e3ff feat(libc): implement libc++ regex_error
Azahar needs a 24-byte exception with the libc++ regex error code
and RTTI. Reuse the guest runtime_error storage for its diagnostic.

Refs #5927
2026-11-22 04:12:21 +00:00
Filip Michalski 1935f50c33 perf(shader): push image metadata that fits the stage range 2026-11-22 04:42:28 +01:00
JJenkx 728f9f1a92 fix(libScePosixForWebKit): copy guest strings safely in fnmatch 2026-11-21 22:32:19 -05:00
MoandClaude Fable 5.2 0e0afccffb fix(libkernel): look the path up for open with O_CREAT and O_DIRECTORY
open with O_CREAT and O_DIRECTORY (without O_EXCL) handed both flags to
the host. Linux 6.4 and later reject the pair with EINVAL for a missing
name, a file and a directory alike, and on Windows OPEN_ALWAYS created
a regular file for a missing name.

FreeBSD 11.4's vn_open_cred creates only when O_CREAT is set without
O_DIRECTORY; otherwise it looks the path up. OpenNative now treats
O_CREAT as absent when O_DIRECTORY is set: a missing name fails with
ENOENT and nothing is created, a file fails with ENOTDIR, a directory
opens, and a write mode on a directory still fails with EISDIR. The
EINVAL result for O_CREAT|O_EXCL|O_DIRECTORY is unchanged.

FreeBSD also skips the access check on this lookup; the host does not.
That gap is recorded in the libkernel debt.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 19:13:26 -08:00
kessler-driftandClaude Opus 5.5 4beb92e0b4 test(libSceJxr): probe unreadable bit I/O state through a no-access page
The edge cases of attachISWrite, putBit16z and fillToByte used the fixed
addresses 0x10000 and 0x10 as unreadable guest state. On Windows the guest
arena starts at 0x10000 and the host can already have memory there, so the
copy succeeded in some runs, the position callback ran and the test aborted
with "attachment forwards original stream" (exit code 0xc0000409). The test
now reserves its own no-access page and checks that it is unreadable first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 04:11:11 +01:00
RTGG 581164ad4b test(libc): drop SonyLocaleconv reset and add read-only default checks in GuestCrt 2026-11-22 04:10:06 +01:00
RTGG 34e07aa706 docs(libSceNpManager): drop unverified reorder, add debt fragment, test Clear under errno hooks 2026-11-22 04:07:39 +01:00
birdmartyandClaude Opus 5.5 06a886cfe2 fix(agc): claim multisampled memory in a CB metadata pass over a single-sample target
A CB fast-clear eliminate or DCC decompress over a single-sample color
target whose memory a host-only multisampled color target still guards
looked up the target's resident image through CachedStorageSurface, and
the guard refused it ("a storage image access ... overlaps multisampled
color target"). Binding such a target as a color attachment already
claims the multisampled memory as reused (ClaimMultisampleTargetMemory
in the draw path); the metadata pass writes the same bytes, so it now
claims them the same way before it touches them, and the guard retires
the multisampled target instead of refusing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 04:56:44 +02:00
Oleg 3173859235 fix(libkernel): answer ESRCH for unused pids in sceKernelGetAppCategoryType 2026-11-22 07:54:22 +05:00
Dean 4009efd979 fix(libSceLibreSsl3): link libc into the OBJ_txt2obj test and move its debt entry into a fragment 2026-11-22 15:54:07 +13:00
Ryuzaki e74a0edf1a feat(libc): add libc++ bad_weak_ptr
Azahar needs the distinct libc++ exception type for its weak pointers.

Refs #5927
2026-11-22 02:45:35 +00:00
RTGG 53c62930d6 test(libc): fix Windows root-preservation assertion in GuestDirectory 2026-11-22 03:43:36 +01:00
RTGG cf16b92469 docs(libSceNpUtility): key debt fragment changes on existing entries 2026-11-22 03:41:18 +01:00
Blazing Cook 765abb1a79 fix(tools): reject duplicate keys in test graph JSON 2026-11-21 20:39:28 -06:00
pinewhite 74b5a0b335 test(libSceNKWebKitRequirements): register the application heap in the WPE fixture
The pasteboard helpers allocate through the guest application heap, so the fixture aborted with an unregistered heap on Linux and with "application heap: process metadata is missing" on Windows. Register host-backed allocate, free, calloc and reallocate through ApplicationHeapRegister, as the other fixtures in this tree do.
2026-11-22 10:38:13 +08:00
pinewhite 4540291ef3 test(libSceLibreSsl3): register the application heap in the OBJ_txt2obj fixture
ObjectFromText allocates the encoded identifier through the guest application heap, so the fixture aborted with "application heap: invalid or missing process parameters". Register host-backed allocate, free, calloc and reallocate through ApplicationHeapRegister, as the other fixtures in this library do.
2026-11-22 10:38:07 +08:00
pinewhite 4a02feff68 test(libSceLibreSsl3): register the application heap in the BIO_vfree fixture
BIO_new_mem_buf allocates through the guest application heap, so the fixture aborted with "application heap: invalid or missing process parameters". Register host-backed allocate, free, calloc and reallocate through ApplicationHeapRegister, as the other fixtures in this library do.
2026-11-22 10:38:05 +08:00
Blazing Cook eae46a313f fix(tools): preserve literal paths in changed-file lists 2026-11-21 20:27:56 -06:00
Mohamed Malek Aifa 4a8c260942 test(libSceHttp): cover SSL error guest outputs 2026-11-22 03:20:22 +01:00
Mohamed Malek Aifa f1e2b1a853 fix(libc): preserve nonblocking flock upgrades 2026-11-22 03:07:30 +01:00
ToRaNekandClaude Fable 5.2 a220b253cb fix(libSceNKWebKit): saturate LayoutRect sums and fix two geometry tests against WebKit
- LayoutRect::unite, LayoutRect::contains and RoundedRect::contains
  added raw LayoutUnit values as int. WebKit's LayoutUnit operators
  saturate, so a rectangle whose right edge passes the maximum wrapped
  to a negative edge here.
- LayoutRect::scale skipped the "infinite" rectangle by comparing its
  origin with INT_MIN / 2; infiniteRect() starts at nearlyMin() / 2,
  another value, so the real infinite rectangle was scaled.
- FloatSize::isZero compared with 0; WebKit compares the absolute
  values with the float epsilon.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 02:21:37 +01:00
kessler-driftandClaude Opus 5.5 e462020b50 docs(libSceLibreSsl3): state the LibreSSL 3.7.3 EVP_PKEY_new_mac_key differences
The pending debt entry said only that types 811, 815 and 1055 may differ
on LibreSSL 3.7.3. It now gives, from the 3.7.3 pmeth_lib.c method table
and gost89imit_pmeth.c, the reason each one queues there, and that 815
returns a key for a 32-byte key. A second entry records that
MacKeyRejection repeats the method types IsLibreSslOnlyPkeyMethod lists.
The Closes when line of the existing entry now reads as one condition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:04:04 +01:00
kessler-driftandClaude Fable 5.2 bc4f4fc850 fix(libSceLibreSsl3): accept BER long-form lengths in the key decoders
d2i_PUBKEY, d2i_RSA_PUBKEY, d2i_PKCS8_PRIV_KEY_INFO, EVP_PKCS82PKEY and
the BIO readers d2i_PKCS8_PRIV_KEY_INFO_bio, d2i_PrivateKey_bio and
d2i_RSAPublicKey_bio refused a long-form length below 128 or with a
leading zero octet with reason 102, so a key that the pinned 078b3d1d
LibreSSL decodes, such as a PKCS#8 whose outer SEQUENCE is written
30 82 00 xx, was not decoded. The in-memory reader now reads lengths as
asn1_get_length of that version does: leading zeros are skipped before
the eight-octet limit and any long form is accepted. The BIO reader
accepts up to six length octets and fails with ASN1_R_HEADER_TOO_LONG
beyond, as asn1_d2i_read_bio does with its eight-octet header read.
Indefinite lengths are still refused; the new debt entry says so.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 01:55:16 +01:00
kessler-driftandClaude Opus 5.5 e528ef5bc0 feat(libSceIcu): implement the collation, normalization, alias, name, break and dictionary data swappers
ucol_swap, ucol_swapInverseUCA, ucol_looksLikeCollationBinary,
unorm2_swap, ucnv_swapAliases, uchar_swapNames, ubrk_swap and
udict_swap call ICU 78.1, whose swap code matches ICU 68.2 except that
unorm2_swap accepts format version 5. That version is refused here
with ICU 68.2's message and U_UNSUPPORTED_ERROR, after the data header
is swapped as 68.2 does.

The guest's UDataSwapper, laid out as in ICU 68.2, is copied into a
host swapper whose functions call the guest's through APS5_VABI
pointers and hand them the guest's swapper. printError receives the
arguments as a System V va_list. cmake/Icu.cmake gains rbbidata.cpp,
dictionarydata.cpp and utext.cpp for ubrk_swap and udict_swap.

The test swaps the in-tree ICU data (ucadata, unames, nfkc and the
big-endian ICU4J cnvalias, sent.brk and thaidict.dict) and a synthetic
inverse UCA file, and checks lengths, bytes, statuses and messages
against values taken from ICU 68.2, in-place swaps, round trips and
what the guest callbacks receive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:51:55 +01:00
Oleg 7f42cdaaf6 fix(libSceAudioIn): reject negative types in the mic-level device gate 2026-11-22 05:39:25 +05:00
kessler-driftandClaude Fable 5.2 7fe662cb3d fix(libSceIcu): read resource 0 as the empty string in the UTF-8 resource accessors
ICU stores an empty string as the resource word 0 and res_getString maps
it to a static empty string instead of reading pRoot[0]. The UTF-8
accessors read the length at pRoot[0], the root resource of the bundle.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 01:13:23 +01:00
kessler-driftandClaude Opus 5.5 d5a6cbd680 fix(libSceLibreSsl3): accept CMS controls on RSA EVP_PKEY_CTX
EVP_PKEY_CTRL_CMS_SIGN returns 1 like DIGESTINIT and PKCS7_SIGN.
EVP_PKEY_CTRL_CMS_ENCRYPT and CMS_DECRYPT return 1 like PKCS7_ENCRYPT
and PKCS7_DECRYPT, and on RSA-PSS queue
RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE and return -2, as in
LibreSSL 3.4.1 pkey_rsa_ctrl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:50:41 +01:00
ToRaNekandClaude Fable 5.2 d23fd217f5 feat(libSceLibreSsl3): decode basicConstraints, extendedKeyUsage and privateKeyUsagePeriod in X509V3_EXT_d2i
X509V3_EXT_d2i threw NotImplemented for three common extensions that
LibreSSL 4.0.0 decodes. They now follow their templates:

- basicConstraints: SEQUENCE { ca BOOLEAN OPTIONAL, pathlen INTEGER
  OPTIONAL } into the 16-byte BASIC_CONSTRAINTS of x509v3.h; ca takes
  the content byte as it is;
- extendedKeyUsage: SEQUENCE OF OBJECT into a stack of ASN1_OBJECT;
- privateKeyUsagePeriod: SEQUENCE { [0] GeneralizedTime OPTIONAL,
  [1] GeneralizedTime OPTIONAL } into PKEY_USAGE_PERIOD.

Refusals queue the errors of tasn_dec.c. X509V3_get_d2i and
X509_CRL_get_ext_d2i use the same table.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 00:50:01 +01:00
amazedturnip 367f9a4f0e fix(libSceNKWebKit): validate guest AuthenticationChallenge in nullify 2026-11-21 17:42:29 -06:00
kessler-driftandClaude Opus 5.5 1ccb826839 fix(libSceLibreSsl3): write no unused bits for an empty BIT STRING in i2d_X509
i2d_X509 took the unused-bits octet from the ASN1_STRING_FLAG_BITS_LEFT
flags even when the BIT STRING was empty, so a certificate whose signature
or BIT STRING algorithm parameter was decoded from 03 01 05 re-encoded as
03 01 05. LibreSSL writes 03 01 00, since i2c_ASN1_BIT_STRING reads the
flags only when the length is positive. X509_digest follows i2d_X509.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:39:24 +01:00
kessler-driftandClaude Opus 5.5 f5aeb89177 fix(libSceLibreSsl3): queue errors for types EVP_PKEY_new_mac_key rejects
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:36:04 +01:00
RTGG 8f07fd9823 fix(libSceNpManager): clear NpTicket data and size before invoking allocator release 2026-11-22 00:29:55 +01:00
RTGG 6c2918688f fix(libc): reset thread-local SonyLconv C-locale defaults on each SonyLocaleconv call
Move SonyLconv and its backing char arrays in SonyLocaleconv_nid_no_patch to thread_local storage and re-initialize all string buffers and fields to canonical C-locale defaults on every call.
2026-11-22 00:29:50 +01:00
RTGG bb46e622a0 fix(libSceLibreSsl): validate guest memory access in SSL_CTX callback setters 2026-11-22 00:29:27 +01:00
amazedturnip feb0e5031e fix(libwebrtc): validate RtpTransceiverInit ctor guest init pointer 2026-11-21 17:24:08 -06:00
Ryuzaki 6656528937 feat(libc): add libc++ thread state
Provide the three thread-state imports reported for Azahar in the
RetroArch inventory. The guest object and pthread key use the existing
libc and libkernel bridges.

Refs #5927
2026-11-21 23:09:21 +00:00
Altewama e97c32480e fix(libwebrtc): return success status from AudioDeviceBuffer start and stop 2026-11-22 00:06:57 +01:00
kessler-driftandClaude Fable 5.2 65866a5349 fix(libSceLibreSsl3): re-encode the signature algorithm before X509_sign signs
X509_sign signed the cached certificate-info encoding and then set the
inner AlgorithmIdentifier in memory only, so a certificate whose inner
identifier had the expected OID but not the parameter LibreSSL writes
(no NULL parameter, or another parameter) came back with the old
identifier in its DER and a signature over that old TBS. It now
rebuilds the TBS with the new identifier, signs that, and stores it as
the cached encoding; a cache that is not a TBSCertificate throws.

A certificate info signed with another signature algorithm still
throws, as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 00:02:15 +01:00
kessler-driftandClaude Opus 5.5 34b55fc6ea fix(libSceLibreSsl): keep negative zero in BN_bin2bn and the zero-word BN_add_word and BN_sub_word
LibreSSL 2.5.4 BN_bin2bn only clears top for an empty input, so a
negative ret becomes negative zero, and BN_add_word and BN_sub_word
return 1 without touching a when the word is zero. Both went through
Store, which cleared the sign of a zero result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:59:01 +01:00
amazedturnip bdf2c4bf6f fix(libwebrtc): validate guest extensions pointer in RtpPacketReceived ctor 2026-11-21 16:44:38 -06:00
kessler-driftandClaude Fable 5.2 1ed69f4198 fix(libSceLibreSsl3): count SSL_CTX_up_ref and SSL_up_ref at the forwarded objects' offsets
SSL_CTX_new and SSL_new resolve to libSceLibreSsl, whose 120-byte SSL_CTX
and 232-byte SSL keep their reference counters at offsets 32 and 168.
SSL_CTX_up_ref and SSL_up_ref incremented the LibreSSL 4.0.0 offsets 40
and 176 instead, so a retained context or connection was destroyed by the
first free and the retain overwrote a neighbouring field.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 23:25:23 +01:00
Nawid3333andClaude Opus 5.5 ee62e408b3 test(shader): skip the integer source modifier test on subgroups narrower than a wave
The DPP cases with row_shl:1 read the neighbouring lane of a 16-lane guest
row, so lane 7 reads lane 8. On a host whose subgroups hold fewer lanes
than the 32-lane wave (lavapipe with 8-lane subgroups) that lane is in
another subgroup and reads zero, and the test failed there. Skip the test
on such devices, as Dpp16Operands does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:14:19 +01:00
Altewama d69f89ca84 feat(libwebrtc): implement AudioDeviceBuffer playout and recording start and stop
Add StartPlayout, StopPlayout, StartRecording and StopRecording, toggling
the measured playing and recording flags with upstream's idempotent guards.
Correct the four declarations to void(WebRtcAudioDeviceBuffer*), matching
the void member functions they export. The task-queue statistics and
periodic logging around them stay unimplemented and are recorded in the
debt fragment.
2026-11-21 22:44:54 +01:00
RTGG 97342d3899 fix(libSceNpUtility): bound AppLaunchLink and ServiceChecker request tables 2026-11-21 21:27:31 +01:00
Thimo Franken d8a9c14864 fix(libScePosixForWebKit): implement SCHED_OTHER wrapper 2026-11-21 21:13:24 +01:00
RTGG e8d0ed2380 fix(libc): preserve UTF-8 roots and ENOTDIR errors in RenameDot
Decode UTF-8 root lengths via std::u8string_view in TrimTrailingSeparators_nid_no_patch and classify missing parents beneath non-directory prefixes with NotFoundError_nid_no_patch in RenameDotError_nid_no_patch, with regression coverage in GuestDirectory.cpp.
2026-11-21 20:24:08 +01:00
Nawid3333andClaude Opus 5.5 766c72537c fix(shader): apply the f16 output modifier after rounding and the FP16_OVFL clamp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 19:44:07 +01:00
DORON1346 d913a8db00 test(libSceLibcInternal): run atomic_wait_deadline in its own working directory
guest_libc_internal_atomic_wait_deadline creates app0/eboot.bin in the
libSceLibcInternal test directory to exercise posix_spawn, and
guest_posix_spawn removes app0 there when it cleans up. When ctest runs
both at once, posix_spawn finds no executable and returns ENOENT instead
of throwing, and the deadline test aborts. Give the test its own working
directory, as guest_posix_spawn_optional_pid already has.
2026-11-21 20:16:32 +02:00
pinewhite 2fd9f955e0 feat(libSceNKWebKitRequirements): implement the WPE pasteboard string helpers
wpe_pasteboard_string_initialize and wpe_pasteboard_string_free are public
libwpe exports that still threw. They follow the LP64 descriptor, allocate-once
and clear-on-free contract of the bundled libwpe 1.14.0 source, allocating the
string data from the guest heap, copying through checked guest memory and
keeping errno.
2026-11-22 02:13:57 +08:00
pinewhite e7e21f5dfa feat(libSceLibreSsl3): implement BIO_vfree
Forward BIO_vfree to the parent library BIO_free and discard its result, as LibreSSL 4.0.0 bio_lib.c does, so titles that free a BIO through the deprecated name no longer throw.
2026-11-22 01:48:12 +08:00
pinewhite fbfc42d7a3 feat(libSceLibreSsl3): implement OBJ_txt2obj
Resolve a dotted object identifier or a built-in short or long name to an ASN1_OBJECT, following LibreSSL 4.0.0 obj_dat.c and a_object.c. Named results return the built-in table entry; numeric text produces an owned encoding that ASN1_OBJECT_free releases.
2026-11-22 01:31:08 +08:00
ToRaNekandClaude Fable 5.2 e6c10bb599 fix(libSceLibreSsl3): stop answering for CRL entries with certificateIssuer
X509_CRL_get0_by_cert compared the certificate issuer with the CRL
issuer for every entry. LibreSSL 4.0.0 compares it with the names of
the entry's certificateIssuer extension, or of the nearest earlier
entry that has one, so the port answered 0 where the source answers 1
and the reverse on an indirect CRL.

GENERAL_NAMES are not decoded here, so the lookup throws
NotImplemented for such an entry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 18:05:52 +01:00
Fernando-Laydner 211d92ea4c fix(web): update progress text on language changes 2026-11-21 14:02:33 -03:00
RTGG 26c6495e89 fix(libScePad): emit all upsampled frames and guard phase in PadHapticBuffer
Widen phase to uint64_t, reset accumulator and phase on rate changes, guard null buffers, and emit all upsampled frames per input sample.
2026-11-21 17:45:24 +01:00
RTGG 2c3488d14b fix(libSceLibreSsl3): check ASN1_OBJECT nid before length in ObjectNid
Check `object->nid != 0` before `object->length == 0` in `LibreSsl3::ObjectNid`, matching LibreSSL 4.0.0 `OBJ_obj2nid` so OID-less `ASN1_OBJECT` entries with a non-zero `nid` and zero length do not resolve to `NID_undef` (`0`).
2026-11-21 17:44:48 +01:00
mrb-eel ebe7cb833c fix(libScePngDec): preserve indexed pixel and palette bytes 2026-11-21 17:16:37 +01:00
birdmartyandClaude Opus 5.5 ffc0cb860c fix(libkernel): keep sceKernelOpen's own name in its log lines
The previous commit wrapped sceKernelOpen's body in a lambda, so its
three log lines were tagged operator(). Set errno at each return
through File::KernelFileResult instead, after the logging, and let
RunKernelFileCall use the same helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 18:03:54 +02:00
slopgobblercobbler f0b7460688 test(libSceAudioIn): verify valid format 0 and invalid format 3 and 4 in OpenEx 2026-11-21 16:58:12 +01:00
slopgobblercobbler bcfcfa8428 test(libScePad): audit scePadRead pre-initialization bounds 2026-11-21 16:57:48 +01:00
RTGG 79285fb0f2 fix(libSceNpParty): validate CreateParam 0x2CA padding, blob readability, and init version ordering
Fix three validation and concurrency bugs in libSceNpParty:
- Check GuestRangeIsZero(param, flagOffset + 1, 6) (0x2CA..0x2CF) instead of 0xCA..0xCF in the non-A branch of ValidateCreateParam.
- Always read data at dataOffset in the non-A branch of ValidateCreateParam and validate GuestBlobIsReadable(data, dataSize) whenever data != 0 && dataSize != 0.
- Store g_version and handler state before publishing g_initialized with memory_order_release in sceNpPartyInitialize, reset g_version in sceNpPartyTerminate, and load g_initialized with memory_order_acquire outside g_handlerMutex.
2026-11-21 16:52:52 +01:00
RTGG ceb549ae9c fix(libSceMsgDialog): consume maximal invalid UTF-8 subparts once
Validate UTF-8 continuation bytes step-by-step against Unicode Table 3-7 bounds in MsgDialog::DecodeUtf8 and advance by the valid maximal prefix length on failure.
2026-11-21 16:52:47 +01:00
RTGG 6a6c8f7976 test(libSceSaveData): fix foreign title ID check and audit RestoreBackupData and CheckBackupData bounds 2026-11-21 16:52:42 +01:00
RTGG 93804b72b0 fix(libSceSaveData): reject non-file and directory paths in SaveDataFile replace_file_with
Validate target paths upfront in savedata::replace_file_with and reject empty source/destination paths in savedata::move_replacing to prevent unwanted directory/temporary-file creation and callback invocations on non-file paths.
2026-11-21 16:52:38 +01:00
RTGG 3caec092d3 fix(libc): evaluate extended rune ranges in wide classification and case conversion
Define the 24-byte FreeBSD 11.4 amd64 _RuneEntry layout, add null-safe ActiveLocale() fallback and binary-search FindEntry(), and evaluate typeRanges, lowerRanges, and upperRanges for code points >= 256 in GuestRune::Is, towlower_nid_postfix, and towupper_nid_postfix.
2026-11-21 16:52:30 +01:00
RTGG 51b36c9e7b fix(libkernel): prevent signed overflow in select deadline saturation
Normalize (seconds, microseconds) without signed overflow, compute unsigned upward/downward headroom via std::make_unsigned_t<Clock::rep>, saturate before scaling, and handle full min()-to-max() spans cleanly.
2026-11-21 16:52:21 +01:00
RTGG 96cbaa8a1d fix(libkernel): map missing Windows and POSIX socket errors to FreeBSD errnos 2026-11-21 16:52:16 +01:00
RTGG 4e980405b2 fix(libSceVideodec2): validate HEVC SEI placement and VCL slice NAL syntax 2026-11-21 16:52:12 +01:00
RTGG b93ac23ac9 fix(libSceAudiodec): avoid mutating M4AAC BSI info on PCM size or pointer errors
Handle DecodeStatus::NotEnoughRoom before writing M4AAC BSI info, and on DecodeStatus::Ok copy PCM output before writing M4AAC BSI info so PCM size or pointer failures leave guest pBsiInfo untouched.
2026-11-21 16:52:08 +01:00
RTGG bfee1515b5 fix(libSceNpEntitlementAccess): handle empty env var, BOM, directories, and empty labels in EntitlementsIni 2026-11-21 16:52:00 +01:00
RTGG 1f42d70a28 fix(libc): reject unsupported exception bits in _Feraise
Follow feraiseexcept's host-safety guard in _Feraise_nid_postfix by throwing std::invalid_argument on bits outside Exceptions (0x3f) before modifying errno or x87/MXCSR state, and document the divergence in docs/dev/debt/changes/fix-libc-feraise-reject-unsupported-bits.md.
2026-11-21 16:51:56 +01:00
RTGG 9503bead16 fix(libSceIme): suppress backward timestamps during PsnDialogNotice cooldown 2026-11-21 16:51:51 +01:00
RTGG 96736c73c5 fix(libSceIme): guard guest pointers and overlapping buffers in ime_filter::FilterText
Guard param, src, dst, and out_length in ime_filter::FilterText via GuestCopyIn_nid_no_patch, GuestWritable_nid_no_patch, and GuestCopyOut_nid_no_patch, buffer output to prevent overlapping src/dst corruption and partial writes on fault, and bounds-check InCodepageA.
2026-11-21 16:51:47 +01:00
RTGG 57599d7066 fix(libc): resume relative symlink expansion in realpath after ascending out of an absolute symlink
Track the path prefix length of an entered absolute symlink via frozenPrefix instead of a sticky boolean so symlink expansion stays suppressed at or below the symlink and resumes once .. ascends above it.
2026-11-21 16:51:42 +01:00
RTGG 204acfbdb4 fix(libc): return ELOOP for paths below symlink loops and deep symlink chains 2026-11-21 16:51:38 +01:00
RTGG 6e14b5fbb7 fix(libSceSystemService): start URL decline cooldown from post-dialog clock time
Sample clock->Now() when OpenUrlOnHost returns OpenUrlOutcome::Declined so modal confirmation dwell time does not shorten or expire OPEN_URL_DECLINE_COOLDOWN.
2026-11-21 16:51:16 +01:00
RTGG 2f33a11b72 fix(libkernel): align macOS guest TLS thread pointer and validate layout 2026-11-21 16:50:55 +01:00
RTGG 061ebd5e79 fix(libc): ignore pthread errors in noexcept libc++ condition_variable methods 2026-11-21 16:50:02 +01:00
RTGG 8d9e99b704 fix(libSceLibreSsl3): delegate PKCS7 ASN1_OBJECT teardown to ASN1_OBJECT_free 2026-11-21 16:49:57 +01:00
ToRaNek 01e992a955 Merge branch 'feat/libscejsc-wtf-small-functions' into feat/libscejsc-url-constructor-set-password 2026-11-21 16:31:44 +01:00
Federico Marras 1966f0202e test(libc): test atomic compare-exchange widths 2026-11-21 16:25:06 +01:00
Federico Marras f43a884fca test(libc): test _Getpmbstate/_Getpwcstate and mbrtowc TLS 2026-11-21 16:25:06 +01:00
Federico Marras abaa185c58 test(libc): test _Lockfilelock and _Unlockfilelock 2026-11-21 16:25:06 +01:00
Federico Marras 2f8296cbee test(libc): test classic numpunct<char> and facet::_Register 2026-11-21 16:25:06 +01:00
birdmartyandClaude Opus 5.5 53fe6e13e4 fix(libkernel): set errno after a file call's logging and expect it from sceKernelReadv
Share RunKernelFileCall through File.hpp instead of two copies, and
wrap sceKernelOpen, sceKernelClose and sceKernelLseek whole so errno
is set after their failure logging. guest_output_pointer_fault now
expects errno 14 from sceKernelReadv over an unreadable iovec array,
as the other sceKernel file calls set it; its checks that the copy
helpers keep errno are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:40:20 +02:00
rudranshcoolhai-boop 36f074ff1a fix(libSceNKWebKit): copy String arguments from their address, not from &impl
WebCore::isPublicSuffix, WebCore::topPrivatelyControlledDomain and
WTF::String::simplifyWhiteSpace copied the StringImpl pointer in from
&string->impl. Forming that member access through a String pointer that
is not 8-byte aligned is undefined behaviour, and the Sanitizers nightly
stops nkwebkit_wtfstringargumentguestpointers on it: the test passes a
String four bytes before an unreadable page.

The pointer is now copied from the String's own address. impl is at
offset 0 (asserted in WtfStringAbi.hpp), so the bytes read are the same,
and a readable String at any alignment gives the same result as an
aligned one, as a plain x86-64 load of the guest object does. An
unreadable String still throws std::invalid_argument.

The test adds Strings at odd addresses in readable memory and checks
the results and reference counts for all three exports.
2026-11-21 19:34:57 +05:30
ToRaNekandClaude Fable 5.2 2104a85c36 Merge branch 'feat/libscejsc-wtf-small-functions' into feat/libscejsc-url-constructor-set-password
Take the recount of #24963 into the shared debt fragment: with one more stub gone from main, the count this branch sets is 119.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 15:03:47 +01:00
ToRaNek f10710fd7c Merge remote-tracking branch 'origin/main' into feat/libscejsc-url-constructor-set-password 2026-11-21 14:55:34 +01:00
ToRaNekandClaude Fable 5.2 bb620c791b feat(libSceJsc): implement the URL(base, relative, encoding) constructor and URL::setPassword
Both were untyped stubs of the 3.20 inventory. They need the URL parser,
which lives in libSceNKWebKit, so they go through the Jsc::ApiBridge:

- the complete-object constructor calls the base-object constructor
  libSceNKWebKit already exports;
- setPassword is added to the ported URL class from WebKit c55364d5,
  next to setUser.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 14:47:21 +01:00
nexus1692andCodebuff 712cae5476 fix(libSceSystemService): read guest title ID safely via GuestCopyIn
sceSystemServiceGetAppId and sceLncUtilIsAppLaunched read the title ID with strlen on the guest pointer, so an unreadable or unterminated title ID crashed the host instead of returning the documented -1.

Generated with Codebuff

Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 14:16:43 +01:00
birdmarty 37052d92e0 fix(libkernel): set guest errno on failure in sceKernel file calls 2026-11-21 14:58:48 +02:00
Steven Dautrich 610b7067ad fix(libSceNKWebKit): exclude overlapping CSS converter export 2026-11-21 13:58:31 +01:00
Steven Dautrich 8a09e09c96 feat(libSceNKWebKit): add fixed decimal formatting 2026-11-21 13:52:51 +01:00
0x70776c 970390fbb5 fix(libScePad): keep output explicit on scePadGetDataInternal error paths 2026-11-21 13:15:52 +01:00
slopgobblercobbler 8e0003f522 test(libkernel): audit sceKernelGetSocPowerConsumption and sceKernelGetSocSensorTemperature bounds 2026-11-21 13:08:47 +01:00
slopgobblercobbler 5c9289d328 test(libSceAudioIn): audit open-ex format bounds, per-path silent state, and buffer guard boundaries 2026-11-21 13:07:14 +01:00
slopgobblercobbler df4922738e test(libSceUserService): audit foreground user query and pointer validation 2026-11-21 13:06:57 +01:00
slopgobblercobbler afc78fbc15 test(libScePad): audit controller information layout, unopened handles, and special handle zeroing 2026-11-21 13:05:36 +01:00
0x70776c 5e8cef3465 fix(libScePad): catch Pad::ReadState exceptions in scePadGetDataInternal 2026-11-21 12:39:56 +01:00
Callimann8 8957d9a87f fix(libcurl): reject a null callback and cyclic forms in curl_formget
Signed-off-by: Callimann8 <64160770+Callimann8@users.noreply.github.com>
2026-11-21 11:06:16 +00:00
Callimann8andClaude Opus 5.5 8798881948 feat(libcurl): implement curl_formget
Copy the guest LP64 curl_httppost chain into host nodes that borrow its
pointers, then serialize it with the bundled curl and forward each chunk
to the guest append callback. Lengths and flags go through HostLong, so an
LLP64 host throws instead of truncating.

The SlistMime test serializes the forms built by curl_formadd, checks the
parts in order including a binary name and contents, and checks that a
short append returns CURLE_READ_ERROR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ2PrBCgtD4myP8EufXgWo
2026-11-21 11:06:16 +00:00
GiannisandClaude Opus 5.5 0a94a32d49 feat(libSceLibcInternal): implement messages<char> and messages<wchar_t>::_Getcat
For an empty facet slot, _Getcat builds a messages facet for the
locale's name with no references, as the (const char*, size_t)
constructor does, and it always returns 6, _X_MESSAGES in
microsoft/STL's xlocinfo, as xlocmes does. num_get (4) and time_get
(5) here use the same numbering. An empty slot with a null locale
throws. This replaces the throwing inventory placeholders 150 and 155.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 12:38:59 +02:00
0x70776c c801034ea5 feat(libScePad): implement scePadGetDataInternal 2026-11-21 11:37:42 +01:00
Alexander 23cd211fc4 fix(tools): restrict digit-separator scan to numeric tokens in nid_names 2026-11-21 10:28:31 +00:00
Alexander 7f080d5a9a perf(tools): scan non-code tokens and skip ignored scopes in nid_names 2026-11-21 09:30:18 +00:00
kessler-driftandClaude Opus 5.5 827e9b4bda fix(libSceLibreSsl3): wrap X509V3_EXT_conf_nid ASN1 values in SEQWRAP, SETWRAP, BITWRAP and OCTWRAP
An ASN1: value with SEQWRAP, SETWRAP, BITWRAP or OCTWRAP returned null without
an ASN1 reason when the modifier had no ':', and threw when it had one.
asn1_cb adds each of them as an explicit universal tag, ignoring any value, and
ASN1_generate_v3 puts these tags around the encoded value, the first one
outermost: a SEQUENCE or SET, or a BIT STRING with no unused bits, or an OCTET
STRING. They are now encoded that way, and a 21st one fails with
ASN1_R_DEPTH_EXCEEDED as append_exp does. IMP and EXP still throw with a ':'
and fail without one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 07:24:27 +01:00
amazedturnip 04c5d67a10 fix(libSceAjm.native): keep WVorbis test helpers in anonymous namespace 2026-11-21 00:04:16 -06:00
Siddhant Singh 2ef6be1a66 feat(libSceGifParser): write title and comment metadata 2026-11-21 11:04:13 +05:30
HBake 1508945ac6 feat(libSceNet): implement sceNetGetInterfaceStats 2026-11-20 20:27:34 -06:00
Oleg 36096e40a7 fix(libkernel): posix mlock and munlock lock mapped pages like the console 2026-11-21 05:13:05 +05:00
slopgobblercobbler 7837e1a3b5 test(libSceAudioOut): audit volume bounds across 8 channels, error precedence, and padspk mix levels
# Conflicts:
#	core/libs/prx/libSceAudioOut/CMakeLists.txt
2026-11-20 22:57:48 +01:00
slopgobblercobbler bc0634623f test(libScePad): verify motion sensor state output sequence in GuestPad 2026-11-20 22:57:14 +01:00
DariusandClaude Opus 5.5 db7a578293 fix(libSceXml): skip ignorable white space by default as firmware 13.40 does
The module's engine starts with setSkipIgnorableWhiteSpace on, so a new
or re-initialized DocumentBuilder drops white space that is a node's only
text. This library started with every option off and kept it as text
nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 23:09:29 +02:00
slopgobblercobbler 69960ef4c7 test(libkernel): audit sysctl kern/debug MIB nodes, null buffer queries, and write rejection 2026-11-20 21:14:08 +01:00
Callimann8andClaude Opus 5.5 adde592d0d feat(libSceNKWebKit): implement WTF::MediaTime::toString
Format the time as WebKit's MediaTime::toString does: "{value/scale = seconds}"
for rational times, "{seconds}" for double-valued ones and ", invalid" for an
invalid time, with the seconds in ECMAScript shortest form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ2Pr9YsGXAAFYYGoHAKFe
2026-11-20 18:22:57 +00:00
slopgobblercobbler 0c984bf548 test(libkernel): audit madvise advice flags and memory alignment boundaries 2026-11-20 18:45:41 +01:00
blawesom 7079f58a69 docs(shader): clarify SPIR-V dump scope 2026-11-20 17:28:51 +01:00
blawesom 95cc7059bf fix(shader): dump final modules on cache hits 2026-11-20 17:28:51 +01:00
blawesom e0bd148794 docs(shader): move interlock findings to a debt fragment 2026-11-20 17:28:51 +01:00
blawesom 5360dca768 feat(shader): dump recompiled SPIR-V modules with APS5_DUMP_SPIRV
Adds APS5_DUMP_SPIRV=<hex code address>|all to write the final recompiled
module to spirv-<stage>-<address>.spv, mirroring APS5_DUMP_IR, to support
issue #18770: the exact PixelInterlockOrderedEXT module that drops an
ordered-interlock write on RADV GFX11 can now be run through a standalone
Vulkan harness on the affected hardware. Covered by agc_spirv_dump_tests.
2026-11-20 17:28:51 +01:00
plentilha e5dace031a fix(libSceFreeTypeOt): clean up slot allocations using validated driver state on rollback 2026-11-20 10:39:35 -03:00
Yunus Shaikh 2eecdd6fc8 Merge #7395's 5b21241399 into fix/shader-pointer-key-lane-masks 2026-11-19 18:00:13 -08:00
Mohamed Malek Aifa 6a8f5d0835 docs: clarify documented LockFileEx downgrade semantics 2026-11-20 02:10:57 +01:00
Mohamed Malek Aifa fe0ff598af docs: restore debt fragment link base 2026-11-20 02:10:57 +01:00
Mohamed Malek Aifa 233051f0e6 docs: fix flock debt source link 2026-11-20 02:10:57 +01:00
Mohamed Malek Aifa deb02d53f9 fix(libkernel): prioritize queued flock upgrades 2026-11-20 02:10:57 +01:00
MarcZX10 c549eb276d docs: describe borderless window mode and ANYPS5_WINDOW_MODE 2026-11-20 00:35:54 +00:00
MarcZX10 c0508db7fd feat(videoout): start borderless with ANYPS5_WINDOW_MODE 2026-11-20 00:35:50 +00:00
MarcZX10 db5e4a014c feat(videoout): toggle borderless with F2 and leave it on F11 2026-11-20 00:35:50 +00:00
MarcZX10 00eeae1e3a feat(videoout): add borderless window mode to the display window 2026-11-20 00:35:50 +00:00
MarcZX10 749d34d95f feat(videoout): add ToggleBorderless input action on F2 2026-11-20 00:04:43 +00:00
xXPBSXxandClaude Sonnet 5.5 0d2749a93b docs(libSceWorkspace): record that libSceWorkspace.sprx did not load in a payload process on firmware 11.60
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 00:20:20 +01:00
Federico Marras c85044324f feat(libSceJsc): implement InspectorHelpers::parseEnumValueFromString 2026-11-19 21:34:09 +01:00
Benjamin 119ac2f4cc fix(libSceFreeType): reject an unusable library before reading the outline in FT_Outline_Render 2026-11-19 19:07:45 +01:00
plentilha ef04843e1b fix(libSceFreeTypeOt): preserve owned bitmap when slot buffer is unwritable 2026-11-19 14:48:37 -03:00
plentilha 10081a8a3a fix(libSceFreeTypeOt): fail SlotInit when root_clazz is unreadable 2026-11-19 11:41:34 -03:00
Stuart Russell 14aba68c24 fix(agc): a 0xffffffff register offset names no register
A SET_*_REG packet or indirect register list with a 0xffffffff offset is accepted by the hardware and the rest of the packet still takes effect. The driver threw and lost the submission. registerOffset now reports the sentinel through an optional, and the validation range check, the direct write loop, the indirect pair loop and the indirect trace skip that entry.
2026-11-19 14:19:24 +00:00
plentilha 5463c0ed7c fix(libSceFreeTypeOt): preserve newer face glyph head on aslot rollback 2026-11-19 09:10:59 -03:00
MarcZX10 c48024adc5 test(libc): return null for a destination with a public and a private subobject
A whole with a public and a private subobject of the destination type, in both base orders, is ambiguous for a source in a third base; with only the public subobject the cast still finds it.
2026-11-19 06:48:46 +00:00
MarcZX10 bac6ec5c7f fix(libc): treat a destination reached through several subobjects as ambiguous whatever their access
The uniqueness of the destination was checked after the candidates were filtered by access, so a private second subobject of the destination left the public one as the only target. Every distinct destination subobject now counts, as in the GNU runtime, and the result reports the ambiguity in whole2dst.
2026-11-19 06:48:46 +00:00
MarcZX10 2651f273af test(libc): keep a public downcast when another route to the source is private
A virtual base inherited publicly through one parent and privately through another is checked in both base orders, with a private-only hierarchy as the negative control and the -1 source-to-destination hint.
2026-11-19 06:48:46 +00:00
MarcZX10 f0bed63ef6 fix(libc): keep a public route to the source when another route to it is private
A source subobject reached through several routes, such as a virtual base inherited publicly through one parent and privately through another, kept only the last route's access, so a later private route erased the public downcast. The routes are now combined the way the destination candidates are.
2026-11-19 06:48:46 +00:00
MarcZX10 6340a34c41 test(libc): cover RTTI cast callback inheritance paths 2026-11-19 06:48:46 +00:00
MarcZX10 bd637b7686 fix(libc): implement RTTI cast result callbacks 2026-11-19 06:48:46 +00:00
MichonandClaude Opus 5.5 2027f7f1f5 fix(agc): require transfer-destination support and refuse unsupported 4_4 textures
Optional sampled formats now also need VK_FORMAT_FEATURE_TRANSFER_DST_BIT,
since texture uploads copy into the image, and guest format 137 (4_4,
R4G4_UNORM_PACK8) joins the list, so a device that lists no features
for it refuses the texture instead of creating an image it cannot use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 06:37:55 +01:00
MichonandClaude Opus 5.5 2d894f6610 fix(agc): refuse 10_10_10_2 SNORM and SINT textures the device cannot sample
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 06:37:55 +01:00
RTGG 873e7ac931 fix(libSceNpWebApi2): validate user contexts, requests, and multipart types per firmware 13.60
Implement the 3-tier packed ID hierarchy (libCtxId -> userCtxId -> requestId) and firmware 13.60 argument, lookup, and non-multipart validation across libSceNpWebApi2 user-context and request lifecycle exports, with updated GuestNpWebApi2 regression tests and a debt fragment.
2026-11-19 02:39:27 +01:00
Yunus Shaikh 606212c86e Merge #7395's ef102a3a52 into fix/shader-pointer-key-lane-masks 2026-11-18 16:44:59 -08:00
plentilha 95d2b106d1 fix(libSceFreeTypeOt): guard SlotDone and lifecycle helper copies 2026-11-18 21:40:46 -03:00
plentilha ab9220c5bd fix(libSceFreeTypeOt): copy glyph slot records through guest memory 2026-11-18 19:42:49 -03:00
RTGG 6f43708861 fix(libSceVideoOut): synchronize FrameTimingLog stop signaling, close on failure, and reject empty reports
Reject empty Report callbacks in Enqueue before locking, synchronize worker.request_stop() under mutex and serialize Finish() with finishMutex, and close file plus clear pending in run()'s catch (...) handler.
2026-11-18 22:47:32 +01:00
RTGG 1d332fafe9 fix(libSceIme): keep complete UTF-8 and stray continuation bytes at the 64 KiB clipboard cap 2026-11-18 22:47:09 +01:00
Benjamin fa4c60ef35 fix(libSceFreeType): copy FT_Outline_Render guest pointers safely 2026-11-18 22:36:24 +01:00
Dean Galvin ada5e09213 fix(libSceAudioOut): run guest_audio_out_port_bounds with the dummy audio driver 2026-11-19 06:11:20 +13:00
MichonandClaude Opus 5.5 671392e910 fix(shader): round D16 reads of UNORM and SNORM texels to nearest
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 17:35:40 +01:00
Nawid3333andClaude Opus 5.5 0ac1bdcf6d test(shader): run v_cvt_off_f32_i4 SDWA with neg and abs instead of refusing it
SdwaCvtOffSatPk expected the decoder to refuse neg and abs on the
v_cvt_off_f32_i4 SDWA source. The decoder now accepts them, and on RDNA2
hardware they leave the result unchanged: they only touch bit 31 of the
selected and extended source, and the instruction reads bits 3:0. The test
now runs the DWORD-destination cases with neg, abs and both and expects
the unmodified result. The v_sat_pk_u8_i16 refusals stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 16:34:43 +01:00
Nawid3333andClaude Opus 5.5 13d397745c feat(shader): accept neg/abs on 32-bit integer DPP and SDWA sources
The RDNA decoder no longer throws for the DPP16 and SDWA neg and abs bits
on VOP1 and VOP2 opcodes whose sources are 32-bit integers. On RDNA2
hardware the bits flip, clear or set bit 31 of the operand after the DPP
lane move and after the SDWA select and extension, which is what
readOperand already does for 32-bit reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 16:31:16 +01:00
bobczan 981fc3ba39 fix(libSceLibreSsl): copy the CMAC message and tag through guest copies 2026-11-18 13:03:39 +00:00
finley 2218cfb3f1 feat(libSceNKWebKit): implement the WebCore::HistoryItem constructors and mutation exports 2026-11-18 13:55:55 +01:00
Ethan Hainline 319e7bde82 fix(libSceVideoOut): copy the mode queries through a guest copy 2026-11-18 06:33:49 -06:00
Ethan Hainline 97d402656c fix(libSceVideoOut): read the HDR mode byte through a guest copy 2026-11-18 06:15:48 -06:00
pr-review2 326dbbc5e8 docs(libSceVideoOut): record the assumed guest pointer error answers 2026-11-18 06:15:48 -06:00
Ethan Hainline 8eb361caac fix(libSceVideoOut): copy guest pointer parameters through GuestPtr 2026-11-18 06:15:48 -06:00
bxon11 d907dcf97b fix(io): retain drive-relative Windows output paths 2026-11-18 15:08:48 +03:00
bxon11 600371f87e fix(io): support long Windows staging paths and portable ACL tests 2026-11-18 15:06:06 +03:00
bxon11 c3c3f28272 test(io): remove Windows symlink before fixture cleanup 2026-11-18 14:52:59 +03:00
bxon11 5d8b3c9c8c test(io): verify Windows recovery when backup cleanup is blocked 2026-11-18 14:52:59 +03:00
bxon11 97de398ac7 fix(io): stage Windows output before replacing existing files 2026-11-18 14:52:48 +03:00
milescovielloandClaude Opus 5.5 73c04effdb fix(libwebrtc): copy AudioBuffer::CopyFrom and CopyTo samples through checked guest copies
AudioBuffer::CopyFrom and CopyTo read the caller's stream config and
read or wrote the interleaved samples one by one through the guest
pointers, so an unmapped or read-only config or sample buffer crashed
the host. The config is now copied in once, CopyFrom copies its
num_frames * num_channels input samples in once before it changes the
buffer, and CopyTo interleaves into a host array and writes it with one
GuestCopyOut_nid_no_patch. A config or sample buffer that can't be
accessed throws std::invalid_argument, the result for a null one, and
errno is kept across the copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 03:35:17 -05:00
milescovielloandClaude Opus 5.5 4c4cdd86d5 fix(libwebrtc): read and write the AudioFrame fields through checked guest copies
AudioFrame::muted, data, mutable_data, UpdateFrame and data_view read
and wrote the frame's fields through the guest pointer, and UpdateFrame
copied the caller's samples with memcpy, so an unmapped or read-only
frame or sample buffer crashed the host. Each field is now read with
GuestCopyIn_nid_no_patch and written with GuestCopyOut_nid_no_patch,
mutable_data clears a muted frame's samples with one copy, and
UpdateFrame copies the samples in once before writing them to the
frame. A frame or sample buffer that can't be accessed throws
std::invalid_argument, the result for a null frame. errno is kept
across the copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 03:34:51 -05:00
Mcm190andClaude Opus 5.5 f41f2a3ee9 fix(libcairo): initialize the test's own Cairo mutexes on Windows
The font pipeline tests link a static Cairo copy beside libcairo's. On
Windows its critical sections start uninitialized, and the reference
helpers locked them through toy font faces and the scaled-font map before
any call initialized them, crashing the conversion and faces modes.
Initialize them at load, as Context.cpp does for libcairo's copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 07:17:56 +00:00
MichonandClaude Opus 5.5 dbd8b11ad3 fix(shader): pack D16 image reads toward zero and saturate 32-bit integers as RDNA2 does
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 07:54:27 +01:00
Mcm190andClaude Opus 5.5 8a66d07511 fix(libcairo): bridge native font faces to guest font-face records
main now represents CairoFontFace handles as FontFace.cpp records, while
the font pipeline passed them to native Cairo as cairo_font_face_t.
cairo_scaled_font_get_font_face now returns one record per native face,
tied to the native face's lifetime through native user data, and
reference and destroy on it act on the native reference count.
cairo_scaled_font_create and cairo_set_font_face unwrap the record and
throw for FreeType faces, which have no native face.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 06:52:31 +00:00
Mcm190andClaude Opus 5.5 b1083cce81 fix(libcairo): return error fonts for null create arguments
Null font faces and matrices passed to cairo_scaled_font_create now
produce Cairo's native null-pointer error font, after the face-status
and font-matrix checks, instead of throwing. cairo_scaled_font_text_to_glyphs
validates its count outputs before the null-argument path writes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 06:52:16 +00:00
Mcm190 c083a46ae6 feat(libcairo): implement native font pipeline and device destruction 2026-11-18 06:52:16 +00:00
Akshay Sharma d507c11ff0 test(relinker): cover rpath and verify-patches repetition and trace-imports in cli parser 2026-11-18 11:54:43 +05:30
Yunus Shaikh 5eb49d1893 test(agc): accept a null record pointer as unmapped in the lane-mask pointer tables
agc_driver_pointer_phi_lane_and_table and
agc_driver_pointer_phi_lane_not_table pair arms whose low word can be 0
with the record pointer's high word: lane_not_table's zero arm, and
lane_and_table's lane-mask arm in the waterfall pass over lanes 32-63.
When the records sit below 4 GiB, the selected pointer is then 0x0,
which faults as unmapped, as a null pointer does in
agc_driver_pointer_phi_sampler_table.

The records are on the test's stack. Since #18253, Windows test
executables link without high-entropy addresses, which keeps their
stacks near the bottom of the address space, and on a Windows RTX 4090
run both tests failed with "selected the descriptor at 0x0: unmapped".
Accept that fault only when the records' high word is 0; elsewhere
these arms still have to fault outside the snapshot.
2026-11-17 18:50:11 -08:00
MichonandClaude Opus 5.5 7623199a80 fix(shader): flush denormal v_trig_preop_f64 results in the f64 flush modes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 03:35:47 +01:00
Arif Athaya Harahap 43c8cf2d92 fix(libfontconfig): read FreeType face and charmap through guest memory 2026-11-18 09:20:56 +07:00
rgvxsthi f3d0378c80 fix(libc): treat directories as case-insensitive when the host cannot report case sensitivity
CaseInsensitiveDirectoryWindows treated any failure of the FileCaseSensitiveInfo query as a case-sensitive directory. Hosts that cannot answer it look names up case-insensitively; Wine fails the query with ERROR_CALL_NOT_IMPLEMENTED. MatchNames then listed the whole directory for every lookup of a missing name instead of one FindFirstFileExW for that name. The errors a host gives for an unsupported information class now mean case-insensitive; other failures keep the previous behaviour.
2026-11-18 13:16:37 +11:00
JJenkxandClaude Opus 5.5 1ec4059a1c fix(agc): sample S# filter mode 3 as a weighted average
FILTER_MODE 3 filters exactly like mode 0 on RDNA2, so decode it as a
weighted average, clear it to 0 in materialized direct samplers so the
min/max rules do not apply, and poison table samplers only for modes 1
and 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:37:42 -05:00
DerKarussellbremserandClaude Fable 5.2 0e1b98b86e fix(relinker): compare the advisor's patch path resolved in its JSON test
tools/suggest_patches.py reports a patch under the resolved catalog
path, but test_patch_advisor_json_integration.py expected the path as
written. With the build tree, and so the test's TMPDIR, behind a
symbolic link or a Windows junction the two differ and the test fails.
The test now expects the resolved path, as fernandomcrsilva proposed
in #22581.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
2026-11-18 01:11:35 +01:00
husari.orozco 29ab20ffe7 fix(libSceNet): model the guest listen queue past its backlog on macOS
FreeBSD 11.4 keeps the listen backlog as `so_qlimit` and `sonewconn` drops a
connection once `so_qlen > 3 * so_qlimit / 2`, so a backlog of 0 completes
one connection and drops every later one while none is accepted. macOS does
not bound a `listen(0)` queue at one, so `guest_sce_net`'s connect-expiry
case completed 64 connects and never saw a pending one.

Each guest listener now counts its completed but unaccepted connections:
`sceNetListen` stores the backlog, `sceNetAccept` releases one, and a
blocking `sceNetConnect` with a connect timeout to a guest listener past
`3 * backlog / 2` follows FreeBSD's drop: it still lets the host complete the
connection into its own queue, waits the timeout, and reports `EAGAIN`, so
the guest sees the pending socket the console shows and the retry path keeps
returning `EADDRINUSE`.

The debt fragment records the bounds: a non-blocking connect, connections
from outside the guest socket set, a negative backlog clamped to FreeBSD's
default `somaxconn`, and the count resetting when the listener closes.
2026-11-17 17:22:10 -06:00
plokmklo 23432dcc0f fix(libSceAvPlayer): hold handed-out video frames with optional extra buffers
A title drawing a handed-out frame could have its buffer rewritten by
the decoder as soon as the next frame was handed out: with 2 or 3
output buffers no earlier handed-out frames were kept and free buffers
were reused newest first.

After the 4 optional decode-ahead framebuffers, request 4 more
optional framebuffers. When they are granted, keep at least the 5
newest handed-out frames intact and reuse free buffers oldest first.
When memory is short, the behaviour is unchanged.

TestPs5ExtendedInitLayout now expects the requested output buffer
count plus the decode-ahead and held pools. The memory-pressure cases
cover a partial and a full held-pool grant, and the handed-out frame
check runs with 2 and 6 output buffers.

Resolves the frame-buffer accounting question of issue #6898: the
output buffer count at 0x228 stays authoritative and the extra pools
are additive. The unknown console frame lifetime is recorded in the
libSceAvPlayer debt file.
2026-11-17 16:48:04 -03:00
milescovielloandClaude Opus 5.5 bd7a675d67 fix(libSceNpManager): copy the sce::np value-class objects through checked guest copies
The NpOnlineId, NpId, User, NpTitleToken and NpAccessToken constructors
and Clear methods, the NpAccessToken IsEmpty query, the NpOnlineId and User
comparison operators and the NpTicket accessors read and wrote the
caller's objects through the guest pointers, so an unmapped or read-only
object crashed the host. Each call now reads its sources once through
ReadGuest and writes the fields it sets with one
GuestCopyOut_nid_no_patch, leaving the struct padding as it was. An
inaccessible object fails through NotImplementedAt_nid_no_patch, as the
NKWebKit value classes do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 13:12:04 -05:00
mjnhbg3 ef23232b9e feat(libSceAmpr): record and execute native file reads 2026-11-17 12:18:27 -05:00
milescovielloandClaude Opus 5.5 700f58b981 fix(shader): say why a private variable counts as per-invocation in the spanned-wave report
The report merged three reasons for a private variable's load into one:
a per-invocation value stored to it, a store through a per-invocation
pointer, or a store in divergent flow. Each variable now keeps the first
reason found, with the stored value's root or the store's block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:10:56 -05:00
milescovielloandClaude Opus 5.5 89e42a70df fix(shader): name the per-invocation value behind a spanned-wave fallback
The spanned-wave check rejected a barrier in divergent flow by its block
alone, so a fallback in a title's log did not say which value made the
flow per-invocation. Each per-invocation value now keeps its root (a
varying built-in, an Input load, a private variable stored a
per-invocation value, a load of memory the shader writes with no barrier
before it, an atomic or subgroup result, a divergent phi, a call or a
parameter), and the report names the branch that splits the flow, its
condition and that condition's root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 10:24:46 -05:00
NWProgramming00andClaude Opus 5.5 4ff75fe392 test(shader): compare transcendental modifier rows within the device's error
The driver's rcp, rsq, sqrt, log2 and exp2 differ from RDNA 2 in the
last bits (rsq(2.0) is one ulp lower on an RTX 4090), so each result is
divided by its modifier's scale and compared with Float32ResultsAgree,
and v_cos_f32 within 2^-11. NaNs and signed zeros stay exact. The rows
at 2^-126, 2^126, exp2(-125) div:2 and exp2(128) are dropped, since a
device within those bounds can cross a flush or overflow edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:40:59 +01:00
NWProgramming00andClaude Opus 5.5 a1efda1d9f test(shader): accept the device's 1/x error in the rcp denormal rows
The default v_rcp_f32 lowering is the driver's 1/x, which Vulkan allows
2.5 ulp of error. A result other than the RDNA 2 value now passes when
it is a normal value within that bound of the exact reciprocal, or a
signed zero when the bound reaches below 2^-126; a denormal result
still fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:40:57 +01:00
NWProgramming00andClaude Opus 5.5 50d5e600ab test(shader): compare f64 transcendental rows within 4 ulp of the same class
The driver's f64 rcp, rsq and sqrt are not required to be correctly
rounded, so finite results now match within 4 ulp while zeros,
infinities, NaNs and the denormal-or-normal class stay exact. The rows
whose exact result is the smallest normal or the overflow threshold
are dropped, since a device within that bound can land on either side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 15:40:56 +01:00
NWProgramming00andClaude Opus 5.5 9a380db74f fix(shader): apply the output modifier on f32 transcendentals with denormals kept
RDNA2 applies mul:2, mul:4 and div:2 to v_rcp_f32, v_rcp_iflag_f32,
v_rsq_f32, v_sqrt_f32, v_log_f32, v_exp_f32 and v_cos_f32 whenever
IEEE mode is off, in every f32 denormal mode. The translation followed
the general rule, which drops the modifier when f32 output denormals
are kept, so those shaders lost the scaling.

Measured on gfx1036 with the hardware oracle; the new execution test
pins the rows for FLOAT_MODE 0xf0 and 0xc0 with IEEE off and 0xf0
with IEEE on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 14:29:48 +01:00
NWProgramming00andClaude Opus 5.5 fb6e04ce83 fix(shader): flush v_rcp_f64, v_rsq_f64 and v_sqrt_f64 denormals by the f64 field
RDNA2 reads a denormal input of v_rcp_f64, v_rsq_f64 and v_sqrt_f64 as
a zero of its sign when bit 0 of the FLOAT_MODE f16/f64 denormal field
is clear, and returns a zero of its sign for a denormal result when
bit 1 is clear. The translation kept both, so rcp of a denormal gave a
large finite value where the hardware gives infinity, and rcp of a
value above 2^1022 gave a denormal where it gives zero.

Measured on gfx1036 with the hardware oracle; the new execution test
pins the exact rows in all four f64 denormal modes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 14:29:34 +01:00
DucengarthandClaude Opus 5.5 e4b09746d2 fix(tools): reject a null or empty pull_request in the event
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 13:31:09 +01:00
GruzberryandClaude Sonnet 5.5 d31446da1d fix(libSceLibcInternal): copy __std_init_once_begin_initialize pending out-param through GuestCopyOut
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 11:17:48 +00:00
NWProgramming00andClaude Opus 5.5 9f30460fd8 fix(shader): flush v_rcp_f32 denormal results to a signed zero
RDNA2 returns a zero of the result's sign from v_rcp_f32 and
v_rcp_iflag_f32 whenever the reciprocal is below 2^-126, in every
FLOAT_MODE f32 denormal mode and IEEE mode. The recompiler kept the
driver's denormal 1/x, so inputs above 2^126 in magnitude gave a
denormal where the hardware gives zero.

Measured on gfx1036 with the hardware oracle; the new execution test
pins those rows for FLOAT_MODE 0xc0 and 0xf0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 12:16:46 +01:00
THEMANnt cf6b8be4c7 fix(libkernel): accept connections on libSceNet sockets 2026-11-17 14:11:15 +03:00
zaryabzipandClaude Opus 5.5 a657558375 fix(npmanager): give out request ids and refuse bad ids as firmware 13.42 does
Firmware 13.42 run in an emulator (issue #9277): request ids start at
0x20000001 and the lowest free one is handed out, a 33rd live request
is refused with 0x80550013, sceNpCreateAsyncRequest refuses a null
parameter (0x80550003) and a size other than 0x18 (0x80550011), and
Poll, Wait, Abort and Delete refuse a request id of 0 or less with
0x80550003. What Poll and Wait answer for a live request is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 14:43:30 +05:00
Dominik Fuchs 5d693e7d2f perf(libSceGnmDriver): store draw packets without reading the command buffer
Build each draw packet in a host array and copy out only the words main
stored, so the writers no longer read the guest command buffer first. The
counted writers store their two spans around the untouched NOP word. The
padding words main never wrote stay untouched and need not be readable.
2026-11-17 09:08:11 +01:00
Dominik Fuchs 19b2d39ada fix(libSceGnmDriver): write draw packets through guest copies 2026-11-17 07:19:31 +01:00
milescovielloandClaude Opus 5.5 57ece99051 fix(libSceFont): clear the writing record through a checked copy
sceFontWritingInit cleared the caller's FontWriting with memset before
building the writing state inside it, so an unmapped record crashed the
host. It now clears it through CopyOutGuest, keeping errno, and an
unwritable record returns SCE_FONT_ERROR_INVALID_PARAMETER, as a null one
does, before anything is built in it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 22:56:50 -05:00
Nicolas AboschandClaude Opus 5.5 0912308e48 fix(agc): close the poll sleep timer when its thread exits
PollSleep created a high-resolution waitable timer per thread and never closed it. Use the
per-thread timer of PreciseWait, which is released with the thread; the 200 us wait is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 23:40:46 -03:00
Nicolas AboschandClaude Opus 5.5 dcf7be76e9 fix(agc): publish the idle epoch under the driver mutex before waking waiters
Queue worker 0 evaluates its idle-epoch wait predicates under the driver
mutex and then blocks, with no timeout on the second wait. The last running
worker finishing (Running destructor) and a queue blocking in a memory wait
(noteWaitBlocked) incremented the epoch and notified without the mutex, so a
bump landing between the predicate check and the block was lost and queue 0
stayed asleep. Take the mutex around the increment; the notify follows it.
Neither call site can hold the mutex: both run during packet execution after
the worker released it, and noteWaitBlocked already locks it on another path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 23:40:45 -03:00
uvtqtandClaude Opus 5.5 fa529d485e test(agc): enable VK_KHR_portability_subset once in the Recorder test device
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 00:35:56 +01:00
AlfaRojoandClaude Opus 5.5 6037d3f541 docs(shader): record that the 16-bit straddle is measured in alignment mode UNALIGNED
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 17:29:33 -06:00
AlfaRojoandClaude Opus 5.5 13e086cb7b docs(shader): record typed 16-bit buffer loads at odd offsets as unpinned
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:48:51 -06:00
AlfaRojoandClaude Sonnet 5.5 d3335727b9 fix(shader): read a 16-bit buffer load that crosses a dword boundary from both dwords
buffer_load_ushort and _sshort at an offset of 3 modulo 4 returned only the low
byte, because the load looked at one dword. RDNA2 (gfx1036, AMD Windows driver 32.0.21043.5001,
through the hardware oracle; IEEE 0, DX10 clamp 1, denorm32 0, denorm16 3, round32/16 0, fp16
overflow 0) returns both bytes whenever offset + 2 <= NUM_RECORDS. The second byte now comes from
the following dword, for every V# range.

BufferHalfStraddle pins ushort and sshort loads against 512 rows measured on that GPU, with
soffset, an immediate offset and a short range, in wave32 and wave64.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 15:31:02 -06:00
zaryabzipandClaude Opus 5.5 bb287c97c9 test(videoout): open the port before the display-position rows touch the driver
The rows for handle -1 ran before the guarded sceVideoOutOpen. Their
handle lookup starts the VideoOut driver, which throws on the main thread
on a runner without a Vulkan surface, so the Windows CI job aborted
instead of skipping. They now run after the open, with the other rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 00:22:10 +05:00
aasishdairel 06c8d671e6 docs(relinker): link the wide-store decoder source in the debt fragment 2026-11-17 08:18:58 +13:00
dantdmdarealguy 6be44f0dc1 fix(agc): give the device-lost hook lambda an empty parameter list
The device-lost hook installed by the VulkanDevice constructor was
written as `[captures] noexcept { ... }`. Omitting the parameter list
before a noexcept specifier is a C++23 feature, so GCC 15 and 16 warn
with -Wc++23-extensions under the project's C++20 mode. Writing `()`
makes the lambda valid C++20; the generated code is unchanged.
2026-11-16 13:17:01 -06:00
aasishdairel 322209a8cd fix(relinker): lower unaligned 256-bit stores for --to-rosetta 2026-11-17 00:26:56 +05:30
aasishdairel ab2b4bf377 fix(relinker): emit module-qualified guest imports in macOS output
GuestModuleBuilder gated the provider-qualified binding name, the
executable-import rename and the provider BindingAliases behind !macos,
so two bundled modules exporting the same NID left macOS imports on flat
symbol lookup: a declared provider was not retained and an import needed
from two providers failed conversion outright (debt relinker entry 92).

The binding name and alias emission now cover macOS like Linux: the
executable's import is renamed to <nid>#moduleN and the named provider
module exports the matching <nid>#moduleN alias, which the macOS guest
writer emits as an extra Mach-O export (ordinary or TLS) so the dyld
flat-namespace bind of the aliased name resolves inside the declared
provider. Guest modules with a declared import module rename their
imports the same way. The multi-needed-provider conversion failure now
only triggers when no provider is declared, matching Linux, and the
Linux import/export type checks apply to macOS imports too. Linux
behaviour is unchanged: the widened conditions are equivalent there.

Evidence: new test_macos_guest_qualified_imports.py with the
qualified_import_fixture.py images converts twin providers through the
macOS writer and asserts the executable and consumer bind
_shared#module1#guest, both providers export the plain name plus their
own alias at the same RVA, an undeclared import with two needed providers
still fails with 'Ambiguous guest import', a single needed provider keeps
the flat name, and an OBJECT-typed import against a FUNC export fails the
now-enabled type check. linux_guest_qualified_imports, guest_symbol_names
and the macOS guest weak import/export tests pass unchanged; the full
relinker-only suite passes (948 tests).
2026-11-16 22:47:08 +05:30
XIIYAZ a92c9bb5d4 fix(libc): fail a stream float scan of an empty hex prefix or a truncated infinity on macOS
Stream scans with a narrow character conversion parse each float field with the host's fscanf. macOS stdio reads 0 from '0x' and inf from 'infi' and leaves the rest for the next conversion, where the console (and glibc) end the field with a matching failure. Before the host scan, the stream source now looks ahead over the few characters such a prefix spans, pushes them back, and fails the conversion for an optional sign and 0x without a hex digit or point, or for infi not completed to infinity.
2026-11-16 19:47:34 +03:00
milescovielloandClaude Opus 5.5 944d29fc64 fix(libSceFont): read and write font open handles and details through checked copies
The sceFontOpenFont* exports read the caller's handle as a reuse hint and
stored results and nullptr through it in place, and the memory and file
forms read FontOpenDetail in place. Each body now runs on a host-local
handle through WithGuestHandle, which copies the handle in once and out
once, and the detail is copied in once; a bad handle or detail returns
SCE_FONT_ERROR_INVALID_PARAMETER, keeping errno.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:05:56 -05:00
milescovielloandClaude Opus 5.5 72b4e9fced fix(libSceFont): read and write generated glyph handles through checked copies
sceFontGenerateCharGlyph cleared and stored the caller's glyph handle and
read the generate detail and its memory record in place, and
sceFontDeleteGlyph read and cleared the handle in place. They now use
CopyInGuest and CopyOutGuest, keeping errno; a bad handle, detail or
memory record returns SCE_FONT_ERROR_INVALID_PARAMETER before a glyph is
created or freed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:05:56 -05:00
milescovielloandClaude Opus 5.5 76bdbb638b fix(libSceFont): set up render surfaces through checked copies
sceFontRenderSurfaceInit, sceFontRenderSurfaceSetScissor and
sceFontRenderSurfaceSetStyleFrame read and wrote the caller's surface and
style frame in place. They now go through GuestCopyIn/GuestCopyOut and the
library's CopyInGuest/CopyOutGuest, writing only the fields they set and
keeping errno; SetStyleFrame returns SCE_FONT_ERROR_INVALID_PARAMETER for an
unmapped surface or frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:05:56 -05:00
milescovielloandClaude Opus 5.5 236893ad43 fix(libSceFont): clear the script and typography outputs through checked copies
sceFontGetScriptLanguage and sceFontGetTypographicDesign cleared their int
output straight through the caller's pointer, so an unwritable output
crashed the host. Both now clear it with CopyOutGuest, keeping errno; a
failed clear returns SCE_FONT_ERROR_INVALID_PARAMETER, as a null output
does, and earlier errors are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:05:55 -05:00
milescovielloandClaude Opus 5.5 1bd1e0f683 fix(libSceFont): write font metrics and style information through checked copies
sceFontGetFontMetrics and sceFontGetFontStyleInformation computed straight
into the caller's output and cleared it in place on failure. They now read
the output into a local with CopyInGuest, compute into it and write it back
with CopyOutGuest, so untouched fields keep their bytes; an unwritable
output on a valid font returns SCE_FONT_ERROR_INVALID_PARAMETER.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:05:55 -05:00
milescovielloandClaude Opus 5.5 e436464669 fix(libSceFont): read and write font memory records and handles through checked copies
sceFontMemoryInit and sceFontMemoryTerm used the caller's FontMemory in
place, and sceFontDestroyLibrary and sceFontDestroyRenderer read and
cleared the caller's handle in place. They now go through CopyInGuest and
CopyOutGuest and check writability before releasing anything; a bad record
or handle returns SCE_FONT_ERROR_INVALID_PARAMETER, keeping errno.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:05:55 -05:00
milescovielloandClaude Opus 5.5 e5453dd5ea fix(libSceFont): read and update style frames through checked copies
The sceFontStyleFrame calls read the caller's frame, and the setters wrote
its fields, in place, so an unmapped or read-only frame crashed the host.
Every call now reads the frame once with CopyInGuest, Init writes the
initialised frame in one copy, and the setters write only the fields they
change; a bad frame returns SCE_FONT_ERROR_INVALID_PARAMETER, keeping errno.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 09:05:55 -05:00
brumskysb 937c9e99f8 docs(debt): measure packed 16-bit store rounding and 4_4 nibbles on gfx1036 2026-11-16 03:43:33 -07:00
PetreandClaude Haiku 5.5 c5758e7dff docs(libkernel): restore the queue-order wording in the semaphore debt entry
The trimmed entry had dropped the priority ordering rule (lower values first,
equal ones in arrival order) and the equal-thread-priority qualifier on the
attribute 2 measurement. Both are back; the entry is 985 characters.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-16 10:28:16 +01:00
PetreandClaude Haiku 5.5 5bfe9aad4c test(libkernel): keep the waiter behind a timed-out head queued, as the console does
On a PS5 (firmware 13.590.001), when the head of the queue times out with
tokens still free, the waiter behind it stays asleep until its own timeout,
and the token stays free. Measured for attributes 1, 2 and 0 with a 200 ms
head and a 3 s waiter: the waiter returned ETIMEDOUT 2950 ms after the
signal, and a poll of 1 afterwards succeeded.

The new check pins that behaviour. It fails on main, which wakes the waiter
at the signal, and passes with this change. The debt fragment records the
measurement, drops the unverified attribute 0 queue order (measured in queue
order), and is under 1000 characters.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-16 10:26:11 +01:00
AdriaanandClaude Opus 5.5 1e732ecb5d fix(libSceAgc): encode sceAgcCbBranch register arguments as the console does
The console masks the mode to 2 bits and the compare function to 3 bits
and clears the low bits of the compare address instead of rejecting them.
The remaining oracle mismatches come from stack arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 11:09:48 +02:00
Waleed Ali Tahir 1e3039af7b fix(libwebrtc): copy packet and utility guest pointers safely 2026-11-16 13:46:03 +05:00
Waleed Ali Tahir 8cf92505fd fix(libwebrtc): probe WavReader destination samples before fread 2026-11-16 13:06:10 +05:00
Waleed Ali Tahir 40b840faf9 fix(libwebrtc): copy WavReader and FileWrapper guest pointers safely 2026-11-16 13:06:10 +05:00
pr-review2 a1578a6638 docs(libSceVideodec2): record that Decode and Flush copy guest buffers 2026-11-16 20:03:00 +13:00
PrivacyOnion 29d0ff9694 fix(libSceVideodec2): validate OutputInfo size, reuse staging, and copy row spans 2026-11-16 07:39:49 +01:00
PrivacyOnion 25cbe3773e fix(libSceVideodec2): bound OutputInfo guest copies by caller thisSize 2026-11-16 07:30:55 +01:00
PrivacyOnion 8a0b9ef3bd fix(libSceVideodec2): safely copy guest decode and flush buffers 2026-11-16 07:30:55 +01:00
Yunus Shaikh b4a5b1a618 Merge #7395's 3c58f422ee into fix/shader-pointer-key-lane-masks
Moves this branch's FormatVersion to 94, above #7395's 93.
2026-11-15 22:17:32 -08:00
MarcZX10 f775a326c2 test(relinker): cover PT_NULL program headers with unused-filter=2 2026-11-16 06:11:58 +00:00
MarcZX10 97925c2639 fix(relinker): skip PT_NULL headers in strict filter validation 2026-11-16 06:11:58 +00:00
MarcZX10 28c2c5021a fix(relinker): warn when the unconverted-module scan stops early 2026-11-16 00:38:06 +00:00
MarcZX10 e05eab461d refactor(relinker): remove the throwing candidate header reader that nothing calls 2026-11-16 00:30:51 +00:00
MarcZX10 3811ccd2fe fix(relinker): skip an unreadable file in sce_module instead of aborting the conversion 2026-11-16 00:30:50 +00:00
Babu AkhilandClaude Opus 5.5 8f65f52ae1 fix(libSceSdma): check the handle before the fill and window arguments
sceSdmaConstantFill and sceSdmaCopyWindowL2L validated their arguments
before Submit checked the handle, so a null, closed or unknown handle with
a nonuniform default-size fill or an out-of-range window reached
NotImplemented instead of returning SdmaErrorInvalidArgument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 05:34:05 +05:30
roboterspinne b6cd01db01 fix(libSceImeDialog): return INVALID_ADDRESS from sceImeDialogGetCurrentStarState for an unwritable state
sceImeDialogGetCurrentStarState stored the star state through the raw
guest pointer, so an unmapped or read-only state pointer crashed the
host process while a dialog was open. The value is now written with the
file's CopyOutPreservingErrno, and a failed copy returns 0x80bc0031, the
code the function already returns for a null state. The open dialog and
null checks keep their order, and errno is preserved across the copy.
2026-11-15 23:12:52 +01:00
Gagan 04c2681493 fix(relinker): support OS dynamic lifecycle tags in guest modules
# Conflicts:
#	core/relinker/relinker/src/guest/GuestImageReader.cpp
2026-11-16 03:32:09 +05:30
zaryabzipandClaude Opus 5.5 d72ced4508 fix(videoout): check the display-position event calls as firmware 13.42 does
sceVideoOutAddDisplayPositionEvent and sceVideoOutDeleteDisplayPositionEvent
threw on every call. They now take their firmware arguments and return
0x8029000b for a handle that is not open and 0x8029000c for a bad queue.
The delete returns 0x8029000d on a valid queue, since nothing is added;
the add throws where it would register, as the kernel side is unread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 02:53:48 +05:00
CPritchandClaude Sonnet 5.5 c5949e4c89 fix(agc): make the draw finisher's pending-write queries see writes queued in the draw pipeline
queryPendingWrite and QueryPendingSpan checked the queue-0 pipeline's queued
writes only when DrawPipeline::Active() was true, which is set only on the
queue worker. A draw handed to the draw finisher captured its memory with no
such check, so a capture over a range that an earlier queued item writes read
the bytes from before that write. The queries now check the queued writes on
the finisher thread as well: a capture over one drains the pipeline first and
a span query over one answers Sync.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 21:31:10 +00:00
Ondra97 2f2259c60d fix(libc): preserve selector shape for dependent float scans 2026-11-15 21:31:18 +01:00
Ondra97 47bbc5cbd4 fix(libc): refresh scan prefix integration with main 2026-11-15 21:26:06 +01:00
Hermes Desk af1e7a2a64 fix(relinker): reject output files needed as directories
Reject conflicts between a planned output file and a directory needed by another output during preflight. Writing the executable to a new app0 path previously left converted modules behind before failing.

Cover Linux and Windows output in write and dry-run modes with synthetic guest modules.
2026-11-15 21:12:18 +01:00
PetreandClaude Sonnet 5.5 53b1246630 fix(libkernel): stop sceKernelSignalSema at a waiter that needs more tokens
On a PS5 (firmware 13.590.001) a semaphore waiter that needs more tokens
than are available blocks the waiters queued behind it: with a waiter of 3
ahead of a waiter of 1, a signal of 1 woke neither and a poll of 1 still
succeeded, for the attributes 1, 2 and 0. sceKernelSignalSema passed over
the larger waiter and woke the later one. It now stops at the first waiter
it cannot satisfy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 20:52:52 +01:00
Kikoarl 31831f576e fix(shader): initialize BindingLayout fields with zero defaults 2026-11-15 20:03:34 +01:00
Queuse af78ab9a82 fix(relinker): wrap address-size LEA roots 2026-11-15 14:32:29 -03:00
Ondra97 14b8ca8d88 fix(libc): merge main into Windows scan prefix fix 2026-11-15 17:31:09 +01:00
Sergio LópezandClaude Fable 5.2 1619ab9d6e test(agc): cover a bounded GDS write and a pointer store in the ahead resolution
The written-ahead test expected a dispatch that binds GDS to stop
resolveGroupAhead. Such a dispatch now writes the fixed GDS range, so the
dispatch after it is adopted ahead too. The unbounded stop is covered by a
dispatch that stores through a raw pointer instead.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-15 16:57:37 +01:00
Babu AkhilandClaude Opus 5.5 aedb6fcbcc fix(libSceSdma): reject handles sceSdmaOpen did not return
A non-null handle that is not the address of an engine slot sceSdmaOpen
returns was dereferenced: an unmapped one crashed the process and a
readable one was used as a slot. Every handle entry point now returns
SdmaErrorInvalidArgument for it, as for a null handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 21:12:49 +05:30
milescovielloandClaude Opus 5.5 c7d1036ba5 fix(libc): probe the gets_s buffer when nothing fits or input ends
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:59:31 -05:00
Dean Galvin 75feb14196 chore: merge main and keep the host NaN handling next to the directed fma condition 2026-11-16 00:39:58 +13:00
Ketan MauryaandClaude Opus 5.5 56b815cd14 feat(shader): allow directed rounding modes for packed f16 fma
Round each exact half product-sum of v_pk_fma_f16 and v_pk_fmac_f16 once
through the interpolation arithmetic in the f16 rounding mode, as packed
add and multiply do, following RDNA2 ISA section 12.10. With f16 results
flushed, a lane is tiny when twice its exact value, rounded in the mode,
is below 2^-13, the 11-bit unbounded-exponent test of packed multiply.

The reference in PackedFmaF16Rounding.cpp matches RDNA2 (gfx1036) on a
2,048-row hardware-oracle sweep of every f16 round, f16 denormal, IEEE,
DX10_CLAMP and FP16_OVFL mode; the test pins 256 of those rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019BnsKwjbZijNX2cctQKmrU
2026-11-15 11:18:14 +00:00
milescovielloandClaude Opus 5.5 2a769e4875 fix(libkernel): safely probe the symbol name of dlsym
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:12:53 -05:00
milescovielloandClaude Opus 5.5 add7dbdc36 fix(libc): safely probe the buffer of gets_s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:09:33 -05:00
milescovielloandClaude Opus 5.5 375d9951ea fix(libSceNpCommon): safely probe the allocator outputs of the heap getters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 01:18:16 -05:00
liu 3a0e8ed7a5 test(agc): count depth view allocations on Windows 2026-11-15 02:14:12 +01:00
DucengarthandClaude Fable 5.2 28c21edc49 fix(tools): report a pull request event without a title as a usage error
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 23:59:05 +01:00
c1b3r-p3d1aandClaude Opus 5.5 5e8abb068c test(shader): check SDWA f32 rounding and frexp destinations on special inputs
agc_driver_sdwa_destination_f32 also runs the seven ops on zeros,
denormals, infinities, NaNs and large values with f32 denormals kept and
flushed, against results measured on gfx1035 (Radeon 680M).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 22:37:50 +01:00
xXPBSXxandClaude Sonnet 5.5 f824cbbbca fix(agc): retry a screenshot trigger that cannot be removed at the next frame
Screenshot::Take threw when removing the APS5_SCREENSHOT_TRIGGER file
failed, for example while another process still had it open on Windows,
and the throw aborted the title. A removal that fails is now reported once
and the trigger is tried again at the next frame; the screenshot is taken
once the file can be removed. A trigger that is not a regular file or
cannot be inspected still throws.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 22:18:16 +01:00
xXPBSXxandClaude Sonnet 5.5 60bff57e4c test(agc): keep a screenshot trigger that another process holds open
When another process holds the APS5_SCREENSHOT_TRIGGER file open on
Windows, removing it fails and Screenshot::Take throws, which aborts the
title (a bot run ended that way after a screenshot request). The test
holds the trigger open, expects Take to return without a request and
without throwing, and expects the released trigger to be consumed at the
next call.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 22:10:30 +01:00
c1b3r-p3d1aandClaude Opus 5.5 f4fe797639 test(shader): run image_gather4h_pck on R8 and RG8 textures
agc_driver_image_packed_horizontal_gather checks the packed bitstream of
8_UNORM and 8_8_UNORM textures next to 8_8_8_8_UNORM, with three more
dmasks. The debt entry records that gfx1035 reads the last row for rows
past the height, where gfx1031 and the emitter return zeros.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 17:17:20 +01:00
XIIYAZ a076d7606a fix(agc): apply a uniform sample mask in the pixel shader on MoltenVK, whose static mask does not stop shading 2026-11-14 18:27:12 +03:00
Alexandre Figueiredo 1921f413b3 feat(agc): print pixel inputs and vertex fetch resources in agc_shader_replay --mem 2026-11-14 15:06:19 +00:00
c1b3r-p3d1aandClaude Opus 5.5 c102e71e54 fix(agc): sample more formats that FORCE_DEGAMMA leaves unchanged without it
On gfx1035 (Radeon 680M) a FORCE_DEGAMMA sampler reads 2_10_10_10 SNORM,
32_32_32 FLOAT, 5_5_5_1, guest format 141 and the 16-, 32- and 10-bit
integer formats bit for bit as without the bit, point and bilinear, so
they no longer throw. The 8-bit integer formats change and still throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:48:09 +01:00
c1b3r-p3d1aandClaude Opus 5.5 1e99d9981e feat(shader): follow split denormal fields and f16 rounding in 16-bit interpolation
Bit 0 of each FLOAT_MODE denormal field keeps that precision's denormal
inputs and bit 1 its denormal result, so denormal modes 1 and 2 no longer
throw in v_interp_p1ll_f16, v_interp_p1lv_f16 and v_interp_p2_f16, and
v_interp_p2_f16 rounds by the f16 rounding mode. The f32 directed rounding
of v_interp_p1ll_f16 and v_interp_p1lv_f16 still throws.

Measured on gfx1035 (Radeon 680M) in all 512 float modes; pinned rows in
agc_driver_interpolation_modes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:19:12 +01:00
c1b3r-p3d1a 74c713fbef Merge remote-tracking branch 'origin/main' into feat/jxr-file-stream
# Conflicts:
#	docs/dev/debt/libSceJxr.md
2026-11-14 11:28:16 +01:00
Sergio LópezandClaude Opus 5.5 1d240739b2 fix(agc): bound the writes of dispatches that cannot store through pointers
DispatchWriteRanges marked every BDA-ABI compute result unbounded, and every
GDS, page-table or fault-buffer binding as well, so a queue-0 dispatch with
those bindings always drained the draw pipeline instead of becoming a commit
item. The fault buffer and the page table are driver-owned, and a result
without a page table has no address table, so it cannot reach guest memory
through pointers. A result now stays unbounded only when it binds the page
table and stores through addresses (bdaWrites or the SPIR-V scan the driver
already uses). A GDS binding adds the fixed GDS range instead. The existing
rule that keeps fault-buffer-only results bounded (e2338d5bd1) is now part
of the general one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 10:04:48 +01:00
Yunus Shaikh 1376724c9f Merge #7395's e9ddd12bd2 into fix/shader-pointer-key-lane-masks 2026-11-14 00:30:02 -08:00
akkadbakkad89 7b8fa75fdc test(libSceNpCommon): cover heap, allocator, JWS and XML init 2026-11-14 13:29:38 +05:30
akkadbakkad89andDevin c16ec76cc6 test(libSceNpCommon): pin the firmware UTF-8 shape scheme and document its permissive accepts
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-14 13:29:34 +05:30
akkadbakkad89andDevin 1806519291 feat(libSceNpCommon): implement heap, allocator and UTF-8 helpers
Firmware 4.03 disassembly shows a NpHeap is a single mspace handle and
a NpAllocator is a function-pointer vtable, and both families are thin
dispatchers:

- _sceNpHeapMalloc/Realloc/Free/Strdup/Strndup and the upgraded
  _sceNpHeapMalloc stub forward to sceLibcMspace*; _sceNpMalloc,
  _sceNpRealloc and _sceNpFree do the same over the global heap
- _sceNpAllocatorMalloc/Realloc/Free/Strdup/Strndup and the upgraded
  _sceNpAllocatorMalloc stub call through the allocator function
  pointers at offsets 0, 8 and 0x10 with the context at 0x18
- _sceNpMsgPackStrUtilIsValidUtf8String(WithSize) perform strict
  UTF-8 validation; sceNpUtilNumChars counts characters and rejects
  control bytes other than tab, line feed and carriage return
- sceNpJwsHs256GetEncodeSize returns ((size + 2) / 3) * 4 + 0x5e and
  sceNpXmlParseInit zero-initialises the 0x268-byte parser context

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-14 13:29:30 +05:30
Sankalp7317andClaude Opus 5.5 4d4484d456 fix(tests): set the upload cache test's environment with _putenv_s on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 12:43:31 +05:30
xXPBSXxandClaude Sonnet 5.5 3ef471d994 docs(debt): state the PS5 result of the sanitizer replace-table getters
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 07:17:46 +01:00
xXPBSXxandClaude Sonnet 5.5 a0c07076f7 fix(kernel): return null from the sanitizer replace-table getters
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 06:49:49 +01:00
xXPBSXxandClaude Sonnet 5.5 f07ad45867 test(kernel): pin sceKernelGetSanitizer{Malloc,New}ReplaceExternal returning null
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 06:49:08 +01:00
Yunus Shaikh 95c2a47c76 Merge #7395's 40d718d87b into fix/shader-pointer-key-lane-masks 2026-11-13 07:53:59 -08:00
edubox 1122c07dfe feat(libSceAbstractYoutube): return 0x809E0005 from Folder Open and Close
In the 13.40 module both bodies are six bytes: mov eax, 0x809E0005; ret, with no
argument read, so the answer is the same for every input and matches the code
the rest of this library's immediate returns already return. The technical debt
entry now lists them with the others.

The new guest_abstract_youtube_trivial_returns test calls the whole immediate
return surface of the library, so the constants stay pinned.
2026-11-13 16:09:44 +01:00
amazedturnip 492091d208 fix(libSceAjm.native): validate guest pointers in sceAjmDecWVorbisCreateHeaderPacket 2026-11-12 22:52:34 -06:00
c1b3r-p3d1aandClaude Opus 5.5 74a0ae2f51 fix(libSceJxr): skip fclose for a stream whose open failed
A failed open leaves the stream with a null file, and closing it passed
that null file to the guest fclose. Close now frees the stream without
calling fclose when there is no file, and the test closes the
missing-file and invalid-mode streams through their Close slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 02:34:38 +01:00
Dean Galvin 856197e3c2 fix(debt): count the remaining libSceJxr additional stubs 2026-11-13 12:16:15 +13:00
c1b3r-p3d1aandClaude Opus 5.5 982d2dcac7 feat(libSceJxr): open file streams from the PKFactory slot
The PKFactory CreateStreamFromFilename slot follows jxrlib's
CreateWS_File: it allocates the stream through WMPAlloc, wires the
FILE* callbacks and opens the file with the guest fopen, returning
WMP_errFileIO when the open fails. The stream's Close follows
CloseWS_File: guest fclose, then WMPFree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 23:47:32 +01:00
Ondra97 fac97d17fe refactor(libc): preserve narrow character scan callers 2026-11-11 13:56:49 +01:00
Ondra97 dcc5a3cae0 fix(libc): reject incomplete hex prefixes in Windows sscanf 2026-11-11 13:46:36 +01:00
amazedturnip 85b345eb9a fix(libSceJxr): validate guest memory pointers in WMPAlloc and WMPFree 2026-11-10 20:54:39 -06:00
Yunus Shaikh bddad7dfa0 fix(shader): give this PR's recompiler change its own disk cache format, 80
#7395 now takes 79, above this PR's 66, so this PR takes 80, the lowest number above it that no open PR uses, and a cache written by another branch's recompiler is not read as this one's.
2026-11-09 19:19:21 -08:00
Yunus Shaikh bc08ac89c7 Merge #7395's 3309a349f6 into fix/shader-pointer-key-lane-masks
Takes #7395's FormatVersion 79, which is above this branch's 66; the next commit gives this branch its own number.
2026-11-09 19:19:18 -08:00
Yunus Shaikh e22ac325f8 Merge #7395's 85e79949ae into fix/shader-pointer-key-lane-masks 2026-11-08 10:23:25 -08:00
Yunus Shaikh 3cc9dd79e9 Merge #7395's 86527d2f76 into fix/shader-pointer-key-lane-masks 2026-11-07 03:58:55 -08:00
Yunus Shaikh c9de9a962c Merge #7395's 0ce8d173a3 into fix/shader-pointer-key-lane-masks 2026-11-06 20:01:32 -08:00
Yunus Shaikh 9eab037489 Merge #7395's e94fb3f29d into fix/shader-pointer-key-lane-masks
e94fb3f29d is #7395 with its merge of main after #7223. The two
conflicts are this branch's own changes over #7395: FormatVersion 66, and
its wording of the pointer-keyed image-table debt entry.
2026-11-03 20:46:02 -08:00
Yunus Shaikh 58ebe4b440 Merge main into fix/shader-pointer-key-lane-masks 2026-11-03 00:33:00 -08:00
MarcZX10 92acfff288 test(libSceNpCommon): cover a callout whose delay overflows the deadline
A callout started with the largest delay must stay queued instead of
running at once.
2026-11-02 23:45:25 +00:00
MarcZX10 bc2aaf29cd fix(libSceNpCommon): saturate the callout deadline in sceNpCalloutStartOnCtx64
The deadline was computed as now plus the requested delay in unsigned
64-bit arithmetic. A delay close to UINT64_MAX wrapped to a deadline in
the past, so the callout ran at once instead of waiting. The deadline is
now clamped to UINT64_MAX.
2026-11-02 23:45:25 +00:00
MarcZX10 b49b54708f test(libSceNpCommon): cover a split invalid UTF-8 lead in the JSON reader
The lead byte of a three-byte sequence ends one call, and the next call
brings a byte that does not continue it, followed by a closing quote.
The value must decode to the lead byte and the letter after it, the same
as when the input comes in one call.
2026-11-02 23:44:36 +00:00
MarcZX10 dc56a69dc0 fix(libSceNpCommon): keep the bytes after a split invalid UTF-8 lead in the JSON reader
When a multi-byte UTF-8 lead ends one call and the next call brings bytes
that do not continue it, the reader decoded the lead alone but still
reported all of the buffered and incoming bytes as consumed. The bytes
after the lead, including a closing quote, were skipped, so the string
never closed and its value was lost. The result depended on where the
input was split.

Report only the incoming bytes that the decoded character used, so the
rest is read again from the input.
2026-11-02 23:44:17 +00:00
Yunus Shaikh afb123a49e Merge #7395's main merge into fix/shader-pointer-key-lane-masks 2026-11-02 06:17:38 -08:00
Yunus Shaikh 87984fe728 Merge #7395's main merge into fix/shader-pointer-key-lane-masks
# Conflicts:
2026-11-02 00:34:58 -08:00
louise-patraandClaude Opus 5.5 b1d851bf47 test(libkernel): require the racing datagram queue to be empty after the drain
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:35:05 +05:30
louise-patraandClaude Opus 5.5 bf70e27f7d test(libkernel): drain late datagrams before the racing reader's final check
The racing reader can stop before the sender's last datagram is readable,
as on macOS loopback. After both threads join, the test now reads each
remaining datagram while the read event reports it, checking its size, and
then requires the event to time out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:13:39 +05:30
louise-patraandClaude Opus 5.5 7287682bf3 fix(libkernel): retry a failed Windows peek event and link the pool test on MinGW
- The peek event is created when a pool record is acquired, and a failed
  WSACreateEvent is tried again on the next acquire instead of leaving the
  record without an event.
- guest_socket_submitted_records checks that a failed preparation is retried
  and the record then reused.
- guest_socket_submitted_record_tests links libc and configures Windows
  unwinding like guest_socket_event_tests, so it links on MinGW.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:35 +05:30
louise-patraandClaude Opus 5.5 eb68e51da7 fix(libkernel): keep every submitted Windows datagram peek reserved until it completes
- A peek that WSARecv left pending stays reserved whatever
  WSAGetOverlappedResult reports, and is reused only once
  HasOverlappedIoCompleted reports it done.
- The pool moves to Socket/include/SubmittedRecords.hpp, and
  guest_socket_submitted_records checks that a submitted record is not
  handed out again before completion and is reused after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:35 +05:30
louise-patraandClaude Opus 5.5 0f4e920500 fix(libkernel): keep the Windows datagram peek nonblocking through cancellation
- NextDatagramSize checks the cancelled peek with WSAGetOverlappedResult
  without waiting, so Ready never waits under the equeue mutex.
- The OVERLAPPED, event and buffer live in a process-wide pool that is never
  freed; a peek whose cancellation is still pending is reused only after
  HasOverlappedIoCompleted reports it done.
- A completion that wins over the cancel reports its size; a failed
  CancelIoEx leaves the peek parked.
- Test: a sender and a racing reader on one datagram socket while the read
  event is polled; every reported size is 0 or 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:35 +05:30
louise-patraandClaude Opus 5.5 a28661f8a7 docs(libkernel): record the measured Windows peek behaviour on a pending reset
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:35 +05:30
louise-patraandClaude Opus 5.5 69cf176682 fix(libkernel): peek Windows datagram sizes and replace re-added socket marks
- GuestSockets::Ready on Windows reads a datagram socket's next datagram size
  with an overlapped MSG_PEEK receive, cancelled if it would wait, since
  Winsock's FIONREAD reports 1 for a zero-length datagram.
- Adding an existing socket event again replaces its low watermark.
- A socket low watermark above INT64_MAX throws instead of being capped.
- A write event re-added on a pipe whose read end closed succeeds and replaces
  its udata; EPIPE is kept for a new event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:35 +05:30
louise-patraandClaude Opus 5.5 cc1e3c285a fix(libkernel): keep the default socket watermark for sizes 0 and 1
A size of 1 set a watermark of 1, so a readiness with no data, such as
a zero-length datagram, no longer fired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:35 +05:30
louise-patraandClaude Opus 5.5 9efc5cd539 fix(libkernel): cap socket low watermarks at INT64_MAX
A size that does not fit in int64_t became negative and let every
readable or writable event through; it now caps at INT64_MAX, which
only end of file reaches. The tests drop the throw assertions for
unimplemented cases and run the pipe write path only where the host
reports pipe write readiness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:34 +05:30
louise-patraandClaude Opus 5.5 3f8fc2e72b feat(libkernel): add pipe write events and socket low watermarks to sceKernelAdd*Event
sceKernelAddWriteEvent takes the write end of a pipe, with EPIPE once
the read end is closed, and a size above 1 sets the low watermark of a
stream socket, as kevent already does for both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:04:25 +05:30
Yunus Shaikh df80d9b636 Merge #7395's 5fdf20fc3d into fix/shader-pointer-key-lane-masks 2026-11-01 01:56:16 -08:00
Yunus Shaikh 3d14230a7c Merge #7395's merge of main into fix/shader-pointer-key-lane-masks
The conflict in core/libs/prx/libSceAgcDriver/CMakeLists.txt from #12862's split is resolved with tools/agc_test_split.py resolve, which moves this PR's test registrations into tests/cmake/.

ShaderDiskCache's FormatVersion conflicts too, since #7395's merge brings 63. This PR's own format moves from 53 to 66, the lowest number above #7395's 63 that no open PR uses, in the stack's order, so its recompiler change keeps a disk cache format of its own.
2026-11-01 02:01:40 +00:00
Yunus Shaikh 13c1955909 Merge main into fix/shader-pointer-key-lane-masks
# Conflicts:
#	core/shader/recompiler/ShaderDiskCache.hpp
2026-10-30 09:58:32 +00:00
Yunus Shaikh ffa34ecc26 Merge feat/shader-nested-sampler-tables into fix/shader-pointer-key-lane-masks 2026-10-29 12:57:34 -07:00
Yunus Shaikh 3e2ebbbf35 fix(shader): give this PR's recompiler change its own disk cache format, 53
#7395 now takes 51 above #7223's 50, and 52 is held by #10000, so this PR takes 53.
2026-10-29 03:45:54 -07:00
Yunus Shaikh 238806dc87 Merge feat/shader-nested-sampler-tables into fix/shader-pointer-key-lane-masks 2026-10-29 03:45:50 -07:00
Yunus Shaikh 408401b351 Merge #7395's main merge into fix/shader-pointer-key-lane-masks 2026-10-28 02:31:20 -07:00
Yunus Shaikh 24d5cbbcec Merge #7395's test-only commit into fix/shader-pointer-key-lane-masks 2026-10-28 01:18:58 -07:00
Yunus Shaikh 752620ec73 Merge main into fix/shader-pointer-key-lane-masks
# Conflicts:
#	core/shader/recompiler/Optimization/src/ResourceTracker.cpp
2026-10-27 22:57:44 -07:00
Yunus Shaikh 4750c85fcd test(agc): stop asserting that two pointer-table shapes are refused
Two checks expected resource planning to refuse a shape with "not a valid
runtime value": a high-word arm read from a buffer whose V# is loaded
through a pointer, and a record pointer arm whose two words are both
immediates. Such a check fails once the shape is supported, so both go.
The first was the whole of agc_driver_pointer_phi_high_second_table's
mode, so that mode and its registration go with it; the lane-mask,
high-word and second-lane cases stay.
2026-10-27 21:52:48 -07:00
Yunus Shaikh cfb72cb70e fix(shader): give this PR's recompiler change its own disk cache format, 51
The format ladder along the stack is #7395 50 and this PR 51, so a cache
written by #7395's recompiler is not read as this one's.
2026-10-27 21:52:46 -07:00
Yunus Shaikh 29365ffe14 Merge #7395's merge into fix/shader-pointer-key-lane-masks 2026-10-27 21:52:30 -07:00
Yunus Shaikh e2af03bf19 Merge #7395's merge of #7223 into fix/shader-pointer-key-lane-masks 2026-10-24 14:46:57 -07:00
Yunus Shaikh 232a8e4c54 Merge #7395's main merge into fix/shader-pointer-key-lane-masks 2026-10-24 06:51:49 -07:00
Yunus Shaikh 08586677a1 Merge #7395's main merge into fix/shader-pointer-key-lane-masks 2026-10-24 01:07:25 -07:00
Yunus Shaikh 9e50a74929 fix(shader): refuse a pointer-keyed record arm whose two words are both immediates
The pointer walk skips an edge whose low word is an immediate, as a waterfall loop's Phi gives one beside the record column read. Where the pointer's two words are Phis of one block, an edge on which both are immediates is a constant pointer that no record holds, such as a null pointer, so the walk now refuses the column there instead of planning it.
2026-10-23 23:37:24 -07:00
Yunus Shaikh 9162d9df8f Merge #7395's 4661f4bab5 into fix/shader-pointer-key-lane-masks 2026-10-22 23:13:02 -07:00
Yunus Shaikh 8704f73b79 Merge feat/shader-nested-sampler-tables into fix/shader-pointer-key-lane-masks
Brings #7395's merge of main bd4d8018d2, with #8991. It merged without conflicts.
2026-10-21 13:03:32 -07:00
Yunus Shaikh a7d1e62b53 docs(shader): note the edge-paired walk of a pointer-keyed record pointer
The two words of the pointer are now walked edge by edge, and an edge
whose low word is a constant or a lane mask is skipped with its high
word. A high word read from a second buffer stays refused on an edge
whose low word is the record word.
2026-10-21 06:59:38 -07:00
Yunus Shaikh 92cede35a0 fix(shader): pair a pointer-keyed record pointer's two words by Phi edge
The low and high words of a pointer-keyed record pointer were walked
separately, so a high-word arm on a path whose low word is a lane mask
refused the plan even though that pair is no pointer. Ratchet & Clank:
Rift Apart (PPSA01474) stops this way at LoadAddressU32@pc=0x9a30: one
high-word arm reads a second buffer, and on that edge the low word is a
lane mask, the waterfall loop reusing the SGPR pair.

Walk the two words together. Where both are Phis of one block, each
low-word edge takes the high word of the same predecessor. An edge whose
low word is a constant or a lane mask is skipped with its high word. A
record low word still needs every high word it can meet to be a constant,
a lane mask or the same record column at offset + 4, so a second-buffer
high word paired with the record word stays refused.

agc_driver_pointer_phi_high_second_lane_table adds the lane-mask low word
to the second-buffer arm: it plans, each group samples the T# its record
selects, and that arm faults outside the snapshot.
2026-10-21 06:59:38 -07:00
Yunus Shaikh e9d4626904 Merge feat/shader-nested-sampler-tables into fix/shader-pointer-key-lane-masks 2026-10-21 03:09:59 -07:00
Yunus Shaikh f877d5e5dc docs(shader): list lane-mask arms and a merged high word for pointer-keyed records
A pointer-keyed record pointer now also takes lane-mask ANDs, the
waterfall loop's lane bit and its OR and NOT forms, and a high word
merged from the record's next word. A high word read from a second buffer
stays refused.
2026-10-20 23:29:41 -07:00
Yunus Shaikh 2788b8f986 fix(shader): skip lane-mask arms built from a waterfall's lane bit in a pointer-keyed record pointer
A T# loaded through a record pointer was still refused with "GetImageResource
dword 0 is not a valid runtime value" when a Phi of the pointer's low word
merged the record read, a zero, and the waterfall's lane mask with the
handled lane's bit cleared, BitwiseAnd32(CompositeExtractU32x4(Ballot(...), 0),
BitwiseNot32(ShiftLeftLogical32(1, index))), as s_ff1, s_lshl and s_not with
s_and, or s_andn2, build it in the SGPR the pointer reuses. The walk took only
Ballot words and ANDs of them as lane masks, so it walked into the NOT and
refused.

A lane-mask operand is now a Ballot word or the loop's lane bit, a shift of 1
by an index from FindILsb32, FindUMsb32 or ReadFirstLane (through the AND,
add, subtract and select that s_ff1_i32_b64, s_bitset0 and the shift's own
mask put around it), or an AND, OR, NOT or Phi of only those and immediates.
An arm of the pointer that is entirely such an operand is skipped. An AND
with a record read in it still has the read matched against the column, and
anything else still refuses.

agc_driver_pointer_phi_lane_not_table builds that shape in a wave64
waterfall: the low word's Phis merge the record read at +0, a zero and the
lane mask without the handled lane's bit, cleared by s_not and s_and and by
s_andn2, and the high word is one read at +4. Each lane samples the T# of its
record, and every masked word faults outside the snapshot.
agc_driver_pointer_vsharp_select_table reads a record keyed by
ReadFirstLane(SelectU32(LogicalAnd, IAdd32, Phi)), a pointer from it, a V#
through the pointer and the T# through the V#; it passes without this change
and keeps that chain checked, including a record pointer moved to the other
V# without a recompile.

Shaders that planned before plan the same way, and a refusal is never cached,
so the disk-cache format does not change.
2026-10-21 06:15:51 +00:00
Yunus Shaikh 64b16cda88 fix(shader): take lane-mask ANDs and a high-word Phi in a pointer-keyed record pointer
A T# loaded through a record pointer was still refused with "GetImageResource
dword 0 is not a valid runtime value" when the pointer's low word passed
ANDs with lane masks, as a waterfall loop that copies EXEC into the
pointer's SGPR builds them, or when its high word was a Phi of the
record's high word read under several keys.

For a pointer-keyed column, the walk of the low word now takes an AND
with a lane-mask operand (a Ballot word, or an AND or Phi of only Ballot
words and immediates) and keeps walking its other operand, so its
record reads must still match the column and anything else still
refuses. The high word is walked the same way: its record reads must
be the record word at the low word's offset plus 4. A high word that is
one read still gives the column its table and record offset, as before.
Otherwise the table comes from a record read whose V# words are defined
before the descriptor load, and the record offset from the high word,
which the GPU does not read for a pointer-keyed column.

A high-word arm read from another buffer, such as one whose V# is
loaded through a pointer, stays refused. A shader that planned before
plans the same way, so the disk-cache format does not change.
2026-10-21 05:39:59 +00:00
1776 changed files with 91886 additions and 7756 deletions

No files matched your search

+4 -1
View File
@@ -909,7 +909,7 @@ jobs:
if: github.event_name == 'pull_request'
env:
BASE: ${{ needs.eligibility.outputs.sha }}
run: git diff --name-only "$BASE" HEAD > changed.txt
run: git diff --name-only -z "$BASE" HEAD -- > changed.txt
- name: Link changed host-only core/libs test executables
if: github.event_name == 'pull_request'
shell: cmd
@@ -972,6 +972,9 @@ jobs:
with:
path: test-graph.json
key: test-graph-${{ runner.os }}-${{ github.sha }}
- name: Report compiler cache statistics
if: ${{ !cancelled() }}
run: ccache --show-stats
- name: Report tests slower than 30 s
if: ${{ !cancelled() }}
shell: bash
+6
View File
@@ -10,6 +10,7 @@ on:
- core/relinker/**
- demo/web/**
- tools/build_web.py
- tools/input-mapper/**
- tools/package_release.py
- tools/nid_names.py
- tools/progress.py
@@ -74,6 +75,11 @@ jobs:
continue-on-error: true
run: python3 tools/progress_prs.py --output "$RUNNER_TEMP/open-pr-progress.json"
- run: python3 tools/progress.py --require-shader-source --open-pr-estimate "$RUNNER_TEMP/open-pr-progress.json" build-wasm/web
- name: Stage the input mapper
run: |
install -d build-wasm/web/input-mapper
install -m 0644 -t build-wasm/web/input-mapper \
tools/input-mapper/{index.html,styles.css,app.js,mapping.js,keys.js,capture.js,validation.js,i18n.js,dropdown.js}
- run: python3 tools/progress_history.py build-wasm/web
- uses: actions/upload-pages-artifact@v5
with:
+3
View File
@@ -113,3 +113,6 @@
[submodule "3rdparty/libpng"]
path = 3rdparty/libpng
url = https://github.com/pnggroup/libpng.git
[submodule "3rdparty/libyuv"]
path = 3rdparty/libyuv
url = https://chromium.googlesource.com/libyuv/libyuv
Vendored Submodule
+1
Submodule 3rdparty/libyuv added at 10592b60c0.
+1 -1
View File
@@ -5,7 +5,7 @@ AnyPS5 relinks PS5 executables into native Linux or Windows programs that run ag
- No comments in code, except `#endif`, namespace ends, and the licence and copyright notice of code adapted from an upstream source (for example ICU or WebRTC). That notice stays verbatim at the top of the file, with a link to the pinned upstream commit. Attribution facts and known gaps still go in `docs/dev/debt/<library>.md`.
- An export you cannot implement calls `NotImplemented_nid_no_patch(__func__)`; never return a made-up success.
- Implement the function for every input. Never special-case a value, ID or path seen in one title's trace; if the general behaviour is unknown, throw and record it in `docs/dev/debt/<library>.md`.
- New third-party code is a submodule at `3rdparty/<name>`: add its `.gitmodules` entry (`git submodule add <url> 3rdparty/<name>`) and build it from source with CMake. Never `find_package` or copy sources in.
- New third-party code is a submodule at `3rdparty/<name>`: add its `.gitmodules` entry (`git submodule add <url> 3rdparty/<name>`) and build it from source with CMake. Never `find_package` or copy sources in, except for the system packages `tools/check_conventions.py` allows: `Python3`, `Threads`, `Git` and `LLVM`.
- Known gaps go in `docs/dev/debt/<library>.md`, added, changed or removed through a fragment in `docs/dev/debt/changes/` ([format](docs/dev/TechnicalDebt.md#fragments)); notes, reports and logs go in the pull request. Add no other files.
- Commit subjects and PR titles are Conventional Commits.
- PR body: copy [the template](.github/pull_request_template.md), keep every line, tick every box, and fill `What`, `Tested`, `Depends on` (#N or none), `Fixes` (Fixes #N or none), `Unblocks` (title ID and discussion, or none), `GPUs tested` (AGC, shader recompiler, VideoOut; otherwise n/a) and `AI-assisted` (yes or no).
+20 -3
View File
@@ -405,6 +405,8 @@ if(BUILD_TESTING)
set_tests_properties(progress_history_helpers PROPERTIES TIMEOUT 20)
add_test(NAME progress_report COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress.py)
add_test(NAME progress_fast_analysis COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_fast_analysis.py)
add_test(NAME progress_open_pr_page COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_progress_open_pr_page.py)
add_test(NAME progress_prs COMMAND ${Python3_EXECUTABLE}
@@ -579,9 +581,22 @@ if(BUILD_TESTING)
add_test(NAME conventions_debt_labels COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_debt_labels.py)
set_tests_properties(conventions_debt_labels PROPERTIES TIMEOUT 20)
add_test(NAME conventions_helpers COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_conventions_helpers.py)
set_tests_properties(conventions_helpers PROPERTIES TIMEOUT 20)
add_test(NAME test_registration COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_test_registration.py)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_test_registration.py RegistrationTests)
set_tests_properties(test_registration PROPERTIES TIMEOUT 60)
set(test_registration_source "${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_test_registration.py")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${test_registration_source}")
file(STRINGS "${test_registration_source}" test_registration_classes REGEX "^class [A-Za-z0-9_]*Tests\\(")
foreach(test_class IN LISTS test_registration_classes)
string(REGEX REPLACE "^class ([A-Za-z0-9_]+).*" "\\1" test_class "${test_class}")
if(NOT test_class STREQUAL "RegistrationTests")
add_test(NAME test_registration_${test_class} COMMAND ${Python3_EXECUTABLE} "${test_registration_source}" ${test_class})
set_tests_properties(test_registration_${test_class} PROPERTIES TIMEOUT 60)
endif()
endforeach()
add_test(NAME unbuilt_exports COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_unbuilt_exports.py)
set_tests_properties(unbuilt_exports PROPERTIES TIMEOUT 20)
@@ -628,7 +643,7 @@ if(BUILD_TESTING)
add_test(NAME check_skips_ctest_policy COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_skips.py CtestSkipPolicyTests)
add_test(NAME check_skips_device_policy COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_skips.py DeviceSkipPolicyTests DeviceLimitationsTests EnvironmentLoaderRetentionTests)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_skips.py DeviceSkipPolicyTests DeviceLimitationsTests HighRefreshLimitationTests EnvironmentLoaderRetentionTests)
add_test(NAME check_skips_cli_output COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_check_skips.py SkipCliOutputTests)
set_tests_properties(check_skips check_skips_privilege check_skips_ctest_policy
@@ -789,7 +804,9 @@ if(BUILD_TESTING)
add_test(NAME pr_overlap_errors COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_errors.py)
add_test(NAME pr_overlap_branch_scan COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_branch_scan.py)
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_branch_scan.py BranchScanTests)
add_test(NAME pr_overlap_branch_scan_exports COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_branch_scan.py ExportSourceTests)
add_test(NAME pr_overlap_progress COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/tools/tests/test_pr_overlap_progress.py)
add_test(NAME pr_overlap_pages COMMAND ${Python3_EXECUTABLE}
+2 -1
View File
@@ -3,6 +3,7 @@
## Code
- Follow the [coding conventions](docs/dev/CONVENTIONS.md): naming, no comments except [technical debt](docs/dev/TechnicalDebt.md), Conventional Commits.
- Every `APS5_*` or `ANYPS5_*` name a pull request adds to the code has a row in [docs/dev/ENVIRONMENT.md](docs/dev/ENVIRONMENT.md). A row for a name the pull request stops reading is removed. `tools/check_conventions.py` reports a violation as `env-reference`.
- **Every exported PS5 function with `APS5_VABI` must have exactly one declaration in a header reachable through the library's `<library>.hpp`. Duplicate declarations in headers, `.cpp` files and tests are forbidden. This is checked by the Python test [`public_headers`](core/libs/tests/test_public_headers.py).**
- Every function either does exactly what it is supposed to or throws. Unimplemented exports call `NotImplemented_nid_no_patch(__func__)` (see [libSceAudioIn](core/libs/prx/libSceAudioIn/Export.cpp)).
- Pull requests that add or change shader instruction semantics say where they come from: measured on hardware (which GPU and what was checked, e.g. with the [hardware oracle](docs/dev/HW_ORACLE.md)) or the exact source (ISA section, LLVM, ACO or Mesa file). Reviewers check the semantics on hardware. Cases the source doesn't settle throw, and behaviour not verified on hardware is recorded in [technical debt](docs/dev/TechnicalDebt.md).
@@ -90,7 +91,7 @@ The [pull request template](.github/pull_request_template.md) is the checklist f
Text in the repository is dry, strict and concise. Record known gaps, unknown NIDs and signatures in [technical debt](docs/dev/TechnicalDebt.md) instead of new files. An entry states the gap first (what differs from the console, what is unverified, what throws) and describes the implemented behaviour only as far as the gap needs it. A pull request that closes a gap removes its entry, or cuts it to what is still open, instead of rewriting it to describe the corrected behaviour. An entry goes in `docs/dev/debt/<name>.md`, named after the first `core/` path it links (`<name>` for `core/libs/prx/<name>/...`, otherwise for `core/<name>/...`), under the same `###` sections as the index; entries that link neither stay in the index. A pull request whose `TechnicalDebt.md` change conflicts after the split rebases and runs `python3 tools/debt_split.py resolve` during the stopped rebase, which moves its added, edited and removed entries to their files; `python3 tools/debt_split.py split` moves entries left in the index.
A link to a Markdown file with a `#fragment` must name a heading of that file, as GitHub writes its anchor: the text of the heading in lowercase, with punctuation removed and spaces turned into hyphens. The check reports a fragment that matches no heading (`doc-anchor`) in the lines a pull request adds; it does not check fragments that were already there.
A link to a Markdown file with a `#fragment` must name a heading of that file, as GitHub writes its anchor: the text of the heading in lowercase, with punctuation removed and spaces turned into hyphens. The check reports a fragment that matches no heading (`doc-anchor`) in the lines a pull request adds; it does not check fragments that were already there. A debt entry (a `- ` line in a debt file or fragment) longer than 1000 characters is reported as a warning (`debt-length`): shorten it to the gap, what is unverified, and what throws.
## Maintainer scripts
+1 -1
View File
@@ -1,4 +1,4 @@
**English** | [Português (Brasil)](docs/user/README.pt-BR.md) | [Español](docs/user/README.es.md) | [Català](docs/user/README.ca.md) | [Italiano](docs/user/README.it.md) | [简体中文](docs/user/README.zh-CN.md) | [Русский](docs/user/README.ru.md) | [Bahasa Indonesia](docs/user/README.id.md) | [Polski](docs/user/README.pl.md) | [日本語](docs/user/README.ja.md) | [العربية](docs/user/README.ar.md) | [Ελληνικά](docs/user/README.el.md) | [Türkçe](docs/user/README.tr.md) | [עברית](docs/user/README.he.md)
**English** | [Português (Brasil)](docs/user/README.pt-BR.md) | [Español](docs/user/README.es.md) | [Català](docs/user/README.ca.md) | [Italiano](docs/user/README.it.md) | [简体中文](docs/user/README.zh-CN.md) | [Русский](docs/user/README.ru.md) | [Bahasa Indonesia](docs/user/README.id.md) | [Polski](docs/user/README.pl.md) | [日本語](docs/user/README.ja.md) | [العربية](docs/user/README.ar.md) | [Ελληνικά](docs/user/README.el.md) | [Türkçe](docs/user/README.tr.md) | [עברית](docs/user/README.he.md) | [Deutsch](docs/user/README.de.md)
# About
+4
View File
@@ -30,12 +30,14 @@ add_library(icu_common STATIC EXCLUDE_FROM_ALL
${ICU_SOURCE_DIR}/common/charstr.cpp
${ICU_SOURCE_DIR}/common/cmemory.cpp
${ICU_SOURCE_DIR}/common/cstring.cpp
${ICU_SOURCE_DIR}/common/dictionarydata.cpp
${ICU_SOURCE_DIR}/common/edits.cpp
${ICU_SOURCE_DIR}/common/emojiprops.cpp
${ICU_SOURCE_DIR}/common/filterednormalizer2.cpp
${ICU_SOURCE_DIR}/common/loadednormalizer2impl.cpp
${ICU_SOURCE_DIR}/common/errorcode.cpp
${ICU_SOURCE_DIR}/common/locavailable.cpp
${ICU_SOURCE_DIR}/common/locresdata.cpp
${ICU_SOURCE_DIR}/common/locmap.cpp
${ICU_SOURCE_DIR}/common/normalizer2.cpp
${ICU_SOURCE_DIR}/common/normalizer2impl.cpp
@@ -43,6 +45,7 @@ add_library(icu_common STATIC EXCLUDE_FROM_ALL
${ICU_SOURCE_DIR}/common/patternprops.cpp
${ICU_SOURCE_DIR}/common/propname.cpp
${ICU_SOURCE_DIR}/common/putil.cpp
${ICU_SOURCE_DIR}/common/rbbidata.cpp
${ICU_SOURCE_DIR}/common/ruleiter.cpp
${ICU_SOURCE_DIR}/common/stringpiece.cpp
${ICU_SOURCE_DIR}/common/uarrsort.cpp
@@ -105,6 +108,7 @@ add_library(icu_common STATIC EXCLUDE_FROM_ALL
${ICU_SOURCE_DIR}/common/ustrcase.cpp
${ICU_SOURCE_DIR}/common/ustring.cpp
${ICU_SOURCE_DIR}/common/ustrtrns.cpp
${ICU_SOURCE_DIR}/common/utext.cpp
${ICU_SOURCE_DIR}/common/utf_impl.cpp
${ICU_SOURCE_DIR}/common/util.cpp
${ICU_SOURCE_DIR}/common/utrace.cpp
@@ -25,6 +25,15 @@ struct Header {
bool app0BeforeFrame = false;
};
struct PlanarImage {
std::uint32_t width;
std::uint32_t height;
std::uint32_t components;
std::uint32_t planeWidths[3]{};
std::uint32_t planeHeights[3]{};
std::vector<std::uint8_t> planes[3];
};
enum class Sampling {
Yuv444,
Yuv422,
@@ -38,10 +47,14 @@ std::vector<std::uint8_t> Encode(std::span<const std::uint8_t> pixels, std::uint
std::vector<std::uint8_t> EncodePlanarYuv(std::span<const std::uint8_t> pixels, std::uint32_t width, std::uint32_t height,
int quality, Sampling sampling, std::uint32_t restartBlocks, std::uint32_t restartRows);
bool HasScanHeader(std::span<const std::uint8_t> jpeg);
std::optional<Header> ParseHeader(std::span<const std::uint8_t> jpeg);
std::optional<Image> Decode(std::span<const std::uint8_t> jpeg);
std::optional<PlanarImage> DecodePlanarYuv(std::span<const std::uint8_t> jpeg, std::uint32_t denominator);
std::uint32_t ScaledDimension(std::uint32_t dimension, std::uint32_t denominator);
std::optional<Image> DecodeScaled(std::span<const std::uint8_t> jpeg, std::uint32_t denominator);
+46
View File
@@ -143,6 +143,12 @@ std::optional<Image> DecodeScaled(std::span<const std::uint8_t> jpeg, std::uint3
return image;
}
bool HasScanHeader(std::span<const std::uint8_t> jpeg) {
Handle handle(TJINIT_DECOMPRESS);
if (tj3Set(handle, TJPARAM_STOPONWARNING, 1) < 0) throw std::runtime_error("Jpeg::HasScanHeader: decoder configuration failed");
return tj3DecompressHeader(handle, jpeg.data(), jpeg.size()) == 0 && tj3Get(handle, TJPARAM_JPEGWIDTH) > 0;
}
std::optional<Header> ParseHeader(std::span<const std::uint8_t> jpeg) {
if (jpeg.empty() || jpeg.size() > INT_MAX) return std::nullopt;
@@ -195,4 +201,44 @@ std::optional<Image> Decode(std::span<const std::uint8_t> jpeg) {
return image;
}
std::optional<PlanarImage> DecodePlanarYuv(std::span<const std::uint8_t> jpeg, std::uint32_t denominator) {
if (denominator != 1 && denominator != 2 && denominator != 4 && denominator != 8) {
throw std::invalid_argument("Jpeg::DecodePlanarYuv: the scale must be 1/1, 1/2, 1/4 or 1/8");
}
if (jpeg.empty() || jpeg.size() > INT_MAX) return std::nullopt;
Handle handle(TJINIT_DECOMPRESS);
if (tj3Set(handle, TJPARAM_STOPONWARNING, 1) < 0) throw std::runtime_error("Jpeg::DecodePlanarYuv: decoder configuration failed");
if (tj3DecompressHeader(handle, jpeg.data(), jpeg.size()) < 0) return std::nullopt;
const int colorspace = tj3Get(handle, TJPARAM_COLORSPACE);
if (colorspace != TJCS_YCbCr && colorspace != TJCS_GRAY) {
throw std::runtime_error("Jpeg::DecodePlanarYuv: planar decoding of an image that is not YCbCr or grayscale is not implemented");
}
const int subsampling = tj3Get(handle, TJPARAM_SUBSAMP);
if (subsampling == TJSAMP_UNKNOWN) throw std::runtime_error("Jpeg::DecodePlanarYuv: planar decoding of an unusual chroma subsampling is not implemented");
const int width = tj3Get(handle, TJPARAM_JPEGWIDTH);
const int height = tj3Get(handle, TJPARAM_JPEGHEIGHT);
if (width <= 0 || height <= 0) return std::nullopt;
if (tj3SetScalingFactor(handle, tjscalingfactor{1, static_cast<int>(denominator)}) < 0) {
throw std::runtime_error("Jpeg::DecodePlanarYuv: the decoder refused the scaling factor");
}
PlanarImage image{ScaledDimension(static_cast<std::uint32_t>(width), denominator), ScaledDimension(static_cast<std::uint32_t>(height), denominator),
subsampling == TJSAMP_GRAY ? 1u : 3u};
unsigned char* planes[3]{};
int strides[3]{};
for (std::uint32_t component = 0; component < image.components; ++component) {
const int planeWidth = tj3YUVPlaneWidth(static_cast<int>(component), static_cast<int>(image.width), subsampling);
const int planeHeight = tj3YUVPlaneHeight(static_cast<int>(component), static_cast<int>(image.height), subsampling);
if (planeWidth <= 0 || planeHeight <= 0) throw std::runtime_error("Jpeg::DecodePlanarYuv: the decoder reported no plane size");
image.planeWidths[component] = static_cast<std::uint32_t>(planeWidth);
image.planeHeights[component] = static_cast<std::uint32_t>(planeHeight);
image.planes[component].resize(static_cast<std::size_t>(planeWidth) * static_cast<std::size_t>(planeHeight));
planes[component] = image.planes[component].data();
strides[component] = planeWidth;
}
if (tj3DecompressToYUVPlanes8(handle, jpeg.data(), jpeg.size(), planes, strides) < 0) return std::nullopt;
return image;
}
} // namespace Decoder::Jpeg
+64
View File
@@ -176,5 +176,69 @@ int main() {
const std::vector<std::uint8_t> truncated(rgbJpeg.begin(), rgbJpeg.begin() + static_cast<std::ptrdiff_t>(rgbJpeg.size() / 2));
Require(!Decoder::Jpeg::DecodeScaled(truncated, 2).has_value());
struct PlanarCase { Decoder::Jpeg::Sampling sampling; std::uint32_t horizontal; std::uint32_t vertical; };
for (const PlanarCase planar : {PlanarCase{Decoder::Jpeg::Sampling::Yuv444, 1, 1}, PlanarCase{Decoder::Jpeg::Sampling::Yuv422, 2, 1},
PlanarCase{Decoder::Jpeg::Sampling::Yuv420, 2, 2}}) {
constexpr std::uint32_t planarWidth = 31;
constexpr std::uint32_t planarHeight = 23;
const std::uint32_t lumaWidth = (planarWidth + planar.horizontal - 1) / planar.horizontal * planar.horizontal;
const std::uint32_t lumaHeight = (planarHeight + planar.vertical - 1) / planar.vertical * planar.vertical;
const std::uint32_t chromaWidth = lumaWidth / planar.horizontal;
const std::uint32_t chromaHeight = lumaHeight / planar.vertical;
const auto lumaAt = [](std::uint32_t x, std::uint32_t y) { return static_cast<std::uint8_t>(40 + 4 * x + 3 * y); };
const auto chromaAt = [](std::uint32_t component, std::uint32_t x, std::uint32_t y) {
return static_cast<std::uint8_t>(component == 1 ? 100 + 2 * x + y : 160 - x - 2 * y);
};
std::vector<std::uint8_t> planes(lumaWidth * lumaHeight + 2 * chromaWidth * chromaHeight);
for (std::uint32_t y = 0; y < lumaHeight; ++y) {
for (std::uint32_t x = 0; x < lumaWidth; ++x) planes[y * lumaWidth + x] = lumaAt(std::min(x, planarWidth - 1), std::min(y, planarHeight - 1));
}
for (std::uint32_t component = 1; component < 3; ++component) {
std::uint8_t* plane = planes.data() + lumaWidth * lumaHeight + (component - 1) * chromaWidth * chromaHeight;
for (std::uint32_t y = 0; y < chromaHeight; ++y) {
for (std::uint32_t x = 0; x < chromaWidth; ++x) plane[y * chromaWidth + x] = chromaAt(component, x, y);
}
}
const auto encoded = Decoder::Jpeg::EncodePlanarYuv(planes, planarWidth, planarHeight, 100, planar.sampling, 0, 0);
const auto decoded = Decoder::Jpeg::DecodePlanarYuv(encoded, 1);
Require(decoded.has_value() && decoded->components == 3 && decoded->width == planarWidth && decoded->height == planarHeight);
Require(decoded->planeWidths[0] == lumaWidth && decoded->planeHeights[0] == lumaHeight);
for (std::uint32_t component = 0; component < 3; ++component) {
const std::uint32_t planeWidth = component == 0 ? lumaWidth : chromaWidth;
const std::uint32_t planeHeight = component == 0 ? lumaHeight : chromaHeight;
Require(decoded->planeWidths[component] == planeWidth && decoded->planeHeights[component] == planeHeight);
Require(decoded->planes[component].size() == static_cast<std::size_t>(planeWidth) * planeHeight);
const std::uint32_t visibleWidth = component == 0 ? planarWidth : (planarWidth + planar.horizontal - 1) / planar.horizontal;
const std::uint32_t visibleHeight = component == 0 ? planarHeight : (planarHeight + planar.vertical - 1) / planar.vertical;
for (std::uint32_t y = 0; y < visibleHeight; ++y) {
for (std::uint32_t x = 0; x < visibleWidth; ++x) {
const std::uint8_t expected = component == 0 ? lumaAt(x, y) : chromaAt(component, x, y);
Require(Difference(expected, decoded->planes[component][y * planeWidth + x]) <= 3);
}
}
}
for (const std::uint32_t denominator : {2u, 4u, 8u}) {
const auto scaled = Decoder::Jpeg::DecodePlanarYuv(encoded, denominator);
Require(scaled.has_value() && scaled->components == 3);
Require(scaled->width == Decoder::Jpeg::ScaledDimension(planarWidth, denominator) && scaled->height == Decoder::Jpeg::ScaledDimension(planarHeight, denominator));
Require(scaled->planeWidths[0] >= scaled->width && scaled->planeHeights[0] >= scaled->height);
Require(scaled->planeWidths[0] == scaled->planeWidths[1] * planar.horizontal && scaled->planeHeights[0] == scaled->planeHeights[1] * planar.vertical);
}
}
const auto grayPlanar = Decoder::Jpeg::DecodePlanarYuv(grayJpeg, 1);
Require(grayPlanar.has_value() && grayPlanar->components == 1 && grayPlanar->width == width && grayPlanar->height == height);
Require(grayPlanar->planeWidths[1] == 0 && grayPlanar->planes[1].empty() && grayPlanar->planes[2].empty());
Require(grayPlanar->planeWidths[0] == width && grayPlanar->planeHeights[0] == height);
totalError = 0;
for (std::size_t i = 0; i < gray.size(); ++i) totalError += Difference(gray[i], grayPlanar->planes[0][i]);
Require(totalError / static_cast<long>(gray.size()) < 4);
for (const std::uint32_t denominator : {0u, 3u, 16u}) {
Require(ThrowsInvalidArgument([&] { Decoder::Jpeg::DecodePlanarYuv(rgbJpeg, denominator); }));
}
Require(!Decoder::Jpeg::DecodePlanarYuv({}, 1).has_value());
Require(!Decoder::Jpeg::DecodePlanarYuv(garbage, 1).has_value());
Require(!Decoder::Jpeg::DecodePlanarYuv(truncated, 1).has_value());
return 0;
}
+56 -4
View File
@@ -240,6 +240,25 @@ target_compile_options(fvad PRIVATE $<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-fno
target_sources(libwebrtc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/prx/libwebrtc/Vad.cpp)
target_include_directories(libwebrtc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/3rdparty/libfvad/src)
target_link_libraries(libwebrtc PRIVATE fvad)
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/scale.cc)
message(FATAL_ERROR "libyuv: ${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/scale.cc is missing; initialize the submodule with git submodule update --init 3rdparty/libyuv")
endif()
add_library(webrtc_yuv STATIC EXCLUDE_FROM_ALL
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/cpu_id.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/planar_functions.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/row_any.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/row_common.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/row_gcc.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/scale.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/scale_any.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/scale_common.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/scale_gcc.cc
${CMAKE_SOURCE_DIR}/3rdparty/libyuv/source/scale_uv.cc)
target_include_directories(webrtc_yuv PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty/libyuv/include)
set_target_properties(webrtc_yuv PROPERTIES POSITION_INDEPENDENT_CODE ON CXX_VISIBILITY_PRESET hidden)
target_compile_options(webrtc_yuv PRIVATE -w)
target_link_libraries(libwebrtc PRIVATE webrtc_yuv)
if(MINGW OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(libwebrtc PRIVATE LINKER:--exclude-libs,ALL)
endif()
@@ -488,6 +507,8 @@ if(BUILD_TESTING)
set_tests_properties(guest_kernel_app_category PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
endif()
add_test_executable(guest_kernel_sys_constant_unknowns_tests tests/GuestKernelSysConstantUnknowns.cpp)
target_include_directories(guest_kernel_sys_constant_unknowns_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_constant_unknowns_tests PRIVATE libkernel_sys libkernel libc)
@@ -498,6 +519,17 @@ if(BUILD_TESTING)
set_tests_properties(guest_kernel_sys_constant_unknowns PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_process_property_tests tests/GuestKernelProcessProperty.cpp)
target_include_directories(guest_kernel_sys_process_property_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_process_property_tests PRIVATE libkernel_sys libkernel libc)
configure_windows_unwind(guest_kernel_sys_process_property_tests)
add_test(NAME guest_kernel_sys_process_property COMMAND guest_kernel_sys_process_property_tests)
set_tests_properties(guest_kernel_sys_process_property PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_kernel_sys_process_property PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel_sys>")
endif()
add_test_executable(guest_kernel_sys_named_object_tests tests/GuestKernelSysNamedObject.cpp)
target_include_directories(guest_kernel_sys_named_object_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_kernel_sys_named_object_tests PRIVATE libkernel_sys libkernel libc)
@@ -516,6 +548,13 @@ if(BUILD_TESTING)
endif()
add_test(NAME nid_buffer_validation COMMAND nid_buffer_validation_tests)
set_tests_properties(nid_buffer_validation PROPERTIES TIMEOUT 10)
add_test_executable(nid_compute_tests nid/tests/NidComputeTests.cpp
nid/src/NidCompute.cpp nid/src/Sha1.cpp)
target_include_directories(nid_compute_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/nid/include)
target_compile_features(nid_compute_tests PRIVATE cxx_std_20)
configure_host_test_executable(nid_compute_tests)
add_test(NAME nid_compute COMMAND nid_compute_tests)
set_tests_properties(nid_compute PROPERTIES TIMEOUT 10)
add_test_executable(guest_dinkumware_fetch_tests NO_RUNTIME_DLL_STAGING
${CMAKE_CURRENT_SOURCE_DIR}/tests/GuestDinkumwareFetch.cpp
@@ -1094,6 +1133,15 @@ if(BUILD_TESTING)
set_tests_properties(guest_abstract_storage_trivial_returns PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAbstractStorage>")
endif()
add_test_executable(guest_abstract_youtube_trivial_returns_tests tests/GuestAbstractYoutubeTrivialReturns.cpp)
target_include_directories(guest_abstract_youtube_trivial_returns_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_abstract_youtube_trivial_returns_tests PRIVATE libSceAbstractYoutube libc)
configure_windows_unwind(guest_abstract_youtube_trivial_returns_tests)
add_test(NAME guest_abstract_youtube_trivial_returns COMMAND guest_abstract_youtube_trivial_returns_tests)
if(WIN32)
set_tests_properties(guest_abstract_youtube_trivial_returns PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceAbstractYoutube>")
endif()
add_test_executable(guest_gnm_neo_context_state_internal_tests tests/GuestGnmNeoContextStateInternal.cpp)
target_include_directories(guest_gnm_neo_context_state_internal_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_gnm_neo_context_state_internal_tests PRIVATE libSceGnmDriverForNeoMode libc)
@@ -1168,7 +1216,7 @@ if(BUILD_TESTING)
target_include_directories(guest_np_common_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_np_common_tests PRIVATE libSceNpCommon libkernel libc)
configure_windows_unwind(guest_np_common_tests)
foreach(testCase IN ITEMS ids sync clock wake)
foreach(testCase IN ITEMS ids sync clock wake utf8 alloc jws xml)
add_test(NAME guest_np_common_${testCase} COMMAND guest_np_common_tests ${testCase})
set_tests_properties(guest_np_common_${testCase} PROPERTIES TIMEOUT 20)
if(WIN32)
@@ -1934,10 +1982,14 @@ if(BUILD_TESTING)
target_include_directories(guest_hub_app_util_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_hub_app_util_tests PRIVATE libSceHubAppUtil libc)
configure_windows_unwind(guest_hub_app_util_tests)
add_test(NAME guest_hub_app_util COMMAND guest_hub_app_util_tests)
set_tests_properties(guest_hub_app_util PROPERTIES TIMEOUT 20)
add_test(NAME guest_hub_app_util COMMAND guest_hub_app_util_tests live)
set_tests_properties(guest_hub_app_util PROPERTIES TIMEOUT 20 PASS_REGULAR_EXPRESSION "\\[PPRBUG-22821\\] sceHubAppUtilDeeplinkToLiveDetailView\\(\\) is not available\\.")
add_test(NAME guest_hub_app_util_ps_subscriptions COMMAND guest_hub_app_util_tests subscriptions)
set_tests_properties(guest_hub_app_util_ps_subscriptions PROPERTIES TIMEOUT 20 PASS_REGULAR_EXPRESSION "\\[PPRBUG-22821\\] sceHubAppUtilDeeplinkToPSSubscriptions\\(\\) is not available\\.")
add_test(NAME guest_hub_app_util_installation_status COMMAND guest_hub_app_util_tests status)
set_tests_properties(guest_hub_app_util_installation_status PROPERTIES TIMEOUT 20 PASS_REGULAR_EXPRESSION "\\[PPRBUG-22821\\] sceHubAppUtilGetInstallationStatus\\(\\) is not available\\.")
if(WIN32)
set_tests_properties(guest_hub_app_util PROPERTIES ENVIRONMENT_MODIFICATION
set_tests_properties(guest_hub_app_util guest_hub_app_util_ps_subscriptions guest_hub_app_util_installation_status PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceHubAppUtil>")
endif()
endif()
+8 -1
View File
@@ -164,6 +164,9 @@ void FixupRelocationSymbolIndices(
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type != kShtRela) continue;
if (shdr.sh_link != dynSymSectionIndex) continue;
if (shdr.sh_entsize != sizeof(Elf64_Rela) || shdr.sh_size % sizeof(Elf64_Rela))
throw std::runtime_error("invalid ELF relocation section layout");
RequireElfRange(elf, shdr.sh_offset, shdr.sh_size, "relocation");
const std::size_t relaOffset = static_cast<std::size_t>(shdr.sh_offset);
const std::size_t relaCount = static_cast<std::size_t>(shdr.sh_size) / sizeof(Elf64_Rela);
@@ -395,7 +398,11 @@ void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string&
for (std::uint16_t i = 0u; i < ehdr.e_shnum; ++i) {
const std::size_t shOffset = static_cast<std::size_t>(ehdr.e_shoff) + i * sizeof(Elf64_Shdr);
const auto shdr = Read<Elf64_Shdr>(elf, shOffset);
if (shdr.sh_type == kShtDynamic) hasDynamic = true;
if (shdr.sh_type == kShtDynamic) {
if (shdr.sh_entsize != sizeof(Elf64_Dyn) || shdr.sh_size % sizeof(Elf64_Dyn))
throw std::runtime_error("invalid ELF dynamic section layout");
hasDynamic = true;
}
if (shdr.sh_type == kShtDynsym) {
if (shdr.sh_entsize != sizeof(Elf64_Sym) || shdr.sh_size % sizeof(Elf64_Sym) || shdr.sh_link >= ehdr.e_shnum)
throw std::runtime_error("invalid ELF dynsym layout");
+25 -7
View File
@@ -143,16 +143,21 @@ void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& l
const auto exportDir = Read<PeDataDirectory>(pe, dataDirectoryOffset);
if (exportDir.VirtualAddress == 0u) throw std::runtime_error("no export directory");
const std::size_t exportDirOffset = RvaToOffset(pe, exportDir.VirtualAddress, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const std::size_t exportDirOffset = RvaRangeToOffset(pe, exportDir.VirtualAddress, sizeof(PeExportDirectory), peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const auto exportTable = Read<PeExportDirectory>(pe, exportDirOffset);
if (exportTable.NumberOfNames == 0u) throw std::runtime_error("no exported names");
const std::size_t namesArrayOffset = RvaToOffset(pe, exportTable.AddressOfNames, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const std::size_t ordinalsArrayOffset = RvaToOffset(pe, exportTable.AddressOfNameOrdinals, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
if (std::uint64_t{namesArrayOffset} + std::uint64_t{exportTable.NumberOfNames} * 4u > pe.size() ||
std::uint64_t{ordinalsArrayOffset} + std::uint64_t{exportTable.NumberOfNames} * 2u > pe.size())
const auto nameRvaTableSize = std::size_t{exportTable.NumberOfNames} * sizeof(std::uint32_t);
const auto ordinalTableSize = std::size_t{exportTable.NumberOfNames} * sizeof(std::uint16_t);
std::size_t namesArrayOffset;
std::size_t ordinalsArrayOffset;
try {
namesArrayOffset = RvaRangeToOffset(pe, exportTable.AddressOfNames, nameRvaTableSize, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
ordinalsArrayOffset = RvaRangeToOffset(pe, exportTable.AddressOfNameOrdinals, ordinalTableSize, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
} catch (const std::runtime_error&) {
throw std::runtime_error("export name tables out of file bounds");
}
std::vector<std::uint32_t> nameRvas(exportTable.NumberOfNames);
std::vector<std::string> names(exportTable.NumberOfNames);
@@ -191,7 +196,8 @@ void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& l
};
std::vector<Forwarder> forwarders;
std::vector<std::uint32_t> directRvas;
const auto functionsArrayOffset = RvaToOffset(pe, exportTable.AddressOfFunctions, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const auto functionTableSize = std::size_t{exportTable.NumberOfFunctions} * sizeof(std::uint32_t);
const auto functionsArrayOffset = RvaRangeToOffset(pe, exportTable.AddressOfFunctions, functionTableSize, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
for (std::uint32_t index = 0u; index < exportTable.NumberOfFunctions; ++index) {
const auto entryOffset = functionsArrayOffset + index * sizeof(std::uint32_t);
const auto rva = Read<std::uint32_t>(pe, entryOffset);
@@ -329,12 +335,15 @@ void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& l
while (importDescOffset <= importDescEnd && sizeof(PeImportDescriptor) <= importDescEnd - importDescOffset) {
const auto desc = Read<PeImportDescriptor>(pe, importDescOffset);
if (desc.OriginalFirstThunk == 0u && desc.FirstThunk == 0u) {
if (desc.TimeDateStamp != 0u || desc.ForwarderChain != 0u || desc.Name != 0u)
throw std::runtime_error("nonzero fields in null import descriptor");
foundNullImportDescriptor = true;
break;
}
const std::uint32_t thunkRva = desc.OriginalFirstThunk != 0u ? desc.OriginalFirstThunk : desc.FirstThunk;
std::size_t thunkOffset = RvaToOffset(pe, thunkRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const auto thunkStartOffset = thunkOffset;
const auto thunkSectionOffset = FindSectionOffsetByRva(pe, thunkRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
const auto thunkSection = Internal::Read<PeSectionHeader>(pe, thunkSectionOffset);
const auto thunkRawEnd = std::uint64_t{thunkSection.PointerToRawData} + thunkSection.SizeOfRawData;
@@ -354,6 +363,16 @@ void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& l
if (thunk == 0u)
break;
const auto addressRvaValue = std::uint64_t{desc.FirstThunk} + (thunkOffset - thunkStartOffset);
if (addressRvaValue > std::numeric_limits<std::uint32_t>::max())
throw std::runtime_error("import address table entry out of bounds");
std::size_t addressOffset;
try {
addressOffset = RvaRangeToOffset(pe, static_cast<std::uint32_t>(addressRvaValue), thunkEntrySize, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
} catch (const std::runtime_error&) {
throw std::runtime_error("import address table entry out of bounds");
}
if (!(thunk & ordinalFlag)) {
const auto hintNameRva = static_cast<std::uint32_t>(thunk & 0x7fffffffffffffffu);
const std::size_t hintNameOffset = RvaToOffset(pe, hintNameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
@@ -362,7 +381,6 @@ void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& l
const std::string funcName = ReadRvaCStr(pe, hintNameRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader, 2u);
if (!funcName.empty()) {
const auto addressOffset = RvaToOffset(pe, desc.FirstThunk, peHeaderOffset, numberOfSections, sizeOfOptionalHeader) + thunkOffset - RvaToOffset(pe, thunkRva, peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
imports.push_back({hintNameOffset + 2u, thunkOffset, addressOffset, funcName});
importNames.push_back(funcName);
}
+92
View File
@@ -0,0 +1,92 @@
#include <nid/NidCompute.hpp>
#include <nid/Sha1.hpp>
#include <array>
#include <cstdint>
#include <iostream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>
namespace {
constexpr std::string_view kAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
void Require(bool condition) {
if (!condition) throw std::runtime_error("NID compute tests failed");
}
std::vector<std::uint8_t> Bytes(const std::string& text) {
return std::vector<std::uint8_t>(text.begin(), text.end());
}
std::string Hex(const std::array<std::uint8_t, 20>& digest) {
constexpr char kDigits[] = "0123456789abcdef";
std::string result;
result.reserve(digest.size() * 2u);
for (const std::uint8_t byte : digest) {
result.push_back(kDigits[byte >> 4u]);
result.push_back(kDigits[byte & 0x0fu]);
}
return result;
}
void RequireSha1(const std::string& text, const std::string& expected) {
Require(Hex(Nid::Sha1(Bytes(text))) == expected);
}
void RequireNid(const std::string& name, const std::string& expected) {
const std::string nid = Nid::ComputeNid(name, "libkernel");
Require(nid == expected);
Require(nid.size() == 11u);
for (const char character : nid)
Require(kAlphabet.find(character) != std::string_view::npos);
}
template<typename TAction>
void RequireRejected(TAction action) {
try { action(); }
catch (const std::invalid_argument&) { return; }
throw std::runtime_error("Invalid symbol name was accepted");
}
}
int main() {
try {
RequireSha1("", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
RequireSha1("abc", "a9993e364706816aba3e25717850c26c9cd0d89d");
RequireSha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"84983e441c3bd26ebaae4aa1f95129e5e54670f1");
RequireSha1("The quick brown fox jumps over the lazy dog",
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12");
struct NidCase {
std::string name;
std::string expected;
};
const NidCase cases[] = {
{"sceKernelGetProcessTimeWide", "IXMJh8CeS7Q"},
{"sceKernelGetSystemTimeWide", "rD34HcfvxVY"},
{"sceNetRecv", "9wO9XrMsNhc"},
{"sceKernelAllocateDirectMemory", "rTXw65xmLIA"},
{"sceSysmoduleLoadModule", "g8cM39EUZ6o"},
{"sceUserServiceGetLoginUserIdList", "fPhymKNvK-A"},
{"scePadReadState", "YndgXqQVV7c"},
{"!", "Ge-sIz2M8MQ"},
{"sceNet_Recv@1?*+/-", "i+c7BYx+xtI"},
{std::string(200, 'a'), "f0ag4GA-q9A"},
};
for (const NidCase& testCase : cases)
RequireNid(testCase.name, testCase.expected);
RequireRejected([] { Nid::ComputeNid("", "libkernel"); });
Require(Nid::ComputeNid("sceNetRecv", "") == Nid::ComputeNid("sceNetRecv", "libSceNet"));
std::cout << "NID compute tests passed\n";
return 0;
} catch (const std::exception& error) {
std::cerr << error.what() << '\n';
return 1;
}
}
+31
View File
@@ -31,6 +31,24 @@ class ElfLayoutTests(unittest.TestCase):
struct.pack_into("<" + kind, image, offset, value)
self.reject(image)
def test_dynamic_section_layout_is_checked(self):
for size, entry_size in ((16, 0), (16, 8), (16, 24), (17, 16)):
with self.subTest(size=size, entry_size=entry_size):
image = build_image(symbols(False), False)
struct.pack_into("<H", image, 0x3c, 5)
struct.pack_into("<IIQQQQIIQQ", image, SHOFF + 4 * 64,
0, 6, 2, 0, 0x680, size, 2, 0, 8, entry_size)
self.reject(image)
def test_valid_dynamic_section_layout_still_patches(self):
image = build_image(symbols(False), False)
struct.pack_into("<H", image, 0x3c, 5)
struct.pack_into("<IIQQQQIIQQ", image, SHOFF + 4 * 64,
0, 6, 2, 0, 0x680, 16, 2, 0, 8, 16)
result, after = patch(PATCHER, bytes(image), "dynamic-layout.so")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertNotEqual(after, image)
def reject(self, image):
result, after = patch(PATCHER, bytes(image), "layout.so")
self.assertEqual(result.returncode, 2, (result.returncode, result.stderr))
@@ -43,6 +61,19 @@ class ElfLayoutTests(unittest.TestCase):
self.assertEqual(result.returncode, 0, result.stderr)
self.assertNotEqual(after, image)
def test_relocation_layout_linked_to_dynsym_is_checked(self):
for size, entry_size in ((25, 24), (24, 0), (24, 8), (24, 16)):
with self.subTest(size=size, entry_size=entry_size):
image = build_image(symbols(False), False)
rela_offset = 0x600
struct.pack_into("<QQq", image, rela_offset, 0x1234, (3 << 32) | 1, 0)
if size > 24:
image[rela_offset + 24] = 0x7f
struct.pack_into("<H", image, 0x3c, 5)
struct.pack_into("<IIQQQQIIQQ", image, SHOFF + 4 * 64,
0, 4, 2, 0, rela_offset, size, 1, 0, 8, entry_size)
self.reject(image)
if __name__ == "__main__":
unittest.main()
+44
View File
@@ -147,6 +147,23 @@ class ForwardingExportTests(unittest.TestCase):
result = subprocess.run([str(PATCHER), "libforwarder", str(path)], capture_output=True, text=True)
return result, path.read_bytes()
def test_export_tables_cannot_cross_section_raw_data(self):
cases = ((28, 0x21fe, "<I", 0x2000, "rva range exceeds section file data"),
(32, 0x21fe, "<I", 0x1032, "export name tables out of file bounds"),
(36, 0x21ff, "<H", 0, "export name tables out of file bounds"))
for field, rva, fmt, value, message in cases:
with self.subTest(field=field):
image = reference()
struct.pack_into("<II", image, 0x58 + 32, 4096, 512)
image.extend(bytes(64))
struct.pack_into("<I", image, 512 + field, rva)
struct.pack_into(fmt, image, 768 + rva - 0x2000, value)
original = bytes(image)
result, after = self.patch(image)
self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
self.assertIn(message, result.stderr)
self.assertEqual(after, original)
def test_forwarder_targets_and_ordinals_survive_name_repacking(self):
names = ["a", "b", "retained_nid_no_patch"]
for bits in (32, 64):
@@ -397,6 +414,20 @@ class ExecutableImportTests(unittest.TestCase):
self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
self.assertIn("import descriptor table is not terminated within import directory", result.stderr)
self.assertEqual(path.read_bytes(), image)
def test_pe_import_descriptor_terminator_is_all_zero(self):
for field, value in ((536, 1), (540, 1), (544, 0x1028)):
with self.subTest(field=field), tempfile.TemporaryDirectory() as directory:
image = bytearray(self.pe())
struct.pack_into("<I", image, field, value)
original = bytes(image)
path = Path(directory) / "program"
path.write_bytes(original)
result = subprocess.run([str(PATCHER), "--exec", str(path)], capture_output=True, text=True, timeout=20)
self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
self.assertIn("nonzero fields in null import descriptor", result.stderr)
self.assertEqual(path.read_bytes(), original)
def test_exec_rejects_thunk_crossing_raw_tail_without_writing(self):
image = bytearray(self.pe())
section = 0x58 + 240
@@ -412,6 +443,19 @@ class ExecutableImportTests(unittest.TestCase):
self.assertIn("thunk entry out of bounds", result.stderr)
self.assertEqual(path.read_bytes(), original)
def test_exec_rejects_iat_crossing_raw_tail_without_writing(self):
self.names = ["sceA", "sceNetRecv"]
image = bytearray(self.pe())
struct.pack_into("<I", image, 512 + 16, 0x15f8)
original = bytes(image)
with tempfile.TemporaryDirectory() as directory:
path = Path(directory) / "program"
path.write_bytes(original)
result = subprocess.run([str(PATCHER), "--exec", str(path)], capture_output=True, text=True, timeout=20)
self.assertEqual(result.returncode, 2, result.stdout + result.stderr)
self.assertIn("import address table entry out of bounds", result.stderr)
self.assertEqual(path.read_bytes(), original)
def test_exec_accepts_macho_without_exports(self):
from test_macho_nids import LC_DYLD_EXPORTS_TRIE, command_fields
image = self.macho()
+141 -2
View File
@@ -70,11 +70,11 @@ int APS5_VABI _ZN15AbstractStorage13YoutubeFolder13RemoveContentERKSbIcSt11char_
}
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder4OpenENS_8ItemTypeE() {
NotImplemented_nid_no_patch(__func__);
return static_cast<int>(0x809E0005u);
}
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder5CloseEv() {
NotImplemented_nid_no_patch(__func__);
return static_cast<int>(0x809E0005u);
}
}
@@ -322,3 +322,142 @@ int APS5_VABI _ZN15AbstractStorage14YoutubeContentC1ERKSbIcSt11char_traitsIcENS_
}
}
extern "C" {
int APS5_VABI libSceAbstractYoutubeUnknown_26_plus_qh3cw_minus_Rk_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("26+qh3cw-Rk", libSceAbstractYoutubeUnknown_26_plus_qh3cw_minus_Rk_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_2l4I9SCoQGo_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("2l4I9SCoQGo", libSceAbstractYoutubeUnknown_2l4I9SCoQGo_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_2spIcbz9a4c_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("2spIcbz9a4c", libSceAbstractYoutubeUnknown_2spIcbz9a4c_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_6A3QZpbCzqI_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("6A3QZpbCzqI", libSceAbstractYoutubeUnknown_6A3QZpbCzqI_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_Bo7s49MExf4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Bo7s49MExf4", libSceAbstractYoutubeUnknown_Bo7s49MExf4_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_C8lFlQympVw_nid_no_patch() {
return 0;
}
APS5_EXPORT("C8lFlQympVw", libSceAbstractYoutubeUnknown_C8lFlQympVw_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_Cz_minus_k0_plus_3Ko_minus_Y_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Cz-k0+3Ko-Y", libSceAbstractYoutubeUnknown_Cz_minus_k0_plus_3Ko_minus_Y_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_Ds9ID4F7dNc_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Ds9ID4F7dNc", libSceAbstractYoutubeUnknown_Ds9ID4F7dNc_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_FkpEJ7DfAtE_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("FkpEJ7DfAtE", libSceAbstractYoutubeUnknown_FkpEJ7DfAtE_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_GGzJcpDXRz4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("GGzJcpDXRz4", libSceAbstractYoutubeUnknown_GGzJcpDXRz4_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_HxZv0UgY_plus_7E_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("HxZv0UgY+7E", libSceAbstractYoutubeUnknown_HxZv0UgY_plus_7E_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_Ix3dt_minus_HaP9s_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("Ix3dt-HaP9s", libSceAbstractYoutubeUnknown_Ix3dt_minus_HaP9s_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_NBDWs6iIqNE_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("NBDWs6iIqNE", libSceAbstractYoutubeUnknown_NBDWs6iIqNE_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_Pk1mFgNtLEM_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("Pk1mFgNtLEM", libSceAbstractYoutubeUnknown_Pk1mFgNtLEM_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_RaO8sKI7L44_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("RaO8sKI7L44", libSceAbstractYoutubeUnknown_RaO8sKI7L44_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_UJyqV64_minus_qNQ_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("UJyqV64-qNQ", libSceAbstractYoutubeUnknown_UJyqV64_minus_qNQ_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_UqZVYj1m2m4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("UqZVYj1m2m4", libSceAbstractYoutubeUnknown_UqZVYj1m2m4_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_aVE9tVODTHw_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("aVE9tVODTHw", libSceAbstractYoutubeUnknown_aVE9tVODTHw_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_cobO1RmAxN4_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("cobO1RmAxN4", libSceAbstractYoutubeUnknown_cobO1RmAxN4_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_gsLtb_minus_uKeH8_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("gsLtb-uKeH8", libSceAbstractYoutubeUnknown_gsLtb_minus_uKeH8_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_hdVPPVnBbZU_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("hdVPPVnBbZU", libSceAbstractYoutubeUnknown_hdVPPVnBbZU_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_oWpmMJAVnI0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("oWpmMJAVnI0", libSceAbstractYoutubeUnknown_oWpmMJAVnI0_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_qrZ8UFLI1Us_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("qrZ8UFLI1Us", libSceAbstractYoutubeUnknown_qrZ8UFLI1Us_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_uk6wVMRO9c0_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("uk6wVMRO9c0", libSceAbstractYoutubeUnknown_uk6wVMRO9c0_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_uyA49_minus_ae2_plus_k_nid_no_patch() {
NotImplemented_nid_no_patch(__func__);
}
APS5_EXPORT("uyA49-ae2+k", libSceAbstractYoutubeUnknown_uyA49_minus_ae2_plus_k_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_zNGleAOPtNs_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("zNGleAOPtNs", libSceAbstractYoutubeUnknown_zNGleAOPtNs_nid_no_patch);
int APS5_VABI libSceAbstractYoutubeUnknown_zp94FyokDLI_nid_no_patch() {
return static_cast<int>(0x809E0005u);
}
APS5_EXPORT("zp94FyokDLI", libSceAbstractYoutubeUnknown_zp94FyokDLI_nid_no_patch);
}
@@ -61,4 +61,32 @@ int APS5_VABI _ZN15AbstractStorage13YoutubeFolder13RemoveContentERKSbIcSt11char_
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder4OpenENS_8ItemTypeE();
int APS5_VABI _ZN15AbstractStorage13YoutubeFolder5CloseEv();
int APS5_VABI libSceAbstractYoutubeUnknown_26_plus_qh3cw_minus_Rk_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_2l4I9SCoQGo_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_2spIcbz9a4c_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_6A3QZpbCzqI_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_Bo7s49MExf4_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_C8lFlQympVw_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_Cz_minus_k0_plus_3Ko_minus_Y_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_Ds9ID4F7dNc_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_FkpEJ7DfAtE_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_GGzJcpDXRz4_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_HxZv0UgY_plus_7E_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_Ix3dt_minus_HaP9s_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_NBDWs6iIqNE_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_Pk1mFgNtLEM_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_RaO8sKI7L44_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_UJyqV64_minus_qNQ_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_UqZVYj1m2m4_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_aVE9tVODTHw_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_cobO1RmAxN4_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_gsLtb_minus_uKeH8_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_hdVPPVnBbZU_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_oWpmMJAVnI0_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_qrZ8UFLI1Us_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_uk6wVMRO9c0_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_uyA49_minus_ae2_plus_k_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_zNGleAOPtNs_nid_no_patch();
int APS5_VABI libSceAbstractYoutubeUnknown_zp94FyokDLI_nid_no_patch();
}
+1 -1
View File
@@ -144,7 +144,7 @@ uint32_t* APS5_VABI sceAgcAcbSetMarkerSpan(CommandBuffer* buf, const char* str,
}
uint32_t* APS5_VABI sceAgcAcbPopMarker(CommandBuffer* buf) {
return Agc::Marker::Pop(buf, __func__);
return Agc::Marker::PopTag(buf, 0u, __func__);
}
uint32_t* APS5_VABI sceAgcAcbSetMarker(CommandBuffer* buf, const char* str, uint32_t color) {
+3 -4
View File
@@ -9,16 +9,15 @@
extern "C" {
std::uint32_t* APS5_VABI sceAgcCbBranch(CommandBuffer* buf, std::uint8_t mode, std::uint8_t compareFunction, const volatile std::uint64_t* compareAddress, std::uint64_t mask, std::uint64_t reference, std::uint8_t cachePolicy1, const volatile std::uint32_t* buffer1, std::uint32_t sizeInDwords1, std::uint8_t cachePolicy2, const volatile std::uint32_t* buffer2, std::uint32_t sizeInDwords2) {
Agc::Command::CheckBits(mode, 3, __func__);
Agc::Command::CheckBits(compareFunction, 7, __func__);
mode &= 3u;
compareFunction &= 7u;
Agc::Command::CheckBits(cachePolicy1, 3, __func__);
Agc::Command::CheckBits(cachePolicy2, 3, __func__);
Agc::Command::CheckBits(sizeInDwords1, 0xfffffu, __func__);
Agc::Command::CheckBits(sizeInDwords2, 0xfffffu, __func__);
const auto address = reinterpret_cast<std::uintptr_t>(compareAddress);
const auto address = reinterpret_cast<std::uintptr_t>(compareAddress) & (compareFunction != 0 ? ~std::uintptr_t{7} : ~std::uintptr_t{0});
const auto first = reinterpret_cast<std::uintptr_t>(buffer1);
const auto second = reinterpret_cast<std::uintptr_t>(buffer2);
if (compareFunction != 0) Agc::Command::CheckAddress(address, 8, __func__);
if (first != 0 || sizeInDwords1 != 0) Agc::Command::CheckAddress(first, 4, __func__);
if (second != 0 || sizeInDwords2 != 0) Agc::Command::CheckAddress(second, 4, __func__);
return Agc::Command::Emit(buf, 0x3fu, {mode | (static_cast<std::uint32_t>(compareFunction) << 8u), static_cast<std::uint32_t>(address), static_cast<std::uint32_t>(address >> 32u), static_cast<std::uint32_t>(mask), static_cast<std::uint32_t>(mask >> 32u), static_cast<std::uint32_t>(reference), static_cast<std::uint32_t>(reference >> 32u), static_cast<std::uint32_t>(first), static_cast<std::uint32_t>(first >> 32u), sizeInDwords1 | (static_cast<std::uint32_t>(cachePolicy1) << 28u), static_cast<std::uint32_t>(second), static_cast<std::uint32_t>(second >> 32u), sizeInDwords2 | (static_cast<std::uint32_t>(cachePolicy2) << 28u)}, __func__);
@@ -9,6 +9,7 @@ namespace Agc::Marker {
std::uint32_t* Push(CommandBuffer* buf, const char* str, const char* function);
std::uint32_t* PushSpan(CommandBuffer* buf, const char* str, std::uint32_t length, const char* function);
std::uint32_t* Pop(CommandBuffer* buf, const char* function);
std::uint32_t* PopTag(CommandBuffer* buf, std::uint32_t tagFlags, const char* function);
}
@@ -12,8 +12,11 @@
namespace {
constexpr std::uint32_t OpcodeNop = 0x10;
constexpr std::uint32_t OpcodeSetUconfigReg = 0x79;
constexpr std::uint32_t CustomPushMarker = 0x0b;
constexpr std::uint32_t CustomPopMarker = 0x0c;
constexpr std::uint32_t MarkerTagRegister = 0x342;
constexpr std::uint32_t PopMarkerTag = 0xc2000000;
}
@@ -48,6 +51,15 @@ std::uint32_t* Pop(CommandBuffer* buf, const char* function) {
return packet;
}
std::uint32_t* PopTag(CommandBuffer* buf, std::uint32_t tagFlags, const char* function) {
Agc::Command::Require(buf != nullptr, function, "null command buffer");
auto* packet = Agc::Command::Allocate(buf, 3, function);
packet[0] = Agc::Command::Header(OpcodeSetUconfigReg, 3, tagFlags);
packet[1] = MarkerTagRegister;
packet[2] = PopMarkerTag;
return packet;
}
}
extern "C" {
@@ -60,7 +72,7 @@ uint32_t* APS5_VABI sceAgcDcbSetMarker(CommandBuffer* buf, const char* str, uint
}
uint32_t* APS5_VABI sceAgcDcbPopMarker(CommandBuffer* buf) {
return Agc::Marker::Pop(buf, __func__);
return Agc::Marker::PopTag(buf, 4u, __func__);
}
uint32_t* APS5_VABI sceAgcDcbPushMarker(CommandBuffer* buf, const char* str, uint32_t color) {
+22 -18
View File
@@ -1,31 +1,35 @@
#include "prx/libSceAgc/Patch/include/CondExec.hpp"
#include "prx/libSceAgc/Command/include/Memory.hpp"
#include "prx/libSceAgc/Command/include/Packet.hpp"
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
namespace {
int SetCommandAddress(std::uint32_t* cmd, const volatile std::uint32_t* command, const char* function) {
Agc::Command::ValidatePacket(cmd, 0x22u, 5, function);
constexpr int InvalidPacket = static_cast<int>(0x8a6c000cu);
bool IsCondExecPacket(const std::uint32_t* cmd) {
return cmd != nullptr && ((cmd[0] >> 8u) & 0xffu) == 0x22u;
}
int SetCommandAddress(std::uint32_t* cmd, const volatile std::uint32_t* command) {
if (!IsCondExecPacket(cmd)) {
return InvalidPacket;
}
const auto address = reinterpret_cast<std::uintptr_t>(command);
Agc::Command::CheckAddress(address, 4, function);
cmd[1] = (cmd[1] & 3u) | (static_cast<std::uint32_t>(address) & ~3u);
cmd[2] = static_cast<std::uint32_t>(address >> 32u);
return 0;
}
int SetEnd(std::uint32_t* cmd, const volatile std::uint32_t* buffer, const char* function) {
Agc::Command::ValidatePacket(cmd, 0x22u, 5, function);
const auto end = reinterpret_cast<std::uintptr_t>(buffer);
const auto packetEnd = reinterpret_cast<std::uintptr_t>(cmd + 5);
Agc::Command::CheckAddress(end, 4, function);
const auto numDwords = (end - packetEnd) / sizeof(std::uint32_t);
Agc::Command::Require(numDwords <= 0x3fffu, function, "conditional execution range is too large");
cmd[4] = (cmd[4] & ~0x3fffu) | static_cast<std::uint32_t>(numDwords);
int SetEnd(std::uint32_t* cmd, const volatile std::uint32_t* buffer) {
if (!IsCondExecPacket(cmd)) {
return InvalidPacket;
}
const std::uint32_t byteDelta = static_cast<std::uint32_t>(
reinterpret_cast<std::uintptr_t>(buffer) - reinterpret_cast<std::uintptr_t>(cmd));
const std::uint32_t numDwords = ((byteDelta >> 2u) - 5u) & 0x3fffu;
cmd[4] = (cmd[4] & ~0x3fffu) | numDwords;
return 0;
}
@@ -34,19 +38,19 @@ int SetEnd(std::uint32_t* cmd, const volatile std::uint32_t* buffer, const char*
extern "C" {
int APS5_VABI sceAgcCondExecPatchSetCommandAddress(uint32_t* cmd, const volatile uint32_t* command) {
return SetCommandAddress(cmd, command, __func__);
return SetCommandAddress(cmd, command);
}
int APS5_VABI sceAgcCondExecPatchSetEnd(uint32_t* cmd, const volatile uint32_t* buffer) {
return SetEnd(cmd, buffer, __func__);
return SetEnd(cmd, buffer);
}
int APS5_VABI sceAgcAsyncCondExecPatchSetCommandAddress(std::uint32_t* cmd, const volatile std::uint32_t* command) {
return SetCommandAddress(cmd, command, __func__);
return SetCommandAddress(cmd, command);
}
int APS5_VABI sceAgcAsyncCondExecPatchSetEnd(std::uint32_t* cmd, const volatile std::uint32_t* buffer) {
return SetEnd(cmd, buffer, __func__);
return SetEnd(cmd, buffer);
}
}
@@ -1,8 +1,10 @@
#include "prx/libSceAgc/Shader/include/CreateShader.hpp"
#include <cerrno>
#include <cstdio>
#include <stdexcept>
#include <prx/libc/include/General.hpp>
#include <prx/libc/include/GuestArena.hpp>
#include "SceShaders.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver.hpp"
@@ -16,6 +18,18 @@ int APS5_VABI sceAgcCreateShader(Shader** dst, void* header, const volatile void
if (dst == nullptr) {
throw std::runtime_error(std::string(fn) + ": dst is null");
}
{
const int savedErrno = errno;
bool writable = false;
{
const GuestArena::HostWrite write(dst, sizeof(*dst));
writable = write.Open() && GuestWritable_nid_no_patch(dst, sizeof(*dst));
}
errno = savedErrno;
if (!writable) {
throw std::runtime_error(std::string(fn) + ": dst is not writable");
}
}
if (header == nullptr) {
throw std::runtime_error(std::string(fn) + ": header is null");
}
@@ -60,8 +74,13 @@ int APS5_VABI sceAgcCreateShader(Shader** dst, void* header, const volatile void
return result;
}
const int savedErrno = errno;
const bool copied = GuestCopyOut_nid_no_patch(dst, &h, sizeof(h));
errno = savedErrno;
if (!copied) {
throw std::runtime_error(std::string(fn) + ": failed to copy dst pointer");
}
AgcDriverRegisterShader_nid_postfix(h);
*dst = h;
return 0;
}
+17 -1
View File
@@ -61,12 +61,27 @@ void testUnusedFields() {
packet = sceAgcCbBranch(&buffer, 1, 0, nullptr, 0, 0, 0, nullptr, 0, 0, nullptr, 0);
check(packet[1] == 1u && packet[2] == 0u && packet[8] == 0u && packet[10] == 0u, "an empty always-taken branch was not written");
const auto cursor = buffer.cursor_up;
expectFailure([&] { sceAgcCbBranch(&buffer, 1, 3, compareAt(0x0000001234567894ull), 0, 0, 0, targetAt(0x2000u), 1, 0, nullptr, 0); });
expectFailure([&] { sceAgcCbBranch(&buffer, 1, 0, nullptr, 0, 0, 0, nullptr, 1, 0, nullptr, 0); });
expectFailure([&] { sceAgcCbBranch(&buffer, 2, 0, nullptr, 0, 0, 0, targetAt(0x2000u), 1, 0, nullptr, 1); });
check(buffer.cursor_up == cursor, "a rejected branch advanced the command buffer");
}
template <std::size_t Size>
void expectBranch(std::uint8_t mode, std::uint8_t compareFunction, std::uint64_t compareAddress, std::uint64_t mask, std::uint64_t reference, const std::array<std::uint32_t, Size>& head) {
std::array<std::uint32_t, 16> words{};
CommandBuffer buffer{words.data(), words.data() + words.size(), words.data(), words.data() + words.size(), nullptr, nullptr, 0};
const auto* packet = sceAgcCbBranch(&buffer, mode, compareFunction, compareAt(compareAddress), mask, reference, 0, nullptr, 0, 0, nullptr, 0);
check(packet == words.data() && std::equal(head.begin(), head.end(), packet), "console branch arguments were not encoded as the console does");
check(buffer.cursor_up == packet + 14, "console branch cursor advance mismatch");
}
void testConsoleArguments() {
expectBranch(0x11, 0x22, 0x33333333u, 0x44444444u, 0x55555555u, std::array{0xc00c3f00u, 0x201u, 0x33333330u, 0u, 0x44444444u, 0u, 0x55555555u, 0u});
expectBranch(1, 2, 3, 4, 5, std::array{0xc00c3f00u, 0x201u, 0u, 0u, 4u, 0u, 5u, 0u});
expectBranch(0x22, 0x44, 0, 0, 0, std::array{0xc00c3f00u, 0x402u, 0u, 0u, 0u, 0u, 0u, 0u});
expectBranch(1, 3, 0x0000001234567894ull, 0, 0, std::array{0xc00c3f00u, 0x301u, 0x34567890u, 0x12u});
}
void testCompareAddress() {
Storage storage;
auto expected = storage.words;
@@ -144,6 +159,7 @@ int main() {
try {
testWriter();
testUnusedFields();
testConsoleArguments();
testCompareAddress();
testTarget(sceAgcBranchPatchSetThenTarget, 8, 0x10000000u, "then target setter wrote the wrong words");
testTarget(sceAgcBranchPatchSetElseTarget, 11, 0x20000000u, "else target setter wrote the wrong words");
+7 -5
View File
@@ -312,14 +312,16 @@ void testMarkers() {
check(acbPush == acb.words.data() && acbPush[0] == Agc::Command::Header(0x10, 3, 0x0bu << 2u), "ACB push marker header mismatch");
check(std::strcmp(reinterpret_cast<const char*>(acbPush + 1), "frame") == 0, "ACB push marker text mismatch");
const auto* acbPop = sceAgcAcbPopMarker(&acb.buffer);
check(acbPop == acb.words.data() + 3 && acbPop[0] == Agc::Command::Header(0x10, 2, 0x0cu << 2u) && acbPop[1] == 0, "ACB pop marker mismatch");
sceAgcDcbPopMarker(&dcb.buffer);
check(acbPop == acb.words.data() + 3 && acbPop[0] == Agc::Command::Header(0x79, 3, 0) && acbPop[1] == 0x342u && acbPop[2] == 0xc2000000u, "ACB pop marker mismatch");
const auto* dcbPop = sceAgcDcbPopMarker(&dcb.buffer);
check(dcbPop == dcb.words.data() + 3 && dcbPop[0] == Agc::Command::Header(0x79, 3, 4) && dcbPop[1] == 0x342u && dcbPop[2] == 0xc2000000u, "DCB pop marker mismatch");
const auto* acbSet = sceAgcAcbSetMarker(&acb.buffer, nullptr, 0);
const auto* dcbSet = sceAgcDcbSetMarker(&dcb.buffer, nullptr, 0);
check(acbSet == acb.words.data() + 5 && dcbSet == dcb.words.data() + 5, "set marker did not return its push packet");
check(acbSet == acb.words.data() + 6 && dcbSet == dcb.words.data() + 6, "set marker did not return its push packet");
check(acbSet[0] == Agc::Command::Header(0x10, 2, 0x0bu << 2u) && acbSet[1] == 0 && acbSet[2] == Agc::Command::Header(0x10, 2, 0x0cu << 2u), "ACB set marker is not a push and pop pair");
check(dcbPush == dcb.words.data() && dcb.words == acb.words, "ACB and DCB markers differ");
check(acb.buffer.cursor_up == acb.words.data() + 9, "incorrect ACB marker cursor advance");
check(dcbPush == dcb.words.data() && std::equal(acb.words.begin(), acb.words.begin() + 3, dcb.words.begin()), "ACB and DCB push markers differ");
check(std::equal(acbSet, acbSet + 4, dcbSet), "ACB and DCB set markers differ");
check(acb.buffer.cursor_up == acb.words.data() + 10 && dcb.buffer.cursor_up == dcb.words.data() + 10, "incorrect marker cursor advance");
expectFailure([] { sceAgcAcbPushMarker(nullptr, "frame", 0); });
expectFailure([] { sceAgcAcbPopMarker(nullptr); });
expectFailure([] { sceAgcAcbSetMarker(nullptr, "frame", 0); });
+58 -22
View File
@@ -13,6 +13,7 @@
namespace {
constexpr std::uint32_t Sentinel = 0xabcdef01u;
constexpr int InvalidPacket = static_cast<int>(0x8a6c000cu);
using CondExecWriter = std::uint32_t* (APS5_VABI *)(CommandBuffer*, const volatile std::uint32_t*, std::uint32_t);
using PatchFunction = int (APS5_VABI *)(std::uint32_t*, const volatile std::uint32_t*);
@@ -27,16 +28,6 @@ void check(bool condition, const char* message) {
if (!condition) throw std::runtime_error(message);
}
template <typename TAction>
void expectFailure(TAction action) {
try {
action();
} catch (const std::runtime_error&) {
return;
}
throw std::runtime_error("expected invalid input to fail");
}
const volatile std::uint32_t* at(std::uintptr_t address) {
return reinterpret_cast<const volatile std::uint32_t*>(address);
}
@@ -59,29 +50,54 @@ std::uintptr_t endAfter(const std::uint32_t* packet, std::uintptr_t numDwords) {
}
template <typename TAction>
void expectUnchanged(const Variant& variant, TAction action) {
void expectInvalidPacket(const Variant& variant, TAction action) {
Storage storage(variant.write);
const auto before = storage.words;
expectFailure([&] { action(storage.packet); });
check(storage.words == before, "failed patch modified the packet");
const int status = action(storage.packet);
check(status == InvalidPacket, "expected invalid packet error code");
check(storage.words == before, "invalid packet patch modified storage");
}
void testSetEnd(const Variant& variant) {
const auto setEnd = variant.setEnd;
for (const std::uintptr_t numDwords : {0u, 1u, 7u, 0x3fffu}) {
Storage storage(variant.write);
storage.packet[4] |= 0xabcd0000u;
const auto before = storage.words;
check(setEnd(storage.packet, at(endAfter(storage.packet, numDwords))) == 0, "SetEnd failed");
check(storage.packet[4] == numDwords, "SetEnd wrote the wrong dword count");
check(storage.packet[4] == (0xabcd0000u | static_cast<std::uint32_t>(numDwords)), "SetEnd wrote the wrong dword count");
check(std::equal(before.begin(), before.begin() + 4, storage.words.begin()), "SetEnd modified other packet words");
check(std::equal(before.begin() + 5, before.end(), storage.words.begin() + 5), "SetEnd modified following words");
}
expectUnchanged(variant, [=](std::uint32_t* packet) { setEnd(packet, at(endAfter(packet, 0x4000u))); });
expectUnchanged(variant, [=](std::uint32_t* packet) { setEnd(packet, packet + 4); });
expectUnchanged(variant, [=](std::uint32_t* packet) { setEnd(packet, nullptr); });
expectUnchanged(variant, [=](std::uint32_t* packet) { setEnd(packet, at(endAfter(packet, 2) + 2)); });
expectUnchanged(variant, [=](std::uint32_t* packet) { setEnd(packet + 1, at(endAfter(packet, 2))); });
{
Storage storage(variant.write);
storage.packet[4] |= 0xabcd0000u;
check(setEnd(storage.packet, at(endAfter(storage.packet, 0x4000u))) == 0, "SetEnd wrap 0x4000 failed");
check(storage.packet[4] == 0xabcd0000u, "SetEnd did not mask count to 14 bits");
}
{
Storage storage(variant.write);
storage.packet[4] |= 0xabcd0000u;
check(setEnd(storage.packet, storage.packet + 4) == 0, "SetEnd packet+4 failed");
check(storage.packet[4] == 0xabcd3fffu, "SetEnd did not mask negative delta to 0x3fff");
}
{
Storage storage(variant.write);
storage.packet[4] |= 0xabcd0000u;
check(setEnd(storage.packet, at(endAfter(storage.packet, 2) + 2)) == 0, "SetEnd unaligned failed");
check(storage.packet[4] == 0xabcd0002u, "SetEnd did not shift unaligned byte delta");
}
expectInvalidPacket(variant, [=](std::uint32_t* packet) { return setEnd(nullptr, at(endAfter(packet, 2))); });
expectInvalidPacket(variant, [=](std::uint32_t* packet) { return setEnd(packet + 1, at(endAfter(packet, 2))); });
{
Storage storage(variant.write);
storage.packet[0] = (storage.packet[0] & ~0xff00u) | 0x2100u;
const auto before = storage.words;
check(setEnd(storage.packet, at(endAfter(storage.packet, 2))) == InvalidPacket, "SetEnd accepted wrong opcode");
check(storage.words == before, "SetEnd modified wrong-opcode packet");
}
}
void testSetCommandAddress(const Variant& variant) {
@@ -96,9 +112,29 @@ void testSetCommandAddress(const Variant& variant) {
check(std::equal(before.begin() + 5, before.end(), storage.words.begin() + 5), "SetCommandAddress modified following words");
}
expectUnchanged(variant, [=](std::uint32_t* packet) { setCommandAddress(packet, nullptr); });
expectUnchanged(variant, [=](std::uint32_t* packet) { setCommandAddress(packet, at(0x1002u)); });
expectUnchanged(variant, [=](std::uint32_t* packet) { setCommandAddress(packet + 1, at(0x1000u)); });
{
Storage storage(variant.write);
storage.packet[1] = 0x1234567bu;
storage.packet[2] = 0xdeadbeefu;
check(setCommandAddress(storage.packet, nullptr) == 0, "SetCommandAddress null address failed");
check(storage.packet[1] == 3u && storage.packet[2] == 0u, "SetCommandAddress did not clear null address");
}
{
Storage storage(variant.write);
storage.packet[1] |= 2u;
check(setCommandAddress(storage.packet, at(0x1002u)) == 0, "SetCommandAddress unaligned failed");
check(storage.packet[1] == 0x1002u && storage.packet[2] == 0u, "SetCommandAddress did not mask low two address bits");
}
expectInvalidPacket(variant, [=](std::uint32_t*) { return setCommandAddress(nullptr, at(0x1000u)); });
expectInvalidPacket(variant, [=](std::uint32_t* packet) { return setCommandAddress(packet + 1, at(0x1000u)); });
{
Storage storage(variant.write);
storage.packet[0] = (storage.packet[0] & ~0xff00u) | 0x2100u;
const auto before = storage.words;
check(setCommandAddress(storage.packet, at(0x1000u)) == InvalidPacket, "SetCommandAddress accepted wrong opcode");
check(storage.words == before, "SetCommandAddress modified wrong-opcode packet");
}
}
}
@@ -1,11 +1,20 @@
#include "prx/libSceAgc/Shader/include/CreateShader.hpp"
#include "prx/libSceAgc/Shader/include/ShaderConstants.hpp"
#include "prx/libc/include/GuestArena.hpp"
#include "prx/libc/include/GuestWriteWatch.hpp"
#include <array>
#include <cerrno>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <stdexcept>
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
namespace {
@@ -113,6 +122,108 @@ void testWithoutProgramAddress() {
check(binary.registers[0].offset == registers[0].offset && binary.registers[0].value == registers[0].value && binary.registers[1].value == registers[1].value && binary.registers[2].value == registers[2].value, "a fetch shader's registers changed");
}
void testInvalidDst() {
Binary binary;
fill(binary, ShaderRegs::ShaderBinaryType::Cs, ShaderRegs::COMPUTE_PGM_LO);
const auto originalSh = binary.shader.sh_registers;
const auto originalLo = binary.registers[0].value;
registered = nullptr;
registrations = 0;
errno = 71;
try {
sceAgcCreateShader(reinterpret_cast<Shader**>(std::uintptr_t{1}), &binary.shader, code.data());
check(false, "unmapped dst pointer accepted");
} catch (const std::runtime_error&) {}
check(errno == 71, "unmapped dst mutated errno");
check(registrations == 0 && binary.shader.code == nullptr && binary.shader.sh_registers == originalSh && binary.registers[0].value == originalLo,
"unmapped dst mutated shader header or registered shader");
if (GuestArena::GuestArenaAvailable_nid_postfix()) {
constexpr std::size_t kArenaBytes = 0x10000;
void* const page = GuestArena::GuestArenaAllocate_nid_postfix(kArenaBytes, kArenaBytes);
check(page != nullptr, "allocating write-watched page failed");
#ifdef _WIN32
const HANDLE section = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_EXECUTE_READWRITE, 0, kArenaBytes, nullptr);
check(section != nullptr, "creating write-watched section failed");
GuestArena::GuestArenaMap_nid_postfix(page, kArenaBytes, section, 0, PAGE_READWRITE);
CloseHandle(section);
const bool watchedWrites = GuestArena::GuestArenaWriteWatched_nid_postfix();
#else
GuestArena::GuestArenaCommit_nid_postfix(page, kArenaBytes, 0x04, kArenaBytes);
const bool watchedWrites = GuestWriteWatch::GuestWriteWatchAvailable_nid_postfix();
if (watchedWrites) {
GuestWriteWatch::GuestWriteWatchRegister_nid_postfix(page, kArenaBytes);
}
#endif
const auto collectDirty = [&]() -> bool {
if (!watchedWrites) {
return true;
}
#ifdef _WIN32
std::array<void*, 16> pages{};
std::size_t count = pages.size();
check(GuestArena::GuestArenaCollectWrites_nid_postfix(reinterpret_cast<std::uintptr_t>(page), kArenaBytes, pages.data(), &count, true),
"collecting write-watched writes failed");
return count != 0;
#else
bool dirty = false;
check(GuestWriteWatch::GuestWriteWatchCollect_nid_postfix(reinterpret_cast<std::uintptr_t>(page), kArenaBytes,
[](void* context, std::uintptr_t, std::uintptr_t) { *static_cast<bool*>(context) = true; }, &dirty),
"collecting write-watched writes failed");
return dirty;
#endif
};
const auto armWatch = [&](void* target) {
if (!watchedWrites) {
return;
}
static_cast<void>(collectDirty());
check(!collectDirty(), "write-watched page was still dirty");
#ifdef _WIN32
MEMORY_BASIC_INFORMATION mbi{};
check(VirtualQuery(target, &mbi, sizeof(mbi)) == sizeof(mbi) && mbi.Protect == PAGE_READONLY, "arming write-watched page failed");
#else
static_cast<void>(target);
#endif
};
auto* const watchedDst = static_cast<Shader**>(page);
*watchedDst = nullptr;
armWatch(watchedDst);
errno = 71;
check(sceAgcCreateShader(watchedDst, &binary.shader, code.data()) == 0, "write-watched dst pointer failed");
check(errno == 71, "write-watched dst mutated errno");
check(*watchedDst == &binary.shader && registered == &binary.shader && registrations == 1,
"write-watched dst pointer did not receive registered shader");
check(collectDirty(), "write-watched dst pointer did not mark page dirty");
Binary roBinary;
fill(roBinary, ShaderRegs::ShaderBinaryType::Cs, ShaderRegs::COMPUTE_PGM_LO);
const auto roOriginalSh = roBinary.shader.sh_registers;
const auto roOriginalLo = roBinary.registers[0].value;
*watchedDst = nullptr;
GuestArena::GuestArenaSetProtection_nid_postfix(reinterpret_cast<std::uintptr_t>(page), kArenaBytes, 0x02);
registered = nullptr;
registrations = 0;
errno = 71;
try {
sceAgcCreateShader(watchedDst, &roBinary.shader, code.data());
check(false, "read-only dst pointer accepted");
} catch (const std::runtime_error&) {}
check(errno == 71, "read-only dst mutated errno");
check(*watchedDst == nullptr && registrations == 0 && roBinary.shader.code == nullptr &&
roBinary.shader.sh_registers == roOriginalSh && roBinary.registers[0].value == roOriginalLo,
"read-only dst mutated header, destination, or registered shader");
GuestArena::GuestArenaSetProtection_nid_postfix(reinterpret_cast<std::uintptr_t>(page), kArenaBytes, 0x04);
#ifndef _WIN32
if (watchedWrites) {
GuestWriteWatch::GuestWriteWatchUnregister_nid_postfix(page, kArenaBytes);
}
#endif
GuestArena::GuestArenaReset_nid_postfix(page, kArenaBytes);
GuestArena::GuestArenaRelease_nid_postfix(page, kArenaBytes);
}
}
}
extern "C" void AgcDriverRegisterShader_nid_postfix(const Shader* shader) {
@@ -126,6 +237,7 @@ int main() {
testPixelWithUserData();
testCreatedAgain();
testWithoutProgramAddress();
testInvalidDst();
std::puts("AGC create shader tests passed");
return 0;
} catch (const std::exception& error) {
@@ -513,6 +513,21 @@ void testUnversionedSize() {
check(sceAgcGetFusedShaderSize(&size, &halves.front, &halves.back) == 0 && size.m_size == halves.back.num_sh_registers * sizeof(ShaderRegister), "unversioned query rejected hull halves");
}
void testUnversionedFusion() {
Halves halves;
SizeAlign size{};
check(sceAgcGetFusedShaderSize(&size, &halves.front, &halves.back) == 0, "unversioned fused size query failed");
std::vector<std::uint8_t> versionedScratch(size.m_size);
std::vector<std::uint8_t> unversionedScratch(size.m_size);
Shader versioned{};
check(sceAgcFuseShaderHalves_0200(&versioned, &halves.front, &halves.back, versionedScratch.data()) == 0, "fusion failed");
Shader unversioned{};
check(sceAgcFuseShaderHalves_nid_postfix(&unversioned, &halves.front, &halves.back, unversionedScratch.data()) == 0, "unversioned fusion failed");
check(unversioned.type == static_cast<std::uint8_t>(ShaderRegs::ShaderBinaryType::Gs) && unversioned.code == versioned.code && unversioned.shader_size == versioned.shader_size, "unversioned fusion did not return the fused program");
check(reinterpret_cast<std::uintptr_t>(unversioned.sh_registers) == reinterpret_cast<std::uintptr_t>(unversionedScratch.data()), "unversioned fused registers are not in the caller's memory");
check(std::memcmp(unversionedScratch.data(), versionedScratch.data(), unversionedScratch.size()) == 0, "unversioned fused registers differ from the versioned fusion");
}
}
int main() {
@@ -533,6 +548,7 @@ int main() {
}
testHullHalves();
testUnversionedSize();
testUnversionedFusion();
LibcRunShutdown_nid_postfix();
std::puts("AGC shader fusion tests passed");
return 0;
@@ -239,6 +239,19 @@ add_custom_command(
VERBATIM
)
set(agcStorePageGatherShaderSource ${CMAKE_CURRENT_SOURCE_DIR}/Graphics/shaders/StorePageGather.comp)
set(agcStorePageGatherShaderSpv ${agcTextureDetileGeneratedDir}/StorePageGather.spv)
set(agcStorePageGatherShaderHeader ${agcTextureDetileGeneratedDir}/StorePageGather_spv.h)
add_custom_command(
OUTPUT "${agcStorePageGatherShaderHeader}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${agcTextureDetileGeneratedDir}"
COMMAND "$<TARGET_FILE:glslang-standalone>" -V --target-env vulkan1.1 -o "${agcStorePageGatherShaderSpv}" "${agcStorePageGatherShaderSource}"
COMMAND ${CMAKE_COMMAND} -DINPUT=${agcStorePageGatherShaderSpv} -DOUTPUT=${agcStorePageGatherShaderHeader}
-DSYMBOL=STORE_PAGE_GATHER_SPV -P "${CMAKE_CURRENT_SOURCE_DIR}/embed_spirv.cmake"
DEPENDS "${agcStorePageGatherShaderSource}" glslang-standalone
VERBATIM
)
set(agcSampleCounterShaderSource ${CMAKE_CURRENT_SOURCE_DIR}/Graphics/shaders/SampleCounter.comp)
set(agcSampleCounterShaderSpv ${agcTextureDetileGeneratedDir}/SampleCounter.spv)
set(agcSampleCounterShaderHeader ${agcTextureDetileGeneratedDir}/SampleCounter_spv.h)
@@ -519,6 +532,7 @@ set(agcDriverSources
${agcTextureRepackShaderHeader}
${agcDispatchArgumentsShaderHeader}
${agcSplitSelectShaderHeader}
${agcStorePageGatherShaderHeader}
${agcTextureDetileWordsShaderHeader}
${agcTextureDetileImageWordsShaderHeader}
${agcSampleCounterShaderHeader}
@@ -154,6 +154,7 @@ struct DrawUserPatch {
struct DrawRelocationPending {
std::uint64_t key = 0, alias = 0, identity = 0;
std::weak_ptr<const DrawEntry> donor;
};
struct DrawRelocationTrial {
@@ -131,6 +131,8 @@ public:
DispatchCacheFootprint DispatchCacheSize();
DispatchCacheFootprint DrawCacheSize();
static std::uint64_t DispatchCacheBytes();
static std::size_t DrawCacheEntries();
static std::size_t DrawKeySightingKeys();
static std::uint64_t DrawCacheBytes();
static ShaderMemory::PendingWrite QueryPendingSpan(std::uint64_t address, std::size_t bytes, std::span<std::byte> known);
std::shared_ptr<const ShaderRegistry> RegisteredShaders();
@@ -217,7 +219,6 @@ private:
static bool verifyDrawEntries();
static bool registerKeyEnabled();
static bool verifyDrawRecipe();
static std::size_t drawCacheEntries();
static bool drawCacheIndirect();
static bool drawCachePushWord();
static bool verifyDrawPushWord();
@@ -457,14 +458,29 @@ private:
std::atomic<std::uint64_t> reference{0};
std::atomic<std::uint64_t> mask{0};
std::atomic<std::uint64_t> shape{0};
std::atomic<std::uint64_t> generation{0};
};
struct AwaitedFields {
std::uint64_t address;
std::uint64_t reference;
std::uint64_t mask;
std::uint64_t shape;
std::uint64_t generation;
};
static std::optional<AwaitedFields> readAwaited(const AwaitedSlot& slot, std::uint64_t awaited);
static bool awaitedUnchanged(const AwaitedSlot& slot, const AwaitedFields& fields);
static bool awaitedSatisfied(const AwaitedFields& fields);
std::array<AwaitedSlot, SubmissionQueueEnd - 0x20 + 1> awaitedSlots{};
std::atomic<bool> tracksTails{false};
std::mutex tailsMutex;
std::vector<std::pair<std::uint32_t, const std::uint32_t*>> unreadTails;
void noteTailRead(const std::uint32_t* read, std::uint32_t queue, const std::uint32_t* next);
static std::optional<AwaitedFields> blockedOn(const AwaitedSlot& slot, std::uint64_t awaited);
static bool stillAwaited(const AwaitedSlot& slot, std::uint64_t awaited);
using HeldSlot = std::pair<const AwaitedSlot*, AwaitedFields>;
bool slotsHeldStill(std::span<const HeldSlot> held) const;
void noteWaitFields(std::uint32_t queue, std::span<const std::uint32_t> packet);
void noteRewindWaitFields(std::uint32_t queue);
std::atomic<bool> captureHold{false};
std::atomic<std::uint64_t> flipSerial{0};
std::atomic<std::uint64_t> flipBatchesUnsignaled{0};
@@ -55,6 +55,7 @@ void Write(std::uint64_t address, std::span<const std::byte> source, std::size_t
// guest writes made meanwhile to untouched bytes survive. Compares in 256-byte blocks.
void WriteChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original);
void WriteChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, std::uint32_t byteStoreLimit);
void WriteChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, std::vector<std::pair<std::uint64_t, std::uint64_t>>& stored);
std::size_t WriteChangedIfHeld(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, std::uint64_t unchangedSince);
std::uint32_t ChangedByteStoreLimit();
void WriteChangedKeepingGuest(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original);
@@ -134,6 +135,11 @@ std::uint64_t StoreOwnBytes(std::uint64_t address, std::size_t bytes, const std:
std::uint64_t StoreOwnBytes(std::uint64_t address, std::size_t bytes, const std::function<void(std::span<std::byte>)>& store);
std::uint64_t StoreOwnBytes(std::uint64_t address, std::span<const std::byte> source);
void SetOwnStoreCompare(bool compare);
void SetLeftWatchCompare(bool compare);
void SeedComparedPages(std::uint64_t address, std::span<const std::byte> bytes);
void UpdateComparedPages(std::uint64_t address, std::span<const std::byte> bytes);
void ChangedComparedPages(std::uint64_t address, std::size_t bytes, std::vector<std::pair<std::uint64_t, std::uint64_t>>& changed);
void SetComparedDecisionHookForTest(void (*hook)());
bool StoredOver(std::uint64_t address, std::size_t bytes, std::uint64_t generation);
bool DriverStoredOver(std::uint64_t address, std::size_t bytes, std::uint64_t generation);
bool StoredAllSince_nid_no_patch(std::uint64_t address, std::size_t bytes, std::uint64_t generation);
@@ -208,6 +214,7 @@ std::uint64_t UntrackedHint(std::uint64_t address, std::size_t bytes);
bool UnchangedSinceCollected(std::uint64_t address, std::size_t bytes, std::uint64_t generation);
bool CpuWroteSince(std::uint64_t address, std::size_t bytes, std::uint64_t generation);
bool UnchangedSinceLastCollect(std::uint64_t address, std::size_t bytes, std::uint64_t generation);
bool StoreUnchangedSinceLastCollect(std::uint64_t address, std::size_t bytes, std::uint64_t generation);
// Per 64 KiB tracker block of [address, address + bytes) (block 0 holds `address`): `changed[k]`
// receives whether the block was stamped after generations[k] (UnchangedSince over that block
// alone), `cpu[k]`, when given, whether a collect stamped it after (a CPU store, as
@@ -173,7 +173,7 @@ public:
output << " execute_to_flip_packet_ms=" << milliseconds(flipReached - executionStart);
output << " flip_packet_to_complete_ms=" << milliseconds(finished - flipReached);
auto accounted = Clock::duration::zero();
for (const auto scope : {"Driver.Packet", "Driver.Suspend", "Driver.WorkerWait", "Driver.Completion", "Driver.EndSubmission", "Driver.Rewind"}) {
for (const auto scope : {"Driver.Packet", "Driver.Suspend", "Driver.WorkerWait", "Driver.Completion", "Driver.EndSubmission", "Driver.Rewind", "Driver.FinisherDrain"}) {
const auto it = metrics.find({scope, "total"});
if (it != metrics.end()) accounted += it->second.total;
}
@@ -527,7 +527,7 @@ private:
class TraceFormat {
public:
using Clock = std::chrono::steady_clock;
static constexpr std::array<std::string_view, 5> WorkerBusyScopes{"Driver.Packet", "Driver.Suspend", "Driver.EndSubmission", "Driver.Rewind", "Driver.Completion"};
static constexpr std::array<std::string_view, 6> WorkerBusyScopes{"Driver.Packet", "Driver.Suspend", "Driver.EndSubmission", "Driver.Rewind", "Driver.Completion", "Driver.FinisherDrain"};
static constexpr std::string_view WorkerWaitScope = "Driver.WorkerWait";
static constexpr std::string_view WorkerPrefix = "queue worker ";
static constexpr std::size_t TopPhases = 8;
@@ -933,15 +933,7 @@ public:
static void BindThread(const char* name, std::size_t capacity = TraceThread::DefaultCapacity);
static void Present(std::uint32_t width, std::uint32_t height, const VulkanDevice* device);
static void GpuRange(const char* name, double beginNs, double endNs, std::uint64_t batch = 0) {
if (!buffering.load(std::memory_order_relaxed)) return;
std::lock_guard lock(gpuMutex);
if (gpuRanges.size() == gpuRanges.capacity()) {
++gpuLost;
return;
}
gpuRanges.push_back({name, beginNs, endNs, batch});
}
static void GpuRange(const char* name, double beginNs, double endNs, std::uint64_t batch = 0);
static bool Recording() {
return AgcDriverTraceRecording_nid_postfix();
@@ -980,14 +972,15 @@ private:
static std::atomic<bool> recording;
static std::atomic<std::uint64_t> ownedDrawUnbound;
inline static std::atomic<bool> buffering{false};
static std::atomic<bool> buffering;
inline static std::atomic<std::uint64_t> presentCount{0};
static thread_local TraceThread* local;
static thread_local const char* localName;
static std::atomic<TraceThread* (*)()> binder;
inline static std::mutex gpuMutex;
inline static std::vector<TraceGpuRange> gpuRanges;
inline static std::uint64_t gpuLost = 0;
static std::mutex gpuMutex;
static std::vector<TraceGpuRange> gpuRanges;
static std::size_t gpuCapacity;
static std::uint64_t gpuLost;
};
}
@@ -431,7 +431,7 @@ private:
VulkanDevice(const PresentationWindow* window, bool compileOnly);
friend struct VulkanDeviceTestAccess;
std::pair<VkBuffer, std::uint64_t> scratchPoolHeader(const ShaderRecompiler::RecompileResult& shader) const;
VkPipeline splitComputePipeline(const Graphics::Context& context, const ShaderRecompiler::RecompileResult& shader, ComputePipelineObjects& objects, const std::array<std::uint32_t, 3>& base);
VkPipeline specializedComputePipeline(const Graphics::Context& context, const ShaderRecompiler::RecompileResult& shader, ComputePipelineObjects& objects, const std::array<std::uint32_t, 3>& base, bool storePages);
ShaderRecompiler::SpirvTarget buildTarget() const;
Graphics::Context buildContext() const;
// Body of Dispatch and DispatchIndirect: `arguments` 0 dispatches x, y, z groups.
@@ -496,6 +496,7 @@ DrawVerdict Driver::draw(QueueState& queue, std::span<const std::uint32_t> packe
if (dataEntry != nullptr) {
++drawEntryCounters.dataHits;
drawCacheUseful().fetch_add(1, std::memory_order_relaxed);
drawRelocationPending.donor = dataEntry;
}
}
}
@@ -703,7 +704,7 @@ DrawVerdict Driver::draw(QueueState& queue, std::span<const std::uint32_t> packe
++drawRelocationTrials[drawIdentity].hits;
if (const auto alias = drawAliases.find(drawAlias); alias != drawAliases.end()) {
const auto donor = drawCache.find(alias->second);
if (donor != drawCache.end() && drawCacheHits - donor->second->touched > drawCacheEntries() / 8) {
if (donor != drawCache.end() && drawCacheHits - donor->second->touched > DrawCacheEntries() / 8) {
drawOrder.splice(drawOrder.begin(), drawOrder, donor->second->order);
donor->second->touched = drawCacheHits;
++drawEntryCounters.touches;
@@ -57,15 +57,19 @@ bool Driver::verifyDrawRecipe() {
return verify;
}
std::size_t Driver::drawCacheEntries() {
std::size_t Driver::DrawCacheEntries() {
static const std::size_t entries = [] {
const char* text = std::getenv("APS5_DRAW_CACHE_ENTRIES");
const auto parsed = text != nullptr ? std::strtoull(text, nullptr, 10) : 0ull;
return parsed != 0 ? static_cast<std::size_t>(parsed) : std::size_t{65536};
return parsed != 0 ? static_cast<std::size_t>(parsed) : std::size_t{262144};
}();
return entries;
}
std::size_t Driver::DrawKeySightingKeys() {
return std::min<std::size_t>(DrawCacheEntries(), 65536) * DrawKeySightings::Ways;
}
std::uint64_t Driver::DrawCacheBytes() {
static const std::uint64_t bytes = [] {
const char* text = std::getenv("APS5_DRAW_CACHE_BYTES");
@@ -167,7 +171,7 @@ bool Driver::drawEntriesThisDraw() {
bool Driver::admitDrawKey(std::uint64_t key, std::uint64_t shape) {
std::lock_guard cacheLock(drawCacheMutex);
if (drawCache.contains(key)) return true;
if (!drawKeySightings) drawKeySightings.emplace(drawCacheEntries() * DrawKeySightings::Ways);
if (!drawKeySightings) drawKeySightings.emplace(DrawKeySightingKeys());
bool seen = drawKeySightings->SeenBefore(key);
const auto& pending = drawRelocationPending;
if (pending.key == key && pending.identity != 0) {
@@ -185,7 +189,7 @@ bool Driver::admitDrawKey(std::uint64_t key, std::uint64_t shape) {
}
}
if (seen || shape == 0 || drawShapes.contains(shape)) return seen;
if (!drawShapeSightings) drawShapeSightings.emplace(drawCacheEntries() * DrawKeySightings::Ways);
if (!drawShapeSightings) drawShapeSightings.emplace(DrawKeySightingKeys());
return drawShapeSightings->SeenBefore(shape);
}
@@ -246,8 +250,8 @@ void Driver::insertDrawEntry(std::uint64_t key, std::vector<std::shared_ptr<Disp
drawOrder.splice(drawOrder.begin(), drawOrder, replacement->order);
found->second = std::move(replacement);
}
while (drawCache.size() > drawCacheEntries() || (drawCache.size() > 1 && drawCacheVariantBytes > DrawCacheBytes())) {
const bool overBytes = drawCache.size() <= drawCacheEntries();
while (drawCache.size() > DrawCacheEntries() || (drawCache.size() > 1 && drawCacheVariantBytes > DrawCacheBytes())) {
const bool overBytes = drawCache.size() <= DrawCacheEntries();
const auto last = drawCache.find(drawOrder.back());
for (const auto& variants : last->second->stages) {
for (const auto& variant : variants) accountDrawVariant(*variant, false);
@@ -32,7 +32,7 @@ void ReadUserWords(const QueueState& queue, DrawProgram& program, bool staticAbi
Graphics::NoteRegisterRead(Graphics::RegisterBank::Shader, program.userDataBase + i);
program.userData.push_back(staticAbi ? ReadGraphicsRegister(queue.shader, program.userDataBase + i) : readUserData(queue.shader, program.userDataBase + i));
}
if ((program.binary.stage == ShaderRecompiler::ShaderStage::Vertex || program.binary.stage == ShaderRecompiler::ShaderStage::Fragment) && program.snapshot->header.empty() && program.snapshot->userDataTailRegister) program.tailContinuation = ReadUserDataTailContinuation(program.binary.code, program.firstUserSgpr, program.userData);
if ((program.binary.stage == ShaderRecompiler::ShaderStage::Vertex || program.binary.stage == ShaderRecompiler::ShaderStage::Fragment || program.binary.stage == ShaderRecompiler::ShaderStage::Mesh) && program.snapshot->header.empty() && program.snapshot->userDataTailRegister) program.tailContinuation = ReadUserDataTailContinuation(program.binary.code, program.firstUserSgpr, program.userData);
}
ShaderRecompiler::ShaderVertexStageInfo DecodeOrderedVertexStageInfo(std::span<const std::byte> header, std::uint64_t headerAddress, std::span<const std::uint32_t> userData, std::vector<Graphics::DecodeRead>& reads, std::uint32_t hiddenUserWords) {
@@ -225,7 +225,7 @@ std::shared_ptr<DrawDecode> Driver::decodeDraw(const QueueState& queue, const Su
const auto localDevice = device.Load();
if (localDevice != nullptr) product->pixel.sampleOrder = localDevice->HostSampleOrder(product->state);
}
product->pixel.quadSampleMask = Graphics::QuadSampleMasks(product->state, product->pixel.sampleOrder);
product->pixel.quadSampleMask = Graphics::QuadSampleMasks(product->state, product->pixel.sampleOrder, context.staticSampleMaskStopsShading);
if (product->pixel.stencilRefExportEnable && Graphics::StencilReferenceUnused(product->state)) {
const auto localDevice = device.Load();
const auto capabilities = localDevice == nullptr ? std::vector<std::uint32_t>{} : localDevice->Target().supportedCapabilities;
@@ -230,7 +230,7 @@ void Driver::lookupDraw(const Submission& submission, const std::shared_ptr<Vulk
rotated->order = entry->order;
again->second = std::move(rotated);
}
if (drawCacheHits - again->second->touched > drawCacheEntries() / 8) {
if (drawCacheHits - again->second->touched > DrawCacheEntries() / 8) {
drawOrder.splice(drawOrder.begin(), drawOrder, again->second->order);
again->second->touched = drawCacheHits;
++counters.touches;
@@ -204,8 +204,11 @@ void Driver::learnPendingRelocation() {
drawRelocationPending = {};
if (pending.key == 0) return;
const auto inserted = drawCache.find(pending.key);
if (inserted == drawCache.end() || inserted->second->decode == nullptr) return;
const auto& entry = *inserted->second;
std::shared_ptr<const DrawEntry> learned;
if (inserted != drawCache.end() && inserted->second->decode != nullptr) learned = inserted->second;
else if (const auto donor = pending.donor.lock(); donor != nullptr && donor->decode != nullptr) learned = donor;
if (learned == nullptr) return;
const auto& entry = *learned;
const auto& programs = entry.decode->programs;
if (entry.stages.size() != programs.size()) return;
const auto known = drawRelocations.find(pending.identity);
@@ -235,7 +238,7 @@ void Driver::learnPendingRelocation() {
word.reads.emplace_back(0, length);
word.high = program.userData[index + 1];
}
const auto base = AlignedWord(program.userData[index]);
const auto base = (static_cast<std::uint64_t>(word.high) << 32) + AlignedWord(program.userData[index]);
for (std::size_t run = 0; run < variant.runs.size() && run < variant.runBases.size(); ++run) {
if (variant.runBases[run] != static_cast<std::int8_t>(index)) continue;
word.reads.emplace_back(static_cast<std::int64_t>(variant.runs[run].first - base), static_cast<std::uint32_t>((variant.runs[run].second - variant.runs[run].first) / sizeof(std::uint32_t)));
@@ -371,16 +371,15 @@ void Driver::ReleaseSettled() {
std::vector<AwaitedWait> Driver::AwaitedWaits() {
std::vector<AwaitedWait> result;
for (const auto& slot : awaitedSlots) {
const auto address = slot.address.load(std::memory_order_acquire);
if (address == 0) continue;
const auto fields = readAwaited(slot, 0);
if (!fields) continue;
AwaitedWait wait;
wait.address = address;
wait.reference = slot.reference.load(std::memory_order_relaxed);
wait.mask = slot.mask.load(std::memory_order_relaxed);
const auto shape = slot.shape.load(std::memory_order_relaxed);
wait.function = static_cast<std::uint32_t>(shape);
wait.bytes = static_cast<std::uint32_t>(shape >> 32u);
if (slot.address.load(std::memory_order_acquire) == address) result.push_back(wait);
wait.address = fields->address;
wait.reference = fields->reference;
wait.mask = fields->mask;
wait.function = static_cast<std::uint32_t>(fields->shape);
wait.bytes = static_cast<std::uint32_t>(fields->shape >> 32u);
if (awaitedUnchanged(slot, *fields)) result.push_back(wait);
}
return result;
}
@@ -220,10 +220,18 @@ ShaderMemory::PendingWrite Driver::classifyPendingWrite(std::uint64_t address, s
return validateSkipVerify() ? Policy::VerifyRaw : Policy::Raw;
}
namespace {
bool checksQueuedWrites() {
return DrawPipeline::Active() || DrawFinisher::OnFinisherThread();
}
}
ShaderMemory::PendingWrite Driver::queryPendingWrite(std::uint64_t address, std::size_t bytes, std::span<std::byte> known) {
using Policy = ShaderMemory::PendingWrite;
auto queued = DrawPipeline::QueuedWrite::None;
if (DrawPipeline::Active()) {
if (checksQueuedWrites()) {
auto& pipeline = DrawPipeline::Queue0();
if (pipeline.Busy()) queued = pipeline.StoredBytes(address, bytes, known.size() == bytes ? known : std::span<std::byte>{});
if (queued == DrawPipeline::QueuedWrite::Stored && known.size() == bytes) {
@@ -241,7 +249,7 @@ ShaderMemory::PendingWrite Driver::queryPendingWrite(std::uint64_t address, std:
}
ShaderMemory::PendingWrite Driver::QueryPendingSpan(std::uint64_t address, std::size_t bytes, std::span<std::byte> known) {
if (DrawPipeline::Active()) {
if (checksQueuedWrites()) {
auto& pipeline = DrawPipeline::Queue0();
if (pipeline.Busy() && pipeline.Overlaps(address, bytes)) return ShaderMemory::PendingWrite::Sync;
}
@@ -3,6 +3,7 @@
#include "prx/libSceAgcDriver/Graphics/include/ColorTargetLayout.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp"
#include "prx/libSceAgcDriver/Graphics/include/GuestTextureResource.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp"
#include "prx/libSceAgcDriver/Graphics/include/TextureTiling.hpp"
#include "prx/libSceAgcDriver/Graphics/include/VertexInput.hpp"
#include "Optimization/ShaderStageInputInfo.hpp"
@@ -53,11 +54,12 @@ void Driver::noteWrittenBuffers(std::uint64_t program, std::uint32_t queue, cons
}
std::vector<std::pair<std::uint64_t, std::uint64_t>> DispatchWriteRanges(const ShaderRecompiler::RecompileResult& compiled, bool& bounded) {
bounded = compiled.bdaAbiVersion == 0 || std::any_of(compiled.bindings.begin(), compiled.bindings.end(), [](const ShaderRecompiler::DescriptorBinding& binding) { return binding.role == ShaderRecompiler::DescriptorRole::FaultBuffer; });
bounded = true;
std::vector<std::pair<std::uint64_t, std::uint64_t>> ranges;
constexpr std::uint64_t UnknownImageBytes = 64ull * 1024 * 1024;
for (const auto& binding : compiled.bindings) {
if (binding.role == ShaderRecompiler::DescriptorRole::Gds || binding.role == ShaderRecompiler::DescriptorRole::BdaPagetable) bounded = false;
if (binding.role == ShaderRecompiler::DescriptorRole::BdaPagetable && (compiled.bdaWrites || Graphics::ShaderStoresThroughAddresses(compiled.spirv))) bounded = false;
if (binding.role == ShaderRecompiler::DescriptorRole::Gds) ranges.emplace_back(Pm4::GdsAddress(), Pm4::GdsAddress() + Pm4::GdsBytes);
if (binding.role != ShaderRecompiler::DescriptorRole::GuestImages || binding.kind != ShaderRecompiler::DescriptorKind::StorageImage) continue;
for (std::uint32_t element = 0; element < binding.count; ++element) {
const bool written = element >= binding.imageWritten.size() || binding.imageWritten[element];
@@ -312,7 +312,10 @@ void Driver::execute(Submission& submission) {
const bool queuesLabel = pipelined && !predicated && header != FlipPacketHeader && header != RenderingWaitPacketHeader && !submission.flips.contains(cursor) && labelPacketQueues(packet, opcode);
const bool heldLabelWait = pipelined && !predicated && orderedWaits && (opcode == 0x3c || opcode == 0x93) && header != RenderingWaitPacketHeader && waitTakesPendingLabel(packet);
const bool beside = DrawFinisher::Overlap() && opcode != 0x15 && (queuesLabel || heldLabelWait || keepsDrawPipeline(packet, header, opcode));
if (!beside) DrawFinisher::Get().Drain();
if (!beside) {
PerformanceTimer finisherWait("Driver.FinisherDrain");
DrawFinisher::Get().Drain();
}
if (DrawFinisher::Overlap()) {
DrawFinisher::NoteDrain(DrawFinisher::DrainSite::Packet, !beside);
if (!beside) DrawFinisher::NoteDrainedOpcode(header == FlipPacketHeader ? 0xffu : opcode, keepsDrawPipeline(packet, header, opcode));
@@ -633,7 +636,10 @@ void Driver::execute(Submission& submission) {
cursor = nextCursor;
}
if (submission.queue == 0) DrawFinisher::Get().Drain();
if (submission.queue == 0) {
PerformanceTimer finisherWait("Driver.FinisherDrain");
DrawFinisher::Get().Drain();
}
PerformanceContext endContext(submission.queue == 0 ? frameTiming() : FrameTiming::Async());
PerformanceTimer endTiming("Driver.EndSubmission");
static const bool submitAtEnd = std::getenv("APS5_SUBMIT_AT_END") != nullptr;
@@ -125,8 +125,15 @@ void Driver::completeSubmission(std::uint64_t serial, std::uint64_t received, st
if (notify) driver.changed.notify_all();
}
} complete{*this, serial, received, labelWrites};
if (flipWork != nullptr) finishFlipWork(flipWork, submitFlipWork(0));
else submitOpenWork(progress);
try {
if (flipWork != nullptr) finishFlipWork(flipWork, submitFlipWork(0));
else submitOpenWork(progress);
} catch (const ProcessShutdown&) {
throw;
} catch (...) {
ReportFailure(std::current_exception());
throw;
}
}
const std::atomic<std::uint64_t>*& Driver::workerQueued() {
@@ -176,20 +183,24 @@ void Driver::run(std::uint32_t id) noexcept {
std::atomic<std::uint32_t>& count;
std::atomic<std::uint64_t>& idleEpoch;
std::condition_variable& changed;
std::mutex& mutex;
bool active = false;
Running(std::atomic<std::uint32_t>& count, std::atomic<std::uint64_t>& idleEpoch, std::condition_variable& changed)
: count(count), idleEpoch(idleEpoch), changed(changed) {}
Running(std::atomic<std::uint32_t>& count, std::atomic<std::uint64_t>& idleEpoch, std::condition_variable& changed, std::mutex& mutex)
: count(count), idleEpoch(idleEpoch), changed(changed), mutex(mutex) {}
void Start() {
count.fetch_add(1, std::memory_order_acq_rel);
active = true;
}
~Running() {
if (active && count.fetch_sub(1, std::memory_order_acq_rel) == 1) {
idleEpoch.fetch_add(1, std::memory_order_release);
{
std::lock_guard lock(mutex);
idleEpoch.fetch_add(1, std::memory_order_release);
}
changed.notify_all();
}
}
} running{runningWorkers, idleEpoch, changed};
} running{runningWorkers, idleEpoch, changed, mutex};
static const bool traceGpu = std::getenv("APS5_TRACE_GPU") != nullptr;
{
PerformanceContext timingContext(id == 0 ? frameTiming() : FrameTiming::Async());
@@ -495,23 +495,60 @@ bool Driver::awaitsTitle(std::uint64_t awaited) const {
return runningWorkers.load(std::memory_order_acquire) == 0 && orderHolders.load(std::memory_order_acquire) == 0 && !completionsPending() && !Graphics::Recorder::SnapshotWriteOverlaps(awaited, 4);
}
std::optional<Driver::AwaitedFields> Driver::readAwaited(const AwaitedSlot& slot, std::uint64_t awaited) {
const auto generation = slot.generation.load(std::memory_order_acquire);
const auto address = slot.address.load(std::memory_order_acquire);
if (address == 0 || (awaited != 0 && address != awaited)) return std::nullopt;
const auto shape = slot.shape.load(std::memory_order_acquire);
const auto reference = slot.reference.load(std::memory_order_acquire);
const auto mask = slot.mask.load(std::memory_order_acquire);
return AwaitedFields{address, reference, mask, shape, generation};
}
bool Driver::awaitedUnchanged(const AwaitedSlot& slot, const AwaitedFields& fields) {
return slot.generation.load(std::memory_order_acquire) == fields.generation && slot.address.load(std::memory_order_acquire) == fields.address;
}
bool Driver::awaitedSatisfied(const AwaitedFields& fields) {
const auto bytes = static_cast<std::uint32_t>(fields.shape >> 32u);
if (bytes == 0) return (Pm4::LoadLabel(fields.address, 4) & Pm4::RewindValid) != 0;
return Pm4::WaitCompares(static_cast<std::uint32_t>(fields.shape), fields.reference, fields.mask, Pm4::LoadLabel(fields.address, bytes == 8 ? 8 : 4));
}
std::optional<Driver::AwaitedFields> Driver::blockedOn(const AwaitedSlot& slot, std::uint64_t awaited) {
const auto fields = readAwaited(slot, awaited);
if (!fields) return std::nullopt;
const bool satisfied = awaitedSatisfied(*fields);
if (!awaitedUnchanged(slot, *fields) || satisfied) return std::nullopt;
return fields;
}
bool Driver::stillAwaited(const AwaitedSlot& slot, std::uint64_t awaited) {
const auto shape = slot.shape.load(std::memory_order_relaxed);
if (shape == 0) return (Pm4::LoadLabel(awaited, 4) & Pm4::RewindValid) == 0;
const std::uint64_t value = Pm4::LoadLabel(awaited, shape >> 32u == 8 ? 8 : 4);
return !Pm4::WaitCompares(static_cast<std::uint32_t>(shape), slot.reference.load(std::memory_order_relaxed), slot.mask.load(std::memory_order_relaxed), value);
return blockedOn(slot, awaited).has_value();
}
bool Driver::slotsHeldStill(std::span<const HeldSlot> held) const {
if (runningWorkers.load(std::memory_order_seq_cst) != 0) return false;
return std::all_of(held.begin(), held.end(), [](const HeldSlot& slot) { return awaitedUnchanged(*slot.first, slot.second); });
}
bool Driver::parkedOnTitle() const {
if (!queue0Uncommitted.empty() || DrawPipeline::Queue0().Busy() || DrawFinisher::Busy() || Graphics::Recorder::QueuedLabelsPending()) return false;
bool parked = false;
std::array<HeldSlot, std::tuple_size_v<decltype(awaitedSlots)>> held{};
std::size_t count = 0;
for (const auto& [queue, worker] : workers) {
const auto& slot = awaitedSlots[queue == 0 ? 0 : queue - 0x20 + 1];
const auto awaited = slot.address.load(std::memory_order_acquire);
if (awaited == 0 ? !worker.pending.empty() : !awaitsTitle(awaited) || !stillAwaited(slot, awaited)) return false;
parked = parked || awaited != 0;
if (awaited == 0) {
if (!worker.pending.empty()) return false;
continue;
}
if (!awaitsTitle(awaited)) return false;
const auto fields = blockedOn(slot, awaited);
if (!fields) return false;
held[count++] = {&slot, *fields};
}
return parked;
return count != 0 && slotsHeldStill(std::span<const HeldSlot>(held.data(), count));
}
void Driver::noteAwaitingTitle(std::uint32_t queue, std::uint64_t awaited) {
@@ -720,6 +757,7 @@ void Driver::executeRewindTail(const Submission& stalled) {
if (ring) PrepareSubmissionRing(stalled.queue);
std::atomic_ref<std::uint32_t> control(*const_cast<std::uint32_t*>(stalled.rewindTail - 1));
if ((control.load(std::memory_order_acquire) & Pm4::RewindValid) == 0) {
noteRewindWaitFields(stalled.queue);
noteWaitBlocked(stalled.queue, reinterpret_cast<std::uint64_t>(stalled.rewindTail - 1), true);
struct BlockedWait {
Driver& driver;
@@ -1003,26 +1041,26 @@ bool Driver::RewindTailsUnread() {
const auto [queue, words] = tail;
if ((std::atomic_ref<std::uint32_t>(*const_cast<std::uint32_t*>(words - 1)).load(std::memory_order_acquire) & Pm4::RewindValid) == 0) return false;
const auto& slot = awaitedSlots[queue == 0 ? 0 : queue - 0x20 + 1];
const auto awaited = slot.address.load(std::memory_order_acquire);
if (awaited == 0 || awaited == reinterpret_cast<std::uint64_t>(words - 1) || !awaitsTitle(awaited)) return true;
const auto shape = slot.shape.load(std::memory_order_relaxed);
const auto reference = slot.reference.load(std::memory_order_relaxed);
const auto mask = slot.mask.load(std::memory_order_relaxed);
if (slot.address.load(std::memory_order_acquire) != awaited) return true;
const auto bytes = static_cast<std::uint32_t>(shape >> 32u);
if (bytes == 0) return (std::atomic_ref<std::uint32_t>(*reinterpret_cast<std::uint32_t*>(awaited)).load(std::memory_order_acquire) & Pm4::RewindValid) != 0;
std::uint64_t value = 0;
std::memcpy(&value, reinterpret_cast<const void*>(awaited), bytes == 8 ? 8 : 4);
return Pm4::WaitCompares(static_cast<std::uint32_t>(shape), reference, mask, value);
const auto fields = readAwaited(slot, 0);
if (!fields || fields->address == reinterpret_cast<std::uint64_t>(words - 1) || !awaitsTitle(fields->address)) return true;
const bool satisfied = awaitedSatisfied(*fields);
return !awaitedUnchanged(slot, *fields) || satisfied;
});
}
void Driver::noteWaitFields(std::uint32_t queue, std::span<const std::uint32_t> packet) {
const auto fields = Pm4::DecodeWait(packet);
auto& slot = awaitedSlots[queue == 0 ? 0 : queue - 0x20 + 1];
slot.reference.store(fields.reference, std::memory_order_relaxed);
slot.mask.store(fields.mask, std::memory_order_relaxed);
slot.shape.store(static_cast<std::uint64_t>(fields.function) | static_cast<std::uint64_t>(fields.bytes) << 32u, std::memory_order_relaxed);
slot.reference.store(fields.reference, std::memory_order_release);
slot.mask.store(fields.mask, std::memory_order_release);
slot.shape.store(static_cast<std::uint64_t>(fields.function) | static_cast<std::uint64_t>(fields.bytes) << 32u, std::memory_order_release);
}
void Driver::noteRewindWaitFields(std::uint32_t queue) {
auto& slot = awaitedSlots[queue == 0 ? 0 : queue - 0x20 + 1];
slot.reference.store(0, std::memory_order_release);
slot.mask.store(0, std::memory_order_release);
slot.shape.store(0, std::memory_order_release);
}
void Driver::noteWaitBlocked(std::uint32_t queue, std::uint64_t awaited, bool blocked) {
@@ -1030,12 +1068,15 @@ void Driver::noteWaitBlocked(std::uint32_t queue, std::uint64_t awaited, bool bl
if (!blocked) {
runningWorkers.fetch_add(1, std::memory_order_seq_cst);
while (captureHold.load(std::memory_order_seq_cst)) PollSleep();
slot.shape.store(0, std::memory_order_relaxed);
slot.generation.fetch_add(1, std::memory_order_release);
}
slot.address.store(blocked ? awaited : 0, std::memory_order_release);
if (blocked) {
if (runningWorkers.fetch_sub(1, std::memory_order_acq_rel) == 1) {
idleEpoch.fetch_add(1, std::memory_order_release);
{
std::lock_guard lock(mutex);
idleEpoch.fetch_add(1, std::memory_order_release);
}
changed.notify_all();
}
}
@@ -4,6 +4,7 @@
#include "prx/libSceAgcDriver/Execution/include/PerformanceTimer.hpp"
#include "prx/libSceAgcDriver/Execution/include/ProfileOutput.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/DriverMemory.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/Draw/DrawPipeline.hpp"
#include "prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp"
#include "prx/libSceAgcDriver/Graphics/include/PipelineLibrary.hpp"
@@ -960,6 +961,7 @@ ShaderRecompiler::RectListShaders DrawRectangle(const ShaderSnapshot& front, con
}
struct UserDataCallSites {
std::shared_ptr<const std::vector<std::uint32_t>> code;
ShaderRecompiler::RdnaProgram program;
std::vector<ShaderRecompiler::UserDataCall> calls;
std::vector<ShaderRecompiler::TableCall> tableCalls;
@@ -971,7 +973,7 @@ constexpr std::size_t UserDataLinksPerProgram = 8u;
std::vector<std::uint32_t> LinkGraphicsUserDataTail(const ShaderRecompiler::RecompileRequest& request, const ShaderSnapshot& snapshot) {
using Stage = ShaderRecompiler::ShaderStage;
if ((request.shader.stage != Stage::Vertex && request.shader.stage != Stage::Fragment) || !request.shader.header.empty() || !snapshot.userDataTailRegister) return {};
if ((request.shader.stage != Stage::Vertex && request.shader.stage != Stage::Fragment && request.shader.stage != Stage::Mesh) || !request.shader.header.empty() || !snapshot.userDataTailRegister) return {};
const auto program = ShaderRecompiler::RdnaInstructionDecoder{}.Decode(request.shader.code);
const auto tail = ShaderRecompiler::FindUserDataTail(program, request.context.userDataBaseRegister, static_cast<std::uint32_t>(request.context.userData.size()));
if (!tail) return {};
@@ -1137,6 +1139,24 @@ void ReportTableCallSplit(std::uint64_t address, const ShaderRecompiler::RdnaPro
std::fprintf(stderr, "[gpu] compute shader 0x%llx: its table call at program counter 0x%x cannot run its callees as their own pipelines: %s\n", static_cast<unsigned long long>(address), call.programCounter, refusal.c_str());
}
#ifdef __APPLE__
std::optional<std::vector<std::uint32_t>> RetargetDriverBlockPointers(std::span<const std::uint32_t> code, const ShaderRecompiler::RdnaProgram& program, const std::vector<ShaderRecompiler::TableCall>& calls) {
std::vector<std::uint32_t> words(code.begin(), code.end());
bool retargeted = false;
for (const auto& call : calls) {
if (!call.constantPointer) continue;
const auto address = DriverDetail::RetargetPs5DriverMemory(*call.constantPointer);
if (address == *call.constantPointer) continue;
const auto rewritten = ShaderRecompiler::RetargetTableCallPointer(words, program, call, address);
if (!rewritten) continue;
words = std::move(*rewritten);
retargeted = true;
}
if (!retargeted) return std::nullopt;
return words;
}
#endif
std::shared_ptr<const PreparedShaderState::UserDataLink> LinkUserDataCallees(const ShaderRecompiler::RecompileRequest& request, const ShaderSnapshot& snapshot, std::size_t codeOffset) {
const bool gcnVertex = ShaderRecompiler::GcnGuestShaders() && request.shader.stage == ShaderRecompiler::ShaderStage::Vertex;
if (request.shader.stage != ShaderRecompiler::ShaderStage::Compute && !gcnVertex) return nullptr;
@@ -1182,6 +1202,15 @@ std::shared_ptr<const PreparedShaderState::UserDataLink> LinkUserDataCallees(con
found->program = ShaderRecompiler::RdnaInstructionDecoder{}.Decode(code);
found->calls = ShaderRecompiler::FindUserDataCalls(found->program, swappc);
found->tableCalls = ShaderRecompiler::FindTableCalls(found->program, swappc);
#ifdef __APPLE__
const auto patched = RetargetDriverBlockPointers(code, found->program, found->tableCalls);
if (patched) {
found->code = std::make_shared<const std::vector<std::uint32_t>>(std::move(*patched));
found->program = ShaderRecompiler::RdnaInstructionDecoder{}.Decode(*found->code);
found->calls = ShaderRecompiler::FindUserDataCalls(found->program, swappc);
found->tableCalls = ShaderRecompiler::FindTableCalls(found->program, swappc);
}
#endif
sites = std::move(found);
}
const auto& program = sites->program;
@@ -22,17 +22,10 @@ namespace AgcDriver::DriverDetail {
void PollSleep() {
#ifdef _WIN32
thread_local HANDLE timer = CreateWaitableTimerExW(nullptr, nullptr, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
if (timer != nullptr) {
LARGE_INTEGER due{};
due.QuadPart = -2000;
if (SetWaitableTimer(timer, &due, 0, nullptr, nullptr, FALSE)) {
WaitForSingleObject(timer, INFINITE);
return;
}
}
#endif
PreciseSleepWaitableTimerWithHandle(PreciseWaitThreadTimer(), 2000);
#else
std::this_thread::sleep_for(std::chrono::microseconds(200));
#endif
}
bool OwnStoreRejects(std::span<const std::uint32_t> packet, std::uint64_t awaited, std::size_t bytes, std::uint32_t queue) {
@@ -450,7 +450,16 @@ void FrameRecorder::writeDelta(std::span<Span> spans, std::span<const std::uint6
for (auto& span : spans) {
span.since = GuestMemory::CollectWrittenBlocks(span.address, static_cast<std::size_t>(span.bytes), span.since, written);
blocks.insert(blocks.end(), written.begin(), written.end());
GuestMemory::ChangedComparedPages(span.address, static_cast<std::size_t>(span.bytes), written);
blocks.insert(blocks.end(), written.begin(), written.end());
}
std::ranges::sort(blocks);
std::vector<std::pair<std::uint64_t, std::uint64_t>> merged;
for (const auto& [begin, end] : blocks) {
if (!merged.empty() && merged.back().second >= begin) merged.back().second = std::max(merged.back().second, end);
else merged.emplace_back(begin, end);
}
blocks = std::move(merged);
auto& driver = DriverDetail::Driver::Get();
const struct Hold {
DriverDetail::Driver& driver;
@@ -483,6 +492,7 @@ void FrameRecorder::writeDelta(std::span<Span> spans, std::span<const std::uint6
for (std::uint64_t at = 0; at < range.bytes;) {
bytes.resize(static_cast<std::size_t>(std::min<std::uint64_t>(FrameCaptureWriter::BlockBytes, range.bytes - at)));
readGuest(range.address + at, bytes);
if (stored.kind == FrameRangeKind::Unwatched) GuestMemory::SeedComparedPages(range.address + at, bytes);
const bool zero = std::all_of(bytes.begin(), bytes.end(), [](std::byte value) { return value == std::byte{0}; });
if (!zero || collected) {
writer->WriteDelta(group, completed, range.address + at, bytes);
@@ -507,6 +517,7 @@ void FrameRecorder::writeDelta(std::span<Span> spans, std::span<const std::uint6
for (const auto& [begin, end] : blocks) {
bytes.resize(static_cast<std::size_t>(end - begin));
readGuest(begin, bytes);
GuestMemory::UpdateComparedPages(begin, bytes);
writer->WriteDelta(group, completed, begin, bytes);
deltaBytes += bytes.size();
any = true;
@@ -533,6 +544,7 @@ void FrameRecorder::snapshot(const Range& range) {
if (abandonIfDiskLow()) return;
bytes.resize(static_cast<std::size_t>(std::min<std::uint64_t>(SnapshotPieceBytes, range.bytes - at)));
readGuest(range.address + at, bytes);
if (range.kind == FrameRangeKind::Unwatched) GuestMemory::SeedComparedPages(range.address + at, bytes);
snapshotBytes += writer->WriteSnapshot(range.address + at, bytes);
}
}
@@ -552,6 +564,7 @@ bool FrameRecorder::abandonIfDiskLow() {
void FrameRecorder::stop(const char* reason) {
GuestMemory::SetOwnStoreCompare(false);
GuestMemory::SetLeftWatchCompare(false);
warnings.push_back(reason);
std::fprintf(stderr, "[frame-capture] %s\n", reason);
try {
@@ -580,6 +593,7 @@ void FrameRecorder::start() {
rewindTailFlips = std::max(rewindTailFlips, driver.RewindTailFlips());
if (!GuestMemory::WriteWatched()) throw std::runtime_error("frame capture: the guest write watch is unavailable, so CPU stores during the frames cannot be recorded");
GuestMemory::SetOwnStoreCompare(true);
GuestMemory::SetLeftWatchCompare(true);
startedAt = std::chrono::steady_clock::now();
startBoundary = boundaries;
allocationsGeneration = GuestAllocations::GuestAllocationsGeneration_nid_postfix();
@@ -637,6 +651,7 @@ void FrameRecorder::start() {
void FrameRecorder::finish() {
emitDelta();
GuestMemory::SetOwnStoreCompare(false);
GuestMemory::SetLeftWatchCompare(false);
if (!writer) return;
auto end = make(FrameCallKind::End);
end.ordinal = ++ordinal;
@@ -688,12 +703,12 @@ std::vector<FrameRecorder::Range> FrameRecorder::committedRanges() {
if (size == 0) throw std::runtime_error("frame capture: the guest arena is not reserved");
std::vector<Range> result;
for (const auto& allocation : GuestAllocations::GuestAllocationsAcquireAll_nid_postfix()) {
if (!allocation->readable) continue;
if (!allocation->readable && !allocation->gpu) continue;
const auto first = allocation->address;
const auto end = first + allocation->bytes;
const auto firstRange = result.size();
const bool host = first < base || end > base + size;
const auto access = FrameRangeAccess::Readable | (allocation->writable ? FrameRangeAccess::Writable : 0u) | (allocation->gpu ? FrameRangeAccess::Gpu : 0u);
const auto access = (allocation->readable ? FrameRangeAccess::Readable : 0u) | (allocation->writable ? FrameRangeAccess::Writable : 0u) | (allocation->gpu ? FrameRangeAccess::Gpu : 0u);
for (auto address = first; address < end;) {
MEMORY_BASIC_INFORMATION info{};
if (VirtualQuery(reinterpret_cast<const void*>(static_cast<std::uintptr_t>(address)), &info, sizeof(info)) == 0) throw std::runtime_error("frame capture: VirtualQuery failed inside the guest arena");
@@ -724,12 +739,12 @@ std::vector<FrameRecorder::Range> FrameRecorder::committedRanges() {
if (size == 0) throw std::runtime_error("frame capture: the guest arena is not reserved");
std::vector<Range> result;
for (const auto& allocation : GuestAllocations::GuestAllocationsAcquireAll_nid_postfix()) {
if (!allocation->readable) continue;
if (!allocation->readable && !allocation->gpu) continue;
const auto first = allocation->address;
const auto end = first + allocation->bytes;
const auto firstRange = result.size();
const bool host = first < base || end > base + size;
const auto access = FrameRangeAccess::Readable | (allocation->writable ? FrameRangeAccess::Writable : 0u) | (allocation->gpu ? FrameRangeAccess::Gpu : 0u);
const auto access = (allocation->readable ? FrameRangeAccess::Readable : 0u) | (allocation->writable ? FrameRangeAccess::Writable : 0u) | (allocation->gpu ? FrameRangeAccess::Gpu : 0u);
HostMapping::Walk(first, end, "frame capture", [&](const HostMapping::Mapping& mapping) {
if (!mapping.readable && !mapping.writable && !mapping.executable) return;
const auto add = [&](std::uint64_t address, std::uint64_t regionEnd, bool readable) {
@@ -537,7 +537,13 @@ std::size_t CaptureCallerOffsets(std::span<unsigned long long> frames, unsigned
#endif
}
bool MemoryProfiled() {
static const bool profile = std::getenv("APS5_PROFILE_DRAW") != nullptr;
return profile;
}
void CountReadCaller(const void* returnAddress) {
if (!MemoryProfiled()) return;
thread_local std::uint32_t sampled = 0;
// Sampled at the same rate as the callers, in step with them (CountCaller advances the counter).
if ((sampled + 1) % 256 == 0) readSiteSamples[static_cast<std::size_t>(CurrentReadSite())].fetch_add(256, std::memory_order_relaxed);
@@ -545,15 +551,11 @@ void CountReadCaller(const void* returnAddress) {
}
void CountWriteCaller(const void* returnAddress) {
if (!MemoryProfiled()) return;
thread_local std::uint32_t sampled = 0;
CountCaller(Profile().writeCallers, sampled, 16, returnAddress);
}
bool MemoryProfiled() {
static const bool profile = std::getenv("APS5_PROFILE_DRAW") != nullptr;
return profile;
}
class TimedAccess {
public:
TimedAccess(MemoryCounterKind kind, std::uint64_t bytes) : kind(kind), bytes(bytes), start(MemoryProfiled() ? std::chrono::steady_clock::now() : std::chrono::steady_clock::time_point{}) {}
@@ -1666,12 +1668,18 @@ struct WriteTracker {
std::array<std::uint64_t, WritePagesPerBlock> pages{};
};
std::unordered_map<std::uint64_t, CpuPages> cpuPages;
std::unordered_map<std::uint64_t, CpuPages> cpuStoredPages;
std::unordered_map<std::uint64_t, CpuPages> walkPages;
std::unordered_map<std::uint64_t, CpuPages> windowPages;
std::map<std::uint64_t, std::uint64_t> refused;
void noteCpuStore(std::uint64_t begin, std::uint64_t end, std::uint64_t stampGeneration) {
notePages(cpuPages, begin, end, stampGeneration);
notePages(cpuStoredPages, begin, end, stampGeneration);
}
void noteCpuTouch(std::uint64_t begin, std::uint64_t end, std::uint64_t stampGeneration) {
notePages(cpuPages, begin, end, stampGeneration);
}
void noteWalkStore(std::uint64_t begin, std::uint64_t end, std::uint64_t stampGeneration) {
@@ -1846,7 +1854,7 @@ struct WriteTracker {
return leaf != nullptr ? leaf->cpuBlocks[block % LeafBlocks] : 0;
}
bool storedOver(std::uint64_t address, std::uint64_t end, std::uint64_t generation, bool walked) const {
bool storedOver(std::uint64_t address, std::uint64_t end, std::uint64_t generation, bool walked, bool storesOnly = false) const {
for (auto block = blockOf(address); block <= blockOf(end - 1); ++block) {
if (stampOf(block) <= generation) continue;
const auto begin = blockBegin(block);
@@ -1861,7 +1869,7 @@ struct WriteTracker {
return false;
};
if (cpuPages.find(block) == cpuPages.end() && cpuStampOf(block) > generation) return true;
if (newerPage(cpuPages, from, to)) return true;
if (newerPage(storesOnly ? cpuStoredPages : cpuPages, from, to)) return true;
if (walked && newerPage(walkPages, from, to)) return true;
const auto found = driverPieces.find(block);
if (found == driverPieces.end()) {
@@ -1907,9 +1915,29 @@ struct WriteTracker {
return false;
}
bool rangeUnchanged(std::uint64_t address, std::size_t bytes, std::uint64_t since, bool walked = true) const {
bool rangeUnchanged(std::uint64_t address, std::size_t bytes, std::uint64_t since, bool walked = true, bool storesOnly = false) const {
if (refusedSince(address, address + bytes, since)) return false;
return unchanged(blockOf(address), blockOf(address + bytes - 1), since) || !storedOver(address, address + bytes, since, walked);
return unchanged(blockOf(address), blockOf(address + bytes - 1), since) || !storedOver(address, address + bytes, since, walked, storesOnly);
}
bool cpuStoreUnchanged(std::uint64_t address, std::size_t bytes, std::uint64_t generation) const {
const auto first = blockOf(address);
const auto last = blockOf(address + bytes - 1u);
const auto end = address + bytes;
for (auto block = first; block <= last; ++block) {
if (const auto found = cpuPages.find(block); found != cpuPages.end()) {
const auto stored = cpuStoredPages.find(block);
const auto begin = blockBegin(block);
const auto from = std::max(address, begin) - begin;
const auto to = std::min<std::uint64_t>(end, begin + WriteBlockBytes) - begin;
for (auto page = from / WritePageBytes; page <= (to - 1u) / WritePageBytes; ++page) {
if (found->second.pages[page] > generation && stored != cpuStoredPages.end() && stored->second.pages[page] > generation) return false;
}
} else if (cpuStampOf(block) > generation) {
return false;
}
}
return true;
}
bool cpuUnchanged(std::uint64_t address, std::size_t bytes, std::uint64_t generation) const {
@@ -2077,9 +2105,10 @@ struct StampRuns {
std::vector<std::pair<std::uint64_t, std::uint64_t>> windowRuns;
};
void noteWrittenRun(StampRuns& runs, std::uintptr_t begin, std::uintptr_t end, std::uint64_t generation) {
if (runs.kind != StampKind::Driver) runs.tracker.noteCpuStore(begin, end, generation);
else runs.tracker.noteWalkStore(begin, end, generation);
void noteWrittenRun(StampRuns& runs, std::uintptr_t begin, std::uintptr_t end, std::uint64_t generation, bool changed = true) {
if (runs.kind == StampKind::Driver) runs.tracker.noteWalkStore(begin, end, generation);
else if (changed && runs.kind != StampKind::ImportWindow) runs.tracker.noteCpuStore(begin, end, generation);
else runs.tracker.noteCpuTouch(begin, end, generation);
}
void stampWrittenRun(void* context, std::uintptr_t begin, std::uintptr_t end) {
@@ -2109,9 +2138,9 @@ void stampWindowRuns(StampRuns& runs) {
const auto generation = tracker.generation.load(std::memory_order_relaxed);
std::size_t index = 0;
for (const auto& [begin, end] : runs.windowRuns) {
noteWrittenRun(runs, static_cast<std::uintptr_t>(begin), static_cast<std::uintptr_t>(end), generation);
for (auto page = begin; page < end; page += WritePageBytes) {
const bool kept = held[index++] != 0;
noteWrittenRun(runs, static_cast<std::uintptr_t>(page), static_cast<std::uintptr_t>(page + WritePageBytes), generation, !kept);
if (!kept) tracker.notePages(tracker.windowPages, page, page + WritePageBytes, generation);
tracker.stamp(tracker.blockOf(page), generation, kept ? runs.window->held : runs.kind);
}
@@ -2390,17 +2419,25 @@ std::uint64_t CollectWrittenBlocks(std::uint64_t address, std::size_t bytes, std
if (spanEnd > spanBegin) walkWrites(tracker, spanBegin & ~std::uint64_t{WritePageBytes - 1}, (spanEnd + WritePageBytes - 1) & ~std::uint64_t{WritePageBytes - 1}, StampKind::Cpu);
spanBegin = spanEnd = 0;
};
for (auto block = first; block <= last; ++block) {
const auto [begin, stop] = clip(block);
if (!tracker.covers(begin, stop - begin)) {
walkSpan();
continue;
}
const auto extend = [&](std::uint64_t begin, std::uint64_t stop) {
if (spanEnd != begin) {
walkSpan();
spanBegin = begin;
}
spanEnd = stop;
};
for (auto block = first; block <= last; ++block) {
const auto [begin, stop] = clip(block);
if (tracker.covers(begin, stop - begin)) {
extend(begin, stop);
continue;
}
for (auto page = begin & ~std::uint64_t{WritePageBytes - 1}; page < stop; page += WritePageBytes) {
const auto from = std::max(begin, page);
const auto to = std::min<std::uint64_t>(stop, page + WritePageBytes);
if (tracker.covers(from, static_cast<std::size_t>(to - from))) extend(from, to);
else walkSpan();
}
}
walkSpan();
const auto append = [&](std::uint64_t begin, std::uint64_t stop) {
@@ -2530,6 +2567,59 @@ std::uint64_t CollectEpoch() {
namespace {
struct ComparedPage {
std::uint64_t hash = 0;
bool known = false;
};
std::atomic<bool> leftWatchCompare{false};
std::mutex comparedMutex;
std::atomic<void (*)()> comparedDecisionHookForTest{nullptr};
std::map<std::uint64_t, ComparedPage> comparedPages;
template<typename Each>
void eachPage(std::uint64_t address, std::size_t bytes, const Each& each) {
const auto stop = address + bytes;
for (auto page = address & ~std::uint64_t{WritePageBytes - 1}; page < stop; page += WritePageBytes) each(page);
}
std::vector<std::optional<std::uint64_t>> hashGuestPages(std::span<const std::uint64_t> pages) {
std::vector<std::optional<std::uint64_t>> hashes(pages.size());
for (std::size_t from = 0; from < pages.size();) {
auto to = from + 1;
while (to < pages.size() && pages[to] == pages[to - 1] + WritePageBytes) ++to;
const bool whole = Accessible(reinterpret_cast<const void*>(static_cast<std::uintptr_t>(pages[from])), (to - from) * WritePageBytes);
for (auto index = from; index < to; ++index) {
const auto* pointer = reinterpret_cast<const std::byte*>(static_cast<std::uintptr_t>(pages[index]));
if (whole || Accessible(pointer, WritePageBytes)) hashes[index] = HashPage(pointer);
}
from = to;
}
return hashes;
}
void compareLeavingPages(std::uint64_t address, std::size_t bytes) {
if (!leftWatchCompare.load(std::memory_order_acquire)) return;
std::vector<std::uint64_t> fresh;
{
const std::lock_guard lock(comparedMutex);
eachPage(address, bytes, [&](std::uint64_t page) {
if (!comparedPages.contains(page)) fresh.push_back(page);
});
}
const auto hashes = hashGuestPages(fresh);
const std::lock_guard lock(comparedMutex);
for (std::size_t index = 0; index < fresh.size(); ++index) {
if (hashes[index]) comparedPages.try_emplace(fresh[index], ComparedPage{*hashes[index], true});
}
}
void noteLeftWatch(std::uint64_t address, std::size_t bytes) {
if (!leftWatchCompare.load(std::memory_order_acquire)) return;
const std::lock_guard lock(comparedMutex);
eachPage(address, bytes, [&](std::uint64_t page) { comparedPages.try_emplace(page); });
}
std::atomic<void (*)(std::uint64_t, std::size_t)> unwatchHook{nullptr};
thread_local bool unwatchWritesProven = true;
@@ -2537,6 +2627,7 @@ std::atomic<int> importWalkFailureForTest{0};
std::atomic<std::uint64_t> importWalkFailureSpanForTest{0};
void beforeUnwatch(std::uint64_t address, std::size_t bytes) {
compareLeavingPages(address, bytes);
const auto hook = unwatchHook.load(std::memory_order_acquire);
if (hook == nullptr) return;
#ifdef _WIN32
@@ -2571,6 +2662,7 @@ void unwatchLocked(WriteTracker& tracker, std::uint64_t address, std::size_t byt
if (tracker.coverage.Exclude(address, bytes, GuestArena::GuestArenaCommitGeneration_nid_postfix())) {
unwatchSerial.fetch_add(1, std::memory_order_release);
bumpSubscriptions(address, bytes, WriteBumpSource::Unwatch);
noteLeftWatch(address, bytes);
}
if (bytes != 0 && !tracker.rewatchStamps.empty()) {
for (auto block = tracker.blockOf(address); block <= tracker.blockOf(address + bytes - 1); ++block) tracker.rewatchStamps.erase(block);
@@ -2579,6 +2671,7 @@ void unwatchLocked(WriteTracker& tracker, std::uint64_t address, std::size_t byt
if (GuestWriteWatch::GuestWriteWatchUnregister_nid_postfix(reinterpret_cast<const void*>(address), bytes)) {
unwatchSerial.fetch_add(1, std::memory_order_release);
bumpSubscriptions(address, bytes, WriteBumpSource::Unwatch);
noteLeftWatch(address, bytes);
}
#endif
}
@@ -2612,6 +2705,63 @@ void SetUnwatchHook(void (*hook)(std::uint64_t, std::size_t)) {
unwatchHook.store(hook, std::memory_order_release);
}
void SetLeftWatchCompare(bool compare) {
leftWatchCompare.store(compare, std::memory_order_release);
if (compare) return;
const std::lock_guard lock(comparedMutex);
comparedPages.clear();
}
void SeedComparedPages(std::uint64_t address, std::span<const std::byte> bytes) {
if (!leftWatchCompare.load(std::memory_order_acquire)) return;
const auto first = (address + WritePageBytes - 1) & ~std::uint64_t{WritePageBytes - 1};
const std::lock_guard lock(comparedMutex);
for (auto page = first; page + WritePageBytes <= address + bytes.size(); page += WritePageBytes) comparedPages[page] = {HashPage(bytes.data() + (page - address)), true};
}
void UpdateComparedPages(std::uint64_t address, std::span<const std::byte> bytes) {
const auto first = (address + WritePageBytes - 1) & ~std::uint64_t{WritePageBytes - 1};
const std::lock_guard lock(comparedMutex);
for (auto found = comparedPages.lower_bound(first); found != comparedPages.end() && found->first + WritePageBytes <= address + bytes.size(); ++found) found->second = {HashPage(bytes.data() + (found->first - address)), true};
}
void ChangedComparedPages(std::uint64_t address, std::size_t bytes, std::vector<std::pair<std::uint64_t, std::uint64_t>>& changed) {
changed.clear();
if (bytes == 0 || bytes > std::numeric_limits<std::uint64_t>::max() - address) return;
const auto end = address + bytes;
std::vector<std::pair<std::uint64_t, ComparedPage>> pages;
{
const std::lock_guard lock(comparedMutex);
for (auto found = comparedPages.lower_bound(address & ~std::uint64_t{WritePageBytes - 1}); found != comparedPages.end() && found->first < end; ++found) pages.push_back(*found);
}
std::vector<std::uint64_t> addresses;
for (const auto& [page, compared] : pages) addresses.push_back(page);
const auto hashes = hashGuestPages(addresses);
for (std::size_t index = 0; index < pages.size(); ++index) {
const auto& [page, compared] = pages[index];
const auto& hash = hashes[index];
if (!hash || (compared.known && *hash == compared.hash)) continue;
const auto begin = std::max(address, page);
const auto stop = std::min(end, page + WritePageBytes);
if (!changed.empty() && changed.back().second == begin) changed.back().second = stop;
else changed.emplace_back(begin, stop);
}
if (pages.empty()) return;
if (const auto hook = comparedDecisionHookForTest.load(std::memory_order_acquire)) hook();
auto& tracker = Tracker();
const auto trackerLock = lockTracker(tracker);
tracker.initialize();
if (!tracker.watched) return;
const std::lock_guard lock(comparedMutex);
for (const auto page : addresses) {
if (tracker.covers(page, WritePageBytes)) comparedPages.erase(page);
}
}
void SetComparedDecisionHookForTest(void (*hook)()) {
comparedDecisionHookForTest.store(hook, std::memory_order_release);
}
bool UnwatchWritesProven() {
return unwatchWritesProven;
}
@@ -3087,7 +3237,7 @@ bool StoredOver(std::uint64_t address, std::size_t bytes, std::uint64_t generati
#ifdef _WIN32
if (GuestArena::GuestArenaHostRegionOverlaps_nid_postfix(address, bytes)) return true;
#endif
return tracker.storedOver(address, address + bytes, generation, false);
return tracker.storedOver(address, address + bytes, generation, false, true);
}
bool DriverStoredOver(std::uint64_t address, std::size_t bytes, std::uint64_t generation) {
@@ -3230,6 +3380,15 @@ bool UnchangedSinceLastCollect(std::uint64_t address, std::size_t bytes, std::ui
return tracker.cpuUnchanged(address, bytes, generation) && tracker.rangeUnchanged(address, bytes, generation, false);
}
bool StoreUnchangedSinceLastCollect(std::uint64_t address, std::size_t bytes, std::uint64_t generation) {
if (bytes == 0u || bytes > std::numeric_limits<std::uint64_t>::max() - address) return false;
auto& tracker = Tracker();
const auto lock = lockTracker(tracker);
tracker.initialize();
if (!tracker.watched || generation == 0u || !tracker.covers(address, bytes)) return false;
return tracker.cpuStoreUnchanged(address, bytes, generation) && tracker.rangeUnchanged(address, bytes, generation, false, true);
}
bool WrittenSince(std::uint64_t address, std::size_t bytes, std::uint64_t generation) {
auto& tracker = Tracker();
const auto lock = lockTracker(tracker);
@@ -3969,17 +4128,23 @@ bool EqualsCommittedUnsynced(std::uint64_t address, std::span<const std::byte> b
namespace {
thread_local void (*compareMappedHook)(std::uint64_t, std::size_t) = nullptr;
std::atomic<bool> compareMappedHookInstalled{false};
bool compareMappedHookArmed() {
return compareMappedHookInstalled.load(std::memory_order_relaxed) && compareMappedHook != nullptr;
}
}
void SetCompareMappedHook(void (*hook)(std::uint64_t address, std::size_t bytes)) {
if (hook != nullptr) compareMappedHookInstalled.store(true, std::memory_order_relaxed);
compareMappedHook = hook;
}
#ifdef __linux__
std::optional<Compare> compareWithoutQuery(std::uintptr_t address, std::span<const std::byte> bytes) {
static const bool enabled = std::getenv("APS5_NO_COPY_COMPARE") == nullptr;
if (!enabled || HostMapping::QueryFd() >= 0 || compareMappedHook != nullptr) return std::nullopt;
if (!enabled || HostMapping::QueryFd() >= 0 || compareMappedHookArmed()) return std::nullopt;
auto& pages = Pages();
pages.initialize();
for (const PageSpan* span : {&pages.arena, &pages.image}) {
@@ -4011,7 +4176,7 @@ Compare CompareMapped(std::uint64_t address, std::span<const std::byte> bytes) {
const bool queried = describePages(static_cast<std::uintptr_t>(address), bytes.size(), [&](const PageRun& run) {
if (!run.readable) outcome = Compare::Unmapped;
else {
if (compareMappedHook != nullptr) compareMappedHook(run.begin, static_cast<std::size_t>(run.end - run.begin));
if (compareMappedHookArmed()) compareMappedHook(run.begin, static_cast<std::size_t>(run.end - run.begin));
if (std::memcmp(reinterpret_cast<const void*>(run.begin), bytes.data() + (run.begin - address), static_cast<std::size_t>(run.end - run.begin)) != 0) outcome = Compare::Differs;
}
return outcome == Compare::Equal;
@@ -4077,11 +4242,22 @@ std::uint32_t ChangedByteStoreLimit() {
#endif
}
void WriteChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original) {
WriteChanged(address, current, original, ChangedByteStoreLimit());
static void appendStored(std::vector<std::pair<std::uint64_t, std::uint64_t>>& stored, std::uint64_t begin, std::uint64_t end) {
if (!stored.empty() && stored.back().second == begin) stored.back().second = end;
else stored.emplace_back(begin, end);
}
static void writeChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, [[maybe_unused]] std::uint32_t byteStoreLimit, bool keepGuest) {
static void writeChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, std::uint32_t byteStoreLimit, bool keepGuest, std::vector<std::pair<std::uint64_t, std::uint64_t>>* stored);
void WriteChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original) {
writeChanged(address, current, original, ChangedByteStoreLimit(), false, nullptr);
}
void WriteChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, std::vector<std::pair<std::uint64_t, std::uint64_t>>& stored) {
writeChanged(address, current, original, ChangedByteStoreLimit(), false, &stored);
}
static void writeChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, [[maybe_unused]] std::uint32_t byteStoreLimit, bool keepGuest, std::vector<std::pair<std::uint64_t, std::uint64_t>>* stored) {
require(current.size() == original.size(), "write-back snapshot sizes differ");
BreakProofs();
if (current.empty()) return;
@@ -4120,12 +4296,20 @@ static void writeChanged(std::uint64_t address, std::span<const std::byte> curre
}
firstChanged = std::min(firstChanged, at + static_cast<std::size_t>(std::countr_zero(changed)));
lastChanged = std::max(lastChanged, at + 32 - static_cast<std::size_t>(std::countl_zero(changed)));
if (stored == nullptr) continue;
for (auto bits = changed; bits != 0;) {
const auto first = static_cast<std::uint32_t>(std::countr_zero(bits));
const auto length = static_cast<std::uint32_t>(std::countr_one(bits >> first));
appendStored(*stored, address + at + first, address + at + first + length);
bits &= ~(((1u << length) - 1u) << first);
}
}
if (masked) _mm_sfence();
#endif
for (; at < size; ++at) {
if (current[at] == original[at] || (keepGuest && destination[at] != original[at])) continue;
destination[at] = current[at];
if (stored != nullptr) appendStored(*stored, address + at, address + at + 1);
firstChanged = std::min(firstChanged, at);
lastChanged = std::max(lastChanged, at + 1);
}
@@ -4137,11 +4321,11 @@ static void writeChanged(std::uint64_t address, std::span<const std::byte> curre
}
void WriteChanged(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original, std::uint32_t byteStoreLimit) {
writeChanged(address, current, original, byteStoreLimit, false);
writeChanged(address, current, original, byteStoreLimit, false, nullptr);
}
void WriteChangedKeepingGuest(std::uint64_t address, std::span<const std::byte> current, std::span<const std::byte> original) {
writeChanged(address, current, original, ChangedByteStoreLimit(), true);
writeChanged(address, current, original, ChangedByteStoreLimit(), true, nullptr);
}
static_assert(std::atomic_ref<std::uint64_t>::is_always_lock_free && std::atomic_ref<std::uint8_t>::is_always_lock_free);
@@ -31,10 +31,25 @@ extern char** environ;
namespace AgcDriver {
std::atomic<bool> PerformanceTrace::buffering{false};
std::mutex PerformanceTrace::gpuMutex;
std::vector<TraceGpuRange> PerformanceTrace::gpuRanges;
std::size_t PerformanceTrace::gpuCapacity = TraceThread::DefaultCapacity;
std::uint64_t PerformanceTrace::gpuLost = 0;
void PerformanceTrace::GpuRange(const char* name, double beginNs, double endNs, std::uint64_t batch) {
if (!buffering.load(std::memory_order_relaxed)) return;
std::lock_guard lock(gpuMutex);
if (gpuRanges.size() >= gpuCapacity) {
++gpuLost;
return;
}
gpuRanges.push_back({name, beginNs, endNs, batch});
}
namespace {
using Clock = std::chrono::steady_clock;
constexpr std::size_t GpuRangeCapacity = TraceThread::DefaultCapacity;
struct Session {
std::mutex mutex;
@@ -359,7 +374,8 @@ void PerformanceTrace::Present(std::uint32_t width, std::uint32_t height, const
std::lock_guard gpu(gpuMutex);
gpuRanges.clear();
gpuLost = 0;
gpuRanges.reserve(GpuRangeCapacity);
gpuCapacity = TraceThread::ParseCapacity(std::getenv("APS5_TRACE_EVENTS"));
gpuRanges.reserve(gpuCapacity);
}
state.presents.push_back(now);
presentCount.fetch_add(1, std::memory_order_relaxed);
@@ -14,6 +14,7 @@
#include <cstring>
#include <limits>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string>
@@ -110,8 +111,8 @@ std::uint64_t ReleaseMemValue(std::span<const std::uint32_t> packet) {
return address(packet[5], packet[6]);
}
std::uint32_t registerOffset(std::uint32_t value) {
require(value != 0xffffffffu, "indirect register sentinel semantics are not implemented");
std::optional<std::uint32_t> registerOffset(std::uint32_t value) {
if (value == 0xffffffffu) return std::nullopt;
const auto offset = value & ~0x70000000u;
if (offset > 0xffffu) {
char what[80];
@@ -537,7 +538,7 @@ void Validate(std::span<const std::uint32_t> packet, std::uint32_t queue) {
require(packet.size() >= 3, "register packet has no values");
if (opcode == 0x7a) require((packet[1] & 0xf0000000u) == 0 || (packet.size() == 3 && (packet[1] == 0x20000243u || packet[1] == 0x10000242u)), "indexed register bank selection is not implemented");
const auto offset = registerOffset(packet[1]);
require(packet.size() - 2 <= 0x10000u - offset, "register range overflow");
if (offset.has_value()) require(packet.size() - 2 <= 0x10000u - *offset, "register range overflow");
break;
}
case 0x59:
@@ -1111,15 +1112,19 @@ void ExecuteIndirectRegisters(std::span<const std::uint32_t> packet, std::span<c
require(pairs.size() == static_cast<std::size_t>(packet[4]) * 2, "indirect register list does not match its packet");
const auto usable = [&](std::uint32_t value) { return !skipInvalid || IndirectRegistersValid(std::span(&value, 1)); };
for (std::size_t i = 0; i < pairs.size(); i += 2) {
if (usable(pairs[i])) registerOffset(pairs[i]);
if (usable(pairs[i])) (void)registerOffset(pairs[i]);
}
for (std::size_t i = 0; i < pairs.size(); i += 2) {
if (usable(pairs[i])) writeRegister(queue, opcode, registerOffset(pairs[i]), pairs[i + 1]);
if (!usable(pairs[i])) continue;
const auto offset = registerOffset(pairs[i]);
if (offset.has_value()) writeRegister(queue, opcode, *offset, pairs[i + 1]);
}
if (queue.savedContext.has_value() && TraceContextState()) {
std::fprintf(stderr, "[context] indirect 0x%x:", opcode);
for (std::size_t i = 0; i < pairs.size(); i += 2) {
if (usable(pairs[i])) std::fprintf(stderr, " %x", registerOffset(pairs[i]));
if (usable(pairs[i])) {
if (const auto offset = registerOffset(pairs[i])) std::fprintf(stderr, " %x", *offset);
}
}
std::fprintf(stderr, "\n");
}
@@ -1289,7 +1294,7 @@ void Execute(std::span<const std::uint32_t> packet, QueueState& queue) {
case 0x69: case 0x76: case 0x79: case 0x7a: {
if (IsTagMarker(packet)) return;
const auto offset = registerOffset(packet[1]);
for (std::size_t i = 2; i < packet.size(); ++i) writeRegister(queue, opcode, offset + static_cast<std::uint32_t>(i - 2), packet[i]);
if (offset.has_value()) for (std::size_t i = 2; i < packet.size(); ++i) writeRegister(queue, opcode, *offset + static_cast<std::uint32_t>(i - 2), packet[i]);
return;
}
case 0x81:
@@ -5,6 +5,7 @@
#include <atomic>
#include <cerrno>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory>
@@ -54,7 +55,12 @@ bool triggered() {
if (error) throw std::runtime_error("Screenshot: cannot inspect trigger file: " + error.message());
if (!std::filesystem::is_regular_file(status)) throw std::runtime_error("Screenshot: trigger must be a regular file");
const bool consumed = std::filesystem::remove(trigger, error);
if (error) throw std::runtime_error("Screenshot: cannot consume trigger file: " + error.message());
static std::atomic<bool> reported{false};
if (error) {
if (!reported.exchange(true)) std::fprintf(stderr, "[gpu] screenshot trigger cannot be consumed yet, trying again at the next frame: %s\n", error.message().c_str());
return false;
}
reported.store(false);
return consumed;
}
@@ -6,6 +6,7 @@
#include <cstdlib>
#include <fstream>
#include <ios>
#include <mutex>
#include <stdexcept>
#include <string>
#include <system_error>
@@ -98,6 +99,8 @@ void TraceFile::ReplaceGzip(const std::filesystem::path& path, std::string_view
}
void TraceFile::AppendLine(const std::filesystem::path& path, std::string_view line) {
static std::mutex appendMutex;
std::lock_guard lock(appendMutex);
std::ofstream output(path, std::ios::binary | std::ios::app);
RequireGood(output, "opening", path);
output.write(line.data(), static_cast<std::streamsize>(line.size()));
@@ -460,8 +460,9 @@ struct ComputePipelineObjects {
VkPipelineLayout layout = VK_NULL_HANDLE;
VkPipeline pipeline = VK_NULL_HANDLE;
VkDescriptorSetLayout resourcesLayout = VK_NULL_HANDLE;
bool storePages = false;
std::mutex splitMutex;
std::map<std::array<std::uint32_t, 3>, VkPipeline> splitPipelines;
std::map<std::array<std::uint32_t, 4>, VkPipeline> splitPipelines;
~ComputePipelineObjects() {
for (const auto& [base, split] : splitPipelines) destroyPipeline(device, split, nullptr);
if (pipeline != VK_NULL_HANDLE) destroyPipeline(device, pipeline, nullptr);
@@ -659,6 +660,7 @@ struct VulkanDevice::State {
std::uint32_t srgbDecodeFormats = 0;
std::uint32_t srgbCopyFormats = 0;
std::uint32_t scaledSampledFormats = 0;
std::uint32_t optionalSampledFormats = 0;
bool storageImageWithoutFormat = false;
VkSampleCountFlags sampleLocationSampleCounts = 0;
VkSampleCountFlags sampleLocationGridSampleCounts = 0;
@@ -1667,6 +1669,7 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
}
state->srgbDecodeFormats = Graphics::SrgbDecodeFormats(state->InstanceFunction<PFN_vkGetPhysicalDeviceFormatProperties>("vkGetPhysicalDeviceFormatProperties"), selected);
state->scaledSampledFormats = Graphics::ScaledSampledFormats(state->InstanceFunction<PFN_vkGetPhysicalDeviceFormatProperties>("vkGetPhysicalDeviceFormatProperties"), selected);
state->optionalSampledFormats = Graphics::OptionalSampledFormats(state->InstanceFunction<PFN_vkGetPhysicalDeviceFormatProperties>("vkGetPhysicalDeviceFormatProperties"), selected);
state->srgbCopyFormats = Graphics::SrgbCopyFormats(state->InstanceFunction<PFN_vkGetPhysicalDeviceFormatProperties>("vkGetPhysicalDeviceFormatProperties"), selected, state->srgbDecodeFormats);
if ((state->subgroup.supportedOperations & VK_SUBGROUP_FEATURE_BASIC_BIT) != 0) {
state->capabilities.push_back(spv::CapabilityGroupNonUniform);
@@ -2656,7 +2659,7 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) :
if (deviceFault || queueCheckpoints || bufferMarkers) {
const auto faultInfo = deviceFault ? state->DeviceFunction<PFN_vkGetDeviceFaultInfoEXT>("vkGetDeviceFaultInfoEXT") : nullptr;
const auto checkpointData = queueCheckpoints ? state->DeviceFunction<PFN_vkGetQueueCheckpointDataNV>("vkGetQueueCheckpointDataNV") : nullptr;
Graphics::DeviceLostHook() = [device = state->device, queue = state->queue, present = state->presentQueue, settle = state->settleQueue, sparse = state->sparseQueue, faultInfo, checkpointData, vendorDump = vendorBinary, owner = state.get(), reportResidency = checkpointsRequested] noexcept {
Graphics::DeviceLostHook() = [device = state->device, queue = state->queue, present = state->presentQueue, settle = state->settleQueue, sparse = state->sparseQueue, faultInfo, checkpointData, vendorDump = vendorBinary, owner = state.get(), reportResidency = checkpointsRequested]() noexcept {
owner->hookActive.fetch_add(1, std::memory_order_acq_rel);
try {
if (!owner->hookRetired.load(std::memory_order_acquire)) {
@@ -3279,7 +3282,7 @@ int VulkanDevice::WriteLabelOnGpu(std::uint64_t address, std::span<const std::by
const auto range = GuestAllocations::GuestAllocationsLookup_nid_postfix(static_cast<std::uintptr_t>(address), true);
return range != nullptr && range->address < address + bytes.size();
}();
if (syncGuest && !Graphics::HostImportCovers(context, address, bytes.size())) return unimported();
if (syncGuest && !Graphics::HostImportCovers(context, address, bytes.size()) && Graphics::HostImportFor(context, address, bytes.size(), Graphics::ImportRequester::Label) == nullptr) return unimported();
const auto* import = Graphics::HostImportFor(context, address, bytes.size());
const bool listed = !state->copiedWriters->empty() || !Graphics::DrawCopiedWriters()->empty();
const bool storesPending = Graphics::Recorder::PendingCompletionStores() != 0;
@@ -3397,6 +3400,7 @@ bool VulkanDevice::FillBuffer(std::uint64_t address, std::size_t bytes, std::spa
if (OpportunisticReap()) recorder.Reap();
const auto context = graphicsContext();
const Graphics::HostImport* import = Graphics::HostImportFor(context, address, bytes);
if (import == nullptr) import = Graphics::HostImportJoinedFor(context, address, bytes);
if (import == nullptr) return false;
// Earlier recorded work that stores into the range must land before the fill, or it would
// overwrite the fill later. Stores the GPU makes (direct dispatch writes, GPU labels, earlier
@@ -3451,6 +3455,7 @@ bool VulkanDevice::FillBuffer(std::uint64_t address, std::size_t bytes, std::spa
// The sync ran completions, whose write-backs can refresh the import table and retire
// the import looked up above; the caller stores the fill itself when it is gone.
import = Graphics::HostImportFor(context, address, bytes);
if (import == nullptr) import = Graphics::HostImportJoinedFor(context, address, bytes);
if (import == nullptr) return false;
} else {
++ordered;
@@ -4924,7 +4929,7 @@ ShaderRecompiler::SpirvTarget VulkanDevice::buildTarget() const {
target.robustBufferAccess2 = state->robustBufferAccess2;
target.exactRobustLoads = state->exactRobustLoads;
target.waveLdsMemoryBarriers = !state->subgroupControlBarriers;
target.largePixelFunctionLdsBuffer = state->driverId == VK_DRIVER_ID_NVIDIA_PROPRIETARY;
target.largePixelFunctionLdsBuffer = state->driverId == VK_DRIVER_ID_NVIDIA_PROPRIETARY || state->driverId == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS;
target.pixelFunctionStorageDwords = state->pixelFunctionStorageDwords;
target.deviceScopeLdsMemoryBarriers = !state->workgroupScopeFences;
target.ldsLockFences = state->ldsLockFences;
@@ -5116,6 +5121,7 @@ Graphics::Context VulkanDevice::buildContext() const {
context.imageFormatList = state->imageFormatList;
context.demoteToHelperInvocation = state->demoteToHelperInvocation;
context.earlyFragmentSampleMaskTestBeforeSampleCounting = state->earlyFragmentSampleMaskTestBeforeSampleCounting;
context.staticSampleMaskStopsShading = state->driverId != VK_DRIVER_ID_MOLTENVK;
context.fmaFloat16 = state->fmaFloat16;
context.primitiveListRestart = state->primitiveListRestart;
context.imageViewMinLod = state->imageViewMinLod;
@@ -5128,6 +5134,7 @@ Graphics::Context VulkanDevice::buildContext() const {
context.srgbDecodeFormats = state->srgbDecodeFormats;
context.srgbCopyFormats = state->srgbCopyFormats;
context.scaledSampledFormats = state->scaledSampledFormats;
context.optionalSampledFormats = state->optionalSampledFormats;
context.sampleLocationSampleCounts = state->sampleLocationSampleCounts;
context.sampleLocationGridSampleCounts = state->sampleLocationGridSampleCounts;
context.sampleLocationGridSizes = state->sampleLocationGridSizes;
@@ -6211,7 +6218,9 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
if (record.resources != nullptr) recorder.KeepBytes(record.resources.get(), record.resources->CopiedBytes());
if (record.bindings != nullptr) {
recorder.Keep(record.bindings);
for (const auto& snapshot : record.bindings->snapshots) recorder.KeepBytes(snapshot.buffer.get(), snapshot.buffer->Bytes().size());
for (const auto& snapshot : record.bindings->snapshots) {
if (snapshot.buffer != nullptr) recorder.KeepBytes(snapshot.buffer.get(), snapshot.buffer->Bytes().size());
}
}
recordStep(PhaseRecordKeeps);
if (record.dataRefresh != RecordedDispatch::DataRefresh::None) {
@@ -6256,8 +6265,7 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
const std::pair<std::uint64_t, std::uint64_t> argumentRange{arguments, arguments + 12};
recorder.NoteAccess(CommandClass::IndirectArguments, Graphics::Recorder::Access{std::span(&argumentRange, 1), {}, {}, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT});
}
auto reads = resources.InPlaceReads();
if (record.bindings != nullptr) reads.insert(reads.end(), record.bindings->inPlaceReads.begin(), record.bindings->inPlaceReads.end());
const auto reads = resources.InPlaceReads();
const auto images = resources.StorageImages();
recorder.NoteAccess(CommandClass::DispatchLeading, Graphics::Recorder::Access{reads, resources.GpuWrites(), images, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, resources.HoldsLease()});
}
@@ -6328,7 +6336,8 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
context.Resolved(&Graphics::DeviceFunctions::cmdBindDescriptorSets, "vkCmdBindDescriptorSets")(commands, VK_PIPELINE_BIND_POINT_COMPUTE, record.objects->layout, ShaderRecompiler::SplitStateAbi::DescriptorSet, 1, &memory->set, 0, nullptr);
recorder.Keep(std::move(memory));
}
context.BindComputePipeline(commands, record.objects->pipeline);
const bool storePages = record.objects->storePages && resources.StorePages();
context.BindComputePipeline(commands, storePages ? specializedComputePipeline(context, *record.shader->program, *record.objects, {0u, 0u, 0u}, true) : record.objects->pipeline);
if (record.bindings != nullptr) Graphics::Require(record.bindings->allocation.set != VK_NULL_HANDLE, "dispatch overlay has no descriptor set");
if (record.bindings != nullptr) context.Resolved(&Graphics::DeviceFunctions::cmdBindDescriptorSets, "vkCmdBindDescriptorSets")(commands, VK_PIPELINE_BIND_POINT_COMPUTE, record.objects->layout, 0, 1, &record.bindings->allocation.set, 0, nullptr);
else resources.Bind(commands, VK_PIPELINE_BIND_POINT_COMPUTE, record.objects->layout);
@@ -6439,7 +6448,7 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
for (std::uint32_t xBase = 0; xBase < record.x; xBase += limit[0]) {
if (!firstChunk) {
Graphics::RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
context.BindComputePipeline(commands, splitComputePipeline(context, *record.shader->program, *record.objects, {xBase, yBase, zBase}));
context.BindComputePipeline(commands, specializedComputePipeline(context, *record.shader->program, *record.objects, {xBase, yBase, zBase}, storePages));
}
firstChunk = false;
dispatchChunk(commands, std::min(limit[0], record.x - xBase), std::min(limit[1], record.y - yBase), std::min(limit[2], record.z - zBase));
@@ -6462,10 +6471,14 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
recorder.MarkCovered(dispatchedAccess);
}
recordStep(PhaseRecordBind);
if (record.htileClear.has_value()) Graphics::ArmHtileDepthClear(record.htileClear->first, record.htileClear->second);
resources.MarkGpuWrites(recorder, record.bindings.get());
const auto htileDispatch = record.htileClear.has_value() ? std::make_shared<Graphics::HtileClearDispatch>() : nullptr;
if (record.htileClear.has_value()) {
Graphics::QueueHtileDepthClear(record.htileClear->first, record.htileClear->second);
const auto htileClear = *record.htileClear;
recorder.ChangeUndoneOnDiscard([htileClear] { Graphics::ArmHtileDepthClear(htileClear.first, htileClear.second); }, [htileClear, htileDispatch] { Graphics::DiscardHtileDepthClear(*htileDispatch, htileClear.first, htileClear.second); });
}
resources.MarkGpuWrites(recorder);
if (record.htileClear.has_value()) {
Graphics::QueueHtileDepthClear(*htileDispatch, record.htileClear->first, record.htileClear->second);
recorder.NotePendingWrite(record.htileClear->first, record.htileClear->second);
}
recordStep(PhaseRecordMarks);
@@ -6474,20 +6487,21 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) {
const bool completionNeeded = resources.NeedsCompletion() || record.htileClear.has_value();
if (completionNeeded && resources.Reusable()) {
auto kept = record.resources;
recorder.OnComplete([kept, htileClear = record.htileClear] {
recorder.OnComplete([kept, htileClear = record.htileClear, htileDispatch] {
kept->CheckFaults();
if (htileClear.has_value()) Graphics::CompleteHtileDepthClear(htileClear->first, htileClear->second);
if (htileClear.has_value()) Graphics::CompleteHtileDepthClear(*htileDispatch, htileClear->first, htileClear->second);
});
} else if (completionNeeded) {
// Listed for DispatchIndirect until the write-back ran (a non-reusable object, so once).
auto writers = state->copiedWriters;
auto kept = record.resources;
recorder.OnComplete([kept, writers, htileClear = record.htileClear] {
recorder.OnComplete([kept, writers, htileClear = record.htileClear, htileDispatch] {
// Delisted before the write-back: one that fails must not keep indirect dispatches on the CPU.
writers->erase(std::remove(writers->begin(), writers->end(), kept), writers->end());
kept->WriteBackBuffers();
if (htileClear.has_value()) Graphics::CompleteHtileDepthClear(htileClear->first, htileClear->second);
if (htileClear.has_value()) Graphics::CompleteHtileDepthClear(*htileDispatch, htileClear->first, htileClear->second);
});
recorder.OnDiscard([kept, writers] { writers->erase(std::remove(writers->begin(), writers->end(), kept), writers->end()); });
// Listed after the registration: a throw there leaves nothing that would pin the CPU path forever.
if (resources.HasCopiedWrites()) writers->push_back(kept);
}
@@ -6508,6 +6522,10 @@ std::shared_ptr<ComputePipelineObjects> VulkanDevice::createComputePipeline(cons
objects->destroyPipeline = state->DeviceFunction<PFN_vkDestroyPipeline>("vkDestroyPipeline");
objects->module = Graphics::CreateShaderModule(state->DeviceFunction<PFN_vkCreateShaderModule>("vkCreateShaderModule"), state->device, state->graphicsPipelineLibrary, shader.spirv.data(), shader.spirv.size() * sizeof(std::uint32_t), "vkCreateShaderModule");
objects->resourcesLayout = setLayout;
const auto words = shader.spirv.Words();
for (std::size_t cursor = 5; cursor < words.size() && (words[cursor] >> 16u) != 0u && (words[cursor] & 0xffffu) != spv::OpFunction; cursor += words[cursor] >> 16u) {
if ((words[cursor] & 0xffffu) == spv::OpDecorate && (words[cursor] >> 16u) == 4u && cursor + 3u < words.size() && words[cursor + 2u] == spv::DecorationSpecId && words[cursor + 3u] == ShaderRecompiler::PipelineSpecialization::StorePages) objects->storePages = true;
}
const bool scratchPool = shader.scratchPoolSlotDwords != 0;
const bool split = shader.splitStateLanes != 0;
const auto extraSet = [&](bool used) { return used || split ? state->workgroupMemoryLayout : VK_NULL_HANDLE; };
@@ -6565,12 +6583,14 @@ std::shared_ptr<ComputePipelineObjects> VulkanDevice::createComputePipeline(cons
return objects;
}
VkPipeline VulkanDevice::splitComputePipeline(const Graphics::Context& context, const ShaderRecompiler::RecompileResult& shader, ComputePipelineObjects& objects, const std::array<std::uint32_t, 3>& base) {
VkPipeline VulkanDevice::specializedComputePipeline(const Graphics::Context& context, const ShaderRecompiler::RecompileResult& shader, ComputePipelineObjects& objects, const std::array<std::uint32_t, 3>& base, bool storePages) {
std::lock_guard lock(objects.splitMutex);
if (const auto found = objects.splitPipelines.find(base); found != objects.splitPipelines.end()) return found->second;
std::array<ShaderRecompiler::PipelineSpecializationConstant, ShaderRecompiler::PipelineSpecialization::WorkgroupOffsetWords> offsets{};
for (std::uint32_t component = 0; component < offsets.size(); ++component) offsets[component] = {ShaderRecompiler::PipelineSpecialization::WorkgroupOffsetBase + component, base[component]};
const Graphics::PipelineSpecialization specialization(shader, context.atomicLockTable, offsets);
const std::array<std::uint32_t, 4> key{base[0], base[1], base[2], storePages ? 1u : 0u};
if (const auto found = objects.splitPipelines.find(key); found != objects.splitPipelines.end()) return found->second;
std::vector<ShaderRecompiler::PipelineSpecializationConstant> replaced;
for (std::uint32_t component = 0; component < ShaderRecompiler::PipelineSpecialization::WorkgroupOffsetWords; ++component) replaced.push_back({ShaderRecompiler::PipelineSpecialization::WorkgroupOffsetBase + component, base[component]});
if (storePages) replaced.push_back({ShaderRecompiler::PipelineSpecialization::StorePages, 1u});
const Graphics::PipelineSpecialization specialization(shader, context.atomicLockTable, replaced);
VkShaderModule module = Graphics::CreateShaderModule(state->DeviceFunction<PFN_vkCreateShaderModule>("vkCreateShaderModule"), state->device, state->graphicsPipelineLibrary, shader.spirv.data(), shader.spirv.size() * sizeof(std::uint32_t), "vkCreateShaderModule");
VkPipeline pipeline = VK_NULL_HANDLE;
try {
@@ -6583,7 +6603,7 @@ VkPipeline VulkanDevice::splitComputePipeline(const Graphics::Context& context,
computePipelinesCreated.fetch_add(1, std::memory_order_relaxed);
state->computePipelinesCreated.fetch_add(1, std::memory_order_relaxed);
if (GuestMemory::GpuMutex().HeldByThisThread()) computePipelinesCreatedLocked.fetch_add(1, std::memory_order_relaxed);
objects.splitPipelines.emplace(base, pipeline);
objects.splitPipelines.emplace(key, pipeline);
return pipeline;
}
@@ -29,6 +29,11 @@ public:
bool TableGuardCurrent(VkDevice device, std::span<const ShaderRecompiler::BdaAbi::Range> ranges);
VkDescriptorBufferInfo Fault() const;
void CheckFault() const;
std::vector<std::pair<std::uint64_t, std::uint64_t>> TakeWrittenPages() const;
std::vector<GuestBufferMemory::StorePage> TakeStorePages() const;
bool StorePages() const { return pages != nullptr; }
void RecordStorePageGather(Recorder& recorder) const;
static std::uint32_t StorePageSlots();
void CheckUse(const BdaResources* record) const;
void NoteUse(std::uint64_t serial);
bool TakeFaultSlot(const Context& context);
@@ -80,6 +85,8 @@ private:
// BdaResources.cpp, which refers to it weakly).
void checkFault(const BdaResources& record) const;
void markWrittenPages(const BdaResources& record) const;
void collectStorePages() const;
void attachStorePages() const;
void checkSrtGuard(const BdaResources& faults) const;
std::span<std::byte> faultBytes() const;
std::shared_ptr<Buffer> table;
@@ -88,11 +95,21 @@ private:
VkDeviceSize faultOffset = 0;
bool reportOnly = false;
std::uint64_t lastUse = 0;
bool privateSlot = false;
mutable std::unique_ptr<Buffer> pages;
VkDevice poolDevice = VK_NULL_HANDLE;
std::unique_ptr<Buffer> targets;
std::uint32_t pageSlots = 0;
std::uint32_t targetCount = 0;
std::uint64_t pageBase = 0;
mutable bool pagesOverflowed = false;
mutable std::vector<GuestBufferMemory::StorePage> storePages;
std::size_t tableBytes = 0;
std::uint64_t tableGuardSerial = 0;
std::vector<ImageTableFaults> imageTables;
std::vector<std::pair<std::uint64_t, std::uint64_t>> imageTableRanges;
std::vector<SrtGuardFaults> srtGuards;
mutable std::vector<std::pair<std::uint64_t, std::uint64_t>> writtenPages;
};
}
@@ -321,6 +321,7 @@ struct Context {
bool viewportIndexLayer = false;
bool demoteToHelperInvocation = false;
bool earlyFragmentSampleMaskTestBeforeSampleCounting = false;
bool staticSampleMaskStopsShading = true;
bool fmaFloat16 = false;
bool primitiveListRestart = false;
bool imageViewMinLod = false;
@@ -337,6 +338,7 @@ struct Context {
std::uint32_t srgbDecodeFormats = 0;
std::uint32_t srgbCopyFormats = 0;
std::uint32_t scaledSampledFormats = 0;
std::uint32_t optionalSampledFormats = 0;
bool provokingVertexLast = false;
bool provokingVertexModePerPipeline = false;
bool singlePassStorage = false;
@@ -25,6 +25,8 @@ const char* DccKeysName(DccKeys keys);
std::size_t DccKeyBytes(std::uint64_t surfaceBytes);
std::size_t DccKeyCount(TextureTileMode tileMode, std::uint32_t elementBytes, std::uint32_t width, std::uint32_t height, std::uint64_t surfaceBytes);
std::size_t DccKeyCount(const GuestTextureResource& surface, std::uint64_t surfaceBytes);
std::size_t DccMipKeySlice(std::uint32_t width, std::uint32_t height, std::uint32_t elementBytes);
std::optional<std::size_t> DccMipKeyOffset(std::uint32_t width, std::uint32_t height, std::uint32_t elementBytes, std::uint32_t mipCount, std::uint32_t firstTailLevel, std::uint32_t level);
template<typename ReadFollowed, typename ReadNamed>
bool KeysServeSurface(std::uint64_t followedDcc, DccKeys uploaded, DccKeys filled, std::uint64_t namedDcc, ReadFollowed&& readFollowed, ReadNamed&& readNamed) {
@@ -39,6 +41,7 @@ bool IsDccClear(DccKeys keys);
std::optional<std::uint8_t> LandedUniformMetadataByte(std::uint64_t address, std::size_t bytes);
DccKeys CurrentDccKeys(std::uint64_t metaAddress, std::uint64_t surfaceBytes);
DccKeys CurrentDccKeys(std::uint64_t metaAddress, std::uint64_t surfaceBytes, std::size_t keyCount);
DccKeys LandedDccKeys(std::uint64_t metaAddress, std::uint64_t surfaceBytes, std::size_t keyCount);
std::optional<DccKeys> KnownPendingDccKeys(std::uint64_t metaAddress, std::uint64_t surfaceBytes);
std::optional<std::uint8_t> CurrentUniformMetadataByte(std::uint64_t address, std::size_t bytes);
// Stores "uncompressed" keys over the surface's metadata on the CPU (a guest memory write: it waits
@@ -5,6 +5,7 @@
#include "prx/libSceAgcDriver/Graphics/include/SampleOrder.hpp"
#include "prx/libSceAgcDriver/Graphics/include/State.hpp"
#include <array>
#include <atomic>
#include <cstdint>
#include <memory>
#include <optional>
@@ -38,6 +39,7 @@ DepthPlaneStoreStatistics DepthPlaneStoreCounts();
void NoteDepthSurfaceWrite(const Context& context, const DepthTarget& target);
bool SampleLocationsCompatibleDepth(const Context& context, VkFormat format, std::uint32_t samples);
std::uint64_t DepthSurfacesSerial();
std::uint64_t DepthSurfaceStorageScans();
std::uint64_t DepthSurfacesReleased();
std::uint64_t DepthSliceBytes(VkExtent2D extent, std::uint32_t bytesPerTexel);
bool DirectDepthCopy(const Context& context, VkFormat depthFormat, VkImageAspectFlagBits aspect, VkFormat colorFormat);
@@ -85,8 +87,15 @@ std::size_t HtileDepthClearBytes_nid_no_patch(std::span<const std::uint32_t> cod
bool NoteHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes, std::size_t nativeBytes = 0u);
void NoteCopyDestination(std::uint64_t address, std::size_t bytes);
void ArmHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes);
void QueueHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes);
void CompleteHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes);
struct HtileClearDispatch {
std::vector<std::shared_ptr<const std::atomic<bool>>> surfaces;
};
void QueueHtileDepthClear(HtileClearDispatch& dispatch, std::uint64_t htileAddress, std::size_t bytes);
void CompleteHtileDepthClear(const HtileClearDispatch& dispatch, std::uint64_t htileAddress, std::size_t bytes);
void DiscardHtileDepthClear(const HtileClearDispatch& dispatch, std::uint64_t htileAddress, std::size_t bytes);
std::uint64_t ArmedHtileDepthClearCount();
std::uint64_t DiscardedHtileDepthClearCount();
std::uint32_t PendingHtileDepthClearDispatches(std::uint64_t htileAddress);
struct HtileMaskClear {
std::uint64_t address = 0;
std::size_t bytes = 0;
@@ -76,9 +76,9 @@ DrawInputCopy CopyZeroPaddedDrawInput(const Context& context, std::uint64_t addr
void KeepDrawInput(Recorder* recorder, std::uint64_t address, const DrawInputCopy& copy, Recorder::SnapshotUse use, std::uint32_t derived, std::uint32_t lowest = 0);
inline constexpr std::uint64_t InPlaceDrawInputMaxReads = 512;
const HostImport* InPlaceDrawInput(const Context& context, std::uint64_t address, std::size_t bytes, std::size_t alignment, bool* behindGpuWrite = nullptr, std::size_t fetched = std::numeric_limits<std::size_t>::max(), std::uint64_t reads = std::numeric_limits<std::uint64_t>::max());
enum class IndexBehindWriter : std::uint8_t { Taken, Off, NoWriter, VertexAttributes, IndexLimit, MeshStage, PrimitiveRestart, VertexOffset, UnitShadow, PendingStorage, LabelOrStore, CopiedWriter, NoImport, Refused, Count };
enum class IndexBehindWriter : std::uint8_t { Taken, Off, NoWriter, IndexLimit, MeshStage, PrimitiveRestart, VertexOffset, UnitShadow, PendingStorage, LabelOrStore, CopiedWriter, NoImport, Refused, Count };
std::array<std::uint64_t, static_cast<std::size_t>(IndexBehindWriter::Count)> IndexBehindWriterCounts();
const HostImport* InPlaceIndexBehindWriter(const Context& context, std::uint64_t address, std::size_t bytes, std::uint32_t indexSize, bool vertexAttributes, bool meshStage, bool primitiveRestart, std::uint32_t firstVertex, IndexBehindWriter* outcome = nullptr);
const HostImport* InPlaceIndexBehindWriter(const Context& context, std::uint64_t address, std::size_t bytes, std::uint32_t indexSize, bool meshStage, bool primitiveRestart, std::uint32_t firstVertex, IndexBehindWriter* outcome = nullptr);
struct InPlaceIndices {
std::optional<std::uint32_t> highest;
std::uint32_t lowest = 0;
@@ -0,0 +1,45 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_DRAWSTAGETIMINGKEYS_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_GRAPHICS_INCLUDE_DRAWSTAGETIMINGKEYS_HPP
#include <algorithm>
#include <cstdint>
#include <map>
#include <mutex>
#include <span>
#include <stdexcept>
#include <utility>
#include <vector>
namespace AgcDriver::Graphics {
class DrawStageTimingKeys {
public:
using Stage = std::pair<std::uint32_t, std::uint64_t>;
static constexpr std::uint64_t MaxKey = (std::uint64_t{1} << 62u) - 1;
explicit DrawStageTimingKeys(std::uint64_t capacity = MaxKey) : capacity(capacity) {
if (capacity > MaxKey) throw std::invalid_argument("draw-stage timing capacity exceeds the key space");
}
std::pair<std::uint64_t, bool> Intern(std::span<const Stage> stages) {
std::vector<Stage> key(stages.begin(), stages.end());
std::sort(key.begin(), key.end());
std::lock_guard lock(mutex);
if (auto found = keys.find(key); found != keys.end()) return {found->second, false};
if (nextKey > capacity) throw std::overflow_error("draw-stage timing key space exhausted");
const auto value = nextKey;
keys.emplace(std::move(key), value);
++nextKey;
return {value, true};
}
private:
std::mutex mutex;
std::map<std::vector<Stage>, std::uint64_t> keys;
std::uint64_t nextKey = 1;
std::uint64_t capacity;
};
}
#endif
@@ -43,6 +43,7 @@ struct HostImport {
bool settleOnDemand = false;
bool dmaBuf = false;
bool joined = false;
bool label = false;
std::shared_ptr<void> chunk;
mutable std::uint64_t lastUse = 0;
std::uint64_t lead = 0;
@@ -93,8 +94,8 @@ ImportWatch PrepareImportWatch(const Context& context);
void SetImportWatch(const Context& context, ImportWatch watch);
bool DmaBufImportSelected(const Context& context);
enum class ImportRequester : std::uint8_t { Map, Build, Access, Join, Segment, ColorTarget };
inline constexpr std::size_t ImportRequesterCount = 6;
enum class ImportRequester : std::uint8_t { Map, Build, Access, Join, Segment, ColorTarget, Label };
inline constexpr std::size_t ImportRequesterCount = 7;
struct HostImportRequesterCounts {
std::uint64_t made = 0;
@@ -114,6 +115,7 @@ struct HostImportCounts {
std::uint64_t retiredPinnedBytes = 0;
std::uint64_t credited = 0;
std::uint64_t creditedBytes = 0;
std::uint64_t labelBytes = 0;
};
const char* ImportRequesterName(ImportRequester requester);
@@ -137,6 +139,7 @@ std::vector<HostImportCopy> ExistingHostImportCopies(const Context& context, std
void RequireGpuLockBeforeImports(const char* where);
bool ImportsHeldByThisThread();
bool WatchedAfterSettle(const Context& context, std::uint64_t address, std::size_t bytes);
void SettleOwnImports(const Context& context, std::uint64_t address, std::size_t bytes);
std::shared_ptr<HostImport> UnregisteredHostImport(const Context& context, std::uint64_t address, std::size_t bytes);
void SetHostImportWindow(std::uint64_t bytes);
// Tests: the window of one large registered range (64 MiB) and the import budget (0: the configured one).
@@ -178,6 +181,7 @@ bool ImportMappedRanges(const Context& context, const GuestAllocations::Mapped&
// re-checks with HostImportFor when it binds the import.
bool HostImportOverlaps(const Context& context, std::uint64_t address, std::size_t bytes);
bool HostImportCovers(const Context& context, std::uint64_t address, std::size_t bytes);
bool HostImportSegmentsCover(const Context& context, std::uint64_t address, std::size_t bytes);
bool ReadTrappableHostImportCovers(const Context& context, std::uint64_t address, std::size_t bytes, std::uint64_t page);
bool ComparedHostImportCovers(const Context& context, std::uint64_t address, std::size_t bytes);
std::uint64_t HostImportSetGeneration();
@@ -329,10 +333,22 @@ struct MirrorStats {
std::uint64_t rangeMirrors = 0;
};
MirrorStats MirrorCounters();
struct AddressStoreStats {
std::uint64_t spanBytes = 0;
std::uint64_t comparedBytes = 0;
std::uint64_t copiedReferenceBytes = 0;
std::uint64_t readReferenceBytes = 0;
std::uint64_t gatheredBytes = 0;
std::uint64_t spilledBytes = 0;
std::uint64_t readbackBytes = 0;
std::uint64_t maskedBytes = 0;
};
AddressStoreStats AddressStoreCounters();
std::uint64_t SnapshotMismatches();
struct HeapMirrorHold {
std::uint64_t mirrors = 0;
std::uint64_t bytes = 0;
std::uint64_t resident = 0;
};
HeapMirrorHold HeapMirrorsWithin(std::uint64_t begin, std::uint64_t end);
void ClearSnapshotCopies(VkDevice device);
@@ -403,12 +419,28 @@ public:
// calls RecordCopyBacks (a dispatch or a recorded draw), since a staged region's results reach
// guest memory by that copy alone. Call before Upload.
void AllowDeviceStaging() { stagingAllowed = true; }
void AllowPassStaging() { passStaging = true; }
void DisallowAddressStaging() { addressStaging = false; }
void AllowAdjustedRegions() { adjustedRegions = true; }
bool HoldsMirror(const std::shared_ptr<ImageMirror>& mirror) const;
bool EvictMirror(const std::shared_ptr<ImageMirror>& mirror);
bool WasEvicted(std::uint64_t address) const;
void RecordEvicted(std::uint64_t address);
void AllowAddressStores() { addressStores = true; }
void NoteAddressStores(std::vector<std::pair<std::uint64_t, std::uint64_t>> pages);
struct StoreSpan {
std::uint64_t begin = 0;
std::uint64_t end = 0;
VkDeviceAddress device = 0;
bool resident = false;
};
struct StorePage {
std::uint64_t address = 0;
std::vector<std::byte> data;
std::array<std::uint32_t, ShaderRecompiler::BdaAbi::StoreMaskWords> mask{};
};
std::vector<StoreSpan> AddressStoreSpans() const;
void NoteStorePages(std::vector<StorePage> pages);
// Records the copy-in of every staged region anew for another use of this upload (a resource
// cache hit, from ShaderResources::Revalidate, under GuestMemory::GpuMutex, once the imports
// were confirmed unchanged): the previous use's copy-back left the shadow behind, and the next
@@ -461,6 +493,15 @@ public:
// regions was recorded (ShaderResources::MarkGpuWrites), under GuestMemory::GpuMutex. A use that
// never calls it (a synchronous draw) stores the staging bytes from the CPU in WriteBack.
void RecordCopyBacks(Recorder& recorder);
void DeferCopyBacks(Recorder& recorder);
void NotePassShadows(const Recorder& recorder);
struct PassStagingCounts {
std::uint64_t joined = 0;
std::uint64_t deferred = 0;
std::uint64_t landed = 0;
std::uint64_t shared = 0;
};
static PassStagingCounts PassStagingTotals();
bool HasGpuCopies() const {
for (const auto& region : regions) if (region.gpuCopy) return true;
return false;
@@ -577,6 +618,8 @@ private:
bool unstaged = false;
bool overlay = false;
bool adaptiveInPlace = false;
bool sharedShadow = false;
std::shared_ptr<void> passShadow;
};
// How [begin, end) lies against the space's base regions.
@@ -632,14 +675,24 @@ private:
// Records the import-to-buffer copies of the given gpuCopy regions into the open batch, with
// the barriers that order them after earlier recorded writes and before the shaders reading them.
void recordGpuCopies(std::span<Region* const> copies, bool addressable);
void addAddressStoreSpans();
bool joinPassShadows(Recorder& recorder, std::span<Region* const> copies);
std::shared_ptr<Buffer> regionShadow(Region& region, bool addressable) const;
void takeHeapReferences();
void recordHeapReferences();
std::span<const std::byte> heapReference(std::uint64_t begin);
void releaseHeapReferences() noexcept;
void publishIntoMirrors();
std::vector<MirrorPublishEntry> mirrorPublishes;
Context context;
bool stagingAllowed = false;
bool passStaging = false;
bool addressStaging = true;
bool adjustedRegions = false;
bool addressStores = false;
std::size_t declaredWrites = 0;
std::optional<std::vector<std::pair<std::uint64_t, std::uint64_t>>> storedPages;
std::vector<StorePage> storePageEntries;
GuestAllocations::Lease lease;
// The cached address space this build maps through (its lease pins the ranges); `regions` then
// holds only the regions outside it (V#s, snapshots, ranges copied per build).
@@ -665,6 +718,8 @@ private:
std::vector<std::pair<std::uint64_t, std::uint64_t>> readsOverBase;
std::vector<std::pair<std::uint64_t, std::uint64_t>> servedInsideBase;
std::vector<std::pair<std::uint64_t, std::vector<std::byte>>> heapReferences;
std::vector<std::pair<std::uint64_t, std::uint64_t>> pendingReferenceCopies;
std::vector<std::pair<std::uint64_t, std::shared_ptr<Buffer>>> heapReferenceCopies;
std::vector<std::pair<std::uint64_t, std::shared_ptr<Buffer>>> heapReadbacks;
std::vector<std::uint64_t> evictedRanges;
// UploadPrepare ran (regions are frozen); `uploaded` once UploadFinish ran.
@@ -14,6 +14,7 @@ Stripes StripesOf(std::uint64_t begin, std::uint64_t end);
bool LockOrderChecked();
void NoteLeafLock() noexcept;
void NoteLeafUnlock() noexcept;
bool LeafLockHeld() noexcept;
void RequireNoLeafLockHeld(const char* where);
template<typename TMutex> class LeafMutex {
@@ -16,11 +16,19 @@ namespace AgcDriver::Graphics {
using GuestRangeList = std::span<const std::pair<std::uint64_t, std::uint64_t>>;
struct PassAttachment {
VkImage image = VK_NULL_HANDLE;
bool written = false;
std::uint32_t mip = 0;
std::uint32_t firstSlice = 0;
std::uint32_t sliceCount = 0;
};
struct PassAccess {
GuestRangeList reads;
GuestRangeList writes;
std::span<const std::pair<VkImage, bool>> images;
std::span<const std::pair<VkImage, bool>> attachments;
std::span<const PassAttachment> attachments;
bool anyReads = false;
bool anyWrites = false;
GuestRangeList writeOnly = {};
@@ -73,6 +81,9 @@ private:
VkImage image;
bool written;
std::uint64_t pass;
std::uint32_t mip = 0;
std::uint32_t firstSlice = 0;
std::uint32_t sliceCount = 0;
};
bool overlapsAny(const GuestRangeSet& set, GuestRangeList ranges) const;
GuestRangeSet reads;
@@ -21,6 +21,7 @@
#include <optional>
#include <span>
#include <tuple>
#include <type_traits>
#include <unordered_set>
#include <utility>
#include <string>
@@ -193,6 +194,7 @@ public:
};
DrawPassStart StartDrawPass(std::uint64_t key, bool forced, bool fenced, const PassAccess& access);
void LeaveRenderPassOpen(std::uint64_t key, std::uint32_t timing, bool fenced, const PassAccess& access, std::function<void(CommandState&)> afterPass = {});
void AfterRenderPass(std::function<void(Recorder&)> work);
void SealPassWriteOnly();
// DCC "uncompressed" key stores (DccMetadata.cpp StoreUncompressedOnGpu): queued on the open
// batch and recorded as one run (one barrier pair for every queued fill) at Submit, before a
@@ -283,6 +285,8 @@ public:
bool KnownHighestIndex(std::uint64_t address, std::size_t bytes, SnapshotUse use, std::optional<std::uint32_t>& highest, std::uint32_t* lowest = nullptr);
void KeepHighestIndex(std::uint64_t address, std::size_t bytes, SnapshotUse use, std::uint64_t generation, std::uint64_t registryGeneration, std::optional<std::uint32_t> highest, std::uint32_t lowest = 0);
void OnComplete(std::function<void()> action);
void OnDiscard(std::function<void()> action);
void ChangeUndoneOnDiscard(const std::function<void()>& change, std::function<void()> undo);
void OnWriteComplete(std::uint64_t address, std::size_t bytes, std::function<void()> action);
void NotePendingWrite(std::uint64_t address, std::size_t bytes);
void NotePendingFill(std::uint64_t address, std::size_t bytes, std::uint8_t value);
@@ -378,6 +382,17 @@ public:
std::uint64_t OpenBatchSerial();
bool HasTimeline() const { return timeline != VK_NULL_HANDLE; }
bool RecordDispatchArguments(VkCommandBuffer commands, VkDeviceAddress source, VkDeviceAddress arguments, const std::array<std::uint32_t, 3>* threadGroup = nullptr);
struct StorePageGather {
VkDeviceAddress fault = 0;
VkDeviceAddress pages = 0;
VkDeviceAddress targets = 0;
std::uint64_t base = 0;
std::uint32_t count = 0;
std::uint32_t slots = 0;
};
void RecordStorePageGather(VkCommandBuffer commands, const StorePageGather& gather);
std::unique_ptr<Buffer> TakeStorePagePool(std::size_t bytes);
void KeepStorePagePool(std::unique_ptr<Buffer> pool);
// Waits until every batch up to `serial` completed on the GPU. Called WITHOUT GuestMemory::GpuMutex:
// it touches only the immutable timeline semaphore (the caller keeps the device alive). Requires
// HasTimeline(); the debug switch APS5_NO_TIMELINE makes the device create the recorder without one.
@@ -413,6 +428,7 @@ public:
std::uint64_t recordedAtOnce;
std::uint64_t segments;
std::uint64_t folds;
std::uint64_t capacityFolds;
};
static SampleDumpStatistics SampleDumpCounts();
struct QueuedWrite {
@@ -556,6 +572,7 @@ public:
// when an access overlaps one of that thread's queued labels; it records them. Set once.
static void SetQueuedLabelRecorder(void (*recorder)());
static void FailNextSubmitsForTest(unsigned count);
static void FailNextDiscardRegistrationsForTest(unsigned count);
// Whether the lock-free pending-write snapshot (open, in-flight and finishing batches) overlaps
// the range: false means no recorded work writes it, so a wait on it has nothing to submit.
static bool SnapshotWriteOverlaps(std::uint64_t address, std::size_t bytes);
@@ -586,6 +603,8 @@ public:
// before). A write-back over any tracked label dword is counted on the [recorder] line (must
// stay 0: it would mean a CPU store landed over a label recorded on the GPU).
static void NoteWrittenBack(std::uint64_t address, std::size_t bytes);
static void NoteWrittenBack(std::span<const std::pair<std::uint64_t, std::uint64_t>> runs);
static std::uint64_t WriteBacksOverLabels();
// Lock-free readers for the queue workers' packet loops and WAIT_REG_MEM polls (values of the
// active recorder; a torn-down recorder never publishes):
@@ -669,7 +688,10 @@ public:
// range index to pass to End, or NoTiming when timing is off or the batch's queries are used up.
static constexpr std::uint32_t NoTiming = 0xffffffffu;
static constexpr std::uint64_t DrawTimingFlag = std::uint64_t{1} << 63u;
static constexpr std::uint64_t DrawStageTimingFlag = std::uint64_t{1} << 62u;
static constexpr std::uint64_t DrawTimingKey(std::uint64_t variantId) { return variantId | DrawTimingFlag; }
static bool DrawStageTimingEnabled();
static std::uint64_t DrawStageTimingKey(std::span<const std::pair<std::uint32_t, std::uint64_t>> stages);
static std::string TimingKeyLabel(std::uint64_t key);
static bool GpuTimingEnabled();
static bool BatchStampsEnabled();
@@ -763,7 +785,16 @@ private:
bool overwritten = false;
const Batch* batch = nullptr;
};
struct SampleSegment {
std::shared_ptr<void> pool;
VkQueryPool handle;
std::uint32_t slot = 0;
std::uint64_t batch = 0;
};
static_assert(std::is_nothrow_move_constructible_v<SampleSegment> && std::is_nothrow_move_assignable_v<SampleSegment>);
struct Batch {
std::uint64_t sampleBatch = 0;
std::vector<SampleSegment> foldedSamples;
VkCommandBuffer commands = VK_NULL_HANDLE;
CommandState graphicsState;
VkFence fence = VK_NULL_HANDLE;
@@ -772,6 +803,7 @@ private:
std::unordered_set<const void*> keptOwners;
std::array<std::shared_ptr<DeviceBuffer>, static_cast<std::size_t>(UploadScratch::Count)> uploadScratch;
std::vector<std::function<void()>> completions;
std::vector<std::function<void()>> discards;
std::vector<std::pair<std::uint64_t, std::uint64_t>> writes;
std::vector<std::uint64_t> writeNotes;
std::vector<std::uint64_t> stampedNotes;
@@ -892,6 +924,7 @@ private:
std::uint64_t key = 0;
std::uint32_t timing = NoTiming;
std::function<void(CommandState&)> afterPass;
std::vector<std::function<void(Recorder&)>> afterEnd;
PassBreak closedBy = PassBreak::NewBatch;
} renderPass;
PassHazards passHazards;
@@ -941,12 +974,9 @@ private:
void dispatchDumps(VkCommandBuffer commands, std::uint32_t firstDump, std::uint32_t dumps, std::uint32_t firstSegment, std::uint32_t lastSegment);
void foldSegments();
void foldQueuedDumps(VkCommandBuffer commands, std::span<const Batch::StoreRun::Queued> writes, std::size_t first, std::size_t end, std::uint32_t& dumpIndex, std::uint32_t& consumed);
struct SampleSegment {
std::shared_ptr<void> pool;
VkQueryPool handle;
std::uint32_t slot = 0;
};
void reserveSampleRestore(const Batch& batch);
std::vector<SampleSegment> pendingSamples;
std::uint64_t sampleBatches = 0;
bool countingSamples = false;
int meshArgumentState = 0;
VkPipelineLayout meshArgumentLayout = VK_NULL_HANDLE;
@@ -970,6 +1000,10 @@ private:
int dispatchArgumentState = 0;
VkPipelineLayout dispatchArgumentLayout = VK_NULL_HANDLE;
VkPipeline dispatchArgumentPipeline = VK_NULL_HANDLE;
VkPipelineLayout storePageGatherLayout = VK_NULL_HANDLE;
VkPipeline storePageGatherPipeline = VK_NULL_HANDLE;
AgcDriver::Mutex storePagePoolsMutex;
std::vector<std::unique_ptr<Buffer>> storePagePools;
// BeginGpuTiming on the open batch without Commands() (RecordStore times its own run, which
// Commands() would close).
std::uint32_t beginTiming(std::uint64_t key);
@@ -1084,6 +1118,7 @@ private:
std::uint64_t wideLabelSequence = 0;
std::atomic<std::size_t> recordedWideLabels{0};
bool wideLabelInLocked(std::uint64_t address, std::size_t bytes) const;
bool pendingLabelInLocked(std::uint64_t address, std::size_t bytes) const;
// labels.size(), readable without the table mutex: a noted write skips the mutex while the
// table is empty (most of the time between label groups).
std::atomic<std::size_t> recordedLabels{0};
@@ -31,6 +31,9 @@ enum class RuntimeSwitch : std::size_t {
IndexInPlaceBehindWriter,
WideLibraryKeys,
NoWideTableCopyHle,
NoDccMipFastClear,
NoTableEntryMemo,
PassStaging,
Count,
};
@@ -45,12 +48,19 @@ std::optional<RuntimeSwitch> Find(std::string_view name);
class AbSchedule {
public:
struct Arm {
std::string name;
std::vector<RuntimeSwitch> switches;
};
struct Config {
double phaseSeconds = 0;
double settleSeconds = 2;
std::uint64_t startPresent = 0;
std::optional<double> startSeconds;
std::vector<RuntimeSwitch> switches;
std::vector<Arm> arms;
bool rotate = false;
};
enum class Event { None, Begin, Settled };
@@ -58,10 +68,10 @@ public:
struct Step {
Event event = Event::None;
std::uint64_t phase = 0;
bool b = false;
std::size_t arm = 0;
};
static Config Parse(std::string_view ab, std::string_view start, std::string_view settle);
static Config Parse(std::string_view ab, std::string_view start, std::string_view settle, bool rotate = false);
explicit AbSchedule(Config config);
@@ -69,6 +79,8 @@ public:
const Config& Settings() const { return config; }
std::size_t ArmOfPhase(std::uint64_t index) const;
private:
Config config;
bool started = false;
@@ -196,6 +196,7 @@ struct ImageTableReuseCounts {
std::uint64_t variantSubstituted = 0;
std::uint64_t variantRejected = 0;
std::uint64_t arrayViewsShared = 0;
std::uint64_t entryMemoHits = 0;
};
ImageTableReuseCounts ImageTableReuses();
std::uint64_t SampledTexturesCleared();
@@ -252,14 +253,6 @@ public:
DescriptorCache::SetAllocation fragmentAllocation;
DescriptorCache::SetAllocation allocation;
std::vector<Snapshot> snapshots;
struct InPlace {
std::size_t allocation;
VkBuffer buffer;
VkDeviceSize offset;
std::size_t bytes;
};
std::vector<InPlace> inPlace;
std::vector<std::pair<std::uint64_t, std::uint64_t>> inPlaceReads;
~DrawBindings();
};
struct MovedBuffer {
@@ -270,7 +263,6 @@ public:
VkBuffer inPlace = VK_NULL_HANDLE;
VkDeviceSize inPlaceOffset = 0;
std::uint32_t adjustment = 0;
bool dispatchInPlace = false;
};
struct DrawUse {
DrawUse() = default;
@@ -302,7 +294,7 @@ public:
// Deferred completion: MarkGpuWrites registers the results the recorded work leaves on the GPU
// (storage images stay there; buffer ranges are noted so CPU reads wait); WriteBackBuffers runs
// once the work completed.
void MarkGpuWrites(Recorder& recorder, const DrawBindings* bindings = nullptr);
void MarkGpuWrites(Recorder& recorder);
void WriteBackBuffers();
// Whether WriteBackBuffers has anything the CPU must see (copied written buffers, BDA faults).
bool NeedsCompletion() const { return (bda != nullptr && faultChecks) || guestMemory.HasCopiedWrites(); }
@@ -315,6 +307,7 @@ public:
void CopyBacksAfterRun(std::shared_ptr<ShaderResources> self) { afterRunSelf = std::move(self); }
void RunAccesses(std::vector<std::array<std::uint64_t, 3>>& out) const;
bool HoldsLease() const { return guestMemory.HoldsLease(); }
bool StorePages() const;
bool SpaceReuse() const { return spaceReuse; }
static bool SpaceReuseDisabled();
bool BdaReadOnly() const { return usesBda && bdaReadOnly; }
@@ -576,7 +569,7 @@ private:
std::uint64_t guestBufferBytes(std::span<const std::uint32_t> words) const;
std::size_t addDataBuffer(std::span<const std::uint32_t> words);
void requireGuestBuffers(std::span<const MovedBuffer> moved = {}) const;
bool movedInPlace(Recorder& recorder, const Allocation& item, std::uint64_t address, std::uint64_t size, MovedBuffer& entry) const;
bool movedInPlace(Recorder& recorder, const Allocation& item, std::uint64_t address, std::uint64_t size, MovedBuffer& entry, bool counted = true) const;
// Stage A: the layout entry of an image binding (samplers are taken at once, the sampler cache
// locks itself); stage B looks the sampled textures and storage images up (resolveImageBinding).
void addImageBinding(const ShaderRecompiler::DescriptorBinding& binding, VkShaderStageFlags flags);
@@ -265,7 +265,8 @@ bool ReordersSamples(const SampleOrder& order);
std::uint32_t InvertSampleOrder(std::uint32_t order);
std::uint32_t HostSampleBits(std::uint32_t guestBits, std::uint32_t order);
bool SampleMaskFollowsOrder(const State& state, const SampleOrder& order);
std::array<std::uint16_t, 4> QuadSampleMasks(const State& state, const SampleOrder& order);
bool SampleMaskInShader(const State& state, const SampleOrder& order, bool staticMaskStopsShading);
std::array<std::uint16_t, 4> QuadSampleMasks(const State& state, const SampleOrder& order, bool staticMaskStopsShading = true);
std::array<std::uint8_t, 8> ExportMappings(const State& state);
std::array<ShaderRecompiler::ColorExportPacking, 8> ExportPackings(const State& state);
std::uint32_t PackedWriteMask(std::uint8_t componentMapping, std::uint32_t exportedMask);
@@ -54,6 +54,8 @@ bool LabelTrapResolveWaits(std::uint64_t address, std::size_t bytes);
VkFormat StorageFormatForGuest(const Context& context, std::uint32_t guestFormat);
// Whether StorageFormatForGuest would succeed, without throwing (unknown guest formats included).
bool StorageFormatAvailable(const Context& context, std::uint32_t guestFormat);
bool StorageSegmentsServe(const Context& context, const GuestTextureResource& descriptor, std::uint64_t guestBytes);
bool StorageSegmentsServe(const Context& context, const StorageTexture& image);
VkFormat HostStorageFormat(const Context& context, VkFormat format);
bool StorageClearAvailable(const Context& context, std::uint32_t guestFormat, DccKeys keys);
std::uint64_t SampledTextureMemory();
@@ -573,6 +575,7 @@ public:
// False, naming why in `refusal`, when the fill must be stored as before.
static constexpr std::uint32_t WholeImage = ~0u;
bool FillClear(std::span<const std::uint32_t, 4> pattern, std::uint32_t layer, const char*& refusal, bool allowRegisterClear = false);
bool ClearMip(const std::array<std::byte, 16>& texel, std::uint32_t level, bool verifiedCodeClear, const char*& refusal);
// The cached, live image whose surface is exactly [address, address + bytes), if any (the newest
// of several: see ClassifyFill).
static std::shared_ptr<StorageTexture> FindLive(std::uint64_t address, std::uint64_t bytes);
@@ -624,6 +627,7 @@ public:
static std::uint64_t LinearImportRetiles();
static std::uint64_t RefreshesProved();
const char* RefreshObligation(std::uint32_t first = 0, std::uint32_t count = 0) const;
bool OtherPendingOverlaps() const;
static std::uint64_t ClearHandOvers();
static std::uint64_t CreationHandOvers();
static std::uint64_t HandedOverSuperseded();
@@ -926,6 +930,7 @@ private:
// DCC keys the image content was uploaded under: a fast-cleared surface starts as its clear value.
DccKeys uploadedKeys = DccKeys::Uncompressed;
mutable DccKeys filledKeys = DccKeys::Uncompressed;
bool holdsClearFill = false;
mutable DccKeyProof keyProof;
mutable DccRangeProof targetKeyProof;
DccSingleProof singleProof;
@@ -17,6 +17,7 @@ VkFormat DccClearTextureFormat(std::uint32_t guestFormat);
VkComponentSwizzle TextureComponentChannel(std::uint32_t guestFormat, VkComponentSwizzle component);
std::uint32_t SrgbDecodeFormats(PFN_vkGetPhysicalDeviceFormatProperties formatProperties, VkPhysicalDevice physical);
std::uint32_t ScaledSampledFormats(PFN_vkGetPhysicalDeviceFormatProperties formatProperties, VkPhysicalDevice physical);
std::uint32_t OptionalSampledFormats(PFN_vkGetPhysicalDeviceFormatProperties formatProperties, VkPhysicalDevice physical);
VkFormat SampledTextureFormat(const Context& context, std::uint32_t guestFormat);
std::uint32_t SrgbCopyFormats(PFN_vkGetPhysicalDeviceFormatProperties formatProperties, VkPhysicalDevice physical, std::uint32_t decodeFormats);
bool SrgbExpandsToRgba8(const Context& context, std::uint32_t guestFormat);
@@ -0,0 +1,82 @@
#version 450
#extension GL_EXT_buffer_reference : require
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
layout(local_size_x = 256) in;
layout(buffer_reference, std430, buffer_reference_align = 4) buffer Words { uint words[]; };
layout(buffer_reference, std430, buffer_reference_align = 8) buffer Targets { u64vec4 targets[]; };
layout(push_constant) uniform Parameters {
Words fault;
Words pages;
Targets targets;
uint64_t base;
uint count;
uint slots;
uint writtenCountWord;
uint writtenSlotsWord;
uint writtenListWord;
uint overflowWord;
} parameters;
const uint PageShift = 12u;
const uint PageWords = 1024u;
const uint MaskWords = 128u;
const uint Probes = 16u;
const uint ChunkShift = 17u;
const uint ChunkPages = 32u;
const uint SlotLimit = 2048u;
const uint None = 0xffffffffu;
shared uint claimed;
uint claimPage(uint64_t address) {
uint key = uint((address - parameters.base) >> PageShift) + 1u;
uint hash = (key * 0x9e3779b1u) >> (32u - uint(findLSB(parameters.slots)));
for (uint probe = 0u; probe < Probes; ++probe) {
uint slot = (hash + probe) & (parameters.slots - 1u);
uint previous = atomicCompSwap(parameters.pages.words[slot], 0u, key);
if (previous == 0u) return slot;
if (previous == key) return None;
}
atomicOr(parameters.fault.words[parameters.overflowWord], 1u);
return None;
}
void main() {
uint claims = min(parameters.fault.words[parameters.writtenCountWord], SlotLimit);
for (uint claim = gl_WorkGroupID.x; claim < claims; claim += gl_NumWorkGroups.x) {
uint record = parameters.fault.words[parameters.writtenListWord + claim];
uint key = parameters.fault.words[parameters.writtenSlotsWord + 2u * record];
uint mask = parameters.fault.words[parameters.writtenSlotsWord + 2u * record + 1u];
uint64_t chunk = uint64_t(key - 1u) << ChunkShift;
for (uint page = 0u; page < ChunkPages; ++page) {
if ((mask & (1u << page)) == 0u) continue;
uint64_t address = chunk + (uint64_t(page) << PageShift);
uint first = parameters.count;
uint last = 0u;
for (uint index = 0u; index < parameters.count; ++index) {
u64vec4 span = parameters.targets.targets[index];
if (address + (1u << PageShift) <= span.x || address >= span.y) continue;
first = min(first, index);
last = index;
}
if (first == parameters.count) continue;
barrier();
if (gl_LocalInvocationIndex == 0u) claimed = claimPage(address);
barrier();
uint slot = claimed;
if (slot == None) continue;
uint data = parameters.slots * (1u + MaskWords) + slot * PageWords;
for (uint word = gl_LocalInvocationIndex; word < PageWords; word += gl_WorkGroupSize.x) {
uint64_t at = address + uint64_t(word) * 4u;
for (uint index = first; index <= last; ++index) {
u64vec4 span = parameters.targets.targets[index];
if (at < span.x || at + 4u > span.y) continue;
Words source = Words(span.z + (at - span.x));
parameters.pages.words[data + word] = source.words[0];
break;
}
}
}
}
}
@@ -1,4 +1,5 @@
#include "prx/libSceAgcDriver/Graphics/include/BdaResources.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Recorder.hpp"
#include "prx/libSceAgcDriver/Execution/include/Mutex.hpp"
#include "prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp"
#include "ImageTableAbi.hpp"
@@ -203,7 +204,7 @@ BdaResources::~BdaResources() {
auto& arena = found->second;
arena.holders.erase(this);
--arena.counts.held;
if (!sharedFaultSlots()) {
if (!sharedFaultSlots() || privateSlot) {
arena.counts.slots -= chunk->slots;
--arena.counts.chunks;
} else {
@@ -249,7 +250,7 @@ bool BdaResources::TakeFaultSlot(const Context& context) {
const bool retake = faultDevice != VK_NULL_HANDLE;
if (!retake) lastUse = arena.finished + 1;
faultDevice = context.device;
const bool shared = sharedFaultSlots();
const bool shared = sharedFaultSlots() && !privateSlot;
const auto slotBytes = shared ? faultSlotBytes(reportOnly) : VkDeviceSize{ShaderRecompiler::BdaAbi::FaultBufferBytes};
const auto withFree = [&] { return std::find_if(arena.chunks.rbegin(), arena.chunks.rend(), [&](const std::shared_ptr<BdaFaultChunk>& chunk) { return chunk->slotBytes == slotBytes && !chunk->free.empty(); }); };
auto source = shared ? withFree() : arena.chunks.rend();
@@ -257,7 +258,7 @@ bool BdaResources::TakeFaultSlot(const Context& context) {
if (shared && source == arena.chunks.rend() && GuestMemory::GpuMutex().HeldByThisThread()) {
std::vector<BdaResources*> idle;
for (auto* holder : arena.holders) {
if (holder->faultChunk->slotBytes == slotBytes && holder->lastUse <= arena.finished && faultSlotClean(holder->faultBytes())) idle.push_back(holder);
if (!holder->privateSlot && holder->faultChunk->slotBytes == slotBytes && holder->lastUse <= arena.finished && faultSlotClean(holder->faultBytes())) idle.push_back(holder);
}
if (!idle.empty()) {
const auto reclaim = (idle.size() + 1) / 2;
@@ -281,7 +282,9 @@ bool BdaResources::TakeFaultSlot(const Context& context) {
const auto stride = shared ? faultStride(context, slotBytes) : slotBytes;
const auto slots = shared ? std::max<VkDeviceSize>(1, FaultChunkBytes / stride) : 1;
chunk = std::make_shared<BdaFaultChunk>();
chunk->buffer = std::make_unique<Buffer>(context, static_cast<std::size_t>(stride * slots), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
VkBufferUsageFlags usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
if (privateSlot) usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
chunk->buffer = std::make_unique<Buffer>(context, static_cast<std::size_t>(stride * slots), usage);
std::memset(chunk->buffer->Bytes().data(), 0, chunk->buffer->Bytes().size());
chunk->slots = static_cast<std::size_t>(slots);
chunk->slotBytes = slotBytes;
@@ -310,7 +313,44 @@ bool BdaResources::TakeFaultSlot(const Context& context) {
return true;
}
BdaResources::BdaResources(const Context& context, const GuestBufferMemory& memory, bool reportOnly) : BdaResources(context, reportOnly) {
std::uint32_t BdaResources::StorePageSlots() {
static const std::uint32_t slots = [] {
const char* value = std::getenv("APS5_BDA_STORE_PAGES");
const auto parsed = value != nullptr ? std::strtoull(value, nullptr, 10) : 1024ull;
return std::bit_ceil(static_cast<std::uint32_t>(std::clamp<unsigned long long>(parsed, 64, 65536)));
}();
return slots;
}
BdaResources::BdaResources(const Context& context, const GuestBufferMemory& memory, bool reportOnly) : reportOnly(reportOnly) {
namespace Abi = ShaderRecompiler::BdaAbi;
static_assert(std::endian::native == std::endian::little);
Require(Abi::FaultBufferBytes <= context.limits.maxStorageBufferRange, "BDA fault buffer exceeds storage buffer range limit");
const auto spans = memory.AddressStoreSpans();
privateSlot = !spans.empty();
TakeFaultSlot(context);
if (!spans.empty()) {
pageSlots = StorePageSlots();
pageBase = spans.front().begin / Abi::StorePageBytes * Abi::StorePageBytes;
Require(spans.back().end - pageBase <= Abi::StorePageSpan, "heap mirrors stored through addresses that span more than 16 TiB are not implemented");
poolDevice = context.device;
if (auto* recorder = Recorder::Active(); recorder != nullptr && recorder->Device() == context.device) pages = recorder->TakeStorePagePool(Abi::StorePagePoolBytes(pageSlots));
if (pages == nullptr) {
pages = std::make_unique<Buffer>(context, Abi::StorePagePoolBytes(pageSlots), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
std::memset(pages->Bytes().data(), 0, Abi::StorePagePoolBytes(pageSlots));
}
std::vector<std::uint64_t> words;
for (const auto& span : spans) {
if (!span.resident) continue;
words.insert(words.end(), {span.begin, span.end, span.device, 0});
++targetCount;
}
if (targetCount != 0) {
targets = std::make_unique<Buffer>(context, words.size() * sizeof(std::uint64_t), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
std::memcpy(targets->Bytes().data(), words.data(), words.size() * sizeof(std::uint64_t));
}
attachStorePages();
}
const auto cached = memory.CachedAddressTable();
std::vector<ShaderRecompiler::BdaAbi::Range> built;
if (!cached.has_value()) built = memory.AddressRanges();
@@ -427,6 +467,53 @@ VkDescriptorBufferInfo BdaResources::Table() const {
return {table->Handle(), 0, tableBytes};
}
void BdaResources::attachStorePages() const {
namespace Abi = ShaderRecompiler::BdaAbi;
if (pages == nullptr) return;
auto* words = reinterpret_cast<std::uint32_t*>(faultBytes().data());
const auto address = pages->DeviceAddress();
words[Abi::StorePagesWord] = static_cast<std::uint32_t>(address);
words[Abi::StorePagesWord + 1] = static_cast<std::uint32_t>(address >> 32u);
words[Abi::StorePageBaseWord] = static_cast<std::uint32_t>(pageBase);
words[Abi::StorePageBaseWord + 1] = static_cast<std::uint32_t>(pageBase >> 32u);
words[Abi::StorePageSlotsWord] = pageSlots;
words[Abi::StorePageOverflowWord] = 0;
}
void BdaResources::RecordStorePageGather(Recorder& recorder) const {
if (pages == nullptr || targetCount == 0) return;
recorder.RecordStorePageGather(recorder.Commands(), {faultChunk->buffer->DeviceAddress() + faultOffset, pages->DeviceAddress(), targets->DeviceAddress(), pageBase, targetCount, pageSlots});
}
std::vector<GuestBufferMemory::StorePage> BdaResources::TakeStorePages() const {
return std::exchange(storePages, {});
}
void BdaResources::collectStorePages() const {
namespace Abi = ShaderRecompiler::BdaAbi;
storePages.clear();
if (pages == nullptr) return;
auto* faultWords = reinterpret_cast<std::uint32_t*>(faultBytes().data());
pagesOverflowed = faultWords[Abi::StorePageOverflowWord] != 0;
faultWords[Abi::StorePageOverflowWord] = 0;
auto* bytes = pages->Bytes().data();
auto* words = reinterpret_cast<std::uint32_t*>(bytes);
for (std::uint32_t slot = 0; slot < pageSlots; ++slot) {
if (words[slot] == 0) continue;
GuestBufferMemory::StorePage page;
page.address = pageBase + (static_cast<std::uint64_t>(words[slot] - 1u) << Abi::StorePageShift);
auto* data = bytes + Abi::StorePageWord(pageSlots, slot) * sizeof(std::uint32_t);
auto* mask = words + Abi::StoreMaskWord(pageSlots, slot);
page.data.assign(data, data + Abi::StorePageBytes);
std::copy(mask, mask + Abi::StoreMaskWords, page.mask.begin());
std::memset(data, 0, Abi::StorePageBytes);
std::memset(mask, 0, Abi::StoreMaskWords * sizeof(std::uint32_t));
words[slot] = 0;
storePages.push_back(std::move(page));
}
if (auto* recorder = Recorder::Active(); recorder != nullptr && recorder->Device() == poolDevice) recorder->KeepStorePagePool(std::move(pages));
}
std::span<const std::byte> BdaResources::TableBytes() const {
if (table == nullptr) return {};
return table->Bytes().first(tableBytes);
@@ -477,11 +564,13 @@ void BdaResources::CheckUse(const BdaResources* record) const {
void BdaResources::checkFault(const BdaResources& record) const {
if (record.faultChunk == nullptr) return;
record.collectStorePages();
if (!reportOnly) markWrittenPages(record);
ShaderRecompiler::BdaAbi::Fault report{};
std::memcpy(&report, record.faultBytes().data(), sizeof(report));
if (report.state == ShaderRecompiler::BdaAbi::FaultState::Empty) {
Require(static_cast<std::uint32_t>(report.reason) == 0 && report.address == 0 && report.bytes == 0 && report.stage == 0 && report.instruction == 0 && report.claim == 0, "BDA fault record has data without publication");
if (record.pagesOverflowed) Require(false, "the GPU stored to more pages of resident heap mirrors in one use than the " + std::to_string(record.pageSlots) + " store pages hold (APS5_BDA_STORE_PAGES)");
if (!reportOnly) checkSrtGuard(record);
return;
}
@@ -492,6 +581,7 @@ void BdaResources::checkFault(const BdaResources& record) const {
loopGuardTripped.store(true, std::memory_order_relaxed);
std::fprintf(stderr, "[gpu] loop guard: the loop exit at pc 0x%x of shader 0x%llx ran past %u evaluations\n", report.instruction, static_cast<unsigned long long>(report.address), report.bytes);
std::memset(record.faultBytes().data(), 0, record.faultBytes().size());
record.attachStorePages();
return;
}
if (report.reason == ShaderRecompiler::BdaAbi::FaultReason::ImageTable) {
@@ -522,6 +612,10 @@ void BdaResources::checkFault(const BdaResources& record) const {
message << "shader stage " << report.stage << ": a split table call part resumed a lane whose s" << report.bytes << " holds 0x" << std::hex << (report.address & 0xffffffffu) << ", but the part was compiled for the value 0x" << (report.address >> 32u) << " that the program sets before the loop, because only callees write that register";
throw std::runtime_error(message.str());
}
if (report.reason == ShaderRecompiler::BdaAbi::FaultReason::StorePages) {
message << "BDA store at 0x" << std::hex << report.address << std::dec << " (" << report.bytes << " bytes, instruction 0x" << std::hex << report.instruction << std::dec << ") into a heap mirror found none of the " << pageSlots << " store pages free (APS5_BDA_STORE_PAGES)";
throw std::runtime_error(message.str());
}
if (report.reason == ShaderRecompiler::BdaAbi::FaultReason::WindowLaneSpill) {
message << "shader stage " << report.stage << ": a relative write stored " << report.bytes << " in lane " << (report.address >> 32u) << " of vector window slot " << (report.address & 0xffffffffu) << ", which holds a scalar spilled with v_writelane_b32 that a later v_readlane_b32 was replaced with";
throw std::runtime_error(message.str());
@@ -576,6 +670,10 @@ void BdaResources::checkSrtGuard(const BdaResources& faults) const {
throw std::runtime_error(message.str());
}
std::vector<std::pair<std::uint64_t, std::uint64_t>> BdaResources::TakeWrittenPages() const {
return std::exchange(writtenPages, {});
}
void BdaResources::markWrittenPages(const BdaResources& record) const {
namespace Abi = ShaderRecompiler::BdaAbi;
auto* words = reinterpret_cast<std::uint32_t*>(record.faultBytes().data());
@@ -592,6 +690,7 @@ void BdaResources::markWrittenPages(const BdaResources& record) const {
}
}
GuestMemory::MarkPossiblyWritten(begin, bytes);
writtenPages.emplace_back(begin, end);
}), "invalid BDA written-page record");
for (std::uint32_t claim = 0; claim < count; ++claim) {
const auto slot = words[Abi::WrittenListWord + claim];
@@ -484,6 +484,24 @@ std::size_t DccKeyCount(const GuestTextureResource& surface, std::uint64_t surfa
return DccKeyCount(surface.tileMode, BytesPerElement(surface.format), surface.width, surface.height, surfaceBytes);
}
std::size_t DccMipKeySlice(std::uint32_t width, std::uint32_t height, std::uint32_t elementBytes) {
constexpr std::uint32_t MetaBlockEdge = 512;
constexpr std::size_t MetaBlockKeys = 4096;
const auto MetaBlockHeight = 1048576u / MetaBlockEdge / elementBytes;
const auto pitch = (width + MetaBlockEdge - 1u) / MetaBlockEdge;
const auto rows = (height + MetaBlockHeight - 1u) / MetaBlockHeight;
return static_cast<std::size_t>(pitch) * rows * MetaBlockKeys;
}
std::optional<std::size_t> DccMipKeyOffset(std::uint32_t width, std::uint32_t height, std::uint32_t elementBytes, std::uint32_t mipCount, std::uint32_t firstTailLevel, std::uint32_t level) {
if (level >= mipCount) return std::nullopt;
if (level >= firstTailLevel) return std::size_t{0};
const auto shiftCeil = [](std::uint32_t extent, std::uint32_t shift) { return std::max<std::uint32_t>((extent + (1u << shift) - 1u) >> shift, 1u); };
std::size_t offset = firstTailLevel < mipCount ? 4096u : 0u;
for (auto above = firstTailLevel; above-- > level + 1u;) offset += DccMipKeySlice(shiftCeil(width, above), shiftCeil(height, above), elementBytes);
return offset;
}
namespace {
// ReadDccKeys, saying in `memoized` whether the answer came from the pending-store memo rather
@@ -583,6 +601,21 @@ DccKeys CurrentDccKeys(std::uint64_t metaAddress, std::uint64_t surfaceBytes, st
return currentDccKeys(metaAddress, keyCount, memoized);
}
DccKeys LandedDccKeys(std::uint64_t metaAddress, std::uint64_t surfaceBytes, std::size_t keyCount) {
Require(keyCount >= DccKeyBytes(surfaceBytes), "a DCC key range covers fewer keys than one per 256 surface bytes");
if (metaAddress == 0 || keyCount == 0 || !GuestMemory::GpuMutex().HeldByThisThread()) {
return CurrentDccKeys(metaAddress, surfaceBytes, keyCount);
}
auto* recorder = Recorder::Active();
if (recorder == nullptr || !recorder->PendingWriteOverlaps(metaAddress, keyCount)) {
return CurrentDccKeys(metaAddress, surfaceBytes, keyCount);
}
if (AnyShadowedOverlaps(metaAddress, keyCount)) return DccKeys::Unreadable;
const auto landed = KeysAfterPendingWrites(*recorder, metaAddress, keyCount);
if (landed.mixed || landed.unknown || landed.value < 0) return DccKeys::Unreadable;
return ByteKeys(static_cast<std::uint8_t>(landed.value));
}
std::optional<std::uint8_t> CurrentUniformMetadataByte(std::uint64_t address, std::size_t bytes) {
if (address == 0 || bytes == 0 || !GuestMemory::Accessible(reinterpret_cast<const void*>(address), bytes)) return std::nullopt;
if (GuestMemory::GpuMutex().HeldByThisThread()) {
@@ -1,6 +1,7 @@
#include "prx/libSceAgcDriver/Graphics/include/MemoryAccounting.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp"
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
#include "prx/libSceAgcDriver/Execution/include/ThreadScratch.hpp"
#include "prx/libc/include/HostThreadSlot.hpp"
#include "prx/libc/include/GuestAllocations.hpp"
#include "prx/libc/include/PrimedSharedMutex.hpp"
@@ -96,6 +97,8 @@ bool singleComponent(VkFormat format, std::uint32_t bytes) {
std::atomic<bool> depthTransferPasses{std::getenv("APS5_NO_DEPTH_TRANSFER_PASS") == nullptr};
std::atomic<std::uint64_t> depthTransferPassCount{0};
std::atomic<std::uint64_t> armedHtileClears{0};
std::atomic<std::uint64_t> discardedHtileClears{0};
bool depthToStoragePass(const Context& context, VkFormat depthFormat, VkFormat colorFormat) {
if (!context.pushDescriptors || !depthTransferPasses.load(std::memory_order_relaxed)) return false;
@@ -929,6 +932,11 @@ std::pair<std::uint64_t, std::uint64_t> staleStencilRange(const DepthSurface& su
void noteStalePlane(std::uint64_t begin, std::uint64_t end);
std::uint64_t nextPlaneSerial();
float quantizeDepth(VkFormat format, VkFormat hostFormat, float depth) {
if (format != VK_FORMAT_D16_UNORM_S8_UINT || hostFormat == format) return depth;
return std::rint(std::clamp(depth, 0.0f, 1.0f) * 65535.0f) * (1.0f / 65535.0f);
}
class DepthSurface {
public:
DepthSurface(const Context& context, const DepthTarget& target, DepthSamplingState sampling = {}) : context(context), target(target), hostFormat(HostDepthFormat(context, target.format)), sampling(std::move(sampling)) {
@@ -1007,7 +1015,7 @@ public:
toGeneral.subresourceRange = viewInfo.subresourceRange;
const auto barrier = context.Resolved(&DeviceFunctions::cmdPipelineBarrier, "vkCmdPipelineBarrier");
barrier(commands, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &toGeneral);
const VkClearDepthStencilValue clear{this->sampling.initialDepth.value_or(target.clearDepth), this->sampling.initialStencil.value_or(this->sampling.aliasStencil.value_or(target.clearStencil))};
const VkClearDepthStencilValue clear{quantizeDepth(target.format, hostFormat, this->sampling.initialDepth.value_or(target.clearDepth)), this->sampling.initialStencil.value_or(this->sampling.aliasStencil.value_or(target.clearStencil))};
context.Function<PFN_vkCmdClearDepthStencilImage>("vkCmdClearDepthStencilImage")(commands, image, VK_IMAGE_LAYOUT_GENERAL, &clear, 1, &toGeneral.subresourceRange);
RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT);
std::vector<std::shared_ptr<void>> imported;
@@ -1150,7 +1158,7 @@ public:
const bool htile = resource.dccAddress == target.htileAddress && resource.dccPipeAligned == target.htilePipeAligned;
const bool bare = resource.dccAddress == 0u && !resource.dccPipeAligned;
if (stencil) {
Require(resource.pipeBankXor == target.pipeBankXor && bare && !resource.dccAlphaOnMsb && !target.htileStencil && target.htileDepthOnly, "native multisample depth sampled metadata or XOR mismatch");
Require(resource.pipeBankXor == target.pipeBankXor && bare && !resource.dccAlphaOnMsb && ((!target.htileStencil && target.htileDepthOnly) || expanded), "native multisample depth sampled metadata or XOR mismatch");
return;
}
const bool layout = resource.pipeBankXor == target.pipeBankXor && resource.iterate256 == target.iterate256 && !resource.dccAlphaOnMsb;
@@ -1204,7 +1212,7 @@ public:
else {
const VkImageSubresourceRange range{aspects, 0, 1, 0, 1};
RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, access, VK_ACCESS_TRANSFER_WRITE_BIT);
const VkClearDepthStencilValue clear{depth, stencil};
const VkClearDepthStencilValue clear{quantizeDepth(target.format, hostFormat, depth), stencil};
context.Function<PFN_vkCmdClearDepthStencilImage>("vkCmdClearDepthStencilImage")(commands, image, VK_IMAGE_LAYOUT_GENERAL, &clear, 1, &range);
RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, access);
}
@@ -2698,7 +2706,8 @@ public:
std::snprintf(text, sizeof(text), "AGC graphics: depth plane copy geometry does not match its layers (copy %ux%u, %u layers, %llu bytes a slice; texture %ux%u guest format %u, dimension %d, tile mode %d, %u layers, %llu bytes a slice, %zu mips)", extent.width, extent.height, layers, static_cast<unsigned long long>(sliceBytes()), resource.width, resource.height, resource.format, static_cast<int>(resource.dimension), static_cast<int>(resource.tileMode), geometry.layers, static_cast<unsigned long long>(geometry.sliceLinearBytes), geometry.mips.size());
throw std::runtime_error(text);
}
const auto stagingBytes = std::max<std::size_t>(static_cast<std::size_t>(geometry.sliceLinearBytes), static_cast<std::size_t>(sliceBytes())) * requested;
const auto stagingLayerStride = (std::max<VkDeviceSize>(geometry.sliceLinearBytes, sliceBytes()) + 3u) & ~VkDeviceSize{3u};
const auto stagingBytes = static_cast<std::size_t>(stagingLayerStride * requested);
std::vector<std::shared_ptr<Buffer>> uploads;
std::vector<std::uint32_t> uploadLayers;
std::vector<std::uint32_t> copiedLayers;
@@ -2713,10 +2722,10 @@ public:
continue;
}
surface = {};
GuestLayer current{resource.baseAddress + geometry.GuestLayerOffset(layer), geometry.layerBytes, resource.tileMode, geometry.thick, GuestMemory::CollectWrites(resource.baseAddress + geometry.GuestLayerOffset(layer), static_cast<std::size_t>(geometry.layerBytes))};
GuestLayer current{resource.baseAddress + geometry.GuestLayerOffset(layer), geometry.layerBytes, resource.tileMode, resource.pipeBankXor, geometry.thick, GuestMemory::CollectWrites(resource.baseAddress + geometry.GuestLayerOffset(layer), static_cast<std::size_t>(geometry.layerBytes))};
current.uncommitted = current.generation == 0 && GuestMemory::CommittedRanges(current.address, static_cast<std::size_t>(current.bytes)).empty();
const bool unchanged = current.uncommitted ? held.uncommitted : held.generation != 0 && GuestMemory::UnchangedSince(current.address, static_cast<std::size_t>(current.bytes), held.generation);
if (held.address == current.address && held.bytes == current.bytes && held.tileMode == current.tileMode && held.thick == current.thick && !Recorder::SnapshotWriteOverlaps(current.address, static_cast<std::size_t>(current.bytes)) && unchanged) {
if (held.address == current.address && held.bytes == current.bytes && held.tileMode == current.tileMode && held.pipeBankXor == current.pipeBankXor && held.thick == current.thick && !Recorder::SnapshotWriteOverlaps(current.address, static_cast<std::size_t>(current.bytes)) && unchanged) {
held.generation = current.generation;
continue;
}
@@ -2728,7 +2737,7 @@ public:
}
if (!copiedLayers.empty() || !uploads.empty()) {
if (staging == nullptr || stagingBytes > staging->Size()) staging = std::make_shared<DeviceBuffer>(context, stagingBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
record(slices, resource, geometry, copiedLayers, uploads, uploadLayers, staging);
record(slices, resource, geometry, copiedLayers, uploads, uploadLayers, staging, stagingLayerStride);
}
const auto viewLayers = viewType == VK_IMAGE_VIEW_TYPE_2D ? 1u : requested - baseLayer;
const std::array<std::uint32_t, 7> key{static_cast<std::uint32_t>(components.r), static_cast<std::uint32_t>(components.g), static_cast<std::uint32_t>(components.b), static_cast<std::uint32_t>(components.a), static_cast<std::uint32_t>(viewType), baseLayer, viewLayers};
@@ -2754,6 +2763,7 @@ private:
std::uint64_t address = 0;
std::uint64_t bytes = 0;
TextureTileMode tileMode = TextureTileMode::kLinear;
std::uint32_t pipeBankXor = 0;
bool thick = false;
std::uint64_t generation = 0;
bool uncommitted = false;
@@ -2768,7 +2778,7 @@ private:
std::vector<DepthPlaneSlice> surfaceLayers;
bool filled = false;
void record(std::span<const DepthPlaneSlice> slices, const GuestTextureResource& resource, const SurfaceGeometry& geometry, std::span<const std::uint32_t> copiedLayers, std::span<const std::shared_ptr<Buffer>> uploads, std::span<const std::uint32_t> uploadLayers, const std::shared_ptr<DeviceBuffer>& staging) {
void record(std::span<const DepthPlaneSlice> slices, const GuestTextureResource& resource, const SurfaceGeometry& geometry, std::span<const std::uint32_t> copiedLayers, std::span<const std::shared_ptr<Buffer>> uploads, std::span<const std::uint32_t> uploadLayers, const std::shared_ptr<DeviceBuffer>& staging, VkDeviceSize stagingLayerStride) {
if (!uploads.empty()) {
Require(context.detiler != nullptr, "depth plane copy requires a texture detiler");
context.detiler->BeginBatch();
@@ -2783,14 +2793,14 @@ private:
const auto& mip = geometry.mips.front();
const auto region = [&](std::uint32_t layer, VkImageAspectFlags aspectMask, std::uint32_t imageLayer) {
VkBufferImageCopy copy{};
copy.bufferOffset = geometry.LinearLayerOffset(layer) + mip.linearOffset;
copy.bufferRowLength = mip.pitchBytes / (format == VK_FORMAT_D32_SFLOAT ? 4u : 2u);
copy.bufferOffset = static_cast<VkDeviceSize>(layer) * stagingLayerStride + mip.linearOffset;
copy.bufferRowLength = mip.pitchBytes / texelBytes();
copy.imageSubresource = {aspectMask, 0, imageLayer, 1};
copy.imageExtent = {extent.width, extent.height, 1};
return copy;
};
for (const auto layer : copiedLayers) {
const auto copy = region(layer, VK_IMAGE_ASPECT_DEPTH_BIT, 0);
const auto copy = region(layer, sourceAspect(), 0);
context.Function<PFN_vkCmdCopyImageToBuffer>("vkCmdCopyImageToBuffer")(commands, slices[layer].image, VK_IMAGE_LAYOUT_GENERAL, staging->Handle(), 1, &copy);
regions.push_back(region(layer, aspect(), layer));
}
@@ -2798,7 +2808,7 @@ private:
RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
for (std::size_t upload = 0; upload < uploads.size(); ++upload) {
const auto layer = uploadLayers[upload];
context.detiler->Dispatch(commands, resource.tileMode, format == VK_FORMAT_D32_SFLOAT ? 4u : 2u, uploads[upload]->Handle(), 0, staging->Handle(), geometry.LinearLayerOffset(layer), geometry.mips.front(), false, layer, geometry.thick);
context.detiler->Dispatch(commands, resource.tileMode, texelBytes(), uploads[upload]->Handle(), 0, staging->Handle(), static_cast<std::uint64_t>(layer) * stagingLayerStride, geometry.mips.front(), false, layer, geometry.thick, {.pipeBankXor = resource.pipeBankXor});
regions.push_back(region(layer, aspect(), layer));
}
if (recorder != nullptr) {
@@ -2832,12 +2842,20 @@ private:
}
}
std::uint32_t texelBytes() const {
return format == VK_FORMAT_D32_SFLOAT ? 4u : (format == VK_FORMAT_R8_UINT || format == VK_FORMAT_R8_UNORM) ? 1u : 2u;
}
VkDeviceSize sliceBytes() const {
return static_cast<VkDeviceSize>(extent.width) * extent.height * (format == VK_FORMAT_D32_SFLOAT ? 4u : 2u);
return static_cast<VkDeviceSize>(extent.width) * extent.height * texelBytes();
}
VkImageAspectFlags sourceAspect() const {
return (format == VK_FORMAT_R8_UINT || format == VK_FORMAT_R8_UNORM) ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
}
VkImageAspectFlags aspect() const {
return format == VK_FORMAT_R16_UINT ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
return (format == VK_FORMAT_R16_UINT || format == VK_FORMAT_R8_UINT || format == VK_FORMAT_R8_UNORM) ? VK_IMAGE_ASPECT_COLOR_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
}
void release() noexcept {
@@ -3100,6 +3118,14 @@ DepthSurface* planeSurface(VkDevice device, std::uint64_t address) {
return found == list.rend() ? nullptr : found->get();
}
DepthSurface* stencilSlice(VkDevice device, std::uint64_t address, const DepthTarget& base) {
auto* owner = planeSurface(device, address);
if (owner == nullptr || owner->retired) return nullptr;
const auto& target = owner->target;
if (target.samples != 1u || target.stencilAddress == 0 || target.stencilAddress != address || target.extent.width != base.extent.width || target.extent.height != base.extent.height || !HasStencil(owner->hostFormat)) return nullptr;
return owner;
}
void settlePendingHtileClear(const Context& context, std::uint64_t address) {
if (Recorder::InCompletion()) return;
auto* recorder = RecorderFor(context);
@@ -3160,6 +3186,31 @@ DepthSurface* drawnDepth = nullptr;
std::atomic<std::uint64_t> surfacesSerial{0};
std::atomic<std::uint64_t> surfacesReleased{0};
std::atomic<std::uint64_t> storageScans{0};
struct UnclaimedAddressesTag {};
struct UnclaimedAddresses {
struct Entry {
VkDevice device = VK_NULL_HANDLE;
std::uint64_t address = 0;
std::uint64_t serial = 0;
};
std::array<Entry, 32> entries{};
Entry& Slot(std::uint64_t address) {
return entries[static_cast<std::size_t>((address >> 8u) * 0x9E3779B97F4A7C15ull >> 59u)];
}
bool Holds(VkDevice device, std::uint64_t address, std::uint64_t serial) {
const auto& entry = Slot(address);
return entry.device == device && entry.address == address && entry.serial == serial;
}
void Remember(VkDevice device, std::uint64_t address, std::uint64_t serial) {
Slot(address) = {device, address, serial};
}
};
void retire(DepthSurface& surface);
@@ -3279,11 +3330,16 @@ bool DepthSurface::PublishToGuest(DepthReadCause cause) {
if (GuestMemory::StoredAllSince_nid_no_patch(address, bytes, plane.range.generation)) {
if (!std::equal(current[index].begin() + first, current[index].begin() + first + bytes, result[index].begin() + first)) tookGuest[index] = true;
std::copy_n(current[index].begin() + first, bytes, result[index].begin() + first);
} else for (std::size_t offset = first; offset < first + bytes; ++offset) {
if (current[index][offset] != plane.Byte(offset) || current[index][offset] == result[index][offset] || GuestMemory::StoredAllSince_nid_no_patch(plane.range.address + offset, 1u, plane.range.generation)) {
if (current[index][offset] != result[index][offset]) tookGuest[index] = true;
result[index][offset] = current[index][offset];
} else if (!GuestMemory::UnchangedSinceLastCollect(plane.range.address + offset, 1u, plane.range.generation)) {
} else {
std::optional<bool> pageUnstored;
for (std::size_t offset = first; offset < first + bytes; ++offset) {
if (current[index][offset] != plane.Byte(offset) || current[index][offset] == result[index][offset] || GuestMemory::StoredAllSince_nid_no_patch(plane.range.address + offset, 1u, plane.range.generation)) {
if (current[index][offset] != result[index][offset]) tookGuest[index] = true;
result[index][offset] = current[index][offset];
continue;
}
if (!pageUnstored) pageUnstored = GuestMemory::StoreUnchangedSinceLastCollect(address, bytes, plane.range.generation);
if (*pageUnstored || GuestMemory::StoreUnchangedSinceLastCollect(plane.range.address + offset, 1u, plane.range.generation)) continue;
Require(cause != DepthReadCause::Access && cause != DepthReadCause::Write, "native multisample depth publication cannot distinguish an unwritten byte from a same-value guest store");
tookGuest[index] = true;
result[index][offset] = current[index][offset];
@@ -3312,15 +3368,21 @@ bool DepthSurface::PublishToGuest(DepthReadCause cause) {
if (const auto hook = depthPublicationHook.load(std::memory_order_acquire)) hook(DepthPublicationStage::PlaneCommitted);
}
publicationFailed = false;
bool publishedExpanded = htile;
for (std::size_t index = 0u; index < publication.size(); ++index) {
const auto& range = sampling.initial[index];
const bool whole = live[index].size() == 1u && live[index][0].address == range.address && live[index][0].bytes == range.bytes;
if (tookGuest[index] || !whole) continue;
if (tookGuest[index] || !whole) {
publishedExpanded = false;
continue;
}
const auto generation = GuestMemory::CollectWritesUncached(range.address, range.bytes);
std::vector<std::byte> committed(range.bytes);
GuestMemory::CopyGuestBytes(committed.data(), reinterpret_cast<const void*>(range.address), range.bytes);
if (committed == result[index]) sampling.initial[index].generation = generation;
else publishedExpanded = false;
}
if (publishedExpanded) expanded = true;
hostWritten->store(false, std::memory_order_release);
publication.clear();
if (superseded[0]) RetireMultisampleColorTarget(sampling.depthAlias->active);
@@ -3805,6 +3867,10 @@ std::uint64_t DepthSurfacesSerial() {
return surfacesSerial.load(std::memory_order_acquire);
}
std::uint64_t DepthSurfaceStorageScans() {
return storageScans.load(std::memory_order_relaxed);
}
std::uint64_t DepthSurfacesReleased() {
return surfacesReleased.load(std::memory_order_acquire);
}
@@ -4034,10 +4100,17 @@ bool SampleLocationsCompatibleDepth(const Context& context, VkFormat format, std
VkFormat HostDepthFormat(const Context& context, VkFormat format) {
if (format != VK_FORMAT_D16_UNORM_S8_UINT) return format;
thread_local VkPhysicalDevice lastPhysical = VK_NULL_HANDLE;
thread_local VkFormat lastFormat = VK_FORMAT_UNDEFINED;
if (context.physical == lastPhysical && lastFormat != VK_FORMAT_UNDEFINED) return lastFormat;
static AgcDriver::Mutex mutex;
static std::map<VkPhysicalDevice, VkFormat> chosen;
std::lock_guard lock(mutex);
if (const auto found = chosen.find(context.physical); found != chosen.end()) return found->second;
if (const auto found = chosen.find(context.physical); found != chosen.end()) {
lastPhysical = context.physical;
lastFormat = found->second;
return found->second;
}
constexpr VkFormatFeatureFlags required = VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
auto host = format;
for (const auto candidate : {VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT_S8_UINT}) {
@@ -4048,6 +4121,8 @@ VkFormat HostDepthFormat(const Context& context, VkFormat format) {
break;
}
chosen.emplace(context.physical, host);
lastPhysical = context.physical;
lastFormat = host;
return host;
}
@@ -4679,6 +4754,7 @@ bool NoteHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes, std::siz
void ArmHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes) {
std::lock_guard lock(surfacesMutex());
armedHtileClears.fetch_add(1, std::memory_order_relaxed);
for (const auto& surface : surfaces()) {
if (!surface->active->load(std::memory_order_acquire) || !surface->samplingActive || surface->target.htileAddress != htileAddress || !surface->clearPending) continue;
const auto& metadata = surface->sampling.initial[1];
@@ -4689,30 +4765,54 @@ void ArmHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes) {
}
}
void QueueHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes) {
void QueueHtileDepthClear(HtileClearDispatch& dispatch, std::uint64_t htileAddress, std::size_t bytes) {
std::lock_guard lock(surfacesMutex());
for (const auto& surface : surfaces()) {
if (!surface->active->load(std::memory_order_acquire) || !surface->samplingActive || surface->target.htileAddress != htileAddress) continue;
if (bytes < surface->sampling.initial[1].bytes) continue;
++surface->clearDispatchesPending;
dispatch.surfaces.push_back(surface->active);
if (surface->clearGeneration == 0u || !surface->sampling.refusal.empty()) continue;
surface->clearCompletionQueued = true;
}
}
void CompleteHtileDepthClear(std::uint64_t htileAddress, std::size_t bytes) {
namespace {
void releaseHtileClearDispatch(const HtileClearDispatch& dispatch) {
for (const auto& surface : surfaces()) {
if (std::ranges::none_of(dispatch.surfaces, [&](const auto& active) { return active.get() == surface->active.get(); })) continue;
if (surface->clearDispatchesPending != 0u && --surface->clearDispatchesPending == 0u) surface->clearCompletionQueued = false;
}
}
}
void CompleteHtileDepthClear(const HtileClearDispatch& dispatch, std::uint64_t htileAddress, std::size_t bytes) {
std::lock_guard lock(surfacesMutex());
releaseHtileClearDispatch(dispatch);
for (const auto& surface : surfaces()) {
if (!surface->active->load(std::memory_order_acquire) || !surface->samplingActive || surface->target.htileAddress != htileAddress) continue;
const auto& metadata = surface->sampling.initial[1];
if (bytes < metadata.bytes) continue;
if (surface->clearDispatchesPending != 0u && --surface->clearDispatchesPending == 0u) surface->clearCompletionQueued = false;
if (surface->clearGeneration == 0u) continue;
Require(GuestMemory::UnchangedSinceCollected(metadata.address, metadata.bytes, surface->clearGeneration), "CPU writes raced native multisample depth clear");
GuestMemory::MarkWritten(metadata.address, metadata.bytes);
}
}
void DiscardHtileDepthClear(const HtileClearDispatch& dispatch, std::uint64_t htileAddress, std::size_t bytes) {
std::lock_guard lock(surfacesMutex());
discardedHtileClears.fetch_add(1, std::memory_order_relaxed);
releaseHtileClearDispatch(dispatch);
for (const auto& surface : surfaces()) {
if (!surface->active->load(std::memory_order_acquire) || !surface->samplingActive || surface->target.htileAddress != htileAddress || surface->clearGeneration == 0u) continue;
if (bytes < surface->sampling.initial[1].bytes) continue;
surface->clearCompletionQueued = false;
surface->sampling.Refuse("native multisample depth clear dispatch was discarded before it ran");
}
}
void ClearDepthSurfaces(VkDevice device) {
std::lock_guard gpu(GuestMemory::GpuMutex());
{
@@ -4819,8 +4919,9 @@ std::shared_ptr<Texture> DepthSurfaceTexture(const Context& context, std::span<c
if (!stencil && format != (d16 ? VK_FORMAT_R16_UNORM : VK_FORMAT_R32_SFLOAT) && !depthBits && !integer) return nullptr;
const bool cube = resource.dimension == TextureDimension::kCube;
const bool layered = cube || (resource.dimension == TextureDimension::k2DArray && resource.depthOrLastArray != 0);
const bool sampled = !cropped && (stencil || (!layered && !integer));
const auto copyFormat = integer ? VK_FORMAT_R16_UINT : d16 ? VK_FORMAT_R16_UNORM : VK_FORMAT_R32_SFLOAT;
const bool sampled = !cropped && !layered && (stencil || !integer);
const bool stencilUnorm = stencil && format == VK_FORMAT_R8_UNORM;
const auto copyFormat = stencil ? (stencilUnorm ? VK_FORMAT_R8_UNORM : VK_FORMAT_R8_UINT) : integer ? VK_FORMAT_R16_UINT : d16 ? VK_FORMAT_R16_UNORM : VK_FORMAT_R32_SFLOAT;
const bool planes = (format == copyFormat || depthBits) && resource.lastLevel == 0 && !(resource.baseArray != 0 && (cube || !layered || resource.baseArray > resource.depthOrLastArray)) && !(cube && resource.depthOrLastArray != 0 && (resource.depthOrLastArray + 1u) % 6u != 0u) && (resource.dimension == TextureDimension::k2D || resource.dimension == TextureDimension::k2DArray || cube);
if (!(sampled ? found->SampledAccepts(words, resource) : planes) && (found->OverwrittenInMemory() || found->OverwrittenOnGpu())) {
retireStoringStale(*found);
@@ -4829,27 +4930,31 @@ std::shared_ptr<Texture> DepthSurfaceTexture(const Context& context, std::span<c
if (sampled && !stencil && mirrorable(base)) found->SyncFromMemory(mirrorResource(base));
found->ApplyFastClear();
if (sampled) return found->Sampled(words, resource, components, found == drawnDepth);
Require(found->hostFormat == base.format, "sampling several slices or an integer view of a depth plane that the device stores in another depth format is not implemented");
Require(stencil ? HasStencil(found->hostFormat) : found->hostFormat == base.format, "sampling several slices or an integer view of a depth plane that the device stores in another depth format is not implemented");
const auto layers = cube ? std::max(resource.depthOrLastArray + 1u, 6u) : layered ? resource.depthOrLastArray + 1u : 1u;
if (!planes) {
char text[400];
std::snprintf(text, sizeof(text), "AGC graphics: sampling the depth planes of depth surface 0x%llx (%ux%u, vk format %d) as a %ux%u texture of guest format %u (vk %d), dimension %d, %u slices, levels %u-%u, base slice %u is not implemented (last array %u, depth bits %d, copy format %d)", static_cast<unsigned long long>(base.address), base.extent.width, base.extent.height, static_cast<int>(base.format), resource.width, resource.height, resource.format, static_cast<int>(format), static_cast<int>(resource.dimension), layers, resource.baseLevel, resource.lastLevel, resource.baseArray, resource.depthOrLastArray, depthBits ? 1 : 0, static_cast<int>(copyFormat));
std::snprintf(text, sizeof(text), "AGC graphics: sampling the %s planes of depth surface 0x%llx (%ux%u, vk format %d) as a %ux%u texture of guest format %u (vk %d), dimension %d, %u slices, levels %u-%u, base slice %u is not implemented (last array %u, depth bits %d, copy format %d)", stencil ? "stencil" : "depth", static_cast<unsigned long long>(base.address), base.extent.width, base.extent.height, static_cast<int>(base.format), resource.width, resource.height, resource.format, static_cast<int>(format), static_cast<int>(resource.dimension), layers, resource.baseLevel, resource.lastLevel, resource.baseArray, resource.depthOrLastArray, depthBits ? 1 : 0, static_cast<int>(copyFormat));
throw std::runtime_error(text);
}
std::vector<DepthPlaneSlice> slices;
const auto geometry = DescribeSurface(resource);
Require(!geometry.levelMajor, "depth planes of a PS4 layered surface with several mip levels (stored level by level) are not implemented");
for (std::uint32_t layer = 0; layer < layers; ++layer) {
const auto address = base.address + geometry.GuestLayerOffset(layer);
auto* slice = depthSlice(context.device, address, base);
if (slice != nullptr) slice->ApplyFastClear();
if (slice == nullptr) slices.push_back({});
else slices.push_back({slice->image, slice == drawnDepth ? 0u : slice->written});
const auto address = (stencil ? base.stencilAddress : base.address) + geometry.GuestLayerOffset(layer);
auto* slice = stencil ? stencilSlice(context.device, address, base) : depthSlice(context.device, address, base);
if (slice != nullptr) {
if (stencil && slice != found && slice->StencilMirrorable()) slice->SyncStencilFromMemory(stencilResource(slice->target));
slice->ApplyFastClear();
slices.push_back({slice->image, slice == drawnDepth ? 0u : slice->written});
} else {
slices.push_back({});
}
}
const auto imageFormat = integer ? VK_FORMAT_R16_UINT : d16 ? VK_FORMAT_D16_UNORM : VK_FORMAT_D32_SFLOAT;
const auto imageFormat = stencil ? copyFormat : integer ? VK_FORMAT_R16_UINT : d16 ? VK_FORMAT_D16_UNORM : VK_FORMAT_D32_SFLOAT;
const VkExtent2D extent{resource.width, resource.height};
auto& copies = planeCopies();
const std::tuple<VkDevice, std::uint64_t, std::uint32_t, std::uint32_t, VkFormat> copyKey{context.device, base.address, extent.width, extent.height, imageFormat};
const std::tuple<VkDevice, std::uint64_t, std::uint32_t, std::uint32_t, VkFormat> copyKey{context.device, stencil ? base.stencilAddress : base.address, extent.width, extent.height, imageFormat};
auto& copy = copies[copyKey];
if (copy == nullptr || copy->layers < layers) copy = std::make_unique<DepthPlaneCopy>(context, extent, imageFormat, layers);
copy->lastUse = ++planeCopyClock();
@@ -4933,6 +5038,19 @@ std::optional<float> planeFillDepth(const DepthTarget& target, std::uint64_t add
return DepthFillValue(pattern, d16);
}
void settleImportsUnderFill(std::uint64_t address, std::size_t bytes) {
std::vector<Context> contexts;
{
std::lock_guard lock(surfacesMutex());
for (const auto& surface : surfaces()) {
if (!surface->active->load(std::memory_order_acquire) || !surface->samplingActive) continue;
const bool covered = std::any_of(surface->sampling.initial.begin(), surface->sampling.initial.end(), [&](const auto& range) { return address < range.address + range.bytes && range.address < address + bytes; });
if (covered && std::none_of(contexts.begin(), contexts.end(), [&](const Context& context) { return context.device == surface->context.device; })) contexts.push_back(surface->context);
}
}
for (const auto& context : contexts) SettleOwnImports(context, address, bytes);
}
}
void NoteDepthMetadataFill(std::uint64_t address, std::size_t bytes, std::uint32_t pattern) {
@@ -4949,6 +5067,7 @@ void NoteDepthMetadataFill(std::uint64_t address, std::size_t bytes, std::uint32
}
for (const auto& plane : clearedPlanes) StorageTexture::FlushPending(plane.address, plane.bytes);
std::lock_guard gpu(GuestMemory::GpuMutex());
settleImportsUnderFill(address, bytes);
std::lock_guard lock(surfacesMutex());
forgetHtileReads(address, bytes);
for (const auto& surface : surfaces()) {
@@ -5072,7 +5191,8 @@ void NoteDepthRenderControl(const DepthRenderControl& draw) {
bool DepthRenderControlDrains(const DepthRenderControl& draw) {
if (draw.samples == 1u) return false;
if ((draw.control & 0x60u) != 0u) return true;
if ((draw.control & 0x40u) != 0u) return true;
if ((draw.control & 3u) == 0u) return false;
std::lock_guard lock(surfacesMutex());
return std::any_of(surfaces().begin(), surfaces().end(), [&](const auto& surface) { return surface->active->load(std::memory_order_acquire) && surface->target.samples == draw.samples && surface->target.address == draw.address; });
}
@@ -5124,12 +5244,19 @@ std::shared_ptr<StorageTexture> layeredDepthStorage(const Context& context, Dept
std::shared_ptr<StorageTexture> DepthSurfaceStorage(const Context& context, std::span<const std::uint32_t> words, const GuestTextureResource& resource, std::uint32_t mip) {
if (mip != 0 || resource.baseLevel != 0) return nullptr;
auto& unclaimed = ThreadScratch<UnclaimedAddresses, UnclaimedAddressesTag>();
if (unclaimed.Holds(context.device, resource.baseAddress, surfacesSerial.load(std::memory_order_acquire))) return nullptr;
storageScans.fetch_add(1, std::memory_order_relaxed);
std::lock_guard lock(surfacesMutex());
const auto serial = surfacesSerial.load(std::memory_order_acquire);
const auto& list = surfaces();
const auto found = std::find_if(list.rbegin(), list.rend(), [&](const auto& surface) {
return surface->active->load(std::memory_order_acquire) && surface->context.device == context.device && !surface->retired && (surface->target.address == resource.baseAddress || (surface->target.stencilAddress != 0 && surface->target.stencilAddress == resource.baseAddress));
});
if (found == list.rend()) return nullptr;
if (found == list.rend()) {
unclaimed.Remember(context.device, resource.baseAddress, serial);
return nullptr;
}
auto& surface = **found;
const bool stencil = surface.target.stencilAddress != 0 && surface.target.stencilAddress == resource.baseAddress;
if (stencil || resource.dimension != TextureDimension::k2DArray || (resource.baseArray == 0 && resource.depthOrLastArray == 0)) return surface.Storage(words, resource, mip);
@@ -5395,6 +5522,23 @@ std::uint64_t DepthTransferPassCount() {
return depthTransferPassCount.load(std::memory_order_relaxed);
}
std::uint64_t ArmedHtileDepthClearCount() {
return armedHtileClears.load(std::memory_order_relaxed);
}
std::uint64_t DiscardedHtileDepthClearCount() {
return discardedHtileClears.load(std::memory_order_relaxed);
}
std::uint32_t PendingHtileDepthClearDispatches(std::uint64_t htileAddress) {
std::lock_guard lock(surfacesMutex());
std::uint32_t pending = 0u;
for (const auto& surface : surfaces()) {
if (surface->active->load(std::memory_order_acquire) && surface->target.htileAddress == htileAddress) pending += surface->clearDispatchesPending;
}
return pending;
}
bool DepthUploadImage(const Context& context) {
return context.depthUploadImage || forcedDepthUploadImage.load(std::memory_order_relaxed);
}
@@ -465,8 +465,9 @@ std::optional<std::uint8_t> overwrittenStencil(const State& state) {
}
std::size_t colorKeyCount(const ColorTarget& color, std::size_t bytes) {
if (color.mipCount != 1 || color.depth != 1 || !color.dccPipeAligned) return DccKeyBytes(bytes);
return DccKeyCount(ColorTextureTileMode(color.tileMode), color.elementBytes, color.extent.width, color.extent.height, bytes);
if (color.mipCount == 1 && color.depth == 1 && color.dccPipeAligned) return DccKeyCount(ColorTextureTileMode(color.tileMode), color.elementBytes, color.extent.width, color.extent.height, bytes);
if (color.mipCount > 1 && color.depth == 1 && color.dccPipeAligned && ColorTextureTileMode(color.tileMode) == TextureTileMode::kR64KBX) return DccMipKeySlice(color.extent.width, color.extent.height, color.elementBytes);
return DccKeyBytes(bytes);
}
std::array<std::byte, 16> clearTexel(const ColorTarget& color, DccKeys keys) {
@@ -1633,7 +1634,7 @@ const HostImport* InPlaceDrawInput(const Context& context, std::uint64_t address
namespace {
constexpr std::array<const char*, static_cast<std::size_t>(IndexBehindWriter::Count)> IndexBehindWriterNames{
"taken", "off", "no writer", "vertex attributes", "index limit", "mesh stage", "primitive restart", "vertex offset",
"taken", "off", "no writer", "index limit", "mesh stage", "primitive restart", "vertex offset",
"unit shadow", "pending storage", "label or store", "copied writer", "no import", "refused"
};
@@ -1670,7 +1671,7 @@ std::array<std::uint64_t, static_cast<std::size_t>(IndexBehindWriter::Count)> In
return counts;
}
const HostImport* InPlaceIndexBehindWriter(const Context& context, std::uint64_t address, std::size_t bytes, std::uint32_t indexSize, bool vertexAttributes, bool meshStage, bool primitiveRestart, std::uint32_t firstVertex, IndexBehindWriter* outcome) {
const HostImport* InPlaceIndexBehindWriter(const Context& context, std::uint64_t address, std::size_t bytes, std::uint32_t indexSize, bool meshStage, bool primitiveRestart, std::uint32_t firstVertex, IndexBehindWriter* outcome) {
const bool enabled = RuntimeSwitches::Set(RuntimeSwitch::IndexInPlaceBehindWriter);
const auto leave = [&](IndexBehindWriter result, const HostImport* import) {
if (outcome != nullptr) *outcome = result;
@@ -1683,7 +1684,6 @@ const HostImport* InPlaceIndexBehindWriter(const Context& context, std::uint64_t
auto* recorder = context.recorder;
if (!enabled || recorder == nullptr || (indexSize != 2 && indexSize != 4) || bytes < indexSize) return leave(IndexBehindWriter::Off, nullptr);
if (!recorder->PendingWriteOverlaps(address, bytes)) return leave(IndexBehindWriter::NoWriter, nullptr);
if (vertexAttributes) return leave(IndexBehindWriter::VertexAttributes, nullptr);
if (context.limits.maxDrawIndexedIndexValue != std::numeric_limits<std::uint32_t>::max()) return leave(IndexBehindWriter::IndexLimit, nullptr);
if (meshStage) return leave(IndexBehindWriter::MeshStage, nullptr);
if (primitiveRestart) return leave(IndexBehindWriter::PrimitiveRestart, nullptr);
@@ -2058,7 +2058,7 @@ DrawInputs prepareDrawInputs(const Context& context, const State& state, const P
const bool skipRestart = state.primitiveRestart && (!listTopology || context.primitiveListRestart || state.stages.mesh);
const auto use = draw.indexSize == 2 ? (skipRestart ? Recorder::SnapshotUse::Index16Restart : Recorder::SnapshotUse::Index16) : (skipRestart ? Recorder::SnapshotUse::Index32Restart : Recorder::SnapshotUse::Index32);
const bool restartTable = skipRestart && state.stages.mesh && (state.stages.mesh->inputPrimitive == 5 || state.stages.mesh->inputPrimitive == 6);
const auto* behindWriter = InPlaceIndexBehindWriter(context, draw.indexAddress, static_cast<std::size_t>(indexBytes), draw.indexSize, !shaders.front().program->vertexAttributes.empty(), static_cast<bool>(state.stages.mesh), skipRestart, draw.firstVertex);
const auto* behindWriter = InPlaceIndexBehindWriter(context, draw.indexAddress, static_cast<std::size_t>(indexBytes), draw.indexSize, static_cast<bool>(state.stages.mesh), skipRestart, draw.firstVertex);
const auto* import = behindWriter != nullptr ? behindWriter : InPlaceDrawInput(context, draw.indexAddress, static_cast<std::size_t>(indexBytes), draw.indexSize, nullptr, static_cast<std::size_t>(indexBytes), reads);
DrawInputCopy copy;
if (import == nullptr) copy = CopyDrawInput(context, context.recorder, draw.indexAddress, static_cast<std::size_t>(indexBytes), draw.indexSize, use, 0, !BindsIndexCopy(state));
@@ -2069,9 +2069,15 @@ DrawInputs prepareDrawInputs(const Context& context, const State& state, const P
highest = draw.indexSize == 2 ? 0xffffu : std::numeric_limits<std::uint32_t>::max();
inputs.indexInputBehindGpuWrite = true;
} else if (import != nullptr) {
const auto range = InPlaceIndexRange(*context.recorder, draw.indexAddress, static_cast<std::size_t>(indexBytes), draw.indexSize, skipRestart);
highest = range.highest;
lowest = range.lowest;
const std::uint32_t largestIndex = draw.indexSize == 2 ? 0xffffu : std::numeric_limits<std::uint32_t>::max();
if (shaders.front().program->vertexAttributes.empty() && !skipRestart && !state.stages.mesh && draw.indexCount != 0 && largestIndex <= context.limits.maxDrawIndexedIndexValue && draw.firstVertex <= std::numeric_limits<std::uint32_t>::max() - largestIndex) {
highest = largestIndex;
lowest = 0u;
} else {
const auto range = InPlaceIndexRange(*context.recorder, draw.indexAddress, static_cast<std::size_t>(indexBytes), draw.indexSize, skipRestart);
highest = range.highest;
lowest = range.lowest;
}
} else if (!copy.reused) {
if (const auto bounds = DrawIndexRange(copy.buffer->Bytes().first(static_cast<std::size_t>(indexBytes)), draw.indexSize, skipRestart)) {
highest = bounds->highest;
@@ -2126,6 +2132,7 @@ DrawInputs prepareDrawInputs(const Context& context, const State& state, const P
APS5_LOG_CHARS_OUT_DEBUG("Index validation OK");
timing.Mark("index_upload");
const auto& attributes = shaders.front().program->vertexAttributes;
const bool wholeRange = args != nullptr || inputs.indexInputBehindGpuWrite;
inputs.vertexOffsets.assign(attributes.size(), 0);
inputs.vertexHandles.reserve(attributes.size());
// An indexed draw's vertex offset moves every fetch: the copy must reach the last one.
@@ -2161,16 +2168,16 @@ DrawInputs prepareDrawInputs(const Context& context, const State& state, const P
continue;
}
// An indirect draw's counts are unknown here: the descriptor's whole range is copied.
const auto bytes = (args != nullptr ? VertexBufferExtent(attribute) : VertexBufferReadSize(attribute, inputs.maxIndex, draw.instanceCount, draw.firstInstance)) + widened;
const auto bytes = (wholeRange ? VertexBufferExtent(attribute) : VertexBufferReadSize(attribute, inputs.maxIndex, draw.instanceCount, draw.firstInstance)) + widened;
const auto& fields = attribute.resource.fields;
const auto address = fields[0] | (static_cast<std::uint64_t>(fields[1] & 0xffffu) << 32u);
const auto firstByte = args == nullptr ? VertexBufferReadOffset(attribute, draw.firstVertex, draw.firstInstance) : 0;
const auto firstByte = !wholeRange ? VertexBufferReadOffset(attribute, draw.firstVertex, draw.firstInstance) : 0;
Require(!state.hasColorTarget || address + bytes <= state.color.MemoryAddress() || state.color.MemoryAddress() + state.color.bytes <= address + firstByte, "vertex buffer aliases the render target");
const auto stride = (fields[1] >> 16u) & 0x3fffu;
fetchOf[i] = fetches.size();
fetches.push_back({address, address + bytes, stride, attribute.fetchIndex, DecodeVertexFormat(attribute).alignment});
const auto recordBytes = static_cast<std::uint64_t>(fields[2]) * stride;
fetchValid.push_back(args == nullptr && stride != 0 ? static_cast<std::size_t>(std::min(recordBytes, static_cast<std::uint64_t>(bytes))) : bytes);
fetchValid.push_back(!wholeRange && stride != 0 ? static_cast<std::size_t>(std::min(recordBytes, static_cast<std::uint64_t>(bytes))) : bytes);
fetchLimit.push_back(args == nullptr ? std::max<std::uint64_t>(VertexDescriptorEnd(attribute, widened), address + bytes) : address + bytes);
}
const auto soloFetches = SoloZeroPaddedFetchIndices(fetches, fetchValid);
@@ -2187,7 +2194,7 @@ DrawInputs prepareDrawInputs(const Context& context, const State& state, const P
plannedFetches.push_back(fetches[f]);
}
const auto plan = PlanVertexCopies(plannedFetches);
const auto rangeFrom = args == nullptr && !state.stages.mesh ? VertexCopyStarts(plan, plannedFetches, inputs.minIndex, draw.firstInstance) : std::vector<std::size_t>(plan.copies.size(), 0);
const auto rangeFrom = !wholeRange && !state.stages.mesh ? VertexCopyStarts(plan, plannedFetches, inputs.minIndex, draw.firstInstance) : std::vector<std::size_t>(plan.copies.size(), 0);
auto& rangeLimit = planLease->rangeLimit;
rangeLimit.assign(plan.copies.size(), std::numeric_limits<std::uint64_t>::max());
for (std::size_t f = 0; f < fetches.size(); ++f) {
@@ -2249,6 +2256,34 @@ DrawInputs prepareDrawInputs(const Context& context, const State& state, const P
// over the target's pages, the DCC key scan of TextureClearKeys, then UnchangedSince), with the
// [draws] target-lookup accounting. `lookup` makes (or finds) the image; DrawWithRecipe refreshes
// the stored object instead.
bool materializeMipClear(const Context& context, const ColorTarget& color, std::shared_ptr<StorageTexture>& resident) {
if (color.dccAddress == 0 || color.mipCount <= 1 || color.mipTail) return false;
const auto keyCount = std::max<std::size_t>(colorKeyCount(color, color.bytes), 1u);
const auto landed = LandedDccKeys(color.dccAddress, color.bytes, keyCount);
DccKeys keys;
bool verified;
if (landed == DccKeys::Unreadable) {
keys = CurrentDccKeys(color.dccAddress, color.bytes, keyCount);
verified = false;
} else {
keys = landed;
verified = true;
}
if (!IsDccClear(keys) || keys == DccKeys::ClearSingle || (keys == DccKeys::ClearRegister && color.elementBytes > 8u)) return false;
const auto texel = clearTexel(color, keys);
if (resident != nullptr) {
const char* refusal = nullptr;
if (resident->ClearMip(texel, color.mip, verified, refusal)) {
MarkDccUncompressed(context, color.dccAddress, color.bytes, keyCount);
return true;
}
MarkDccUncompressed(context, color.dccAddress, color.bytes, keyCount);
}
StorageTexture::FlushPending(color.address, color.bytes, nullptr, "fast-clear materialization");
writeTexels(color, texel);
return true;
}
template<typename TLookup>
std::shared_ptr<StorageTexture> refreshResidentTarget(const Context& context, const State& state, const ColorTarget& color, DrawOutcome& outcome, bool profile, const TLookup& lookup) {
const auto lookupStart = profile ? std::chrono::steady_clock::now() : std::chrono::steady_clock::time_point{};
@@ -2265,6 +2300,7 @@ std::shared_ptr<StorageTexture> refreshResidentTarget(const Context& context, co
if (reported.insert(color.address).second) std::fprintf(stderr, "[gpu] color target 0x%llx stays non-resident: %s\n", static_cast<unsigned long long>(color.address), error.what());
}
if (resident != nullptr) materializeCmaskClear(context, color, resident);
if (resident != nullptr) materializeMipClear(context, color, resident);
if (profile) {
const auto lookupUs = std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - lookupStart).count();
++outcome.targetLookups;
@@ -2755,6 +2791,7 @@ void keepRecordedDraw(Recorder& recorder, const std::shared_ptr<ShaderResources>
writers->erase(std::remove(writers->begin(), writers->end(), resources), writers->end());
resources->WriteBackBuffers();
});
recorder.OnDiscard([resources, writers] { writers->erase(std::remove(writers->begin(), writers->end(), resources), writers->end()); });
writers->push_back(resources);
GuestMemory::BreakProofs();
} else if (completion) {
@@ -3101,11 +3138,20 @@ void recordDraw(const Context& context, const State& state, const Pm4::DrawParam
thread_local std::vector<std::pair<VkImage, bool>>* passImagesSlot = nullptr;
auto& passImages = ShaderRecompiler::ThreadOwned(passImagesSlot);
resources.StorageImages(passImages);
InlineList<std::pair<VkImage, bool>, 16> passAttachments;
for (const auto& target : record.targets) {
if (target != nullptr) passAttachments.EmplaceBack(target->Image(), true);
InlineList<PassAttachment, 16> passAttachments;
for (std::size_t index = 0; index < record.targets.size(); ++index) {
const auto& target = record.targets[index];
if (target == nullptr) continue;
if (index < state.colors.size()) {
const auto& color = state.colors[index];
const std::uint32_t firstSlice = target->ImageDepth() > 1u ? color.depthSlice : color.arraySlice;
const std::uint32_t sliceCount = target->ImageDepth() > 1u || color.arrayLastSlice != 0u ? color.layers : 1u;
passAttachments.EmplaceBack(PassAttachment{target->Image(), true, color.mip, firstSlice, sliceCount});
} else {
passAttachments.EmplaceBack(PassAttachment{target->Image(), true, 0u, 0u, 0u});
}
}
for (const auto image : record.multisampleImages) passAttachments.EmplaceBack(image, true);
for (const auto image : record.multisampleImages) passAttachments.EmplaceBack(PassAttachment{image, true, 0u, 0u, 0u});
const bool unknownMemory = addressBased || resources.UsesAddressTable() || resources.HasCopiedWrites();
static_cast<void>(StorageTexture::StoreDrawnLinearTouching("draw access", [&](std::uint64_t begin, std::uint64_t end) { return std::any_of(passReads.begin(), passReads.end(), [&](const auto& read) { return read.first < end && begin < read.second; }) || resources.WritesOverlap(begin, static_cast<std::size_t>(end - begin)); }, unknownMemory));
const auto drawUse = resources.BeginDrawUse(*recorder);
@@ -3245,12 +3291,20 @@ void recordDraw(const Context& context, const State& state, const Pm4::DrawParam
APS5_LOG_CHARS_OUT_DEBUG("Push constants recorded");
static const bool timeEachDraw = std::getenv("APS5_PROFILE_GPU_DRAWS") != nullptr;
auto eachDrawTiming = Recorder::NoTiming;
if (timeEachDraw) {
std::uint64_t key = 0;
for (const auto& shader : shaders) {
if (shader.program != nullptr && (key == 0 || shader.stage == ShaderRecompiler::ShaderStage::Fragment)) key = shader.program->variantId;
if (timeEachDraw && Recorder::GpuTimingEnabled()) {
if (Recorder::DrawStageTimingEnabled()) {
std::vector<std::pair<std::uint32_t, std::uint64_t>> stages;
for (const auto& shader : shaders) {
if (shader.program != nullptr) stages.emplace_back(static_cast<std::uint32_t>(shader.stage), shader.program->variantId);
}
eachDrawTiming = recorder->BeginInPassGpuTiming(Recorder::DrawStageTimingKey(stages));
} else {
std::uint64_t key = 0;
for (const auto& shader : shaders) {
if (shader.program != nullptr && (key == 0 || shader.stage == ShaderRecompiler::ShaderStage::Fragment)) key = shader.program->variantId;
}
eachDrawTiming = recorder->BeginInPassGpuTiming(Recorder::DrawTimingKey(key));
}
eachDrawTiming = recorder->BeginInPassGpuTiming(Recorder::DrawTimingKey(key));
}
noteDrawFaultToken(context, *recorder, commands, shaders, draw, static_cast<std::uint32_t>(state.stages.mesh.has_value() ? AgcDriver::FaultStage::mesh : AgcDriver::FaultStage::graphics), record.indirect != nullptr ? record.indirect->args : nullptr);
if (record.stencilReplay.empty()) recordDrawCommands(context, commands, state, draw, inputs, record.indirect, argumentBuffer, argumentOffset, trace, subdraw);
@@ -3959,7 +4013,7 @@ void rememberTargets(const State& state, std::span<const TargetBinding> targets,
auto& depth = ThreadTargetMemo().depth;
const bool enabled = TargetMemoEnabled() && proof.epoch != 0;
colors.valid = enabled && !targets.empty() && std::ranges::all_of(targets, [&](const TargetBinding& binding) {
return binding.resident != nullptr && binding.resident->Cached() && !binding.multisampled && binding.color.fmaskAddress == 0 && !colorOverlapsDepth(state, binding) && metadataProved(binding.color);
return binding.resident != nullptr && binding.resident->Cached() && !binding.multisampled && binding.color.fmaskAddress == 0 && !binding.resident->OtherPendingOverlaps() && !colorOverlapsDepth(state, binding) && metadataProved(binding.color);
});
if (colors.valid) {
colors.proof = proof;
@@ -3975,6 +4029,15 @@ void rememberTargets(const State& state, std::span<const TargetBinding> targets,
}
}
bool sameColorTargetSurface(const ColorTarget& a, const ColorTarget& b) {
if (a == b) return true;
if (a.arrayLastSlice != 0 || b.arrayLastSlice != 0 || !(a.volume || a.depth > 1) || !(b.volume || b.depth > 1)) return false;
auto adjusted = b;
adjusted.depthSlice = a.depthSlice;
adjusted.layers = a.layers;
return a == adjusted;
}
bool repeatColors(const Context& context, const State& state, const TargetProof& proof, std::vector<TargetBinding>& targets, std::vector<VkImageView>& views) {
auto& memo = ThreadTargetMemo().colors;
thread_local std::uint32_t lookups = 0;
@@ -3986,10 +4049,16 @@ bool repeatColors(const Context& context, const State& state, const TargetProof&
return false;
}
if (!colorProofMatches(memo.proof, proof)) return false;
if (memo.descriptors != state.colors) {
if (memo.descriptors.size() != state.colors.size()) {
noteTargetMemo(TargetMemoEvent::Descriptor);
return false;
}
for (std::size_t index = 0; index < state.colors.size(); ++index) {
if (!sameColorTargetSurface(memo.descriptors[index], state.colors[index]) || (memo.descriptors[index] != state.colors[index] && memo.attachments[index].proxied)) {
noteTargetMemo(TargetMemoEvent::Descriptor);
return false;
}
}
const auto footprint = depthFootprint(state.depth);
const bool overlapKnown = footprint == memo.clearOfDepth && !RuntimeSwitches::Set(RuntimeSwitch::NoTargetMemoOverlapCache);
for (std::size_t index = 0; index < targets.size(); ++index) {
@@ -4007,7 +4076,8 @@ bool repeatColors(const Context& context, const State& state, const TargetProof&
}
binding.gpuTiling = binding.color.tileMode == ColorTileMode::RenderTarget && context.detiler != nullptr;
binding.proxied = memo.attachments[index].proxied;
views.push_back(memo.attachments[index].view);
const bool exact = memo.descriptors[index] == binding.color;
views.push_back(exact ? memo.attachments[index].view : binding.resident->AttachmentView(binding.color.format, binding.color.mip, binding.color.depthSlice, binding.color.layers, binding.color.arraySlice));
}
noteTargetMemo(TargetMemoEvent::Hit);
noteTargetMemo(overlapKnown ? TargetMemoEvent::OverlapCached : TargetMemoEvent::OverlapComputed);
@@ -5062,7 +5132,7 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters&
Require(limit != 0u && !state.depth, "mesh layer windows require a nonzero output limit and color-only layered rendering");
Require(std::ranges::all_of(shaders, [](const CompiledShader& shader) { return shader.program != nullptr && shader.program->layerReplaySafe; }), "mesh layer windows refuse shaders with guest memory writes, clocks or unproven side effects");
if (recipeOut != nullptr) recipeOut->reset();
for (std::uint32_t base = 0; base < state.renderLayers;) {
const auto makeWindow = [&](std::uint32_t base) {
auto window = state;
window.renderLayers = std::min(limit, state.renderLayers - base);
window.meshLayerBase = base;
@@ -5074,8 +5144,76 @@ void Draw(const Context& context, const State& state, const Pm4::DrawParameters&
color.layers = window.renderLayers;
}
if (!window.colors.empty()) window.color = window.colors.front();
Draw(context, window, draw, shaders, snapshots, nullptr, trace);
base += window.renderLayers;
return window;
};
auto firstWindow = makeWindow(0u);
static const bool profile = std::getenv("APS5_PROFILE_DRAW") != nullptr;
PreparedDraw prepared(profile);
prepared.trace = trace;
prepared.contentKey = contentKey;
prepared.passAttachments = PassAttachmentMemoEnabled();
const struct HeldSpace {
PreparedDraw& prepared;
~HeldSpace() {
const auto& resources = prepared.resolved.resources;
if (resources == nullptr || !resources->SpaceReuse() || !resources->SpaceHeld()) return;
if (prepared.spaceKeep != nullptr) *prepared.spaceKeep = resources->ReleaseSpace();
else if (prepared.recorder != nullptr) resources->HoldSpaceThrough(prepared.recorder->Id(), prepared.recorder->OpenSerial());
else static_cast<void>(resources->ReleaseSpace());
}
} heldSpace{prepared};
bool sharePrepared = false;
try {
if (!prepareDraw(context, firstWindow, draw, shaders, snapshots, prepared)) {
keepHeldSpace(prepared);
return;
}
sharePrepared = !draw.indirect && prepared.lean && !prepared.multisampled && prepared.stencilReplay.empty() && prepared.resolved.resources != nullptr && !prepared.resolved.resources->SpaceReuse() && !prepared.targets.empty() && std::none_of(prepared.targets.begin(), prepared.targets.end(), [](const TargetBinding& binding) { return binding.resident == nullptr || binding.proxied || binding.stagedTemporary != nullptr || binding.dump != nullptr; });
const bool finalCompletion = prepared.completion;
const bool finalWaited = prepared.outcome.waited;
if (sharePrepared) {
prepared.completion = false;
prepared.outcome.waited = false;
}
recordPreparedDraw(context, firstWindow, draw, shaders, prepared);
if (sharePrepared) {
for (std::uint32_t base = firstWindow.renderLayers; base < state.renderLayers;) {
auto window = makeWindow(base);
if (base + window.renderLayers >= state.renderLayers) {
prepared.completion = finalCompletion;
prepared.outcome.waited = finalWaited;
}
for (std::size_t index = 0; index < window.colors.size(); ++index) {
const auto& color = window.colors[index];
prepared.targets[index].color = color;
prepared.targetViews[index] = prepared.targets[index].resident->AttachmentView(color.format, color.mip, color.depthSlice, color.layers, color.arraySlice);
}
if (prepared.masked.has_value()) {
prepared.masked->renderLayers = window.renderLayers;
prepared.masked->meshLayerBase = window.meshLayerBase;
prepared.masked->meshLayerCount = window.meshLayerCount;
prepared.masked->colors = window.colors;
prepared.masked->color = window.color;
}
const auto& pipelineState = prepared.masked.has_value() ? *prepared.masked : window;
prepared.pipeline = CachedPipeline(context, pipelineState, prepared.inputs.VertexLayout(), prepared.resolved.resources->SetLayouts(), shaders, VK_IMAGE_LAYOUT_GENERAL);
prepared.framebuffer = prepared.pipeline->AcquireFramebuffer(prepared.targetViews, prepared.framebufferOwners, window.renderExtent, window.renderLayers);
recordPreparedDraw(context, window, draw, shaders, prepared);
base += window.renderLayers;
}
}
} catch (...) {
ThreadTargetMemo().Invalidate();
keepHeldSpace(prepared);
throw;
}
keepHeldSpace(prepared);
if (!sharePrepared) {
for (std::uint32_t base = firstWindow.renderLayers; base < state.renderLayers;) {
auto window = makeWindow(base);
Draw(context, window, draw, shaders, snapshots, nullptr, trace);
base += window.renderLayers;
}
}
return;
}
@@ -5311,6 +5449,7 @@ void RunColorMetadataPass(const Context& context, const ColorMetadataPass& pass)
MaterializeMultisampleTargetClear(context, color);
continue;
}
ClaimMultisampleTargetMemory(color.MemoryAddress(), color.bytes);
if (color.cmaskAddress != 0) {
const auto resident = metadataPassResident(context, color);
if (materializeCmaskClear(context, color, resident) && resident != nullptr) resident->MarkDirty();
@@ -5336,6 +5475,10 @@ void RunColorMetadataPass(const Context& context, const ColorMetadataPass& pass)
continue;
}
}
if (color.mipCount > 1 && resident == nullptr) {
std::shared_ptr<StorageTexture> chain = CachedStorageSurface(context, SurfaceForTarget(color));
if (materializeMipClear(context, color, chain)) continue;
}
storeClearTexels(context, color, texel);
}
}
File diff suppressed because it is too large. Load diff
@@ -22,7 +22,8 @@ bool isAnisoFilter(std::uint32_t raw) {
VkSamplerReductionMode toVkReductionMode(std::uint32_t raw) {
switch (raw) {
case 0: return VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT;
case 0:
case 3: return VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT;
case 1: return VK_SAMPLER_REDUCTION_MODE_MIN_EXT;
case 2: return VK_SAMPLER_REDUCTION_MODE_MAX_EXT;
default: throw std::runtime_error("AGC graphics: guest sampler descriptor uses an unknown reduction filter mode " + std::to_string(raw));
@@ -347,7 +347,7 @@ GuestTextureResource DecodeTextureResource(std::span<const std::uint32_t> descri
result.lastLevel = lastLevel;
result.tileMode = tileMode;
result.dimension = dimension;
result.format = !fmask ? format : static_cast<std::uint32_t>(fmaskLayout->storageBits == 8u ? ShaderRecompiler::IrBufferFormat::Format8UInt : fmaskLayout->storageBits == 16u ? ShaderRecompiler::IrBufferFormat::Format16UInt : ShaderRecompiler::IrBufferFormat::Format32UInt);
result.format = !fmask ? format : static_cast<std::uint32_t>(fmaskLayout->storageBits == 8u ? ShaderRecompiler::IrBufferFormat::Format8UInt : fmaskLayout->storageBits == 16u ? ShaderRecompiler::IrBufferFormat::Format16UInt : fmaskLayout->storageBits == 32u ? ShaderRecompiler::IrBufferFormat::Format32UInt : ShaderRecompiler::IrBufferFormat::Format32_32UInt);
result.dstSelX = static_cast<std::uint8_t>(dstSelX);
result.dstSelY = static_cast<std::uint8_t>(dstSelY);
result.dstSelZ = static_cast<std::uint8_t>(dstSelZ);
@@ -101,7 +101,7 @@ Stripes StripesOf(std::uint64_t begin, std::uint64_t end) {
bool LockOrderChecked() {
#ifdef NDEBUG
static const bool checked = std::getenv("APS5_ASSERT_GPU_LOCK") != nullptr;
static const bool checked = std::getenv("APS5_ASSERT_GPU_LOCK") != nullptr || std::getenv("APS5_ASSERT_LOCK_ORDER") != nullptr;
return checked;
#else
return true;
@@ -116,6 +116,10 @@ void NoteLeafUnlock() noexcept {
if (LockOrderChecked()) --leafLocksHeld;
}
bool LeafLockHeld() noexcept {
return leafLocksHeld != 0;
}
void RequireNoLeafLockHeld(const char* where) {
if (!LockOrderChecked()) return;
if (leafLocksHeld == 0 && !ImportsHeldByThisThread()) return;
@@ -244,10 +244,10 @@ std::shared_ptr<Buffer> stageGuestSamples(const Context& context, const Multisam
class MultisampleTarget : public std::enable_shared_from_this<MultisampleTarget> {
public:
MultisampleTarget(const Context& context, const ColorTarget& target, bool guestSamples = false, std::optional<VkClearColorValue> initialClear = std::nullopt, std::shared_ptr<Buffer> preparedUpload = {}, std::vector<std::byte> initialBaseline = {}) : context(context), target(target), cmask(target.cmaskAddress, target.cmaskBytes), colorFill(target), guestColorBaseline(std::move(initialBaseline)) {
MultisampleTarget(const Context& context, const ColorTarget& target, bool guestSamples = false, std::optional<VkClearColorValue> initialClear = std::nullopt, std::shared_ptr<Buffer> preparedUpload = {}, std::vector<std::byte> initialBaseline = {}, bool hasRegisterClear = true) : context(context), target(target), cmask(target.cmaskAddress, target.cmaskBytes), colorFill(target), guestColorBaseline(std::move(initialBaseline)) {
this->context.bufferPool.reset();
if (target.dccAddress != 0) metadataValid = std::make_shared<std::atomic<bool>>(true);
const auto initial = initialClear ? *initialClear : initialDccClear(target);
const auto initial = initialClear ? *initialClear : initialDccClear(target, hasRegisterClear);
if (target.dccAddress != 0) cleared = initial;
const auto samples = static_cast<VkSampleCountFlagBits>(target.samples);
Require((context.limits.framebufferColorSampleCounts & samples) != 0, "the device cannot render color with the target's sample count");
@@ -548,7 +548,7 @@ public:
fmaskRange.reset();
fmaskCopy = {};
metadataValid = std::make_shared<std::atomic<bool>>(true);
const auto initial = initialDccClear(use);
const auto initial = initialDccClear(use, true);
cleared = initial;
drawn = false;
++contents;
@@ -817,6 +817,16 @@ public:
return twinView;
}
bool TakesRegisterState(const ColorTarget& use) const {
return fromTexture && !drawn && !storageWritten && dccRanges.size() == 2 && use.address == target.address && use.dccAddress == target.dccAddress && use.dccAlphaOnMsb == target.dccAlphaOnMsb && use.dccPipeAligned == target.dccPipeAligned && use.tileMode == target.tileMode && use.elementBytes == target.elementBytes && use.pipeBankXor == target.pipeBankXor && (use.dccControl != target.dccControl || use.cmaskAddress != target.cmaskAddress || use.cmaskBytes != target.cmaskBytes);
}
void CheckTextureImport() const {
Require(metadataValid->load(std::memory_order_acquire), "multisampled DCC metadata was released while its color target remains resident");
const auto keys = dccFill ? LandedUniformMetadataByte(dccRanges[1].address, dccRanges[1].bytes) : std::nullopt;
checkDccWrites(keys && *dccFill == *keys * 0x01010101u ? std::size_t{1} : dccRanges.size());
}
bool Serves(const ColorTarget& use) const {
if (use.format == target.format) return sameTarget(target, use);
auto twin = use;
@@ -1071,7 +1081,7 @@ private:
return upload;
}
VkClearColorValue initialDccClear(const ColorTarget& use) {
VkClearColorValue initialDccClear(const ColorTarget& use, bool hasRegisterClear) {
if (use.dccAddress == 0) return {};
const auto dccBytes = MultisampledDccBytes(use);
Require((use.dccAddress & 4095u) == 0, "multisampled DCC metadata base alignment is not implemented");
@@ -1092,6 +1102,7 @@ private:
continue;
}
Require(GuestMemory::Watched(range.address, range.bytes), "initial multisampled DCC contents require watched guest memory");
if (index != 0u) GuestMemory::MaterializeKnownZero(range.address, range.bytes);
range.generation = collectBlocks(range.address, range.bytes);
Require(range.generation != 0, "initial multisampled DCC contents have no write generation");
watched.push_back(range);
@@ -1126,6 +1137,7 @@ private:
}
std::vector<std::byte> fmaskBytes(fmaskCopy.compared ? fmaskRange->bytes : 0u);
if (fmaskCopy.compared) GuestMemory::Read(fmaskRange->address, fmaskBytes);
Require(hasRegisterClear || bytes[1].front() != std::byte{0x20}, "multisampled texture DCC register clear requires a known render-target clear color");
const auto clear = MultisampledDccClear(use, bytes[1], bytes[2]);
Require((watched.empty() || GuestMemory::UnchangedSinceAll(watched)) && (!fmaskRange || fmaskCopy.compared || GuestMemory::UnchangedSinceAll(std::span(&*fmaskRange, 1u))), "initial multisampled DCC contents changed during import");
for (std::size_t index = 0; index < dccRanges.size(); ++index) {
@@ -1143,15 +1155,7 @@ private:
Require(false, text);
}
void checkDccCurrent(const ColorTarget& use, bool metadataRefilled) const {
if (dccRanges.empty()) {
Require(use.dccAddress == 0, "adding DCC to a resident multisampled color target is not implemented");
return;
}
Require(metadataValid->load(std::memory_order_acquire), "multisampled DCC metadata was released while its color target remains resident");
static_cast<void>(MultisampledDccBytes(use));
Require(use.address == target.address && use.dccAddress == target.dccAddress && use.dccControl == target.dccControl && use.dccAlphaOnMsb == target.dccAlphaOnMsb && use.dccPipeAligned == target.dccPipeAligned && use.cmaskAddress == target.cmaskAddress && use.cmaskBytes == target.cmaskBytes && use.tileMode == target.tileMode && use.elementBytes == target.elementBytes && use.pipeBankXor == target.pipeBankXor, "multisampled DCC target layout or metadata changed");
const auto ranges = metadataRefilled ? std::size_t{1} : dccRanges.size();
void checkDccWrites(std::size_t ranges) const {
for (std::size_t index = 0; index < ranges; ++index) requireDccRange(compared(index) || GuestMemory::Watched(dccRanges[index].address, dccRanges[index].bytes), dccRanges[index], "multisampled DCC target reuse requires watched guest memory");
for (std::size_t index = 0; index < ranges; ++index) {
const auto& range = dccRanges[index];
@@ -1163,6 +1167,17 @@ private:
}
if (auto* recorder = Recorder::Active(); recorder != nullptr) requireDccRange(!recorder->PendingWriteOverlaps(range.address, range.bytes), range, "pending writes to a resident multisampled DCC target or its metadata are not implemented");
}
}
void checkDccCurrent(const ColorTarget& use, bool metadataRefilled) const {
if (dccRanges.empty()) {
Require(use.dccAddress == 0, "adding DCC to a resident multisampled color target is not implemented");
return;
}
Require(metadataValid->load(std::memory_order_acquire), "multisampled DCC metadata was released while its color target remains resident");
static_cast<void>(MultisampledDccBytes(use));
Require(use.address == target.address && use.dccAddress == target.dccAddress && use.dccControl == target.dccControl && use.dccAlphaOnMsb == target.dccAlphaOnMsb && use.dccPipeAligned == target.dccPipeAligned && use.cmaskAddress == target.cmaskAddress && use.cmaskBytes == target.cmaskBytes && use.tileMode == target.tileMode && use.elementBytes == target.elementBytes && use.pipeBankXor == target.pipeBankXor, "multisampled DCC target layout or metadata changed");
checkDccWrites(metadataRefilled ? std::size_t{1} : dccRanges.size());
if (fmaskRange) {
Require(use.fmaskAddress == target.fmaskAddress && use.fmaskPipeBankXor == target.fmaskPipeBankXor, "native FMASK target layout changed");
const auto& range = *fmaskRange;
@@ -1485,7 +1500,9 @@ MultisampleTarget& acquire(const Context& context, const ColorTarget& requested,
if (target->context.device != context.device || !target->Serves(requested)) continue;
auto use = requested;
use.format = target->target.format;
if (recreated(target->target, use)) {
const bool takesRegisterState = target->TakesRegisterState(use);
if (takesRegisterState) target->CheckTextureImport();
if (takesRegisterState || recreated(target->target, use)) {
{
std::unique_lock lock(guardedMutex());
if (!target->active->load(std::memory_order_acquire)) continue;
@@ -1574,6 +1591,19 @@ MultisampleTarget& createFilled(const Context& context, const GuestTextureResour
RequireNoMultisampleColorTarget(use.address, static_cast<std::size_t>(bytes), "sampling a multisampled texture no draw rendered to");
GuestMemory::FlushGpuWrites(use.address, static_cast<std::size_t>(bytes));
if (!GuestMemory::Accessible(reinterpret_cast<const void*>(use.address), static_cast<std::size_t>(bytes))) refuse(std::string("whose color memory ") + range + " is not mapped");
if (!written && resource.dccAddress != 0u && use.tileMode == ColorTileMode::RenderTarget) {
use.dccAddress = resource.dccAddress;
use.dccPipeAligned = resource.dccPipeAligned;
use.dccAlphaOnMsb = resource.dccAlphaOnMsb;
auto target = std::make_shared<MultisampleTarget>(context, use, false, std::nullopt, std::shared_ptr<Buffer>{}, std::vector<std::byte>{}, false);
target->Keep();
targets().push_back(std::move(target));
auto& created = *targets().back();
created.use->hostOnly.store(false, std::memory_order_release);
guard(context, use, created.active, created.metadataValid, created.use, created.shared_from_this());
created.fromTexture = true;
return created;
}
std::uint64_t htileBytes = 0;
bool htileCleared = false;
if (resource.dccAddress != 0) {
@@ -45,15 +45,20 @@ PassHazard PassHazards::Check(const PassAccess& access, bool samePass) const {
if (overlapsAny(writes, access.writes) || overlapsAny(writeOnly, access.writes) || overlapsAny(writes, access.writeOnly)) return PassHazard::WriteAfterWrite;
if (overlapsAny(reads, access.writes) || overlapsAny(reads, access.writeOnly)) return PassHazard::WriteAfterRead;
const auto conflicts = [](bool earlier, bool later) { return earlier || later; };
const auto attachmentsOverlap = [](const Attachment& seen, const PassAttachment& incoming) {
if (seen.image != incoming.image) return false;
if (seen.sliceCount == 0 || incoming.sliceCount == 0) return true;
return seen.mip == incoming.mip && seen.firstSlice < incoming.firstSlice + incoming.sliceCount && incoming.firstSlice < seen.firstSlice + seen.sliceCount;
};
for (const auto& [image, written] : access.images) {
if (image == VK_NULL_HANDLE) continue;
if (std::any_of(images.begin(), images.end(), [&](const auto& seen) { return seen.first == image && conflicts(seen.second, written); })) return PassHazard::Image;
if (std::any_of(attachments.begin(), attachments.end(), [&](const Attachment& seen) { return seen.image == image && conflicts(seen.written, written); })) return PassHazard::Image;
}
for (const auto& [image, written] : access.attachments) {
if (image == VK_NULL_HANDLE) continue;
if (std::any_of(images.begin(), images.end(), [&](const auto& seen) { return seen.first == image && conflicts(seen.second, written); })) return PassHazard::Image;
if (std::any_of(attachments.begin(), attachments.end(), [&](const Attachment& seen) { return seen.image == image && !(samePass && seen.pass == pass) && conflicts(seen.written, written); })) return PassHazard::Image;
for (const auto& incoming : access.attachments) {
if (incoming.image == VK_NULL_HANDLE) continue;
if (std::any_of(images.begin(), images.end(), [&](const auto& seen) { return seen.first == incoming.image && conflicts(seen.second, incoming.written); })) return PassHazard::Image;
if (std::any_of(attachments.begin(), attachments.end(), [&](const Attachment& seen) { return attachmentsOverlap(seen, incoming) && !(samePass && seen.pass == pass) && conflicts(seen.written, incoming.written); })) return PassHazard::Image;
}
return PassHazard::None;
}
@@ -68,11 +73,11 @@ void PassHazards::Add(const PassAccess& access) {
if (it == images.end()) images.emplace_back(image, written);
else it->second = it->second || written;
}
for (const auto& [image, written] : access.attachments) {
if (image == VK_NULL_HANDLE) continue;
const auto it = std::find_if(attachments.begin(), attachments.end(), [&](const Attachment& seen) { return seen.image == image && seen.pass == pass; });
if (it == attachments.end()) attachments.push_back({image, written, pass});
else it->written = it->written || written;
for (const auto& incoming : access.attachments) {
if (incoming.image == VK_NULL_HANDLE) continue;
const auto it = std::find_if(attachments.begin(), attachments.end(), [&](const Attachment& seen) { return seen.image == incoming.image && seen.pass == pass && seen.mip == incoming.mip && seen.firstSlice == incoming.firstSlice && seen.sliceCount == incoming.sliceCount; });
if (it == attachments.end()) attachments.push_back({incoming.image, incoming.written, pass, incoming.mip, incoming.firstSlice, incoming.sliceCount});
else it->written = it->written || incoming.written;
}
anyReads = anyReads || access.anyReads;
anyWrites = anyWrites || access.anyWrites;
@@ -27,6 +27,7 @@
#include <deque>
#include <list>
#include <mutex>
#include <spirv/unified1/GLSL.std.450.h>
#include <spirv/unified1/spirv.hpp>
#include <stdexcept>
#include <string>
@@ -34,6 +35,7 @@
#include <thread>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <unordered_set>
#include <vector>
@@ -351,7 +353,7 @@ bool ShadersWriteMemory(std::span<const CompiledShader> shaders) {
void ValidateSampleMask(const Context& context, const State& state, std::span<const CompiledShader> shaders) {
if (!PartialSampleMask(state)) return;
const bool uniform = UniformSampleMask(state) && !SampleMaskFollowsOrder(state, HostSampleLocationsFor(context, state).order);
const bool uniform = UniformSampleMask(state) && !SampleMaskInShader(state, HostSampleLocationsFor(context, state).order, context.staticSampleMaskStopsShading);
for (const auto& shader : shaders) {
if (shader.stage != ShaderRecompiler::ShaderStage::Fragment) continue;
Require(shader.program != nullptr, "missing compiled fragment shader");
@@ -411,6 +413,285 @@ void appendKey(std::vector<std::byte>& key, const TValue& value) {
key.insert(key.end(), bytes.begin(), bytes.end());
}
bool FallbackDepth16(const Context& context, const State& state) {
return state.depth.has_value() && state.depth->format == VK_FORMAT_D16_UNORM_S8_UINT && HostDepthFormat(context, state.depth->format) != VK_FORMAT_D16_UNORM_S8_UINT;
}
bool QuantizesDepth16(const Context& context, const State& state) {
return FallbackDepth16(context, state) && (state.depthTest || state.depthWrite);
}
std::uint32_t QuantizeDepth16Step(float value) {
if (!(value > 0.0f)) return 0u;
if (value >= 1.0f) return 65535u;
return static_cast<std::uint32_t>(std::rint(value * 65535.0f));
}
std::pair<float, float> HostDepthBounds(const Context& context, const State& state) {
if (!FallbackDepth16(context, state)) return {state.minDepthBounds, state.maxDepthBounds};
const std::uint32_t minStep = QuantizeDepth16Step(state.minDepthBounds);
const std::uint32_t maxStep = QuantizeDepth16Step(state.maxDepthBounds);
if (minStep > maxStep) {
return {static_cast<float>(minStep) * (1.0f / 65535.0f), static_cast<float>(maxStep) * (1.0f / 65535.0f)};
}
const float minBound = minStep == 0u ? 0.0f : (static_cast<float>(minStep) - 0.25f) * (1.0f / 65535.0f);
const float maxBound = maxStep == 65535u ? 1.0f : (static_cast<float>(maxStep) + 0.25f) * (1.0f / 65535.0f);
return {minBound, maxBound};
}
std::vector<std::uint32_t> QuantizeFragmentDepth16(const CompiledShader& shader) {
const auto words = shader.program->spirv.Words();
Require(words.size() >= 5 && words[0] == spv::MagicNumber && words[3] != 0, "invalid fragment SPIR-V header");
std::uint32_t glslStd450Id = 0;
std::uint32_t entryPointId = 0;
bool earlyFragmentTests = false;
bool depthReplacing = false;
std::uint32_t fragDepthVar = 0;
std::uint32_t fragCoordVar = 0;
std::uint32_t f32Type = 0;
std::uint32_t u32Type = 0;
std::uint32_t v4f32Type = 0;
std::uint32_t ptrInputV4F32 = 0;
std::uint32_t ptrInputF32 = 0;
std::uint32_t ptrOutputF32 = 0;
std::uint32_t constU32_2 = 0;
std::uint32_t const0 = 0;
std::uint32_t const1 = 0;
std::uint32_t const65535 = 0;
std::uint32_t constInv65535 = 0;
for (std::size_t cursor = 5; cursor < words.size();) {
const auto count = words[cursor] >> 16u;
Require(count != 0 && count <= words.size() - cursor, "truncated fragment SPIR-V instruction");
const auto op = static_cast<spv::Op>(words[cursor] & 0xffffu);
if (op == spv::OpFunction) break;
if (op == spv::OpExtInstImport && count == 6 && words[cursor + 2] == 0x4c534c47u && words[cursor + 3] == 0x6474732eu && words[cursor + 4] == 0x3035342eu && words[cursor + 5] == 0u) glslStd450Id = words[cursor + 1];
else if (op == spv::OpEntryPoint && count >= 3 && words[cursor + 1] == spv::ExecutionModelFragment) entryPointId = words[cursor + 2];
else if (op == spv::OpExecutionMode && count >= 3) {
if (words[cursor + 2] == spv::ExecutionModeEarlyFragmentTests) earlyFragmentTests = true;
else if (words[cursor + 2] == spv::ExecutionModeDepthReplacing) depthReplacing = true;
} else if (op == spv::OpDecorate && count == 4 && words[cursor + 2] == spv::DecorationBuiltIn) {
if (words[cursor + 3] == spv::BuiltInFragDepth) fragDepthVar = words[cursor + 1];
else if (words[cursor + 3] == spv::BuiltInFragCoord) fragCoordVar = words[cursor + 1];
} else if (op == spv::OpTypeFloat && count == 3 && words[cursor + 2] == 32u) f32Type = words[cursor + 1];
else if (op == spv::OpTypeInt && count == 4 && words[cursor + 2] == 32u && words[cursor + 3] == 0u) u32Type = words[cursor + 1];
else if (op == spv::OpTypeVector && count == 4 && f32Type != 0 && words[cursor + 2] == f32Type && words[cursor + 3] == 4u) v4f32Type = words[cursor + 1];
else if (op == spv::OpTypePointer && count == 4) {
if (words[cursor + 2] == spv::StorageClassInput && v4f32Type != 0 && words[cursor + 3] == v4f32Type) ptrInputV4F32 = words[cursor + 1];
else if (words[cursor + 2] == spv::StorageClassInput && f32Type != 0 && words[cursor + 3] == f32Type) ptrInputF32 = words[cursor + 1];
else if (words[cursor + 2] == spv::StorageClassOutput && f32Type != 0 && words[cursor + 3] == f32Type) ptrOutputF32 = words[cursor + 1];
} else if (op == spv::OpConstant && count == 4) {
if (u32Type != 0 && words[cursor + 1] == u32Type && words[cursor + 3] == 2u) constU32_2 = words[cursor + 2];
else if (f32Type != 0 && words[cursor + 1] == f32Type) {
if (words[cursor + 3] == 0x00000000u) const0 = words[cursor + 2];
else if (words[cursor + 3] == 0x3f800000u) const1 = words[cursor + 2];
else if (words[cursor + 3] == 0x477fff00u) const65535 = words[cursor + 2];
else if (words[cursor + 3] == 0x37800080u) constInv65535 = words[cursor + 2];
}
}
cursor += count;
}
Require(entryPointId != 0, "fragment SPIR-V has no entry point");
Require(!earlyFragmentTests || !ShadersWriteMemory(std::span(&shader, 1)), "early fragment tests with memory writes on a 16-bit depth target with stencil that the device stores in another depth format are not implemented");
std::uint32_t nextId = words[3];
const bool needGlslStd450 = glslStd450Id == 0;
if (needGlslStd450) glslStd450Id = nextId++;
const bool needF32Type = f32Type == 0;
if (needF32Type) f32Type = nextId++;
const bool needFragCoord = fragDepthVar == 0;
bool needU32Type = false;
bool needV4F32Type = false;
bool needPtrInputV4F32 = false;
bool needPtrInputF32 = false;
bool needPtrOutputF32 = false;
bool needConstU32_2 = false;
bool createFragCoordVar = false;
bool createFragDepthVar = false;
if (needFragCoord) {
if (u32Type == 0) {
u32Type = nextId++;
needU32Type = true;
}
if (v4f32Type == 0) {
v4f32Type = nextId++;
needV4F32Type = true;
}
if (ptrInputV4F32 == 0) {
ptrInputV4F32 = nextId++;
needPtrInputV4F32 = true;
}
if (ptrInputF32 == 0) {
ptrInputF32 = nextId++;
needPtrInputF32 = true;
}
if (ptrOutputF32 == 0) {
ptrOutputF32 = nextId++;
needPtrOutputF32 = true;
}
if (constU32_2 == 0) {
constU32_2 = nextId++;
needConstU32_2 = true;
}
if (fragCoordVar == 0) {
fragCoordVar = nextId++;
createFragCoordVar = true;
}
fragDepthVar = nextId++;
createFragDepthVar = true;
}
const bool needConst0 = const0 == 0;
if (needConst0) const0 = nextId++;
const bool needConst1 = const1 == 0;
if (needConst1) const1 = nextId++;
const bool needConst65535 = const65535 == 0;
if (needConst65535) const65535 = nextId++;
const bool needConstInv65535 = constInv65535 == 0;
if (needConstInv65535) constInv65535 = nextId++;
const auto isPostAnnotation = [](spv::Op op) {
switch (op) {
case spv::OpCapability:
case spv::OpExtension:
case spv::OpExtInstImport:
case spv::OpMemoryModel:
case spv::OpEntryPoint:
case spv::OpExecutionMode:
case spv::OpExecutionModeId:
case spv::OpString:
case spv::OpSourceExtension:
case spv::OpSource:
case spv::OpSourceContinued:
case spv::OpName:
case spv::OpMemberName:
case spv::OpModuleProcessed:
case spv::OpDecorate:
case spv::OpMemberDecorate:
case spv::OpDecorationGroup:
case spv::OpGroupDecorate:
case spv::OpGroupMemberDecorate:
case spv::OpDecorateId:
case spv::OpDecorateString:
return false;
default:
return true;
}
};
std::vector<std::uint32_t> out;
out.reserve(words.size() + 64);
out.insert(out.end(), words.begin(), words.begin() + 5);
std::size_t copied = 5;
const auto flushTo = [&](std::size_t limit) {
if (copied < limit) {
out.insert(out.end(), words.begin() + static_cast<std::ptrdiff_t>(copied), words.begin() + static_cast<std::ptrdiff_t>(limit));
copied = limit;
}
};
const auto emitQuantizedStore = [&](std::uint32_t valueId, std::span<const std::uint32_t> storeTail) {
const auto clamped = nextId++;
const auto scaled = nextId++;
const auto rounded = nextId++;
const auto quantized = nextId++;
out.insert(out.end(), {
(8u << 16u) | static_cast<std::uint32_t>(spv::OpExtInst), f32Type, clamped, glslStd450Id, static_cast<std::uint32_t>(GLSLstd450FClamp), valueId, const0, const1,
(5u << 16u) | static_cast<std::uint32_t>(spv::OpFMul), f32Type, scaled, clamped, const65535,
(6u << 16u) | static_cast<std::uint32_t>(spv::OpExtInst), f32Type, rounded, glslStd450Id, static_cast<std::uint32_t>(GLSLstd450RoundEven), scaled,
(5u << 16u) | static_cast<std::uint32_t>(spv::OpFMul), f32Type, quantized, rounded, constInv65535,
((3u + static_cast<std::uint32_t>(storeTail.size())) << 16u) | static_cast<std::uint32_t>(spv::OpStore), fragDepthVar, quantized
});
out.insert(out.end(), storeTail.begin(), storeTail.end());
};
bool emittedDecorations = !createFragCoordVar && !createFragDepthVar;
bool emittedDeclarations = false;
bool inEntryFunction = false;
bool waitingForEntryInsert = false;
for (std::size_t cursor = 5; cursor < words.size();) {
const auto count = words[cursor] >> 16u;
Require(count != 0 && count <= words.size() - cursor, "truncated fragment SPIR-V instruction");
const auto op = static_cast<spv::Op>(words[cursor] & 0xffffu);
if (op == spv::OpMemoryModel && needGlslStd450) {
flushTo(cursor);
out.insert(out.end(), {(6u << 16u) | static_cast<std::uint32_t>(spv::OpExtInstImport), glslStd450Id, 0x4c534c47u, 0x6474732eu, 0x3035342eu, 0u});
}
if (!emittedDecorations && isPostAnnotation(op)) {
flushTo(cursor);
emittedDecorations = true;
if (createFragCoordVar) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpDecorate), fragCoordVar, static_cast<std::uint32_t>(spv::DecorationBuiltIn), static_cast<std::uint32_t>(spv::BuiltInFragCoord)});
if (createFragDepthVar) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpDecorate), fragDepthVar, static_cast<std::uint32_t>(spv::DecorationBuiltIn), static_cast<std::uint32_t>(spv::BuiltInFragDepth)});
}
if (!emittedDeclarations && op == spv::OpFunction) {
flushTo(cursor);
emittedDeclarations = true;
if (needF32Type) out.insert(out.end(), {(3u << 16u) | static_cast<std::uint32_t>(spv::OpTypeFloat), f32Type, 32u});
if (needU32Type) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpTypeInt), u32Type, 32u, 0u});
if (needV4F32Type) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpTypeVector), v4f32Type, f32Type, 4u});
if (needPtrInputV4F32) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpTypePointer), ptrInputV4F32, static_cast<std::uint32_t>(spv::StorageClassInput), v4f32Type});
if (needPtrInputF32) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpTypePointer), ptrInputF32, static_cast<std::uint32_t>(spv::StorageClassInput), f32Type});
if (needPtrOutputF32) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpTypePointer), ptrOutputF32, static_cast<std::uint32_t>(spv::StorageClassOutput), f32Type});
if (needConstU32_2) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpConstant), u32Type, constU32_2, 2u});
if (needConst0) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpConstant), f32Type, const0, 0x00000000u});
if (needConst1) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpConstant), f32Type, const1, 0x3f800000u});
if (needConst65535) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpConstant), f32Type, const65535, 0x477fff00u});
if (needConstInv65535) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpConstant), f32Type, constInv65535, 0x37800080u});
if (createFragCoordVar) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpVariable), ptrInputV4F32, fragCoordVar, static_cast<std::uint32_t>(spv::StorageClassInput)});
if (createFragDepthVar) out.insert(out.end(), {(4u << 16u) | static_cast<std::uint32_t>(spv::OpVariable), ptrOutputF32, fragDepthVar, static_cast<std::uint32_t>(spv::StorageClassOutput)});
}
if (op == spv::OpEntryPoint) {
if (needFragCoord) {
const auto entrySpan = words.subspan(cursor, count);
const bool addCoord = createFragCoordVar || std::find(entrySpan.begin() + 5, entrySpan.end(), fragCoordVar) == entrySpan.end();
const bool addDepth = createFragDepthVar || std::find(entrySpan.begin() + 5, entrySpan.end(), fragDepthVar) == entrySpan.end();
const std::uint32_t extra = (addCoord ? 1u : 0u) + (addDepth ? 1u : 0u);
flushTo(cursor);
out.push_back(((count + extra) << 16u) | static_cast<std::uint32_t>(spv::OpEntryPoint));
out.insert(out.end(), words.begin() + static_cast<std::ptrdiff_t>(cursor + 1), words.begin() + static_cast<std::ptrdiff_t>(cursor + count));
if (addCoord) out.push_back(fragCoordVar);
if (addDepth) out.push_back(fragDepthVar);
copied = cursor + count;
}
if (!depthReplacing) {
flushTo(cursor + count);
out.insert(out.end(), {(3u << 16u) | static_cast<std::uint32_t>(spv::OpExecutionMode), entryPointId, static_cast<std::uint32_t>(spv::ExecutionModeDepthReplacing)});
}
cursor += count;
continue;
}
if (op == spv::OpExecutionMode && count >= 3 && (words[cursor + 2] == spv::ExecutionModeEarlyFragmentTests || words[cursor + 2] == spv::ExecutionModeDepthLess || words[cursor + 2] == spv::ExecutionModeDepthGreater)) {
flushTo(cursor);
copied = cursor + count;
cursor += count;
continue;
}
if (needFragCoord) {
if (op == spv::OpFunction && count >= 3 && words[cursor + 2] == entryPointId) inEntryFunction = true;
else if (op == spv::OpFunctionEnd) {
inEntryFunction = false;
waitingForEntryInsert = false;
} else if (inEntryFunction && op == spv::OpLabel) {
inEntryFunction = false;
waitingForEntryInsert = true;
} else if (waitingForEntryInsert && op != spv::OpVariable && op != spv::OpLine && op != spv::OpNoLine) {
flushTo(cursor);
const auto zPtr = nextId++;
const auto zValue = nextId++;
out.insert(out.end(), {
(5u << 16u) | static_cast<std::uint32_t>(spv::OpAccessChain), ptrInputF32, zPtr, fragCoordVar, constU32_2,
(4u << 16u) | static_cast<std::uint32_t>(spv::OpLoad), f32Type, zValue, zPtr
});
emitQuantizedStore(zValue, {});
break;
}
} else if (op == spv::OpStore && count >= 3 && words[cursor + 1] == fragDepthVar) {
flushTo(cursor);
emitQuantizedStore(words[cursor + 2], words.subspan(cursor + 3, count - 3));
copied = cursor + count;
cursor += count;
continue;
}
cursor += count;
}
flushTo(words.size());
out[3] = nextId;
return out;
}
bool narrowLibraryKeysNow() {
return !RuntimeSwitches::Set(RuntimeSwitch::WideLibraryKeys);
}
@@ -516,7 +797,11 @@ bool libraryKeys(PipelineLibraryKeys& keys, const Context& context, const State&
appendKey(keys.renderPass, color.partialWriteMask != 0u);
}
appendKey(keys.renderPass, state.depth.has_value());
if (state.depth) appendKey(keys.renderPass, state.depth->format);
if (state.depth) {
appendKey(keys.renderPass, state.depth->format);
appendKey(keys.renderPass, HostDepthFormat(context, state.depth->format));
}
appendKey(keys.fragmentShader, QuantizesDepth16(context, state));
sampleKey(HostSampleMask(state));
for (auto* key : {&keys.fragmentShader, &keys.fragmentOutput}) {
appendKey(*key, context.sampleLocationSampleCounts);
@@ -606,10 +891,11 @@ Pipeline::Pipeline(const Context& context, const State& state, const VertexInput
std::vector<PipelineSpecialization> specializations;
specializations.reserve(shaders.size());
const VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT meshSubgroup{VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT, nullptr, 32u};
const bool quantizeDepth16 = QuantizesDepth16(context, state);
for (std::uint32_t i = 0; i < shaders.size(); ++i) {
const auto& shader = *shaders[i].program;
const auto demoted = (barycentricPatches || state.rectList) && shaders[i].stage == ShaderRecompiler::ShaderStage::Vertex ? DemoteVertexLayerOutput(shader.spirv.Words()) : std::vector<std::uint32_t>{};
const auto words = demoted.empty() ? shader.spirv.Words() : std::span<const std::uint32_t>(demoted);
const auto patched = (barycentricPatches || state.rectList) && shaders[i].stage == ShaderRecompiler::ShaderStage::Vertex ? DemoteVertexLayerOutput(shader.spirv.Words()) : quantizeDepth16 && shaders[i].stage == ShaderRecompiler::ShaderStage::Fragment ? QuantizeFragmentDepth16(shaders[i]) : std::vector<std::uint32_t>{};
const auto words = patched.empty() ? shader.spirv.Words() : std::span<const std::uint32_t>(patched);
_modules[i] = CreateShaderModule(context, words.data(), words.size() * sizeof(std::uint32_t), "vkCreateShaderModule graphics");
const auto stage = VulkanStage(shaders[i].stage);
stages[i].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
@@ -788,7 +1074,7 @@ Pipeline::Pipeline(const Context& context, const State& state, const VertexInput
depthStencil.front = state.stencilFront;
depthStencil.back = state.stencilBack;
const VkSampleMask sampleMask = HostSampleMask(state);
if (PartialSampleMask(state) && UniformSampleMask(state) && !SampleMaskFollowsOrder(state, sampleOrder)) samples.pSampleMask = &sampleMask;
if (PartialSampleMask(state) && UniformSampleMask(state) && !SampleMaskInShader(state, sampleOrder, context.staticSampleMaskStopsShading)) samples.pSampleMask = &sampleMask;
VkPipelineColorBlendStateCreateInfo blend{VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO};
const bool alternateAlpha = SplitsAlternateAlpha(state);
std::vector<VkPipelineColorBlendAttachmentState> firstChannels(state.blends.begin(), state.blends.end());
@@ -1069,16 +1355,18 @@ void Pipeline::Continue(CommandState& recording, const State& state, const State
}
if (depthBias) recording.SetDepthBias(context, HostDepthBiasConstant(context, state.depth->format, state.depthBiasConstant), state.depthBiasClamp, state.depthBiasSlope);
if (!depthBounds) return;
recording.SetDepthBounds(context, state.minDepthBounds, state.maxDepthBounds);
const auto [minDepthBounds, maxDepthBounds] = HostDepthBounds(context, state);
recording.SetDepthBounds(context, minDepthBounds, maxDepthBounds);
}
void Pipeline::setLibraryState(CommandState& recording, const State& state) const {
const bool depth = state.depth.has_value();
const auto [minDepthBounds, maxDepthBounds] = depthBounds ? HostDepthBounds(context, state) : std::pair{0.0f, 1.0f};
recording.SetCullMode(context, state.cullMode);
recording.SetFrontFace(context, state.frontFace);
recording.SetDepthBias(context, depthBias ? HostDepthBiasConstant(context, state.depth->format, state.depthBiasConstant) : 0.0f, depthBias ? state.depthBiasClamp : 0.0f, depthBias ? state.depthBiasSlope : 0.0f);
if (dynamicDepthBiasEnable) recording.SetDepthBiasEnable(context, depthBias);
recording.SetDepthBounds(context, depthBounds ? state.minDepthBounds : 0.0f, depthBounds ? state.maxDepthBounds : 1.0f);
recording.SetDepthBounds(context, minDepthBounds, maxDepthBounds);
recording.SetDepthTestEnable(context, depth && state.depthTest);
recording.SetDepthWriteEnable(context, depth && state.depthWrite);
recording.SetDepthCompareOp(context, depth ? state.depthCompare : VK_COMPARE_OP_ALWAYS);
@@ -1140,7 +1428,10 @@ void Pipeline::ContinueBackFaces(CommandState& recording, const State& state, co
setColorWriteMasks(recording, state, masked, false);
setViewports(recording, state);
recording.SetDepthBias(context, HostDepthBiasConstant(context, state.depth->format, state.backDepthBiasConstant), state.depthBiasClamp, state.backDepthBiasSlope);
if (depthBounds) recording.SetDepthBounds(context, state.minDepthBounds, state.maxDepthBounds);
if (depthBounds) {
const auto [minDepthBounds, maxDepthBounds] = HostDepthBounds(context, state);
recording.SetDepthBounds(context, minDepthBounds, maxDepthBounds);
}
}
void Pipeline::PushConstants(VkCommandBuffer commands, VkShaderStageFlags stages, std::span<const std::byte, PipelinePushConstantBytes> bytes) const {
@@ -1270,6 +1561,7 @@ std::size_t pipelineKey(std::vector<std::byte>& storage, const Context& context,
append(key, state.depth.has_value());
if (state.depth) {
append(key, state.depth->format);
append(key, HostDepthFormat(context, state.depth->format));
append(key, state.depth->samples);
append(key, state.depthTest);
append(key, state.depthWrite);
@@ -9,6 +9,7 @@
#include "prx/libc/include/HostThreadSlot.hpp"
#include "prx/libSceAgcDriver/Execution/include/ThreadScratch.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Recorder.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DrawStageTimingKeys.hpp"
#include "prx/libSceAgcDriver/Graphics/include/BdaResources.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ReferenceStorage.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp"
@@ -34,6 +35,8 @@
#include "prx/libc/include/GuestAllocations.hpp"
#include "prx/libc/include/GuestArena.hpp"
#include "prx/libSceAgcDriver/Graphics/shaders/DispatchArguments_spv.h"
#include "prx/libSceAgcDriver/Graphics/shaders/StorePageGather_spv.h"
#include "BdaAbi.hpp"
#include <algorithm>
#include <array>
#include <atomic>
@@ -211,7 +214,7 @@ constexpr std::uint32_t DumpFoldCapacity = 1024;
constexpr std::uint32_t SampleDumpBytes = 15 * 16 + 8;
constexpr VkDeviceSize DumpListOffset = 16 + 8 * SegmentFoldCapacity;
constexpr std::uint32_t SampleDumpPushBytes = 40;
std::atomic<std::uint64_t> dumpsQueued{0}, dumpsQueuedInPass{0}, dumpsAtOnce{0}, segmentsClosed{0}, dumpFolds{0};
std::atomic<std::uint64_t> dumpsQueued{0}, dumpsQueuedInPass{0}, dumpsAtOnce{0}, segmentsClosed{0}, dumpFolds{0}, capacityFolds{0};
struct SamplePoolCache {
VkDevice device;
@@ -577,6 +580,7 @@ bool ProcTable() {
// under this mutex takes the GPU mutex (no lock-order cycle).
AgcDriver::Mutex labelTableMutex;
std::atomic<unsigned> injectedSubmitFailures{0};
std::atomic<unsigned> injectedDiscardRegistrationFailures{0};
Recorder* labelTableOwner = nullptr;
// The ranges of the calling worker's queued labels (NoteQueuedLabel, cleared by
// ForgetQueuedLabels): the flush hook, on the same thread, has them recorded before an access that
@@ -1496,6 +1500,8 @@ Recorder::~Recorder() {
}
if (dispatchArgumentPipeline != VK_NULL_HANDLE) context.Function<PFN_vkDestroyPipeline>("vkDestroyPipeline")(context.device, dispatchArgumentPipeline, nullptr);
if (dispatchArgumentLayout != VK_NULL_HANDLE) context.Function<PFN_vkDestroyPipelineLayout>("vkDestroyPipelineLayout")(context.device, dispatchArgumentLayout, nullptr);
if (storePageGatherPipeline != VK_NULL_HANDLE) context.Function<PFN_vkDestroyPipeline>("vkDestroyPipeline")(context.device, storePageGatherPipeline, nullptr);
if (storePageGatherLayout != VK_NULL_HANDLE) context.Function<PFN_vkDestroyPipelineLayout>("vkDestroyPipelineLayout")(context.device, storePageGatherLayout, nullptr);
for (const auto fence : spare) context.Function<PFN_vkDestroyFence>("vkDestroyFence")(context.device, fence, nullptr);
spare.clear();
for (const auto pool : sparePools) context.Function<PFN_vkDestroyQueryPool>("vkDestroyQueryPool")(context.device, pool, nullptr);
@@ -2105,7 +2111,7 @@ Recorder::DrawPassStart Recorder::StartDrawPass(std::uint64_t key, bool forced,
return {open->commands, true, false, PassBreak::Continued};
}
const auto reason = PassBreakFor(hazard);
const bool merge = MergeBarriers() && !fenced && !pass.fenced && !pass.afterPass;
const bool merge = MergeBarriers() && !fenced && !pass.fenced && !pass.afterPass && pass.afterEnd.empty();
const bool elide = merge && hazard == PassHazard::None;
endOpenRenderPass(reason, !merge);
const auto commands = Commands();
@@ -2127,6 +2133,11 @@ void Recorder::LeaveRenderPassOpen(std::uint64_t key, std::uint32_t timing, bool
open->passHazards.Add(access);
}
void Recorder::AfterRenderPass(std::function<void(Recorder&)> work) {
Require(RenderPassOpen(), "work after a render pass without an open render pass");
open->renderPass.afterEnd.push_back(std::move(work));
}
void Recorder::SealPassWriteOnly() {
if (open != nullptr) open->passHazards.SealWriteOnly();
}
@@ -2150,9 +2161,19 @@ void Recorder::endOpenRenderPass(PassBreak by, bool barrier) {
EndGpuTiming(pass.timing);
open->coveredAccess = barrier ? VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT : 0;
open->hostReadOwed = true;
auto after = std::move(pass.afterEnd);
pass = {};
pass.closedBy = by;
PerformanceTrace::Amount(PassBreakScopeNames[static_cast<std::size_t>(by)], 1);
std::exception_ptr failure;
for (auto& work : after) {
try {
work(*this);
} catch (...) {
if (failure == nullptr) failure = std::current_exception();
}
}
if (failure != nullptr) std::rethrow_exception(failure);
}
void Recorder::QueueKeyStore(VkBuffer buffer, VkDeviceSize first, VkDeviceSize last, std::shared_ptr<void> seed, std::uint64_t begin, std::uint64_t end) {
@@ -2227,6 +2248,7 @@ void Recorder::ensureOpen() {
if (open == nullptr) {
++passGeneration;
auto batch = std::make_unique<Batch>();
batch->sampleBatch = ++sampleBatches;
try {
VkCommandBufferAllocateInfo allocation{VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO};
allocation.commandPool = context.pool;
@@ -2382,7 +2404,7 @@ bool Recorder::closeStoreRun(bool atSubmit) {
// A label says the work before it is done: the queued key stores (results of that work)
// land ahead of every store of the run, and the pass a draw left open ends.
if (!open->keyStores.empty()) recordKeyStores(true);
const bool passEndLast = open->renderPass.open && !open->renderPass.afterPass;
const bool passEndLast = open->renderPass.open && !open->renderPass.afterPass && open->renderPass.afterEnd.empty();
if (open->renderPass.open) endOpenRenderPass(PassBreak::Label);
const auto commands = open->commands;
run.timing = beginTiming(ClassKey(CommandClass::LabelRun));
@@ -2581,7 +2603,7 @@ void reportBarriers() {
AgcDriver::ProfilePrint_nid_no_patch("; validate: would emit %llu (%s) + %llu batch ends, would skip %llu; emitted/skipped by class:%s", static_cast<unsigned long long>(emitted), kinds.c_str() + 1, static_cast<unsigned long long>(validateBatchEnds.exchange(0, std::memory_order_relaxed)), static_cast<unsigned long long>(skipped), classes.c_str());
}
AgcDriver::ProfilePrint_nid_no_patch("\n");
AgcDriver::ProfilePrint_nid_no_patch("[samples] occlusion dumps (cumulative): %llu queued (%llu inside an open pass), %llu recorded at once; %llu segments closed; %llu folds of queued dumps\n", static_cast<unsigned long long>(dumpsQueued.load(std::memory_order_relaxed)), static_cast<unsigned long long>(dumpsQueuedInPass.load(std::memory_order_relaxed)), static_cast<unsigned long long>(dumpsAtOnce.load(std::memory_order_relaxed)), static_cast<unsigned long long>(segmentsClosed.load(std::memory_order_relaxed)), static_cast<unsigned long long>(dumpFolds.load(std::memory_order_relaxed)));
AgcDriver::ProfilePrint_nid_no_patch("[samples] occlusion dumps (cumulative): %llu queued (%llu inside an open pass), %llu recorded at once; %llu segments closed; %llu folds of queued dumps, %llu at capacity\n", static_cast<unsigned long long>(dumpsQueued.load(std::memory_order_relaxed)), static_cast<unsigned long long>(dumpsQueuedInPass.load(std::memory_order_relaxed)), static_cast<unsigned long long>(dumpsAtOnce.load(std::memory_order_relaxed)), static_cast<unsigned long long>(segmentsClosed.load(std::memory_order_relaxed)), static_cast<unsigned long long>(dumpFolds.load(std::memory_order_relaxed)), static_cast<unsigned long long>(capacityFolds.load(std::memory_order_relaxed)));
}
}
@@ -2713,10 +2735,36 @@ std::uint32_t Recorder::BeginGpuTiming(std::uint64_t key) {
std::string Recorder::TimingKeyLabel(std::uint64_t key) {
char text[32];
if (DrawStageTimingEnabled() && (key & (DrawTimingFlag | DrawStageTimingFlag)) == (DrawTimingFlag | DrawStageTimingFlag)) {
std::snprintf(text, sizeof(text), "drawset 0x%llx", static_cast<unsigned long long>(key & ~(DrawTimingFlag | DrawStageTimingFlag)));
return text;
}
std::snprintf(text, sizeof(text), (key & DrawTimingFlag) != 0 ? "draw 0x%llx" : "0x%llx", static_cast<unsigned long long>(key & ~DrawTimingFlag));
return text;
}
bool Recorder::DrawStageTimingEnabled() {
static const bool enabled = std::getenv("APS5_PROFILE_GPU_DRAW_STAGES") != nullptr;
return enabled;
}
std::uint64_t Recorder::DrawStageTimingKey(std::span<const std::pair<std::uint32_t, std::uint64_t>> stages) {
static auto* keys = new DrawStageTimingKeys;
const auto [key, inserted] = keys->Intern(stages);
if (inserted) {
char text[96];
std::snprintf(text, sizeof(text), "[drawstages] drawset 0x%llx", static_cast<unsigned long long>(key));
std::string line = text;
for (const auto& [stage, variant] : stages) {
std::snprintf(text, sizeof(text), " %u:0x%llx", stage, static_cast<unsigned long long>(variant));
line += text;
}
line += '\n';
AgcDriver::ProfilePrint_nid_no_patch("%s", line.c_str());
}
return key | DrawTimingFlag | DrawStageTimingFlag;
}
std::uint32_t Recorder::BeginInPassGpuTiming(std::uint64_t key) {
if (!GpuTimingEnabled() || open == nullptr || open->queries == VK_NULL_HANDLE) return NoTiming;
return beginTiming(key);
@@ -2808,6 +2856,66 @@ bool Recorder::RecordDispatchArguments(VkCommandBuffer commands, VkDeviceAddress
return true;
}
void Recorder::RecordStorePageGather(VkCommandBuffer commands, const StorePageGather& gather) {
namespace Abi = ShaderRecompiler::BdaAbi;
struct Parameters {
VkDeviceAddress fault;
VkDeviceAddress pages;
VkDeviceAddress targets;
std::uint64_t base;
std::uint32_t count;
std::uint32_t slots;
std::uint32_t writtenCountWord;
std::uint32_t writtenSlotsWord;
std::uint32_t writtenListWord;
std::uint32_t overflowWord;
};
static_assert(sizeof(Parameters) == 56);
if (storePageGatherPipeline == VK_NULL_HANDLE) {
VkShaderModule module = VK_NULL_HANDLE;
try {
const VkPushConstantRange push{VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(Parameters)};
VkPipelineLayoutCreateInfo layoutInfo{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
layoutInfo.pushConstantRangeCount = 1;
layoutInfo.pPushConstantRanges = &push;
if (storePageGatherLayout == VK_NULL_HANDLE) Check(context.Function<PFN_vkCreatePipelineLayout>("vkCreatePipelineLayout")(context.device, &layoutInfo, nullptr, &storePageGatherLayout), "vkCreatePipelineLayout store page gather");
module = CreateShaderModule(context, STORE_PAGE_GATHER_SPV, sizeof(STORE_PAGE_GATHER_SPV), "vkCreateShaderModule store page gather");
VkComputePipelineCreateInfo pipelineInfo{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO};
pipelineInfo.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO};
pipelineInfo.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
pipelineInfo.stage.module = module;
pipelineInfo.stage.pName = "main";
pipelineInfo.layout = storePageGatherLayout;
Check(context.Function<PFN_vkCreateComputePipelines>("vkCreateComputePipelines")(context.device, context.pipelineCache, 1, &pipelineInfo, nullptr, &storePageGatherPipeline), "vkCreateComputePipelines store page gather");
context.Function<PFN_vkDestroyShaderModule>("vkDestroyShaderModule")(context.device, module, nullptr);
} catch (...) {
if (module != VK_NULL_HANDLE) context.Function<PFN_vkDestroyShaderModule>("vkDestroyShaderModule")(context.device, module, nullptr);
throw;
}
}
recordBarrier(commands, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_HOST_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
context.BindComputePipeline(commands, storePageGatherPipeline);
const Parameters parameters{gather.fault, gather.pages, gather.targets, gather.base, gather.count, gather.slots, Abi::WrittenCountWord, Abi::WrittenSlotsWord, Abi::WrittenListWord, Abi::StorePageOverflowWord};
function(cmdPushConstants, "vkCmdPushConstants")(commands, storePageGatherLayout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(parameters), &parameters);
function(cmdDispatch, "vkCmdDispatch")(commands, 64, 1, 1);
recordBarrier(commands, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_HOST_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
CountBarriers(CommandClass::StagingOut, 2);
}
std::unique_ptr<Buffer> Recorder::TakeStorePagePool(std::size_t bytes) {
std::lock_guard lock(storePagePoolsMutex);
const auto found = std::find_if(storePagePools.begin(), storePagePools.end(), [&](const auto& pool) { return pool->Bytes().size() == bytes; });
if (found == storePagePools.end()) return nullptr;
auto pool = std::move(*found);
storePagePools.erase(found);
return pool;
}
void Recorder::KeepStorePagePool(std::unique_ptr<Buffer> pool) {
std::lock_guard lock(storePagePoolsMutex);
if (storePagePools.size() < 4) storePagePools.push_back(std::move(pool));
}
void Recorder::CountSamples() {
GuestMemory::AssertGpuLockHeld("Recorder::CountSamples");
gpuSampleCounter();
@@ -2997,7 +3105,7 @@ bool Recorder::QueuesSampleDumps() const {
}
Recorder::SampleDumpStatistics Recorder::SampleDumpCounts() {
return SampleDumpStatistics{dumpsQueued.load(std::memory_order_relaxed), dumpsQueuedInPass.load(std::memory_order_relaxed), dumpsAtOnce.load(std::memory_order_relaxed), segmentsClosed.load(std::memory_order_relaxed), dumpFolds.load(std::memory_order_relaxed)};
return SampleDumpStatistics{dumpsQueued.load(std::memory_order_relaxed), dumpsQueuedInPass.load(std::memory_order_relaxed), dumpsAtOnce.load(std::memory_order_relaxed), segmentsClosed.load(std::memory_order_relaxed), dumpFolds.load(std::memory_order_relaxed), capacityFolds.load(std::memory_order_relaxed)};
}
bool Recorder::segmentSlotReady(const Batch& batch) const {
@@ -3069,7 +3177,8 @@ void Recorder::beginSegment(Batch& batch) {
void Recorder::endSegment(Batch& batch) {
function(cmdEndQuery, "vkCmdEndQuery")(batch.commands, batch.segments, batch.segmentSlot);
batch.segmentActive = false;
pendingSamples.push_back({batch.segmentPool, batch.segments, batch.segmentSlot});
reserveSampleRestore(batch);
pendingSamples.push_back({batch.segmentPool, batch.segments, batch.segmentSlot, batch.sampleBatch});
segmentsClosed.fetch_add(1, std::memory_order_relaxed);
}
@@ -3085,10 +3194,13 @@ void Recorder::copySegments(VkCommandBuffer commands, std::uint32_t count) {
}
}
void Recorder::reserveSampleRestore(const Batch& batch) {
const auto needed = pendingSamples.size() + batch.foldedSamples.size() + 1;
if (needed > pendingSamples.capacity()) pendingSamples.reserve(std::max(needed, 2 * pendingSamples.capacity()));
}
void Recorder::retireSegments(std::uint32_t count) {
for (std::uint32_t i = 0; i < count; ++i) {
if (pendingSamples[i].pool != nullptr) open->kept.push_back(std::move(pendingSamples[i].pool));
}
open->foldedSamples.insert(open->foldedSamples.end(), std::make_move_iterator(pendingSamples.begin()), std::make_move_iterator(pendingSamples.begin() + count));
pendingSamples.erase(pendingSamples.begin(), pendingSamples.begin() + count);
}
@@ -3155,13 +3267,17 @@ void Recorder::foldSegments() {
recordBarrier(commands, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_HOST_READ_BIT);
CountBarriers(CommandClass::Copy, 3);
retireSegments(count);
capacityFolds.fetch_add(1, std::memory_order_relaxed);
}
void Recorder::endSamples(Batch& batch) {
if (!batch.sampleActive) return;
function(cmdEndQuery, "vkCmdEndQuery")(batch.commands, batch.samples, 0);
batch.sampleActive = false;
if (sampleCounterState > 0 && batch.samplesDrawn) pendingSamples.push_back({batch.samplePool, batch.samples});
if (sampleCounterState > 0 && batch.samplesDrawn) {
reserveSampleRestore(batch);
pendingSamples.push_back({batch.samplePool, batch.samples, 0, batch.sampleBatch});
}
batch.samplesDrawn = false;
}
@@ -3207,6 +3323,7 @@ void Recorder::foldSamples(Batch& batch, VkDeviceAddress target, std::uint32_t b
} while (done < pendingSamples.size());
recordBarrier(commands, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT | VK_PIPELINE_STAGE_HOST_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_INDIRECT_COMMAND_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_HOST_READ_BIT);
CountBarriers(CommandClass::Copy, target != 0 ? 4u : 2u);
batch.foldedSamples.insert(batch.foldedSamples.end(), std::make_move_iterator(pendingSamples.begin()), std::make_move_iterator(pendingSamples.end()));
pendingSamples.clear();
}
@@ -4016,6 +4133,23 @@ void Recorder::OnComplete(std::function<void()> action) {
writeBackCompletions.fetch_add(1, std::memory_order_acq_rel);
}
void Recorder::OnDiscard(std::function<void()> action) {
ensureOpen();
open->discards.push_back(std::move(action));
}
void Recorder::ChangeUndoneOnDiscard(const std::function<void()>& change, std::function<void()> undo) {
ensureOpen();
if (injectedDiscardRegistrationFailures.load(std::memory_order_relaxed) != 0 && injectedDiscardRegistrationFailures.fetch_sub(1, std::memory_order_relaxed) != 0) throw std::bad_alloc();
open->discards.reserve(open->discards.size() + 1u);
change();
open->discards.push_back(std::move(undo));
}
void Recorder::FailNextDiscardRegistrationsForTest(unsigned count) {
injectedDiscardRegistrationFailures.store(count, std::memory_order_relaxed);
}
void Recorder::OnWriteComplete(std::uint64_t address, std::size_t bytes, std::function<void()> action) {
const auto end = address + bytes;
Batch* holder = open != nullptr && overlaps(*open, address, end) ? open.get() : nullptr;
@@ -4571,6 +4705,10 @@ std::size_t Recorder::PendingLabels() const {
bool Recorder::PendingLabelIn(std::uint64_t address, std::size_t bytes) const {
std::lock_guard tableLock(labelTableMutex);
return pendingLabelInLocked(address, bytes);
}
bool Recorder::pendingLabelInLocked(std::uint64_t address, std::size_t bytes) const {
if (bytes == 0) return false;
const auto end = address + bytes;
if (const auto first = labels.lower_bound(address); first != labels.end() && first->first < end) return true;
@@ -4701,7 +4839,6 @@ bool Recorder::AfterRecordedWork(std::function<void()> action) {
batch.completions.push_back(std::move(action));
++batch.completionLabelCount;
completionLabels.fetch_add(1, std::memory_order_acq_rel);
GuestMemory::BreakProofs();
if (&batch == open.get() && activeRecorder == this && pendingLabelSince.load(std::memory_order_relaxed) == NoPendingLabel) {
pendingLabelSince.store(std::chrono::steady_clock::now().time_since_epoch().count(), std::memory_order_release);
}
@@ -4740,6 +4877,24 @@ void Recorder::NoteWrittenBack(std::uint64_t address, std::size_t bytes) {
for (auto& batch : recorder->inFlight) count(*batch);
}
void Recorder::NoteWrittenBack(std::span<const std::pair<std::uint64_t, std::uint64_t>> runs) {
Recorder* recorder = activeRecorder;
if (recorder == nullptr || runs.empty()) return;
std::vector<std::pair<std::uint64_t, std::uint64_t>> joined;
{
std::lock_guard tableLock(labelTableMutex);
for (const auto& [begin, end] : runs) {
if (!joined.empty() && (begin <= joined.back().second || !recorder->pendingLabelInLocked(joined.back().second, static_cast<std::size_t>(begin - joined.back().second)))) joined.back().second = std::max(joined.back().second, end);
else joined.emplace_back(begin, end);
}
}
for (const auto& [begin, end] : joined) NoteWrittenBack(begin, static_cast<std::size_t>(end - begin));
}
std::uint64_t Recorder::WriteBacksOverLabels() {
return writeBacksOverLabels.load(std::memory_order_relaxed);
}
bool Recorder::writtenBackSince(std::uint64_t sequence, std::uint64_t begin, std::uint64_t end) {
std::lock_guard ringLock(writtenBackMutex);
if (writtenBack.empty() || writtenBack.back()[0] <= sequence) return false;
@@ -4779,7 +4934,10 @@ void Recorder::Submit() {
const bool segments = segmentMode();
if (!segments) {
endSamples(*open);
if (pendingSamples.size() >= SampleFoldCapacity) foldSamples(*open, 0);
if (pendingSamples.size() >= SampleFoldCapacity) {
foldSamples(*open, 0);
capacityFolds.fetch_add(1, std::memory_order_relaxed);
}
}
const bool hostReadCovered = (open->run.open || !open->run.queued.empty()) && closeStoreRun(true);
if (segments && pendingSamples.size() >= SampleFoldCapacity) foldSegments();
@@ -5436,6 +5594,23 @@ void Recorder::finish(std::unique_ptr<Batch> batch, bool wait, int source, bool
}
void Recorder::discard(std::unique_ptr<Batch> batch) noexcept {
std::erase_if(pendingSamples, [&](const SampleSegment& sample) { return sample.batch == batch->sampleBatch; });
std::erase_if(batch->foldedSamples, [&](const SampleSegment& sample) { return sample.batch == batch->sampleBatch; });
if (pendingSamples.size() + batch->foldedSamples.size() <= pendingSamples.capacity()) {
pendingSamples.insert(pendingSamples.begin(), std::make_move_iterator(batch->foldedSamples.begin()), std::make_move_iterator(batch->foldedSamples.end()));
} else {
std::fprintf(stderr, "[samples] %zu occlusion samples folded by a discarded batch are lost: no capacity was reserved to restore them\n", batch->foldedSamples.size());
}
for (auto& action : batch->discards) {
try {
action();
} catch (const std::exception& error) {
std::fprintf(stderr, "[recorder] a discarded batch's discard action failed: %s\n", error.what());
} catch (...) {
std::fprintf(stderr, "[recorder] a discarded batch's discard action failed with a non-standard exception\n");
}
}
batch->discards.clear();
removeLabels(*batch);
if (batch->completionLabelCount != 0) completionLabels.fetch_sub(batch->completionLabelCount, std::memory_order_acq_rel);
if (batch->completionStoreCount != 0) completionStores.fetch_sub(batch->completionStoreCount, std::memory_order_acq_rel);
@@ -2,6 +2,7 @@
#include <algorithm>
#include <array>
#include <atomic>
#include <cctype>
#include <cerrno>
#include <cmath>
#include <cstdio>
@@ -37,6 +38,9 @@ constexpr std::array<const char*, SwitchCount> SwitchNames{
"APS5_INDEX_IN_PLACE_BEHIND_WRITER",
"APS5_WIDE_LIBRARY_KEYS",
"APS5_NO_WIDE_TABLE_COPY_HLE",
"APS5_NO_DCC_MIP_FAST_CLEAR",
"APS5_NO_TABLE_ENTRY_MEMO",
"APS5_PASS_STAGING",
};
struct SwitchValues {
@@ -63,6 +67,9 @@ struct SwitchValues {
std::getenv("APS5_INDEX_IN_PLACE_BEHIND_WRITER") != nullptr,
std::getenv("APS5_WIDE_LIBRARY_KEYS") != nullptr,
std::getenv("APS5_NO_WIDE_TABLE_COPY_HLE") != nullptr,
std::getenv("APS5_NO_DCC_MIP_FAST_CLEAR") != nullptr,
std::getenv("APS5_NO_TABLE_ENTRY_MEMO") != nullptr,
std::getenv("APS5_PASS_STAGING") != nullptr,
};
for (std::size_t index = 0; index < SwitchCount; ++index) set[index].store(environment[index], std::memory_order_relaxed);
}
@@ -93,6 +100,48 @@ std::string FlippableList() {
return list;
}
std::vector<RuntimeSwitch> ParseSwitchList(std::string_view list, std::string_view ab) {
std::vector<RuntimeSwitch> switches;
for (;;) {
const auto plus = list.find('+');
const auto name = Trim(list.substr(0, plus));
if (name.empty()) throw std::invalid_argument("APS5_AB: an empty switch name in '" + std::string(ab) + "'");
const auto found = RuntimeSwitches::Find(name);
if (!found.has_value()) throw std::invalid_argument("APS5_AB: " + std::string(name) + " cannot change while the title runs; switches the A/B can change: " + FlippableList());
if (std::find(switches.begin(), switches.end(), *found) != switches.end()) throw std::invalid_argument("APS5_AB: " + std::string(name) + " is listed twice");
switches.push_back(*found);
if (plus == std::string_view::npos) break;
list = list.substr(plus + 1);
}
return switches;
}
AbSchedule::Arm ParseArm(std::string_view token, std::string_view ab, const std::vector<AbSchedule::Arm>& defined) {
if (token.empty()) throw std::invalid_argument("APS5_AB: an empty arm in '" + std::string(ab) + "'");
if (token == "A") return {"A", {}};
const auto equal = token.find('=');
if (equal != std::string_view::npos) {
const auto name = Trim(token.substr(0, equal));
if (name.empty() || name == "A") throw std::invalid_argument("APS5_AB: an arm defined with '=' needs a name other than A in '" + std::string(ab) + "'");
if (std::any_of(name.begin(), name.end(), [](char c) { return !std::isalnum(static_cast<unsigned char>(c)) && c != '_'; })) throw std::invalid_argument("APS5_AB: the arm name '" + std::string(name) + "' may only contain letters, digits and _ in '" + std::string(ab) + "'");
for (const auto& arm : defined) {
if (arm.name == name) throw std::invalid_argument("APS5_AB: arm " + std::string(name) + " is defined twice");
}
return {std::string(name), ParseSwitchList(token.substr(equal + 1), ab)};
}
for (const auto& arm : defined) {
if (arm.name == token) return arm;
}
auto switches = ParseSwitchList(token, ab);
std::string name;
for (const auto id : switches) name += (name.empty() ? "" : "+") + std::string(RuntimeSwitches::Name(id));
return {std::move(name), std::move(switches)};
}
bool InArm(const AbSchedule::Arm& arm, RuntimeSwitch id) {
return std::find(arm.switches.begin(), arm.switches.end(), id) != arm.switches.end();
}
}
namespace RuntimeSwitches {
@@ -118,25 +167,31 @@ std::optional<RuntimeSwitch> Find(std::string_view name) {
}
AbSchedule::Config AbSchedule::Parse(std::string_view ab, std::string_view start, std::string_view settle) {
AbSchedule::Config AbSchedule::Parse(std::string_view ab, std::string_view start, std::string_view settle, bool rotate) {
Config config;
config.rotate = rotate;
ab = Trim(ab);
const auto colon = ab.find(':');
if (colon == std::string_view::npos) throw std::invalid_argument("APS5_AB: expected <seconds>:<switch>[+<switch>...], got '" + std::string(ab) + "'");
if (colon == std::string_view::npos) throw std::invalid_argument("APS5_AB: expected <seconds>:<switch>[+<switch>...] or <seconds>:<arm>|<arm>[|...], got '" + std::string(ab) + "'");
config.phaseSeconds = ParseSeconds(ab.substr(0, colon), "APS5_AB phase length");
if (config.phaseSeconds < 1) throw std::invalid_argument("APS5_AB: a phase must last at least 1 s");
auto list = ab.substr(colon + 1);
if (Trim(list).empty()) throw std::invalid_argument("APS5_AB: no switch listed after the phase length");
for (;;) {
const auto plus = list.find('+');
const auto name = Trim(list.substr(0, plus));
if (name.empty()) throw std::invalid_argument("APS5_AB: an empty switch name in '" + std::string(ab) + "'");
const auto found = RuntimeSwitches::Find(name);
if (!found.has_value()) throw std::invalid_argument("APS5_AB: " + std::string(name) + " cannot change while the title runs; switches the A/B can change: " + FlippableList());
if (std::find(config.switches.begin(), config.switches.end(), *found) != config.switches.end()) throw std::invalid_argument("APS5_AB: " + std::string(name) + " is listed twice");
config.switches.push_back(*found);
if (plus == std::string_view::npos) break;
list = list.substr(plus + 1);
const auto list = Trim(ab.substr(colon + 1));
if (list.empty()) throw std::invalid_argument("APS5_AB: no switch listed after the phase length");
if (list.find('|') == std::string_view::npos && list.find('=') == std::string_view::npos) {
config.arms = {{"A", {}}, {"B", ParseSwitchList(list, ab)}};
} else {
for (auto rest = list;;) {
const auto bar = rest.find('|');
config.arms.push_back(ParseArm(Trim(rest.substr(0, bar)), ab, config.arms));
if (bar == std::string_view::npos) break;
rest = rest.substr(bar + 1);
}
if (config.arms.size() < 2) throw std::invalid_argument("APS5_AB: at least two arms are needed, got '" + std::string(list) + "'");
}
for (const auto& arm : config.arms) {
for (const auto id : arm.switches) {
if (std::find(config.switches.begin(), config.switches.end(), id) == config.switches.end()) config.switches.push_back(id);
}
}
start = Trim(start);
if (!start.empty()) {
@@ -158,6 +213,12 @@ AbSchedule::Config AbSchedule::Parse(std::string_view ab, std::string_view start
AbSchedule::AbSchedule(Config config) : config(std::move(config)) {}
std::size_t AbSchedule::ArmOfPhase(std::uint64_t index) const {
const auto count = static_cast<std::uint64_t>(config.arms.size());
const auto cycle = config.rotate ? index / count : 0;
return static_cast<std::size_t>((index + cycle) % count);
}
AbSchedule::Step AbSchedule::AtPresent(std::uint64_t present, double seconds) {
if (!firstSeconds.has_value()) firstSeconds = seconds;
if (!started) {
@@ -167,17 +228,17 @@ AbSchedule::Step AbSchedule::AtPresent(std::uint64_t present, double seconds) {
settled = false;
phase = 0;
phaseStart = seconds;
return {Event::Begin, 0, false};
return {Event::Begin, 0, 0};
}
if (seconds - phaseStart >= config.phaseSeconds) {
++phase;
settled = false;
phaseStart = seconds;
return {Event::Begin, phase, (phase & 1u) != 0};
return {Event::Begin, phase, ArmOfPhase(phase)};
}
if (!settled && seconds - phaseStart >= config.settleSeconds) {
settled = true;
return {Event::Settled, phase, (phase & 1u) != 0};
return {Event::Settled, phase, ArmOfPhase(phase)};
}
return {};
}
@@ -196,8 +257,9 @@ AbState& Ab() {
const char* ab = std::getenv("APS5_AB");
const char* start = std::getenv("APS5_AB_START");
const char* settle = std::getenv("APS5_AB_SETTLE");
const bool rotate = std::getenv("APS5_AB_ROTATE") != nullptr;
if (ab != nullptr) {
created->schedule.emplace(AbSchedule::Parse(ab, start != nullptr ? start : "", settle != nullptr ? settle : ""));
created->schedule.emplace(AbSchedule::Parse(ab, start != nullptr ? start : "", settle != nullptr ? settle : "", rotate));
for (std::size_t index = 0; index < SwitchCount; ++index) created->environment[index] = RuntimeSwitches::Set(static_cast<RuntimeSwitch>(index));
}
return created;
@@ -205,10 +267,11 @@ AbState& Ab() {
return *state;
}
std::string SwitchSettings(const AbState& state, bool b) {
std::string SwitchSettings(const AbState& state, std::size_t arm) {
const auto& config = state.schedule->Settings();
std::string text;
for (const auto id : state.schedule->Settings().switches) {
const bool set = state.environment[static_cast<std::size_t>(id)] != b;
for (const auto id : config.switches) {
const bool set = state.environment[static_cast<std::size_t>(id)] != InArm(config.arms[arm], id);
text += std::string(text.empty() ? "" : ", ") + RuntimeSwitches::Name(id) + (set ? " set" : " unset");
}
return text;
@@ -226,7 +289,7 @@ std::vector<std::string> AbAtPresent(std::uint64_t present, double seconds) {
auto& state = Ab();
std::lock_guard lock(state.mutex);
std::vector<std::string> lines;
char text[512];
char text[4096];
const auto& config = state.schedule->Settings();
const auto step = state.schedule->AtPresent(present, seconds);
if (step.event == AbSchedule::Event::None) return lines;
@@ -235,13 +298,16 @@ std::vector<std::string> AbAtPresent(std::uint64_t present, double seconds) {
char from[96];
if (config.startSeconds.has_value()) std::snprintf(from, sizeof(from), "%.1f s after the first present", *config.startSeconds);
else std::snprintf(from, sizeof(from), "present %llu", static_cast<unsigned long long>(config.startPresent));
std::snprintf(text, sizeof(text), "[ab] in-run A/B: phases of %.1f s from %s, settle %.1f s; A: %s; B: %s\n", config.phaseSeconds, from, config.settleSeconds, SwitchSettings(state, false).c_str(), SwitchSettings(state, true).c_str());
lines.emplace_back(text);
std::snprintf(text, sizeof(text), "[ab] in-run A/B: phases of %.1f s from %s, settle %.1f s", config.phaseSeconds, from, config.settleSeconds);
std::string header = text;
if (config.rotate) header += ", the arm order rotates by one at every cycle of " + std::to_string(config.arms.size()) + " phases";
for (std::size_t index = 0; index < config.arms.size(); ++index) header += "; " + config.arms[index].name + ": " + SwitchSettings(state, index);
lines.emplace_back(header + "\n");
}
for (const auto id : config.switches) RuntimeSwitches::Assign(id, state.environment[static_cast<std::size_t>(id)] != step.b);
std::snprintf(text, sizeof(text), "[ab] phase %c %llu begins at present %llu (t %.3f s): %s\n", step.b ? 'B' : 'A', static_cast<unsigned long long>(step.phase), static_cast<unsigned long long>(present), seconds, SwitchSettings(state, step.b).c_str());
for (const auto id : config.switches) RuntimeSwitches::Assign(id, state.environment[static_cast<std::size_t>(id)] != InArm(config.arms[step.arm], id));
std::snprintf(text, sizeof(text), "[ab] phase %s %llu begins at present %llu (t %.3f s): %s\n", config.arms[step.arm].name.c_str(), static_cast<unsigned long long>(step.phase), static_cast<unsigned long long>(present), seconds, SwitchSettings(state, step.arm).c_str());
} else {
std::snprintf(text, sizeof(text), "[ab] phase %c %llu settled at present %llu (t %.3f s)\n", step.b ? 'B' : 'A', static_cast<unsigned long long>(step.phase), static_cast<unsigned long long>(present), seconds);
std::snprintf(text, sizeof(text), "[ab] phase %s %llu settled at present %llu (t %.3f s)\n", config.arms[step.arm].name.c_str(), static_cast<unsigned long long>(step.phase), static_cast<unsigned long long>(present), seconds);
}
lines.emplace_back(text);
return lines;
@@ -241,6 +241,7 @@ void ShaderResources::prepareAddressBindings(std::span<const CompiledShader> sha
Require(context.bufferDeviceAddress, "buffer device address is not enabled");
static const bool profile = std::getenv("APS5_PROFILE_DRAW") != nullptr;
guestMemory.AcquireRegistered();
if (!bdaReadOnly) guestMemory.AllowAddressStores();
const auto snapshotsStart = profile ? std::chrono::steady_clock::now() : std::chrono::steady_clock::time_point{};
for (const auto& snapshot : snapshots) guestMemory.AddSnapshot(snapshot);
if (profile) GuestBufferMemory::CountAddressBuild(std::chrono::duration<double, std::micro>(std::chrono::steady_clock::now() - snapshotsStart).count());
@@ -525,6 +525,7 @@ struct TextureCounters {
// ShaderResources::refreshOwnObjects).
std::atomic<std::uint64_t> ownRefreshes{0};
std::atomic<std::uint64_t> tablesReused{0};
std::atomic<std::uint64_t> tableEntryMemoHits{0};
std::atomic<std::uint64_t> tablesReplayed{0};
std::atomic<std::uint64_t> tablesResolved{0};
std::atomic<std::uint64_t> tableWritesKept{0};
@@ -562,7 +563,7 @@ void reportTextureCounters() {
auto last = counters.lastReport.load();
if (nowMs - last < 10000 || !counters.lastReport.compare_exchange_strong(last, nowMs)) return;
const auto count = [](const std::atomic<std::uint64_t>& value) { return static_cast<unsigned long long>(value.load(std::memory_order_relaxed)); };
AgcDriver::ProfilePrint_nid_no_patch("[textures] sampled created: %llu from storage images, %llu cleared on the GPU, %llu uploaded on the GPU from host imports, %llu snapshots (%llu snapshot reads over recorded writes inside cachedTexture, %llu storage-path fallbacks); stage-A records %llu: %llu fast hits, %llu full lookups; storage images %llu hits, %llu created, %llu own-object refreshes; image tables %llu reused, %llu resolved; dynamic-resolution variants: %llu surfaces, %llu entries substituted, %llu entries rejected; %llu one-layer 2D array entries bound to the 2D texture of their surface; untracked snapshots %llu kept by the write-watch hint, %llu compared; views kept through a pending alias: %llu lookups, %llu revalidations\n", count(counters.fromStorage), count(counters.cleared), count(counters.imported), count(counters.snapshots), count(counters.pendingReads), count(counters.storageFallbacks), count(counters.records), count(counters.fastHits), count(counters.fastMisses), count(counters.storageHits), count(counters.storageCreated), count(counters.ownRefreshes), count(counters.tablesReused), count(counters.tablesResolved), count(counters.variantSurfaces), count(counters.variantSubstituted), count(counters.variantRejected), count(counters.arrayViewsShared), count(counters.untrackedKept), count(counters.untrackedCompared), count(counters.aliasViews), count(counters.aliasRefreshes));
AgcDriver::ProfilePrint_nid_no_patch("[textures] sampled created: %llu from storage images, %llu cleared on the GPU, %llu uploaded on the GPU from host imports, %llu snapshots (%llu snapshot reads over recorded writes inside cachedTexture, %llu storage-path fallbacks); stage-A records %llu: %llu fast hits, %llu full lookups; storage images %llu hits, %llu created, %llu own-object refreshes; image tables %llu reused (%llu found cached by the entry memo), %llu resolved; dynamic-resolution variants: %llu surfaces, %llu entries substituted, %llu entries rejected; %llu one-layer 2D array entries bound to the 2D texture of their surface; untracked snapshots %llu kept by the write-watch hint, %llu compared; views kept through a pending alias: %llu lookups, %llu revalidations\n", count(counters.fromStorage), count(counters.cleared), count(counters.imported), count(counters.snapshots), count(counters.pendingReads), count(counters.storageFallbacks), count(counters.records), count(counters.fastHits), count(counters.fastMisses), count(counters.storageHits), count(counters.storageCreated), count(counters.ownRefreshes), count(counters.tablesReused), count(counters.tableEntryMemoHits), count(counters.tablesResolved), count(counters.variantSurfaces), count(counters.variantSubstituted), count(counters.variantRejected), count(counters.arrayViewsShared), count(counters.untrackedKept), count(counters.untrackedCompared), count(counters.aliasViews), count(counters.aliasRefreshes));
}
// What the sampled-texture lookups on this thread proved their returned objects current against,
@@ -653,7 +654,10 @@ bool SampledFromStorageEligible(const Context& context, std::uint32_t format, st
}
bool SampledFromStorageEligible(const Context& context, const GuestTextureResource& resource, std::uint64_t guestBytes) {
return SampledFromStorageEligible(context, resource.format, resource.baseAddress, guestBytes);
if (SampledFromStorageEligible(context, resource.format, resource.baseAddress, guestBytes)) return true;
static const bool disabled = std::getenv("APS5_NO_SAMPLED_FROM_STORAGE") != nullptr;
if (disabled || !sampledFromStorageForTest.load(std::memory_order_relaxed) || IsBlockCompressed(resource.format) || !StorageFormatAvailable(context, resource.format)) return false;
return StorageSegmentsServe(context, resource, guestBytes);
}
bool ImportGpuWrittenSampledSurface(const Context& context, const GuestTextureResource& resource, std::uint64_t guestBytes) {
@@ -1419,6 +1423,7 @@ struct CachedStorageTexture {
std::uint32_t mip;
std::shared_ptr<StorageTexture> texture;
std::uint64_t accounted = 0;
std::uint64_t lastPresent = 0;
};
// As TextureCache: use order with a hash index by key, plus one by image for StorageImageCached.
@@ -1661,6 +1666,7 @@ std::shared_ptr<StorageTexture> cachedStorageTexture(const Context& context, std
if (layers) it->texture->RefreshLayers(layers->first, layers->second);
else it->texture->Refresh();
cache.entries.splice(cache.entries.begin(), cache.entries, it);
it->lastPresent = Recorder::Presents();
texture = it->texture;
if (TextureCountersReported()) counters.storageHits.fetch_add(1, std::memory_order_relaxed);
if (profile) LookupOutcomes::Add(LookupOutcomes::StorageHit, start);
@@ -1676,6 +1682,7 @@ std::shared_ptr<StorageTexture> cachedStorageTexture(const Context& context, std
}
created->AdoptHandOver(std::move(handOver));
CachedStorageTexture entry{key, mip, std::move(created)};
entry.lastPresent = Recorder::Presents();
static const bool keepNew = std::getenv("APS5_NO_KEEP_NEW_STORAGE") == nullptr;
if (auto* recorder = Recorder::Active(); keepNew && recorder != nullptr && GuestMemory::GpuMutex().HeldByThisThread() && recorder->Recording()) recorder->Keep(entry.texture);
entry.accounted = heldBytes(*entry.texture);
@@ -1934,9 +1941,10 @@ std::uint64_t ReleaseTextureCaches(std::uint64_t bytes, bool newImage) {
}
storageKept = 0;
bool spared = false;
const auto present = Recorder::Presents();
for (auto it = cache.entries.end(); it != cache.entries.begin();) {
--it;
if (it->texture->Dirty()) {
if (it->texture->Dirty() || (present != 0u && it->lastPresent + 1u >= present)) {
++storageKept;
continue;
}
@@ -2129,7 +2137,10 @@ std::size_t ShaderResources::RefreshStorageChangedOutsideWatch() {
ShaderResources::ShaderResources(const Context& context, std::span<const CompiledShader> shaders, const ColorTarget& target, std::uint32_t colorAttachments, std::uint64_t indexAddress, std::size_t indexBytes, std::span<const GuestMemorySnapshot> snapshots, bool deviceStaging) : context(context), guestMemory(context) {
drawBuild = true;
const bool addressTables = std::ranges::any_of(shaders, [](const CompiledShader& shader) { return shader.program != nullptr && std::ranges::any_of(shader.program->bindings, [](const auto& binding) { return binding.role == ShaderRecompiler::DescriptorRole::BdaPagetable; }); });
if (deviceStaging && !addressTables) guestMemory.AllowDeviceStaging();
if (deviceStaging && !addressTables) {
guestMemory.AllowDeviceStaging();
guestMemory.AllowPassStaging();
}
prepareAddressBindings(shaders, snapshots);
build(shaders, &target, colorAttachments, indexAddress, indexBytes);
}
@@ -2398,6 +2409,8 @@ struct ReusedTable {
std::vector<std::string> bound;
bool replayable = false;
std::vector<std::uint32_t> representatives;
std::vector<std::list<CachedTexture>::iterator> cachedEntries;
std::uint64_t cachedErasures = std::numeric_limits<std::uint64_t>::max();
};
constexpr std::size_t ReusedTableCount = 4;
@@ -2430,16 +2443,26 @@ bool TableCurrent(ReusedTable& table) {
return GuestMemory::UnchangedSinceAll(table.queries);
}
bool CachedTableTextures(const ReusedTable& table, std::vector<std::shared_ptr<Texture>>& cached) {
bool CachedTableTextures(ReusedTable& table, std::vector<std::shared_ptr<Texture>>& cached) {
auto& cache = Textures();
std::lock_guard lock(cache.mutex);
std::vector<std::list<CachedTexture>::iterator> entries;
entries.reserve(table.queries.size());
for (const auto& element : table.elements) {
if (element.rejected || element.live || element.substitute) continue;
const auto it = findTexture(cache, element.key);
if (it == cache.entries.end() || it->texture != element.texture.lock()) return false;
entries.push_back(it);
auto& entries = table.cachedEntries;
if (table.cachedErasures == cache.erasures && !RuntimeSwitches::Set(RuntimeSwitch::NoTableEntryMemo)) {
TextureCounts().tableEntryMemoHits.fetch_add(1, std::memory_order_relaxed);
} else {
table.cachedErasures = std::numeric_limits<std::uint64_t>::max();
entries.clear();
entries.reserve(table.queries.size());
for (const auto& element : table.elements) {
if (element.rejected || element.live || element.substitute) continue;
const auto it = findTexture(cache, element.key);
if (it == cache.entries.end() || it->texture != element.texture.lock()) {
entries.clear();
return false;
}
entries.push_back(it);
}
table.cachedErasures = cache.erasures;
}
cached.reserve(entries.size());
for (const auto it : entries) {
@@ -2476,7 +2499,7 @@ std::string HexText(std::uint64_t value) {
return text;
}
void ValidateRuntimeResources(const CompiledShader& shader, std::span<const std::uint32_t> words) {
void ValidateRuntimeResources(const CompiledShader& shader, std::span<const std::byte> data) {
Require(shader.program != nullptr, "missing compiled shader");
const auto& program = *shader.program;
const auto& descriptors = program.bindings;
@@ -2490,21 +2513,30 @@ void ValidateRuntimeResources(const CompiledShader& shader, std::span<const std:
heap = &binding;
}
}
Require(words.size() == program.shaderDataDwords, "invalid compact shader data size");
Require(data.size() == program.shaderDataDwords * sizeof(std::uint32_t), "invalid compact shader data size");
constexpr auto metadataWords = sizeof(ShaderRecompiler::RuntimeAbi::ResourceMetadata) / sizeof(std::uint32_t);
Require(program.imageMetadataDword <= words.size() && program.runtimeImageCount <= (words.size() - program.imageMetadataDword) / metadataWords, "runtime image metadata exceeds shader data");
Require(program.imageMetadataDword <= program.shaderDataDwords && program.runtimeImageCount <= (program.shaderDataDwords - program.imageMetadataDword) / metadataWords, "runtime image metadata exceeds shader data");
for (const auto index : program.runtimeImageResources) {
Require(index < program.runtimeImageCount, "runtime image resource exceeds its compact layout");
const auto offset = program.imageMetadataDword + index * metadataWords;
const auto kind = words[offset];
const auto first = words[offset + 1u];
const auto count = words[offset + 2u];
std::array<std::uint32_t, 3> header;
std::memcpy(header.data(), data.data() + offset * sizeof(std::uint32_t), sizeof(header));
const auto [kind, first, count] = header;
Require(count != 0u, "runtime image metadata has no descriptor elements");
Require(kind < heaps.size() && heaps[kind] != nullptr, "runtime metadata references an unbound image heap");
Require(first < heaps[kind]->count && count <= heaps[kind]->count - first, "runtime metadata exceeds its bound heap");
}
}
void ValidatePushedImageData(const CompiledShader& shader) {
const auto& program = *shader.program;
if (program.runtimeImageCount == 0u || program.pushConstants.empty()) return;
const auto size = program.stencilReferences.empty() ? program.pushConstants.size() : program.stencilReferenceDword * sizeof(std::uint32_t);
if (size == 0u) return;
Require(size <= ShaderRecompiler::RuntimeAbi::PushConstantDwords * sizeof(std::uint32_t) && size <= program.pushConstants.size(), "invalid pushed image metadata size");
ValidateRuntimeResources(shader, std::as_bytes(std::span(program.pushConstants)).first(size));
}
}
void ShaderResources::buildPrepare(std::span<const CompiledShader> shaders, const ColorTarget* target, std::uint32_t colorAttachments, std::uint64_t indexAddress, std::size_t indexBytes) {
@@ -2537,6 +2569,7 @@ void ShaderResources::buildPrepare(std::span<const CompiledShader> shaders, cons
for (const auto& shader : shaders) {
Require(shader.program != nullptr, "missing compiled shader");
ShaderRecompiler::RuntimeAbi::RequireVersion(shader.program->runtimeAbiVersion);
ValidatePushedImageData(shader);
if (shader.program->poisonedSrtReads != 0) {
const auto& programBindings = shader.program->bindings;
const auto flat = std::find_if(programBindings.begin(), programBindings.end(), [](const ShaderRecompiler::DescriptorBinding& binding) { return binding.role == ShaderRecompiler::DescriptorRole::FlattenedSrt; });
@@ -2646,7 +2679,7 @@ void ShaderResources::buildPrepare(std::span<const CompiledShader> shaders, cons
Require(binding.count == 1, "shader data and flattened SRT descriptors must not be arrays");
Require(!binding.guestDescriptor.empty(), "empty shader data descriptor");
if (binding.role == ShaderRecompiler::DescriptorRole::ShaderData) {
ValidateRuntimeResources(shader, binding.guestDescriptor);
ValidateRuntimeResources(shader, std::as_bytes(std::span(binding.guestDescriptor)));
}
item.allocations.push_back(addDataBuffer(binding.guestDescriptor));
if (binding.role == ShaderRecompiler::DescriptorRole::ShaderData) shaderData = static_cast<std::int64_t>(item.allocations.back());
@@ -4247,7 +4280,7 @@ void noteEpochProof(bool reused, bool verified, bool failed) {
if (verified) checks.fetch_add(1, std::memory_order_relaxed);
if (failed) failures.fetch_add(1, std::memory_order_relaxed);
const auto count = (reused ? reuses : proofs).fetch_add(1, std::memory_order_relaxed) + 1u;
static const bool report = std::getenv("APS5_PROFILE_DRAW") != nullptr || std::getenv("APS5_VERIFY_DRAW_PIPELINE") != nullptr;
static const bool report = std::getenv("APS5_PROFILE_DRAW") != nullptr || std::getenv("APS5_VERIFY_DRAW_PIPELINE") != nullptr || std::getenv("APS5_PIPELINE_STATS") != nullptr;
if (!report) return;
if (count % 262144u == 0u || (count & (count - 1u)) == 0u) std::fprintf(stderr, "[epoch-proofs] resource proofs: %llu reused the epoch's, %llu proved; verify: %llu checked, %llu failed; storage refreshes reused %llu\n", static_cast<unsigned long long>(reuses.load()), static_cast<unsigned long long>(proofs.load()), static_cast<unsigned long long>(checks.load()), static_cast<unsigned long long>(failures.load()), static_cast<unsigned long long>(StorageTexture::epochRefreshes.load()));
}
@@ -5764,6 +5797,7 @@ bool ShaderResources::RefreshData(VkCommandBuffer commands, const CompiledShader
bool ShaderResources::refreshData(VkCommandBuffer commands, const CompiledShader& shader, Recorder* recorder) {
Require(shader.program != nullptr, "missing compiled shader");
ValidatePushedImageData(shader);
const auto& program = *shader.program;
bool recorded = false;
// One [gputime] range of class TemplateDataRefresh around the updates, begun at the first one
@@ -5779,7 +5813,7 @@ bool ShaderResources::refreshData(VkCommandBuffer commands, const CompiledShader
const auto size = binding.guestDescriptor.size() * sizeof(std::uint32_t);
Require(allocation.buffer != nullptr && !allocation.guest && allocation.size == size && size <= MaxRefreshBytes, "template data buffer cannot take the dispatch's words");
if (allocation.dataWords.size() == binding.guestDescriptor.size() && std::equal(allocation.dataWords.begin(), allocation.dataWords.end(), binding.guestDescriptor.begin())) continue;
if (binding.role == ShaderRecompiler::DescriptorRole::ShaderData) ValidateRuntimeResources(shader, binding.guestDescriptor);
if (binding.role == ShaderRecompiler::DescriptorRole::ShaderData) ValidateRuntimeResources(shader, std::as_bytes(std::span(binding.guestDescriptor)));
if (recorder != nullptr && timing == Recorder::NoTiming) timing = recorder->BeginGpuTiming(Recorder::CommandClass::TemplateDataRefresh);
writeDataWords(commands, held->allocations.front(), binding.guestDescriptor);
allocation.dataWords.assign(binding.guestDescriptor.begin(), binding.guestDescriptor.end());
@@ -6879,7 +6913,7 @@ std::uint64_t SampledTexturesImported() {
ImageTableReuseCounts ImageTableReuses() {
const auto& counters = TextureCounts();
return {counters.tablesReused.load(std::memory_order_relaxed) + counters.tablesReplayed.load(std::memory_order_relaxed), counters.tablesResolved.load(std::memory_order_relaxed), counters.tablesReplayed.load(std::memory_order_relaxed), counters.tableWritesKept.load(std::memory_order_relaxed), counters.tableWritesMade.load(std::memory_order_relaxed), counters.variantSurfaces.load(std::memory_order_relaxed), counters.variantSubstituted.load(std::memory_order_relaxed), counters.variantRejected.load(std::memory_order_relaxed), counters.arrayViewsShared.load(std::memory_order_relaxed)};
return {counters.tablesReused.load(std::memory_order_relaxed) + counters.tablesReplayed.load(std::memory_order_relaxed), counters.tablesResolved.load(std::memory_order_relaxed), counters.tablesReplayed.load(std::memory_order_relaxed), counters.tableWritesKept.load(std::memory_order_relaxed), counters.tableWritesMade.load(std::memory_order_relaxed), counters.variantSurfaces.load(std::memory_order_relaxed), counters.variantSubstituted.load(std::memory_order_relaxed), counters.variantRejected.load(std::memory_order_relaxed), counters.arrayViewsShared.load(std::memory_order_relaxed), counters.tableEntryMemoHits.load(std::memory_order_relaxed)};
}
void ShaderResources::finishImageTables() {
@@ -6935,6 +6969,13 @@ std::vector<PresyncSurface> ShaderResources::PresyncSurfaces() const {
const bool gpuDirect = sampled ? SampledFromStorageEligible(context, format, address, guestBytes) : HostImportCovers(context, address, static_cast<std::size_t>(guestBytes));
if (!gpuDirect) surfaces.push_back({address, guestBytes, false});
};
const auto considerResource = [&](const GuestTextureResource& resource, std::uint64_t guestBytes, bool sampled) {
const bool gpuDirect = sampled ? SampledFromStorageEligible(context, resource, guestBytes) : HostImportCovers(context, resource.baseAddress, static_cast<std::size_t>(guestBytes)) || StorageSegmentsServe(context, resource, guestBytes);
if (!gpuDirect) surfaces.push_back({resource.baseAddress, guestBytes, false});
};
const auto considerImage = [&](const StorageTexture& image, std::uint64_t address, std::uint64_t guestBytes) {
if (!HostImportCovers(context, address, static_cast<std::size_t>(guestBytes)) && !StorageSegmentsServe(context, image)) surfaces.push_back({address, guestBytes, false});
};
static const bool keyRanges = std::getenv("APS5_NO_DCC_PRESYNC") == nullptr;
const auto considerKeys = [&](std::uint64_t dccAddress, std::uint64_t guestBytes) {
const auto keyBytes = DccKeyBytes(guestBytes);
@@ -6952,7 +6993,7 @@ std::vector<PresyncSurface> ShaderResources::PresyncSurfaces() const {
for (const auto& range : describedRanges) {
if (std::strcmp(range.kind, "texture") == 0 && textureIndex < textures.size()) {
const auto& texture = textures[textureIndex++];
if (texture->ViewsStorageImage()) consider(range.format, range.address, range.bytes, false);
if (texture->ViewsStorageImage()) considerImage(*texture->SharedStorageSource(), range.address, range.bytes);
else consider(range.format, range.address, range.bytes, true);
considerKeys(range.dccAddress, range.bytes);
}
@@ -6960,7 +7001,7 @@ std::vector<PresyncSurface> ShaderResources::PresyncSurfaces() const {
for (std::size_t index = 0; index < storageTextures.size(); ++index) {
if (storageTextures[index] == nullptr || (index != 0 && storageTextures[index] == storageTextures[index - 1])) continue;
const auto& image = *storageTextures[index];
consider(image.Descriptor().format, image.Descriptor().baseAddress, image.GuestBytes(), false);
considerImage(image, image.Descriptor().baseAddress, image.GuestBytes());
considerKeys(image.Descriptor().dccAddress, image.GuestBytes());
}
return surfaces;
@@ -6968,7 +7009,7 @@ std::vector<PresyncSurface> ShaderResources::PresyncSurfaces() const {
if (!imageRecords.empty()) {
for (const auto& record : imageRecords) {
if (!record.decoded) continue;
consider(record.resource.format, record.resource.baseAddress, record.guestBytes, record.sampled);
considerResource(record.resource, record.guestBytes, record.sampled);
considerKeys(record.resource.dccAddress, record.guestBytes);
}
return surfaces;
@@ -6979,7 +7020,7 @@ std::vector<PresyncSurface> ShaderResources::PresyncSurfaces() const {
if (IsNullTextureResource(words)) return;
const auto resource = DecodeTextureResource(words);
const auto guestBytes = SurfaceGuestBytes(resource);
consider(resource.format, resource.baseAddress, guestBytes, binding.kind == ShaderRecompiler::DescriptorKind::SampledImage);
considerResource(resource, guestBytes, binding.kind == ShaderRecompiler::DescriptorKind::SampledImage);
considerKeys(resource.dccAddress, guestBytes);
});
for (const auto& binding : deferredCompute.program->bindings) {
@@ -6988,7 +7029,7 @@ std::vector<PresyncSurface> ShaderResources::PresyncSurfaces() const {
try {
const auto resource = DecodeTextureResource(std::span<const std::uint32_t>(binding.guestDescriptor).subspan(element * 8u, 8u));
const auto guestBytes = SurfaceGuestBytes(resource);
consider(resource.format, resource.baseAddress, guestBytes, true);
considerResource(resource, guestBytes, true);
considerKeys(resource.dccAddress, guestBytes);
} catch (const std::runtime_error&) {
}
@@ -7131,11 +7172,11 @@ std::optional<std::vector<ShaderResources::MovedBuffer>> ShaderResources::MovedR
return moved;
}
bool ShaderResources::movedInPlace(Recorder& recorder, const Allocation& item, std::uint64_t address, std::uint64_t size, MovedBuffer& entry) const {
bool ShaderResources::movedInPlace(Recorder& recorder, const Allocation& item, std::uint64_t address, std::uint64_t size, MovedBuffer& entry, bool counted) const {
static const bool enabled = std::getenv("APS5_NO_MOVED_BUFFERS_IN_PLACE") == nullptr;
auto& counters = MovedInPlace();
const auto refuse = [&] {
counters.refused.fetch_add(1, std::memory_order_relaxed);
if (counted) counters.refused.fetch_add(1, std::memory_order_relaxed);
return false;
};
if (!enabled || context.hostImportAlignment == 0) return false;
@@ -7161,7 +7202,7 @@ bool ShaderResources::movedInPlace(Recorder& recorder, const Allocation& item, s
entry.inPlace = import->buffer;
entry.inPlaceOffset = offset - adjustment;
entry.adjustment = adjustment;
counters.taken.fetch_add(1, std::memory_order_relaxed);
if (counted) counters.taken.fetch_add(1, std::memory_order_relaxed);
return true;
}
@@ -7208,9 +7249,16 @@ std::optional<std::vector<ShaderResources::MovedBuffer>> ShaderResources::MovedD
const bool written = element >= binding.bufferWritten.size() || binding.bufferWritten[element];
if (written || empty || item.written) return refuse(MoveRefusal::Written);
if (size > context.limits.maxStorageBufferRange) return refuse(MoveRefusal::Limit);
VkDescriptorBufferInfo view{};
std::uint64_t serial = 0;
const bool inPlace = item.adjustment == 0 && HostImportView(context, address, static_cast<std::size_t>(size), view, serial);
MovedBuffer entry{kept->allocations[element], address, static_cast<std::size_t>(size)};
bool inPlace = false;
if (item.adjustment == 0 && recorder == nullptr) {
VkDescriptorBufferInfo view{};
std::uint64_t serial = 0;
inPlace = HostImportView(context, address, static_cast<std::size_t>(size), view, serial);
} else if (item.adjustment == 0) {
inPlace = movedInPlace(*recorder, item, address, size, entry, false) && entry.adjustment == 0;
if (!inPlace) entry = MovedBuffer{kept->allocations[element], address, static_cast<std::size_t>(size)};
}
const auto begin = address - item.adjustment;
const auto bytes = static_cast<std::size_t>(GuestBufferMemory::ViewBytes(size, item.adjustment));
if (!inPlace && maxBytes != 0 && proof.bytes + bytes > maxBytes) return refuse(MoveRefusal::Limit);
@@ -7218,8 +7266,6 @@ std::optional<std::vector<ShaderResources::MovedBuffer>> ShaderResources::MovedD
const bool pending = recorder != nullptr ? recorder->PendingWriteOverlaps(begin, bytes) : Recorder::SnapshotWriteOverlaps(begin, bytes);
const std::array<std::pair<std::uint64_t, std::uint64_t>, 1> range{{{begin, begin + bytes}}};
if (guestMemory.WritesOverlap(begin, bytes) || pending || StorageTexture::AnyPendingOverlaps(range) || AnyShadowedOverlaps(begin, bytes)) return refuse(MoveRefusal::Overlap);
MovedBuffer entry{kept->allocations[element], address, static_cast<std::size_t>(size)};
entry.dispatchInPlace = inPlace;
moved.push_back(entry);
++proof.buffers;
if (inPlace) ++proof.inPlace;
@@ -7304,16 +7350,6 @@ std::shared_ptr<ShaderResources::DrawBindings> ShaderResources::PrepareDrawBindi
keep({begin, nullptr, override->inPlaceOffset, bytes, override->inPlace});
continue;
}
if (override != moved.end() && override->dispatchInPlace) {
VkDescriptorBufferInfo view{};
std::uint64_t serial = 0;
if (!HostImportView(context, override->address, override->size, view, serial)) return {};
const auto begin = override->address - item.adjustment;
if (result == nullptr) result = std::make_shared<DrawBindings>();
result->inPlace.push_back({index, view.buffer, view.offset, static_cast<std::size_t>(view.range)});
result->inPlaceReads.push_back({begin, begin + GuestBufferMemory::ViewBytes(override->size, item.adjustment)});
continue;
}
std::uint64_t address = item.address;
std::size_t size = item.size;
if (override != moved.end()) {
@@ -7375,7 +7411,7 @@ std::shared_ptr<ShaderResources::DrawBindings> ShaderResources::PrepareDrawBindi
totalSnapshotBytes += bytes;
CaptureTrace::Log("draw-snapshot batch=%llu address=%llx bytes=%zu", static_cast<unsigned long long>(recorder.Submissions() + 1), static_cast<unsigned long long>(begin), bytes);
}
if (selected.empty() && (result == nullptr || result->inPlace.empty()) && !rebound) return {};
if (selected.empty() && !rebound) return {};
if (result == nullptr) result = std::make_shared<DrawBindings>();
writeDrawSets(*result, selected, faultRecord);
recorder.Keep(result);
@@ -7428,10 +7464,6 @@ void ShaderResources::writeDrawSets(DrawBindings& result, std::span<const std::s
auto& snapshotIndices = ShaderRecompiler::ThreadOwned(indicesSlot);
snapshotIndices.assign(allocations.size(), selected.size());
for (std::size_t index = 0; index < selected.size(); ++index) snapshotIndices[selected[index]] = index;
thread_local std::vector<std::size_t>* inPlaceSlot = nullptr;
auto& inPlaceIndices = ShaderRecompiler::ThreadOwned(inPlaceSlot);
inPlaceIndices.assign(allocations.size(), result.inPlace.size());
for (std::size_t index = 0; index < result.inPlace.size(); ++index) inPlaceIndices[result.inPlace[index].allocation] = index;
auto nextWrite = writes.begin();
for (const auto& binding : bindings) {
const auto original = setOf(binding) == 0 ? _set : fragment.set;
@@ -7442,12 +7474,6 @@ void ShaderResources::writeDrawSets(DrawBindings& result, std::span<const std::s
const auto offset = static_cast<std::size_t>(write.pBufferInfo - descriptorBuffers.data());
write.pBufferInfo = buffers.data() + offset;
for (std::size_t element = 0; element < binding.allocations.size(); ++element) {
const auto boundIndex = inPlaceIndices[binding.allocations[element]];
if (boundIndex != result.inPlace.size()) {
const auto& bound = result.inPlace[boundIndex];
buffers[offset + element] = wholeDwordRange({bound.buffer, bound.offset, bound.bytes});
continue;
}
const auto snapshotIndex = snapshotIndices[binding.allocations[element]];
if (snapshotIndex == selected.size()) continue;
const auto& snapshot = result.snapshots[snapshotIndex];
@@ -7557,18 +7583,18 @@ void ShaderResources::WriteBack() {
if (unaligned) std::rethrow_exception(unaligned);
}
void ShaderResources::MarkGpuWrites(Recorder& recorder, const DrawBindings* bindings) {
bool ShaderResources::StorePages() const {
return bda != nullptr && bda->StorePages();
}
void ShaderResources::MarkGpuWrites(Recorder& recorder) {
if (bda != nullptr && recorder.Device() == context.device) bda->NoteUse(recorder.OpenSerial());
// The ranges this use reads in place through their host imports (read-only and written elements
// alike, and an address-based build's whole leased heaps), before the writes: a CPU store into
// one of them (the copy HLE) must not land before the recorded work read it.
static const bool readOnlyLeaseSkip = std::getenv("APS5_NO_READ_ONLY_LEASE_SKIP") == nullptr;
const auto kind = !guestMemory.HoldsLease() ? Recorder::ReadKind::DispatchElement : readOnlyLeaseSkip && usesBda && bdaReadOnly ? Recorder::ReadKind::AddressBasedReadOnly : Recorder::ReadKind::AddressBased;
if (bindings != nullptr && !bindings->inPlaceReads.empty()) {
auto reads = guestMemory.InPlaceReads();
reads.insert(reads.end(), bindings->inPlaceReads.begin(), bindings->inPlaceReads.end());
recorder.NotePendingReads(reads, kind);
} else if (auto split = guestMemory.SplitInPlaceReads()) {
if (auto split = guestMemory.SplitInPlaceReads()) {
recorder.NotePendingReadList(std::move(split->space), kind);
recorder.NotePendingReads(split->own, kind);
} else {
@@ -7588,8 +7614,10 @@ void ShaderResources::MarkGpuWrites(Recorder& recorder, const DrawBindings* bind
recorder.AfterRun([inRun](Recorder& after) { inRun->guestMemory.RecordCopyBacks(after); });
guestMemory.MarkStagedWrites();
} else {
guestMemory.DeferCopyBacks(recorder);
guestMemory.RecordCopyBacks(recorder);
}
if (bda) bda->RecordStorePageGather(recorder);
// Only the written elements' ranges (AddWritable): a read-only element is neither noted here
// nor marked as a direct write, so CPU reads of its memory never wait for this work.
recorder.NotePendingWrites(guestMemory.Writes());
@@ -7600,6 +7628,7 @@ void ShaderResources::MarkGpuWrites(Recorder& recorder, const DrawBindings* bind
}
guestMemory.MarkDirectWrites();
guestMemory.NoteCarriedShadows(recorder);
guestMemory.NotePassShadows(recorder);
if (!BuildProfiled()) return;
auto& counters = BufferWrites();
// Recorded uses only (dispatches and recorded draws): a synchronous draw writes back in
@@ -7626,6 +7655,8 @@ void ShaderResources::WriteBackBuffers() {
} catch (const BdaUnalignedAccess&) {
unaligned = std::current_exception();
}
guestMemory.NoteAddressStores(bda->TakeWrittenPages());
guestMemory.NoteStorePages(bda->TakeStorePages());
}
if (!SkipWriteBack()) guestMemory.WriteBack();
if (unaligned) std::rethrow_exception(unaligned);
@@ -7,6 +7,7 @@
#include "prx/libSceAgcDriver/Graphics/include/TextureTiling.hpp"
#include "prx/libSceAgcDriver/Graphics/include/TextureSwizzleEquations.hpp"
#include "prx/libSceAgcDriver/Graphics/include/DccMetadata.hpp"
#include "prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp"
#include "prx/libSceAgcDriver/Graphics/include/TextureFormat.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Pipeline.hpp"
#include "prx/libSceAgcDriver/Execution/include/GuestMemory.hpp"
@@ -326,8 +327,15 @@ bool vertexControlSupported(std::uint32_t word) {
}
// Bits 26/27 (ZCLIP_NEAR/FAR_DISABLE) become depth clamping; bit 19 selects the [0, 1] clip space;
// bit 16 disables clipping.
constexpr std::uint32_t UcpCullOnlyEnable = 0x20000u;
constexpr std::uint32_t ClipControlMask = ~(0x10000u | 0x80000u | 0x01000000u | 0x0c000000u);
std::uint32_t clipControlMask(const Registers& cx) {
const auto exports = find(cx, 0x207);
const bool hasClipDistances = exports != cx.end() && (exports->second & 0xffu) != 0u;
return hasClipDistances ? ClipControlMask : (ClipControlMask & ~UcpCullOnlyEnable);
}
bool zFormatSupported(std::uint32_t format) {
return format == 0u || format == 1u || format == 2u || format == 3u || format == 9u;
}
@@ -1289,8 +1297,13 @@ bool SampleMaskFollowsOrder(const State& state, const SampleOrder& order) {
return std::ranges::any_of(order, [&](std::uint32_t word) { return (HostSampleBits(mask, word) & full) != mask; });
}
std::array<std::uint16_t, 4> QuadSampleMasks(const State& state, const SampleOrder& order) {
if (!SampleMaskFollowsOrder(state, order)) return QuadSampleMasks(state);
bool SampleMaskInShader(const State& state, const SampleOrder& order, bool staticMaskStopsShading) {
if (SampleMaskFollowsOrder(state, order)) return true;
return !staticMaskStopsShading && state.perSampleShading && PartialSampleMask(state) && UniformSampleMask(state);
}
std::array<std::uint16_t, 4> QuadSampleMasks(const State& state, const SampleOrder& order, bool staticMaskStopsShading) {
if (!SampleMaskInShader(state, order, staticMaskStopsShading)) return QuadSampleMasks(state);
const auto mask = static_cast<std::uint16_t>(state.quadSampleMask[0] & ((1u << state.samples) - 1u));
return {mask, mask, mask, mask};
}
@@ -1861,7 +1874,7 @@ State DecodeState(const QueueState& queue, bool vertexWorkgroup) {
if (auto reason = sampleMaskRejection(queue, read(cx, 0x2f8), read(cx, 0x30e), read(cx, 0x30f)); !reason.empty()) throw std::runtime_error(reason);
const auto viewportControl = read(cx, 0x206);
if (viewportControl != 0x43fu && viewportControl != 0u) throw std::runtime_error(vteMessage(viewportControl));
zero(cx, 0x204, ClipControlMask, "a PA_CL_CLIP_CNTL flag");
zero(cx, 0x204, clipControlMask(cx), "a PA_CL_CLIP_CNTL flag");
result.depthClamp = (read(cx, 0x204) & 0x0c000000u) != 0;
result.negativeOneToOne = (read(cx, 0x204) & 0x80000u) == 0;
const auto raster = read(cx, 0x205);
@@ -2446,7 +2459,7 @@ GuestTextureResource SurfaceForTarget(const ColorTarget& color) {
surface.dstSelY = 5;
surface.dstSelZ = 6;
surface.dstSelW = 7;
surface.dccAddress = color.dccAddress != 0 ? color.dccAddress : color.chainDccAddress;
surface.dccAddress = color.chainDccAddress != 0 ? color.chainDccAddress : color.dccAddress;
surface.dccAlphaOnMsb = color.dccAlphaOnMsb;
surface.dccPipeAligned = color.dccPipeAligned;
if (ColorTileModeIsGcn(color.tileMode)) surface.gcnPitch = surface.width;
@@ -2736,6 +2749,9 @@ ColorTarget DecodeColorBuffer(const Registers& cx, std::uint32_t slot, bool allo
color.chainDccAddress = dccBase;
color.dccAlphaOnMsb = DccAlphaOnMsb(color.format, swap);
color.dccPipeAligned = ((attrib3 >> 30u) & 1u) != 0;
if (color.dccPipeAligned && ColorTextureTileMode(color.tileMode) == TextureTileMode::kR64KBX && !RuntimeSwitches::Set(RuntimeSwitch::NoDccMipFastClear)) {
if (const auto offset = DccMipKeyOffset(color.surfaceExtent.width, color.surfaceExtent.height, color.elementBytes, color.mipCount, std::min(firstTailLevel, color.mipCount), color.mip)) color.dccAddress = dccBase + *offset;
}
} else {
static bool reported = false;
if (!reported) {
@@ -2998,7 +3014,7 @@ std::string DrawRejection(const QueueState& queue, bool indexed) {
if (auto reason = sampleMaskRejection(queue, config, word, other); !reason.empty()) return reason;
}
if (value(cx, 0x206, word) && word != 0x43fu && word != 0u) return vteMessage(word);
if (auto reason = nonzero(cx, 0x204, ClipControlMask, "a PA_CL_CLIP_CNTL flag"); !reason.empty()) return reason;
if (auto reason = nonzero(cx, 0x204, clipControlMask(cx), "a PA_CL_CLIP_CNTL flag"); !reason.empty()) return reason;
std::uint32_t targetMask = 0, shaderMask = 0;
if (value(cx, 0x8e, targetMask) && value(cx, 0x8f, shaderMask) && value(cx, 0x202, word)) {
const auto slots = ColorExportSlots(shaderMask);
@@ -1704,6 +1704,22 @@ bool StorageFormatAvailable(const Context& context, std::uint32_t guestFormat) {
}
}
bool StorageSegmentsServe(const Context& context, const GuestTextureResource& descriptor, std::uint64_t guestBytes) {
static const bool disabled = std::getenv("APS5_NO_IMPORT_SEGMENT_VIEWS") != nullptr;
if (disabled || guestBytes == 0 || !HostImportSegmentsCover(context, descriptor.baseAddress, static_cast<std::size_t>(guestBytes))) return false;
try {
const auto geometry = DescribeSurface(descriptor);
return geometry.guestBytes == guestBytes && StorageBlockUnits(descriptor, geometry);
} catch (const std::exception&) {
return false;
}
}
bool StorageSegmentsServe(const Context& context, const StorageTexture& image) {
static const bool disabled = std::getenv("APS5_NO_IMPORT_SEGMENT_VIEWS") != nullptr;
return !disabled && image.BlockUnits() && HostImportSegmentsCover(context, image.Descriptor().baseAddress, static_cast<std::size_t>(image.GuestBytes()));
}
VkFormat HostStorageFormat(const Context& context, VkFormat format) {
return StorageFormatOrUndefined(context, format);
}
@@ -3004,11 +3020,16 @@ std::uint64_t StorageTexture::LinearImportRetiles() {
return linearImportRetiles.load(std::memory_order_relaxed);
}
bool StorageTexture::OtherPendingOverlaps() const {
return otherPendingOverlaps();
}
bool StorageTexture::otherPendingOverlaps() const {
auto& pending = Pending();
std::lock_guard lock(pending.mutex);
const auto other = [&](const StorageTexture* texture) { return texture != this && texture->overlaps(descriptor.baseAddress, static_cast<std::size_t>(guestBytes)); };
return std::any_of(pending.textures.begin(), pending.textures.end(), other) || std::any_of(pending.flushing.begin(), pending.flushing.end(), other);
const auto owed = [&](const StorageTexture* texture) { return other(texture) && texture->pendingUnitInside(descriptor.baseAddress, static_cast<std::size_t>(guestBytes)); };
return std::any_of(pending.textures.begin(), pending.textures.end(), owed) || std::any_of(pending.flushing.begin(), pending.flushing.end(), other);
}
const char* StorageTexture::RefreshObligation(std::uint32_t first, std::uint32_t count) const {
@@ -4847,6 +4868,7 @@ std::uint64_t StorageTexture::OccasionalLabelStores() {
}
void StorageTexture::markLayersPending(std::uint32_t first, std::uint32_t count) {
if (count != 0 && !anyLayerPending()) holdsClearFill = false;
if (count != 0) {
const auto begin = layerBegin(first);
const auto end = layerBegin(first + count - 1) + layerBytes(first + count - 1);
@@ -5260,6 +5282,7 @@ void StorageTexture::appendStoredLayers(std::uint64_t address, std::size_t bytes
bool StorageTexture::storesWhole() const {
if (descriptor.dccAddress == 0) return false;
if (uploadedKeys != DccKeys::Uncompressed) return true;
if (holdsClearFill && anyLayerPending()) return true;
if (descriptor.mipCount <= 1) return false;
auto& live = Live();
std::lock_guard lock(live.mutex);
@@ -6134,21 +6157,42 @@ std::size_t StorageTexture::StoreDrawnLinear(const char* reason) {
GuestMemory::TagGpuLockSite(GuestMemory::GpuLockSite::Flush);
std::lock_guard gpu(GuestMemory::GpuMutex());
std::vector<std::pair<std::uint64_t, std::size_t>> ranges;
#if defined(__APPLE__)
const bool trap = (std::strcmp(reason, "label") == 0 || std::strcmp(reason, "interrupt") == 0) && LabelTrapsEnabled();
if (trap) labelTrapsSet.store(true, std::memory_order_relaxed);
std::vector<std::shared_ptr<StorageTexture>> linear;
#endif
{
std::lock_guard lock(pending.mutex);
#if defined(__APPLE__)
const bool trap = (std::strcmp(reason, "label") == 0 || std::strcmp(reason, "interrupt") == 0) && LabelTrapsEnabled();
if (trap) labelTrapsSet.store(true, std::memory_order_relaxed);
#endif
for (const auto& entry : pending.drawn) {
const auto* texture = entry.texture;
auto* texture = entry.texture;
if (!texture->dirty) continue;
#if defined(__APPLE__)
if (trap && texture->descriptor.tileMode == TextureTileMode::kLinear && HostImportCovers(texture->context, texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes)) && trapReadsAtLabel(texture)) continue;
if (trap && texture->descriptor.tileMode == TextureTileMode::kLinear) {
if (auto alive = texture->weak_from_this().lock()) {
linear.push_back(std::move(alive));
continue;
}
}
#endif
ranges.emplace_back(texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes));
}
}
#if defined(__APPLE__)
std::erase_if(linear, [&](const std::shared_ptr<StorageTexture>& texture) {
if (HostImportCovers(texture->context, texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes))) return false;
ranges.emplace_back(texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes));
return true;
});
if (!linear.empty()) {
std::lock_guard lock(pending.mutex);
for (const auto& texture : linear) {
if (!texture->dirty || std::none_of(pending.drawn.begin(), pending.drawn.end(), [&](const auto& entry) { return entry.texture == texture.get(); })) continue;
if (trapReadsAtLabel(texture.get())) continue;
ranges.emplace_back(texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes));
}
}
#endif
std::size_t stored = 0;
for (const auto& [address, bytes] : ranges) {
if (FlushPending(address, bytes, nullptr, reason)) ++stored;
@@ -7367,6 +7411,108 @@ bool StorageTexture::FillClear(std::span<const std::uint32_t, 4> pattern, std::u
return true;
}
bool StorageTexture::ClearMip(const std::array<std::byte, 16>& texel, std::uint32_t level, bool verifiedCodeClear, const char*& refusal) {
if (level >= descriptor.mipCount || descriptor.mipCount <= 1) { refusal = "level"; return false; }
if (geometry.thick || geometry.imageDepth != 1 || geometry.layers != 1) { refusal = "geometry"; return false; }
const auto& mip = geometry.mips[level];
if (mip.tail) { refusal = "tail"; return false; }
const auto begin = descriptor.baseAddress + geometry.GuestOffset(0, mip);
const auto bytes = static_cast<std::size_t>(mip.tiledSize);
if (bytes == 0 || begin + bytes > descriptor.baseAddress + guestBytes) { refusal = "range"; return false; }
const auto elementBytes = BytesPerElement(descriptor.format);
std::array<std::byte, 16> repeated{};
for (std::size_t offset = 0; offset + elementBytes <= repeated.size(); offset += elementBytes) std::memcpy(repeated.data() + offset, texel.data(), elementBytes);
std::array<std::uint32_t, 4> pattern{};
std::memcpy(pattern.data(), repeated.data(), repeated.size());
VkClearColorValue clearValue{};
if (!FillClearColor(storageFormat, elementBytes, pattern, clearValue) && !(ClearKeepsDenormals(context, storageFormat) && FillClearColor(storageFormat, elementBytes, pattern, clearValue, true))) {
refusal = "pattern";
return false;
}
if (descriptor.dccAddress != 0 && !verifiedCodeClear) {
if (Recorder::SnapshotWriteOverlaps(descriptor.dccAddress, static_cast<std::size_t>(guestBytes / 256)) || TextureClearKeys(descriptor, guestBytes) != DccKeys::Uncompressed) {
refusal = "keys";
return false;
}
}
auto* recorder = Recorder::Active();
if (recorder == nullptr) {
refusal = "no recorder";
return false;
}
bool aliasedKeys = false;
{
auto& live = Live();
std::lock_guard lock(live.mutex);
for (auto* texture : live.textures) {
if (texture == this || texture->released || !texture->overlaps(begin, bytes)) continue;
texture->forgetSavedOver(begin, bytes);
if (texture->descriptor.dccAddress != 0) aliasedKeys = true;
}
}
static const bool trace = std::getenv("APS5_TRACE_FILL_COVER") != nullptr;
static std::atomic<int> traced{0};
if (trace && (descriptor.dccAddress != 0 || aliasedKeys) && traced.fetch_add(1) < 16) std::fprintf(stderr, "[fill-cover] clear of mip %u of 0x%llx+0x%llx (format %u, keys 0x%llx%s): pattern %08x %08x %08x %08x\n", level, static_cast<unsigned long long>(descriptor.baseAddress), static_cast<unsigned long long>(guestBytes), descriptor.format, static_cast<unsigned long long>(descriptor.dccAddress), aliasedKeys ? " aliased" : "", pattern[0], pattern[1], pattern[2], pattern[3]);
PublishShadow(begin, bytes, PublishScope::PartialUnits, PublishReason::FillClear);
GuestMemory::MarkWritten(begin, bytes);
const auto commands = recorder->Commands();
const auto timing = recorder->BeginGpuTiming(Recorder::CommandClass::FillClear);
Recorder::CountBarriers(Recorder::CommandClass::FillClear, 2);
if (auto self = weak_from_this().lock()) keepStorageTexture(*recorder, std::move(self));
if (Recorder::BarrierValidate()) {
const std::pair<VkImage, bool> cleared{image, true};
recorder->NoteAccess(Recorder::CommandClass::FillClear, Recorder::Access{{}, {}, std::span(&cleared, 1), VK_PIPELINE_STAGE_TRANSFER_BIT});
}
VkImageSubresourceRange subresource{VK_IMAGE_ASPECT_COLOR_BIT, level, 1u, 0u, 1u};
VkImageMemoryBarrier toClear{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER};
toClear.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
toClear.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
toClear.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
toClear.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
toClear.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
toClear.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
toClear.image = image;
toClear.subresourceRange = subresource;
context.Function<PFN_vkCmdPipelineBarrier>("vkCmdPipelineBarrier")(commands, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &toClear);
clearImage(commands, clearValue, subresource);
VkImageMemoryBarrier toGeneral = toClear;
toGeneral.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
toGeneral.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
toGeneral.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
toGeneral.newLayout = VK_IMAGE_LAYOUT_GENERAL;
context.Function<PFN_vkCmdPipelineBarrier>("vkCmdPipelineBarrier")(commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &toGeneral);
recorder->EndGpuTiming(timing, bytes);
const bool watched = GuestMemory::Watched(descriptor.baseAddress, static_cast<std::size_t>(guestBytes));
if (watched) {
layerOriginal.assign(trackedLayers, false);
cancelStoredSaves();
releaseUnheldOriginal();
}
if (blockUnits) {
const auto first = static_cast<std::uint32_t>((begin - descriptor.baseAddress) / trackedLayerBytes);
const auto count = static_cast<std::uint32_t>((bytes + trackedLayerBytes - 1) / trackedLayerBytes);
if (!watched) {
std::vector<bool> filled(trackedLayers, false);
std::fill_n(filled.begin() + first, count, true);
captureGuestBytes(&filled);
}
const auto now = GuestMemory::CollectWritesUncached(begin, bytes);
for (auto unit = first; unit < first + count; ++unit) layerGeneration[unit] = now;
refreshGeneration();
forgetBorrowed(first, count);
markLayersPending(first, count);
} else {
if (!watched) captureGuestBytes(nullptr);
const auto now = GuestMemory::CollectWritesUncached(begin, bytes);
for (std::uint32_t layer = 0; layer < trackedLayers; ++layer) layerGeneration[layer] = collectedLayerGeneration(layer, now, true);
refreshGeneration();
forgetBorrowed(0, trackedLayers);
markLayersPending(0, trackedLayers);
}
holdsClearFill = true;
return true;
}
void StorageTexture::WriteBack() {
storeTrappedOverlaps("explicit");
const auto previous = std::exchange(flushReason, "explicit");
@@ -169,6 +169,26 @@ std::uint32_t ScaledSampledFormats(PFN_vkGetPhysicalDeviceFormatProperties forma
return formats;
}
constexpr std::array<std::uint32_t, 3> kOptionalTextureFormats{51u, 55u, 137u};
std::uint32_t OptionalSampledBit(std::uint32_t guestFormat) {
for (std::uint32_t index = 0; index < kOptionalTextureFormats.size(); ++index) {
if (kOptionalTextureFormats[index] == guestFormat) return 1u << index;
}
return 0u;
}
std::uint32_t OptionalSampledFormats(PFN_vkGetPhysicalDeviceFormatProperties formatProperties, VkPhysicalDevice physical) {
std::uint32_t formats = 0;
for (const auto format : kOptionalTextureFormats) {
VkFormatProperties properties{};
formatProperties(physical, ResolveTextureFormat(format), &properties);
constexpr VkFormatFeatureFlags required = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
if ((properties.optimalTilingFeatures & required) == required) formats |= OptionalSampledBit(format);
}
return formats;
}
std::uint32_t SrgbDecodeFormats(PFN_vkGetPhysicalDeviceFormatProperties formatProperties, VkPhysicalDevice physical) {
const char* forced = std::getenv("APS5_SRGB_SHADER_DECODE");
const bool always = forced != nullptr && (std::strcmp(forced, "1") == 0 || std::strcmp(forced, "copy") == 0);
@@ -201,6 +221,8 @@ bool SampledDepth24S8(const Context& context) {
VkFormat SampledTextureFormat(const Context& context, std::uint32_t guestFormat) {
const auto scaled = ScaledSampledBit(guestFormat);
Require(scaled == 0u || (context.scaledSampledFormats & scaled) != 0u, "unsupported guest texture format " + std::to_string(guestFormat));
const auto optional = OptionalSampledBit(guestFormat);
Require(optional == 0u || (context.optionalSampledFormats & optional) != 0u, "unsupported guest texture format " + std::to_string(guestFormat));
if (IsRepackedTextureFormat(guestFormat) || guestFormat == static_cast<std::uint32_t>(ShaderRecompiler::IrBufferFormat::Format11_11_10Float)) return VK_FORMAT_B10G11R11_UFLOAT_PACK32;
const auto format = static_cast<ShaderRecompiler::IrBufferFormat>(guestFormat);
if (format == ShaderRecompiler::IrBufferFormat::Format8_24UNorm && !SampledDepth24S8(context)) return VK_FORMAT_R32_SFLOAT;
@@ -243,8 +265,9 @@ bool IsSrgbTextureFormat(std::uint32_t guestFormat) {
bool IgnoresForcedDegamma(std::uint32_t guestFormat) {
switch (guestFormat) {
case 7u: case 8u: case 13u: case 22u: case 23u: case 24u: case 29u: case 36u: case 50u: case 64u: case 65u: case 66u: case 71u: case 77u:
case 132u: case 133u: case 134u: case 136u: case 175u: case 176u: case 177u: case 178u: case 179u: case 180u: return true;
case 7u: case 8u: case 11u: case 12u: case 13u: case 20u: case 21u: case 22u: case 23u: case 24u: case 27u: case 28u: case 29u: case 36u: case 50u: case 51u: case 54u: case 55u:
case 62u: case 63u: case 64u: case 65u: case 66u: case 69u: case 70u: case 71u: case 72u: case 73u: case 74u: case 75u: case 76u: case 77u:
case 132u: case 133u: case 134u: case 135u: case 136u: case 141u: case 175u: case 176u: case 177u: case 178u: case 179u: case 180u: return true;
default: return false;
}
}
@@ -693,18 +693,22 @@ bool AnyPublishInProgress() {
}
bool AnyShadowedOverlaps(std::uint64_t address, std::size_t bytes) {
if (!UnitShadowEnabled() || bytes == 0) return false;
auto& registry = Registry();
std::lock_guard lock(registry.mutex);
return anyShadowedLocked(registry, address, bytes);
return !LiveUnitsClear(address, bytes);
}
bool AnyShadowedOverlaps(std::span<const std::pair<std::uint64_t, std::uint64_t>> ranges) {
if (!UnitShadowEnabled() || ranges.empty()) return false;
auto& registry = Registry();
std::lock_guard lock(registry.mutex);
auto& copy = ThreadScratch<std::shared_ptr<const LiveRanges>, LiveRangesTag>();
const auto serial = liveSerial.load(std::memory_order_acquire);
if (copy == nullptr || copy->serial != serial) {
auto published = publishedLive.load(std::memory_order_acquire);
copy = published != nullptr && published->serial == serial ? std::move(published) : currentLiveRanges();
}
if (copy->ranges.empty()) return false;
for (const auto& [begin, end] : ranges) {
if (end > begin && anyShadowedLocked(registry, begin, static_cast<std::size_t>(end - begin))) return true;
if (end <= begin) continue;
const auto it = std::upper_bound(copy->ranges.begin(), copy->ranges.end(), begin, [](std::uint64_t value, const std::pair<std::uint64_t, std::uint64_t>& range) { return value < range.second; });
if (it != copy->ranges.end() && it->first < end) return true;
}
return false;
}
@@ -15,7 +15,11 @@ uint32_t APS5_VABI sceAgcDriverInitResourceRegistration(void) {
uint32_t APS5_VABI sceAgcDriverQueryResourceRegistrationUserMemoryRequirements(uint64_t* size_in_bytes) {
if (!size_in_bytes) return AGC_EINVAL;
*size_in_bytes = 0x4000ULL;
const uint64_t size = 0x4000ULL;
const int savedErrno = errno;
const bool copied = GuestCopyOut_nid_no_patch(size_in_bytes, &size, sizeof(size));
errno = savedErrno;
if (!copied) return AGC_EINVAL;
return 0;
}
@@ -3,6 +3,7 @@
#include <cstdint>
#include <cstddef>
#include <cerrno>
#include <mutex>
#include <stdexcept>
#include "SceTypes.hpp"
@@ -40,8 +41,12 @@ int APS5_VABI sceAgcDriverSetHsOffchipParam(uint16_t granularity, uint16_t buffe
int APS5_VABI sceAgcDriverGetHsOffchipParam(uint16_t* granularity, uint16_t* buffering) {
if (granularity == nullptr || buffering == nullptr) throw std::invalid_argument("sceAgcDriverGetHsOffchipParam: null output");
std::lock_guard lock(hsOffchipParamMutex);
*granularity = hsOffchipParam.granularity;
*buffering = hsOffchipParam.buffering;
const auto localParam = hsOffchipParam;
const int savedErrno = errno;
const bool copiedGranularity = GuestCopyOut_nid_no_patch(granularity, &localParam.granularity, sizeof(localParam.granularity));
const bool copiedBuffering = GuestCopyOut_nid_no_patch(buffering, &localParam.buffering, sizeof(localParam.buffering));
errno = savedErrno;
if (!copiedGranularity || !copiedBuffering) throw std::invalid_argument("sceAgcDriverGetHsOffchipParam: invalid output pointer");
return 0;
}
@@ -55,8 +60,12 @@ int APS5_VABI sceAgcDriverSetTFRing(const volatile void* base, uint32_t size) {
int APS5_VABI sceAgcDriverGetTFRing(uintptr_t* base, uint32_t* size) {
if (base == nullptr || size == nullptr) throw std::invalid_argument("sceAgcDriverGetTFRing: null output");
std::lock_guard lock(tessellationFactorRingMutex);
*base = tessellationFactorRing.base;
*size = tessellationFactorRing.size;
const auto localRing = tessellationFactorRing;
const int savedErrno = errno;
const bool copiedBase = GuestCopyOut_nid_no_patch(base, &localRing.base, sizeof(localRing.base));
const bool copiedSize = GuestCopyOut_nid_no_patch(size, &localRing.size, sizeof(localRing.size));
errno = savedErrno;
if (!copiedBase || !copiedSize) throw std::invalid_argument("sceAgcDriverGetTFRing: invalid output pointer");
return 0;
}
@@ -0,0 +1,32 @@
#include "AllocationCounter.hpp"
#include <new>
extern "C" void* __real__Znwy(std::size_t bytes);
namespace {
thread_local bool countingAllocations = false;
thread_local std::size_t countedAllocations = 0;
}
extern "C" void BeginAllocationCount_nid_no_patch() noexcept {
countedAllocations = 0;
countingAllocations = true;
}
extern "C" std::size_t EndAllocationCount_nid_no_patch() noexcept {
countingAllocations = false;
return countedAllocations;
}
extern "C" void AllocateForCount_nid_no_patch(std::size_t bytes) {
void* (*volatile allocate)(std::size_t) = &::operator new;
void* allocation = allocate(bytes);
::operator delete(allocation);
}
extern "C" void* __wrap__Znwy(std::size_t bytes) {
if (countingAllocations) ++countedAllocations;
return __real__Znwy(bytes);
}
@@ -0,0 +1,10 @@
#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_TESTS_ALLOCATIONCOUNTER_HPP
#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_TESTS_ALLOCATIONCOUNTER_HPP
#include <cstddef>
extern "C" void BeginAllocationCount_nid_no_patch() noexcept;
extern "C" std::size_t EndAllocationCount_nid_no_patch() noexcept;
extern "C" void AllocateForCount_nid_no_patch(std::size_t bytes);
#endif
@@ -3,9 +3,11 @@
#include "ControlFlow/RequestSerializer.hpp"
#include "SpirvBackend/SpirvBda.hpp"
#include <spirv/unified1/GLSL.std.450.h>
#include <algorithm>
#include <cstring>
#include <functional>
#include <initializer_list>
#include <optional>
#include <string>
#include <vector>
#include <utility>
@@ -226,6 +228,35 @@ std::pair<std::uint32_t, std::uint32_t> LoopsKeptRolled(const std::vector<std::u
return {loops, kept};
}
std::optional<std::size_t> CallNesting(const std::vector<std::uint32_t>& spirv, const char* caller, const char* callee) {
std::uint32_t callerId = 0;
std::uint32_t calleeId = 0;
for (std::size_t at = 5; at < spirv.size() && (spirv[at] >> 16u) != 0u; at += spirv[at] >> 16u) {
if ((spirv[at] & 0xffffu) != spv::OpName) continue;
const auto* name = reinterpret_cast<const char*>(&spirv[at + 2u]);
if (std::strcmp(name, caller) == 0) callerId = spirv[at + 1u];
if (std::strcmp(name, callee) == 0) calleeId = spirv[at + 1u];
}
if (callerId == 0u || calleeId == 0u) return std::nullopt;
std::optional<std::size_t> deepest;
std::vector<std::uint32_t> merges;
bool inside = false;
for (std::size_t at = 5; at < spirv.size() && (spirv[at] >> 16u) != 0u; at += spirv[at] >> 16u) {
const auto opcode = spirv[at] & 0xffffu;
if (opcode == spv::OpFunction) {
inside = spirv[at + 2u] == callerId;
merges.clear();
}
if (!inside) continue;
if (opcode == spv::OpSelectionMerge || opcode == spv::OpLoopMerge) merges.push_back(spirv[at + 1u]);
if (opcode == spv::OpLabel) {
while (!merges.empty() && merges.back() == spirv[at + 1u]) merges.pop_back();
}
if (opcode == spv::OpFunctionCall && spirv[at + 3u] == calleeId) deepest = std::max(deepest.value_or(0u), merges.size());
}
return deepest;
}
}
void RunBdaContractTests() {
@@ -319,6 +350,14 @@ void RunBdaContractTests() {
const auto [byteLoops, rolled] = LoopsKeptRolled(shader, "write_bda_bytes");
AgcDriver::Graphics::Require(byteLoops == 1u && rolled == 1u, "the byte loop of write_bda_bytes may be unrolled, which copies its write lookup once per byte");
}
for (const bool coherent : {false, true}) {
const auto shader = MakeBdaDwordReadTestShader(0x1000, 4, coherent, false);
const std::string span = coherent ? "read_bda_span_coherent" : "read_bda_span";
const std::string loader = coherent ? "load_bda_span_coherent" : "load_bda_span";
const auto nesting = CallNesting(shader, span.c_str(), loader.c_str());
AgcDriver::Graphics::Require(nesting.has_value(), "a four-dword BDA read has no call from " + span + " to " + loader);
AgcDriver::Graphics::Require(*nesting == 0u, span + " calls " + loader + " inside a selection or loop; NVIDIA's Blackwell driver then gives the lanes that take the dword path the results of other lanes");
}
const std::array<std::uint32_t, 4> dwordValues{0x11223344u, 0x55667788u, 0x99aabbccu, 0xddeeff00u};
for (const std::uint32_t dwords : {2u, 3u, 4u}) {
const auto shader = MakeBdaDwordWriteTestShader(0x7fff12340f82ULL, dwords, dwordValues.data());
@@ -1,5 +1,6 @@
#include "BdaShader.hpp"
#include "BdaAbi.hpp"
#include "PipelineSpecialization.hpp"
#include "IntermediateRepresentation/IrMetadata/ShaderStage.hpp"
#include "prx/libSceAgcDriver/Graphics/include/BdaResources.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Resources.hpp"
@@ -10,8 +11,10 @@
#include <initializer_list>
#include <limits>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
@@ -62,8 +65,11 @@ public:
moduleInfo.codeSize = code.size_bytes();
moduleInfo.pCode = code.data();
Check(context.Function<PFN_vkCreateShaderModule>("vkCreateShaderModule")(context.device, &moduleInfo, nullptr, &module), "vkCreateShaderModule");
const std::uint32_t storePages = 1u;
const VkSpecializationMapEntry entry{ShaderRecompiler::PipelineSpecialization::StorePages, 0u, sizeof(storePages)};
const VkSpecializationInfo specialization{1u, &entry, sizeof(storePages), &storePages};
VkComputePipelineCreateInfo pipelineInfo{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO};
pipelineInfo.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, module, "main", nullptr};
pipelineInfo.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, module, "main", &specialization};
pipelineInfo.layout = layout;
Check(context.Function<PFN_vkCreateComputePipelines>("vkCreateComputePipelines")(context.device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &pipeline), "vkCreateComputePipelines");
} catch (...) { release(); throw; }
@@ -547,7 +553,120 @@ void RunBdaExecutionTests(const Context& context) {
RunBdaAnchorTests(context);
}
static void RunBdaStorePageTests(const Context& context) {
namespace Abi = ShaderRecompiler::BdaAbi;
constexpr std::uint32_t slots = 64;
constexpr std::uint64_t page = Abi::StorePageBytes;
constexpr std::uint64_t guest = 0x7fff12400000ULL;
Buffer unbound(context, 2 * page, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
Buffer masked(context, page, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
Buffer pool(context, Abi::StorePagePoolBytes(slots), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
const std::array<Abi::Range, 2> ranges{{
{guest, guest + 2 * page, unbound.DeviceAddress(), Abi::Read | Abi::Write | Abi::Spill, 0},
{guest + 2 * page, guest + 3 * page, masked.DeviceAddress(), Abi::Read | Abi::Write | Abi::Masked, 0},
}};
Buffer table(context, sizeof(Abi::Header) + sizeof(ranges), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
Buffer fault(context, Abi::FaultBufferBytes, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
Buffer output(context, 4, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
const Abi::Header header{Abi::Version, static_cast<std::uint32_t>(ranges.size()), sizeof(Abi::Range), 0};
std::memcpy(table.Bytes().data(), &header, sizeof(header));
std::memcpy(table.Bytes().data() + sizeof(header), ranges.data(), sizeof(ranges));
const auto words = [&](Buffer& buffer) { return reinterpret_cast<std::uint32_t*>(buffer.Bytes().data()); };
const auto reset = [&](bool attached) {
std::memset(unbound.Bytes().data(), 0x77, unbound.Bytes().size());
std::memset(masked.Bytes().data(), 0xcd, masked.Bytes().size());
std::memset(pool.Bytes().data(), 0, pool.Bytes().size());
std::memset(fault.Bytes().data(), 0, fault.Bytes().size());
std::memset(output.Bytes().data(), 0, output.Bytes().size());
if (!attached) return;
const auto address = pool.DeviceAddress();
auto* faultWords = words(fault);
faultWords[Abi::StorePagesWord] = static_cast<std::uint32_t>(address);
faultWords[Abi::StorePagesWord + 1] = static_cast<std::uint32_t>(address >> 32u);
faultWords[Abi::StorePageBaseWord] = static_cast<std::uint32_t>(guest);
faultWords[Abi::StorePageBaseWord + 1] = static_cast<std::uint32_t>(guest >> 32u);
faultWords[Abi::StorePageSlotsWord] = slots;
};
const auto slotOf = [&](std::uint64_t address) -> std::optional<std::uint32_t> {
const auto key = Abi::StorePageKey(guest, address);
for (std::uint32_t probe = 0; probe < Abi::StorePageProbes; ++probe) {
const auto slot = (Abi::StorePageHash(key, slots) + probe) & (slots - 1u);
if (words(pool)[slot] == key) return slot;
}
return std::nullopt;
};
const auto pageBytes = [&](std::uint32_t slot) { return pool.Bytes().data() + Abi::StorePageWord(slots, slot) * sizeof(std::uint32_t); };
const auto run = [&](std::vector<std::uint32_t> shader) {
Pipeline pipeline(context, shader, {&table, &fault, &output});
pipeline.Run(1);
Abi::Fault result{};
std::memcpy(&result, fault.Bytes().data(), sizeof(result));
std::uint32_t loaded = 0;
std::memcpy(&loaded, output.Bytes().data(), sizeof(loaded));
return std::pair{result, loaded};
};
const auto untouched = [&](Buffer& buffer, std::byte fill) {
const auto bytes = buffer.Bytes();
return std::all_of(bytes.begin(), bytes.end(), [&](std::byte value) { return value == fill; });
};
reset(true);
auto [stored, loaded] = run(MakeBdaStoreLoadTestShader(guest + 0x104, guest + 0x104, 0xa1b2c3d4u, 32));
Require(stored.state == Abi::FaultState::Empty, "a store into an unbound heap mirror block published a fault");
Require(loaded == 0xa1b2c3d4u, "a read after a store into an unbound heap mirror block in the same dispatch returned " + Hex(loaded));
Require(untouched(unbound, std::byte{0x77}), "a store into an unbound heap mirror block reached the block's zero memory");
const auto first = slotOf(guest + 0x104);
Require(first.has_value(), "a store into an unbound heap mirror block claimed no store page");
std::uint32_t paged = 0;
std::memcpy(&paged, pageBytes(*first) + 0x104, sizeof(paged));
Require(paged == 0xa1b2c3d4u, "the store page of an unbound heap mirror block holds " + Hex(paged));
Require(std::all_of(pageBytes(*first), pageBytes(*first) + 0x104, [](std::byte value) { return value == std::byte{0}; }), "a store page holds bytes no store wrote");
Require(words(fault)[Abi::StorePageOverflowWord] == 0, "one store page overflowed the store page table");
reset(true);
std::tie(stored, loaded) = run(MakeBdaStoreLoadTestShader(guest + 0x10, guest + page + 0x20, 0x11223344u, 32));
Require(stored.state == Abi::FaultState::Empty && loaded == 0x77777777u, "a read of an unbound block no store reached did not read its memory (got " + Hex(loaded) + ")");
Require(slotOf(guest + 0x10).has_value() && !slotOf(guest + page).has_value(), "a read claimed a store page");
reset(true);
std::tie(stored, loaded) = run(MakeBdaStoreLoadTestShader(guest + page - 2, guest + page - 4, 0xa1b2c3d4u, 32));
Require(stored.state == Abi::FaultState::Empty, "an unaligned store across two unbound pages published a fault");
Require(loaded == 0xc3d40000u, "a read beside an unaligned store across two unbound pages returned " + Hex(loaded));
const auto low = slotOf(guest + page - 2);
const auto high = slotOf(guest + page);
Require(low.has_value() && high.has_value() && *low != *high, "an unaligned store across two unbound pages did not claim a store page each");
Require(pageBytes(*low)[page - 2] == std::byte{0xd4} && pageBytes(*low)[page - 1] == std::byte{0xc3} && pageBytes(*high)[0] == std::byte{0xb2} && pageBytes(*high)[1] == std::byte{0xa1}, "an unaligned store across two unbound pages split its bytes wrongly");
reset(true);
std::tie(stored, loaded) = run(MakeBdaStoreLoadTestShader(guest + 2 * page + 0x13, guest + 2 * page + 0x10, 0x5au, 8));
Require(stored.state == Abi::FaultState::Empty && loaded == 0x5acdcdcdu, "a byte store into a copy-backed heap mirror did not reach its memory (read " + Hex(loaded) + ")");
const auto maskSlot = slotOf(guest + 2 * page);
Require(maskSlot.has_value(), "a store into a copy-backed heap mirror claimed no store page");
const auto* mask = words(pool) + Abi::StoreMaskWord(slots, *maskSlot);
Require(mask[0] == (1u << 0x13) && std::all_of(mask + 1, mask + Abi::StoreMaskWords, [](std::uint32_t word) { return word == 0; }), "the store mask of a byte store holds " + Hex(mask[0]));
Require(std::all_of(pageBytes(*maskSlot), pageBytes(*maskSlot) + page, [](std::byte value) { return value == std::byte{0}; }), "a store into a copy-backed heap mirror wrote its store page");
reset(true);
std::tie(stored, loaded) = run(MakeBdaStoreLoadTestShader(guest + 2 * page + 0x1e, guest + 2 * page + 0x1c, 0xa1b2c3d4u, 32));
Require(stored.state == Abi::FaultState::Empty && loaded == 0xc3d4cdcdu, "an unaligned dword store into a copy-backed heap mirror read back " + Hex(loaded));
const auto* split = words(pool) + Abi::StoreMaskWord(slots, *slotOf(guest + 2 * page));
Require(split[0] == 0xc0000000u && split[1] == 0x3u, "the store mask of an unaligned dword store holds " + Hex(split[0]) + " " + Hex(split[1]));
reset(true);
const std::array<std::uint32_t, 4> values{0x01020304u, 0x05060708u, 0x090a0b0cu, 0x0d0e0f10u};
std::tie(stored, loaded) = run(MakeBdaDwordWriteTestShader(guest + 2 * page + 0x18, 4, values.data()));
Require(stored.state == Abi::FaultState::Empty && std::memcmp(masked.Bytes().data() + 0x18, values.data(), sizeof(values)) == 0, "a four-dword store into a copy-backed heap mirror did not reach its memory");
const auto* wide = words(pool) + Abi::StoreMaskWord(slots, *slotOf(guest + 2 * page));
Require(wide[0] == 0xff000000u && wide[1] == 0xffu && wide[2] == 0, "the store mask of a four-dword store across two mask words holds " + Hex(wide[0]) + " " + Hex(wide[1]));
reset(true);
const auto key = Abi::StorePageKey(guest, guest);
for (std::uint32_t probe = 0; probe < Abi::StorePageProbes; ++probe) words(pool)[(Abi::StorePageHash(key, slots) + probe) & (slots - 1u)] = key + 1000u + probe;
std::tie(stored, loaded) = run(MakeBdaStoreLoadTestShader(guest + 8, guest + 8, 0xa1b2c3d4u, 32));
Require(stored.state == Abi::FaultState::Ready && stored.reason == Abi::FaultReason::StorePages && stored.address == guest + 8 && stored.bytes == 4, "a store finding no free store page did not fault");
Require(words(fault)[Abi::StorePageOverflowWord] == 1, "a store finding no free store page did not mark the overflow");
Require(untouched(unbound, std::byte{0x77}), "a refused store reached the unbound block's memory");
reset(false);
std::tie(stored, loaded) = run(MakeBdaStoreLoadTestShader(guest + 8, guest + 8, 0xa1b2c3d4u, 32));
Require(stored.state == Abi::FaultState::Ready && stored.reason == Abi::FaultReason::StorePages, "a store into an unbound block without a store page table did not fault");
Require(untouched(unbound, std::byte{0x77}), "a store without a store page table reached the unbound block's memory");
}
void RunBdaStoreExecutionTests(const Context& context) {
RunBdaStorePageTests(context);
namespace Abi = ShaderRecompiler::BdaAbi;
Buffer first(context, 2, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
Buffer second(context, 3, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT);
@@ -1,6 +1,7 @@
#include "BdaTests.hpp"
#include "prx/libSceAgcDriver/Graphics/include/BdaResources.hpp"
#include "prx/libSceAgcDriver/Graphics/include/Recorder.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ResidentMirror.hpp"
#include "prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp"
#include "prx/libc/include/GuestAllocations.hpp"
#include "prx/libc/include/GuestHeap.hpp"
@@ -1748,7 +1749,10 @@ void hostImportReportTests() {
counts.requesters[static_cast<std::size_t>(ImportRequester::Segment)] = {1, 1u << 16u, 0, 0, 2};
counts.requesters[static_cast<std::size_t>(ImportRequester::ColorTarget)] = {1, 1u << 20u, 0, 0, 0};
const auto text = FormatHostImportCounts(counts);
Require(text == "3 live (3.0 MiB); made 9 (6.1 MiB), refused 7 (3.5 MiB, 4 remembered), failed 3; by requester (made/refused/failed): map 2/0/0, build 5/7/1, access 0/0/0, join 0/0/0, segment 1/0/2, color target 1/0/0", "the host import report is wrong: " + text);
Require(text == "3 live (3.0 MiB); made 9 (6.1 MiB), refused 7 (3.5 MiB, 4 remembered), failed 3; by requester (made/refused/failed): map 2/0/0, build 5/7/1, access 0/0/0, join 0/0/0, segment 1/0/2, color target 1/0/0, label 0/0/0", "the host import report is wrong: " + text);
counts.labelBytes = 3u << 19u;
const auto labels = FormatHostImportCounts(counts);
Require(labels == text + "; 1.5 MiB of label windows", "the host import report does not name the label windows: " + labels);
}
class PieceWindow {
@@ -4048,30 +4052,135 @@ void heapMirrorTests(const Context& context, const BdaTestAccess& access) {
Require(build(0, {}) == first && MirrorCounters().heapChecks == quiet.heapChecks && MirrorCounters().sweeps == quiet.sweeps && MirrorCounters().blocksCopied == quiet.blocksCopied, "an unchanged heap range was compared block by block or the mirrors were swept again");
guest[65536 + 9] = 0x66;
Require(build(0, {}) == first && MirrorCounters().heapChecks > quiet.heapChecks && MirrorCounters().blocksCopied == quiet.blocksCopied + 1 && access.addressBytes(first)[65536 + 9] == std::byte{0x66}, "a CPU write after an unchanged build was missed");
{
GuestBufferMemory leased(context);
leased.AcquireRegistered();
leased.AllowAddressStores();
leased.Upload(true);
for (const auto& range : leased.AddressRanges()) {
if (range.end <= address || range.begin >= address + bytes) continue;
Require(range.permissions == ShaderRecompiler::BdaAbi::Read, "a read-only heap mirror became writable for a program that stores through addresses");
}
leased.WriteBack();
}
registry(false, false);
sweep();
const auto swept = MirrorCounters();
Require(swept.heapMirrors == before.heapMirrors && swept.heapBytes == before.heapBytes, "the heap mirror outlived its range");
registry(true, true);
const auto device = build(address + 16, [&](GuestBufferMemory& leased) {
std::uint32_t adjustment = 0;
const auto view = leased.Descriptor(address + 16, 32, adjustment);
access.bytes(view.buffer)[view.offset + adjustment] = std::byte{0x77};
guest[16 + 8] = 0x55;
});
Require(guest[16] == 0x77 && guest[16 + 8] == 0x55, "a writable heap mirror's write-back lost the GPU's store or rolled back the CPU's");
Require(build(0, {}) == device && access.addressBytes(device)[16] == std::byte{0x77} && access.addressBytes(device)[16 + 8] == std::byte{0x55}, "the writable heap mirror missed the stores");
Require(build(address + 40, [&](GuestBufferMemory& leased) {
std::uint32_t adjustment = 0;
const auto view = leased.Descriptor(address + 40, 8, adjustment);
access.bytes(view.buffer)[view.offset + adjustment] = std::byte{0x78};
}) == device && guest[40] == 0x78, "a writable heap mirror's second write-back lost the GPU's store");
guest[65536 + 1] = 0x79;
Require(build(0, {}) == device && access.addressBytes(device)[40] == std::byte{0x78} && access.addressBytes(device)[65536 + 1] == std::byte{0x79}, "the writable heap mirror missed a store after a write-back");
registry(false, true);
sweep();
Require(MirrorCounters().heapMirrors == before.heapMirrors, "the writable heap mirror outlived its range");
const auto writableMirror = [&](bool forceCopy) {
std::memset(block, 0x11, bytes);
registry(true, true);
const auto device = build(address + 16, [&](GuestBufferMemory& leased) {
std::uint32_t adjustment = 0;
const auto view = leased.Descriptor(address + 16, 32, adjustment);
access.bytes(view.buffer)[view.offset + adjustment] = std::byte{0x77};
guest[16 + 8] = 0x55;
});
const auto held = HeapMirrorsWithin(address, address + bytes);
const bool resident = held.resident != 0;
const std::string what = resident ? "a resident writable heap mirror" : "a copy-backed writable heap mirror";
Require(held.mirrors == 1 && !(forceCopy && resident), what + " was made where the address space limit forces a copy-backed one");
Require(!resident || held.bytes == bytes, what + " left a block of nonzero guest bytes unbound");
Require(guest[16] == 0x77 && guest[16 + 8] == 0x55, what + "'s write-back lost the GPU's store or rolled back the CPU's");
Require(build(0, {}) == device && access.addressBytes(device)[16] == std::byte{0x77} && access.addressBytes(device)[16 + 8] == std::byte{0x55}, what + " missed the stores");
Require(build(address + 40, [&](GuestBufferMemory& leased) {
std::uint32_t adjustment = 0;
const auto view = leased.Descriptor(address + 40, 8, adjustment);
access.bytes(view.buffer)[view.offset + adjustment] = std::byte{0x78};
}) == device && guest[40] == 0x78, what + "'s second write-back lost the GPU's store");
guest[65536 + 1] = 0x79;
Require(build(0, {}) == device && access.addressBytes(device)[40] == std::byte{0x78} && access.addressBytes(device)[65536 + 1] == std::byte{0x79}, what + " missed a store after a write-back");
{
GuestBufferMemory leased(context);
leased.AcquireRegistered();
leased.AllowAddressStores();
leased.AddWritable(address + 16, 32);
leased.Upload(true);
const auto expected = ShaderRecompiler::BdaAbi::Read | ShaderRecompiler::BdaAbi::Write | (resident ? 0u : ShaderRecompiler::BdaAbi::Masked);
const auto ranges = leased.AddressRanges();
auto cursor = address;
for (auto part = std::find_if(ranges.begin(), ranges.end(), [&](const auto& range) { return range.begin == address; }); cursor < address + bytes && part != ranges.end(); ++part) {
Require(part->begin == cursor && part->deviceAddress == device + cursor - address && part->permissions == expected, what + " a program stores to through addresses is not writable in the BDA table with " + (resident ? "plain Read|Write" : "Read|Write|Masked"));
cursor = part->end;
}
Require(cursor == address + bytes, what + " a program stores to through addresses is not wholly in the BDA table");
const auto stored = access.addressBytes(device);
constexpr std::uint64_t page = ShaderRecompiler::BdaAbi::StorePageBytes;
const std::array<std::pair<std::uint64_t, std::byte>, 3> stores{{{16, std::byte{0x7c}}, {1000, std::byte{0x7a}}, {65536 + 2000, std::byte{0x7b}}}};
std::vector<GuestBufferMemory::StorePage> pages;
for (const auto& [offset, value] : stores) {
stored[offset] = value;
const auto at = (address + offset) / page * page;
if (pages.empty() || pages.back().address != at) pages.push_back({at, {}, {}});
const auto bit = address + offset - at;
pages.back().mask[bit / 32u] |= 1u << (bit % 32u);
}
guest[1000 + 8] = 0x5b;
std::vector<std::pair<std::uint64_t, std::uint64_t>> written;
for (auto& entry : pages) {
const auto first = static_cast<std::ptrdiff_t>(entry.address - address);
entry.data.assign(stored.begin() + first, stored.begin() + first + static_cast<std::ptrdiff_t>(page));
written.emplace_back(entry.address, entry.address + page);
}
leased.NoteAddressStores(std::move(written));
leased.NoteStorePages(std::move(pages));
leased.WriteBack();
}
Require(guest[16] == 0x7c && guest[1000] == 0x7a && guest[65536 + 2000] == 0x7b, "an address store into " + what + " did not reach guest memory");
Require(guest[1000 + 8] == 0x5b && guest[40] == 0x78 && guest[65536 + 1] == 0x79, "the write-back of address stores into " + what + " rolled back a CPU store");
guest[65536 + 3000] = 0x5c;
Require(build(0, {}) == device && access.addressBytes(device)[1000] == std::byte{0x7a} && access.addressBytes(device)[65536 + 2000] == std::byte{0x7b} && access.addressBytes(device)[65536 + 3000] == std::byte{0x5c}, "a refresh of " + what + " reverted the address stores");
{
GuestBufferMemory leased(context);
leased.AcquireRegistered();
leased.AllowAddressStores();
leased.AddWritable(address + 16, 32);
leased.Upload(true);
Require(!leased.AddressStoreSpans().empty(), "a program that stores through addresses into " + what + " has no store span");
auto unpooled = context;
unpooled.bufferPool.reset();
const BdaResources keep(unpooled);
const auto slotsBefore = BdaResources::FaultSlots(context.device);
auto storing = std::make_unique<BdaResources>(unpooled, leased, false);
const auto slotsHeld = BdaResources::FaultSlots(context.device);
Require(storing->HoldsFaultSlot() && slotsHeld.slots == slotsBefore.slots + 1 && slotsHeld.chunks == slotsBefore.chunks + 1 && slotsHeld.held == slotsBefore.held + 1, "a build that stores through addresses into " + what + " did not take a fault chunk of its own");
storing.reset();
const auto slotsAfter = BdaResources::FaultSlots(context.device);
Require(slotsAfter.slots == slotsBefore.slots && slotsAfter.chunks == slotsBefore.chunks && slotsAfter.held == slotsBefore.held, "a destroyed build that stored through addresses into " + what + " left its fault chunk counted in the arena");
std::lock_guard gpu(AgcDriver::GuestMemory::GpuMutex());
storing = std::make_unique<BdaResources>(unpooled, leased, false);
std::vector<std::unique_ptr<BdaResources>> idle;
for (std::size_t index = 0; index < 8; ++index) idle.push_back(std::make_unique<BdaResources>(unpooled));
constexpr std::uint64_t used = std::uint64_t{1} << 62;
storing->NoteUse(used);
for (const auto& resources : idle) resources->NoteUse(used);
BdaResources::NoteFinished(context.device, used);
const auto reclaimedBefore = BdaResources::FaultSlots(context.device).reclaimed;
std::vector<std::unique_ptr<BdaResources>> pressure;
while (BdaResources::FaultSlots(context.device).reclaimed == reclaimedBefore && pressure.size() < 256) pressure.push_back(std::make_unique<BdaResources>(unpooled));
Require(BdaResources::FaultSlots(context.device).reclaimed != reclaimedBefore, "fault slot pressure beside a build that stores through addresses into " + what + " reclaimed no idle slot");
Require(storing->HoldsFaultSlot(), "fault slot pressure reclaimed the private fault slot of an idle build that stores through addresses into " + what);
pressure.clear();
idle.clear();
storing.reset();
leased.WriteBack();
}
registry(false, true);
sweep();
Require(MirrorCounters().heapMirrors == before.heapMirrors, what + " outlived its range");
};
struct AddressSpaceLimit {
explicit AddressSpaceLimit(std::uint64_t bytes) { SetResidentAddressSpaceLimit(bytes); }
~AddressSpaceLimit() { SetResidentAddressSpaceLimit(0); }
AddressSpaceLimit(const AddressSpaceLimit&) = delete;
AddressSpaceLimit& operator=(const AddressSpaceLimit&) = delete;
};
{
const AddressSpaceLimit limit(1);
writableMirror(true);
}
writableMirror(false);
#ifdef _WIN32
{
Loaded 100 of 1776 files, more files were not shown because too many files have changed in this diff. Show more