Commit Graph
18 Commits
Author SHA1 Message Date
AlxcBTW ad85ed13ac perf(agc): format and write steady-state log lines off the queue worker
Texture creation logged one stdout line per texture and per mip through
WriteLogLine, which formatted with the mingw printf and flushed every
line on the queue worker (about 786k lines in a 25 minute cave run).

AsyncLog keeps a bounded queue and a logger thread. AGC_LOG_DEFERRED
captures numeric arguments on the caller and formats them on the logger
thread; WriteLogLine hands finished lines to a per-module sink in
libc/LogMacros.hpp that AgcDriver installs, so all AgcDriver stdout
lines keep their order and are written one flush per batch. A full queue
blocks the caller, so no line is dropped. Flush runs on driver failure,
shutdown and at exit. APS5_LOG_SYNC=1 restores the synchronous path.

Identical "deferred write-back failed" notes are printed three times per
10 s and then counted into one "repeated N more times" line. A
"[log] 10 s" line reports lines, bytes, caller time and logger time
(APS5_LOG_STATS=0 hides it).
2026-10-15 20:42:16 +02:00
Dean 95945006ec Merge pull request #4629 from mugurc/fix/libcxx-portability
fix(libs): build with libc++
2026-10-15 10:46:05 +13:00
Adrià f3434892bc Merge pull request #5862 from MarcZX100/feat/windows-worker-thread-names
feat(windows): name presenter and queue worker threads
2026-10-14 16:39:02 +02:00
MarcZX100 445db4d013 feat(windows): name presenter and queue worker threads 2026-10-14 14:02:27 +00:00
MarcZX100 2cc4999420 feat(libc): add optional log timestamps 2026-10-14 13:55:30 +00:00
mugurc facc03ae90 fix(libs): build with libc++
Apple clang ships libc++, which differs from libstdc++ where the sources
relied on it:

- std::atomic<std::shared_ptr<T>> is not provided. AtomicSharedPtr is that
  type where the library has it and a mutex-guarded pointer with the same
  member functions elsewhere; the AGC driver uses it.
- std::atomic_ref<const T> is not provided; the page span reads go through
  a non-const reference.
- std::filesystem::file_time_type::clock::to_sys is not provided;
  std::chrono::file_clock::to_sys is.
- std::max and std::min do not deduce across the integer types of the
  guest range arithmetic, which is spelled with an explicit type.
- <string> and <initializer_list> are included where the sources and tests
  use them.
2026-10-12 19:57:33 +03:00
mugurc f818d5e225 fix(libs): spell inline assembly symbols for Mach-O hosts
C symbols in Mach-O carry a leading underscore, and its assembler has no
.type or .size directives. APS5_ASM_SYMBOL names a symbol the way the
assembler of the host expects it, APS5_ASM_FUNCTION_END closes a function
(.size on ELF, nothing elsewhere), and APS5_ASM_FUNCTION defines a global
function on macOS.

The fiber stack switch, the signal mask helpers, getcontext and their tests
use them instead of writing the ELF spelling. The assembly they produce on
Linux and Windows is the same as before.
2026-10-12 19:57:33 +03:00
fdfawef324andClaude Opus 5.5 58669dc134 fix(libc): write each log line in one call
mingw's fprintf writes an unbuffered stream a character at a time and
holds the stream's lock for the whole line. The APS5_LOG_* lines that
carry a RecompileRequest ("Shader ... could not be prepared after
registration", 15-20 KB each) took one WriteFile per character, and every
other thread writing to stderr waited behind them, guest calls that log
included. Demon's Souls (PPSA01342 v1.005, Windows) stops on a black
screen after two frames on main: a BPE job worker waits for the stderr
lock in sceSaveDataDirNameSearch's trace while the shader preparation
pool prints its dumps, so GameCoreLoop never finishes a frame.

The log macros now format the line into memory and write it with one
fwrite, as Driver::reportSkip does since 8cf2f6580. The UCRT writes an
unbuffered stream's fwrite as one even-length block and the last byte,
so a line takes at most two writes on Windows and one on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:23:21 -04:00
DariusHQ cf1545d751 feat(libkernel): implement getcontext, setcontext and makecontext
PSXS5, SwanStationPS5 and Nuvio stop at start-up on setcontext on main,
and EVO Player and ProsperoStore do on Windows. The three are imported
by the statically linked OpenSSL's ASYNC code.

The three use FreeBSD 11's amd64 ucontext_t (mcontext at 0x10, mc_len
800, uc_link at 0x330, 0x370 bytes), which the titles are built
against: EVO Player's ASYNC_is_capable captures into a 0x370-byte stack
buffer, and async_fibre_makecontext sets uc_link at 0x330 and uc_stack
at 0x338. getcontext saves every register at its call in assembly and
stores the context as FreeBSD's sys_getcontext does: rax and rdx as 0,
the carry flag clear, the FXSAVE image and the signal mask, and nothing
from uc_link on. setcontext checks mc_len and mc_flags as set_mcontext
does, installs the signal mask, masks MXCSR with the host's MXCSR_MASK
and returns through iretq, so every general register and the flags are
restored and nothing is written below the target stack pointer.
makecontext follows FreeBSD 11's amd64 libc.

Windows checks guard-page growth and exception unwinding against the
stack bounds in the TEB. setcontext and longjmp now set them to the
stack they switch to, which makecontext registers and pins writable as
libSceFiber does for fiber stacks. OpenSSL enters a context with
setcontext and then switches with _setjmp and _longjmp.
2026-10-11 13:00:38 +03:00
Zheorgyan eec5c18279 fix(libc): define APS5_LOG_OUT_DEBUG when APS5_DEBUG_LOG is set 2026-10-09 13:42:51 +02:00
boykopovar 94c443e32f refactor(agc): make frame timing logs optional by cmake option 2026-09-28 10:51:29 +03:00
boykopovar 65c6214a68 fix(agc): validate rect-list addressing model + logs refactor 2026-09-23 21:26:21 +03:00
boykopovar 8e95b27583 chore(cmake): add cmake option -DAPS5_AGC_CREATE_LOG 2026-09-13 17:44:17 +03:00
boykopovar 36c29c9a66 feat(libs): sysv abi macros for windows exports 2026-09-10 13:30:05 +03:00
boykopovar 74de895ac0 feat(libs): add new libSceAgc unknown functions 2026-09-10 09:43:59 +03:00
boykopovar 8400150f80 feat(libs): add new declarations to libSceAgc 2026-09-10 09:09:08 +03:00
boykopovar 411a4d00a5 feat(libs): add change export name macros 2026-09-10 08:22:39 +03:00
boykopovar abc72da741 feat(libs): define vabi macros + add to declarations 2026-09-10 08:07:03 +03:00