Commit Graph
5577 Commits
Author SHA1 Message Date
Gerard L.andClaude Opus 5.5 b6a9530723 fix(agc): use gfx1013's smaller mip tail limits for 8 and 16 bpp SW_64KB_Z_X
The smallest mip levels of a tiled surface are packed together into one
block, the mip tail. A size limit decides which level is the first to
go into the tail.

For SW_64KB_Z_X, AnyPS5 used the same limit as the other 64 KiB modes.
In addrlib, that is only the case on Navi10. On every other GFX10 chip,
including the PS5's gfx1013, addrlib halves the limit for 8 and 16 bpp
Z_X surfaces: the width at both sizes, and also the height at 8 bpp.
The setting behind this is dsMipmapHtileFix (see HwlConvertChipFamily
and ComputeSurfaceInfoMacroTiled in gfx10addrlib.cpp).

With the larger limit, the tail started too early. For example, a
256x256 R8 surface with 9 levels started its tail at mip 1 instead of
mip 2, and took 131072 bytes instead of 196608. Every level was then
read and written back at the wrong offset.

GetMipTailLayout now halves the limits the same way. Only the level
where the tail starts changes; the tail slot positions stay the same.
This follows addrlib's setting for gfx1013. The console's own layout
has not been measured.

Fixes #1590

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 20:06:51 +02:00
Karan Vora 3a16e5e54e perf(shader): round v_cvt_pknorm and v_cvt_pk_u8 in f32
v_cvt_pknorm_i16/u16_f32 rounded |x| * 32767 or 65535 to nearest even
with a 64-bit integer product, variable 64-bit shifts and a sticky bit.
In f32, p = |x| * scale is the f32 nearest to the exact product, so
roundEven(p) is the answer unless p is exactly k + 0.5, where the sign of
the exact error fma(|x|, scale, -p) decides. Lanes that select a
constant (NaN, |x| >= 1) multiply 0 instead.

v_cvt_pk_u8_f32 truncated with the saturating conversion and rounded the
fraction by hand; it is now roundEven(x) between the 0 and 255 clamps,
NaN giving 0, read without the f32 denormal flush.

New test agc_driver_f32_pack_rounding: 563,232 inputs around every
rounding tie, checked against the exact product in double.
2026-10-09 14:05:07 -04:00
Nahuel Genchi 230625e080 fix(libc): return ENOMEM from posix_memalign for sizes the default heap rejects 2026-10-09 15:03:07 -03:00
Archit Dewan 4a5cd6e40b fix(ajm): reject ATRAC9 gradients beyond decoder bounds 2026-10-09 13:53:46 -04:00
MarcZX100 49887893a4 test(hmd): register disconnected-device tests 2026-10-09 17:47:28 +00:00
MarcZX100 bcaccb6e20 test(libkernel): set pthread test timeout by platform 2026-10-09 17:46:21 +00:00
MarcZX100 74a7a4ab05 test(libkernel): register pthread start coverage 2026-10-09 17:46:21 +00:00
Karan Vora 42692dee11 perf(shader): fold the denormal flush into f32 compares against constants
When f32 denormals are flushed, v_cmp_*_f32 compares flush(a) with
flush(b). With one operand a constant, the flush of the other operand
can go into the compare: a denormal and its flushed zero compare the same
way with a NaN, an infinity or a normal constant, and comparing flush(x)
with a zero is comparing x with +-2^-126 (flush(x) < 0 is x <= -2^-126,
flush(x) == 0 is |x| < 2^-126, and so on, the unordered forms alike).

emitFloatCompare reads both operands unflushed, finds a constant operand
after its abs/neg modifiers, mirrors the predicate when the constant is
first, and emits one compare. Two registers, f16 compares and modes that
keep f32 denormals are unchanged. New test agc_driver_f32_compare_constant
checks all 12 predicates against flush(a) op flush(b).
2026-10-09 13:38:56 -04:00
MarcZX100 d809ccf797 test(libc): cover getcwd zero-size buffer 2026-10-09 17:38:45 +00:00
Hannah Lyons 7d130d1b4b test(libkernel): check getdents errno on success and closed descriptors 2026-10-09 13:30:45 -04:00
Hannah Lyons d6963f46d6 feat(libkernel): implement getdents and getdirentries 2026-10-09 13:30:45 -04:00
Karan Vora b7df8884ff perf(shader): saturate f32 to integer conversions once
The translation of v_cvt_i32/u32/flr_i32/rpi_i32_f32 and v_cvt_i16/u16_f16
already maps NaN to 0 and clamps the value into range before
ConvertS32F32/ConvertU32F32, and the backend truncated it again and
repeated the NaN and range selects on the result. Those IR ops have no
other producers, so the backend now emits one OpConvertFToS or
OpConvertFToU, and EmitF32ToU32 and EmitTruncF32Value, which had no
other users, are removed.

