Commit Graph

960 Commits

Author SHA1 Message Date
Adrià e783f19bc1
Merge pull request #3441 from MarcZX100/codex/fold-unordered-infinity-compares-3355
fix(recompiler): fold true unordered comparisons against f32 infinity
2026-10-11 13:55:17 +02:00
Adrià 6f7a12b0ee
Merge pull request #3472 from oneandonlydean/up4/fix-bda-note-write-nvidia-hang
fix(shader): set a BDA-written page's bit inside the slot probe loop
2026-10-11 13:51:42 +02:00
Adrià e5d4f59dac
Merge pull request #3438 from ivica00/fix/srgb-bilinear-cube-compare
fix(shader): return 0 for 8-bit sRGB color comparison
2026-10-11 13:43:27 +02:00
Dean Galvin e7b4c05549 fix(shader): set a BDA-written page's bit inside the slot probe loop
note_bda_write loaded the chunk's page mask and set the page's bit after the probe loop, through a function variable holding the slot. NVIDIA 610.57.04 (Linux) never finishes a dispatch that takes that path: agc_driver_bda_device and agc_driver_flat_apertures_0, _2, _3, _4, _5 lose the device. The same load and conditional OpAtomicOr now run in the loop body, on the iteration that finds or claims the slot.
2026-10-11 23:50:11 +13:00
Adrià 9a9bd3fb3c
Merge pull request #2369 from karanvora2599/perf/shader-coherent-alias
perf(shader): load from buffers without Coherent when the load has no GLC or DLC
2026-10-11 12:47:46 +02:00
ivica00 cb52ca10c9 fix(shader): return 0 from 8-bit sRGB color comparison
image_sample_c_lz on gfx1035 returns 0 for 8-bit sRGB, so the unorm clamp was the wrong result. Bilinear cube comparison without DISABLE_CUBE_WRAP keeps throwing because that filter blends across faces.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 12:44:53 +02:00
MarcZX100 85b60b65d1 fix(recompiler): fold unordered infinity comparisons 2026-10-11 10:40:37 +00:00
ivica00 fc7446590a fix(shader): compare sRGB colors and bilinear cube faces
Subnautica Below Zero stops while compiling a menu shader that compares an sRGB color texture or a bilinear cube face. sRGB uses the unorm reference clamp, and a bilinear cube sample stays on the face it hits.

Written with AI assistance.
2026-10-11 12:32:28 +02:00
Adrià e7827eb4d4
Merge pull request #3416 from AchrafReyani/fix/nodiscard-warnings
fix(shader): discard two nodiscard results explicitly
2026-10-11 12:16:54 +02:00
Adrià a7d80e7413
Merge pull request #2410 from karanvora2599/perf/shader-pack-conversions-f32
perf(shader): round v_cvt_pknorm and v_cvt_pk_u8 in f32
2026-10-11 12:16:07 +02:00
Adrià 3bf63fadce
Merge pull request #3401 from AchrafReyani/carry/pipodi-3350
fix(recompiler): split descriptor webs selected per lane
2026-10-11 12:08:57 +02:00
Adrià 6cee0bb02a
Merge pull request #3400 from AchrafReyani/carry/pipodi-3349
fix(recompiler): evaluate an out-of-range constant buffer read as zero
2026-10-11 12:08:15 +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
Achraf Reyani 30a3cbea7d fix(shader): discard two nodiscard results explicitly
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 18:45:44 +09:00
Alex Collini f3e654a4f5 fix(recompiler): split descriptor webs selected per lane
A T# picked per lane with SelectU32 and made uniform with
v_readfirstlane, as in a waterfall loop, left a descriptor web without
Phis that the web walk could not split. CollectDescriptorPhis now steps
through ReadFirstLane, and a Phi-free tuple containing SelectU32 or
ReadFirstLane is split on the shared condition (SelectU32) or wrapped in
a matching ReadFirstLane. The new nodes are placed after the last
original node of the tuple in its block and inserted only when the web
is split; otherwise they are invalidated like the web's Phis.

PPSA26344 compute shader 0x800037f200 selects its T# per lane between
SRT reads or zero and reads the first lane of the result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 18:42:56 +09:00
Alex Collini 5a9d731540 fix(recompiler): evaluate an out-of-range constant buffer read as zero
s_buffer_load returns zero for dwords outside the V#'s range. The SRT
evaluator refused such a read instead, so evaluating a descriptor failed
as soon as one arm of a split T# read through a null or short V#, even
when that arm is never taken. The evaluator now returns zero for those
reads, as the hardware does.

