Commit Graph

615 Commits

Author SHA1 Message Date
Adrià 2220effbe4
Merge pull request #3482 from MarcZX100/codex/rx-cross-block-3475
fix(agc): retain cross-block R_X coordinate XORs
2026-10-11 14:02:02 +02:00
Adrià 544b38d094
Merge pull request #3474 from 014-code/fix/agc-resource-cache-storage-eviction
fix(agc): evict resource-cache images with storage entries
2026-10-11 13:50:49 +02:00
Adrià daa13905cb
Merge pull request #3434 from Yuva1024/fix/agc-nvidia-pipeline-link-optimization
fix(agc): skip the background pipeline relink on NVIDIA's proprietary driver
2026-10-11 13:49:43 +02:00
MarcZX100 8a390b06df fix(agc): XOR overlapping R_X coordinate contributions 2026-10-11 11:49:23 +00:00
Adrià b33b1b8e66
Merge pull request #3458 from alfalfa-star/fix/agc-dcc-writeback-keys-reused
fix(agc): store a storage image's DCC keys at write-back only when not stored yet
2026-10-11 13:49:15 +02:00
MarcZX100 a6cb65e481 fix(agc): retain cross-block R_X coordinate XORs 2026-10-11 11:23:47 +00:00
Donson 16cfe85a38 fix(agc): evict resource-cache images with storage entries 2026-10-11 19:08:29 +08:00
alfalfa-star 63f06f2935 fix(agc): store a storage image's DCC keys at write-back only when not stored yet
MarkDirty stores uncompressed keys at an image's first write and marks
its uploaded keys uncompressed. The write-back stored them again,
whenever the key bytes did not read uncompressed. By then the title may
have reused the metadata memory: RIDE 4 (PPSA01599) frees its 1920x1088
render targets after the legal screen and Unreal Engine's small-block
allocator takes the 64 KiB key block that followed one of them. The
deferred write-back then filled the allocator's free lists with 0xff
and the title crashed popping one.

The write-back now stores keys only when the image's uploaded keys are
not uncompressed already, that is when no store at the first write or
an earlier write-back made them so since the keys were last read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 12:51:36 +02:00
Yuvaraj b29133c74e fix(agc): skip the background pipeline relink on NVIDIA's proprietary driver
On an RTX 4060 (Ada, driver 617.42) the optimized link of a pipeline built
from libraries loses the device (VK_ERROR_DEVICE_LOST) as soon as it is
bound, which fails agc_driver_pixel_valid_mask in 16 of 20 runs. With
APS5_NO_PIPELINE_LTO=1 it passes 20 of 20. Reporters see the same loss on an
Ampere card with a depth attachment; two Blackwell cards do not lose it.

A device whose driver is VK_DRIVER_ID_NVIDIA_PROPRIETARY keeps the
fast-linked pipeline and no longer queues the link-time-optimized relink.
Other drivers are unchanged.

Refs #2866

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 12:44:46 +02:00
Adrià c064e6898e
Merge pull request #3425 from oneandonlydean/up4/fix-3158-span-limit
perf(agc-driver): join host-import spans only over whole aligned windows
2026-10-11 12:35:57 +02:00
Adrià b70a0e278f
Merge pull request #1491 from Celegans12/feat/shader-tessellation-triangle-patches
feat(shader): implement triangle-patch tessellation
2026-10-11 11:50:50 +02:00
Adrià 946ffa08d4
Merge pull request #3372 from alfalfa-star/fix/agc-fast-clear-import-window
fix(agc): keep a fast-clear copy where an import window can stamp watched memory
2026-10-11 11:40:15 +02:00
Cesar Rodriguez a947303731 perf(agc-driver): join host-import spans only over whole aligned windows
one span. A title that grows a heap 16 KiB at a time then re-imports the
whole chain on every growth: Ratchet & Clank: Rift Apart re-imported about
1.5 TiB while loading its first scene, and NVIDIA refused grown spans with
VK_ERROR_OUT_OF_DEVICE_MEMORY, which leaves those ranges copied per draw.