The translation drops its FPTrunc32, as the conversions round toward
zero, and the selects whose constant the conversion of the clamped value
already gives. v_cvt_i32_f32 and v_cvt_u32_f32 read their source without
the f32 denormal flush: a denormal truncates to 0 either way.
2026-10-09 13:28:39 -04:00
authurtabo-byte ce66d2688e fix(libSceAudioOut): allow state queries during output waits 2026-10-09 10:24:31 -07:00
authurtabo-byte f8b9b04dd1 fix(libSceSaveData): accept 32 MiB save memory 2026-10-09 10:24:30 -07:00
Daniel Radosa 1414b27d29 feat(libkernel): implement seteuid and setegid
The guest process is assumed to run as root. Under FreeBSD's
sys_seteuid and sys_setegid, id 0 is then accepted without a privilege
check and changes no credential, so both return 0. Any other id would
change the effective credential, which is not modelled, and throws.

Part of #1578.
2026-10-09 19:14:02 +02:00
krishnarayaandClaude Opus 5.5 dffd449489 fix(shader): give 10_10_10_2 integer vertex inputs an integer type
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-09 12:49:25 -04:00
Celegans12 fcc5105aeb fix(shader): count folded draw offsets once in the vertex and instance indices
When the embedded vertex fetch adds the base vertex or start instance
user SGPR to the index VGPR, the driver folds that SGPR into the draw's
first vertex and first instance. v5/v8 were gl_VertexIndex and
gl_InstanceIndex, which already include it, so the translated add
counted it twice, on direct draws and CPU-path indirect records alike.
The entry of a vertex or local program now subtracts the folded SGPR's
user data word from the builtin, which gives the zero-based indices the
hardware has. A record drawn in place on the GPU keeps the CPU's word,
so the fetch analyzer counts the SGPR as shared unless the fetch add is
the only reader of v5/v8 and the SGPR (no earlier access or EXEC write,
no carry, clamp, second add or other write of the SGPR); such records
take the CPU path. The fold moves into Driver::FoldDrawOffsets,
ClassifyIndirectDraw becomes public for the test, and the env switches
that skipped the fold go.
2026-10-09 18:41:51 +02:00
Joey Fisher f00c2f2d16 fix(recompiler): apply the S_BFE_U32 width when the vertex fetch scanner folds constants 2026-10-09 10:37:40 -06:00
krishnarayaandClaude Opus 5.5 2ea1f6fb71 fix(shader): stop decoding gfx6/7-only VOP2 opcodes on RDNA
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-09 12:30:40 -04:00
klosixgaming-arch 0b82fc4cf1 Merge branch 'main' into bionic/fix-intel-smulextended-v2 2026-10-09 11:28:35 -05:00
Karan Vora d220f48e92 perf(shader): load from buffers without Coherent when the load has no GLC or DLC
A program with one GLC or DLC buffer load or store decorated the whole
guest buffer array Coherent, so its other loads were coherent too. On
NVIDIA that keeps them out of the L1 cache: one GLC store made the
re-reads of a 4 KiB window about 2.7 times slower.

RDNA keeps those loads incoherent. A load without GLC or DLC can hit the
per-CU L0 and per-SA L1 caches, which are not coherent between
work-groups, and code that needs another work-group's data reads it
with GLC/DLC or invalidates the caches first (LLVM AMDGPU memory model,
GFX10: an acquiring load is followed by buffer_gl1_inv; buffer_gl0_inv).

The program metadata now records whether a program invalidates a cache
(buffer_gl0_inv, buffer_gl1_inv, s_gl1_inv, s_dcache_inv). Without one,
a program with GLC/DLC accesses gets a second array on the same binding,
buffers_coherent, decorated Coherent, and both arrays are Aliased as
buffers_u64 already is. Loads without GLC or DLC read buffers; GLC/DLC
loads, stores and atomics use buffers_coherent. A program that
invalidates a cache keeps the whole array Coherent.
2026-10-09 12:22:04 -04:00
marcio-ch adbd8f5e68 feat(libSceRudp): implement sceRudpGetStatus
Zero the status buffer after initialization like sceRudpGetContextStatus,
and return the not-initialized error before it, instead of throwing.
2026-10-09 13:17:26 -03:00
Nahuel GenchiandClaude Opus 5.5 6c81134f79 fix(libkernel): submit APR command buffers that were not constructed
sceKernelAprSubmitCommandBuffer rejected a buffer object with EINVAL
unless sceAmprAprCommandBufferConstructor had tagged it. The tag is
AnyPS5's own: in the retail layout the type word only carries state
bits and the constructors zero the object, so a zero-filled object
bound with SetBuffer is a valid APR buffer.

