Commit Graph

6138 Commits

Author SHA1 Message Date
Adrià Franch f9a074250f feat(shader): implement v_qsad_pk_u16_u8 and the mqsad ops
Decode VOP3 0x172, 0x173 and 0x175. Each op slides a 4-byte window over the
64-bit src0 and adds the byte SAD against src1 to the matching 16-bit
(pk_u16) or 32-bit (mqsad_u32) field of src2; the mqsad forms skip zero
reference bytes. Sums wrap per field, as measured on RDNA2 hardware.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:22:25 +02:00
Adrià Franch d43a5487ca docs: SHA-256 memory operands now relink except RIP-relative ones
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:22:02 +02:00
Adrià Franch 5fc16a9548 feat(relinker): lower SHA-256 instructions with a memory operand
SHA256RNDS2/MSG1/MSG2 with a memory source made `--to-intel` fail the
whole relink. The stub now spills a scratch xmm, loads the operand into
it with MOVDQU (AMD does not fault on a misaligned SHA operand, so the
unaligned load keeps that behaviour) and runs the register-form
lowering. RSP-based operands get the spill depth added to their
displacement. RIP-relative operands still fail: the stub runs at a
different address.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:21:40 +02:00
Adrià Franch 13ac232520 fix(shader): count ds_permute_b32 as a lane source
With uniform inputs every lane writes to the same target lane, so only
that lane receives the value; the two-lane wave64 path must not share it.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:21:33 +02:00
Adrià Franch dbb76aa511 feat(shader): implement ds_permute_b32
ds_permute_b32 is the forward (scatter) counterpart of ds_bpermute_b32:
every active lane sends its data to lane ((addr + offset) >> 2) & 31 of
its wave. As measured on hardware, the highest sending lane wins, an
active lane nobody writes to gets 0 and inactive lanes neither send nor
receive. It lowers to one shuffle of the data, address and EXEC bit per
source lane, using the same wave base as ds_bpermute_b32.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:19:43 +02:00
Adrià Franch 5c09d039bb perf(shader): index ValidateProgram by value and block id
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-04 08:18:51 +02:00
Dean 870bdd814f
Merge pull request #373 from MichonGoddijn231849/fix/replaced-device-shadows
fix(agc): a replaced device's unit shadows leave the registry
2026-10-04 18:49:42 +13:00
Dean a874079ac6
Merge pull request #422 from MichonGoddijn231849/perf/graphics-failure-memo
perf(agc): memoize source failures of draw stages as for compute
2026-10-04 18:49:25 +13:00
Dean 50eafda4ce
Merge pull request #424 from MichonGoddijn231849/perf/template-rebind-moved-buffers
perf(agc): draw templates rebind moved read-only buffers and data words
2026-10-04 18:49:08 +13:00
Dean 7b64e262d8
Merge pull request #427 from RomainROCH/codex/fix-wide-string-precision
fix(libc): count wide string precision in output characters
2026-10-04 17:50:53 +13:00
Dean 2e9da3f0fa
Merge pull request #350 from QDarkRex/fix/relinker-windows-icon
fix(relinker): add icons to generated Windows executables
2026-10-04 17:50:37 +13:00
RomainROCH a35e0cfc84 test(relinker): register segment coverage beside load alignment checks 2026-10-04 05:59:16 +02:00
Dean 8f1957623b
Merge pull request #463 from oneandonlydean/perf/agc-occlusion-dumps-on-gpu
perf(agc): record occlusion counter dumps on the GPU
2026-10-04 16:39:08 +13:00
RomainROCH 85d036ca19 perf(relinker): reuse each segment scan across import records 2026-10-04 05:37:13 +02:00
RomainROCH bd2223bba8 Merge remote-tracking branch 'origin/main' into codex/fix-executable-segments 2026-10-04 05:31:06 +02:00
RomainROCH 73d042321b Merge remote-tracking branch 'origin/main' into codex/fix-elf-string-bounds 2026-10-04 05:30:58 +02:00
QDarkRex d8684cb184 test(relinker): add C++ unit test for WindowsIconResourceBuilder 2026-10-04 10:29:20 +07:00
QDarkRex 9642d1b3b0 fix(relinker): add icons to generated Windows executables 2026-10-04 10:29:20 +07:00
RomainROCH 328def4bab fix(relinker): validate all executable segments and preserve live imports 2026-10-04 05:26:01 +02:00
RomainROCH e63524ae34 fix(relinker): bound dynamic strings by the declared table size 2026-10-04 05:23:18 +02:00
Dean Galvin 584c5bc590 perf(agc): wait for a pending key fill before materializing a register DCC clear
The first draw into a target whose DCC keys hold the register clear code
materializes the clear. The GPU clear of the resident image refuses while a
recorded write to the keys is still pending, so whenever the title's own key
fill had not run yet the clear went the CPU way: the clear texels stored
into guest memory (16 MiB for PPSA21564's normal G-buffer) and the image
uploaded again. With the occlusion dumps no longer draining the device, the
fill is usually still pending at that draw, and that was every frame of
PPSA21564's level.

The draw now waits for the recorded writes of the key range alone, checks
the keys again, and clears on the GPU when they still hold the register
code, as it did when the fill had already landed.
2026-10-04 16:17:09 +13:00
Dean Galvin 2596f8c0ad perf(agc): record occlusion counter dumps on the GPU
Every ZPASS_DONE counter dump drained the device so the CPU could add up
the occlusion queries of the finished batches and store the running total.
PPSA21564 dumps around each occlusion-tested pass: about 1.5k drains per
10 s at its title screen, and in a level's early passes four drains a frame
that took 5.6 s of every 10 s of the graphics worker.

The running total now lives in a small buffer the GPU updates in batch
order. A batch still ends its occlusion query at submit; a query that saw
draws is remembered, and its pool is kept alive until it is folded. A dump
ends the open batch's query, copies the remembered results next to the
total, adds them with a one-thread compute shader that also stores the 16
DB counters into the dump's host import, and begins a fresh query for the
rest of the batch. The dump is ordered with the work around it like any
other GPU store, noted as a pending write and stamped. More than 64
remembered results are folded at a submit. Query pools are recycled.

A dump into memory the GPU cannot see, under a pending copied write-back
or over a label the CPU stores at a completion falls back to the drain,
which settles the remembered results on the CPU. Without buffer device
addresses the counting stays on the CPU.
2026-10-04 16:17:09 +13:00
Dean 33a2f907f4
Merge pull request #460 from oneandonlydean/perf/agc-gpu-mesh-indirect
perf(agc): draw mesh-stage indirect draws on the GPU
2026-10-04 16:15:58 +13:00
Dean 2cb95dab12
Merge pull request #452 from SP4C3B4R-8/fix/scissor-window-offset
fix(libSceAgcDriver): accept scissors that apply the zero window offset
2026-10-04 15:48:01 +13:00
Dean Galvin fb55cb2c0e perf(agc): draw mesh-stage indirect draws on the GPU
A mesh program took its draw's index count from push constants, so an
indirect mesh-path (NGG) draw needed the CPU to read its record first,
waiting for the GPU to finish everything recorded before. In PPSA21564
that was about 170 waits per 10 s at the title, menu and level (about
1 s), and one per frame in the intro (2.2 s per 10 s).

The two free mesh push dwords now carry the device address of an argument
record (a VkDrawMeshTasksIndirectCommandEXT followed by the index count
and first index). When the address is set, the prologue takes the index
count and the first index from the record (the new MeshArgument IR value,
a load through a physical storage buffer pointer) and offsets its index
reads by the first index; a direct draw leaves the address 0 and draws as
before. Mesh modules declare the physical storage buffer capability for
it, and the driver's SPIR-V validation accepts the extension in mesh
modules.

An indexed mesh draw with one record that patches no user SGPR now stays
on the GPU. A one-thread compute pass (Graphics/shaders/MeshArguments.comp)
turns the record, read in place from its host import, into the draw's
argument record: the groups and instances of vkCmdDrawMeshTasksIndirectEXT
and the index count and first index the mesh program reads, with the CPU
path's rules (count clamped to the index buffer, nothing for an empty
record or past the device's group limits). The index buffer descriptor
covers the whole buffer and the program offsets by the first index. When
the records cannot be read in place, the CPU reads them and fills the
same argument record (ResolveMeshArguments).
2026-10-04 15:45:56 +13:00
Dean dca710d602
Merge pull request #465 from oneandonlydean/fix/agc-cross-queue-submission-order
fix(agc): run a wait-free submission of another queue after queue 0's earlier submissions
2026-10-04 15:45:30 +13:00
Dean 26e7783483
Merge pull request #457 from oneandonlydean/perf/shader-cache-version-inputs
perf(shader): hash only the recompiler's inputs into the shader cache version
2026-10-04 15:45:12 +13:00
Dean 2ccd3d7b56
Merge pull request #440 from oneandonlydean/feat/agc-fan-gs-input
feat(agc): take triangle fans as NGG geometry shader input
2026-10-04 15:44:54 +13:00
Dean 3e23099fbb
Merge pull request #472 from adriadam10/fix/shader-memory-test-page-read
test(agc): keep shader memory test tables inside one guest page
2026-10-04 15:41:47 +13:00
Dean 0bd34077b4
Merge pull request #455 from arreina/pr/libatrac9-bounds
fix(audio): bound ATRAC9 decoding to the superframe
2026-10-04 15:41:29 +13:00
Dean 837bb8fe96
Merge pull request #438 from adriadam10/feat/vop3-div-fixup-f16
feat(shader): implement v_div_fixup_f16
2026-10-04 15:41:11 +13:00
Dean bbfb3c2b5c
Merge pull request #242 from adriadam10/fix/nid-dynstr-suffix-sharing
fix(nid): share string suffixes when rebuilding .dynstr
2026-10-04 15:40:53 +13:00
RomainROCH 5211ba115b fix(libc): count wide string precision in output characters 2026-10-04 04:31:26 +02:00
Dean e006f64237
Merge pull request #284 from SP4C3B4R-8/fix/replaced-device-host-imports
fix(libSceAgcDriver): destroy host imports of a replaced Vulkan device
2026-10-04 15:13:54 +13:00
Dean e7eabe5048
Merge pull request #282 from SP4C3B4R-8/fix/vulkan-prefer-discrete-gpu
fix(libSceAgcDriver): prefer a discrete GPU over the first suitable device
2026-10-04 15:08:45 +13:00
Dean e84b558bf1
Merge pull request #462 from oneandonlydean/fix/agc-own-store-write-watch
fix(agc): consume the write-watch faults of the driver's own CPU stores
2026-10-04 15:01:48 +13:00
Dean 7c4ff2df70
Merge pull request #464 from oneandonlydean/fix/relinker-exact-reciprocals
fix(relinker): lower VRSQRTPS and VRCPPS to correctly rounded results for --to-intel
2026-10-04 14:45:23 +13:00
Dean Galvin 097566d547 fix(relinker): lower VRSQRTPS and VRCPPS to correctly rounded results for --to-intel
RSQRTPS and RCPPS are approximations whose low bits differ between Intel
and AMD. Intel returns 0x3F7FF000 for 1/sqrt(1.0), and two Newton-Raphson
steps on it settle on 0.99999994 instead of 1.0. PPSA21564 renormalises
its spring quaternions that way: an identity quaternion keeps w at
0.99999994 with a zero axis, its axis-angle conversion then normalises the
zero axis into NaNs, and the NaN bone poses reach keyframed physics bodies.
A NaN body later moves to an invalid broadphase cell and the game crashes
a few seconds into its hub level.

--to-intel now replaces the VEX.128 register forms with an out-of-line stub
that computes 1/sqrt(x) with SQRTPS and DIVPS (1/x with DIVPS), keeping
the upper half of the destination cleared and the scratch register intact.
A site with no room for the jump, including one followed by a branch
target or a RIP-relative instruction, keeps the native instruction and is
reported as kept instead of failing the relink.
2026-10-04 14:40:16 +13:00
Dean 396b282315
Merge pull request #339 from DotDebian/feat/cpu-time-clocks
feat(libkernel): support the CPU-time clocks in clock_gettime and clock_getres on Windows
2026-10-04 14:21:40 +13:00
Dean 40a9e455ea
Merge pull request #430 from adriadam10/feat/relinker-sha1-lowering
feat(relinker): lower SHA-1 instructions for --to-intel
2026-10-04 14:14:08 +13:00
Dean fafec33471
Merge pull request #380 from DotDebian/fix/progress-count-sopp-shared-opcodes
fix(tools): count the debug branches and s_ttracedata_imm as decoded shader instructions
2026-10-04 14:13:51 +13:00
Dean e6505d8a93
Merge pull request #312 from RomainROCH/codex/fix-save-memory-metadata
fix(savedata): report memory metadata write failures
2026-10-04 14:13:01 +13:00
Dean 7384588c35
Merge pull request #411 from MichonGoddijn231849/fix/writelane-ignores-exec
fix(shader): v_writelane_b32 ignores EXEC
2026-10-04 14:06:16 +13:00
Dean d77b96fd44
Merge pull request #403 from MichonGoddijn231849/perf/pending-image-index
perf(agc): index the pending storage images by guest range
2026-10-04 14:06:00 +13:00
Dean d43b12c34e
Merge pull request #433 from adriadam10/fix/relinker-sse4a-upper-qword
fix(relinker): zero dst[127:64] in EXTRQ and INSERTQ lowerings
2026-10-04 14:05:41 +13:00
Dean 40b1c7a6f9
Merge pull request #432 from adriadam10/fix/relinker-vex-rip-relative
fix(relinker): report RIP-relative operands of VEX, EVEX and 0F38/0F3A instructions
2026-10-04 14:05:25 +13:00
Dean deb7e0dfff
Merge pull request #363 from DotDebian/test/sopk-cmpk-compares
test(shader): cover the s_cmpk compares and count them as tested variants
2026-10-04 14:05:04 +13:00
Dean ad473fa569
Merge pull request #389 from DotDebian/feat/mimg-sample-d-cl-o
feat(shader): decode image_sample_d_cl_o
2026-10-04 14:04:47 +13:00
Dean 0207f9ca9a
Merge pull request #388 from DotDebian/fix/mimg-sample-lod-clamp
fix(shader): let image samples clamp their LOD on devices with shaderResourceMinLod
2026-10-04 14:04:31 +13:00
Dean 0df090c30b
Merge pull request #386 from DotDebian/feat/vop3p-integer-dot
feat(shader): implement the integer dot products
2026-10-04 14:04:14 +13:00