Commit Graph

557 Commits

Author SHA1 Message Date
Dean 3d8ffeb271
Merge pull request #4395 from oneandonlydean/up4/carry-1810
fix(agc): cache Linux describePages results
2026-10-12 23:54:52 +13:00
Dean 3356c28fd6
Merge pull request #4106 from fma-rc/feat/agc-present-mode
feat(agc): select the swapchain present mode with ANYPS5_PRESENT_MODE
2026-10-12 23:53:46 +13:00
Dean dfb2033eb1
Merge pull request #3889 from devavijitsingh/fix/agc-write-tracker-lifetime
fix(agc): keep write tracker alive through driver teardown
2026-10-12 23:52:18 +13:00
Dean b6aa03eae1
Merge pull request #3956 from GustavoGamarra95/feat/agc-storage-dump-selector
feat(agc): select storage dumps by shape and store them at each flip
2026-10-12 23:51:32 +13:00
Dean b40a0b17dc
Merge pull request #3946 from danzaio/fix/shader-failure-address
fix(agc): name the shader address and stage in preparation failures
2026-10-12 23:51:09 +13:00
Dean 98341494df
Merge pull request #4308 from utkuhalis/pr/agc-acb-rendering-wait
feat(libSceAgc): implement sceAgcAcbWaitUntilSafeForRendering
2026-10-12 23:50:06 +13:00
Dean b117e31f39
Merge pull request #4186 from Scramblrrrr/codex/host-hole-query-cross-test
fix(memory): exclude arena host holes from every write-tracking query
2026-10-12 23:49:18 +13:00
Ahir 49e9298706 fix(agc): store only the requested pages of a Linux page query
describePages stored the whole VMA that PROCMAP_QUERY or /proc/self/maps returned. Linux merges adjacent
anonymous mappings with equal flags, so an arena VMA can span GiBs, and the first table miss inside it after
an invalidation rewrote every page of it. Only the pages of the request, rounded out to whole pages, are
stored now, as #1791 describes.

When the guest arena is available, RunUnmappedGapTests checks that a check stores no pages outside its
range, and that protecting and unmapping through the registry clears the stored pages. The registry checks
follow the test on the perf/linux-page-cache branch linked from #1791.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 21:35:24 +13:00
Swastik-51 9f06176334 fix(agc): cache Linux describePages results 2026-10-12 21:35:13 +13:00
Adrià 2979ae37a3
Merge pull request #4152 from adriadam10/feat/phase-b
perf(agc): build shader pipeline libraries when shaders are registered
2026-10-12 10:31:42 +02:00
Dean 9bc3623517
Merge pull request #4355 from oneandonlydean/up4/fix-4276-stencil-ref-export
fix(agc): export the stencil reference from pixel shaders with VK_EXT_shader_stencil_export
2026-10-12 21:22:09 +13:00
Dean 18028b4920
Merge pull request #4320 from oneandonlydean/up4/fix-frame-dump-queue
fix(agc-driver): queue frame dumps at the dump scale
2026-10-12 21:21:48 +13:00
Adrià Franch d809e6d0db fix(agc): close the library prebuild pool only if it was created
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-12 09:50:41 +02:00
Adrià Franch 361c7e2024 perf(agc): keep oversized shaders specialized and prebuild libraries on their own thread
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-12 09:50:41 +02:00
Adrià Franch e9def903fd perf(agc): prebuild each stage's library alone and keep two descriptor sets with pipeline libraries
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-12 09:50:41 +02:00
Adrià Franch 7f64d14772 perf(agc): build the shader pipeline libraries when graphics stages are resolved at registration
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-12 09:50:41 +02:00
Adrià Franch ddb6680667 perf(recompiler): read buffer V# words in the shader when modules are built at registration
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-12 09:50:32 +02:00
Dean Galvin 22d662eda7 fix(agc): export the stencil reference from pixel shaders with VK_EXT_shader_stencil_export 2026-10-12 19:44:41 +13:00
fma-rc 21b9e2efeb
feat(agc): select the swapchain present mode with ANYPS5_PRESENT_MODE 2026-10-12 08:30:00 +02:00
Dean 2ccbd376f8
Merge pull request #2169 from authurtabo-byte/feat/agc-uniform-sample-locations
feat(agc): support uniform custom MSAA sample locations
2026-10-12 19:06:44 +13:00
Dean Galvin abc1cfa57d fix(agc-driver): queue frame dumps at the dump scale
A frame presented from guest memory with APS5_DUMP_FRAMES is read back
at the size of the display buffer, and that whole copy went into the
dump writer's queue with the scale beside it (31.6 MiB for a 3840x2160
buffer). The queue holds 64 MiB, so the third frame the writer had not
finished ended the run with "frame dump queue exceeded 64 MiB". A frame
blitted from the resident image is already reduced on the GPU and queued
at the reduced size.

