Commit Graph

153 Commits

Author SHA1 Message Date
Dean 8002d11f67
Merge pull request #1915 from TheAggie/fix/agc-radv-raster-defaults
fix(agc): accept RADV's disabled conservative rasterization and out-of-order watermark
2026-10-10 17:42:34 +13:00
Dean eb283f5c8f
Merge pull request #1914 from TheAggie/feat/agc-force-dst-alpha-one
feat(agc): blend against an opaque destination for CB_COLOR_ATTRIB FORCE_DST_ALPHA_1
2026-10-10 17:42:27 +13:00
Dean 5b6c778a95
Merge pull request #1769 from TideOPL/pr/stride0-raw-range
fix(agc): apply the raw OOB_SELECT range rules to zero-stride vertex buffers
2026-10-10 17:41:11 +13:00
Adrià a9ac7bc4c3
Merge pull request #1580 from Zheorgyan/feat/storage-buffers-update-after-bind
feat(agc): bind storage buffers update-after-bind above the per-stage limit
2026-10-10 03:12:01 +02:00
Adrià 7876b46ff3
Merge pull request #1534 from hamb3r/codex/clearmrt-stencil-clear
fix(agc): preserve ClearMRT color writes and validate stencil clears
2026-10-10 03:09:58 +02:00
Zheorgyan 27e6ad1ad2 feat(agc): bind storage buffers update-after-bind above the per-stage limit 2026-10-10 02:08:15 +02:00
TideOPL 46606e9c73 test(agc): cover depth surface lookups of reused memory
agc_driver_graphics registers a D32 and a D16 surface on a mock device and looks up views at their addresses. Views of the surface's own extent in R32F or R16, and T#s that read the raw depth bits, sample the depth plane; a view of another extent, a 2D array view of another extent, an R11G11B10 view, an R32 uint view without a depth layout and an R32F view of a D16 surface return null and take the ordinary texture path. On main the first of these throws in DepthSurface::Sampled.
2026-10-10 00:44:40 +01:00
Adrià a00165da9e
Merge pull request #1252 from MathiasDevelopes/feat/recompiler-native-f16-rte
feat(recompiler): convert f32 to f16 natively when the device rounds 16-bit floats to nearest even
2026-10-10 00:39:15 +02:00
Adrià fc063cff85
Merge pull request #1074 from alfalfa-star/feat/agc-graphics-int64-atomics
feat(agc): accept 64-bit atomics in graphics shaders when the device enables them
2026-10-10 00:14:56 +02:00
Adrià 2d537f13bb
Merge pull request #1073 from alfalfa-star/feat/agc-uint16-color-export
feat(agc): accept UINT16_ABGR color exports into unsigned integer targets
2026-10-10 00:13:23 +02:00
Dean 2af96d1863
Merge pull request #1085 from Celegans12/fix/agc-host-heap-budget
fix(agc): throw instead of aborting when a heap mirror cannot be made
2026-10-10 08:05:48 +13:00
Celegans12 4709920641 fix(agc): throw instead of aborting when a heap mirror cannot be made
An address-based build whose heap mirror the device refused, or one past
APS5_HEAP_MIRROR_MIB, stopped the process inside acquireMirror. PPSA26344
hit it at 478 s with 6.8 GiB of heap mirrors beside the host imports.

- a mirror that would go past the budget first sweeps the mirrors whose
  registered range is gone, before its allocation; if it still does not
  fit, the build throws "past the budget"
- the mirror is allocated once: a refusal throws with the range, the
  Vulkan result and the mirror totals, so the draw or dispatch fails like
  any other allocation; nothing is registered for the refused range
- the BDA resource tests run with a 4 MiB mirror budget and a mock memory
  limit: a mirror past the budget is made in the swept mirror's memory,
  and a refused one fails after a single allocation attempt
2026-10-09 14:58:20 +02:00
Celegans12 52eb4272de fix(agc): copy an imported range once a merge extends it past its import
An address-based build maps each imported registered range through its
host import. UploadPrepare merges a descriptor range or snapshot
overlapping such a range into the range's region, and the region kept
the import even when the merge took it past the import's end, as a V#
crossing into the next registered range does. Descriptor then bound the
import's buffer beyond its size, and the BDA table mapped the whole
region, the next range included, through the import's device address.