PPSA26344 compute shader 0x800037f200 reads one arm's T# through a null
V# and stopped at "SrtWalker::EvaluateRuntimeSources failed to evaluate
runtime sources".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 18:42:47 +09:00
Adrià Franch a898efdb41 fix(shader): index hull control-point inputs with constant slots
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-11 11:25:56 +02: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
Alex d809958b27 fix(shader): fold BitReverse32 of an immediate
A descriptor dword built by S_BREV_B32, V_BFREV_B32 or S_BREV_B64 from a
constant stayed a runtime value, so the resource could not be resolved
and the shader failed to prepare. The constant folder now reverses the
bits of an immediate the way the hardware does (D[31-i] = S0[i]), like
the existing BitCount32 fold. ConstantBitTest covers the fold.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-11 05:23:40 -04:00
Adrià 4c9686fe2e
Merge pull request #1388 from gjonn/feat/agc-color-compare-constant-swizzle
feat(agc): color compare through a view whose X channel is constant
2026-10-11 11:21:17 +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à Franch a0e03ab48d fix(agc): write a color compare's channels to their own registers 2026-10-11 11:10:41 +02:00
Adrià Franch 6ac5cad133 fix(agc): compare the red channel of a swizzled view 2026-10-11 11:10:41 +02:00
Gjon Gojcevic d32a7881f0 feat(agc): apply the view's channel selects to a color compare
Comparison sampling of a color texture required the view's X channel to select red. A title runs image_sample_c_lz on a 1x1 R8 unorm placeholder whose dst_sel is constant 0 on all four channels.

On hardware the compare result is placed in every channel and each returned channel then applies its own dst_sel: 0 gives 0, 1 gives 1, R/G/B/A give the compare result. Return each dmask register from its own select, and throw only for the reserved selects 2 and 3.
2026-10-11 11:10:41 +02:00
Adrià Franch 60a14b5be6 fix(recompiler): bind a 2D texture to a 1D image access
A 1D sample or load of a 2D T# had no runtime image mode after the mode table landed, so it was still refused at materialization. Sampled 1D accesses now also accept a 2D view; the address completion in the emitter reads the missing row as 0.
2026-10-11 11:07:41 +02:00
Gjon Gojcevic 8f44aa656a fix(recompiler): read sampled image address components the instruction omits as 0
Measured on hardware: a position component the instruction omits reads as 0, like an explicit 0, and the next VGPR is ignored. Missing array layers and derivative components are 0 too. Cube coordinates still need all components.
2026-10-11 11:07:41 +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
Karan Vora 17267336af fix(shader): get the pknorm tie error from exact subtractions
normF32 took the error of p = |x| * scale from fma(|x|, scale, -p).
Vulkan only guarantees GLSL Fma on f32 the precision of a multiply
followed by an add, and lavapipe in Mesa 25.2.8 splits it, so the error
was 0 there and products that round to k + 0.5 were resolved by
roundEven: v_cvt_pknorm_u16_f32 of 0x37c000c0 gave 0x00020002 instead of
0x00010001.

scale + 1 is a power of two, so A = |x| * (scale + 1) is exact and the
product is A - |x|. Since A >= |x|, p = A - |x| and the error
(A - p) - |x| are computed with correctly rounded subtractions only
(Fast2Sum), which every driver gives exactly.
2026-10-11 05:03:58 -04:00
Karan Vora 2069fd1262 Merge remote-tracking branch 'origin/main' into perf/shader-coherent-alias 2026-10-11 04:57:31 -04:00
Karan Vora 8d0a0504ae Merge remote-tracking branch 'origin/main' into perf/shader-pack-conversions-f32 2026-10-11 04:57:04 -04:00
Adrià 1c75f4d228
Merge pull request #3357 from AchrafReyani/fix/spirv-unordered-compare-nvidia
fix(shader): emit unordered f32 relations as negated ordered ones
2026-10-11 10:52:35 +02:00
Adrià f6b421b73c
Merge pull request #3040 from CouchRiv/fix-shader-ldexp-f16-denorm-flush
fix(shader): flush v_ldexp_f16 denormals per the f16 denormal mode
2026-10-11 10:48:14 +02:00
Adrià 4154f0d765
Merge pull request #2411 from karanvora2599/perf/shader-pkrtz-native-rte
perf(shader): convert v_cvt_pkrtz_f16_f32 from the native nearest-even conversion
2026-10-11 10:41:08 +02:00
Adrià 903417e238
Merge pull request #2428 from karanvora2599/perf/shader-dot2-f32-fast-path
perf(shader): compute v_dot2_f32_f16 in f32 outside the special cases
2026-10-11 10:40:42 +02:00
Achraf Reyani 97ee575d6c fix(shader): emit unordered f32 relations as negated ordered ones
NVIDIA's Vulkan compiler (driver 616.92) aborts while building a pipeline
whose OpFUnordLessThanEqual or OpFUnordGreaterThanEqual compares against
+infinity. The negated inverse ordered relation gives the same result for
every input, NaN included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 17:32:47 +09:00
Adrià 04ab4a86cd
Merge pull request #921 from 011010/feat/cmake-use-system-deps
build: add ANYPS5_USE_SYSTEM_DEPS option
2026-10-11 10:30:35 +02:00
Adrià 7028457e31
Merge pull request #2259 from TheAggie/fix/shader-coherent-bda-atomic-loads
fix(shader): read GLC/DLC BDA dwords with device-scope atomic loads
2026-10-11 10:26:29 +02:00
Alex 63b2bcb354 fix(shader): flush v_ldexp_f16 denormals per the f16 denormal mode
v_ldexp_f16 ignored the FLOAT_MODE denorm16 flush bits on main. Flush a
denormal half input when bit 0 is clear. When bit 1 is clear, flush the
result when its exact value is below the minimum normal half, decided
on the f32 product before the half conversion rounds it: 0x07ff scaled
by 2^-1 is zero on RDNA2, not the minimum normal. NaN handling and
destination high-half preservation stay the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 04:24:00 -04:00
Adrià bbd7157150
Merge pull request #822 from Celegans12/feat/agc-unnormalized-sampler-offsets
feat(agc): accept texel offsets with unnormalized sampler coordinates
2026-10-11 10:23:33 +02:00
husari.orozco 6ad5c61f1a build: route system dependency include paths and pin the shader cache to package versions 2026-10-11 10:18:23 +02:00
husari.orozco 96ad950914 build: add ANYPS5_USE_SYSTEM_DEPS option
Resolve SDL2, freetype, Vulkan-Headers, SPIRV-Headers, glslang and
SPIRV-Tools from the system instead of the bundled submodules when the
option is ON. It is OFF by default, so the bundled build is unchanged.