The readback is now reduced by the dump scale when the slot retires and
queued at that size, the same pixels the writer kept before. With
APS5_DUMP_SCALE=1 nothing is reduced and the limit is reached as before.

video_out_frame_dump_queue presents four 3840x2160 frames from guest
memory while the writer is held on the first file and compares every
dump with the decoded display buffer.
2026-10-12 18:54:34 +13:00
Utku Halis 661f8e1e7c feat(libSceAgc): implement sceAgcAcbWaitUntilSafeForRendering 2026-10-12 08:26:47 +03:00
AlxcBTW b42ef24e07
fix(libs): keep thread_local objects with destructors out of module teardown on Windows (#4029)
* fix(agc): keep the driver's per-thread scratch out of thread_local teardown

With MinGW's emulated TLS, a thread_local with a destructor in a DLL is
destroyed after its storage is gone: when a std::thread ends, winpthread
runs libgcc's emutls key destructor, which frees the thread's thread_local
storage, and only then does the loader's DLL_THREAD_DETACH run the DLL's
tls_atexit list, so the destructors run on freed memory. The queue worker
touches four of them in libSceAgcDriver (the dispatch-ahead map, the
pending waits, the draw-snapshot compare vectors and the image decode
memo), and Driver::stop's join of the worker then corrupts the heap.
Under cdb's checking heap agc_driver_draw_cache_reuse stopped at the
worker's exit with heap corruption in all 127 runs, with graphics
pipeline libraries, with APS5_NO_PIPELINE_LTO=1 and with APS5_NO_GPL=1.
Without it the damage shows intermittently, as exit 0xc0000374 (2 of 143
runs with a cold NVIDIA shader cache) or as a fault in whatever allocates
next, such as NVIDIA's compiler on the optimized-link thread (#2980).

These objects now live in HostThreadLocal, fiber-local storage that owns
them, as the recorder's buffers do since e424b6b7b.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(libs): keep thread_local objects with destructors out of module teardown

The teardown order behind the driver's heap corruption holds in every
module: with MinGW's emulated TLS a thread's thread_local storage is freed
before the module's DLL_THREAD_DETACH runs its thread_local destructors,
so they run on freed objects. PreciseSleepUs's timer (used, among others,
by the video-out vblank thread) then closes a stale handle; libkernel's
directory path, socket waker and UUID random device, libSceRandom's random
device and libScePosixForWebKit's random device and host lookup free or
close stale objects. They move to HostThreadLocal. The other thread_locals
in the modules are trivially destructible or only built for Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(libs): fail when a module registers a thread_local destructor

prx_thread_local_destructors lists the symbols of every built module and,
where MinGW's thread_local destructor support is linked in, disassembles
the module for calls to __cxa_thread_atexit outside libc's registration of
guest destructors. A module that keeps a thread_local with a destructor
fails it with the function that registers one: with main's libSceRandom
it reports sceRandomGetRandomNumber, and with this branch all 122 modules
pass, libc being the only one that links the support.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(agc): keep the image memo behind its pointer