A merge that extends a region past its end now drops the import. The
region then takes the import lookup and, with no import covering it,
the copy path, as a range crossing an image mirror's end already does.
Like every copied range, it is read-only to pointer stores.
2026-10-09 12:11:06 +02:00
Scott Schuster af9e60b690 fix(agc): accept RADV's point and line depth bias enable on triangle draws
With depth bias enabled, RADV sets POLY_OFFSET_PARA_ENABLE in
PA_SU_SC_MODE_CNTL next to the front and back enables, whatever the
topology; vkQuake's draws carry 0x3a46. The bit applies the offset to
points and lines, so it changes nothing for triangles, and Vulkan applies
depth bias only to polygons. It is now accepted with depth bias on
triangle topologies; point and line draws with it are still rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 00:54:22 -05:00
Scott Schuster 88cc2ea477 fix(agc): accept RADV's disabled conservative rasterization state
With conservative rasterization disabled, RADV programs
PA_SC_CONSERVATIVE_RASTERIZATION_CNTL to NULL_SQUAD_AA_MASK_ENABLE alone,
where libSceAgc writes the two INNER_TO_NORMAL overrides (0x6000). A value
made of only those bits now decodes as disabled; overestimation (0x6001) keeps
its checks, and every other mode is still rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 18:24:47 -05:00
Scott Schuster 6c5b181b68 fix(agc): accept PA_SC_MODE_CNTL_1's out-of-order watermark
RADV sets OUT_OF_ORDER_WATER_MARK to 7 on every GFX10 draw, also when
OUT_OF_ORDER_PRIMITIVE_ENABLE is off. The watermark only tunes out-of-order
rasterization, which stays rejected, so the field is accepted alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 18:24:47 -05:00
Scott Schuster 1e20b4ec50 feat(agc): blend against an opaque destination for CB_COLOR_ATTRIB FORCE_DST_ALPHA_1
FORCE_DST_ALPHA_1 makes blending read a target's destination alpha as 1, as
for an RGBX surface; RADV sets it for formats without alpha. The target's
blend factors are rewritten to what they become with Ad = 1: DST_ALPHA is
ONE and ONE_MINUS_DST_ALPHA is ZERO, SRC_ALPHA_SATURATE is ZERO in the color
equation, and DST_COLOR and ONE_MINUS_DST_COLOR are ONE and ZERO in the
alpha equation. Other CB_COLOR_ATTRIB bits stay rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 18:24:46 -05:00
TideOPL c17c5ebd4d fix(agc): apply the raw OOB_SELECT range rules to zero-stride vertex buffers
With stride 0, OOB_SELECT 2 puts a fetch out of range only when NUM_RECORDS
is 0, and OOB_SELECT 3 only when the offset is not below NUM_RECORDS (GFX10
table in Mesa ac_descriptors.c). A one-record descriptor therefore returns
its whole element: Unreal's per-draw PrimitiveId stream is such a descriptor,
and refusing it skipped the draw. A wholly out-of-range fetch reads a zero
buffer.
2026-10-08 19:46:22 +01:00
Celegans12 97b9439d4f perf(agc): size the storage and sampled texture caches to the device
The storage image and sampled texture caches each let go of their least
recently used entries past a fixed 2 GiB, and a sampled view of a
storage image counted that image a second time.

The storage image cache keeps a quarter of the largest device-local
heap, at least the 2 GiB of before (TextureCacheBudget). The sampled
cache gets what VK_EXT_memory_budget leaves on that heap after the
memory in use outside sampled textures and cached storage images, the
storage cache's budget and an eighth of the heap budget, read at most
once a second and at least 2 GiB; without the extension it keeps the
storage cache's rule. A snapshot counts its image allocation, a texture
still bound after leaving the cache counts as sampled memory, and a
change of more than 10% is logged at most every 10 s. A nonzero
APS5_TEXTURE_CACHE_MIB sets both budgets; a view of a cached storage
image counts nothing and leaves the cache when its image does.
2026-10-08 20:24:03 +02:00
alfalfa-star a2b049d455 feat(agc): accept 64-bit atomics in graphics shaders when the device enables them
The recompiler emits OpCapability Int64Atomics for 64-bit buffer atomics
in any stage, and the device enables shaderBufferInt64Atomics when it
has it, but graphics shader validation only accepted its fixed list of
capabilities, so every draw whose shaders use one was rejected with
"SPIR-V requires unsupported device capability 12". Compute dispatches
are not validated this way and already ran them.