Every package is required: a missing one, or Vulkan-Headers older than
1.4.310 (the agc driver uses VK_KHR_maintenance8), fails the configure
with an error and nothing falls back to the submodule. The system
packages are exposed under the same target names the bundled path uses,
so the rest of the CMake is untouched.

SDL2 is linked from the system as a shared library because the prx
libraries are shared objects and distribution static SDL2 is usually not
PIC. ffmpeg-core, libjpeg-turbo, stb, VulkanMemoryAllocator and LibAtrac9
stay bundled.
2026-10-11 10:18:10 +02:00
Adrià 05c870cc05
Merge pull request #2408 from karanvora2599/perf/shader-compare-constant-flush
perf(shader): fold the denormal flush into f32 compares against constants
2026-10-11 10:14:42 +02:00
Adrià df09e33759
Merge pull request #2407 from karanvora2599/perf/shader-float-to-int-once
perf(shader): saturate f32 to integer conversions once
2026-10-11 10:14:22 +02:00
Celegans12 d0d127b17d feat(agc): accept texel offsets with unnormalized sampler coordinates
Explicit-LOD offset samples through FORCE_UNNORMALIZED samplers now add
sign-extended texel offsets to f32 coordinates before clamping, using
OpFAdd with NoContraction and a sampler specialization selector.

Without native nonconstant-offset support, retain only runtime image
modes valid for unnormalized sampling and reject normalized samplers.
Preserve constant-swizzle handling, indirect-image rejection and main's
flat-volume and flat-line compatibility rules when selecting those modes.

Serialize image compatibility and folding flags and the sampler folding
flag in cache format 34, with roundtrip, preparation and execution coverage.
Retain main's request format 15 and runtime ABI 11.
2026-10-11 10:08:25 +02:00
Adrià f60923bf50
Merge pull request #3294 from kr4y4/feat/shader-compute-user-data-calls
feat(shader): link compute shaders' user-data callees at dispatch
2026-10-11 10:07:22 +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
krishnaraya 6d9321fc57 feat(shader): link compute shaders' user-data callees at dispatch
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 09:59:27 +02:00
Scott Schuster 73e0890c20 fix(shader): read GLC/DLC BDA dwords with device-scope atomic loads
Coherent (GLC/DLC) global loads were emitted as Volatile loads through
physical pointers. Volatile does not make another workgroup's stores
visible within the same dispatch, so a workgroup spinning on a flag
written by another one (decoupled look-back scans, as in RADV's
acceleration-structure build) never saw it on NVIDIA. Aligned coherent
dword reads now use OpAtomicLoad at device scope; the byte path keeps
the old reads for unaligned addresses.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 02:41:19 -05:00
Adrià 92bc441279
Merge pull request #3306 from CouchRiv/fix-shader-ldexp-f32-denorm-keep
fix(shader): keep f32 subnormals in v_ldexp_f32 when denormals are kept
2026-10-11 09:28:17 +02: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