The image decode memo went into HostThreadLocal as the whole array. On
Linux, where HostThreadLocal is a plain thread_local, that put 1024 memo
entries into every thread's TLS block instead of one pointer. It keeps
its unique_ptr as before, now owned by HostThreadLocal, so Linux builds
the same thread_local as main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Dean Galvin <dean.galvin@live.com>
2026-10-12 18:25:29 +13:00
fma-rc 9db923e907
fix(shader): clip primitives with an all-zero clip position 2026-10-12 06:46:34 +02:00
danzaio 56df893667 fix(agc): preserve dumps for non-standard shader failures
Capture the request once before rethrowing from the shared handler. Standard exceptions keep the shader address, stage, optional dump filename and full message; non-standard exceptions remain unchanged after capture.

AI-assisted: yes.
2026-10-12 01:33:37 -03:00
danzaio e71e3a4b3f fix(agc): name the shader address and stage in preparation failures
PrepareShaderWithDiagnostics dumped the request but rethrew the raw error, so a failure never said which shader it came from. Wrap it with the shader address and stage, keeping the dump. AI-assisted: yes.
2026-10-12 01:33:37 -03:00
Dean eb91f4e860
Merge pull request #4049 from Mouhand-Kaddo/fix/demons-readonly-resummarize
fix(agc): handle Demon's Souls read-only depth resummarize
2026-10-12 17:30:54 +13:00
Dean 991378066e
Merge pull request #3661 from Celegans12/fix/agc-own-resolved-dispatch-state
fix(agc): own resolved dispatch state through thread exit
2026-10-12 17:29:00 +13:00
authurtabo-byte c9e48e5ae2 feat(agc): support uniform custom MSAA sample locations 2026-10-11 20:36:04 -07:00
screamm 1b4baaee27 fix(memory): exclude arena host holes from every write-tracking query
On Windows agc_write_tracking has failed since #3594 with

    write tracking test failed: an unwatched range reads as not stored over

from the check in CheckSharedBlock:

    if (!Watched(outside, unwatched.size())) Require(StoredOver(outside, unwatched.size(), TrackerGeneration()), "an unwatched range reads as not stored over");