The device records the feature (bufferInt64Atomics in the device state
and the graphics Context) and ValidateShaders accepts Int64Atomics when
it is enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 20:16:01 +02:00
alfalfa-star 45541350bb feat(agc): accept UINT16_ABGR color exports into unsigned integer targets
SPI_SHADER_COL_FORMAT 7 (UINT16_ABGR) was rejected by DecodeState,
though the recompiler already handles it: a pixel shader's MRT output
under mode 7 is a uvec4, and a compressed export's 16-bit halves are
taken with OpBitFieldUExtract. The format is now accepted when the
target's CB_COLOR_INFO number type is UINT; into any other target it
still throws, as does SINT16_ABGR (8), whose halves would need sign
extension.

The target records the export (ColorTarget::uintExport). Shader
validation then requires a uint4 output at its location instead of a
float4 one, and blending into it is refused (Vulkan has no blending of
integer attachments).

PPSA14632 (LEGO Horizon Adventures) writes a 2848x1600 R8_UINT target
this way; those draws were dropped.

agc_driver_pixel_uint16_export draws compressed MRT0 exports under mode
7 into a linear 16_16_16_16 UINT target, one row per pair of packed
words (0x0000ffff/0xffff0000, 0x00010002/0xffffffff and four distinct
halves), and reads every 16-bit component back under the identity,
STD_REV and ALT_REV export mappings. agc_driver_graphics covers the
decode and the blend refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 18:46:09 +02:00
boykopovar 6741e90a1c fix(shader): restore prepared image compatibility and update regression fixtures 2026-10-08 18:32:12 +03:00
boykopovar 1b3da3a740 test(agc): update graphics binding and bda range checks 2026-10-08 17:37:40 +03:00
boykopovar 05fa426112 perf(shader): eliminate prepared-path overhead in data, descriptors, dispatch, bda 2026-10-08 17:29:17 +03:00
boykopovar dccfa08de9 feat(shader): add fixed runtime abi + typed descriptor heaps 2026-10-08 17:26:04 +03:00
Celegans12 1816aea91c fix(agc): store and read DCC keys over the console's metadata extent
The console's DCC of a single-level 4-byte SW_64KB_R_X surface is
ceil(W/512) * ceil(H/512) * 4096 bytes, 49152 for 1920x1080, but the
driver stored and read one key per 256 surface bytes (34560).
PPSA26344 retiles its render DCC into the displayable copy it
registers (cs_dcc_retile_32bpp); a retile of the stale tail gives the
mixed keys PPSA12544 stops on.