Ranges are now joined only when a chain covers a whole aligned window (8 MiB
by default, APS5_HOST_IMPORT_WINDOW_MIB on the device); until the window is
complete each range is imported on its own, and a span never crosses a
window edge. Growth therefore re-imports a range once more at most when its
window completes, instead of the chain on every growth. Joining any part of
a window was tried first and still re-imported 2 GB per second in Ratchet,
as each growth re-imported the window's partial span. A single range larger
than the window is imported whole. SetHostImportWindow(0) keeps the
unbounded spans, which is what the existing tests use.

The new importWindowTests (agc_driver_graphics) checks that a full window is
one span, that a partly filled window imports its range alone, that a view
crossing a window edge gets no import, and that completing one window leaves
the other window's import in place; with the window ignored it fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 22:35:28 +13:00
Celegans12 77dcb74ccd feat(shader): implement triangle-patch tessellation
DecodeShaderStages accepts LS, HS and an NGG passthrough ES, reads the
3-bit VGT_TF_PARAM fields, refuses its other bits but DISTRIBUTION_MODE,
and needs HOS levels that keep [1, 63]; 0x286-0x287 join the draw key.
Local and domain programs are prepared with their stage group: its
headers are merged over one set of defaults, and a local program left
unbound by the hull header is prepared at its first draw.