The host stack array lies in a host hole of the guest arena. #3594 made
Watched, collectWrites, UnchangedSince, UnchangedSinceAll and storeOwn
reject ranges overlapping such holes, but StoredOver, MarkWritten,
WrittenSince, ChangedBlocks and ImportWatched still accepted them through
WriteTracker::covers(), so StoredOver proved a range not stored over while
Watched called it unwatched (#4087).

The exclusion now lives in WriteTracker::covers() on Windows, which every
query already asks, and the per-function checks are removed. Host holes
are padded to the allocation granularity and the tracker blocks are 64 KiB
from the arena base, so no block is shared between a hole and arena
memory, and ranges outside the holes get the same answers as before.

A new case enumerates the arena for a host hole and checks every query
against it; on the previous code StoredOver, MarkWritten, StoreOwnBytes,
WrittenSince and ChangedBlocks fail it.

Fixes #4087

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-11 21:36:46 -03:00
Avijit Singh fc7a9650f9 style(agc): remove unnecessary shutdown explanation
Keep the tracker initialization fix without an explanatory code comment or technical-debt entry, as requested in review.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-12 05:32:09 +05:30
Dean Galvin 5864ee5839 fix(agc): report arena host holes as stored over on Windows
StoredOver still read block stamps for a range in a host region inside the guest arena interval, which Watched reports as unwatched since #3594.
2026-10-12 12:38:06 +13:00
Gustavo Ariel Gamarra Rojas a70ec3946d feat(agc): store the dumped storage images at each flip
An image whose results stay on the GPU is never written back, so
APS5_DUMP_STORAGE saw nothing; APS5_STORE_AT_FLIP=1 stores every pending
image and ran a 4 GB device out of memory at 3840x2160. The selected
images alone are now stored at each flip.
2026-10-11 19:59:42 -03:00
jweidenh 2b8f151b3f test(agc): verify optimized pipeline draws and readback 2026-10-12 00:16:28 +02:00
Adrià e10f91b305
Merge pull request #3777 from MarcZX100/codex/agc-store-idle-3272
fix(agc): store pending storage-image results when queues idle
2026-10-12 00:04:39 +02:00
Adrià 90933951d9
Merge pull request #419 from MichonGoddijn231849/feat/msaa-targets
feat(agc): multisampled color and depth targets with CB resolves
2026-10-12 00:01:37 +02:00
Mouhand Kaddo 82ac3bd93e fix(agc): skip read-only depth resummarize draws 2026-10-12 02:01:36 +04:00
Adrià df64fa9382
Merge pull request #3738 from Mouad-Scriptz-0/feat/agc-merged-vertex-tables
fix(agc): read a merged program's vertex tables past its hidden user words
2026-10-11 23:56:46 +02:00
Adrià 06664a44cd
Merge pull request #3717 from jweidenh/codex/nvidia-pipeline-replay
feat(agc): capture and replay compute pipeline compilation
2026-10-11 23:54:52 +02:00
Michon d109f3966f fix(agc): guest access to a multisampled color target's memory throws
A multisampled target's samples are only on the host, so its guest memory
never holds them: a CPU read through GuestMemory::Read/ReadCommitted, a
DMA_DATA copy from it and a texture or storage image lookup at its address
throw instead of returning bytes that were never written there. Asked by
oneandonlydean; the test reads a resolved-only target's memory each way.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 23:41:30 +02:00
Michon ebf361103c feat(agc): multisampled color and depth targets with CB resolves
Draws with PA_SC_AA_CONFIG multisampling (2, 4 or 8 samples, every target with as many
fragments, the standard sample locations, MSAA_ENABLE) render into host-only multisampled
color images and multisampled depth surfaces; the pipeline rasterizes with that sample
count. A CB_COLOR_CONTROL resolve over a multisampled CB0 runs as a render pass whose
resolve attachment is CB1's resident image. A zero fill over a target's CMASK fast-clears
it to the CB_COLOR_CLEAR_WORD values of its next use. EQAA, coverage conversion,
nonstandard sample locations, sampling a multisampled surface and multisampled mips stay
refused.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 23:41:30 +02:00
Adrià 8a13a1b8ef
Merge pull request #3594 from Scramblrrrr/codex/windows-host-write-watch-exclusion
fix(agc): exclude host arena holes from write-watch proofs
2026-10-11 23:39:34 +02:00
Adrià 1342c4b9df
Merge pull request #3539 from MarcZX100/codex/agc-write-data-dst3-3534
fix(agc): accept WRITE_DATA destination 3 for memory fences
2026-10-11 23:36:57 +02:00
Adrià a672688e94
Merge pull request #3523 from XairRrR/fix/agc-default-unexported-pixel-inputs
fix(agc): read zero for pixel inputs of parameters the vertex stage does not export
2026-10-11 23:36:20 +02:00
Adrià 9865c57f76
Merge pull request #2261 from Sanjaysrinivas/feat/registered-ngg-workgroup
fix(agc): route registered NGG workgroups through mesh
2026-10-11 23:23:54 +02:00
Adrià fc5faefc44
Merge pull request #3159 from XairRrR/perf/agc-shader-prep-lock
perf(agc-driver): prepare shader ABI variants before taking the preparation lock
2026-10-11 23:23:53 +02:00
jweidenh 3740c233bc fix(agc): accept core Vulkan capabilities during compute replay 2026-10-11 16:34:26 -04:00
jweidenh a4ae6d7e31 fix(agc): capture larger compute modules and binding flags 2026-10-11 16:14:44 -04:00
jweidenh 8fbd0eecc1 feat(agc): capture and replay compute pipeline compilation 2026-10-11 16:09:48 -04:00
Avijit Singh 471d9eced2 fix(agc): keep write tracker alive through driver teardown
Initialize the guest write tracker during Driver construction so its function-local static is destroyed after Driver on process exit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-12 00:19:21 +05:30