DccKeyCount gives that extent. Color target and storage image key
stores cover it when the DCC is pipe-aligned (CB_COLOR_ATTRIB3 bit 30,
T# word 6 bit 19), whose CB keys reach its last meta block, and throw
where it is not writable; unaligned DCC keeps one key per 256 bytes,
as do texture and color target key reads. DisplayBufferKeys reads the
display DCC over the extent, presents only when every key agrees,
names the first differing key's pixels and checks a pending image
against those keys.
2026-10-08 15:24:43 +02:00
Adrià fd5342b6d6
Merge pull request #1425 from gjonn/fix/agc-reversed-rgba8-color-targets
fix(agc): render 8_8_8_8 and 16_16_16_16 color targets with reversed component orders
2026-10-08 15:18:26 +02:00
Scott Schuster 550920a1fd fix(agc): render CB_COLOR_CONTROL mode disable as a draw without color
Mode 0 of CB_COLOR_CONTROL turns color writes off, but a draw with a
written color target and this mode was skipped as unsupported. Count no
export as written when the mode is disable, so the draw renders without
a color attachment like the existing attachment-free path, and accept
the mode with any ROP3, which does not apply while writes are off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 15:13:08 +02:00
Adrià ede7ead473
Merge pull request #1419 from TheAggie/fix/agc-accept-tuning-fields
fix(agc): accept RB and primitive-group tuning fields
2026-10-08 15:12:33 +02:00
MathiasDevelopes 8685c14d16
feat(recompiler): convert f32 to f16 natively when the device rounds 16-bit floats to nearest even
The integer emulation of the round-to-nearest-even float-to-half
conversion is exact but costly: a compute shader with about 3600
conversions never finished compiling on NVIDIA. When the device enables
shaderFloat16 and guarantees shaderRoundingModeRTEFloat16,
shaderDenormPreserveFloat16 and shaderSignedZeroInfNanPreserveFloat16,
it advertises Float16, RoundingModeRTE and DenormPreserve, and the
recompiler emits OpFConvert under the 16-bit RoundingModeRTE,
DenormPreserve and SignedZeroInfNanPreserve execution modes instead.
NaNs keep the emulated quiet NaN with the high payload bits. Devices
without these guarantees keep the emulation.

Graphics validation accepts the RoundingModeRTE, DenormPreserve and
SignedZeroInfNanPreserve execution modes for 16-, 32- and 64-bit floats,
so vertex and pixel shaders with a native conversion still draw.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 12:51:07 +00:00
Adrià 07c2405c35
Merge pull request #1371 from TibixDev/pr/depth-maintenance-precheck
fix(agc): reject depth maintenance before shader compilation
2026-10-08 14:37:01 +02:00
Adrià 0b3cc73e1c
Merge pull request #1112 from Celegans12/feat/agc-conservative-rasterization
feat(agc): implement overestimating conservative rasterization
2026-10-08 14:31:38 +02:00
Adrià d393c3e754
Merge pull request #1346 from TibixDev/pr/disabled-color-targets
fix(agc): honor disabled color targets and their reset state
2026-10-08 13:36:03 +02:00
Adrià a983fb5df5
Merge pull request #1348 from TibixDev/pr/null-pixel-input-state
fix(agc): ignore stale input state for null pixel shaders
2026-10-08 13:29:44 +02:00
Celegans12 29c22442dc feat(agc): implement overestimating conservative rasterization
A draw whose PA_SC_CONSERVATIVE_RASTERIZATION_CNTL (context 0x313) was
not the default 0x6000 threw in DecodeState and the draw precheck.
0x6001 sets OVER_RAST_ENABLE and now decodes to Vulkan's overestimation
mode, chained to the pipeline's rasterization state and its key.

The device enables VK_EXT_conservative_rasterization only when its
primitiveOverestimationSize is at most 1/256 pixel and it rasterizes
degenerate triangles; elsewhere the pipeline throws. Overestimation is
accepted only when triangles reach the rasterizer: VGT_GS_OUT_PRIM_TYPE
behind a geometry shader, VGT_TF_PARAM's output topology behind
tessellation, VGT_PRIMITIVE_TYPE otherwise. Other 0x313 values and
centroid interpolation still throw.

Adds the agc_driver_conservative_rasterization GPU test and extends
agc_driver_graphics.
2026-10-08 13:20:22 +02:00
hamb3r 8ed4ff55b5 fix(agc): validate stencil clear before decoding stencil operations 2026-10-08 14:16:10 +03:00
Aryan Sharma 72e8d502f9 fix(agc): draw with DB_RENDER_CONTROL STENCIL_CLEAR_ENABLE
A draw that sets STENCIL_CLEAR_ENABLE was rejected as a whole, so its
color output was lost as well. The draw is now rasterized with every
covered sample's stencil replaced by DB_STENCIL_CLEAR, whatever the
stencil and depth tests are, and its color outputs are written as usual.
The depth/stencil state is decoded for such a draw even when
DB_DEPTH_CONTROL enables no test. Depth clear, copy, resummarize and
decompress draws are still rejected.
2026-10-08 14:16:10 +03:00
Adrià b1c5f10df8
Merge pull request #1319 from TibixDev/pr/allocation-lease-deadlock
fix(memory): release the registry lock while waiting for a lease
2026-10-08 13:08:46 +02:00
Celegans12 9513703244 fix(shader): read the half-wave scans of wave64 reductions on any host subgroup
The GFX10 lowering of a wave64 reduction scans rows with DPP row_shr
1/2/4/8 and v_permlanex16_b32 under EXEC -1, then joins lanes 31 and 63
with a scalar op. The console fills lanes outside the entry EXEC with
the identity, but on the host they can be helpers that sit out subgroup
operations or invocations that were never launched: on 64 lanes (RADV)
the emulated chain reads 0 or stale values from them, and on 32 lanes
lane 63 throws since #997.

EmitReadLane now recognises the sequence on any host for UMin, UMax,
SMin, SMax, IAdd, AND and OR when the keys are the identity outside the
entry EXEC. On 64 lanes, lanes 31 and 63 become subgroup reductions of
the keys of invocations 0-31 and 32-63; on 32 lanes or fewer, lane 31
reduces all keys and lane 63 is the identity. It throws without
subgroup arithmetic or on a subgroup wider than the wave. VulkanDevice
reports GroupNonUniformArithmetic and ShaderValidation checks it.
2026-10-08 12:10:32 +02:00
Adrià 30e89cc6a0
Merge pull request #1266 from Celegans12/fix/agc-oversized-descriptor-sets
fix(agc): allocate oversized descriptor sets from a dedicated pool
2026-10-08 12:09:59 +02:00
Celegans12 e1d4e699be feat(agc): implement primitive-ordered pixel shaders with fragment shader interlock
DecodeState and the draw precheck rejected DB_SHADER_CONTROL bit 16,
PRIMITIVE_ORDERED_PIXEL_SHADER (POPS), which runs the ordered section
of overlapping pixels' shaders in primitive order. The bit now reaches
the recompiler as a pixel stage field, and such a pixel shader declares
PixelInterlockOrderedEXT and runs its whole body between
OpBeginInvocationInterlockEXT and OpEndInvocationInterlockEXT; an
invocation that a BDA read fault kills ends the interlock first. The
POPS collision SGPRs read 0, so a title skips its POPS wait and runs
its per-collision loop once. An image_load still reads a sampled
binding, which misses an earlier overlapping primitive's image_store in
the same draw. The device enables VK_EXT_fragment_shader_interlock when
it has fragmentShaderPixelInterlock; without it the recompile throws,
as does a nonzero POPS_OVERLAP_NUM_SAMPLES. The field is part of the
recompile cache key, the draw key and the serialized request (version 10).
2026-10-08 11:18:46 +02:00
TibixDev 09b419e8cc fix(agc): ignore stale input state for null pixel shaders
Use the synthetic shader input and export state when selecting the null pixel program. Keep ordinary shader validation unchanged. Written with AI assistance.
2026-10-08 11:23:09 +03:00
Michon 20e055c244 feat(agc): compute dispatches with scratch memory
A compute program with COMPUTE_PGM_RSRC2.SCRATCH_EN takes its per-lane private size from the AGC
shader header (scratch_size_dw_per_thread) instead of being refused. The size travels in
ShaderComputeStageInfo (cache key, request serialization version 10) to the translator, whose
scratch accesses already lower to a per-invocation Function array of that many dwords.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 10:22:40 +02:00
Adrià e705d430d6
Merge pull request #1139 from alfalfa-star/fix/agc-inert-pixel-stage
fix(agc): run draws whose pixel stage cannot run without its program
2026-10-08 10:20:09 +02:00
Adrià 8e22498c20
Merge pull request #1134 from alfalfa-star/fix/agc-mesh-unindexed-index-vsharp
fix(agc): bind a null index buffer to non-indexed mesh draws
2026-10-08 10:15:09 +02:00
TibixDev 1841f3c6e7 fix(agc): honor disabled color-buffer formats
Exclude COLOR_INVALID attachments from the effective write mask while preserving later MRT export indices and depth-only rendering. Validated with the graphics tests and Skyrim menu draws.

AI-assisted implementation and testing by OpenAI Codex.
2026-10-08 10:22:13 +03:00
Chad c17337b6d9 fix(agc): size CMASK by whole 1024x512 metablocks
A CMASK holds 4 KiB per 1024x512-pixel metablock, not one nibble per 8x8
tile of the target: 1920x1080 spans 0x6000 bytes, as titles clear it,
not 16200. The swizzled nibbles of the lower-right tiles lie past the
packed size, so the fast-clear check missed them and the expanded store
left them cleared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 19:53:02 +13:00
Adrià 56f3da20e8
Merge pull request #1072 from alfalfa-star/feat/agc-cmask-fast-clear
feat(agc): render into CMASK fast-clear color targets
2026-10-08 08:32:04 +02:00
Adrià e9fecced17
Merge pull request #1086 from Celegans12/fix/agc-depth-bias-clamp-default
fix(agc): include PA_SU_POLY_OFFSET_CLAMP in the initial context state
2026-10-08 08:06:30 +02:00
alfalfa-star b5be685912 feat(agc): accept CMASK fast-clear DCC targets whose CMASK is expanded
A color target with both DCC and CB_COLOR_INFO.FAST_CLEAR keeps its fast
clear in the DCC keys and fills its CMASK with 0xF (expanded), as radv
does (radv_get_cmask_fast_clear_value) and as PPSA21567 does
(CB_COLOR_INFO 0x10042730, reported on #419). Such targets now decode;
their clear is materialized by the existing DCC path. A DCC target's
CMASK that is not all expanded throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 07:58:40 +02:00