The local program ends at its jump into the hull half.
TessellationLowering lowers LDS and ring addresses that are affine in
the control point and relative index to tessellation interfaces with
strides from the code, and refuses accesses outside the patch, per-patch
writes from other control points and a modified primitive export. Hull
lanes read their own saved exec bit, also of host-subgroup-masked
copies; other masks are refused, gl_InvocationID loads as a scalar and
factors clamp to 63.
2026-10-11 11:25:56 +02:00
milescoviello f774e1cd98 fix(agc): keep a fast-clear copy where an import window can stamp watched memory
range is write-watched. Since #2984, Refresh turns a BlockMaybeWritten
unit into BlockUnchanged only through compareUntracked, which needs that
copy. Where a host import leaves its range watched and making it stamps
the imported pages (the probe's writtenAtImport, 4 of 4 on NVIDIA's
Linux driver), the import window stamps the surface, so a pending
fast-cleared image counted as changed again and
agc_driver_dcc_keys_first_write failed on main (#3179).

HostImports now keeps whether making each kind of import stamped the
probe's pages, and WatchedImportsStampPages reports whether an import
that leaves its range watched can stamp it. The clear path skips the
copy only when no such import can, as oneandonlydean proposed in #3179.
Devices whose probe saw no pages written at the import, devices without
host imports and Windows (whose alias imports don't disarm the guest
views) keep #2699's saving.
An unprobed watch (APS5_WRITE_WATCH_IMPORTS=watch) keeps the copy.

The fast-clear check in agc_driver_dcc_keys_first_write now expects the
copy exactly when the range is unwatched or such a stamp is possible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 11:18:04 +02:00
Adrià 5ad2cb8cd0
Merge pull request #1377 from gjonn/fix/agc-unnormalized-base-level-view
fix(agc): sample the base level of mipmapped views with unnormalized coordinates
2026-10-11 11:17:05 +02:00
Adrià 90c152e840
Merge pull request #1333 from TibixDev/pr/descriptor-pool-recycling
perf(agc): recycle descriptor pools after their last set is released
2026-10-11 11:11:24 +02:00
Adrià Franch ac1c3b775b fix(agc): read the base level of a mipmapped view through unnormalized coordinates only where the hardware does
Multi-level views, and views starting above mip 0, are bound as their base
level only when every use of the image is image_sample_lz through an
unnormalized S# without minimum LOD or LOD bias, the case measured exact on
RDNA2. Selected-LOD, implicit-LOD and offset uses keep throwing.

The recompiler records selected-LOD uses (SamplerUseNonZeroLod) and proves
the case per image (imageUnnormalizedBaseLevel); the shader disk cache
format goes to 27.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-11 11:07:25 +02:00
Gjon Gojcevic 0fe4d66b7e fix(agc): sample the base level of mipmapped views with unnormalized coordinates
Vulkan only accepts unnormalized samplers on single-level views, while the
guest binds full mip chains and samples their base level. Bind a lazily
created one-level view of the descriptor's base mip instead of refusing
mipmapped views and views that start above mip 0.
2026-10-11 11:07:25 +02:00
TibixDev 058b7e8f94 fix(agc): support alternate channel order in 16-bit color targets
Map red and blue exports, write masks and constant-color blend factors together. Reject conflicting simultaneous target constants.

Semantics: Mesa 26.2.2 src/amd/common/ac_formats.c ac_translate_colorswap; console equivalence remains unverified. Graphics tests passed. Written with AI assistance.
2026-10-11 10:59:37 +02:00
TibixDev 4e7ca3c760 fix(agc): recycle descriptor pools after their last set is released
Allocate cached sets without individual-free pools. Reset a pool after its
last owner releases it. Keep stable pool indices, skip full pools, and
terminate if reset fails. No GPU wait is added.

This avoids RADV 26.2.2's affected individual-free allocation path.

Validation: Fedora 44 Release graphics tests pass. The reset-failure
regression fails on the previous behavior and passes on this change.
llvmpipe and RX 6600 pass the 3,301-set lifecycle test with core and
synchronization validation. Windows was not tested.

AI-assisted: yes.
2026-10-11 10:54:44 +02:00
Adrià d5477f8402
Merge pull request #2015 from arvindfroi/fix/agc-placeholder-images
fix(agc): typed image heaps on devices without nullDescriptor
2026-10-11 10:48:40 +02:00
Arvind Frøiland 7216621545 fix(agc): typed image heaps on devices without nullDescriptor
The typed descriptor heaps write a null descriptor for a null guest
image, and the device therefore required VK_EXT_robustness2's
nullDescriptor. MoltenVK has the extension but not the feature, so on
macOS no Vulkan device opened and every GPU test was skipped. The
feature is now enabled when the device has it. Without it, the device
creates a placeholder image per typed image heap: 1x1, cleared to zero,
of the heap's dimension, sample count, numeric class and access, and a
null guest image binds the placeholder of its heap. A heap whose
placeholder the device cannot create throws when a null image reaches
it. TechnicalDebt.md lists where a placeholder differs from a null
descriptor.

agc_placeholder_images checks every image resource the recompiler maps
to a heap against that heap's placeholder, so the two cannot drift
apart, and agc_shader_device_profile now expects a device without
nullDescriptor to be accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-11 10:32:49 +02:00
TibixDev 17cc2ce5b4 perf(agc): write draw descriptors from retained CPU metadata
Replace per-draw Vulkan descriptor copies with a single write from retained buffer and image metadata. Keep per-draw guest snapshots, sets and resource ownership unchanged. Baseline RX 6600 profiling attributed 28% of graphics-worker cycles to descriptor copies.

Validation: mixed descriptor and snapshot regression passes on RADV RX 6600 and llvmpipe with Vulkan validation; graphics and guest-memory tests pass. Written with AI assistance.
2026-10-11 10:27:59 +02:00
Michon 56ea14f44c fix(agc): an HTILE fill covers a depth surface only over its whole pipe-aligned metadata
A fill was taken to cover the surface when it spanned ceil(w/8)*ceil(h/8)*4 bytes, a linear HTILE layout. In
the pipe-aligned SW_64KB_Z_X layout a surface's HTILE words lie across a 32 KiB metadata block per 1024x512
pixels (AMD PAL gfx10 addrlib: a 16x16 surface has a valid word at offset 260), so a fill of the linear size
cleared tiles it never wrote. HtileMetadataBytes gives that extent; the fast clear tests fill it (the compute
fixture now dispatches one group per KiB with TGID_X).

Reported with a PAL reproducer by @Amoenus.

Co-Authored-By: Amoenus <5391396+Amoenus@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:19:53 +02:00
Michon 30a0545b21 fix(agc): a depth surface's clears record on its own device
`Recorder::Active()` is process-wide. With two devices (agc_driver_depth_fast_clear_submit draws on its
own device; its compute-fill DCB makes the driver create a second one, whose recorder becomes the
active one) a surface's fast clear was recorded into the other device's command buffer, unordered with
the draw: the compute-fill case failed about once in 60-90 runs. A surface now records into the active
recorder only when that recorder is its own device's, and submits on its own device otherwise.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:19:53 +02:00
Michon c133e23dde fix(agc): depth fast clears through the HTILE metadata
Rebased onto main as one commit (the six commits of #374). A uniform fill over a depth surface's whole
HTILE (DMA_DATA, the fill kernels or a CPU store) clears the depth and stencil aspects its ZMask and
SMem fields say, to DB_DEPTH_CLEAR / DB_STENCIL_CLEAR, when the surface is next bound or sampled.

Main's RADV clear_htile_mask recognition (#2229) now goes through the same pending clear: an HTILE clear
marks the matching surfaces' depth aspect, and one for a surface not created yet is applied when it is
first bound. Main's HTILE address decode and this one are merged into one (TILE_SURFACE_ENABLE, a
nonzero DB_HTILE_DATA_BASE and a depth format).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:19:53 +02:00
Adrià 6170ce820c
Merge pull request #3167 from CnRJay/perf/agc-sparse-heap-mirror
perf(agc): mirror a sparse descriptor heap instead of copying it per dispatch
2026-10-11 10:07:03 +02:00
Adrià 1be0a7ce9b
Merge pull request #3324 from AchrafReyani/carry/host-import-span-windows-alias
fix(agc): import a span's ranges one at a time when Windows refuses its alias
2026-10-11 10:01:20 +02:00
Adrià 5b1c64117d
Merge pull request #3330 from AchrafReyani/carry/agc-ignore-window-offset-enable
fix(agc): ignore the window offset enable bit of the raster mode
2026-10-11 10:00:57 +02:00
Adrià cf0e270a94
Merge pull request #3175 from Raghav314/fix/agc-bda-written-pages
fix(agc): note BDA-written pages at full address width and read back only the claimed ones
2026-10-11 10:00:06 +02:00
Chad 38012ec35c perf(agc): drop a comment the conventions check refuses 2026-10-11 09:55:14 +02:00
Chad b88ad02090 perf(agc): mirror a sparse descriptor heap instead of copying it per dispatch 2026-10-11 09:55:14 +02:00
Adrià c12a19e4de
Merge pull request #3237 from Raghav314/perf/agc-cache-fault-only-resources
perf(agc): cache resources whose only completion work is the fault check
2026-10-11 09:50:44 +02:00
Adrià 2bb78d2c7a
Merge pull request #1825 from TheAggie/feat/agc-ngg-vertex-mesh-v2
feat(agc): run unregistered NGG vertex programs that need a workgroup on the mesh path
2026-10-11 09:35:19 +02:00
Adrià 74a0ba3965
Merge pull request #2479 from NahuelGenchi/fix/agc-alias-one-slice-array
perf(agc): take a 2D storage image's results for a one-slice array on the device
2026-10-11 09:27:06 +02:00
Adrià fbcdf1a804
Merge pull request #2992 from CnRJay/fix/agc-sparse-heap-cut
fix(agc): copy a sparse descriptor heap only up to its last backed byte
2026-10-11 09:24:32 +02:00
Abdulrahman Elkordy aa653ec50e fix(agc): import a span's ranges one at a time when Windows refuses its alias
#3158 imports a run of address-adjacent registered ranges as one span.
On Windows a shared mapping in the span needs a read-write alias, and
MapAlias refuses one unless the range is a single contiguous run of
views of one section. Ranges that are adjacent in guest address can be
separate views, so the refusal escaped from importAllocation and
agc_driver_dcc_keys_first_write failed on main with "read-write alias
of shared guest memory ...: the range is not one contiguous run of
views of a section".

A span whose alias is refused is now remembered, and its ranges are
imported one at a time as before spans; a single range that is refused
still throws.

Claude-Session: https://claude.ai/code/session_012SLQbhAiexxW6TtjYToW8a
2026-10-11 10:24:24 +03:00
raghav314 c0348a02bf fix(agc): note BDA-written pages at full address width and read back only the claimed ones
A shader store through the BDA table records its 4 KiB page in the fault
buffer, and the driver marks those pages written after the use. The page
number was truncated to 32 bits, so a store above 16 TiB marked a page at
another address. And the driver scanned all 4096 slots after every use,
even when nothing was stored.

Slots now hold a 128 KiB chunk (its number plus one, 32 bits for any
address below 512 TiB) and a mask of its 4 KiB pages. A shader that
claims a slot appends it to a list, with a count. The driver reads the
count, decodes only the claimed slots, marks each run of pages once and
clears only those slots. A writable BDA range past 512 TiB is refused
when the table is built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 12:54:02 +05:30
Adrià ccb299cbca
Merge pull request #2756 from TheAggie/feat/agc-radv-vkquake-dispatch
feat(agc): accept the dispatch and indirect packet forms vkQuake's RADV emits
2026-10-11 09:22:58 +02:00
Adrià be8a67db1c
Merge pull request #3228 from GustavoGamarra95/feat/agc-alpha-to-coverage
feat(agc): emulate undithered alpha-to-coverage
2026-10-11 09:22:23 +02:00
Adrià 47c8e19eb7
Merge pull request #1619 from fisherjoey/fix/depth-compare-copy
perf(agc): sample comparison-read R32F/R16 surfaces from a GPU depth copy of their storage image
2026-10-11 09:21:23 +02:00
Adrià df23cab62b
Merge pull request #3211 from Scramblrrrr/codex/recorder-buffer-only-budget-main
fix(agc): enforce the kept-byte budget before buffer-only work
2026-10-11 09:20:12 +02:00
Adrià c757e8eaa7
Merge pull request #3220 from kr4y4/fix/agc-sampler-border-color-class
fix(agc): pick float or integer sampler border colours from the paired images
2026-10-11 09:19:14 +02:00
Adrià 010fad317a
Merge pull request #3194 from XairRrR/feat/agc-8-8-swap-alt-blending
feat(agc-driver): blend into COLOR_8_8 SWAP_ALT targets with a separate alpha equation
2026-10-11 09:17:35 +02:00
raghav314 024cb1feda perf(agc): cache resources whose only completion work is the fault check
A draw or dispatch whose shaders have guarded descriptor slots (or a rect
list) but no BDA table gets a fault buffer, and with it NeedsCompletion(),
which kept its resources out of the resource cache, and NeverReusable
skipped the cache lookup for it. In PPSA36082 nearly every draw in the hub
is such a build, so the cache served none of them.

Such an object has no table to revalidate, no stores through BDA and no
copied writes, so it is now reusable. Each use of a reused object checks
the fault record when its batch completes (CheckFaults) instead of
running the once-only write-back; draw recipes over such a template
register the same check, and dispatch recipes still skip templates with
completion work. NeverReusable now refuses what noteReusable refuses: a
BDA table, or a fault buffer with APS5_LOOP_GUARD set (its fault resets
the buffer).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 09:15:53 +02:00
Adrià 5beb77f0f6
Merge pull request #3231 from Raghav314/perf/agc-pass-fault-only-draws
perf(agc): continue render passes across draws with only a fault buffer
2026-10-11 09:14:20 +02:00
Adrià 6e52fb8f8c
Merge pull request #3158 from XairRrR/perf/agc-host-import-spans
perf(agc-driver): import adjacent registered ranges as one host-import span
2026-10-11 09:14:15 +02:00
Dean ef3d996f39
Merge pull request #3277 from oneandonlydean/carry/alx-stencil-plane-view-reuse
fix(agc): treat other-shaped views of a depth surface's stencil plane as reused memory
2026-10-11 19:08:58 +13:00
Scott Schuster 0e3449129e fix(agc): accept any ES VGPR count for NGG vertex programs on the mesh path
vkQuake's NGG culling vertex shaders load only the vertex ID
(SPI_SHADER_PGM_RSRC2_GS ES_VGPR_COMP_CNT 0), and DecodeShaderStages still
required 3 for a program routed to the mesh path. The merged ES inputs keep
their positions whatever the count, and the mesh entry loads all of them,
so the count is now checked only for real geometry programs, as the GS
VGPR count already was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 07:56:37 +02:00