CRI's file system in Sonic Origins (PPSA05324) lays out its
AprCommandBuffer objects in its own zeroed work memory and never calls
the constructors. Its first read submit failed with 0x80020016, and the
CRI file system stopped there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 13:10:44 -03:00
Mouhand-Kaddo c80bea9b88 fix(posix): configure resolver tests for Windows unwinding 2026-10-09 20:07:54 +04:00
marcio-ch fc3e2345c0 refactor(libSceNpPartner001): name the EA access exports
sceNpEAAccessInitialize and sceNpEAAccessTerminate resolve the NIDs
7CxI50-xlCk and pMxXhNozUX8, which shadPS4 names in np_partner.cpp. The
stubs still throw; only the names and no-argument signatures change.
2026-10-09 12:57:50 -03:00
Achraf ReyaniandClaude Opus 5.5 58e18f0828 fix(libc): remove read-only files on Windows
FreeBSD's unlink ignores the file's own permission bits, so remove()
succeeds on a file the guest made read-only with chmod(0400). On Windows
the guest chmod sets FILE_ATTRIBUTE_READONLY, and DeleteFileW then fails
with ERROR_ACCESS_DENIED, which remove() reported as EACCES. Clear the
attribute and retry, restoring it if the retry still fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-10 00:55:32 +09:00
JAB-devandClaude Opus 5.5 255ed1de7c test(libSceNgs2.native): keep the matrix level clamp clear of the other NGS2 changes
Use INFINITY and NAN from <cmath> instead of a new <limits> include, and
list the TechnicalDebt entry beside the other NGS2 voice entries, so the
change merges cleanly with the pan, channel map and reverb changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 17:55:06 +02:00
Achraf ReyaniandClaude Opus 5.5 46786b1e91 fix(libc): read directory entries through the wide dirent API on Windows
The guest passes and expects UTF-8 names, but on Windows opendir and
readdir used MinGW's narrow dirent API, which works in the ANSI code
page: opendir failed for a directory whose name is outside the code page,
and readdir returned names as ANSI bytes, with "?" for characters the code
page lacks. Use _wopendir and _wreaddir there and convert each name to
UTF-8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-10 00:45:18 +09:00
JAB-devandClaude Opus 5.5 473ca04b2f fix(libSceNgs2.native): throw on reverb rack sizes and sample rates the reverb does not handle
A reverb_size other than the default was accepted and ignored, and below
about 7.5 kHz an allpass length went negative and wrapped to a 16 GB buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 17:38:18 +02:00
EdouardSenceandClaude Opus 5.5 ab09a0a975 fix(agc): accept disabled conservative rasterization with uncertainty-region bits
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 17:38:13 +02:00
Scott SchusterandClaude Opus 5.5 bbdb35b195 fix(libc): check a whole range before collecting its writes with reset
WindowsMappings::Collect resets each part of the range as it walks it:
it marks shared views seen and resets private pages' write-watch bits.
When it then met a NOACCESS view or memory that is not committed
private memory, it returned false with the earlier parts already reset,
so their writes were lost to the caller's fallback. With reset, the
whole range is now checked first and nothing is reset when it fails.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 10:36:55 -05:00
Joey Fisher 36997299e9 test(agc): check that streaming-feedback T# fields share a sampled texture entry 2026-10-09 09:32:23 -06:00
Josip Parlov 9cea268f9e refactor(libc): name the 12 Cyberpunk stubs the NID database resolves 2026-10-09 17:32:08 +02:00
Mouhand-Kaddo a1e2781f80 fix(posix): match FreeBSD numeric IPv4 lookups
Parse legacy decimal, octal and hexadecimal forms before host lookup. Preserve FreeBSD shorthand, whitespace and 64-bit accumulation, clear the SDK resolver error on numeric success, and add regression coverage.
2026-10-09 19:31:56 +04:00
Achraf ReyaniandClaude Opus 5.5 d8c5d142b6 fix(libc): allocate getcwd's buffer from the application heap
getcwd(NULL, size) returned memory from the guest heap directly, while
the caller frees it with free(), which goes to the application heap.
With a title's malloc replacement registered, that free reached the
replacement with a pointer it never returned. Allocate from the
application heap like strdup, and report ENOMEM when it returns null.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-10 00:26:48 +09:00
Josip Parlov c90f85535e refactor(agc): name HV4j+E0MBHE sceAgcCreateInterpolantMapping_0100 2026-10-09 17:25:54 +02:00
Mouhand-Kaddo 4c7e823294 feat(opus): implement 48 kHz libSceOpusDec
Decode raw mono and stereo packets for missing system-library imports. Add behavioral tests and document unverified firmware semantics.
2026-10-09 19:24:56 +04:00
Mouhand-Kaddo d14f036122 feat(posix): implement gethostbyname
Resolve the missing EVO-PLAYER import reported in #1578. Convert native host entries into the guest ABI with owned per-thread storage, and use the SDK network error location for failures.
2026-10-09 19:24:55 +04:00
Mouhand-Kaddo e0b0d087cc test(posix): cover gethostbyname guest results
Check numeric address bytes, guest hostent fields, per-thread result lifetime, and the SDK resolver error location. The check currently fails to link because the reported export is missing.
2026-10-09 19:24:55 +04:00
klosixgaming-arch dd0d8cd425 fix(shader): work around Intel iGPU OpSMulExtended bug 2026-10-09 10:20:14 -05:00
Karan Vora 9996baaf41 perf(shader): pick f32 min, max and med3 results with fewer selects
EmitClassifyF32Bits found a NaN from the exponent and mantissa fields
separately. The magnitude settles it: a NaN is above 0x7f800000 and a
zero is 0.

min and max ended with two NaN selects. An ordered compare is false when
either operand is a NaN, so the ordered pick already returns rhs for a
NaN lhs; only the select that returns lhs for a NaN rhs, also when both
are NaNs, is needed.

med3 is the minimum of the three when any operand is a NaN and the
median otherwise. The median is used only without NaNs, so it is now
built from compares and the zero-sign rule alone, and the minimum reuses
the operands' NaN tests instead of classifying intermediate values.
2026-10-09 11:18:19 -04:00
Joey Fisher 24e33365f0 perf(agc): key sampled textures without the streaming-feedback fields
MIN_LOD_WARN, MIP_STATS_COUNTER_EN and MIP_STATS_COUNTER_ID are ignored by the texture decoder, but the cache
key held the raw T# words. A title that rotates the counter fields per use got a cache entry per variant of the
same texture, and the extra entries evicted live ones under the budget.
2026-10-09 09:14:22 -06:00
popcoder565andClaude Opus 5.5 3b0454dadf test(agc-driver): retire the unit shadow block's import before releasing it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 10:59:12 -04:00
Josip Parlov 61684ce98f test(net): reset the closed peer with unread data so the send fails at once 2026-10-09 16:53:26 +02:00
AlexandClaude Opus 5.5 270f375c82 fix(agc): skip prim state preparation for a patch/hull mismatch
sceAgcCreatePrimState only packs registers, but it now also resolves the
graphics ABI ahead of time, and that resolve throws when the primitive
type is a patch list without HS_EN or a hull stage with another type.
No draw can use such a state, so leave it to draw time and return the
registers. Bit 2 of VGT_SHADER_STAGES_EN is HS_EN, not an NGG bit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-09 16:49:28 +02:00
Pedro a1efdab629 fix(videoout): cancel flips on a port the title closed instead of failing the driver
A flip still queued or in presentation when the title closes its port is discarded, as on hardware, rather than stored as a driver failure. A closed port no longer terminates the presentation thread nor surfaces from Shutdown. The lifetime test now expects cancellation and the reopen mode is registered in ctest.
2026-10-09 09:42:53 -05:00
Pedro 59c98bde58 test(videoout): limit the flip tests to the 30 second contribution timeout 2026-10-09 09:40:45 -05:00
Karan Vora 3a2494e533 perf(shader): choose the fma NaN result only when the result is NaN
#2083 chooses the NaN result of the f32 fma family on the bits: the first
NaN source, quieted in IEEE mode, with the addend skipped when the
product is infinity times zero, and 0xffc00000 otherwise. The selection
and the infinity-times-zero test ran for every fma, but a NaN source
always gives a NaN result, so for any other result they return it
unchanged.

FPNanResultFma32 carries the result and the three sources, with the IEEE
mode as a flag. The SPIR-V emitter makes the selection, including the
infinity-times-zero test, in a branch taken only for a NaN result, and
the SRT evaluator computes it exactly. Add, sub and mul keep the inline
selects: with two sources a branch costs more than it saves.
2026-10-09 10:27:36 -04:00
eljackjoestar-cmd 4dc29440d5 fix(rtc): validate ticks before timezone conversion 2026-10-09 18:20:55 +04:00
eljackjoestar-cmd d31100a0f2 fix(agc): release shader modules after pipeline creation 2026-10-09 18:19:43 +04:00