Skip to content

Latest commit

 

History

History
549 lines (488 loc) · 408 KB

design.md

File metadata and controls

549 lines (488 loc) · 408 KB

Design notes

Groundwork for running the Xbox Series build of GTA VI natively on Windows. The work that does not need the executable is in place; booting can start as soon as game_scarlett_master.exe is available.

Ground rules

  • Everything here runs from your own copy and stays on your PC. Game files, generated code, shader caches and reports that quote game data are never committed, uploaded or shared. reports/ is git-ignored for this reason.
  • Nothing in this folder decrypts, unpacks or works around Xbox package protection. The tools only read files that are already plain on disk.
  • The store keeps the game as one packaged container (.xvc): an XVD file whose contents are encrypted, so the build can't use it and needs the folder that holds MicrosoftGame.Config. Given one as --game, finding one with --find, or finding one alone in the folder given, make_game.py reads only its plain 4 KiB header to say what it is instead of "not found". Fields read, at file offsets (xvdtool's XvdHeader + 0x200 for the signature in front of it), checked on one 1.0.2.1 package: msft-xvd magic at 0x200; VolumeFlags at 0x208 (0x41, ReadOnly and RegionIdInXts; EncryptionDisabled 0x2 is clear); ContentType at 0x284 (1, Title); XvcDataLength at 0x290 (non-zero for an XVC); PackageVersion at 0x3BC, four u16 stored lowest part first (1, 2, 0, 1 is 1.0.2.1). No key field is read.

Why a loader before a recompiler

The Xbox Series CPU is x86-64, the same as a PC. Unlike Hookshot, where ARM64 code has to be translated, most of the game's code can run as-is. The work is everything around it:

Layer Approach Folder
CPU code Map the PE image and run it natively. Patch only what can't run on desktop (privileged instructions, console-only intrinsics). Each mapped image's .pdata is checked (in bounds, sorted, non-overlapping; zero-length entries allowed, as in System32's symcryptk.dll) and registered with RtlAddFunctionTable, so SEH/C++ exceptions and stack walks unwind through its frames; the host MSVC runtime's RtlPcToFileHeader import is redirected so an MSVC throw in a mapped image finds its image base. The loader installs static TLS for the calling thread and, through gta6rt_tls_host.dll's thread events, for every thread started after the image was loaded. runtime/src
Imports (GameOS / GDK / Xbox DLLs) Every imported dll!function goes to a shim. Unimplemented ones log once and return a failure, so the missing surface shows up at runtime. runtime/shims
Graphics Xbox D3D12 (d3d12_xs) to Vulkan. Shaders ship as compiled RDNA2 machine code; tools\rdna2spirv.py translates all 26,503 to SPIR-V. The D3D12 layer is still to do. tools\ (translator), later (D3D12)
Assets .rpf archives (RPF9) read through the runtime's file layer. later

Layout

tools/       Python analysis tools (no game data inside)
  pe_inspect.py   PE headers, sections, entropy, imports sorted by where they resolve, .pdata, TLS
  rpf_probe.py    RPF header survey of a game folder
  manifest.py     SHA-256 manifest of a game folder (create), plus a verify subcommand
  manifest.py     SHA-256 manifest of a game folder, plus a --verify mode
  inline_scan.py  inline command-list writes in an image, and whether each checks the cursor limit first
scripts/
  first_look.ps1  run once the exe arrives: the full report set for it
runtime/     C++ native loader (CMake + Ninja, MSVC)
  src/            PE mapper, relocations, import binding, TLS
  shims/          per-DLL shim tables
reports/     generated output (git-ignored)
docs/        notes

Day one, when the exe is here

.\scripts\first_look.ps1 -Exe "<game>\game_scarlett_master.exe"

This writes reports/exe/ (JSON plus a readable summary). Check it in this order:

  1. Section entropy. Sections near 8.0 bits/byte are still encrypted or compressed. If .text is one of them, nothing else can be done yet.
  2. Import table. Each DLL is marked bundled (in the game folder), system (present on this Windows), or shim (needs a reimplementation). The shim list is the real to-do list.
  3. .pdata function count. This gives function boundaries for patching and later analysis.
  4. Inline command-list writes. python -I tools/inline_scan.py <game>\game_scarlett_master.exe --sites (a few minutes; it streams dumpbin /disasm). "UNCHECKED 0" means every inline write checks the cursor limit, so a layer that keeps the cursor at the limit receives every command through the vtable; any unchecked site is a write that layer never sees. The package's DLLs check at every site (d3d12_command_objects.md, "Every inline write in the package's DLLs checks first").

Then runtime\build\gta6rt.exe --dry-run <exe> maps the image and binds every import to the shim table without running any game code. It reports what it couldn't bind.

Reproduce the shader tests

Build the hand-written tests where LLVM supports AMDGPU and SPIRV-Tools is available. Run the generated shaders with the Vulkan test tools on the target GPU. Use the same output folder in both commands.

python -I runtime/test/shaders/build.py <out>
python -I runtime/test/shaders/check.py <out> [runtime-build-directory]

The wave-mask fixture checks every lane and the wave64 ballot fixture checks mask counts and first-set lanes across both halves of a wave. Rebuild vk_compute_test before running check.py. It uses a full 64-wide compute subgroup for these two checks, and the summary reports them as skipped if the device cannot provide one. cs_exec64 still checks per-lane EXEC writes on 32-wide subgroups. With LEONIDA_W64_EMULATE=1 in the environment of both commands, build.py translates with --wave64-emulate and check.py runs every wave64 check without asking for a 64-wide subgroup, so a 32-wide GPU runs them all (scripts/run_gpu_tests.py honours the same variable). Pick one of several GPUs with the Vulkan loader, e.g. VK_LOADER_DRIVERS_SELECT='*nv*' or '*amd*'. The flat-input fixture checks both integer IDs and interpolated UVs. The corpus comparison is a separate test and uses shader files from the local build.

On macOS the test tools default to MoltenVK. To test another Vulkan driver, set LEONIDA_VULKAN_LOADER to the standard loader dylib and VK_DRIVER_FILES to the driver's ICD manifest, for example LEONIDA_VULKAN_LOADER=/path/to/libvulkan.1.dylib VK_DRIVER_FILES=/path/to/lvp_icd.json. These tools do not request portability enumeration, so use the default for MoltenVK.

Run python -I scripts/run_gpu_tests.py --filter ms_v5_workgroup to check the mesh workgroup index. The synthetic shader exports its incoming v5 from lanes 0, 1 and 31 in the RGB channels of a full-screen triangle. One vkCmdDrawMeshTasksEXT(2, 3, 4) produces 24 triangles. A stencil countdown lets pixel i record only triangle i in Vulkan rasterization order. For g = x + 2*y + 6*z, the CPU compares each pixel with (32*g, 32*g + 1, 32*g + 31, 1) (the 32-thread fixture's g * NumThreads + lane values). This checks the translator's register mapping on the host GPU. SPIRV-Tools 2026.1 validates this fixture. Version 2025.1 reports a known error on CullPrimitiveEXT. Vulkan mesh rasterization order · Validator fix.

Build the runtime

.\scripts\build_runtime.ps1

It sets up MSVC through vcvars64.bat and builds at BelowNormal priority on half the cores, writing to runtime\build\. If VS's "C++ CMake tools" component is installed, it uses CMake and Ninja. Otherwise it calls cl directly. That component may not be installed, and the devkitPro MSYS cmake on PATH can't build MSVC projects. When you add a source file, add it to runtime\CMakeLists.txt and to the file list in build_runtime.ps1.

Asset status (no exe needed)

Asset State Where
Archive data Carved without the encrypted tables of contents. Most archives are 93–99% plain zlib (levels.rpf 98.3%, 1.1M files; full census 23,535 placement maps / 1,670,442 entities). Not zlib: audio.rpf (99.9%), about half of story000.rpf and shared_minigame000.rpf. <work>\carve\<archive>\, coverage.json; world_census.md
Videos 797 Bink 2 files (KB2n), cut out whole. *.bk2 in the carve folders
Shaders 26,503 carved from shaders.rpf, native RDNA2 code unpacked (FSSM), disassembled, and translated to SPIR-V; all validate (see Translator status). <work>\shaders\ (.dxbc, fssm\, disasm\, spirv\)
Textures Solved. Headers are in CPU segments: GPU pointer at q[k], u16 width/height/depth and DXGI format at q[k+4], mip count at byte 2 of q[k+5]. Data is AMD SW_4K_S tiled, largest mip first. The GPU segment is the blob run after the CPU blob. On 200 samples, 173 decode at least 1.5× smoother detiled than untiled (median 2.56×). Exports the top mip, slice 0, as DDS. 22,342 exported (1.23 GiB): every header whose GPU data follows its CPU blob. World and model textures are handled by the TXD and TTPF exporters below. GPU offsets must be 256-byte aligned, which drops the false headers in navmeshes/anim. tools\tex_headers.py, tools\tex_export.py, <work>\textures\
Models Done: 382,781 models measured at the e293917 pin (levels.rpf 343,327, packs 26,585, story000 7,461, data 3,175, shared_minigame000 1,294, core_restofworld 936, story000_restofworld 3; 0 decode failures across all 382,781 models; 159,511 drawable-dictionary children, 223,270 standalone; the other archives measure 4,686 fragments, 30,343 bone-bound, 126,301,454 triangles and 512 embedded textures, while the levels.rpf fragments/bone-bound/triangles/embedded cells are not independently reproduced (†) (no levels.rpf manifest; the count harness emits no such fields); 72 unrecovered scan candidates vs 1,282 at 917e9b9). Earlier baselines: 350,251 at 917e9b9 (159,486 dictionary children, 190,765 standalone) and 190,792 at c3708fb; the +32,530 gain at e293917 comes from upstream v1.2 PRs #8–#12 (optional fragment pointers, texture-dictionary filtering, probe-cap parity, and zero-radius drawables; see models.md). Exported with tools\rpf9dump (built on breadbbbb/rpf9-explorer's Core; see below). Resources are found at page offset +16 after 16 zero bytes, followed by a zlib system blob with a drawable/fragment header and then the following zlib blocks as graphics data. Positions are quantized: bias + scale * ((q >> 8) & 0xFFFFFF). Output is OBJ (positions, UVs, indices) plus a manifest with real model names (e.g. cvar_int_grg2b_toys_1), bounds, per-mesh shader index and material texture references (parameter hash, name hash, 64-bit asset key). My earlier 0x1380/0x1601 descriptor notes stand, but the "data not located" blocker was wrong. Character skeletons are separate: the shared 597-name .#ft table and its model-side bone-hash mapping are in character_skeleton.md. <work>\assets\<archive>\models\
Texture dictionaries Same tool: TXD resources become DDS per texture. <work>\assets\<archive>\textures\
World textures (TTPF) Done (all 57 pools, 357,115 catalog entries, 0 failures): the original exporter baseline exported 308,895 (98,603 complete, 210,292 partial) and skipped 48,220 (33,507 BCPack, 14,030 compact mapping, 678 arrays/volumes, 5 unsupported format, 0 unmapped). The compact-tail tool resolves 14,011 of the 14,030 layouts (305,264 complete, 1,100,865 mips, 4.59 GiB), the multi-slice pass resolves all 697 arrays/cubemaps/volumes (textures_arrays.md), and DXGI 11 resolves the last 5 format skips, bringing the measured zlib/raw split to 305,959 complete, 16,423 partial, and 34,733 skipped (0 remaining layout/format skips; all 34,733 are BCPack). Clean-room tools/bcpack.py decodes all six active BCPack modes (BC1, BC3, BC4, BC5, BC6H, BC7), giving a tools/ttpf_mips.py scan codec-availability projection of 357,115 complete / 0 partial / 0 skipped; on full-corpus chunk decode with --allow-provisional --history <path>, BC6H decodes 268 / 268 chunks (0 strict) and BC7 decodes 5,150 / 5,167 chunks (583 strict), while 17 / 5,167 BC7 chunks (0.33%) still cleanly refuse in provisional mode. rpf9dump's C# TtpfReader (e293917 pin, breadbbbb/rpf9-explorer#7) decodes compact tails, multi-slice layouts, DXGI 11, and strict BCPack BC1/BC3/BC4/BC5 directly; BC6H/BC7 and provisional-history chunks remain skipped by rpf9dump and can be completed by tools/ttpf_assets.py (textures.md). 46 pools are in data\ttdb\**, 11 in pack\<name>\data\ttdb\** (exported under ttpf_pack\<pack>\). data\ttdb\**\*.ttpf (57 pools, 58 GiB) are loose RDS5 texture pools, not inside RPFs. rpf9-explorer's TtpfReader reads the catalog and detiles them; checked visually (ttdb_graphics: scope reticles, clean lines). Names are generated (texture_N_<assetkey>); models reference textures by asset key. Measured breakdowns and decode caveats are in textures.md. <work>\assets\ttpf\<pool>\ + manifest.json
Animation Indexed without the TOC: 130,470 zlib streams (4,203,762,662 stored / 11,593,460,132 inflated), 95.4% readable. New RAGE page directories (0DRP, version 122), MoVE (version 19), 273 pack:/ name tables (2,298 paths), and a tail RBF0 rig-set manager (rage__crRigSetManager: 1,126 rig sets, 6,677 source→rig entries, 3,669 distinct rigs; 56 empty). Bone data: one standalone 28-name table and 3 motion-matcher streams with embedded bone tables (30-name union, 19 joaat32 hashes present, 4 motionmatcher paths); no rig→skeleton link was found. Clip dictionaries are system-only RAGE resources (page map at the +0x08 pointer). tools/anim_clips.py decodes 191,042 of 191,042 animations in 61,505 of them to per-frame values (channel types 0–5, 7, 8 and the GTA VI type 10) and resolves 111,948 of 159,584 .motion children to a clip. For each .motion it reads the per-child durations and time curves and, on 10,171 of 17,247, the one-axis parameter node (axis name hash, sorted sample values, range). The 2/3 packed streams are second pages of 0DRP resources, which are not decoded. No YCD/RSC7 at any stream start. The rpf9_carve tail overread is measured in docs/animation.md. tools\anim_index.py, <work>\anim-index\
Audio audio.rpf holds raw (not zlib) AWC banks: Opus (codec 0x0B) and XMA2 streams. Exported as whole .awc files plus audio_manifest.json (stream ids, codec, channels, rate, duration). Done: 7,162 banks, 27 GiB, 1,603,231 streams, about 1,324 hours (codec 0x0B Opus 1,601,167; 5: 1,818; 2: 227; 0 PCM: 19). tools/awc_opus.py repackages every Opus stream losslessly into a standard Ogg Opus file (no re-encode; PCM streams become .wav). The AWC framing is 2048-byte blocks of [u16 length][packet], with a zero length padding the block (as rpf9-explorer's OpusPreview reads it). The final granule is pre-skip + declared samples; the EOS page is emitted at the packet that reaches that target and later padding packets are dropped, so decoders stop at the declared end. Checked: 20 real streams at 48 and 32 kHz decode to exactly their declared counts; 300 random streams decode with ffmpeg with no errors. XMA2 streams (codec 5, 1,818) are written as RIFF XMA2 files by rpf9dump xma (rpf9-explorer's AwcRecovery.WriteXmaWave) and decoded to PCM WAV by ffmpeg: all 1,818 decode. Streamed music (tag 0x48: chunks with a per-channel record table, each channel's 2048-byte subblocks after the aligned header, and a repeated-prefix skip per chunk) becomes one Ogg Opus per descriptor channel (3,008 banks contain music). The Opus TOC stereo bit gives the packet channel count; a 1-channel descriptor can carry stereo packets, whose interleaved sample count is halved for the end granule. Checked: a 4-channel bank gives four 42.0 s mono channels; 1-channel stereo banks export at the config duration. Output: <work>\assets\audio\ogg\<bank>\<stream id>.ogg. Done: 1,598,051 Opus streams + 3,116 music channels as Ogg Opus (22 GB), 19 PCM16 and 227 codec-2 streams (32-bit float PCM, 4 bytes per sample; values can exceed ±1) as WAV, 1,818 XMA2 as WAV. Every audio stream is converted; all WAVs decode. make_game.py --wav also decodes the Ogg Opus output to 16-bit PCM WAV with tools/audio_wav.py (ffmpeg required; existing WAVs are skipped on resume). <work>\assets\audio\awc\
World placement Full census of levels.rpf: 23,535 map resources / 1,670,442 entities; all maps/entities exact, 36/36 shards, 98.32% stream coverage. Map files occupy a continuous band from ~7.5 to ~62.9 GiB; the earlier 9,918 / 680,228 sample was a 55% lower bound. 0x7a resources: CMapData root, 0x90-byte CEntityDef with position/quaternion/scale/archetype/flags/per-entity id/per-archetype key/LOD fields; names and most archetypes are hash-only. Archetype and map names are lower-cased joaat, confirmed by a MurmurHash3 x64 low-64 key; see world_names.md. tools\world_index.py, tools\world_census.py, tools\world_names.py; world.md, world_census.md, world_names.md
Navmeshes navmeshes.rpf: 90,295 zlib streams (6,540,238,392 stored / 20,551,068,624 inflated), 97.5% readable; 9,603 0DRP pages and 27,644 0x00010015 pages, no NAVM/CNavMesh/NVMS magic. 0DRP is generic RPF paging, not a navmesh container. tools\navmesh_index.py; navmesh.md
BVH core_bvh4.rpf: 565,596 streams, 271,627 complete BVH4 streams + 10 eight-MiB split continuations, 269,106 instance records. Header 0x81020006 at +0x100, 64-byte node units, 208-byte instances with a 3x4 transform; prebuilt acceleration data, not source meshes or shaders. tools\bvh_index.py; bvh.md
RBF0 1,263 data.rpf resources, 475,461 elements, 44,887 descriptors and 340,859 strings. Inline record stream with no section table; UI/Scaleform (rage__fwui*, screens, subtitles, settings). The anim.rpf tail uses the same format (rage__crRigSetManager). tools/rbf0_tree.py decodes every resource to a strict JSON/CSV/XML element, value and text tree. tools\rbf0_index.py, tools\rbf0_tree.py; rbf0.md
Gamedata common.rpf: 954 streams (5,647,255 stored / 50,231,123 inflated), 85.5% readable; 266 XML documents / 118 roots (time/weather, vehicles/handling, peds/schedules, tuning, manifests, world/navigation); tools/gamedata_xml.py catalogs 267 payloads / 259 well-formed / 118 roots / 428,611 elements. No RBF0/PSIN. tools\gamedata_index.py, tools\gamedata_xml.py; gamedata.md
PSIN script.rpf: 671 streams start with PSIN, 670 complete; sections LSCH, LENM, LSNS, LGID, LRSC, CHKS. data.rpf: 2,281 streams, 1,045 complete after joining. LSCH (type schema: structs and members) and LENM (enums) are decoded on all 17,664 / 17,641 whole sections across every archive, names as case-sensitive joaat. The instance data before LSCH is a block table plus 16-byte-aligned blocks with 20-bit-block pointers; read from the LRSC root through the schema, it reaches 129,100,004 of 129,117,812 block bytes on 17,507 containers. LSNS is a block table of 16-byte records (5,217 sections, 0 layout errors); the records are uniformly random, match no tested name hash and may be encrypted, so they stay unread. No plaintext scripts or names. Hash-typed members name other resources (u32: lower-cased joaat; u64: MurmurHash3 x64 low 64 bits): 228,427 values in 5,355 of 18,404 containers resolve against rpf9_names.py names, 299 control hits. tools/psin_index.py, tools/psin_data.py, tools/psin_names.py; psin.md
Audio config audio.rpf first 19.5 MiB: 837 zlib streams / 54,143,493 inflated bytes. 1,589 music records, 1,589 distinct ids, exact milliseconds; hash & 0x1fffffff is the AWC stream id. 1,584/1,589 durations match the AWC manifest / 2; no per-track start offsets. tools/audio_config.py; audio_config.md
Page directory 0DRP: fixed 0x60-byte header, version 122; q38 at +0x38 gives 16-byte records {u32 hash, u32 size, u64 0x50000000 + target}. data.rpf: 15,768 pages / 60,880 records; targets tile with zero overlaps. Names still need the TOC. tools/page_index.py; page_directory.md
Story / minigame story000.rpf (18.65 GiB) is mixed: 264 Bink 2 streams (3.33 GB), 225,281 raw RSC8 headers (v8001), 442 nested RPF9 headers and zlib resource pages. story000_script.rpf is 2,309 PSIN streams (2,118 complete), not a named script container; shared_minigame000 mixes pages, PSIN and XML. tools/story_index.py; story.md
Rest-of-world / script Six archives, 1.57 GB total: core_restofworld 1.21 GB (11 Bink 2 streams / 1.24 GB, 37 decoded models, 958 graphics pages, 6 PSIN), story000_restofworld 189 MB, story000_script 74 MB (2,309 PSIN, 2,118 complete), small appdata0/licences. No maps; no validated script container. tools/restofworld_index.py; restofworld.md
Audio stations Audio config 0x762160: 19 station blocks of {station hash, u32 boundary, ordered u32 content ids}; the boundary is a byte offset, not a count. VCRR content ids 0x28F2-0x2941 map exactly to records 0xBD73-0xBDC2 (80/80); other clusters are context-dependent or shared. Title-keyed stream ids resolve 702/800 resolved titles exactly and 746/800 with case/punctuation/feature variants. No per-track start offsets. radio_stations.md
D3D12 command objects Measured command queue / command list / fence / PresentX surface, split into verified exports and slots, prior-art claims, and open questions. Queue/list/fence creation and barriers are scoped; PresentX signature/slot and exact swapchain/plane parameters remain open until the executable is available. d3d12_command_objects.md

rpf9dump (bulk export)

tools\rpf9dump is a small CLI over the Core library from https://github.com/breadbbbb/rpf9-explorer (a friend's tool; source at third_party\rpf9-explorer, audited: no keys, no network, no custom build targets). It decrypts nothing. It carves validated resources, as rpf9_carve.py does, but with working model and texture decoders.

dotnet build tools\rpf9dump\rpf9dump.csproj -c Release -o <work>\tools\rpf9dump
rpf9dump models|textures <archive.rpf> <work>\assets
rpf9dump ttpf <pool.ttpf> <work>\assets\ttpf
rpf9dump audio <audio.rpf> <work>\assets
python -I make_game.py --stages assets   # everything, in order; skips what is done

Full-scan indexes are also saved to %LOCALAPPDATA%\RpfPreview\Indexes, so the rpf9-explorer GUI opens these archives with complete listings instead of its 16 MiB preview scan.

Other prepared pieces

  • tools\shader_profile.py writes the instruction profile to <work>\shaders\profile.json. An earlier corpus run reported 551 distinct mnemonics, with 204 accounting for 99% of instructions. Those counts predate the filter for assembler directives and comments.
  • tools\shader_ir.py: parses every disassembled instruction into opcode, typed operands (s/v registers and ranges, NSA register lists, constants, literals, export targets, interpolation attributes), modifiers and encoding bytes. On 1,000 shaders, 12 of 2.2M operands were left untyped before the last fix. This is the front end for an RDNA→SPIR-V translator.
  • tools\rtti_scan.py: MSVC x64 RTTI scanner (class names, bases, vtables). Tested on the bundled DLLs; run it on the exe first.
  • tools\hashdict.py: joaat hash→name dictionary (<work>\hashes.json, 1.9M entries, checked against adder = 0xB779A091). On day one, rerun with --extra <exe> so PSO field and type names resolve. Without the exe only about 1% do.
  • Runtime shims: all of xmem.dll is shimmed with the measured argument shapes (XMemAlloc, XMemFree, XMemVirtualQuery(process, address, out64), XMemGetWorkingSetStatistics(kind, out), with kind 0x20000001 at all seven FSR call sites). The d3d12_xs root-signature serializer forwards to the PC d3d12.dll after clearing the Xbox flag byte; the deserializer forwards unchanged. D3D12XboxCreateDevice returns an Xbox-ABI proxy over the PC device: every PC vtable slot is forwarded with this adjusted, Xbox slot 62 is CreateComputePipelineState, and Xbox slot 76 maps resource creation to CreateCommittedResource with the Xbox 0x101/0x1 layout word replaced by the PC layout. Slots 9/10 are ID3D12DescriptorHeap methods, not device methods. The PC heap getters take a hidden return pointer (RDX), while Xbox expects the 8-byte handle in RAX, so slot 14 wraps the heap and slots 9/10 convert it. The heap holds a reference to the device proxy and its GetDevice returns that same proxy. Queues, fences, command lists and PresentX extensions remain unimplemented.
  • PSO metadata is a new variant (PSIN, LSCH schema, LENM, LSNS, LGID, LRSC, CHKS, little-endian). CodeWalker's parser reads the container but not the new schema; dump it once the exe gives the field names.

Shader translation (RDNA → SPIR-V)

tools\rdna2spirv.py (needs spirv-as/spirv-val on PATH: Vulkan SDK, or spirv-tools in WSL) translates parsed RDNA code to SPIR-V assembly, assembles it with spirv-as, and validates it with spirv-val (Vulkan 1.2). It runs one lane per invocation and keeps VGPRs and SGPRs as uint arrays with exact bit patterns. Version 0 treated EXEC as all-ones and covered only branch-free vertex and pixel shaders with no memory loads: common float and integer ALU ops and exports to gl_Position, params and MRTs. Unsupported instructions are reported by name, never guessed. In that version, VS_Passthrough and VS_BlurFilter translated and validated. Coverage across the corpus and the blocking instructions are in <work>\shaders\spirv_run.log; the former next steps, structured branches (EXEC masks) and the descriptor/binding model for s_load, s_buffer_load, buffer_* and image_*, are now implemented. Current coverage is in Translator status below.

Also handled: 64-bit scalar moves, per-invocation EXEC reads, whole-quad mode on EXEC, m0, SCC, vector and scalar compares, v_mul_hi_u32, v_cvt_pkrtz_f16_f32 (now exact round-toward-zero; the earlier round-to-nearest version could overflow to inf), and pixel interpolation (v_interp_p1/p2/mov become fragment inputs at their attribute's location). MODE writes (s_setreg) model the f16/f64 rounding field, FP_ROUND[3:2], the only MODE field the corpus writes; other MODE writes are refused (see Known approximations).

GPU tests (RTX 4060 Ti)

runtime\test\vk_harness.cpp (build: runtime\build\test\build_harness.cmd, MSVC + the Vulkan 1.4 headers from Hookshot's CPM cache, loading vulkan-1.dll at runtime) draws one triangle with a given VS + FS into an RGBA32F target and dumps the floats. Test shaders are in <work>\gputest.

  • VS_Passthrough (translated) is bit-exact. All 64×64 pixels are written, and param0.xy = (u, 1 − v) with max error 0, with zw = (0, 1) as exported. This covers the VertexIndex input, integer/float ALU, inline constants, and position/param exports.
  • 400 arithmetic-only translated pixel shaders (no buffers, descriptors or subgroup ops), driven by a generic full-screen VS feeding locations 0–15: the driver compiled every pipeline, every draw completed, and every output was finite. This is a stability check, not a value check (there's no reference for these).
  • Texture path is exact (runtime\test\vk_texture_test.cpp): translated PS_PassthroughCopy gives max error 0.0 over all 64×64 pixels against the expected nearest-sampled 8×8 test texture. That covers push-constant user data, a heap-relative s_load_dwordx8 of the T#, the hash-table lookup of the T# and of the shader's literal S#, bindless sampling, v_interp, and the f16 compressed export. It also caught a translator bug that validation can't: compressed exports read the wrong register pair (LLVM prints v4, v4, v5, v5), giving (r,g,r,g). That's fixed.
  • After the export fix, 2 of the 400 smoke-test shaders (PS_ImposterShadow variants) gave non-finite red values. The cause was round-to-nearest pkrtz overflowing to inf, fixed with exact RTZ. One variant is now fully finite. The other still has 1 inf and 4 NaN in red, and RTZ can't create those from finite values, so they come from the shader's own maths on the synthetic test inputs (hardware would pass them through too). That's consistent with hardware, but unconfirmed without a reference.

Translator status and runtime contract

Full corpus (verified pixel-shader inputs incl. front face, ACO-confirmed 16-bit semantics, vcc_hi as an SGPR, code-embedded data via s_getpc_b64, global memory, exact packed-f16 modifiers): All 26,503 shaders translate and pass spirv-val (Vulkan 1.2 target, --allow-offset-texture-operand): 2,236 VS, 12,101 PS, 2,689 CS, 9,282 mesh, 195 geometry. spirv/index.json lists each one's requirements. Output: <work>\shaders\spirv\ (.spvasm + .spv), and the log is <work>\shaders\spirv_run.log.

How the generated SPIR-V expects the runtime to work:

Piece Contract
Execution model One invocation = one lane. A wave = a subgroup, so cross-lane ops (ds_swizzle, v_permlane*, v_readlane/v_writelane, v_mbcnt) become subgroup shuffles. Requires subgroup size == wave size (wave32 maps directly onto NVIDIA GPUs; wave64 shaders need a 64-wide subgroup or emulation). v_readlane_b32/v_writelane_b32 mask the lane select with 63 in wave64 (S1[5:0]) and 31 in wave32 (S1[4:0]); until SHADER-52 both used 63, so a wave32 select ≥ 32 pointed past a 32-wide subgroup. GPU-checked with cs_w32_lane_wrap.asm (lane 40 → 8).
DPP VOP1/VOP2 _dpp applies to src0. DPP16 controls (quad_perm, row_shl/shr/ror/share/xmask/mirror/half_mirror) and DPP8 (dpp8 + fi) select the source lane, then row_mask (one bit per 16-lane row) and bank_mask (one bit per 4-lane bank) decide which destination lanes update. A lane whose row/bank is off is not written. A source lane outside the row is invalid: bound_ctrl 1 uses 0 as src0, otherwise the lane is not written. A source lane inactive under EXEC is used when fi is 1; otherwise bound_ctrl decides. DPP8 always writes an enabled lane: fi 1 reads the inactive source, fi 0 uses 0. DPP16/8 never leaves its 16/8-lane group, so this is exact on every subgroup at least that wide; under --wave64-emulate the exchange goes through the workgroup buffer like the other cross-lane ops. GPU-checked with runtime/test/shaders/cs_dpp*.asm on an RTX 3070 and hardware-measured on an RX 6800. On an RX 6700 XT (gfx1031), tools/crosslane_fuzz.py --dpp-sweep --oracle hw checks every DPP16 control × bound_ctrl × fi, every row_mask/bank_mask pair and the DPP8 selects in wave32 and wave64: 14,412 cases, all matching these rules (BUILD-162, docs/shader_validation.md FUZZ-7). Semantics from the RDNA2 ISA, AMD LLVM modifier syntax and the GPUOpen DPP notes.
EXEC A per-invocation active flag. VALU writes and exports are masked by it, scalar ops aren't, and v_cmpx, saveexec and EXEC writes update it. A pixel lane still inactive at the end is discarded. Measured on native gfx1100 (8 threads): a v_mov_b32 under EXEC=0x0F leaves the other lanes untouched, EXEC=0 writes nothing, a store writes only active lanes and v_cmpx_gt_u32 narrows EXEC (4 of 4 cases); note that AMD clang 20 rejects v_add_co_u32, v_sub_co_u32, v_add_co_ci_u32 and v_mad_u64_u32 for gfx1100, gfx1101 and gfx1102, so this toolchain could not reproduce the RX 7600 result below, which leaves open whether those parts support the opcodes and says only that they could not be assembled here. A pixel lane that was inactive at the last exp ... vm it executed is discarded, and on a path without one, a lane inactive at the end (EXEC is kept at the export only where a path can write it afterwards). The vm rule is from the RDNA2 ISA reference guide (30-November-2020, §11.1 and §11.2.1: EXEC at the export is the valid mask and the final one sent is used), not measured on hardware; checked on the CPU by tests/semantic/test_export_valid_mask.py. VALU scalar lane-mask destinations (v_cmp_*, v_add_co_u32, v_add_co_ci_u32, v_sub_co_u32, v_sub_co_ci_u32, v_subrev_co_u32, v_subrev_co_ci_u32, v_mad_u64_u32, v_mad_i64_i32) write 0 for lanes off in EXEC (SDST[lane] = EXEC[lane] ? bit : 0, AMD RDNA2 ISA). Until 2026-11-22 the six *_co_* ops and v_mad_u64_u32/v_mad_i64_i32 did not AND the carry/sign bit with active, so inactive lanes leaked 1 bits into VCC/SGPR masks (s_bcnt1, s_cbranch_vccz, v_cndmask_b32). Checked on the CPU by tests/semantic/test_carry_exec_mask.py (wave32, wave64, and --wave64-emulate structure), and GPU-verified on native RDNA2 (gfx1036, AMD Radeon Graphics) with partial EXEC masks (inactive lanes write 0 in sdst for v_add_co_u32 and v_mad_u64_u32). Checked on the CPU by tests/semantic/test_carry_exec_mask.py (wave32, wave64, and --wave64-emulate structure), and hardware-verified on an AMD RX 7600 (gfx1102) with v_add_co_u32 and v_add_co_ci_u32 carrying on every active lane: VCC reads 0xffffffff with full EXEC, 0x0000ffff for the mask 0x0000ffff and 0xaaaaaaaa for 0xaaaaaaaa in wave32, vcc_lo = 0x0000ffff with vcc_hi = 0x0000000f for the same partial mask in wave64, and 0 when EXEC is 0 even with VCC preloaded to all ones; with one carrying lane under mask 0x0000ffff VCC is 0x00000001, and v_sub_co_u32/v_subrev_co_u32 with a borrow under that mask give 0x0000ffff too. The *_co_ci_ forms, v_mad_u64_u32 and v_mad_i64_i32 share the same path but were not measured separately.; also GPU-verified on native RDNA2 (gfx1036, AMD Radeon Graphics) with partial EXEC masks (inactive lanes write 0 in sdst for v_add_co_u32 and v_mad_u64_u32). The *_co_ci_ forms, v_mad_u64_u32 and v_mad_i64_i32 share the same path but were not measured separately.
s_*_saveexec_b32/b64, s_andn1/andn2_wrexec_b32/b64 RDNA2 ISA SOP1. saveexec: D = EXEC; EXEC = f(S0, EXEC); SCC = (EXEC != 0). wrexec: EXEC = f(S0, EXEC); D = EXEC. f is one of and, or, xor, andn1 (~S0 & EXEC), andn2 (S0 & ~EXEC), orn1, orn2, nand, nor, xnor, the table in Gen.EXEC_LOGIC. The definitions match tools/cf_ref.py _SAVEEXEC, the FUZZ-8 model. Each invocation holds its own lane's bit (0 or ~0), so f is the bitwise op on that bit. A lane EXEC had off becomes active when f gives 1 for it (nand, nor, orn1, orn2, xnor, ...), as on hardware, and SCC is the wave vote. Until 2026-11-22 only and/or/andn2_saveexec and andn2_wrexec were translated. CPU-checked by tests/semantic/test_saveexec_variants.py (all ten saveexec kinds in wave32 and wave64, both wrexec kinds, partial EXEC and S0, an empty result, every lane against cf_ref._SAVEEXEC) and by tools/cf_diff.py (300 programs × wave32/64 still pass). Not GPU-verified for the seven new kinds.
Control flow Reducible graphs use structured branches and natural loops. Irreducible graphs use the dispatch-loop form, which can also be forced with --dispatch-loop for comparisons. The control-flow unit test checks 18,228 generated graphs. Irreducible graphs use node splitting (cfg_structure.split_irreducible, up to min(2*N, N+64) blocks) and fall back to the dispatch-loop form when capped; it can also be forced with --dispatch-loop for comparisons. cfg_structure.structure, cfg_structure.run, and rdna2spirv.assemble's structured emitter are iterative and hoist each guarded member's dominated tail continuation out of its enclosing guard (exact by strict dominance: no block outside the guard's subtree can target the continuation), keeping OpSelectionMerge nesting O(1) on sequential diamond/loop chains instead of nesting O(N) deep and hitting Python's recursion limit on multi-thousand-block shaders (e.g. 2,000 sequential diamonds nest to depth 2 instead of 2,000). The control-flow unit test (tests/test_cfg_structure.py) checks 20,000 generated graphs plus 2,000-diamond, 1,200-loop, and 1,500-early-exit chains. AMD A/B checks compare the two forms for selected pixel shaders with defined test inputs. For shaders that never export colour, the comparison checks pixel coverage. Nesting is bounded (SHADER-299): a tree deeper than MAX_STRUCTURED_DEPTH (16) is emitted in the dispatch-loop form instead, since spirv-val time grows roughly with the cube of the measured nesting depth. Over the 1.0.2.1 corpus (26,503 modules, spirv-val 2026.4): the deepest block of a module is nested 118 constructs deep, 12,963 modules are structured (median 15) and 6,000 of those are deeper than 16; an estimated 85% of the corpus's spirv-val time is in modules nested 20 or deeper. Median spirv-val time for the same module in each form: depth 20 181 -> 129 ms (1.4x), 30 507 -> 371 (1.4x), 50 1,712 -> 738 (2.3x), 64 2,692 -> 1,163 (2.3x), 77 5,122 -> 1,130 (4.5x), and the deepest (118) 13,683 -> 1,352 ms (10.1x). Depth 5-12 shows no gain (at depth 6 the flat form is slightly slower), which is why the bound sits at 16. Both forms pass spirv-val on a 200-shader slice (200/200 each), and gen.nesting records the tree depth.
User data Push constants, 144 bytes: dwords 0–31 = initial s0–s31 (the user SGPRs the console driver loads from the root signature: descriptor-table pointers, constants and so on), dwords 32–33 = the 64-bit heap base, dwords 34–35 = the code base: the Xbox VA where the runtime uploaded this shader's whole FSSM blob. --mesh-compute modules add dwords 36–37, the output buffer address (152 bytes; see "Mesh shaders as compute"). --pc-tail-ubo keeps only dwords 0–31 here (128 bytes) and moves the rest to a uniform block (see "Push-constant tail as a uniform block"). The runtime has to reproduce the console driver's root-signature-to-user-SGPR mapping; that comes from the exe or driver behaviour.
Xbox GPU addresses Shaders build Xbox GPU virtual addresses, and some force the high dword to 0 (descriptor tables in the low 4 GB). Every memory access goes to heap base + Xbox VA, so the runtime maps the console's GPU address window into one host buffer-device-address allocation.
Code-embedded data 155 VS/PS had "undecodable words". They're constant tables inside the code range (float values like 0x3EF7…, plus zeros), read through s_getpc_b64 + s_add_u32/s_addc_u32 + s_load (147 of 155). The translator re-anchors each instruction to its true FSSM offset by matching encodings, translates only code reachable from entry (a branch into data is rejected), and turns s_getpc_b64 into code base + next-instruction offset. The runtime uploads each shader's FSSM blob into the heap and passes that VA as the code base. Re-anchoring compares bytes exactly, except that VOP3P op_sel_hi[2] (bit 14) is ignored on two-source packed ops: the compiler stores 0 there, and LLVM prints its default of 1. Unused VOP3/VOP3P SRC1 (bits 49:41) and SRC2 (bits 58:50) fields are also ignored when stored as 0 and printed as 0x80: LLVM 23 re-encodes a source it doesn't read as inline constant 0 (one-source v_rcp/v_log/v_sqrt_f32_e64, two-source v_sub_f32_e64/v_cmp_*_e64/v_mul_lo_u32/v_pk_mul_f16). Both checks for clean listings and re-anchoring use the parsed operand count to apply this exception only to unused sources. A used source encoded as 0 reads s0 and is never treated as inline zero. tests/semantic/test_printed_encoding.py checks used SRC1/SRC2 and an unused field with synthetic listings. Confirmed by a count over the corpus with LLVM 23.1.5: without it, 1,471 of the 1,473 shaders with embedded data are rejected ("reachable instruction with normalized encoding"); with it, all 1,473 translate and pass spirv-val. Runs with LLVM 21 already translated all of them, so older LLVMs presumably print the stored 0 (not re-checked). Data words that decode with ignored fields set are printed re-encoded (e.g. 0xbe8d2242 as s_rfe_b64 0xbe802242), so they can never match. Since the decoder consumed the same length, they are anchored in sequence and marked. A shader that can reach a marked word is rejected; none of the corpus does. All 155 now translate.
Printed encodings A listing is LLVM's text for what it decoded, not the bytes it read, so the translator checks the two against each other: the re-anchoring above for listings with undecodable words, and, for every other listing whose header names its code range and whose blob sits next to it (fssm/, or fspx/ for FSPX), each instruction's printed encoding against the bytes at its offset, with the same exceptions (same_encoding). A difference is Unsupported, naming the instruction, its offset and both byte strings, instead of a translation of the field as 0. The case that prompted it: llvm-mc's gfx1013 decoder (LLVM 21.1.8) drops the VOP3 op_sel bits (word 0, bits 14:11) of a 16-bit VOPC compare: 0a 08 a9 d4 01 05 02 00 disassembles as v_cmp_lt_u16_e64 s10, v1, v2 and re-encodes with the bits cleared (its assembler rejects op_sel on VOPC for gfx1013 and gfx1030 alike). Counted over the 1.0.2.1 corpus: the 25,030 clean listings hold 30,335,381 instructions, and none differs from its bytes beyond those exceptions (754); the 166 16-bit VOPC compares (154 shaders, all f16) have op_sel clear. Hand-written listings, run_gpu_tests.py's code 0x0..0x0 (synthetic) listings and a blob that doesn't hold the listing's code range (the tests' header-only FSSM) are not checked. tests/semantic/test_printed_encoding.py (a dropped VOPC op_sel, a later instruction, the SRC2 exception, and the unchecked cases).
Global memory global_load/store_dword*: address = (64-bit SGPR base + zero-extended 32-bit VGPR offset, or a 64-bit VGPR address) + the instruction offset, translated through the heap base. Inactive lanes don't access memory, and loads merge their previous values with OpPhi. The offset is the signed 12-bit byte value as llvm-mc prints it, -2048..2047 (offset:-4 is the field 0xffc; llvm-mc rejects offset:0xffc and disassembles that field as offset:-4, so no repo path delivers the raw unsigned field), added to the address as is; a tool that printed the raw field (0xffc) would mean the same offset, and a value outside 12 bits is rejected. Measured on an AMD Radeon RX 6800 (gfx1030) running global_load_dword as a raw compute kernel, wave32 and wave64 alike, with the dword at byte n = 0x10000000+n and the pointer at 0x1000: offset 0 reads 0x10001000, -4 0x10000ffc, -2048 0x10000800, 2044 0x100017fc, -1024 0x10000c00. The translator used to subtract 0x1000 from an already negative value (4096 bytes too low). Checked by tests/semantic/test_global_mem_offset.py (both addressing modes, dword/x2/x4, byte/short loads and stores at -4, -2048, 2047 and 0) and the GPU test runtime/test/shaders/cs_global_neg_offset.asm (vk_compute_test ... 40 dump).
Global atomics (global_atomic_*, 32-bit) add, sub, smin/umin, smax/umax, and, or, xor, swap and cmpswap at the global_load/store address (same Gen.global_address: saddr pair plus zero-extended vaddr, or a 64-bit vaddr with off, plus the signed 12-bit offset), as one OpAtomic* on the PhysicalStorageBuffer dword, device scope, guarded so inactive lanes don't touch memory. fmin and fmax (32-bit float) lower to a structured OpAtomicCompareExchange CAS loop using GLSL.std.450 NMin/NMax (no Vulkan float-atomic extension needed; NaN returns the non-NaN operand, -0.0 < +0.0). inc and dec (32-bit unsigned wrapping against DATA: inc gives (M >= DATA) ? 0 : M + 1, dec gives (M == 0 With glcthe pre-op value lands invdst, the first operand; without glcthere is novdst, and the first-read analysis counts operand 0 as the address (a source). cmpswaptakesvdataas the pair {DATA, CMP}:M = (M == CMP) ? DATA : M, as buffer_atomic_cmpswap. Still Unsupported: the _x264-bit forms,inc/dec, the float atomics, and slc/dlc. and/or/xor/swap_x2work on a 64-bit element (two dwords, low first) as one 32-bit atomic per dword, with no Int64 atomics: a bitwise op leaves the same memory that way, since its bits are independent. **Approximation:** an exchange can tear, since two lanes swapping into one element at once can leave one's low dword with the other's high dword (A.lo, B.lo, B.hi, A.hi), and the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done (as fords_and/or/xor_b64). **Approximation:** the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done (as for ds_and/or/xor_b64). Still Unsupported: the other _x2 forms (add/sub/min/max/fmin/fmax_x2carry or compare across the dwords, andcmpswap_x2compares all 64 bits),inc/dec, fcmpswap, and slc/dlc. Until 2026-11-22 every global atomic was rejected. CPU-checked by tests/semantic/test_global_atomics.py(all ten ops on a value grid with and withoutglc, cmpswap, offsets from -2048 to 2044, offaddressing, seeded values, rejected forms, the first-read analysis). CPU-checked bytests/semantic/test_global_atomics.py(all ten integer ops plusfmin/fmaxon a value grid with and withoutglc, NaN/±0/±inf, multi-lane CAS contention, cmpswap, offsets from -2048 to 2044, offaddressing, seeded values, rejected forms, the first-read analysis) andtests/semantic/test_global_atomics_x2.py(the four_x2forms with and withoutglc, an offset, seeded values, the carrying forms rejected), and validated with spirv-val(native and--wave64-emulate`). Not GPU-verified.
Sub-dword MUBUF loads and GFX10_FORMAT_8_UINT buffer_load_ubyte, buffer_load_sbyte, buffer_load_ushort and buffer_load_sshort read 1 or 2 bytes at `Gen.buffer_address(..., elem=1
8/16-bit global stores and d16 loads global_store_byte/short write the low 8/16 bits of the data VGPR (the _d16_hi forms its high half). global_load_{u,s}byte_d16 and global_load_short_d16 write the low 16 bits of vdst (the _hi forms the high 16) and keep the other half; ubyte zero-extends and sbyte sign-extends the byte to 16 bits. The address is the global_load/store one (Gen.global_address). The access goes one byte at a time, so a 16-bit access that crosses a dword (at byte 3) is exact too. A store merges each byte into its dword with atomic and/or, which keeps neighbouring bytes even when another lane writes them, as buffer byte stores do. A load reads each byte. Inactive lanes neither store nor load. The first-read analysis counts a d16 load's vdst as read, for the half it keeps. global_load/store_dword_addtid (lane-id and M0 addressing) raise Unsupported; until 2026-11-22 they crashed with IndexError, and the ten sub-dword ops raised Unsupported. CPU-checked by tests/semantic/test_global_sub_dword.py (every byte offset 0 to 7 for each op, an inactive lane, rejected forms, the first-read analysis). Not GPU-verified.
Literal samplers Some shaders build their S# from immediates (for example 0x92, 0xC00000, 0x14500000, 0). The runtime registers those in the descriptor hash table too, by scanning the translated shaders' constant S# values, not only S#s the game binds.
Scalar/buffer memory s_load*, s_buffer_load*, buffer_load* and buffer_store* use buffer device addresses (PhysicalStorageBuffer64). LLVM VCCTuple scalar register lists ending in vcc_lo,vcc_hi (e.g. [s100,s101,s102,s103,s104,s105,vcc_lo,vcc_hi], [s92,...,s105,vcc_lo,vcc_hi], seen in 6 FidelityFX FSPX shaders) are parsed as slist operands in tools/shader_ir.py, clear vcc from the lane-mask state in tools/lane_masks.py, and route sN slots to %sgpr and vcc_lo/vcc_hi to %vcc/%vcc_hi across SMEM loads, T#/S#/V# descriptor reads, and global_* saddr. src_scc reads %scc (0 or 1, RDNA2 inline constant 253), matching scc. image_atomic_* and image_atomic_cmpswap accept a16 packed 16-bit unsigned coordinates (low half first, matching image_store). CPU-checked by tests/semantic/test_fspx_rules.py and validated with spirv-val (native and --wave64-emulate). Not GPU-verified. The base comes from the 64-bit SGPR pointer or the V# (dword0 \
2D array resource dimensions For image_get_resinfo on a 2D array, X/Y are the width/height at the requested mip, Z is the view layer count and W is its mip count. The query reads the sampled array at binding 3. A native gfx1036 kernel returned (19,11,5,3), (9,5,5,3) and (4,2,5,3) for the three mips of a synthetic array. On RTX 5080 and Radeon Graphics the translated query matched those tuples and returned (4,2,3,2) at relative mip 1 with a view starting at mip 1 and covering three layers. The registered ps_array_resinfo draw checks all 4096 pixels against (8,8,12,1).
Images and samplers image_sample_l on 2D arrays used to read its LOD from the array layer; it now reads the LOD after all coordinates. image_get_lod and image_gather4_lz also work on 2D arrays. With d16 every sample result is f16, packed two to a VGPR from the low half (the packed D16 of GFX10, as LLVM returns D16 image data); image_sample_c_lz/_c_lz_o follow it too, and until 2026-11-21 their compare result was written as f32 bits, which read as 0 in the low half. Checked by tests/test_translate.py (test_depth_compare_sample_result_width) and GPU-checked with runtime/test/shaders/ps_sample_c_lz.asm (vk_texture_test dref: a D32 texture and a LESS_OR_EQUAL compare sampler) on an NVIDIA GeForce RTX 2060 SUPER (Linux, driver 620.70.06): 4096/4096 pixels exact for f32 and d16; with the old translator the d16 result read 0 in the 2048 pixels whose compare passes.
Images and samplers (core) Bindless. Set 0: binding 0 = 2D sampled images, 1 = samplers, 2 = descriptor hash table (storage buffer), 3 = 2D-array images (cube textures are bound here as 6-layer 2D-array views, cube arrays as 6N layers: the shader already selected the face with v_cube*), 4 = r32ui storage images, 5 = 1D, 6 = 3D. A cube sample's s and t come in [1, 2] and its third coordinate is 8·slice + face, as the hardware takes them (Mesa ac_nir_lower_tex_coords.c, LLPC ImageBuilder.cpp); the view is read at (s − 1, t − 1), layer 6·slice + face. GPU-checked with runtime/test/shaders/ps_cube_sample.asm (vk_texture_test cube). For a native Metal path, tools/spirv_metal_set0.py sizes set 0's runtime arrays from vulkan_bindless.h and moves each binding to its own argument-buffer ID range (binding b starts at the capacities of bindings 0..b-1 added up), to convert with SPIRV-Cross --msl-decoration-binding: SPIRV-Cross 1.4.363.0 otherwise puts every runtime array at one ID and comments all but one out as "Overlapping binding" (SHADER-161). cs_imgstore converted this way writes all 3×64 texels correctly in a native Metal dispatch on an Apple A18 Pro.
Typed buffer loads The format is V# word3[18:12] (GFX10_FORMAT, from Mesa's gfx10-rsrc.json, saved as tools\gfx10_formats.json). Supported: f32 ×1–4, u32 ×1–4, i32 ×1–4 (formats 21/63/73/76), f16 ×1/2/4, unorm8 ×1/2/4, snorm8 ×1/2/4, uint8 ×1/2/4, sint8 ×1/2/4, unorm16 ×1/2/4, snorm16 ×1/2/4, uint16 ×1/2/4, sint16 ×1/2/4, 10-10-10-2 and 2-10-10-10 unorm. Others give 0. The 8- and 16-bit UINT/SINT formats 5, 6, 11, 12, 18, 19, 28, 61 and 70 were missing until 2026-11-22 and read 0: UINT channels zero-extend, SINT channels sign-extend, d16 packs them as 16-bit integers, measured natively on gfx1036 (wave32 and wave64) with tools/hw_oracle and checked word for word by tests/semantic/test_buffer_format_narrow_int.py; GPU-checked by runtime/test/shaders/cs_fmt_int_narrow.asm, whose 136 expected words are the same program run natively on gfx1036 (exact on an RTX 5080 and on the gfx1036 iGPU through Vulkan). Full-width SINT accesses preserve integer bits. D16 SINT loads saturate to signed 16-bit and D16 stores sign-extend, covered by the synthetic cs_fmt_sint32.asm readback. DST_SEL swizzle is applied (0→0, 1→1.0f for float/norm or integer 1 for UINT/SINT, 4..7→X..W). Missing channels repeat the format's own (component c = c mod n), measured on an RX 6700 (SHADER-86). UNORM/SNORM give the correctly rounded quotient by (2ⁿ−1), as the hardware does (0 mismatches vs hardware over 395,776 conversions on that GPU). It is built with integer ops (Gen.norm_bits): x/(2ⁿ−1) in binary is x's bits repeated, so a 64-bit multiply by the repeat pattern, FindUMsb and the round bit give the f32 exactly (the tail never ends, so there are no ties). OpFDiv is not enough on the GPU: Vulkan allows it 2.5 ULP, and on an RX 6700 (AMD Windows 26.11.2) and an RTX 5090 it returned the reciprocal-multiply bits (8_UNORM 130/256 exact, #599). Checked against exact values in tests/semantic/test_norm_decode.py (every value up to 8 bits, edges and the reciprocal-multiply misses for 10, 15 and 16 bits). 8_SNORM (2), 16_SNORM (8) and 8_8_SNORM (15) were missing until 2026-11-22 and decoded to 0. Format names list the channel widths from the top bit, so 2_10_10_10 (50) is R10G10B10A2 and 10_10_10_2 (44) has a 2-bit x (Mesa gfx10_format_table.py, ac_formats.c). Until 2026-11-22 the two were swapped, in stores too. Until 2026-11-21 an element that started mid-dword re-read dword 0 for its tail (need was ceil(size/4) and only the first dword was shifted); loads now take need = ceil((byte_shift + size) / 4) dwords and shift the whole window so the packed stream starts at the element (FUZZ-5, leftover from #234). The 10:10:10:2 order is checked by cs_fmt_1010102 in tests/semantic/test_value_semantics.py (the shader decodes the format, so a GPU run can't check it). Mid-dword spanning elements are checked by tests/semantic/test_buffer_load_format.py (CrossingDwordBoundary); repeat / UNORM / DST_SEL 1 by the SHADER-86 cases in the same file. The _xy and _xyz forms (buffer and tbuffer) are GPU-checked by cs_fmt_xy_xyz.asm, whose words were measured natively on a Radeon 680M (gfx1035, RDNA2): they write only their 2 or 3 VGPRs, and missing channels repeat there too (TEST-185).
Descriptor hash table uint mask; entries[mask+1] of 10 uints: key[0..7], index, pad. The key is a T# or a padded S#. FNV-1a over the eight key words selects the first slot. The shared SPIR-V lookup probes up to eight slots and returns index 0 on a miss. The runtime supplies a fallback at index 0 and maps live descriptor keys to bindless indices. Outside the wave64 emulation, the lookup's result goes through OpGroupNonUniformBroadcastFirst before it indexes the image or sampler array. The lookup key words come from SGPRs, so every invocation in a subgroup has the same index; the broadcast is an identity on all drivers and marks the value uniform for the compiler. It declares GroupNonUniform and GroupNonUniformBallot, without a shuffle capability or subgroup-lane input. The shader index records the capabilities; its features field lists optional Vulkan device features. Mesa ANV 26.2.7 on an Intel Alder Lake-S UHD (Xe-LP, Linux) segfaults in vkCreate*Pipelines on a sampler index taken straight from the probe loop when that sampler serves both a float and an integer image (cs_sample_lz_int_d16, ps_ssharp); with the broadcast both pass. Checked by tests/test_desc_cache.py (test_lookup_result_is_broadcast_before_use).
3D explicit-gradient texture samples For image_sample_d and image_sample_d_cl on a 3D view, the first six address VGPRs contain dP/dx.xyz and dP/dy.xyz. XYZ and the optional minimum LOD follow. With a16, the six derivative VGPRs still hold f32; the following two words contain packed f16 coordinates and the optional clamp. The hand-written tests/semantic/fixtures/volume_gradients.asm checks the source registers of both gradients, coordinates and clamp. LLVM gfx1030 assembles all four forms and their modules validate for Vulkan 1.2. LLVM GFX10 address sizing and SPIR-V Grad operands
image_sample_c_l Scalar 2D depth comparison (dmask:0x1) takes the f32 reference, XY coordinates and explicit mip in that order. Under A16 the reference stays full-width; XY share a VGPR and LOD uses the next low half. D16 returns the comparison in the low half of the destination. Confirmed against LLVM AMDGPU's llvm.amdgcn.image.sample[.a16].dim.ll lowering and synthetic Vulkan 1.2 modules in test_explicit_mip_depth_compare.
Packed sample addresses GFX10 image_sample_d with a16 keeps the non-G16 gradients as f32 and packs the following coordinates as f16 pairs, following LLVM's GFX10 operand layout. test_a16_sample_gradients_use_full_vgprs checks the emitted gradient operands, and ps_texture_grad_a16 checks coordinate selection with a single-mip texture on RTX 5080. The same holds for every extra argument before the coordinates (LLVM getAddrSizeMIMGOp: one word each, then the gradients, then the packed halves; llvm-mc takes v[0:2] for a 2D image_sample_c_b ... a16): an image_sample_b bias keeps its VGPR with the f16 in the low half, an image_sample_c_lz z-compare its f32 VGPR, and image_sample_d_cl its four f32 gradients, with the clamp the half right after the coordinates (an f16 pad may follow it). Until 2026-11-21 those were unpacked as pairs too, and the clamp was taken from the last half. GPU-checked on an NVIDIA GeForce RTX 2060 SUPER (Linux, driver 620.70.06) with ps_texture_bias_a16, ps_sample_c_lz_a16 (vk_texture_test dref_a16) and ps_texture_grad_cl_a16, which draws on the --two-mip texture with the clamp 0 on the left half and 1 on the right: 4096/4096 pixels exact each. The old reading got 4,032 bias pixels and both depth-compare results in 2,048 pixels wrong, a clamp taken from the pad read mip 1 on the left half, and the sample without its clamp mip 0 on the right half (2,048 pixels each).
Vertex fetch s_swappc_b64 at the start of a VS calls a driver-generated fetch program that isn't in the blob. It's replaced by Vulkan vertex inputs: each ISG1 input-signature element (DXBC container) becomes an input at location = its D3D input register, typed by its component type, and is written to v(4 + 4·register + component). That rule was checked over all 788 fetch-calling shaders: in 783 every read-before-write VGPR is predicted by it (715 exact). Reads of components the element doesn't declare (e.g. .w of an xyz position, 3 VS) are allowed: the fetch returns the format defaults (0, 0, 1), and Vulkan fills a vec4 input from a narrower format the same way. Inputs are declared as vec4. The runtime must bind vertex buffers by the game's D3D12 input layout, location = input register.
PS system inputs v0–v1 = barycentrics (consumed by v_interp, which becomes attribute inputs). v2.. = the SV_Position components the shader reads, packed in order. Verified on 2,531 of 3,000 PS: the VGPRs they read before writing equal exactly the position components their input signature reads. Filled from FragCoord: xy/z directly, and w directly too, because AMD's position-w register holds 1/w (Mesa lowers load_frag_coord_w_rcp straight to frag_pos[3], ac_nir_lower_intrinsics_to_args.c), the same as Vulkan's FragCoord.w. Front face follows the used position components when the signature declares SV_IsFrontFace, as ±1.0 (Mesa: load_front_face = front_face > 0). Only enabled inputs are packed, in hardware order (Mesa radv_shader_args.c: barycentric pairs, POS_X/Y/Z/W, FRONT_FACE, ANCILLARY, SAMPLE_COVERAGE, POS_FIXED_PT). That explains the earlier "unverified" shaders: 102 read pos.xy + front face, and 76 read pos.x/y/w + front face. Raw barycentric reads (321 PS, e.g. v_readfirstlane_b32 s41, v1): AMD interpolates P = P0 + i(P1 − P0) + j(P2 − P0), so i/j are the weights of vertices 1/2, which is BaryCoordKHR.y/.z (VK_KHR_fragment_shader_barycentric). GPU-checked with runtime/test/shaders/ps_bary.asm: raw i/j equal the interpolated weights on every pixel. The pair is perspective-center, the only pair this layout models; that holds for every corpus PS (row "PS interpolation modes"). A PS that reads any other unexplained register inside the system-input range is still rejected (none left in the corpus). Reads past the last hardware input are values undefined on some path, so zero stands in for them. All register arrays start at zero, so translated shaders are deterministic.
Inputs and outputs VS: legacy (non-NGG) hardware VS, measured over all 2,236 (scripts/vs_input_survey.py): no exp prim, no s_sendmsg (so no GS_ALLOC_REQ) and no v_mbcnt in any of them, and every one exports pos0 and param. The input VGPRs are Mesa's GFX10 legacy-VS layout (radv_shader_args.c, declare_vs_input_vgprs, not is_ngg): v0 = vertex id, v1 unused, v2 = primitive id, v3 = instance id. On entry no VS reads v1 or v2; 788 start with the fetch call (see Vertex fetch) and read the fetched attributes from v4 up, and of the other 1,448, 1,052 read v0 only, 386 v0 and v3, and 10 neither (NGG would have put the VS inputs at v5/v8, after five GS VGPRs). Both ids are zero-based on the hardware: v0 excludes the draw's base vertex and v3 its first instance (Mesa ac_nir_lower_intrinsics_to_args.c: vertex_id is load_vertex_id_zero_base, instance_id is load_instance_id; the bases come in the base_vertex / start_instance SGPRs). Vulkan's VertexIndex / InstanceIndex include firstVertex/vertexOffset / firstInstance, so the translator seeds v0 = VertexIndex - BaseVertex and v3 = InstanceIndex - BaseInstance (DrawParameters, device feature shaderDrawParameters, in every VS's features). GPU-checked with runtime/test/shaders/vs_base_ids.asm (VKH_DRAW=16,7): 0x101 on every pixel, where VertexIndex/InstanceIndex alone gave 0x7111. exp pos0 → Position, exp pos1..pos3 → ClipDistance / CullDistance (and Layer/ViewportIndex in VS when pos1 is the misc vector), exp paramN → location N. RDNA2/GFX10 packs clip distances before cull distances contiguously across 4-component pos exports (up to 8 floats total), starting at pos2 when a misc vector (PointSize, EdgeFlag, ShadingRate, Layer, ViewportIndex; GFX9+ packs Layer in z[10:0] and ViewportIndex in z[19:16]) occupies pos1, and at pos1 otherwise (Mesa src/amd/common/nir/ac_nir_prerast_utils.c: ac_nir_export_position; AMD LLPC lgc/lowering/LowerInOut.cpp: LowerInOut::visitReturnInst). Slot assignment follows the DXBC OSG1 signature (SV_ClipDistance = 2, SV_CullDistance = 3, SV_RenderTargetArrayIndex = 4, SV_ViewportArrayIndex = 5, SV_ShadingRate = 23), ordered by (semantic_index, register, component) with clip before cull; when OSG1 is absent (or declares none of those system values), pos1..pos3 exports are discarded. PS: v_interp_* attribute N → input location N. exp mrtN → location N, exp mrtz x → FragDepth.
16-bit results From Mesa ACO (aco_ir.cpp: instr_is_16bit, can_use_opsel) for GFX10: f16 VOP1/VOP2 ops (v_add/sub/subrev/mul/max/min_f16, v_fmac_f16, v_cvt_f16_f32, f16 unary) and opsel-capable VOP3 ops (v_fma_f16, _e64 forms of the 16-bit integer ops) are partial writes that keep the high half. The VOP2 (_e32) 16-bit integer ops (v_lshrrev_b16…) define the whole register, so the high half is modelled as zero. An op_sel destination bit writes the high half. The translator used to clear the high half on f16 ops; that's fixed. op_sel on f16 VOP3 ops (v_fma_f16, v_med3_f16, v_add/sub/subrev/mul/max/min_f16, f16 unary, v_fmac_f16): bit i (i < number of sources) reads the high half of source i, the last bit writes the high half of the destination; neg/abs apply to the selected half. Source: Mesa ACO can_use_opsel and the RDNA2 ISA VOP3 OP_SEL field. Checked by the structural tests in tests/test_f16_op_sel.py (which half is read, where the result goes) and the value tests in tests/test_f16_op_sel_values.py. Hardware-verified on an AMD RX 6800 (gfx1030), the instructions run as a raw compute kernel in wave32 and in wave64 (IEEE off, DX10 clamp on, denormals kept, round to nearest; the bytes assemble identically for gfx1013 and gfx1030): v_med3_f16 with all 16 op_sel patterns, with neg/abs on a selected high half, with clamp, and with the destination also a source; the plain forms v_add/sub/mul/max/min_f16 (_e32, and _e64 with neg/abs/clamp), v_fmac_f16 (_e32, and _e64 with neg/abs; the accumulator is the low half of the destination), v_rndne/floor/ceil/trunc/fract/sqrt/rcp/rsq_f16 (_e32 and _e64) and v_cvt_f16_f32: low halves in, low half out, high half of the destination kept. 336 words per wave size (plus v_rsq_f16_e64 and v_ceil_f16_e64 in a later run), all as the rule says and as the translator computes. Vulkan (AMD Radeon RX 6800, Windows, driver 26.11.2; the nine ps_f16_* fixtures also pass on an NVIDIA RTX 4050 Laptop and an AMD Radeon 740M (RADV), both Linux): ps_f16_med3_opsel, ps_f16_med3_mods, ps_f16_vop2, ps_f16_vop2b, ps_f16_vop1, ps_f16_vop1b, whose expected words are the hardware ones (tests/test_f16_hw_words.py checks them against the rule and the translator without a GPU). Not expressible, so not verified: op_sel on the VOP2 and VOP1 ops in VOP3 encoding (v_add/sub/mul/max/min_f16_e64, v_fmac_f16_e64, the unary _e64 forms, v_cvt_f16_f32_e64): llvm-mc 21 rejects the modifier for gfx1013 and gfx1030, and its disassembler prints bytes that have those bits set without it (03 08 32 d5 01 05 02 00 comes back as v_add_f16_e64 v3, v1, v2). The translator's op_sel handling for these forms is therefore never reached from a disassembly listing and rests on the ISA field description alone; whether the hardware honours the bits there is unknown, and a blob that set them would be translated as if they were clear. Also unverified: NaN and denormal operands, other rounding and IEEE modes, outside the f16 transcendentals (measured, see the f16 transcendentals row). Driver quirk (AMD Windows driver 26.11.1, RX 9070): valu_fuzz f16 seed 3 programme 38 loses the high half of v26: v_add_f16_e32 v26, v29, v32 then v_sub_nc_u16_e64 v28, v32, v27 op_sel:[1,1,0] then v_add_f16_e64 v26, v26, v28 — the final add should keep 0xCD52 in the high half, but the GPU returns 0xEEEEEEEE (native) / 0x00000000 (--emulate), all 64 threads. Bisected to the pair: the add's two sources must both have been produced by earlier partial writes; either alone, a NaN input alone, or dst==src0 alone all pass. The emitted SPIR-V was checked with spirv-dis in both modes: the keep (load old v26, AND 0xFFFF0000, OR new low half, store to index 26) is present and correctly addressed, so the translator is clear and this is the driver miscompiling the pattern. Minimal reproducer: the three ops above with programme 38's inits (v26 0xCD524000, v28 0xC692D243, v29 0xBC004200, v32 0xB35ABD4B, v27 0xB48ABA06). Pinned by tests/test_values.py (v_add_f16_e64_keep_hi, v_add_f16_e32_keep_hi), which check the translator's keep, not the driver. Found and bisected by 1TrickOmen, reported on #634.
16-bit SDWA result with dst_sel:DWORD A 16-bit op in SDWA form (v_add/sub/subrev/mul/min/max_f16_sdwa, the f16 unary ops, v_cvt_u16_f16, v_cvt_i16_f16, v_cvt_f16_u16, v_cvt_f16_i16) with dst_sel:DWORD writes the whole VGPR: the 16-bit result zero-extended, whatever dst_unused says. The keep-the-high-half rule of the row above is for the non-SDWA forms only; with dst_sel:WORD_0 dst_unused:UNUSED_PRESERVE the high half is kept as usual. Until 2026-11-22 the translator kept the high half for dst_sel:DWORD (Gen.insn marked an SDWA destination only for a dst_sel other than DWORD). Measured natively on an AMD Radeon iGPU (gfx1036, RDNA2, Windows driver 26.10.1) with python -I tools/sdwa_diff.py --oracle hw (#2113) and with the program of runtime/test/shaders/ps_sdwa_dword_hi.asm through tools/hw_oracle: destinations 0xdeadbeef give 0x00004000 (v_add_f16, PRESERVE), 0x00000003 (v_cvt_u16_f16, PAD), 0x00004700 (v_cvt_f16_u16, PRESERVE), 0x0000c000 (v_mul_f16, SEXT); the same ops with dst_sel:WORD_0 UNUSED_PRESERVE give 0xdead4000, 0xdead0003, 0xdead4700, 0xdeadc000. GPU-checked through Vulkan with ps_sdwa_dword_hi.asm on an RTX 5080 (driver 616.92) and the same Radeon iGPU (4096/4096 pixels each); CPU-checked in tests/semantic/test_value_semantics.py.
f16 inline constants An inline float constant (0.5, 1.0, 2.0, 4.0, their negatives, 0.15915494) in an operand of a 16-bit float op is the f16 value in the low half with a zero high half, not f32 bits (the translator used to unpack the f32 pattern, whose low half is 0, so v_add_f16 d, 1.0, v added 0.0). Measured on an AMD RX 6800 (gfx1030) raw kernel, wave32 and wave64: v_add/mul/max_f16, v_sub_f16_e64, v_fma_f16, v_fmac_f16, v_rcp_f16, v_med3_f16, v_cmp_lt_f16, v_cvt_f32_f16 (0.5 gives 0x3f000000), v_cos_f16, v_pk_add_f16/v_pk_mul_f16 (the high result half sees 0.0), v_pack_b32_f16; 0.15915494 is 0x3118; the high half op_sel selects from a constant reads +0.0 (v_med3_f16, v_fma_f16, v_pack_b32_f16, v_pk_add_f16 with swapped halves). GPU tests ps_f16_const, ps_f16_const2 and ps_f16_pack (Vulkan: AMD Radeon RX 6800, Windows, driver 26.11.2; all three fail without the fix). Constants in v_fma_mix_f32/v_fma_mixlo/mixhi_f16 operands follow the same rule per operand (measured on an RDNA2 iGPU, gfx1036, SHADER-135): f32 bits where op_sel_hi makes the operand f32, the f16 constant with a zero high half where it makes it f16, so op_sel with op_sel_hi reads +0.0; an integer constant is its 32-bit integer. The translator gives the same words for the float constants in every op_sel/op_sel_hi combination and for the integer constants as f16 halves, but not for 1 and 64 as f32 operands: their bits are f32 denormals, which gfx1036 flushes to a zero of their sign (denorm_mode_32 = 0, the MODE the translator assumes for the game) and the translator keeps (difference 4 in docs/shader_validation.md, "f16 output modifiers, clamp and v_fma_mix* operands on RDNA2").
v_fmamk_f16, v_fmaak_f16 VOP2 with a literal K: fmamk computes D = S0 * K + S1 (printed vdst, src0, K, vsrc1), fmaak computes D = S0 * S1 + K (printed vdst, src0, vsrc1, K). In print order both are a[1] * a[2] + a[3], as for v_fmamk/fmaak_f32. K is the f16 in the literal's low 16 bits; a float literal is converted to f16 (src_h). One rounding to f16, as v_fmac_f16 (SHADER-55). The GFX10 f16 VOP2 write puts the result in the low half and keeps the high half. Until 2026-11-22 both raised Unsupported. CPU-checked by tests/semantic/test_valu_fmamk_fmaak_f16.py, against v_fma_f16 with K in a VGPR (value grids, a float literal, the operand order, seeded values). Not GPU-verified.
SDWA select on an f16 inline constant In an _sdwa 16-bit float op, an inline float constant is first the f16 value over a zero high half (row above) and src0_sel/src1_sel then narrows those 32 bits like a register's, zero-extended, before neg/abs and the op: 1.0 under WORD_1 reads +0.0, 2.0 under BYTE_1 reads the f16 denormal 0x0040. An SGPR source, and an integer op reading the f32 bits of a float constant (v_cvt_f16_u16_sdwa d, 1.0 src0_sel:WORD_1 converts 0x3f80), are narrowed the same way. Until 2026-11-22 the translator used the whole f16 constant (v_add_f16_sdwa d, 1.0, v src0_sel:WORD_1 with v = 0.5 gave 1.5). Measured on an AMD Radeon iGPU (gfx1036, Ryzen 9 9950X3D, driver 26.10.1) with tools/hw_oracle (raw HIP kernel, wave32): the four words of runtime/test/shaders/ps_sdwa_f16_const.asm; found with python -I tools/sdwa_diff.py --oracle hw (#2113). GPU test ps_sdwa_f16_const, 4096/4096 pixels on an NVIDIA GeForce RTX 5080 (driver 616.92) and the same Radeon iGPU through Vulkan; both fail without the fix. Also executed by tests/semantic/test_value_semantics.py.
v_pack_b32_f16 input neg A VOP3 neg on an operand of this instruction flips the sign bit of the 16-bit half that operand contributes, not of the whole 32-bit source, and only that half: measured on gfx1036 (RDNA2 iGPU, AMD Windows driver 32.0.21044.64) with 192 raw kernels, 0x7c01 gives 0xfc01 under IEEE mode 0 and 0xfe01 under mode 1, in either half and with op_sel. The translator moved the bits unchanged and refused every modifier; it now XORs 0x8000 into the selected half. abs is still refused, because its rule on this instruction is unmeasured (SHADER-260), and the mode-1 quieting of a signalling-NaN half is not modelled while SHADER-190 is open; under mode 0, where the bits move unchanged, the translation is exact. Checked on the CPU by tests/test_values.py and tests/semantic/test_vop3_const_mods.py; the gfx1036 measurement above is @Sanonymous01's, not repeated here.
Packed 16-bit integer ops (v_pk_add/sub_u16/i16, v_pk_mul_lo_u16, v_pk_mad_u16/i16, v_pk_max/min_u16/i16) VOP3P: result half 0 takes each source's half from op_sel[i], result half 1 from op_sel_hi[i] (defaults [0,..] and [1,..]), as for v_pk_lshlrev_b16. Each half is computed on its own and wraps to 16 bits. clamp (add, sub, mad) saturates the half to its type's range; the exact value fits in 32 bits. neg_lo/neg_hi are float-only and raise Unsupported, as does clamp on the other ops. A constant operand is treated as a 32-bit dword C: op_sel[i] == 0 selects bits [15:0], op_sel[i] == 1 selects bits [31:16]. Positive inline constants zero-extend (5 → 0x00000005), negative inline constants sign-extend (-1 → 0xFFFFFFFF, -16 → 0xFFFFFFF0), and 32-bit literals retain their full dword (0x12345678). Lowered via OpBitField*Extract at 16 * sl[i]. Until 2026-11-22 reading the high half of a constant raised Unsupported. A constant operand reads as its low 16 bits. Its high half under op_sel/op_sel_hi is not measured for integer ops (for f16 constants it reads +0.0, see the row above), so a constant whose high half would be read raises Unsupported instead of guessing; the compiler's usual form, op_sel_hi:[1,0] with the constant second, reads only the low half. Until 2026-11-22 all eleven ops raised Unsupported. CPU-checked by tests/semantic/test_alu_pk_int16.py (value grids, seeded mad, op_sel/op_sel_hi combinations, clamp including the unsigned sub floor, inline and literal constants, rejected forms). Hardware-verified on RDNA2 (gfx1035, Windows 11, driver 26.5.1, wave32 & wave64 via tools/int_hw_probe.py --oracle both --group valu_pk_int16, and independently on gfx1036 desktop APU, Windows 11, driver 32.0.21045.29003, across 380 raw compute kernels covering all 11 ops, constants under op_sel/op_sel_hi, clamp, and wave32/wave64 parity with 0 wave diffs and 0 mismatches): all eleven ops (wrap, clamp saturation on add/sub/mad, and constant op_sel/op_sel_hi) match bit-for-bit. Hardware-verified on RDNA2 (gfx1035, Windows 11, driver 26.5.1, wave32 & wave64 via tools/int_hw_probe.py --oracle both --group valu_pk_int16): all eleven ops (wrap, clamp saturation on add/sub/mad, and op_sel/op_sel_hi) match bit-for-bit.
v_sin_f32, v_cos_f32, v_sin_f16, v_cos_f16 The operand is an angle in turns (the ISA says valid over +-256; the measurement below finds no such limit on gfx1030). turn_angle reduces it in turns first, x - RoundEven(x) (exact in binary32, in [-0.5, 0.5]), then scales by 2*pi and calls Sin/Cos, so the angle stays in [-pi, pi], the only range where GLSL guarantees them (2^-11 absolute). Scaling first rounded the fractional turn away (about 1.2e-4 rad near 255 turns, #594); the first fix (#1283) reduced with Fract, which rounds `1 -
v_pack_b32_f16 source modifiers A VOP3 abs or neg on an operand of this instruction acts on the 16-bit half that operand contributes, not on the whole 32-bit source, and only on that half: abs clears bit 15 and neg flips it, abs first, both as plain bit moves — the operand is not converted to a float. Until 2026-11-22 any such operand was rejected as Unsupported. neg is measured on gfx1036 (RDNA2 iGPU, AMD Windows driver 32.0.21044.64) with 192 raw kernels: 0x7c01 gives 0xfc01 under IEEE mode 0 and 0xfe01 under mode 1, in either half and with op_sel, so the sign move does not depend on the mode. **abs and - **neg, abs, and - abs rests on the ISA's definition of ABS on a float operand as the sign clear, applied before neg; no hardware run of this instruction with abs exists yet, and abs on a NaN half is therefore unmeasured too. Not modelled: IEEE mode 1 also quiets a signalling-NaN half (0x7c01 → 0x7e01); which mode the game's shaders run in is SHADER-190, and under mode 0, where the bits move unchanged, the translation is exact. Checked by tests/test_values.py, tests/semantic/test_vop3_const_mods.py, tests/semantic/test_pack_b32_f16_mods.py (exact bits through the interpreter) and the GPU fixture ps_f16_pack_mods (words derived from the rule, not a readback); the gfx1036 measurement above is @Sanonymous01's, not repeated here.
Packed integer dot products (v_dot2_i32_i16, v_dot2_u32_u16, v_dot4_u32_u8, v_dot8_i32_i4, v_dot8_u32_u4) and v_pk_fmac_f16 RDNA2 ISA: v_dot2_i32_i16/u16 (2×16-bit), v_dot4_u32_u8 (4×8-bit unsigned), and v_dot8_i32_i4/u4 (8×4-bit) extract each element with OpBitFieldSExtract/OpBitFieldUExtract, sum the elementwise products with S2 wrapping at 32 bits, and saturate to [INT32_MIN, INT32_MAX] / [0, UINT32_MAX] under VOP3P clamp (signed carry tracking handles the v_dot2_i32_i16 (-32768)^2 + (-32768)^2 + S2 overflow/cancellation edge). The hardware default op_sel:[0,0,0] and op_sel_hi:[1,1,1] (whether omitted or written explicitly) is accepted; any other op_sel/op_sel_hi (such as op_sel_hi:[0,0,0] or [0,1,1], which select the low half for lane 1 on v_dot2_*), neg_lo/neg_hi, DPP/SDWA forms, and source neg/abs raise Unsupported. (v_dot4_i32_i8 and v_dot4c_i32_i8 are covered separately in the Signed-byte dot products row, #1754.) v_pk_fmac_f16 (VOP2) unpacks src0, vsrc1 and vdst as f16x2 (Gen.src_h, so inline float constants apply in the low half with +0.0 high), computes fma(src0[k], vsrc1[k], vdst[k]) per half with single f16 rounding (Gen.fma_f16_odd, SHADER-55), and packs with Gen.f16_pack2; any modifier outside _dpp or non-VGPR vdst raises Unsupported, and v_pk_fmac_f16 marks vdst as read before write in read_before_write_vgprs and reg_reads_writes. Until 2026-11-22 all six ops raised Unsupported. Hardware-confirmed on RDNA2: on gfx1036 (Ryzen 9 7950X3D iGPU, tools/hw_oracle, @aslan2142), all 60 integer dot-product sets (plain, swapped/SGPR sources, and clamp) match bit-for-bit, all measured op_sel/neg_* variants are refused, and all 22 v_pk_fmac_f16 default-MODE (0x000003C0: round-to-nearest-even, f16 denormals kept, IEEE and DX10_CLAMP on) words match in both source orders (all 34 non-NaN halves bit-exact; the 10 NaN halves yield quiet f16 NaN, as SPIR-V does not preserve NaN payload bits or sign); independently confirmed on gfx1035 (Radeon 680M, tools/hw_oracle, @Youssefrah16) across 18 cases × wave32/wave64 (36/36 bit-exact). Pinned by tests/semantic/test_alu_dot_pk_fmac.py (all 82 gfx1036 measured tables plus hand-written .asm fixture, boundary/clamp cases, default/non-default op_sel/op_sel_hi, read_before_write_vgprs/reg_reads_writes, DPP, seeded sweeps, and rejected forms). Non-default f16 MODEs (denormal flush, RTZ) are not modelled on v_pk_fmac_f16 while the translator has no MODE input.
v_med3_f32 output modifiers The translator applies mul:2, mul:4 or div:2 to the median before clamping to [0, 1], following LLVM’s modifier order. The finite-input fixture ps_med3_mods.asm produced 4,096 exact pixels on an Apple M3 Max with MoltenVK and on Mesa llvmpipe (software Vulkan); it also passes (4,096/4,096) on an NVIDIA RTX 4050 Laptop and an AMD Radeon 740M (RADV), both Linux, and on an RTX 2060 SUPER per #634. This uses the existing float MODE assumptions described above.
v_div_fmas_f32, v_div_fmas_f64 Scaled FMA for IEEE-754 division (VOP3): D = VCC[lane] ? (2^32 * fma(S0, S1, S2)) : fma(S0, S1, S2) for f32 and 2^64 (OpCapability Float64) for f64. When VCC is set and the operands cannot overflow under pre-scaling (|S0|, |S1| < 2^110 and |S2| < 2^95 for f32; < 2^990 and < 2^958 for f64), the operands are pre-scaled before Fma (S0·2^16, S1·2^16, S2·2^32 / S0·2^32, S1·2^32, S2·2^64) so tiny intermediates (e.g. 2^-75 · 2^-75 → 2^-118 in f32, 2^-540 · 2^-540 → 2^-1016 in f64) do not underflow before scaling; otherwise post-FMA scaling is used. VOP3 input (abs/neg) and output (mul:2/mul:4/div:2, then clamp) modifiers apply via clamp_mods / clamp_mods_f64. Source: AMD RDNA 2 ISA reference (V_DIV_FMAS_F32, V_DIV_FMAS_F64) and LLVM VOP3Instructions.td. Not measured on RDNA2 hardware (translated GPU output checked on RTX 5070 by @duudiis). Checked on the CPU (spirv_mini_interp for f32 with VCC 0/1, tiny-intermediate fused scale, and modifiers) and with spirv-val (f32 and f64) by tests/semantic/test_alu_div_fmas.py; not run on the shader corpus.
POPS Primitive-ordered pixel shading (10 PS, src_pops_exiting_wave_id wait loop, s_sleep, MSG_ORDERED_PS_DONE) becomes fragment-shader interlock (PixelInterlockOrderedEXT). It begins at the end of the entry block and ends at shader exit: a longer critical section with the same ordering. src_pops_exiting_wave_id reads 0, and the runtime must put 0 (no collision, bit 31 clear) in the POPS collision SGPR, so the hardware wait loop is skipped. Needs VK_EXT_fragment_shader_interlock (fragmentShaderPixelInterlock).
Coherent image accesses (glc) On GFX10 a device-scope (coherent) load is glc dlc and a device-scope store glc: Mesa sets exactly these bits for ACCESS_COHERENT (ac_get_hw_cache_flags, GFX10–10.3 branch). In the corpus only the 10 POPS pixel shaders use them: 30 image_load ... glc dlc and 50 image_store ... glc, all 2D, and in each shader the 3 T#s it loads are the 3 it stores, a read-modify-write of its ordered images. A glc image_load therefore reads the storage view the stores write (OpImageRead on binding 8 + 3·dim + class, the class picked from the T# FORMAT as for stores), not the sampled array of "Typed image loads": a sampled read has no coherent form in SPIR-V, and between critical sections the fragment-shader interlock only makes coherent memory visible (Vulkan memory model: non-atomic accesses are private unless Coherent; ARB_fragment_shader_interlock: stores to coherent memory in one critical section are visible to reads in the next). A shader with a glc image load or store decorates its storage views Coherent, as vkd3d-proton's dxil-spirv does for rasterizer-ordered views (dxil_converter.cpp: "ROV implies coherent"). These 10 modules need shaderStorageImageReadWithoutFormat (listed in their index features); every other image_load keeps the sampled path and needs no storage feature (SHADER-151). dlc alone is a CU-scope load and stays non-coherent; glc on a sampled read (image_sample*, image_gather*, image_load_mip) or on a dimension without storage views (cube) is Unsupported. Until 2026-11-22 the coherent loads read the sampled array and nothing was Coherent, so a POPS read could miss the previous fragment's store. Confirmed by these references, tests/semantic/test_image_coherent.py (each read and write's view and type, decorations, capabilities, index features; 7 of its 10 tests fail on the old translator) and a corpus count; not GPU-checked: a stale read is a cache race no deterministic test forces.
2D image_sample_lz The T# FORMAT selects the float, UINT or SINT sampled view at LOD zero. With nearest sampling, native gfx1036 returned the original 32-bit integer components. RTX 5080 and gfx1036 Vulkan readbacks matched all four channels on RGBA8 UINT, SINT and UNORM for full-width and D16 results. The R32 UINT/SINT saturation-boundary fixture also matched all 64 sampled sums on both adapters.
2D image_sample_l The T# FORMAT selects the sampled image type, and every type uses the LOD following the two coordinates. Vulkan requires the sampled type and signedness to match the view. The CPU test in tests/test_image_load_typed.py checks the R32 UINT, SINT and FLOAT descriptor branches, the float fallback on a lookup miss and the LOD register with full-width and D16 results. Vulkan sampling validation
Implicit 2D pixel-shader integer samples For image_sample, take the UV derivatives before branching on the T# format, then sample the matching float, UINT or SINT view with those gradients. In ps_sample_implicit_sint a 128×128 signed texture minifies onto 64×64 pixels. Clamping the sampler to level 0 returned four color quadrants; allowing level 1 returned cyan. All four signed D16 channels matched at every pixel on RTX 5080 and gfx1036.
Texel offsets image_sample*_o: the first address dword packs signed 6-bit offsets (x [5:0], y [13:8], z [21:16]), which become the SPIR-V Offset operand. A non-constant Offset outside gather needs VK_KHR_maintenance8, and is validated with spirv-val --allow-offset-texture-operand. The operand is always a run-time value: the translator extracts the fields from the register, also when the shader loaded the dword from an immediate, so every _o sample needs the extension. image_gather4_lz_o / _l_o read x and y the same way; a gather Offset needs shaderImageGatherExtended, not maintenance8. GPU-tested with runtime/test/shaders/ps_texoff.asm on vk_texture_test (in check.py and scripts/run_gpu_tests.py; SKIP on a device without the extension), on an AMD Radeon RX 6800, Windows driver 26.11.2, maintenance8 enabled: an 8×8 texture whose texels are all different, a point sampler that clamps to the edge, 2D targets, mip 0. image_sample_lz_o with an offset computed per pixel (all 64 pairs of x, y in −4..3, none clamped), image_sample_l_o with (−3, +2) and image_sample_lz_o with (+16, −32) from immediates, and image_gather4_lz_o of red and of green with the per-pixel offset gave, on all 4096 pixels, the texels worked out by hand from this rule (derivation in the .asm header). Run with a sabotaged translator, the test fails when the sample offset is dropped, has x and y swapped, takes y from bit 6, or uses 4-bit or 5-bit fields, and when the gather offset is dropped, has x and y swapped or takes y from bit 6; 4-bit and 5-bit gather fields pass, because the gather offsets stay in −4..3. What it shows is that the translated SPIR-V implements this rule on Vulkan; it does not measure the field layout on the hardware. It cannot see the sign extension on this driver: with the fields read unsigned the same texels come back: Offset 60..63 sampled as −4..−1 and +32 as −32 (the device reports texel offset limits −64..63, gather −32..31). The sign extension and the gather field width are therefore pinned by the structural test tests/test_texel_offsets.py (signed, bit 8k, 6 bits, for _lz_o, _l_o, _o, 3D and gather) and are not GPU-tested through Vulkan. The x field is measured on hardware: image_sample_lz_o run as a raw compute kernel on the same RX 6800 (gfx1030, wave32 and wave64), on a 64×1 R32_FLOAT image whose texel i holds i, with a point sampler that clamps to the last texel: from texel 40, offset dword 0x20 reads texel 8 and 0x3c reads texel 36 (unsigned would clamp both to 63); from texel 10, 0x1f reads 41 and 0x20 clamps to 0; 0x40, 0x80 and 0xc0 read the centre texel (bits 6–7 are ignored); and a non-zero y field, z field or top byte leaves x alone. All 36 rows fit x = sign-extended bits [5:0]. The y and z fields are measured too (SHADER-337): tools/texoff_probe.py --oracle hw on the integrated GPU of a Ryzen 9 9950X3D (gfx1036, RDNA2, Windows driver 32.0.21045.16010), wave32 and wave64, samples a linear R32_SFLOAT texture whose texel holds its index (2D 64×64 for y, 3D 64×1×64 for z) with image_sample_lz_o and a point sampler that clamps to the last texel. From row 40, y = 0x20 reads row 8 and 0x3c row 36, 0x21 row 9 (unsigned would clamp all three to 63); from row 10, 0x1f reads 41 and 0x20 clamps to 0 (unsigned: 42); 0xc0 (bits 14–15 set, field 0) reads row 40 and 0x7f row 39, so those bits are ignored; x −2 with y −4 in one dword reads both. The z field at bits [21:16] gives the same 7 results on the 3D image. All 15 rows fit each field = sign-extended 6 bits, the bits above it ignored, which is the translator's rule; tests/test_texoff_probe.py checks that every row with a negative field tells the signed reading from the unsigned one. The (+16, −32) sample is outside Vulkan's guaranteed −8..7 and is judged only where the device limits cover it. image_sample_o, image_sample_b_o and image_gather4_l_o are GPU-tested with runtime/test/shaders/ps_texoff_forms.asm (the same texture, sampler and per-pixel offset as ps_texoff, all 64 offset pairs in −4..3; in check.py and scripts/run_gpu_tests.py): 4096/4096 pixels exact on an NVIDIA GeForce RTX 4090 (driver 621.24) and on the integrated GPU of a Ryzen 9 9950X3D (gfx1036, driver 32.0.21045.16010), both with maintenance8 enabled. Not GPU-tested: _c_lz_o, the z field (3D), 1D, 2D-array and cube targets (offset next to an array layer), wrap or mirror addressing, linear filtering, mips other than 0, other vendors' drivers, and a device without maintenance8 (the test skips there; the translator has no fallback for it). Without maintenance8 (--texel-offset-fallback, NVIDIA Pascal for one): an image_sample*_o gets no Offset; the offset is folded into the coordinate instead, as coordinate + offset ÷ the size of the sampled level. The level is 0 for _lz / _c_lz, the given LOD for _l, and OpImageQueryLod's for implicit samples (plus the bias for _b), floored and clamped to the image's levels. A texel offset applies before wrapping and clamping, and an integer offset commutes with both, so the shift is exact for every address mode at that level. The one case that differs is a trilinear blend of two levels, where the coarser level moves by offset ÷ 2 of its texels. Implicit samples become Grad samples with the derivatives of the unshifted coordinate (× 2^bias for _b), so the LOD and anisotropy are those of the original sample even when the offset varies per pixel. Gathers keep their Offset (shaderImageGatherExtended). Only 4 of the 12,101 PS need it, all through image_sample_o. GPU-tested on an NVIDIA GeForce GTX 1060 6GB (no maintenance8; driver 560.94, Windows 10) with LEONIDA_TEXOFF_FALLBACK=1: ps_texoff and ps_texoff_implicit (the per-pixel sample as image_sample_o) are 4096/4096 pixels exact, with the +16/−32 sample judged too, since a coordinate shift has no device offset limit. Checked in tests/test_texel_offsets.py, including spirv-val without --allow-offset-texture-operand.
A16 sample offsets For the supported image_sample*_o forms, the first address VGPR retains the signed texel-offset fields. The following coordinates and any trailing LOD use packed binary16 halves, low half first. LLVM counts extra operands as whole words before packing coordinates and LOD (getAddrSizeMIMGOp). On RTX 5080 and Radeon Graphics, ps_texoff.asm checked 64 distinct offsets applied to packed U/V at texel (3,5) against the expected texel for each of 4096 pixels. Swapping the halves or dropping the offset changed 4032 pixels per GPU.
Optional device features Shaders may need fragmentShaderBarycentric, fragmentShaderPixelInterlock and maintenance8. All three are present on an RTX 4060 Ti (and an RTX 2060 SUPER), and runtime/test/vk_harness.cpp enables them when available, as does the runtime's create_vulkan_device_standalone, each with its extension (VulkanDeviceInfo::fragment_shader_barycentric, fragment_shader_interlock, maintenance8; checked by d3d12_vulkan_device_test). All three are present on an RTX 4060 Ti, and runtime/test/vk_harness.cpp enables them when available. (It is guarded by the header macro VK_KHR_MAINTENANCE_8_EXTENSION_NAME, so older Vulkan headers build without it. vk_texture_test enables it too, and shaderImageGatherExtended.) A device without fragmentShaderBarycentric (NVIDIA Pascal) runs the raw-barycentric PS with --bary-fallback (below). Shaders translated with --fma khr need VK_KHR_shader_fma and its shaderFmaFloat32 feature (VkPhysicalDeviceShaderFmaFeaturesKHR): create_vulkan_device_standalone, runtime/test/vk_test_device.h and the vk_* test programs enable it when the device offers it (VulkanDeviceInfo::shader_fma), and a test program refuses (exit 77) a module with OpCapability FMAKHR on a device without it.
Wave size Most of the game's shaders are wave64: 23,841 of 26,503 (fssm_header.wave_size(): FSSM header flags word u32[0xD4] bit 5, 0x20 = wave32, 0 = wave64; 0 contradictions against GFX10 code-proven wave32/wave64 instructions across all 26,503 blobs): 10,974 of 12,101 PS, 9,282 of 9,282 mesh shaders, 2,236 of 2,236 VS, 1,154 of 2,689 CS and 195 of 195 GS, against 2,662 wave32 (1,535 CS and 1,127 PS). A full-corpus translation at ec8ec4c9 marks exactly these 23,841 wave64 (subgroup_size 64) in the index. Before the FSSM flag (#1900) the wave size came from code markers (64-bit EXEC/mask writes, exec_hi, *_saveexec_b64): at 6a6704df they made 21,538 of the 26,487 shaders translated then wave64 (the figure quoted here was 21,545). Against the flag they call 2,287 wave64 shaders wave32 (943 PS, 1,057 VS, 287 CS), whose code has no 64-bit EXEC/mask marker, and none the other way. An older marker scan (s_mov_b64 exec, -1, exec_hi, s_and/or_saveexec_b64 and 64-bit masks) counted 9,930 PS, 8,666 mesh shaders, 1,115 VS and 923 CS. The translator maps a wave to a subgroup, and NVIDIA subgroups are 32 wide. What that means: (1) lane-independent code, which is most pixel-shader math, is exact; (2) wave-wide branch decisions and reductions are made per 32-lane half, which is exact unless scalar state computed for one half is later consumed by the other; (3) lane indices from v_mbcnt_lo/hi and wave IDs from the merged-wave SGPR must be 64-lane values. Mesh and compute shaders build thread IDs as wave_id·64 + mbcnt, so those need a mapping from LocalInvocationIndex (lane = index & 63, wave = index >> 6). Full fidelity needs either 64-wide subgroups (AMD GPUs, via VK_EXT_subgroup_size_control requiredSubgroupSize = 64) or emulating cross-half ops (ballot, readlane, shuffles across halves) through workgroup memory.
Mesh shaders NGG wave64 programs → VK_EXT_mesh_shader (MeshEXT). PSV0 (DXBC) gives NumThreads (128×1×1 in the corpus), MaxOutputVertices/Primitives (128/128) and the topology (triangles). System inputs, from Mesa's RADV setup for mesh as NGG on GFX10.3: v5 = first launch vertex ID of the lane (the "vertex_id" slot), linearGroupIndex * NumThreads + LocalInvocationIndex with the linear index from WorkgroupId/NumWorkgroups; all 9,282/9,282 corpus mesh shaders read v5 once with v_readfirstlane_b32 sX, v5 and use sX only via s_lshr_b32 D, sX, 7 to recover the group index (NumThreads is 128 in the corpus), matching TomBox's mesh ABI (gid.x * numThreads + gi) on 1D launches. GPU-checked with runtime/test/shaders/ms_v5_workgroup.asm (24/24 groups exact on RTX 4060 Ti and RTX 3080, and on an RTX 4050 Laptop and an AMD Radeon 740M (RADV)); still unverified on Xbox hardware: the low 7 bits of v5 on lanes 1..127 and whether 3D DispatchMesh flattens XYZ or uses X only. The merged-wave-info SGPR (s3 in this ABI) = wave ID << 24, from LocalInvocationIndex >> 6; v_mbcnt lanes = LocalInvocationIndex & 63; user data in s16.. as usual. 1,473 of 1,500 sampled mesh shaders read exactly v5, and the rest only add loop-carried registers. Exports: on NGG, thread t exports vertex t (pos0, paramN) and primitive t (prim). They're staged per invocation; an all-off export is the dummy a wave with no vertices must issue, and writes nothing. s_sendmsg GS_ALLOC_REQ (m0 = prims << 12 | verts, sent by thread 0) stores the counts in a workgroup variable. At shader end, in uniform control flow: workgroup barrier, OpSetMeshOutputsEXT(min(verts, max), min(prims, max)), then each thread writes its staged vertex (Position + Location N) and primitive (PrimitiveTriangleIndicesEXT = bits [8:0], [18:10], [28:20]; CullPrimitiveEXT = bit 31). pos1..pos3 clip/cull distances are staged per invocation and emitted in a per-vertex Block output struct (Position + ClipDistance/CullDistance arrays, VK_EXT_mesh_shader) when used, keeping the standalone %ms_out_pos layout unchanged for shaders without pos1+. The distances are copied to that struct one float at a time, not as a whole array: SPIRV-Cross 1.4.363.0 turns a whole-array store into a mesh output into a C array assignment that Metal rejects (SHADER-155; ms_clip then compiles and draws its 2048/4096 pixels in a native Metal mesh draw on an Apple A18 Pro). GPU-checked with runtime/test/shaders/ms_tri.asm (VKH_MESH=1 vk_harness), built from the game's own idioms (thread ID from s3 and mbcnt across two waves, thread-0 ALLOC_REQ, per-thread exports): 0 error on every pixel.
Mesh shaders as compute (--mesh-compute) For devices without VK_EXT_mesh_shader (NVIDIA Pascal, for one). Each mesh shader becomes a GLCompute module with the same workgroup size and code; only the epilogue changes. Instead of OpSetMeshOutputsEXT and the mesh outputs, after the same barrier lane 0 writes the vertex and primitive counts, lane i < vertex count writes its vertex and lane i < primitive count its primitive into this workgroup's slot of an output buffer: slot = linear workgroup index (x + y·nx + z·nx·ny) × slot_bytes, computed in 64 bits. The buffer's device address is in push-constant dwords 36–37, so these modules declare 152 bytes. Slot layout (rdna2spirv.mesh_compute_layout, recorded per shader as mesh_compute in the index), all 16-byte aligned: a header (vertex count, primitive count), then max_vertices vertices, each holding the position, the clip and then cull distances padded to whole vec4s, and one vec4 per param location; then max_primitives primitives of three vertex indices plus 1 if culled. The modules need no mesh capability, extension or shaderClipDistance. tools/mesh_compute_vs.py writes the vertex shader that draws the slots with a non-indexed vkCmdDraw(groups × max_primitives × 3): vertex v is workgroup v / (3·max_primitives), primitive (v / 3) mod max_primitives, corner v mod 3. A primitive past the count, or one culled, gets one position outside the clip volume at all three corners and is clipped. Otherwise the corner's index, clamped to max_vertices − 1, selects the vertex, and its position, distances and params go out at the mesh shader's locations, so the pixel shader is unchanged. One draw rasterizes in vertex order, which is workgroup then primitive order, as with mesh workgroups. Corpus: all 9,282 mesh shaders are 128×1×1 with 128/128 outputs, wave64, 0–18 params, clip distances in 1,906, cull distances and per-primitive attributes in none, no task shaders. On a 32-wide device combine it with --wave64-emulate. GPU-checked on an NVIDIA GeForce GTX 1060 6GB (Pascal: no mesh shaders; driver 560.94, Windows 10) with LEONIDA_MESH_COMPUTE=1 LEONIDA_W64_EMULATE=1: ms_tri, ms_w64x_ballot and ms_wave_info_s3 4096/4096 pixels exact, ms_clip 2048/4096 covered as expected, ms_v5_workgroup 24/24 workgroup coordinates, zero Khronos validation messages. Checked in tests/test_mesh_compute.py. The runtime side, turning a DispatchMesh into that dispatch, a barrier and the draw, is the follow-up (it needs the graphics pipelines of #291). Unused primitives still run the vertex shader; compaction with an indirect draw would avoid that.
Push-constant tail as a uniform block (--pc-tail-ubo) For devices whose maxPushConstantsSize is 128, Vulkan's minimum, which can't take the 144-byte block (152 with --mesh-compute): AMD's Windows driver on RDNA2 iGPUs (Radeon 680M on 22.40.84.06, 610M on 24.10.16.14, the Ryzen 5 7600's iGPU on 24.10.24) and some Intel Arc drivers (D3D-14, push_constants_need_fallback in d3d12_vulkan_device.cpp). The push-constant block keeps dwords 0–31 (s0–s31, 128 bytes). The tail that follows them by default, the heap base and code base and, with --mesh-compute, the output address, becomes %pc_tail: a uniform block at set 1, binding 0 with the same members in the same order at offsets 0, 4, … (16 bytes, 24 with --mesh-compute). Set 1 is otherwise unused, so set 0's update-after-bind table doesn't change. The block is declared, and listed in the entry point's interface, only when the shader reads the tail (a memory access through the heap base, s_getpc_b64, or the --mesh-compute epilogue); the index then records "pc_tail": {"set": 1, "binding": 0, "bytes": 16}, and "push_constant_bytes" is 128 for every module. "bindings" still lists set 0 only. Without the flag nothing changes. Checked: tests/test_pc_tail_ubo.py; all 185 hand-written GPU test shaders pass spirv-val with the flag (109 of them read the tail) with set-0 bindings unchanged. The GPU harnesses and the D3D12 layer that bind the block are the follow-ups.
Geometry shaders On output stream zero, GS_OP_EMIT_CUT emits the staged vertex and ends its strip under the same EXEC guard. The synthetic gs_emit_cut.asm checks that six vertices form two separate triangles. RDNA 2 ISA, S_SENDMSG. All 195 are $GS_VoxelizeGeneric permutations: legacy (merged ES/GS) wave32 programs on LDS rings, with no exp. All 195 are $GS_VoxelizeGeneric permutations: legacy (merged ES/GS) programs on LDS rings, with no exp, written for wave64 (inferred from the code, not confirmed against the console's wave-size setting: the EXEC prologue that gs_tri.asm mirrors compares the thread count with 64 and writes a 64-bit EXEC, the count in #94 finds v_mbcnt_hi_u32_b32 in all 195, and the translator marks all 195 wave64; an earlier version of this row said wave32, TEST-251). Inputs: vertex i sits at the dword offset in v0 lo / v0 hi / v1 lo; an LDS read at vertex base + 4·(4·reg + comp) is input-signature register reg, component comp (checked: SV_Position xyz in dwords 0–2 and TEXCOORD0.xy in 4–5, as ISG1 declares). Outputs: emitted vertex k is dwords [k·4·nreg, (k+1)·4·nreg) of the lane's GSVS area, dword = 4·reg + comp of the output signature (20 dwords = 5 OSG1 registers; every write matches a declared mask). Translation: synthetic offsets (vertex i at dword 64·i), LDS reads → gl_in[i] inputs, LDS writes → staged slots, MSG_GS EMIT → copy slot (emit count) to the outputs + OpEmitVertex, CUT → OpEndPrimitive, GS_DONE → nothing. The prologue's s_bfm_b64/s_cselect EXEC setup is fed s3 = 64 << 8. GPU-checked with runtime/test/shaders/gs_tri.asm (VKH_GS=… vk_harness): 0 error. Without a geometry stage (Apple GPUs: Metal, MoltenVK), tools/spirv_gs_to_compute.py lowers the translated module to a compute capture pass, one invocation per input primitive: inputs come from a buffer, each OpEmitVertex writes the outputs to a record buffer, and a meta buffer holds each primitive's vertex count and strip ends, for an ordinary draw afterwards (SHADER-159). gs_tri lowered this way, converted with SPIRV-Cross and run natively on an Apple A18 Pro: 195/195 records exact for 65 random triangles, and the captured fullscreen triangle drawn from the records matches all 4096 gradient pixels. Not done: wiring it into a draw path, and GS that use cross-lane operations or more than one invocation.
Integer clamp The VOP3 clamp bit on v_add_nc_u32, v_sub_nc_u32, v_subrev_nc_u32 saturates the result to [0, 0xFFFFFFFF], and on v_add_nc_i32/v_sub_nc_i32 to [0x80000000, 0x7FFFFFFF]; without it they wrap. GFX9+ semantics: LLVM selects uaddsat/usubsat and saddsat/ssubsat to exactly these ops with clamp set. Until this change clamp was silently ignored on the unsigned ops (and the signed ones were Unsupported). Checked on the CPU by tests/semantic/test_alu_add_nc_clamp.py. The carry-out unsigned ops (v_add_co_u32, v_sub_co_u32, v_subrev_co_u32, v_add_co_ci_u32, v_sub_co_ci_u32, v_subrev_co_ci_u32) with VOP3 clamp likewise saturate D to 0xFFFFFFFF on add carry or 0 on sub borrow while still reporting the real carry/borrow bit in sdst (until 2026-11-22 the translator ignored clamp on all six); confirmed natively on RDNA2 (AMD Radeon 680M gfx1035 wave32 & wave64 via tools/hw_oracle, and independently on gfx1036 in #1746) and CPU-checked by tests/semantic/test_alu_add_co_clamp.py. The 16-bit unsigned add/sub (v_add_nc_u16, v_sub_nc_u16, and the v_add_u16/v_sub_u16/v_subrev_u16 _e64 names) saturate to [0, 0xFFFF] with clamp (llvm-mc 21 gfx1030 encodes the bit on them, and LLVM selects i16 uaddsat/usubsat to them); until 2026-11-22 the translator wrapped instead. clamp on any other 16-bit integer op raises Unsupported. CPU-checked by tests/semantic/test_alu_u16_clamp.py (the high half of the destination is kept), not GPU-verified. CPU-checked by tests/semantic/test_alu_u16_clamp.py (the high half of the destination is kept), and Hardware-verified on RDNA2 (AMD Radeon 680M, gfx1035, Windows 11, driver 26.5.1, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137): all 32-bit and 16-bit *_nc_* clamp cases (including op_sel and kept destination half on u16) match hardware bit-for-bit. Open divergence measured on the same hardware: v_add_co_u32, v_sub_co_u32, v_subrev_co_u32, v_add_co_ci_u32, v_sub_co_ci_u32 and v_subrev_co_ci_u32 with clamp saturate D (0xFFFFFFFF / 0) while still reporting the real carry/borrow in sdst, whereas the translator currently ignores clamp on these carry-out ops.
v_add_nc_i16, v_sub_nc_i16 GFX10 VOP3-only signed 16-bit add and subtract. Without clamp they are bit-identical to v_add_nc_u16/v_sub_nc_u16 (the low 16 bits wrap) and take the same path: op_sel:[s0,s1,dst] picks each source's half and the destination half, and the other half of D is kept. With clamp, the exact sum or difference of the sign-extended halves saturates to [-32768, 32767] (SClamp), where the u16 forms saturate to [0, 0xFFFF]. Until 2026-11-22 both raised Unsupported. CPU-checked by tests/semantic/test_valu_add_sub_nc_i16.py (a value grid with and without clamp, op_sel including the destination half, and equality with the u16 forms without clamp). Not GPU-verified. Measured on native gfx1100: clamp saturates the exact sign-extended sum to [-32768, 32767] and the other half of D is kept.
Gather sampler LOD Before choosing the mip for the four fetches in image_gather4_l(_o), clamp the requested LOD to S# word 1's MIN_LOD [11:0] and MAX_LOD [23:12] (unsigned 4.8). ps_gather_sampler_lod.asm reads the S# from the heap. On RTX 5080 and Radeon Graphics, a maximum of 0.25 selects the base quadrants and a minimum of 0.75 selects the cyan mip across the 64×64 draw. Without these bounds half of each frame reads the wrong level. Radeon also agreed with native OpImageGather Lod (VK_AMD_texture_gather_bias_lod) for those bounds. At exactly 0.5, with bounds [0,1], that native draw selected mip 1; the emulation now computes the mip as Floor(LOD + 0.5), ties up, and also selects mip 1 (before SHADER-152 it used RoundEven, which selected mip 0).
s_absdiff_i32, s_mul_hi_i32 s_absdiff_i32: D = |S0 − S1| with the 32-bit difference wrapped first (0x7FFFFFFF − 0x80000000 → 1; a difference of −2³¹ stays 0x80000000), SCC = D ≠ 0. s_mul_hi_i32: high word of the signed 64-bit product, SCC kept. From the RDNA2 ISA pseudocode; checked on the CPU by tests/semantic/test_salu_absdiff_mul_hi.py. Hardware-verified on an AMD Radeon RX 7900 XTX (gfx1100, Windows 11, driver 26.10.1) as raw wave32 kernels through tools/hw_oracle: s_absdiff_i32(0x7FFFFFFF, 0x80000000) = 1 and s_absdiff_i32(0x80000000, 0) = 0x80000000, both with SCC = 1, and equal operands give 0 with SCC = 0; s_mul_hi_i32(0x7FFFFFFF, 0x7FFFFFFF) = 0x3FFFFFFF and s_mul_hi_i32(-1, 1) = 0xFFFFFFFF, with SCC left as it was. Also verified on native RDNA2 (gfx1036, AMD Radeon Graphics): 500 programs in tools/salu_diff.py (--oracle translator,hw) matched bit-for-bit with 0 mismatches, and the high product word and SCC retention confirmed across edge values.
SCC from scalar ALU s_and/or/xor/andn2/orn2/nand/nor/xnor_b32 and s_lshl/lshr_b32 set SCC = result ≠ 0, s_add/sub_i32 and s_addk_i32 set it to signed overflow, s_min_u32/s_max_u32 to S0 < S1 / S0 > S1, and s_min_i32/s_max_i32 to the same compared signed: SCC is 1 when S0 is the one chosen, and a tie chooses S1 (RDNA2 ISA, S_MIN_I32: D = S0 < S1 ? S0 : S1, SCC = 1 if S0 is chosen). Before this fix these ops left SCC unchanged, so a following s_cbranch_scc* read a stale flag, and until 2026-11-21 s_min_i32/s_max_i32 set SCC on a tie. 32-bit scalar shifts now mask the amount to 5 bits. GPU-checked with runtime/test/shaders/ps_scc.asm and ps_scc_minmax.asm (NVIDIA GeForce RTX 2060 SUPER, Linux, driver 620.70.06: 4096/4096 pixels exact, and all 4096 differ with the old translator). On lane masks in a wave32 program (a source is EXEC, VCC or a mask SGPR, or the result goes to EXEC) the 32-bit bitwise ops' result is the whole wave's mask, so SCC is a subgroup vote (OpGroupNonUniformAny), as for the _b64 forms. Until 2026-11-22 each lane took its own bit: s_and_b32 s0, vcc_lo, exec_lo; s_cbranch_scc0 skipped the block in lanes whose bit was 0, and a loop closed by s_andn2_b32 exec_lo, ...; s_cbranch_scc1 let each lane leave early. Found and checked by tools/cf_diff.py (FUZZ-8, CPU differential against the ISA model); GPU test runtime/test/shaders/ps_scc_mask32.asm passes (s5 == 8 on 2,048 pixels, 192 of them with bit 0, and s5 == 7 on 2,048) on an NVIDIA RTX 4050 Laptop (Linux, driver 620.73.04, natively and under LEONIDA_W64_EMULATE=1) and an AMD Radeon 740M (RADV, Mesa 26.3.1), and on an RTX 2060 SUPER per #634. A 32-bit op on one half of a wave64 mask still takes the lane's bit (its SCC would be a vote of that half).
Chained scalar constant folding (PERF) Multi-step constant calculations on SGPRs (s_mov_b32, s_lshl_b32, s_lshr_b32, s_mul_i32, s_add_u32, s_sub_u32, s_lshl1..4_add_u32, s_bfe_u32/i32, s_min/max_u32/i32, s_andn2/orn2/nand/nor/xnor_b32, s_abs_i32, s_absdiff_i32, s_sext_i32_i8/i16, s_pack_*_b32_b16, s_bfm_b32) fold completely at translation time and record folded literal values in self.sgpr_imm, allowing downstream instructions within the basic block to propagate constants. s_buffer_load offset expressions computed via constant SALU fold statically into 64-bit addresses, and in-bounds reads eliminate runtime bounds check branches and Phi nodes. s_bfe with constant control words emits static offset/width operands directly. Checked by tests/semantic/test_salu_chained_const_prop.py and tests/semantic/test_scalar_alu_and_smem_folding.py.
Far branches s_getpc_b64; s_add_u32 K; s_addc_u32 0/−1; s_setpc_b64 on the same pair is a branch beyond s_branch's ±32K-dword range. It's folded into one branch to (address after s_getpc) + K before CFG construction.
No-op SOPP/SMEM (s_icache_inv, s_ttracedata, s_ttracedata_imm, s_code_end, s_version, ds_nop, v_clrexcp) Instruction-cache invalidate, thread-trace data, end-of-code padding, the ISA version marker and the DS no-operation have no register, memory, SCC, VCC or EXEC effect, so they are in NOOPS with s_nop / v_nop / v_pipeflush. v_clrexcp clears the TRAPSTS exception bits, which nothing translated reads (s_getreg_b32 is unsupported and there are no traps), so it is a no-op too (since 2026-11-22; before, both it and ds_nop raised Unsupported). The data-cache invalidations (buffer_gl0_inv, buffer_gl1_inv, s_dcache_inv, s_gl1_inv) concern coherence between waves and stay Unsupported. Source: RDNA2 ISA SOPP/SOPK/SMEM/DS/VOP1. CPU-checked by tests/semantic/test_sopp_noops.py (values, SCC and VCC survive; the data-cache invalidations are still rejected).
Buffer format stores buffer_store_format_* and _d16_* encode every format the loads decode (the same FORMATS table: f32/u32, f16, unorm/snorm 8/16/10-10-10-2, uint/sint 8/16). 1–2-byte elements are merged into their dword with atomic and/or so neighbours are kept. The atomics use element 0 of the array at the aligned dword address, which also compiles on MoltenVK 1.4.0 (checked with cs_store on an Apple M3 Max and Mesa llvmpipe). d16 data is unpacked first (f16 → float for float kinds, 16-bit integers for integer kinds). Before this, only four f32 formats, rgba16f and rgba8 unorm were stored, and everything else silently stored nothing. GPU-checked with runtime/test/shaders/cs_store.asm (rgba8 unorm, R10G10B10A2 (2_10_10_10), two r16f halves of one dword, d16 rgba16f: exact, neighbours untouched). buffer_load_format_d16_* packs pairs the same way. UNORM/SNORM stores convert NaN to zero before clamping. On native gfx1036, buffer_store_format_d16_xyzw into RGBA8_UNORM/SNORM matched clamp, scale by 255/127 and round to nearest even for all 63,488 finite binary16 encodings. Both infinities saturated and all 2,046 NaNs stored zero in both wave32 and wave64. The translated sweep matched all 65,536 bytes per format on RTX 5080 and Radeon Graphics. For normalized stores with format 56 (8/8/8/8) or 50 (10/10/10/2), a Z,Y,X,W descriptor exchanges the red and blue memory fields after filling absent input components with zero. Native gfx1036 confirmed both channel orders at all four instruction widths for packed and ordinary stores in wave32 and wave64. A store with fewer components than its format writes the whole element, with 0 for the components it doesn't give (_xy into 32_32_32_32 leaves z = w = 0, _xyz into 16_16_16_16 leaves w = 0); into a one-channel format only x is written. Measured natively on a Radeon 680M (gfx1035, RDNA2), and GPU-checked by cs_fmt_xy_xyz.asm for 32_32_32_32, 16_16_16_16, 8_8_8_8 UNORM and UINT and 32 (TEST-185). Unsigned integer stores saturate to the destination channel width. On native gfx1036, RGBA8_UINT, RG16_UINT and RGBA16_UINT clipped overflowing inputs to 255 or 65535, with RGBA32_UINT as a full-width control. For normalized stores with format 56 (8/8/8/8) or 50 (10/10/10/2), a Z,Y,X,W descriptor exchanges the red and blue memory fields after filling absent input components with zero; native gfx1036 confirmed both channel orders at all four instruction widths for packed and ordinary stores in wave32 and wave64. tbuffer_store_format_* is not translated. 8- and 16-bit SINT stores clamp the signed 32-bit value to [-2^(w-1), 2^(w-1) - 1] (300 stores 127 into 8_SINT, -129 stores -128), and the 8/16-bit UINT formats 5, 11 and 18 saturate like the others; measured natively on gfx1036 for x, xy, xyzw and d16_xyzw stores (a d16 half is read as a signed 16-bit integer for SINT, so 0xff80 stores -128) with the runtime's selectors (X001, XY01, XYZW) and checked by tests/semantic/test_buffer_format_narrow_int.py (until 2026-11-22 those formats stored nothing). tbuffer_store_format_* and its _d16_* forms take the instruction's format instead of the V#'s, as the tbuffer loads do: only that format is encoded, and its element size decides the bounds check (an 8_UNORM byte is stored where the V#'s 16-byte element would not fit; a 16-byte element is dropped where the V#'s 4-byte one would fit). A V# whose FORMAT is 0 (INVALID) still disables the store. No format: modifier is GFX10's default, BUF_FMT_8_UNORM; a format FORMATS has no encoder for stays Unsupported. Measured natively on a Radeon 680M (gfx1035, wave32 = wave64) and GPU-checked by cs_tbuffer_store.asm (13 stores: f32, f16, 8_8_8_8 UINT and UNORM, 2_10_10_10, d16, the default format, more and fewer components than the format has, both bounds cases, a V# with FORMAT 0; exact on an RTX 3050 and the 680M); CPU-checked by tests/semantic/test_tbuffer_store.py.
No-op SOPP/SMEM (s_icache_inv, s_ttracedata, s_ttracedata_imm, s_code_end, s_version, ds_nop, v_clrexcp, s_atc_probe, s_atc_probe_buffer) Instruction-cache invalidate, thread-trace data, end-of-code padding, the ISA version marker and the DS no-operation have no register, memory, SCC, VCC or EXEC effect, so they are in NOOPS with s_nop / v_nop / v_pipeflush. v_clrexcp clears the TRAPSTS exception bits, which nothing translated reads (s_getreg_b32 is unsupported and there are no traps), so it is a no-op too (since 2026-11-22; before, both it and ds_nop raised Unsupported). s_atc_probe and s_atc_probe_buffer (SMEM) probe, that is prefetch, an address in the address translation cache: no data comes back and nothing is written, so they are no-ops too (since 2026-11-22). The data-cache invalidations (buffer_gl0_inv, buffer_gl1_inv, s_dcache_inv, s_gl1_inv) concern coherence between waves and stay Unsupported. Source: RDNA2 ISA SOPP/SOPK/SMEM/DS/VOP1. CPU-checked by tests/semantic/test_sopp_noops.py (values, SCC and VCC survive; the data-cache invalidations are still rejected).
No-op SOPP/SMEM (s_icache_inv, s_ttracedata, s_ttracedata_imm, s_code_end, s_version, ds_nop, v_clrexcp, s_atc_probe, s_atc_probe_buffer, s_incperflevel, s_decperflevel, s_wakeup) Instruction-cache invalidate, thread-trace data, end-of-code padding, the ISA version marker and the DS no-operation have no register, memory, SCC, VCC or EXEC effect, so they are in NOOPS with s_nop / v_nop / v_pipeflush. v_clrexcp clears the TRAPSTS exception bits, which nothing translated reads (s_getreg_b32 is unsupported and there are no traps), so it is a no-op too (since 2026-11-22; before, both it and ds_nop raised Unsupported). s_atc_probe and s_atc_probe_buffer (SMEM) probe, that is prefetch, an address in the address translation cache: no data comes back and nothing is written, so they are no-ops too (since 2026-11-22). s_incperflevel and s_decperflevel increment or decrement a performance counter (RDNA2 ISA SOPP, SIMM16[3:0]) and s_wakeup pings the other waves of the threadgroup out of an s_sleep, which is itself a no-op here; none writes a register, memory, SCC, VCC or EXEC, so they are no-ops too (since 2026-11-22). The data-cache invalidations (buffer_gl0_inv, buffer_gl1_inv, s_dcache_inv, s_gl1_inv) concern coherence between waves and stay Unsupported. Source: RDNA2 ISA SOPP/SOPK/SMEM/DS/VOP1. CPU-checked by tests/semantic/test_sopp_noops.py (values, SCC and VCC survive; the data-cache invalidations are still rejected).
Buffer format store rounding and 2-component DST_SEL (SHADER-364) UNORM/SNORM stores (Gen.encode_norm_bits) round the exact product clamp(x) * scale once in 64-bit integer arithmetic with ties away from zero, instead of double-rounding through OpFMul + RoundEven (UNORM16(0.3) stores 19661, not 19660; SNORM2(±0.5) stores ±1). MUBUF buffer_store_format_* (and _d16_*) into 2-component formats infer COMP_SWAP from V# DST_SEL_X/Y/Z: use_y = (sy >= 4) and (sz < 4), rev = (sx != 4) and (sy >= 4 or sz >= 4) (XY01 → (x, y), YX01 → (y, x), XYZW → (x, w) so _xy writes (x, 0), YXZW/ZYXW → (w, x)); MTBUF tbuffer_store_format_* ignores DST_SEL and always stores (x, y). Measured natively on RDNA2 (gfx1036, AMD Ryzen 7 9800X3D iGPU, Linux AMDGPU DRM via tools/hw_oracle, wave32 and wave64) with tools/buffer_store_probe.py: 0 mismatches across 5 UNORM/SNORM formats (2,474 inputs × MUBUF/MTBUF × wave32/64 = 9,896 runs) + SNORM2 ties, all 12 2-component formats (XY01 vs XYZW), and all 216 (sx, sy, sz) triples on 32_32_UINT. Checked on CPU + spirv-val by tests/semantic/test_buffer_store_rdna2.py and tests/test_buffer_store_probe.py.
s_lshl1..4_add_u32 D = (S0 << N) + S1. SCC = the sum taken in 64 bits is ≥ 2³², so a bit shifted out of S0 sets it as well as a carry out of the add (RDNA ISA pseudocode: tmp = (64'U(S0) << N) + 64'U(S1)). Checked on the CPU by tests/semantic/test_salu_lshl_add.py. Hardware-verified on the same gfx1100 part through tools/hw_oracle: s_lshl1_add_u32(0x80000000, 0) = 0 with SCC = 1 (the bit shifted out of S0 sets it, with no carry out of the add), s_lshl2_add_u32(5, 3) = 0x17 with SCC = 0, s_lshl4_add_u32(1, 0) = 0x10. Also verified on native RDNA2 (gfx1036, AMD Radeon Graphics): 500 programs in tools/salu_diff.py (--oracle translator,hw) matched bit-for-bit with 0 mismatches across shift amounts 1–4, confirming that bits shifted out of S0 set SCC as well as sum overflow.
Other additions image_gather4_l(_o): no explicit-LOD gather in core Vulkan, so four OpImageFetch at the mip the "Gather sampler LOD" row chooses, in gather order. image_gather4_l(_o): no explicit-LOD gather in core Vulkan, so four OpImageFetch at mip Floor(clamp(LOD, S# MIN_LOD, MAX_LOD) + 0.5) (ties up, as native) in gather order. With d16 those four taps round to binary16 and pack low half first into two consecutive VGPRs. The packed words and the first untouched VGPR were checked with ps_gather_wrap.asm on RTX 5080 and Radeon Graphics. Each of the four texel coordinates goes through the S#'s own address mode, read from S# word0 (CLAMP_X = bits [2:0], CLAMP_Y = [5:3]; fields from Mesa src/amd/registers/gfx10-rsrc.json, values SQ_TEX_* in Mesa gfx6.json, matching RADV's radv_tex_wrap mapping of Vulkan address modes): 0 wrap (c mod n), 1 mirror (c mod 2n, reflected), 2 clamp to the last texel, 3 mirror-once (-1-c for negative c, then clamped), as in Vulkan's address-mode definitions. The modulo is OpSRem plus the period when the remainder is negative, not OpSMod. On a Ryzen 5 7600's iGPU (RDNA2) with AMD's Windows driver 24.10.24, OpSMod of a negative coordinate came out with the dividend's sign: the three ps_gather_wrap cases whose wrap or mirror coordinate is negative (1, 2 and 6) fetched outside the image and read zeros, while the same module passed on an RTX 4070 SUPER. With OpSRem and the fix-up, all 4096 pixels are exact on both. A literal S# (s_mov_b32 earlier in the block) is decoded at translation time; otherwise the mode is read from the SGPR at run time. A literal S# with a border mode (4-7: half-border, border colour) or FORCE_UNNORMALIZED is Unsupported; a run-time S# can't be judged, so modes 4-7 act as clamp-to-edge there and FORCE_UNNORMALIZED (word0 bit 15) is not applied (coordinates are still scaled by the image size). Modes 6 (clamp border) and 7 (mirror once border) give a tap whose coordinate, before the clamp, is outside [0, n-1] on either axis the S# border colour's channel instead of the fetched texel: BORDER_COLOR_TYPE = word 3 [31:30] (Mesa gfx10-rsrc.json SQ_IMG_SAMP_WORD3, SQ_TEX_BORDER_COLOR_* in gfx6.json), 0 transparent black, 1 opaque black (alpha 1), 2 opaque white; 1 for an integer format, as Vulkan's INT_OPAQUE_*. Type 3 (a colour from the border-colour table, BORDER_COLOR_PTR) is Unsupported on a literal S# and transparent black at run time (SHADER-348: since #1567 made the game's S# words literals, 16 of the corpus's mode-6 gathers failed as Unsupported; before that they ran as clamp-to-edge). A literal S# with a half-border mode (4, 5) or FORCE_UNNORMALIZED is Unsupported; a run-time S# can't be judged, so modes 4 and 5 act as clamp-to-edge there and FORCE_UNNORMALIZED (word0 bit 15) is not applied (coordinates are still scaled by the image size). Those two, and a table border colour (BORDER_COLOR_TYPE 3) on a run-time S#, which gives transparent black, are the remaining approximations; the unnormalized rules (texel-unit coordinates, mip 0) weren't confirmed on hardware, so they were not guessed. GPU-checked with runtime/test/shaders/ps_gather_wrap.asm (vk_texture_test; expected values derived by hand in its header; six border cases, three literal and three run-time S#) on AMD (Radeon 880M, wave64) and NVIDIA RTX 5070. GPU-checked with runtime/test/shaders/ps_gather_wrap.asm (vk_texture_test; expected values derived by hand in its header; six border cases, three literal and three run-time S#) on AMD (Radeon 880M, wave64) and NVIDIA RTX 5070; the border modes with runtime/test/shaders/ps_gather_border.asm (two literal and two run-time S#s, opaque white and transparent black, modes 6 and 7) on NVIDIA RTX 4070 SUPER (driver 621.01), with tests/test_translate.py's test_gather4_l_*border*. image_gather4_lz_o: OpImageGather … Offset. image_store on 1D (bindings 17–19, Image1D) and with a16 coordinates. ds_swizzle BITMASK_PERM ("pippi" masks; GPU-checked). v_add_f64, v_cvt_f32_f64 (Float64). v_mul/mad_i32_i24, v_alignbyte_b32, v_xnor_b32, v_ffbh_i32, v_swap_b32, s_abs_i32, s_bfm_b32/b64, 64-bit ordered and v_cmpx compares, 16-bit compares, 8/16-bit global loads, neg(…) constant operands (GPU-checked where listed in runtime/test/shaders).
v_mad_u64_u32, v_mad_i64_i32 {sdst, D} = S0 × S1 + S2 as a 65-bit result (RDNA ISA pseudocode), the product unsigned or signed. sdst (a lane mask) gets bit 64 for active lanes and 0 for lanes off in EXEC (EXEC[lane] ? bit64 : 0, matching v_cmp_* and *_co_*): the carry out for u64, and for i64 the sign of the exact sum (bit 64 of a 65-bit two's-complement value), not a signed-overflow flag. tools/lane_masks.py tracks sdst as a lane mask (until 2026-11-22 it only matched *_co_*, so s_bcnt1/s_ff1/v_mbcnt on sdst read each lane's own mask word as plain data). clamp is rejected. Checked on the CPU by tests/test_lane_masks.py, tests/semantic/test_alu_mad64.py (including 64-lane s_bcnt1_i32_b64/s_ff1_i32_b64 ballot tests), and tests/semantic/test_carry_exec_mask.py (EXEC masking on inactive lanes). Hardware-verified on RDNA2 (AMD Radeon 680M, gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137): unsigned carry, signed positive overflow (-2³¹)² + INT64_MAX giving sdst = 0, negative sum giving sdst = 1, and inactive EXEC lane leaving D untouched with sdst = 0 all match bit-for-bit.
Ray tracing image_bvh_intersect_ray / image_bvh64_intersect_ray (64 CS: RT shadows) are one traversal step against AMD's hardware BVH node format. The traversal loop lives in the game's shader. The step is emulated over buffer reads following Mesa RADV's software path (radv_nir_rt_common.c, intersect_ray_amd_software_box/_tri; node layouts from bvh_defines.h). Node id = address >> 3 | type (0–3 triangle, 4 box16, 5 box32). Box nodes give the four child ids, with misses and NaN boxes = 0xFFFFFFFF, sorted by entry distance when descriptor bit 63 (box_sort_enable) is set. Triangle nodes read their three vertices from the slots the node type picks: TRI0 (0,1,2), TRI1 (1,3,2), TRI2 (2,3,4), TRI3 (2,4,0), 12 bytes each. They use the watertight test with RADV's shared edge/vertex tie-breaks and give (t/|det|, sign(det), b_i/|det|, b_j/|det|), or (inf, 1, 0, 0) on a miss. The weights i and j are chosen by the node type's byte of the triangle-ID word at +60: bits [1:0] and [3:2], 0/1/2 = vertex 0/1/2; 0x09 gives RADV's (v, w). Vertex slots and remap follow AMD GPURT (CalcTriangleCompressionVertexIndices, SwizzleBarycentrics) and the public XDXR software path (bvh.md §7a). These two references agree; no game BVH is decoded yet to count over. A GPU can't confirm the rule either, because every GPU runs this emulation and none runs the native instruction. tests/semantic/test_image_bvh_tri.py runs every node type and remap byte on the interpreter. The game's code divides by .y exactly as for the hardware's numerator/denominator. Address = descriptor base + ((node & ~7) << 3), base = descriptor bits [39:0] in 256-byte units (assumption: RADV only uses base 0). The runtime must build the game's acceleration structures in this AMD node format (RADV's GPU BVH builder produces it) wherever the game's D3D12 calls build them. Far branches with s_sub_u32/s_subb_u32 (backward) are folded too. GPU-checked with runtime/test/shaders/cs_bvh.asm: sorted box children and the triangle result are exact. The 32-bit form (11 address dwords: the node id has no high dword) runs the same scene in cs_bvh32.asm and gives the same eight words.
Coverage Every shader in the corpus translates. The remaining fidelity gap is wave64 cross-half code on 32-wide subgroups in VS/PS/GS (tier C of the Wave64 graphics row; tiers A and B are exact); compute and mesh shaders are exact there with --wave64-emulate (see the wave-size and wave64 rows).
Flat pixel inputs A pixel input location read only by v_interp_mov_f32 is declared Flat. Locations read with v_interp_p1/p2 remain interpolated. The ps_flat GPU test passes integer IDs through the first vertex alongside interpolated UVs.
v_interp operand guards (SHADER-177) The single-lane model reads the attribute's own value for v_interp_p1/p2, which is only right when the VGPR source really holds the barycentric coordinate that op interpolates with — p1 reads I = v0 and p2 reads J = v1, per op — and v_interp_mov_f32 models only the p0 provoking vertex. A p1/p2 (f32 and f16 forms) whose source is not its own coordinate — v0 for p1, v1 for p2, each either the hardware register or a plain v_mov_b32 copy rooted at it (the copy's single write in the whole shader, defined before the use, copy chains followed, and its source v0/v1 itself unwritten up to the copy: a copy of an already-overwritten v0/v1 carries a computed value — zeroing the source before copying renders (0,0) on hardware — while a write after the copy is fine, the copy saved the value) — is Unsupported, naming the register and the role, so a swapped p1(v1)/p2(v0) pair, a both-v0 pair, or a copy of an overwritten source is refused rather than silently mistranslated; v_interp_mov_f32 with p10/p20 is Unsupported, naming the select. A direct v0/v1 read stays accepted even when the shader overwrites v0/v1 first (evaluate-at-offset/snapped barycentrics; up to 213 PS, #1218): modelling that computed value is the separate provenance follow-up. Zero corpus cost: over the 26,503-shader corpus every f32 I/J source is v0/v1 (117,001 / 116,997) except one PS whose four v_interp_p2_f32 read J through v_mov_b32 v14, v1 (its v1 unwritten up to the copy; the later overwrites are the saved-copy case), which the copy rule keeps translating (bit-identical .spv), every f16 source is v0/v1 (58,950 / 58,950), and all 6,926 v_interp_mov_f32 use p0. Confirmed by tests/semantic/test_interp_guards.py (refusals name the operand and its role, including swapped and both-v0 pairs, a wrong-root copy, and a copy of an overwritten source; the copy, copy-chain, matching-role and saved-from-later-zero cases translate and compute; a second write or a dpp copy no longer qualifies; a mutation check that the guard consults the copy analysis) and by re-translating a 200-shader corpus slice plus that PS before and after: translated/valid counts and every .spv unchanged.
Pixel-shader interpolants When a sidecar fssm/<name>.fssm holds a pixel-input table (tools/fssm_header.py: 8-byte records from 0x138 while the first byte is 6; table position = v_interp attr number), every position 0..count−1 is declared as a fragment input at that Location, including positions the code never reads (the table overcounts the code's distinct v_interp attrs in 775 of 12,101 PS: 300 by one, 475 by two or more; only the 10 records starting with kind 7 undercount). A 32-bit v_interp read (p1/p2/mov) of a 16-bit-flagged position (flag bit 4; measured natively on RDNA2, AMD Radeon 680M gfx1035 in wave32 and wave64 via tools/vinterp_hw_probe.py --oracle both, SHADER-430: the VINTRP unit reads the same LDS parameter-cache dwords at M0 + 48·attr + {8·c, 8·c + 4, 32 + 4·c} with no hidden 16-bit unpacking, so v_interp_mov_f32 returns the raw 32-bit parameter word and v_interp_p1_f32/v_interp_p2_f32 interpolate those 32-bit words as binary32), and reads past the table still declare an input (the value is undefined on hardware). 11,199 such inputs corpus-wide, matching the *_f16 interpolation opcodes in 99.7%) sees the value rounded to f16 (round to nearest, f16 denormals flushed to signed zero, back to f32) via a single OpQuantizeToF16 (a PackHalf2x16/UnpackHalf2x16 round-trip is folded to a no-op by at least one Vulkan driver, RTX 5080); reads through the *_f16 opcodes already narrow and are unchanged (on a location an f16 op also reads, the f32 read is of the per-vertex raw word, "16-bit interpolation"; on gfx1036 a 32-bit p1/p2_f32 read of a packed channel takes the raw LDS words as f32 bits, one fma each (SHADER-430, tools/interp_hw_probe.py); what P10/P20 words the SPI stores for such a channel is unverified), and reads past the table still declare an input (the value is undefined on hardware). Without a sidecar, or with an empty table, the output is byte-identical to the code-driven path. Confirmed by synthetic fixtures plus mini-interpreter agreement (tests/test_rdna2spirv_pixelinput.py: an f32 read of a flagged slot with input 1.1 yields the f16-rounded 1.099609375; unflagged and table-less controls yield exact 1.1) and tests/test_vinterp_hw_probe.py. The index.json entry records ps_interpolants (count) and ps_fp16_interpolants (flagged positions).
PS interpolation modes (SHADER-181) Every interpolated pixel input in this build is perspective-correct at the pixel center, and every other input is flat, so the single v0/v1 pair the code reads is PERSP_CENTER. The translator models exactly these two: Flat for v_interp_mov_f32, plain (perspective, center) inputs and BaryCoordKHR for v_interp_p1/p2 and the f16 forms. Two records describe each input, and they state different facts: PSV0 (DXBC) stores the interpolation mode; the FSSM input record's flags byte (byte 7) stores the read method — bit 0 (0x01) marks v_interp_mov_f32 (4,600 records), bit 1 (0x02) 32-bit v_interp_p1/p2 (51,191; values 0 and 3 never occur), bit 3 (0x08) a Float16-typed parameter (11,619), bit 4 (0x10) the *_f16 opcodes (11,199; 24 f16-read records lack it). The flag/usage cross-table over all 55,791 records has no contradiction: every bit-0 position the code reads is read only by v_interp_mov_f32 (4,295 positions), every bit-1 position only by v_interp_p1/p2 or the f16 forms (49,594), and no position is read both ways (1,902 positions are unread, and 88 reads fall past the table). The mode is in PSV0, not the FSSM: tools/ps_interp_modes.py decodes it from the PSV0 signature elements (DXIL::InterpolationMode, "must match D3D_INTERPOLATION_MODE": 1 Constant, 2 Linear, 3 LinearCentroid, 4 LinearNoperspective, 5 LinearNoperspectiveCentroid, 6 LinearSample, 7 LinearNoperspectiveSample; the 16-byte elements carry row, cols, semantic kind, component type and the mode — layout in the Pixel-shader inputs section) and maps the modes onto the SPI_PS_INPUT_ENA barycentric-pair bits (Mesa gfx103.json register type SPI_PS_INPUT_ENA: PERSP_SAMPLE/CENTER/CENTROID = bits 0/1/2, LINEAR_SAMPLE/CENTER/CENTROID = bits 4/5/6; the same type serves SPI_PS_INPUT_ADDR). No FSSM word stores ENA/ADDR: every u16 in bytes 0x00–0x138 of all 12,101 PS was compared against the signature-reconstructed ENA and only constant coincidences matched, and the register addresses (0x286CC/0x286D0, or 0xA1B3/0xA1B4 as context-register indices) appear in no PS blob, so the v2.. position layout of "PS system inputs" (one enabled pair) is the only ENA witness. Census (12,101 PS; 101,024 declared / 77,245 read inputs): every arbitrary, clip and cull input is Constant (6,333 rows, 4,529 read) or Linear = perspective-centre (81,385 rows, attributes plus 1,806 SV_ClipDistance and 2 SV_CullDistance); zero centroid, sample or noperspective generics; per shader 6,350 linear only, 4,507 linear and constant, 6 constant only, 1,238 no interpolated input. 101,024 declared / 76,215 read inputs): every arbitrary, clip and cull input is Constant (6,333 rows, 3,652 read) or Linear = perspective-centre (81,385 rows, attributes plus 1,806 SV_ClipDistance and 2 SV_CullDistance); zero centroid, sample or noperspective generics; per shader 6,350 linear only, 4,507 linear and constant, 6 constant only, 1,238 no interpolated input. ISG1 has no mode field, and the DXIL part carries no bitcode. SV_Position is mode 4 (11,295 rows) or mode 5 (27) — noperspective by the D3D rule —. With packed-component read masks, the classifier assigns 10,260 shaders to the perspective-centre pair and 1,841 to no pair. It assigns none to a linear pair. This count measures input classification; it does not directly measure how the hardware delivers SV_Position; front face is a system input (1,984 rows, 345 read, at most one per shader). SV_Position is mode 4 (11,295 rows) or mode 5 (27) — noperspective by the D3D rule — and is delivered through the system VGPRs in every shader except 4, which interpolate it through the parameter cache with the linear pair (FragCoord stays at the pixel center, which only differs at partly covered MSAA pixels); front face is a system input (1,984 rows, 345 read, at most one per shader). The code reads one barycentric pair per shader: v0/v1 in 10,259, none in 1,841, and one shader reads J from v14 (a copy of v1), so the perspective-centre assumption holds for every interpolated generic input. Mode and read method disagree in thousands of rows — the residual surface for modelling is: those 4 linear-pair position shaders, Constant rows read via p1/p2 or *_f16 (2,190 records at the matching table position; flat semantics in hardware, not modelled), and Linear rows read only by v_interp_mov_f32 (3,197; already declared Flat). The translator's table check (check_read_methods, the row below) compares each read's opcode against the record's read-method bits (fssm_header.read_methods) — since the bits restate the read method, it rejects 0 of 12,101 PS: a consistency check between the two encodings of the read, not a mode check (a centroid/sample/noperspective input would still read v_interp_p1/p2 and pass; that every interpolated input is perspective-centre is the PSV0 census result above, so keying a refusal on genuinely unmodelled modes means decoding PSV0, not reading these bits). Counted with tools/ps_interp_modes.py (stdlib; PSV0, FSSM and disassembly in one pass; #1301 removed the earlier #1246 census tool in favour of it) on the 1.0.2.1 corpus; tests tests/test_ps_interp_modes.py, tests/test_fssm_header.py and tests/test_rdna2spirv_pixelinput.py (synthetic). No GPU test: no shader needs centroid or sample interpolation. Not covered: bit 3 (0x08) is set in 11,619 records (all 11,199 16-bit ones, 396 flat, 24 linear). The 213 PS that overwrite v0/v1 before a v_interp (SHADER-178) compute their own barycentrics in code; PSV0 gives them no other mode.
PS v_interp read methods (SHADER-181, translator side) Bits 0–1 of the FSSM input record's flags byte (byte 7; fssm_header.read_methods) give the read method of each table position: bit 0 (0x01) = read through v_interp_mov_f32, bit 1 (0x02) = read through v_interp_p1/p2 or the f16 forms. They do not give the D3D interpolation mode, which is PSV0's (row "PS interpolation modes", tools/ps_interp_modes.py, #1256). Exactly one bit is set in every corpus record (bit 1 in 51,191, bit 0 in 4,600). In all 12,101 PS every bit-0 position the code reads is read only by v_interp_mov_f32 (4,295 read positions), every bit-1 position only by p1/p2 or the f16 forms (49,594), and no position is read both ways (1,902 positions are unread, and 88 reads fall past the table). The translator follows the read method, which is what the code does: v_interp_mov → Flat, p1/p2 → a plain input (perspective, pixel center; BaryCoordKHR for raw i/j). That this one pair is perspective-center holds because PSV0 lists no centroid, sample or noperspective generic input, and the code reads one barycentric pair (#1256). Table positions don't pair one-to-one with PSV0 rows, since the table keeps only the inputs the compiled code uses, so a PSV0 row's mode and the record's read method can differ at a paired position; #1256 counts those cases. rdna2spirv.check_read_methods refuses a PS whose read position disagrees with its record's read method (v_interp_mov of a bit-1 position, p1/p2/f16 of a bit-0 one), or whose record has neither or both bits, instead of reading it as perspective-center. It refuses 0 of 12,101 PS, and shard 0/12 translates byte-identically to before the check. index.json records ps_flat_interpolants, the bit-0 positions. Tests: tests/test_rdna2spirv_pixelinput.py and tests/test_fssm_header.py (synthetic). GPU-checked by @Vonsek on #1246 (RTX 5080 and Radeon integrated graphics, stock ps_flat with a hand-built table of read methods 2 and 1): the smooth channels match a per-center perspective reference, the flat channel keeps the provoking value, and flipping either record's read method makes the translator refuse the shader. Bit 3 (0x08, 11,619 records) is a Float16-typed parameter per #1256.
Mixed flat and smooth f32 reads A pixel shader may use v_interp_mov_f32 p0 and v_interp_p1/p2_f32 on the same input location. The translator declares it PerVertexKHR, takes vertex 0 for the MOV, and interpolates the smooth read with the triangle weights. The fallback modes without per-vertex inputs reject this combination. The synthetic mixed_f32_varying.asm fixture and CPU interpreter check both reads at two points of one triangle. AMD RDNA 2 ISA, VINTRP instructions
Computed I/J barycentrics (SHADER-177) v_interp_p1/p2 weight the interpolation with the values their operand VGPRs hold at the two ops, not with the hardware's own pair. Vonsek's image evidence on a synthetic triangle (#1224): zeroed sources render P0 = (0,0) on all 4,096 pixels, and copies of the pair read in swapped order render (v,u) — both follow the two VINTRP equations in the RDNA2 ISA guide; the centre interpolation the single-lane model used to emit is wrong for both. When a write of the operand register reaches an interp site (earlier in its own basic block, or in any block a path runs through first — loops included; a write at the site itself, an interp whose destination is its own I/J register, happens after the operand is read), the attribute is read PerVertexKHR and both ops interpolate with the operand values loaded from %vgpr, which holds whatever the program computed: constants (snapped coordinates, 577 straight-line sites), copies and copy chains (575), arithmetic (8), multi-writer sequences (1,135). The p1 loads its I and keeps it for the p2, which loads its J fresh — the program often sets J up between the two ops (574 sites) — so the final value uses the I of the p1 with the J of the p2; the p1's own full-sum value is dead because nothing may read the partial between the ops. Pipodi's straight-line scan puts the upper bound at 213 PS (#1218 comment 7076614458; 2,290 v0/v1 sites plus one PS reading J through a copy, all branchy); the reaching-write analysis finds 207 with a write that can reach an interp, and 6 whose overwrites sit on paths that cannot (left pristine, .spv unchanged). The other 11,888 PS keep the interpolated-input read and a byte-identical .spv. Composes with the operand guards (row above, #1224): a pristine plain v_mov copy of the pair stays the guards' to model (centre interpolation, bit-identical .spv, including the corpus's one copy PS), an operand that is neither v0/v1 nor written stays the guards' role-naming refusal, and a computed site is exempt from interp_pair_src and modelled here — which relaxes exactly the guards' copy-based refusals whose operand a program write reaches: a twice-written register (v_mov then arithmetic — the load reads the value the later write left; value-proven by test_copy_written_again_is_computed), a copy of an already-overwritten v0/v1 (Vonsek's zero-before-copy row: hardware renders P0, which is exactly the loaded zeros), and a modified v_mov_b32_dpp source (any write of the operand is a %vgpr value; translation-only test). A pristine copy in the wrong role still refuses (no computed value to model). Over the corpus the relaxation is empty — every one of the 213 PS names v0/v1 (or the one qualified copy), so on main and on this branch alike the set translates 213/213 and passes spirv-val 213/213, and no shader changes class; the guards' refusals that relax are the synthetic ones the tests cover. Refused (naming the pattern): a computed pair whose p1 partial is rewritten or read between the ops (its hardware value P10·I would be observable), one whose ops are not in one basic block (the captured I would not dominate the p2), a dangling op without its partner, any computed pair under --bary-fallback or --f16-interp-fallback (neither has PerVertexKHR inputs; the latter's decoded-half read would otherwise drop the computed weights), and a computed 32-bit read of a 16-bit-flagged interpolant — every one empty over the corpus. Confirmed by tests/semantic/test_interp_computed_ij.py and tests/semantic/test_interp_guards.py (Vonsek's rows, the between-ops J, f16 pairs, the refusals, the relaxed classes) and the ps_ij_computed GPU test (RTX 5060 Ti: snapped quarter pair = 0.5, zeroed pair = P0 = 0, (i, j/2) halving the second weight with 0.0 max error over 4,096 pixels; the same fixture built on main is wrong on 4,096 of 4,096).
Whole-wave masks tools/lane_masks.py tracks per-lane mask bits through scalar registers, vector operations and saved EXEC spills. Whole-mask counts, first-set-lane queries, the leading-bit scans s_flbit_i32_b32 / s_flbit_i32 of vcc_lo/exec_lo (and _hi) and equality use subgroup operations (tests/semantic/test_salu_flbit_lane_mask.py; until then the flbit scans saw this lane's 0 / ~0). Whole-mask counts, first-set-lane queries and equality use subgroup operations. cs_wavemask checks all 64 lanes with a partially active EXEC mask. A physical 32-lane subgroup cannot directly exchange mask bits with the other half of a wave64, so cs_wavemask and the cs_wave64_ballot / cs_wm_* tests are exact only on 64-wide subgroups (AMD): on an RTX 4090 (subgroup 32) s_bcnt1_i32_b64 of lanes 16–47 counts 16, one half (#101). check.py skips them where the GPU has no 64-wide compute subgroup. A mask copied into a VGPR with v_mov_b32 goes through the normal EXEC-gated store, so inactive lanes keep the old VGPR (SHADER-21 part 2, #210); per-lane mask computations still store in all lanes, because whole-wave readers (wave_mask, v_readfirstlane) read every lane's bit. cs_mask_vgpr_exec checks it.
Floating-point operations Separate floating-point instructions carry NoContraction so the driver preserves their individual rounding. The instructions that fuse multiply-add (v_fma_f32, v_fmac_f32, v_fmaak_f32, v_fmamk_f32, v_fma_mix*) round once on RDNA2 (measured on gfx1150 by tools/f32_fuzz.py --oracle hw: 72 of 72 cancellation probes fused). SPIR-V has two ways to say that. GLSL.std.450 Fma is the default (--fma glsl), but the Vulkan SPIR-V environment gives it the precision "inherited from OpFMul followed by OpFAdd", so a driver may legally round twice; tools/f32_fuzz.py and runtime/test/shaders/cs_fma_fused.asm are the tests that notice. tools/f32_fuzz.py and runtime/test/shaders/cs_fma_fused.asm are the tests that notice — on an AMD Radeon RX 6800 (Mesa RADV 26.2.6-arch3.1, Linux), RADV/ACO actually splits 5 of the 7 f32 FMAs in cs_fma_fused under --fma glsl (folding/splitting against the live v_mul_f32 product a*a) and emits single-rounded v_fma_f32 (8/8 exact) under --fma khr. --fma khr emits OpFmaKHR (SPV_KHR_fma, capability FMAKHR; "correctly rounded"), which needs VK_KHR_shader_fma with shaderFmaFloat32 on the device. The index then lists capability FMAKHR, extension SPV_KHR_fma and feature shaderFmaFloat32 for exactly the shaders that use it, and the output of every shader without a fused multiply-add is byte-identical under both options. khr is not the default because a device without the extension would fail pipeline creation; a runtime that knows its device has shaderFmaFloat32 should translate with --fma khr. The f16 forms (v_fma_f16, v_fmac_f16, v_pk_fma_f16) never use either: they are exact round-to-odd arithmetic built from OpFMul/OpFAdd with NoContraction (Gen.fma_f16_odd), so a fused f32 Fma would not change them (v_fma_mixlo_f16/v_fma_mixhi_f16 under the toward-zero MODE are the exception: fma_mix_odd needs the exact product error Fma(x, y, -p), which is only guaranteed with OpFmaKHR), and an f16 OpFmaKHR (shaderFmaFloat16) is not used. There is no f64 fused multiply-add in the translator yet (v_add_f64 only).
NoContraction cost on MoltenVK (SHADER-234) MoltenVK's SPIRV-Cross turns each NoContraction OpFAdd, OpFSub and OpFMul into a call to a [[clang::optnone]] helper (spvFAdd, spvFSub, spvFMul), and Metal does not inline it. MoltenVK 1.4.2 and main up to at least 5189f8de are affected. SPIRV-Cross 98cbb7c0 inlines the helpers from MSL 3.2 with bit-identical output, and MoltenVK on macOS 26 or newer compiles MSL 4.0. On an Apple M3 Max, a translated compute shader of v_mul_f32, v_add_f32 and v_sub_f32 in a loop took 7.6 to 15.7 times as long on the GPU with the optnone helpers as with 98cbb7c0. With independent operations and no NoContraction, it took two thirds of the 98cbb7c0 time, which is the cost of the decoration itself (measurement). The same spvFMul helper drops the sign of a -0 product (SHADER-182, #1376).
NoContraction multiply on MoltenVK (SHADER-182) On MoltenVK, a multiply whose exact product is a negative zero (+0 × -1.5, -0 × 1.0) returns +0 in f32, f16 and packed f16 (#1203). MoltenVK's SPIRV-Cross turns every NoContraction OpFMul into its spvFMul helper, which returns fma(l, r, T(0)). A -0 product plus +0 is +0. The f16 multiplies are OpFMul on float or v2float, so they take the same path. So does the product inside fma_f16_odd: v_fma_f16, v_fmac_f16 and v_pk_fma_f16 return +0 for a -0 product plus a -0 addend. SPIRV-Cross 300681bb changes the addend to T(-0.0). MoltenVK 1.4.2 has the old helper, and so does MoltenVK main at 5189f8de (2026-10-13), which pins the parent commit aa217aeb. The translator does not change for this. MVK_CONFIG_FAST_MATH_ENABLED=0 does not help, because the helper itself adds +0, and per #1203 neither does SignedZeroInfNanPreserve (#664). Measured on an Apple M3 Max (macOS 27.3): Metal keeps the sign for a * b and for fma(a, b, -0.0) with MTLMathModeFast and with MTLMathModeSafe, and loses it only with the +0 addend. With valu_fuzz.py --family f16, MoltenVK 5189f8de as pinned matches 49/50 programs with --seed 1 --wave 32, 98/100 with --seed 1 --emulate and 98/100 with --seed 4 --emulate, and Homebrew MoltenVK 1.4.2 gives the same counts. Each mismatch is a -0 product read as +0. The same build with SPIRV-Cross 300681bb matches 50/50, 100/100 and 100/100, as does KosmicKrisp (Mesa 26.3.1). For the FMA path, --seed 330 --wave 32 with --skip-op v_mul_f16 --skip-op v_pk_mul_f16 matches 49/50 with aa217aeb (a v_fmac_f16 result) and 50/50 with 300681bb and on KosmicKrisp.
MoltenVK fast-math (SHADER-234, NaN compares) MoltenVK compiles every shader's MSL with Metal's fast-math on by default (MVK_CONFIG_FAST_MATH_ENABLED, default 1), and with it Metal folds an f32 compare of a NaN with itself as if the NaN were an ordinary number: v_cmpx_eq_f32 and v_cmpx_le_f32 on (NaN, NaN) give true where the ISA, AMD and NVIDIA give false (ps_vcmpx_forms, #1374: word 1 0xf05e8e16, want 0xf05e8a12, bits 2 and 10; found by @zneel and @DomasUrbonas). The translation is not involved: the compare is OpFOrdEqual / OpFOrdLessThanEqual, and the MSL MoltenVK generates (MVK_CONFIG_SHADER_DUMP_DIR) is byte-identical with fast-math on and off, so it is Metal's compile option. MVK_CONFIG_FAST_MATH_ENABLED=2 (on demand) does not help, because translated modules don't declare an execution mode that asks for IEEE behaviour; 0 does. The test tools (runtime/test/vulkan_loader.h, which every Vulkan test program uses to load MoltenVK) set MVK_CONFIG_FAST_MATH_ENABLED=0 before MoltenVK reads its configuration, unless the variable is already set, so a user's own value still wins; the variable also reaches MoltenVK through the Vulkan loader. A runtime that loads MoltenVK on a Mac must do the same. Fast-math off does not remove the [[clang::optnone]] spvFAdd/spvFSub/spvFMul helpers SPIRV-Cross emits for NoContraction (11 calls in ps_ops's MSL either way: their cost is the other part of SHADER-234), and it does not fix the row above (SHADER-182): valu_fuzz.py --family f16 --seed 1 gives the same v_mul_f16 +0 mismatch with fast-math on and off. Confirmed on an Apple A18 Pro (macOS 26.6.2, MoltenVK 1.4.2): ps_vcmpx_forms fails on all 4,096 pixels with fast-math on and matches all 4,096 with it off, natively and with wave64 emulation; no other run_gpu_tests.py result and none of the 25 ctest tests changes.
Denormal flush and special results in v_rcp_f32, v_rsq_f32, v_sqrt_f32, v_log_f32, v_exp_f32, v_rcp_iflag_f32 Measured on an RX 6800 (gfx1030, not the console's gfx1013) with raw kernels in both wave sizes and all four IEEE/DX10_CLAMP combinations: all six read a denormal input as a zero of its sign and flush a denormal result, even with MODE's denormal field set to keep them. v_rcp_f32(±0) = ±inf, v_rsq_f32(-0) = -inf, v_sqrt_f32(-0) = -0, v_log_f32(±0) = -inf, v_rcp_f32(FLT_MAX) = +0, v_exp_f32(-127) = +0, v_exp_f32(128) = +inf, and every invalid result (v_sqrt_f32/v_rsq_f32/v_log_f32 of a negative, …) is 0xffc00000. Each is within 1 ulp of correctly rounded on the values tried, and v_rcp_iflag_f32 is bit-identical to v_rcp_f32. Not modelled yet: the translator leaves all six on Vulkan's default denormal handling, and the ±0 and negative inputs above stay undefined in the emitted SPIR-V (OpFDiv by zero, Sqrt/Log2 of a negative), as listed in the multiply-add and output modifiers row; the clamp/omod bits on v_cvt_f32_* and v_rcp_iflag_f32 are modelled there. Source: @shelbykb2's hardware words, not the ISA text. The corpus only ever writes MODE's FP_ROUND field and carries mul:2/mul:4/div:2 on 102,365 float instructions (a compiler does not emit one that is ignored), so the inferred f32 state, IEEE off with denormals flushed, is the one to model. Corpus count (tools/shader_profile.py, 26,503 shaders; the shader count of each op deduplicates its _e32/_e64 forms): v_rcp_f32 17,393 shaders / 424,863 occurrences, v_rsq_f32 17,221 / 269,310, v_sqrt_f32 14,511 / 201,422, v_log_f32 8,454 / 90,199, v_exp_f32 8,603 / 148,846, v_rcp_iflag_f32 7,395 / 34,852; 20,193 shaders (76.2%) use at least one, 1,169,492 occurrences (2.6% of the corpus's 44,406,870 instructions).
f16 transcendentals (v_exp_f16, v_log_f16, v_rcp_f16, v_rsq_f16, v_sqrt_f16, v_sin_f16, v_cos_f16) Measured on an RX 6700 XT (gfx1031, not the console's gfx1013) with tools/f16_trans_sweep.py: all 65,536 inputs of each op, wave32 and wave64 (identical on every input), five MODEs (FUZZ-29). With f16 denormals kept (denorm_mode_16_64 = 3, the assembler default and what the translator assumes), v_exp/log/rcp/rsq/sqrt_f16 are correctly rounded on every input that is not a NaN (0 ulp). v_sin/v_cos_f16 take turns and reduce them exactly over the whole f16 range (no ±256 limit): compared with sin/cos(2πx), every result for
f64 literal sources For v_cvt_f32_f64 and either source of v_add_f64, a literal dword supplies bits 63:32 and bits 31:0 are zero. Inline integers are sign-extended and inline floats use their binary64 value. For example, gfx1030 llvm-mc encodes 1.5 as the literal word 0x3ff80000. The synthetic tests/semantic/fixtures/f64_literals.asm checks both source words in the translated SPIR-V, including the distinction between the printed literal 0x1 and inline 1. LLVM AMDGPU operand conversions
v_cvt_f32_f64 output modifiers Convert to f32, apply mul:2, mul:4, or div:2 if present, then apply clamp to [0, 1] if requested. LLVM GFX10 assembler tests confirm the modifier encodings. tests/test_f64_conversion.py checks the resulting SPIR-V data flow.
v_add_f64 output modifiers The double sum is scaled by mul:2, mul:4 or div:2 if present, then clamped to [0, 1] if clamp is set, as for f32 (clamp_mods_f64, GLSL.std.450 FClamp on the double, so a NaN result and the sign of a -0 result are left to the driver, also as for f32). Until 2026-11-22 both were ignored. Source: LLVM AMDGPU defines it as VOP3Inst<"v_add_f64", VOP3_Profile<VOP_F64_F64_F64>> (VOP3Instructions.td), and VOPProfile sets HasClamp (f64 is a modifier type) and HasOMod (floating-point destination) (SIInstrInfo.td). It is the only f64 arithmetic the translator handles; v_cvt_f32_f64 has the row above. tests/test_f64_output_modifiers.py checks the SPIR-V data flow; runtime/test/shaders/ps_f64_mods.asm is the GPU test (needs shaderFloat64, which vk_harness now enables when the fragment shader declares Float64), passed on an NVIDIA RTX 6000 Ada (driver 615.71.09, Linux; 4096/4096 pixels exact, and the main translator gives the predicted old words).
v_rcp_f64, v_rsq_f64, v_sqrt_f64 Double-precision reciprocal (OpFDiv %double 1.0 x), inverse square root (GLSL.std.450 InverseSqrt), and square root (GLSL.std.450 Sqrt), requiring Float64 (shaderFloat64). VOP3 input modifiers (abs, neg) apply to the double operand, and output modifiers (mul:2, mul:4, div:2, then clamp to [0, 1]) apply via clamp_mods_f64 (LLVM VOP1Inst / VOP_F64_F64 in VOP1Instructions.td, HasClamp and HasOMod via VOPProfile). Special-value edge cases (±0, negative inputs, NaN) follow the driver's SPIR-V OpFDiv/InverseSqrt/Sqrt rules, as for the f32 forms. Checked by tests/test_f64_transcendentals.py (SPIR-V data flow and spirv-val).
v_trunc_f64, v_ceil_f64, v_rndne_f64, v_floor_f64 Round binary64 toward zero, positive infinity, nearest-even, or negative infinity respectively; the result stays binary64. The translator maps these to GLSL.std.450 Trunc, Ceil, RoundEven, and Floor with shaderFloat64 (no intermediate f32). Register pairs are low word first, literal dwords fill bits 63:32 with a zero low word, and inactive lanes keep both destination words. VOP3 applies source modifiers before rounding and the existing f64 scale/clamp path afterwards. Sources: AMD RDNA 2 ISA §6.2.1 and §12.8 (VOP1 opcodes 23–26), and LLVM's GFX10 assembler tests. Value and SPIR-V checks: tests/semantic/test_f64_round.py. Hardware-confirmed natively on RDNA2 (gfx1036 iGPU, Windows driver 32.0.21042.62, tools/hw_oracle, wave32 and wave64 identical on every case) by @timelery: exact IEEE-754 rounding that keeps signed zeros and binary64 subnormals (ceil(+sub) = +1.0, ceil(-sub) = -0.0, floor(+sub) = +0.0, floor(-sub) = -1.0, trunc(±sub) = ±0.0, rndne(±0.5) = ±0.0, rndne(±1.5) = ±2.0, rndne(±2.5) = ±2.0, ±inf stays ±inf, and ±qNaN/±sNaN pass through unchanged under IEEE=0), where sub is the smallest binary64 subnormal; the hex literal dword populates bits 63:32 with a zero low word (v_floor_f64 v[4:5], 0x3ff80000 -> 0x3ff0000000000000); and the VOP3 output modifiers behave as for v_add_f64/v_sqrt_f64: applied on hardware under denorm16_64=0 and ignored under denorm16_64=3 (IEEE=0), while the translator applies them through clamp_mods_f64 as those rows do.
Floating-point class compare v_cmp_class_f32 writes the selected class to a lane mask. v_cmpx_class_f32 intersects the existing EXEC with that same predicate and preserves VCC, as specified in AMD's RDNA2 ISA §12.9. VOP3 abs and neg on src0 are applied as raw sign-bit moves on the 32-bit integer bits (OpBitwiseAnd 0x7FFFFFFF, then OpBitwiseXor 0x80000000) rather than FAbs/OpFNegate, so signalling NaNs stay signalling (class bit 0) and subnormals are never flushed. Hardware-measured natively on RDNA2 (gfx1036) via tools/hw_oracle (Ryzen 7 9800X3D iGPU, Linux AMDGPU DRM): 672/672 exact across 21 representative IEEE-754 values (including 5 sNaNs) × 4 modifier forms (v, -v, `
Float controls (NaN, ±inf, −0) (SHADER-99) RDNA2 float ops return NaN, ±inf and −0 as computed, and Vulkan lets the driver assume none of them occur unless the module says otherwise. Every module therefore declares OpExecutionMode %main SignedZeroInfNanPreserve 32 (capability SignedZeroInfNanPreserve, core since SPIR-V 1.4). Its index entry lists "float_controls": ["shaderSignedZeroInfNanPreserveFloat32"], the device property it needs; vk_pipeline_check skips the shader where that property is false, and --no-float-controls leaves the mode out. Measured on AMD Radeon RX 9070 XT (driver 26.11.2). Without the mode, runtime/test/shaders/cs_signed_zero_nan.asm gets 0 in out[4..7]: the x != x NaN checks fold to false and a NaN v_cvt_f16_f32 is lost. The f16 fuzzer (tools/valu_fuzz.py --family f16) also saw v_pk_mul_f16 −0 products come back +0, and, with integer f16 narrowing (#575), NaN results that were never stored. With the mode, the test and those programs match. Other drivers, from testers in #664: RADV (RX 7800 XT) folds the f16 NaN check (out[6]) without the mode; NVIDIA and Intel Arc keep all three either way. Apple GPUs (MoltenVK) report the property, and the mode fixes their NaN checks, but −0 products (out[0], out[2], out[3]) still come back +0 with or without it (#1203, SHADER-182). check.py and scripts/run_gpu_tests.py don't judge those three words on an Apple device. Mesa's llvmpipe, where the CI runs these tests, returns 0 for the 0 × inf NaN check (out[5]) with or without the mode, while its other NaN checks give 1 (#664), so out[5] isn't judged there (UNJUDGED_WORDS in check.py). f64 (SignedZeroInfNanPreserve 64) isn't declared yet.
Float controls (f16 denormals) (SHADER-526) RDNA2 keeps f16 denormals, so every module also declares OpExecutionMode %main DenormPreserve 16 (capability DenormPreserve, core since SPIR-V 1.4 like SignedZeroInfNanPreserve, so no extension at --target-env vulkan1.2). The translator models f16 arithmetic in f32 with integer narrowing (Gen.f16_bits), so an f16 denormal is an ordinary f32 value in the module and no f32 denormal is involved: the 16-bit mode is what governs the f16→f32 conversion the driver emits for an f16 source. NVIDIA flushed that conversion without it: in runtime/test/shaders/ps_sdwa_f16_const.asm the y lane (src0_sel:BYTE_1 of 2.0 is the denormal 0x0040 = 2^−18, × 1024.0 = 2^−8 = 0x1c00) read 0x0000, 4096/4096 pixels wrong, while x, z and w matched; with the mode the test is 4096/4096 exact (RTX 4070 SUPER, driver 610.88, Windows 11, validation layers on). The same lane read 0x0000 on an RTX 3090 (driver 610.88, found by @Rainmaker33). Assembling the same module with only the two DenormPreserve lines removed reads 0x0000 again, so it is the mode the driver honours, not a change in the translated code. Not every NVIDIA build flushes it: on main without the mode an RTX 4060 Ti (621.24), an RTX 5070 Ti (620.73.04, Linux) and an RTX 5080 (616.92) pass the test. The index entry lists "shaderDenormPreserveFloat16" after "shaderSignedZeroInfNanPreserveFloat32"; vk_pipeline_check skips the shader where the device reports that property false, and --no-float-controls leaves both modes out. Where the property is false the module has no f16 denormal guarantee, so an f16 denormal read can come back +0 exactly as in that lane above (NVIDIA's default without the mode); that is a value difference in the shader, and the GPU test's y lane is then expected to fail. The AMD Radeon iGPU (RDNA2, driver 24.10.24, Vulkan 1.3.280) reports shaderDenormPreserveFloat16 true with denormBehaviorIndependence 32_BIT_ONLY, and vk_pipeline_check builds the module and its pipeline there (ps_sdwa_f16_const: 1 module ok, 1 pipeline ok, wave32 and wave64); the GPU test itself skips on that device, which has 128 push-constant bytes where the test needs 144. tests/semantic/test_f16_denorm_preserve.py pins the mode, the index property and the four words.
Multiply-add with a literal v_fmamk_f32/v_madmk_f32 are D = S0 × K + S1 and v_fmaak_f32/v_madak_f32 are D = S0 × S1 + K, K being the 32-bit literal. LLVM prints them vdst, src0, K, vsrc1 and vdst, src0, vsrc1, K, so in print order all four are a[1] × a[2] + a[3] (fused for fmamk/fmaak). Until 2026-11-21 fmamk and madmk computed S0 × S1 + K. Source: RDNA2 ISA (V_FMAMK_F32, V_MADMK_F32) and the operand fields of the llvm-mc encoding. Checked by tests/semantic and GPU-checked with runtime/test/shaders/ps_fma_literal.asm on an NVIDIA GeForce RTX 2060 SUPER (Linux, driver 620.70.06): 4096/4096 pixels exact, and 4096/4096 differ with the old translator.
Multiply-add and output modifiers v_mac_f32 is the VOP2 form of v_mad_f32, not of v_fma_f32: the product is rounded before the add (OpFMul + OpFAdd, both NoContraction). It used to emit Fma, one ULP off on some inputs. Source: LLVM SIInstrInfo.cpp getNewFMAInst (V_MAC_F32 -> V_MAD_F32_e64, V_FMAC_F32 -> V_FMA_F32_e64). VOP3 clamp and mul:2/mul:4/div:2 now apply to v_cvt_f32_i32/u32/ubyte0..3, v_cvt_f32_f16 and v_rcp_iflag_f32 (they were dropped). Source: LLVM VOPProfileI2F (Ins64 = $src0, $clamp, $omod) and the float-source profiles. Found by tools/f32_fuzz.py (FUZZ-3: an exact-arithmetic model against the translated SPIR-V; 0 mismatches over 10,000 seeded programs after the fix) and pinned by runtime/test/shaders/ps_f32_mods.asm (tests/semantic/test_f32_valu.py); GPU-checked (TEST-298): ps_f32_mods gives the expected four words (0xc0256a01 0x3f800000 0x41e00000 0x3fc00000, so the v_mac_f32 product is not fused and the clamp, mul:4 and div:2 on v_cvt_f32_ubyte1/u32/f16 and v_rcp_iflag_f32 apply) on an NVIDIA GeForce RTX 2060 SUPER (Linux, driver 615.78.08); mul:2 on the conversions is not in that fixture. not yet GPU-verified. Still open: on some inputs the ISA defines a result but the emitted SPIR-V is undefined: v_rcp_f32(±0) (OpFDiv by zero), v_rsq_f32/v_log_f32 of ±0 or a negative, v_sqrt_f32 of a negative. v_cvt_pk_u8_f32(NaN) now selects +0 before FClamp (see "Float-to-byte pack"). v_rcp_f32(±0) (OpFDiv by zero), v_rsq_f32/v_log_f32 of ±0 or a negative, v_sqrt_f32 of a negative (v_cvt_pk_u8_f32(NaN) now selects +0 before FClamp, see "Float-to-byte pack").
Output modifiers on hardware (gfx1150) Measured on a Radeon 880M (gfx1150, RDNA3.5; not RDNA2) with tools/f32_fuzz.py --oracle hw, 46,967 programs: mul:2/mul:4/div:2 turn a -0 result (a flushed denormal result included) into +0, and are ignored with MODE.IEEE = 1; with f32 denormals kept they are also ignored for the ALU ops (the transcendental and cube ops still apply them). LLVM notes that omod mishandles signed zeros (SIFoldOperands.cpp) and D30209 describes -0 being forced to +0 before the modifier. The translator keeps -0 (OpFMul), so on that evidence it likely differs from hardware (see #1006). RDNA2 itself is unmeasured (see #1006). Also measured there: with denorm_mode_32 = 0 f32 denormal operands read as zero and denormal results flush (add/mul/fma/min/max/rounding ops, DX9 mul), exact with 3. v_fma_mix* f32 operands read as zero when denormal too (SHADER-298: gfx1036, 0x00000001, 0x807fffff, and the integer inline constants 1 and 64; f16 operands widen to normal values); its result is not flushed, since that was not measured. Invalid operations give 0xffc00000; a signalling NaN passes unchanged with IEEE off and is quieted with IEEE on. RDNA2 does the same: gfx1036 (the integrated GPUs of a Ryzen 9 7950X3D and a Ryzen 7 9800X3D; RDNA2, but not the console's gfx1013), seeds 1 to 6, 38,858 programs, 0 mismatch and 56 omod -0 → +0 deviations, with identical counts through the Linux libdrm launcher and the Windows HIP launcher; v_rcp_iflag_f32 with clamp/omod on the same GPU, 6,552 programs, 0 mismatch and 35 such deviations, otherwise behaves like v_rcp_f32. Also measured there: with denorm_mode_32 = 0 f32 denormal operands read as zero and denormal results flush (add/mul/fma/min/max/rounding ops, DX9 mul), exact with 3; invalid operations give 0xffc00000; a signalling NaN passes unchanged with IEEE off and is quieted with IEEE on. Details in docs/shader_validation.md ("32-bit float VALU on the GPU").
Output modifiers on hardware (gfx1150, RDNA2) Measured on a Radeon 880M (gfx1150, RDNA3.5; not RDNA2) with tools/f32_fuzz.py --oracle hw, 46,967 programs: mul:2/mul:4/div:2 turn a -0 result (a flushed denormal result included) into +0, and are ignored with MODE.IEEE = 1; with f32 denormals kept they are also ignored for the ALU ops (the transcendental and cube ops still apply them). LLVM notes that omod mishandles signed zeros (SIFoldOperands.cpp) and D30209 describes -0 being forced to +0 before the modifier. The translator keeps -0 (OpFMul), so on that evidence it likely differs from hardware (see #1006). RDNA2 does the same, rule for rule (SHADER-353): on an RX 6700 XT (gfx1031, a discrete RDNA2 part, not the console's gfx1013; AMD Windows driver 26.11.2), seeds 1 to 6, 39,101 programs, 0 mismatch and 66 omod -0 → +0 deviations. Per MODE, counting only the programs where the omod changes the result: with IEEE off and f32 denormals flushed (the game's mode) it is applied every time (2,680, and the 66 -0 results become +0); with denormals kept it is ignored by the ALU ops (1,811) and applied by v_rcp/rcp_iflag/rsq/sqrt/exp/log_f32 and the four cube ops (869, -0 → +0 only there); with IEEE on it is ignored (2,650) and a -0 result stays -0. Earlier, gfx1036 (the integrated GPUs of a Ryzen 9 7950X3D and a Ryzen 7 9800X3D) gave seeds 1 to 6, 38,858 programs, 0 mismatch and 56 such deviations, with identical counts through the Linux libdrm launcher and the Windows HIP launcher; v_rcp_iflag_f32 with clamp/omod on the same GPU, 6,552 programs, 0 mismatch and 35 such deviations, otherwise behaves like v_rcp_f32. Also measured there: with denorm_mode_32 = 0 f32 denormal operands read as zero and denormal results flush (add/mul/fma/min/max/rounding ops, DX9 mul), exact with 3. v_fma_mix* f32 operands read as zero when denormal too (SHADER-298: gfx1036, 0x00000001, 0x807fffff, and the integer inline constants 1 and 64; f16 operands widen to normal values); its result is not flushed, since that was not measured. Invalid operations give 0xffc00000; a signalling NaN passes unchanged with IEEE off and is quieted with IEEE on. Details in docs/shader_validation.md ("32-bit float VALU on the GPU").
Float min/max/med3 with NaN, v_fract Measured on an AMD Radeon RX 6800 (gfx1030, not the console's gfx1013) with the hw-oracle tool from the AnyPS5 project, 537 input rows in all four IEEE/DX10_CLAMP combinations and in wave32 and wave64, the same for every combination with quiet NaNs. v_min_f32/v_max_f32, v_min_f16/v_max_f16 and each half of v_pk_min_f16/v_pk_max_f16: one NaN operand gives the other operand, bits unchanged; both NaN give src0; -0 < +0. v_min3/v_max3 = f(f(s0, s1), s2) with that min/max. v_med3_f32/_f16: with any NaN operand the result is min3(s0, s1, s2), otherwise the median (-0 < +0). v_fract_f32 rounds x − floor(x) once and returns 0x3f7fffff (the largest float below 1) where that gives 1.0, e.g. fract(-1e-10); f16 gives 0x3bff; fract(-0) = +0, fract(±inf) = NaN, a NaN passes through. Measured natively on gfx1036 (RDNA2) in the MODE inferred for the game (IEEE 0, f32 denormals flushed): v_floor_f32, v_ceil_f32 and v_fract_f32 read a denormal operand as a zero of its sign (floor(-1e-45) = -0, ceil(+1e-45) = +0, fract of either 0), fract(±inf) is exactly 0xffc00000, and a NaN operand comes back unchanged, a signalling one too. The translator flushes the operand and selects those words itself (Gen.round_f32_flushed) instead of leaving them to the driver's f32 denormal handling, which Vulkan does not fix; until 2026-11-22 a driver that keeps denormals gave -1.0, +1.0 and 0x3f7fffff there. v_cvt_flr_i32_f32 likewise returns 0 for a negative denormal (the translator gave -1). Checked against 119 measured words by tests/semantic/test_alu_floor_ceil_fract_hw.py. For v_fract_f16, either infinity gives the gfx1036 word 0xfe00, or +0 with the DX10 clamp. The translator selects these results explicitly. The hand-written ps_fract_f16_infinity.asm fixture checks both signs, the preserved destination bits and a color channel computed from the result sign in the CPU interpreter (tests/semantic/test_fract_f16_infinity.py). A source neg on a signalling NaN operand still quiets it in the translator. Not changed: f16 fract(±inf) is 0xfe00 on the hardware and a quiet positive NaN in the translator, and neg on a signalling NaN operand quiets it in the translator. The translator emits NMin/NMax for these min/max ops (before: FMin/FMax, whose NaN result GLSL.std.450 leaves to the implementation). med3 is NMin(NMax(z, NMin(x, y)), NMax(x, y)) (until 2026-11-22 this used FClamp(z, lo, hi), which was GLSL.std.450 undefined whenever z was NaN or both x and y were NaN), and when an operand can be a NaN, OpIsNan of each such operand (none for an inline or literal constant that is not a NaN) selects NMin(NMin(x, y), z) instead; all 1-, 2-, and 3-NaN operand positions for both v_med3_f32 and v_med3_f16 were hardware-verified on RDNA2 (gfx1035, wave32 & wave64). FMin/FMax, whose NaN result GLSL.std.450 leaves to the implementation). med3 is FClamp(z, NMin(x, y), NMax(x, y)), and when an operand can be a NaN, OpIsNan of each such operand (none for an inline or literal constant that is not a NaN) selects NMin(NMin(x, y), z) instead. v_fract_f32 is Fract followed by OpFOrdEqual with 1.0 and an OpSelect of 0x3f7fffff, so the NaN of fract(±inf) is kept; v_fract_f16 does the same before packing and then replaces a packed 0x3c00 with 0x3bff (not after an output multiplier, where 1.0 can be a true result). Other FMin/FMax/FClamp uses (the clamp bit, LOD and conversion clamps, v_cvt_pk_u8_f32, the BVH slab test) are unchanged. Not modelled: signalling NaNs under IEEE mode; NaN under the clamp bit (hardware gives +0 with DX10_CLAMP=1 and the NaN with DX10_CLAMP=0; the translator still emits FClamp); the payload when all operands are NaN in the f16 or three-source forms (NMin and NMax only promise a NaN). The binary v_min_f32 and v_max_f32 forms explicitly select the first operand when the second is NaN, preserving the first quiet NaN's sign and payload when both are quiet NaNs, as measured on the RX 6800. The CPU test tests/semantic/test_minmax_f32_payload.py checks both operand orders using finite color exports. Also, without the SignedZeroInfNanPreserve execution mode Vulkan does not strictly guarantee NaN or signed-zero behaviour, so these rules hold where the driver keeps them. NaN under the clamp bit (hardware gives +0 with DX10_CLAMP=1 and the NaN with DX10_CLAMP=0; the translator still emits FClamp); the NaN payload when both operands are NaN (NMin only promises a NaN); and without the SignedZeroInfNanPreserve execution mode Vulkan does not strictly guarantee NaN or signed-zero behaviour, so these rules hold where the driver keeps them. With an output modifier (mul:2, mul:4, div:2) on v_fract_f16 the translator applies the modifier to the f32 fract before narrowing to f16; the hardware order of rounding and modifier for that case was not measured, so a result can differ by one f16 step for tiny negative inputs (e.g. x = -1e-4 with div:2). GPU-checked with runtime/test/shaders/ps_fnan_med3.asm and ps_fnan_fract.asm (inputs read from memory at run time) on an AMD Radeon RX 6800, Windows 11, driver 26.11.2: 4096/4096 pixels exact; on that driver the two med3 words differed before the change (0x40e00000 and 0x40600000 instead of 0x40a00000 and 0xc0200000), and so did the f16 fract word (0x3c00 instead of 0x3bff) once f16 results were narrowed with integer round-to-nearest; the f32 fract and the min/max words were already the hardware words there. tests/semantic/test_float_nan_fract.py runs the measured rows through the translator and the interpreter.
ds_swizzle_b32 An active destination reads the selected source lane's VGPR. If EXEC disables that source, the read returns zero; a disabled destination keeps its prior value. The hardware measurements confirm the disabled-source result on gfx1036 and gfx1150. In the seven-invocation CPU fixture, lane 6 selects lane 7, which is absent. The translator returns zero in that case; the corresponding result on hardware is unverified. The fixture exercises QUAD_PERM and SWAP in test_ds_permute.py.
Wave64 handling Wave size is detected per shader from the code (64-bit EXEC writes, exec_hi, v_mbcnt_hi, *_saveexec_b64/*_wrexec_b64, and 64-bit lane-mask SOP ops s_bcnt[01]_i32_b64 / s_ff[01]_i32_b64 / s_wqm_b64 / s_bfm_b64 even when the mask is an ordinary SGPR pair; mesh shaders are always wave64). Wave size comes from the sidecar fssm/<name>.fssm header flags word u32[0xD4] bit 5 (0x20 = wave32, 0 = wave64; fssm_header.wave_size()), cross-checked against wave64/wave32 code markers (WAVE64_RE / WAVE32_RE: a contradicting header and code listing raises Unsupported), and falls back to the code-marker heuristic (64-bit EXEC/VCC writes, exec_hi, v_mbcnt_hi, *_saveexec_b64/*_wrexec_b64, and 64-bit lane-mask SOP ops s_bcnt[01]_i32_b64 / s_ff[01]_i32_b64 / s_wqm_b64 / s_bfm_b64, plus wave64 for mesh shaders) when no FSSM-magic sidecar is present (FSPX programs or synthetic listings). Confirmed across all 26,503 corpus blobs with 0 contradictions against GFX10 SOP1/SOP2/SOPC/VOP3 encodings: 23,841 wave64 (1,154 CS, 195 GS, 9,282 MS, 10,974 PS, 2,236 VS) and 2,662 wave32 (1,535 CS, 1,127 PS); the code-marker heuristic alone misclassified 2,287 markerless wave64 shaders as wave32 (287 CS: 162 straight-line and 125 branchy, including 11 with v_readlane_b32, 35 v_readfirstlane_b32, 29 ds_swizzle_b32, 14 s_barrier; 943 PS: 906 straight-line and 37 branchy; 1,057 VS: 1,020 straight-line and 37 branchy); CPU-checked by tests/test_fssm_header.py and tests/test_fssm_wave_size.py. Until 2026-11-21 a mask-only wave64 program with no EXEC markers was translated as wave32, so s_bcnt1_i32_b64 counted one half (#210). GPU-checked with runtime/test/shaders/cs_w64_mask_detect.asm (48 set bits of (lane & 5) != 0) on NVIDIA GeForce RTX 5060 under LEONIDA_W64_EMULATE=1. The hardware lane is exact in compute and mesh shaders (LocalInvocationIndex mod 64 or 32) and is used by v_mbcnt and EXEC writes. In other stages it's the subgroup lane. Constant EXEC writes (s_mov_b32 exec_lo/exec_hi, K) set each lane from its own bit of K, as (K >> lane) & 1 (shift and mask: Intel's Windows driver evaluated OpBitFieldUExtract of a constant that fits in 16 bits with the lane taken mod 16, so exec_lo = 0xffff ran all 32 lanes; GPU-checked with runtime/test/shaders/cs_exec_const.asm on Intel UHD Graphics 770, driver 32.0.101.6129, and NVIDIA GeForce RTX 4080 SUPER); before, any non-zero constant turned every lane on. A register written to exec_hi sets lanes 32–63 only. VCC's halves follow the same rule while VCC holds a lane mask: a 32-bit write to vcc_lo sets lanes 0–31 of the mask and one to vcc_hi lanes 32–63 (until 2026-11-22 a vcc_lo write set all 64 lanes and a vcc_hi write never reached the mask that s_cbranch_vccz/v_cndmask read; CPU-checked by tests/semantic/test_wave64_vcc_half_write.py, not GPU-checked). Mask and 0/-1 half-writes to vcc_lo/vcc_hi keep VCC tracked as a lane mask across subsequent ops (s_bcnt1_i32_b64, further half-writes), whereas plain-data writes (s_buffer_load_dword vcc_lo, s_load_dword, scalar ALU, non-mask constants) end VCC's mask state and store the scalar word across all 64 lanes instead of updating only one mask half (confirmed on 1 wave64 PS in the 1.0.2.1 corpus and tests/semantic/test_wave64_vcc_half_write.py). GPU-checked with runtime/test/shaders/cs_exec64.asm: lanes 16–47 enabled from two constants, exact on a 32-wide-subgroup GPU. Still approximate on 32-wide subgroups: cross-lane ops between the two halves of a wave64 (readlane/permlane/DPP/shuffles across lane 31/32, wave-wide reductions). The metadata index marks every wave64 shader so a runtime can request requiredSubgroupSize = 64 where supported (AMD), which makes those exact too.
Lane select (v_readlane_b32 / v_writelane_b32) The lane is S1[4:0] in wave32 and S1[5:0] in wave64, from an SGPR or a constant, and EXEC is ignored (RDNA 3 ISA guide pseudocode for both opcodes; RDNA 2 has the same encoding and gives no pseudocode). Until #488 (SHADER-52) a wave32 shader masked with 63 as well: a lane select of 32 or more wrote no lane, and a read shuffled from a lane past the end of a 32-wide subgroup, which SPIR-V leaves undefined (NVIDIA wraps it, so reads happened to come out right there). Found by the FUZZ-7 cross-lane fuzzer: 23 of 100 random wave32 programs, each minimized to s_mov_b32 s28, K; v_writelane_b32 vD, x, s28 with K ≥ 32. GPU-checked with runtime/test/shaders/cs_w32_lane_wrap.asm (25 16 777 777) on NVIDIA GeForce RTX 5060 (#488) and RTX 4090 (subgroup 32, driver 621.14); tests/test_translate.py checks the masks in the SPIR-V, and tests/semantic/test_wave32_lane_select.py runs the shader across 32 lanes, where a mask of 63 is an out-of-range shuffle.
First active lane in a vertex shader (v_readfirstlane_b32, MoltenVK) A native v_readfirstlane_b32 is a ballot of the EXEC lanes, its lowest set bit, and a shuffle from that lane (lane 0 when no lane is on). In a vertex shader the lowest bit is taken with FindILsb over the ballot's four words (the lowest non-zero word wins), not with OpGroupNonUniformBallotFindLSB. The two give the same lane, because a ballot has no bit at or above the subgroup size. Other stages keep BallotFindLSB; the --wave64-emulate form already used FindILsb on its two mask words. Why: MoltenVK lowers BallotFindLSB, like the SubgroupSize built-in, to Metal's threads_per_simdgroup input, which a vertex function can't declare ("invalid 'threads_per_simdgroup' attribute for input declaration in a vertex function"), so every VS with a readfirstlane failed to compile there. Confirmed on an Apple M4 (MoltenVK 1.4.2): hand-written VS with subgroupBallotFindLSB or gl_SubgroupSize fail, and ballot, shuffle, broadcast-first, elect, votes, and ballot + findLSB + shuffle (32- and 64-lane forms) create. Corpus (1.0.2.1, translated from 4eb6155d): 572 of the 2,236 VS contain v_readfirstlane_b32, and exactly those 572 modules change; all 2,236 stay spirv-val-valid. VS pipelines on the M4 go from 667 to 672 of 2,236 on main (the rest fail on the subgroup lane built-in, #1784), and from 1,662 to 2,233 with #1784's vertex-subgroup workaround (its flag is not on main) (the 571 threads_per_simdgroup failures are gone). tests/semantic/test_vs_readfirstlane.py runs it on the wave interpreter with the first EXEC lane in word 0 and word 1.
Wave64 emulation (--wave64-emulate) Wave64 compute and mesh shaders exact on any subgroup size (32-wide NVIDIA, Intel, AMD in wave32 mode), with no subgroup operation at all. One invocation is still one lane. Everything a lane needs from the rest of its wave goes through a Workgroup buffer %x_buf: votes (s_cbranch_vccz/vccnz/execz/execnz, SCC of mask ops, s_cmp of masks), whole-mask words (s_bcnt1, s_ff1, v_mbcnt), v_readlane, v_readfirstlane, ds_bpermute, ds_swizzle, v_permlane16/x16. The program runs in rounds: in each round every wave that is neither done nor waiting at s_barrier runs one segment of its program (a basic block, cut at each cross-lane op), then the whole workgroup meets at one OpControlBarrier (Workgroup, AcquireRelease, workgroup + uniform + image memory) that sits in uniform control flow, because every invocation runs every round. A cross-lane op ends its segment after the lane has stored its value (per-lane data, double-buffered by round parity) or ORed its bit (two mask words per wave, three slots by round mod 3, each slot cleared two rounds after it was read); the code after it runs one round later, when all 64 lanes have written. SSA values live across a cut go through Function variables. s_barrier is a scheduler state: the wave stops running segments until every wave that isn't done is waiting, which is also how hardware counts finished waves. A memory access that conflicts with an earlier one in the same segment (read after write, write after read, write after write; LDS and buffer/image memory separately) starts a new round, so two halves of a wave in different subgroups access memory in instruction order, as the lanes of one hardware wave do. A scalar load (s_load*, s_buffer_load*) counts as a buffer read: until #1587 it was left out, so a store and a later scalar load of the same address shared a segment and the half in the other subgroup could load before this half had stored (valu_fuzz.py --family mem --emulate: lanes 32-63 read the fill pattern after an s_buffer_load/s_load of the slot lane 0 had written, on RDNA1 RADV and an RTX 5060; v_readfirstlane_b32, which gives that slot, already reads the whole wave). Pinned by tests/semantic/test_w64x_scalar_load_order.py (no segment of the emitted rounds accesses buffer memory after a write or writes after a read; three of its five cases fail without the rule). Confirmed by that CPU test and the ordering argument above; the race does not show on an RX 7900 XTX (AMD 26.10.1 LLPC, Windows 11): valu_fuzz.py --family mem --seed 5 --programs 21 --wave 64 --emulate matches 21/21 before and after the rule (3 runs each), so a GPU reproduction on RDNA1/RADV (where #1587 was found) is still pending. Not ordered: sampling an image the wave wrote. The missing lanes of a partial last wave read as 0. Without the flag the output is unchanged, apart from two fixes that apply to every wave64 compute/mesh shader: v_writelane_b32 selects the lane by the wave lane (on a 32-wide subgroup writes to lanes 32–63 were lost; cs_w64x_writelane), and ds_bpermute_b32 (see the LDS row). Fewer rounds, same results: a whole-mask read (s_bcnt1, v_mbcnt_lo/hi, ...) of the value of the same register (or EXEC) that an earlier read in the block already exchanged reuses that exchange (the value's identity is the SSA id last stored to the register, forgotten at block start and at any label); and a block that ends in a voted branch (s_cbranch_vccz/vccnz/execz/execnz) runs its successor in the round that reads the vote, since that segment only reads the vote and picks the next block (an inner loop in the scheduler, flag %x_chain). Both rules are pinned by cs_w64x_mask_reuse (a mask register and EXEC rewritten between reads), cs_w64x_mask_reuse2 (EXEC read twice, a read after a buffer store, one half of a mask pair rewritten while the other is kept, a voted branch whose successor starts with a load of the other half's earlier store) and cs_w64x_chain_barrier (a voted branch whose successor starts with s_barrier, two waves): expected values from the ISA, first run on the AMD 880M with its native 64-wide subgroup, then emulated on both GPUs; tests/test_translate.py counts the exchanges in the SPIR-V (one per value, a new one after a rewrite of the register or EXEC), and the translator refuses (Unsupported) a voted branch whose segment was not started by the vote's own round. Under --wave64-emulate, tools/wave64_emulate_opt.py runs three exact CFG/dataflow passes to eliminate redundant scheduler rounds and global OpSwitch blow-up (#884): (1) backward SCC liveness skips scc_from_mask / scc_any_half votes on lane-mask ops (s_*_saveexec_*, s_andn1/andn2_wrexec_*, s_and/or/xor/andn2/orn2/nand/nor/xnor/not_b64, s_wqm_*) whenever SCC is dead-out (never read before an unconditional overwrite or s_endpgm), (2) safe lane-local s_cbranch_execz/execnz region folding inlines single-entry, single-exit post-dominated regions with no cross-lane ops, no s_barrier, no unmasked side effects, no write_all_lanes mask spills, no EXEC-widening, no live-out scalars, and for each memory domain (mem/lds) either read-only accesses or an acyclic single write/atomic behind if (%active) (issuing any uniform x_memory_order split/barrier before the branch — including scalar s_load*/s_buffer_load* per #1587 — and chaining single-predecessor continuations), and (3) structured emulation (plan_structured_emulation, control_flow = "emulated wave64 structured") removes the global round-loop OpSwitch on multi-superblock reducible CFGs without non-uniform 32-bit half-mask SCC: single-wave workgroups (<= 64 threads) run 100% inline structured SPIR-V with direct workgroup barriers (0 OpSwitch, 0 x_spill, strictly monotone GEN/KILL 4-bit dirty_in memory ordering across blocks and loop back-edges), while multi-wave workgroups (> 64 threads, without divergent s_barrier) emit post-dominating spine blocks and barrier-free guards/loops (including live-out scalars, single-write stores, EXEC-widening, and read-only loops) inline and isolate any remaining wave-divergent barrier regions into local mini-schedulers (or a tail scheduler at early s_endpgm). Checked on the CPU by tests/semantic/test_wave64_emulate_opt.py (40/64/128/256-thread workgroup interpreter with strict uniform barrier checks, ScreenProbes-shaped chains, nested/reused saveexec folds, single-store WAR/RAW ordering, single-wave inline_all loop-carried WAR, monotone dirty_in regression after x_round, multi-wave structured_hybrid + local mini_scheduler, divergent s_barrier fallback, cs_w64x_saveexec_b64.s fixture, and negative controls; not yet GPU-verified for the structured emulation pass). (1) backward SCC liveness skips scc_from_mask / scc_any_half votes on lane-mask ops (s_*_saveexec_*, s_andn1/andn2_wrexec_*, s_and/or/xor/andn2/orn2/nand/nor/xnor/not_b64, s_wqm_*) whenever SCC is dead-out (never read before an unconditional overwrite or s_endpgm), and (2) safe lane-local s_cbranch_execz/execnz region folding inlines single-entry, single-exit post-dominated regions with no cross-lane ops, no s_barrier, no memory/LDS writes, no unmasked side effects, no write_all_lanes mask spills, no EXEC-widening, and no live-out scalars behind if (%active) (issuing any uniform x_memory_order split before the branch — including scalar s_load*/s_buffer_load* per #1587 — and chaining single-predecessor continuations), keeping all 64 lanes of each wave in the same scheduler round. Checked on the CPU by tests/semantic/test_wave64_emulate_opt.py (64-thread and 128-thread workgroup interpreter with uniform barrier checks, ScreenProbes-shaped chains, nested/reused saveexec folds, internal loop, cs_w64x_saveexec_b64.s fixture, RAW memory/scalar-load ordering, and negative controls for live-out scalars, stores, cross-lane ops, and EXEC-widening). scripts/bench_wave64.py times cs_bench_mix native and emulated and checks the emulated output bytes against the native AMD run. Cost: one workgroup barrier per segment, and %x_buf = (2·L + 6·W + 7) dwords for L invocations in W waves, counted in lds_bytes. GPU-checked on NVIDIA GeForce RTX 5070 Laptop (subgroup 32, driver 617.42) and AMD Radeon 880M (subgroup 64, AMD driver 26.11.2 LLPC): check.py 38/39 (the mesh test runs in the other script) and scripts/run_gpu_tests.py 40/40 on both with LEONIDA_W64_EMULATE=1, including every wave64 test (cs_wavemask, cs_wave64_ballot, cs_wm_*) and the cross-half suite cs_w64x_* / ms_w64x_ballot: readlane and writelane at lanes ≥ 32, readfirstlane with only upper lanes active, branches voted by one lane of either half, ballot + v_mbcnt_lo/hi compaction over 64 lanes (also in a mesh shader, 4096/4096 pixels), a 128-thread workgroup whose two waves take different branches, s_barrier between waves with different loop counts, LDS read-after-write and write-after-read across the halves without a barrier, a load, ballot and load in one block, and a partial wave (group 40). Without the flag the same RTX 5070 passes 19/37 (the wave64 tests skip there). Not covered: VS/PS/GS (no workgroup memory or barrier there). Known driver bug: AMD's Windows shader compiler for RDNA2 crashes (access violation in vkCreateComputePipelines) on many emulated compute shaders with LDS (#857: drivers 32.0.21030 to 32.0.21045.29003, iGPUs and RX 6000; 23.20.44, RDNA3, RDNA4, RADV and NVIDIA are fine), so make_game.py --wave64-emulate auto leaves emulation off when the runtime's GPU is such a device and runs wave64 natively (rdna2_amd_windows in tools/vk_subgroup_info.py, by PCI device ID and driver ID).
Workgroup memory limit (SHADER-309) A compute shader's Workgroup variables, the LDS array plus %x_buf (the wave64 exchange, 2·L + 6·W + 7 dwords, or the 3 barrier-round counts), must fit in the device's maxComputeSharedMemorySize. spirv-val does not check device limits, and RADV (Mesa 27.0.0-devel, RX 7600) dies with SIGFPE in vkCreateComputePipelines on a module 4 bytes over 64 KiB (#1721, hand-built repro by YaBulochka). The limit differs per device: 65536 on RADV and NVIDIA, 32768 on the AMD Windows driver (RX 9070 XT, 32.0.32029.2010) and Intel (UHD 770, 101.7092), measured by towade in #1745; the Vulkan minimum is 16384. The translator runs offline, so it has two parts. (1) rdna2spirv.py keeps every module under a hard cap, MAX_SHARED_BYTES (--max-shared-memory, default 65536): the LDS array is the program's need (RSRC2 LDS_SIZE, or the end of the furthest constant-offset access, counted exactly from the offset and the access width: a b32 at offset 65,532 ends at 16,384 dwords) rounded up to a power of two; when that plus %x_buf is over the cap but the need still fits, the array shrinks to the RSRC2 allocation and its accesses are bounds-checked (below); when the need itself does not fit (a 64 KiB LDS under --wave64-emulate) the shader is refused (Unsupported, with the byte counts). The array is clipped to 16,384 dwords, but an RSRC2 allocation over the cap (LDS_SIZE above 128 units, so 66,048 B or more) is counted at its full size and refused, native or emulated, instead of being cut. LDS bounds: RDNA2 LDS does not wrap, and an access outside the workgroup's allocation reads 0 and its write is dropped (RDNA2 ISA sections 3.6.1 and 3.6.6). The wrapped power-of-two array aliases such an access onto a valid word, so when a program's constant offsets reach past its RSRC2 allocation, or the array was shrunk, the array is the allocation and Gen.lds_access checks every dword (index < allocation, else a read or an atomic's old value is 0 and the write or atomic is skipped): ds_read*/ds_write* of every width (b64/b96/b128 and read2/write2 per dword), the sub-dword reads and writes, every LDS atomic, ds_cmpst, ds_mskor, ds_wrxchg*. ds_swizzle/ds_bpermute/ds_permute do not use %lds; ds_append/ds_consume were already refused. Every other shader keeps the wrapped array and emits no check, as before. Hypothesis, not yet counted over the corpus: the 16 of 486 LDS-using CS that index past LDS_SIZE with constant offsets (the Compute shaders row) now read 0 there, as the ISA says, where they used to read the wrapped word. Counted over a 1.0.2.1 corpus by towade (#1882, counts only): with the exact need (offset + access width) none of the 485 LDS-using CS reaches past its RSRC2 allocation with a constant offset, so none gets a bounds check (no OpULessThan added, native or emulated); the "16 of 486" in the Compute shaders row came from the older offset + 4-dword estimate. %x_buf is already sized to the workgroup's waves, so it has nothing to give back. lds_bytes in index.json is the module's whole Workgroup total (LDS, %x_buf, a mesh shader's %ms_counts). (2) The D3D12 shim's create_compute compares lds_bytes with the device's maxComputeSharedMemorySize and refuses the pipeline with a log line (E_NOTIMPL) instead of creating an invalid one. Pinned by tests/semantic/test_cs_shared_memory_limit.py (Workgroup bytes counted from the emitted SPIR-V: under the cap unchanged, shrunk to the 51,200 B allocation and bounds-checked, the exact-cap boundary, an access ending at 64 KiB counted exactly, a 64 KiB LDS refused when emulated and accepted natively, a native 66,048 B allocation refused, run through spirv_mini_interp: an out-of-range write dropped with the word it would wrap to intact, out-of-range reads (b32, u16) giving 0, a b64 write straddling the allocation's end, out-of-range atomics returning 0 and changing nothing, and an in-range shader with no check; lds_bytes equal to the SPIR-V total) and shader_library_test (lds_bytes read from the index). Confirmed by those CPU tests only; GPU runs (RADV; AMD Windows and Intel at 32 KiB) are pending. Not covered: mesh shaders against maxMeshSharedMemorySize.
Barycentric fallback (--bary-fallback) For devices without VK_KHR_fragment_shader_barycentric (NVIDIA Pascal, for one). The raw pair a PS reads ("PS system inputs": 321 PS) comes from an ordinary vec3 input, %bary, at the lowest location none of the shader's attributes uses, instead of BuiltIn BaryCoordKHR. The module then needs neither the FragmentBarycentricKHR capability nor the extension, and the index records the location as bary_fallback_input. The stage before the PS writes (1,0,0), (0,1,0), (0,0,1) at the triangle's three vertices: tools/bary_fallback_gs.py writes that pass-through geometry shader from the index (Position and the PS's input locations copied unchanged). Default (perspective) interpolation of those weights is the perspective-correct barycentric, the value BaryCoordKHR has, so .y/.z stay AMD's i/j; shaders that don't read the pair translate to the same module either way. GPU-checked on an NVIDIA GeForce GTX 1060 6GB (Pascal, no barycentric extension; driver 560.94, Windows 10) with LEONIDA_BARY_FALLBACK=1: ps_bary 4096/4096 pixels exact, and ps_uniform_branch and ps_scc_mask32 pass, through run_gpu_tests.py and build.py + check.py, with zero Khronos validation messages. Checked in tests/semantic/test_bary_fallback.py. For a known VS/PS pair, python -I tools/bary_fallback_gs.py DIR --pair VS PS builds PS.bary_gs.clipN.spv. It copies the producer’s ClipDistance[N] at each emitted vertex, using the VS index field clip_distance_count. On RTX 5080 and Radeon integrated graphics, two independently shifted clip planes yielded 512, 1024, 2048 or 4096 covered pixels, matching the native barycentric path. For a cull-only VS the pair writes PS.bary_gs.cullN.spv from cull_distance_count. A two-plane synthetic draw on the same GPUs covered 0 pixels when every vertex was negative for either plane and all 4096 when each plane had a nonnegative vertex. The helper rejects mixed clip/cull arrays. The runtime building that GS per pipeline is the follow-up (it needs the graphics pipelines of #291).
Metadata index spirv/index.json: one entry per translated shader with its stage, wave64 / subgroup_size, SPIR-V capabilities and extensions, the Vulkan features to enable (barycentrics, interlock, mesh, geometry, Float64, Int64, buffer device address, write-without-format, shaderFmaFloat32 for --fma khr, …), needs_maintenance8, the descriptor bindings it uses (set 0), push-constant size, local_size, user_sgprs (CS), lds_bytes, mesh max_vertices/max_primitives/params, geometry inputs/outputs, vertex-input locations and types, full vertex_input_signature (ISG1 register/mask/system-value/component-type, for PSO lookup), wave64_emulated (true for VS/PS/GS wave64, which the translator emits as per-subgroup code with no cross-half exchange, and for compute/mesh translated with --wave64-emulate; the runtime does not use it: it reads wave64, subgroup_size and wave64_exchange), dynamic_format (runtime V# FORMAT: codes outside FORMATS decode to 0) / fixed_format_codes, src_sha256 and optional fssm_sha256 (via --fssm-dir), PS system inputs, bary_fallback_input (--bary-fallback: the location of the barycentric input), mesh_compute (--mesh-compute: the slot layout and push-constant size), pc_tail (--pc-tail-ubo: the set, binding and size of the uniform block that holds the push-constant tail), and input/output locations. A shader translated with --wave64-emulate carries wave64_exchange: "workgroup" and subgroup_size: null: any subgroup size is exact, request none. Otherwise subgroup_size (64 for wave64, 32) is what the PSO asks for through VkPipelineShaderStageRequiredSubgroupSizeCreateInfo where the device lists the stage in requiredSubgroupSizeStages (docs/d3d12_vulkan.md section 3.2): that list is the driver's, not "compute/mesh only". The AMD Windows driver reports FRAGMENT, COMPUTE, TASK and MESH (measured on a Radeon 880M, driver 26.11.2, sizes 32..64), and current Mesa RADV on GFX10+ reports COMPUTE, FRAGMENT and task/mesh (src/amd/vulkan/radv_physical_device.c, requiredSubgroupSizeStages, Mesa main at 152b9cde; older Mesa: compute only), so wave64 pixel shaders can run exact there. NVIDIA lists every stage but only size 32, so there a native wave64 shader cannot get 64 and wave64 PS/VS/GS stay 2x32. A runtime can create every pipeline at load time from it without parsing SPIR-V.
Full-corpus pipeline build vk_pipeline_check <spirv dir> pipeline_cache.bin --jobs 4 on an RTX 4060 Ti (NVIDIA 595 driver): all 26,503 shaders become real pipelines, 0 failures (cs 2,689, ps 12,101, ms 9,282, vs 2,236, gs 195; graphics stages with generated stub partners). Compile time 40,784 s of CPU (2.84 h wall on 4 threads): cs 23,633 s (mean 8.8 s; the ray-tracing ScreenProbes/RTShadowTrace shaders take 2-19 min each), ps 11,481 s, ms 5,395 s, vs 275 s. The resulting VkPipelineCache is 3.81 GB; seeding a run with it makes those pipelines instant, which is what a fast first boot needs. The cache is per driver and GPU, and a shader whose SPIR-V changes compiles again (the checker resumes from the file). Neither register storage (one variable per register) nor smaller SPIR-V cut NVIDIA compile time: the big ray-tracing shaders are expensive as such, so the runtime should compile them in the background rather than block on them.
Wave-uniform branches VCC and EXEC are wave-wide registers, but one invocation holds only its own lane's bit. s_cbranch_vccz/vccnz/execz/execnz therefore reduce the condition across the subgroup (OpGroupNonUniformAny), so the whole wave takes the branch together, as on hardware. Before this, each lane decided alone. A lane could skip scalar instructions that the hardware wave executes (its SGPRs went stale for later code), and cross-lane ops or barriers inside the block saw a split wave. v_cmp/v_cmp_class/64-bit compares now write 0 for inactive lanes (hardware VOPC behaviour), so the reduction sees the true mask. GPU-checked with runtime/test/shaders/ps_uniform_branch.asm: lanes whose own VCC bit is 0 run the block's scalar add when their wave has any set bit. s_cbranch_scc0/1 stay per lane; SCC is uniform as long as the SGPRs feeding it are.
Compute shaders FSSM header word 0x138 = COMPUTE_PGM_RSRC2: USER_SGPR [5:1], TGID_X/Y/Z_EN [9:7], TG_SIZE_EN [10], TIDIG_COMP_CNT [12:11], LDS_SIZE [23:15] in 512-byte units. Words 0x13C/0x140/0x144 = thread-group size. This was checked against what all 2,689 CS read before writing: 2,281 match exactly, and the rest overshoot only through loop-carried registers in the straight-line check. 0x110, which looked similar, doesn't match. Layout: s0..user−1 = user data (push constants), then the enabled workgroup IDs (WorkgroupId), and v0/v1/v2 = thread ID x/y/z (LocalInvocationId, separate VGPRs on GFX10). Example: the 1,013 shaders with RSRC2 0x998 have 12 user SGPRs, group ID x/y in s12/s13, and compute x = s12·32 + v0. Shaders with TG_SIZE_EN are rejected for now. GPU-checked with runtime/test/shaders/cs_lds.asm through runtime/test/vk_compute_test.cpp: 4 groups × 64 threads, LDS exchange between the two waves of a group behind s_barrier, store through a V# into the device-address heap, 0 mismatches.
Signed-byte dot products v_dot4_i32_i8 D, S0, S1, S2 (VOP3P) is S2 plus the sum of the four products of the sign-extended bytes of S0 and S1, modulo 2^32; v_dot4c_i32_i8 D, S0, S1 (VOP2) adds the same sum to D. Emitted as four pairs of OpBitFieldSExtract, OpIMul and OpIAdd. Confirmed on RDNA2 hardware (gfx1036, raw kernels through tools/hw_oracle): 10 operand sets, both instructions and both source orders of the accumulating one, with sign-mixed bytes and sums that wrap; the measured words are the table in tests/semantic/test_alu_dot4_i8.py. clamp and op_sel/op_sel_hi are translated and checked against the same gfx1036 hardware table: clamp saturates v_dot4_i32_i8 to signed 32-bit [-2^31, 2^31-1] (both overflowing sets), and op_sel/op_sel_hi pick the 16-bit half of S0/S1 for byte pairs 0..1 and 2..3 (e.g. op_sel 2 / op_sel_hi 5 exchanges the 16-bit halves of S1, matching all 5 measured sets — the form of the 89 words llvm-mc does not decode, fspx.md); non-default S2 half selection stays refused. neg_lo/neg_hi, which llvm-mc accepts on v_dot4_i32_i8 only, are not ignored (neg_lo flips bit 15 and neg_hi bit 31 of S0 or S1, and on S2 neg_hi clears bit 31 before neg_lo flips it; 5 sets under 8 forms, 45 words): any set bit stays Unsupported, while an all-zero field is the plain instruction. Counts: the 29 FSPX programs use the pair 27,271 times (v_dot4c_i32_i8 25,813, v_dot4_i32_i8 1,458), all in 13 programs; none of the game's own 26,503 shaders has either encoding (0 of the 12,791 words llvm-mc cannot decode there with gfx1013).
Workgroup barriers s_barrier (cs/ms) is one OpControlBarrier (workgroup scope, workgroup memory). On RDNA every s_barrier counts against the same workgroup barrier and a wave that has ended no longer counts, while Vulkan requires a barrier to be reached by every invocation in uniform control flow. Under --wave64-emulate the round loop keeps a single barrier at the top level, so this holds. Native wave32 compute shaders run in barrier rounds when an s_barrier sits anywhere but a top-level block of the structured tree (one every invocation runs): under a guard, in a loop, or in the dispatch loop (needs_barrier_rounds, bar_scheduler). That is the emulated loop without its cross-lane part: s_barrier ends a segment, each invocation runs its blocks until its next s_barrier or the end, then the whole workgroup meets at one OpControlBarrier (the same workgroup/acquire-release/workgroup-memory semantics) at the end of the round. A wave that is done no longer holds the others, and a per-round count of the invocations not done (three Workgroup words, by round mod 3) ends the loop. Cross-lane operations stay subgroup operations, as in the dispatch loop, since a wave's lanes run the same segment. A barrier in a top-level block keeps the single OpControlBarrier in place. In the 1.0.2.1 corpus 43 of the 55 wave32 cs shaders with s_barrier have one nested (SHADER-91's count), so those 43 now run in rounds. Why: an Intel GPU does not survive the nested form. cs_barrier_divergent.asm (two barrier sites in different branches), cs_barrier_early_end.asm (the other waves end without a barrier) and cs_barrier_loop.asm (a barrier in a loop whose trip count differs per wave) each lose the device (vkQueueWaitIdle → VK_ERROR_DEVICE_LOST) on an Intel Arrow Lake Xe-LPG iGPU (Windows 32.0.101.8132), and cs_barrier_divergent hangs or writes nothing on a UHD 770 (101.6129, #634). With barrier rounds all three pass there and on an RTX 5070 Ti Laptop (617.42). NVIDIA passed them before too (RTX 4070 Ti on 610.88 and 621.24, RTX 5090 on Linux 595.99, RTX 5070 Ti). Still not proven on the native wave64 path (wave64 cs and every ms, run natively only on AMD's 64-wide subgroups): there the barrier stays where s_barrier is, inside a selection or loop construct in every ms and most wave64 cs shaders of the corpus. Branches are scalar, so whole waves take the same path, and RDNA's own barrier counts the way the shader expects.
LDS A Workgroup uint array sized from LDS_SIZE, rounded up to a power of two that also covers every constant offset (15 of 486 shaders index past LDS_SIZE). Covers ds_read/write_b32..b128, read2/write2 (+st64), u16/i16/u8/i8 reads (also ds_read_u16_d16/_d16_hi and, since SHADER-85, ds_read_u8_d16/_d16_hi and ds_read_i8_d16/_d16_hi: the byte is zero- or sign-extended 8→16 into one half of the destination VGPR and the other half is kept, per the RDNA2 ISA DS opcode descriptions (opcodes 162–165) and as for the u16 d16 reads; GPU-checked with cs_w32_lds_u8_d16.asm, byte values 0x80/0xFF/0x7F with a non-zero offset:), b16/b8 writes (atomic and/or, so neighbouring lanes don't race), the add/sub/min/max/and/or/xor atomics with and without return, wrxchg, cmpst (OpAtomicCompareExchange with DATA as comparator and DATA2 as value), and ds_bpermute_b32 as a subgroup shuffle. ds_permute_b32, its forward (scatter) form, has no Vulkan equivalent: each source lane that is on in EXEC publishes ((vAddr + offset) >> 2) mod 32 and each destination lane scans the 32 sources of its half and keeps the last one that targets it (a shuffle of target and data per source lane; under --wave64-emulate two buffer rounds and a Function variable instead). Per the ISA pseudocode (tmp[0..63] = 0; next if !EXEC[i] on the source; VGPR[VDST][i] = tmp[i] only if EXEC[i]): a destination lane nobody targets gets 0, an off source sends nothing, an off destination keeps its VDST, and the half rule above applies as for ds_bpermute_b32. When several sources target one lane the ISA leaves the winner unpredictable ("the value from one of the writers"; its pseudocode says the highest-numbered); the translator takes the highest, and nothing may depend on it. Confirmed by the GPU tests cs_w32_permute.asm and, per half of a wave64, cs_w64x_permute.asm (SHADER-90: rotation, offset, unwritten lane = 0, off destination keeps its value, off source does not win) and tests/semantic/test_ds_permute.py. Hardware-verified on RDNA2 (gfx1036, AMD Ryzen 7 9800X3D iGPU, Linux AMDGPU DRM via tools/hw_oracle, wave32 and wave64, SHADER-133) with tools/ds_permute_probe.py (9/9 cases exact in both wave sizes): unaddressed active lanes get 0, off destinations keep VDST, off sources send nothing, 2-/4-/32-way collisions deterministically take the highest-numbered active lane in the 32-lane half (matching the translator), vAddr + offset carries from the low 2 bits before >> 2 mod 32, wave64 runs as two independent 32-lane halves (+32 wraps within each half), and missing lanes of a partial wave (20 threads in wave32, 40 in wave64) send nothing. A source lane that is off in EXEC reads 0 and an off destination lane keeps its value (RDNA ISA §10.4.4), in wave32 as in wave64. In wave64 the permute also runs as two wave32s: each half reads lanes of its own half. Until 2026-11-21 lanes 32–63 of a 64-wide subgroup read the low half and inactive sources kept their value (cs_w64x_bpermute, AMD Radeon 880M); the wave32 path shuffled the raw value until the same day (cs_bpermute32: wave32, EXEC without lanes 8–15, so lane 6 reads 0; GPU-checked on RTX 5070 and Radeon 880M). A source lane that doesn't exist, in the missing lanes of a partial wave, also reads 0: the shuffle result is kept only where a ballot of the running invocations has the source lane, since SPIR-V leaves a shuffle from an invocation that isn't running undefined. Before this, RADV returned stale register values that changed between runs (cs_w64x_partial, a 40-thread group, native wave64 on AMD RX 6700 XT, RADV Mesa 26.3.1). Writes and atomics run only in active lanes. Indices wrap at the array size, where hardware would return 0 for out-of-range reads. s_barrier = OpControlBarrier Workgroup/Workgroup, AcquireRelease + WorkgroupMemory.
ds_cmpst_b32 The non-returning compare-and-store: M = (M == data0) ? data1 : M, the same OpAtomicCompareExchange as ds_cmpst_rtn_b32 with the old value dropped (operands vaddr, data0, data1). Source: RDNA2 ISA DS_CMPST_B32. CPU-checked by tests/semantic/test_lds_atomics_values.py; GPU-checked by runtime/test/shaders/cs_lds_b64_cmpst.asm (hit and miss on an RTX 3070, driver 621.01, Windows 11), and measured on native gfx1100 through tools/hw_oracle (hit, miss and hit-to-zero), where GFX11 spells it ds_cmpstore_b32 with the store value before the compare value. Not GPU-verified. GPU-checked by runtime/test/shaders/cs_lds_b64_cmpst.asm (hit and miss on an RTX 3070, driver 621.01, Windows 11).
LDS ADDTID (ds_read_addtid_b32, ds_write_addtid_b32) The LDS forms address one dword at M0[15:0] + offset + 4 * lane, where offset is an unsigned 16-bit byte offset and lane is the invocation index within the RDNA wave. The Workgroup array supplies LDS_BASE. The compute/mesh path uses the ordinary LDS addressing and EXEC guard. The GDS form raises Unsupported. Source: RDNA2 ISA §10.4 and §12.13 (opcodes 176/177), LLVM GFX1030 assembly syntax. tests/semantic/test_lds_addtid.py compares the two forms with ordinary LDS reads/writes over two waves, including partial EXEC and emulated wave64.
ds_add_f32, ds_add_rtn_f32 M = M + DATA as binary32 on the LDS dword (RDNA2 ISA, DS_ADD_F32); the _rtn_ form returns the old M. No core SPIR-V atomic adds floats on Workgroup memory, so it is an OpAtomicCompareExchange loop with an OpFAdd (round to nearest even, NoContraction). That is exact under contention: every update is one successful exchange of the value it read. Not measured: how the LDS adder treats denormals and NaN payloads; the result is OpFAdd's IEEE sum. The f32 min/max forms are #2495's. Until 2026-11-22 both raised Unsupported. CPU-checked by tests/semantic/test_lds_add_f32.py (a value grid, the non-returning form, offset:, ties to even, -0 + +0, overflow to ±inf, seeded values, against a once-rounded double sum). Not GPU-verified.
ds_mskor_b32, ds_mskor_rtn_b32 `tmp = M[A]; M[A] = (tmp & ~DATA)
ds_{inc,dec,rsub}_u32, ds_{min,max}_f32 (and _rtn_) 32-bit LDS atomics lowered inside Gen.lds_op via a Workgroup-scope OpAtomicCompareExchange CAS loop (no shader float atomic extension needed): ds_inc_u32 gives (M >= DATA) ? 0 : M + 1 (unsigned), ds_dec_u32 gives `(M == 0
ds_wrxchg2_rtn_b32, ds_wrxchg2st64_rtn_b32 Two atomic exchanges, addressed as ds_write2_b32 addresses its dwords: vaddr + offset0 * 4 and vaddr + offset1 * 4 (times 64 for st64). M[A0] = data0 and M[A1] = data1, and vdst (a VGPR pair) gets the two old words. Both exchanges run before either result is written, so vdst may alias the address or data VGPRs. When both offsets name one dword, the second exchange returns data0. Each exchange is atomic on its own, not the pair together, as on hardware (two DS operations). Until 2026-11-22 both ops raised Unsupported. CPU-checked by tests/semantic/test_lds_wrxchg2.py (offsets, st64 = 256-byte steps, the same dword twice, aliasing, a single-VGPR vdst rejected). Measured on native gfx1100: with vaddr 16 the offsets 0/4 read vaddr + 0 and vaddr + 16, the _st64_ form's offsets 1/2 read vaddr + 256 and vaddr + 512 (64 dwords per step), vdst takes the two old words, and with both offsets on one dword the second exchange returns data0; vdst may alias the address or the data pair, which still lands both data words in LDS and leaves the old words in vdst. Not GPU-verified.
ds_wrxchg_rtn_b64, ds_wrxchg2_rtn_b64, ds_wrxchg2st64_rtn_b64 64-bit LDS exchanges (two dwords, low first): M[A] = DATA, and vdst gets the old 64 bits. wrxchg_rtn_b64 has one element at vaddr + offset. The 2 forms have two, at vaddr + offset0/offset1 * 8 (times 64 for st64), as ds_write2_b64 addresses them, and vdst is four VGPRs. Each dword is its own 32-bit OpAtomicExchange, without Int64 atomics on Workgroup memory. All exchanges run before vdst is written. Approximation: two lanes exchanging into one element at once can tear it, leaving one's low dword with the other's high dword (A.lo, B.lo, B.hi, A.hi), which a 64-bit exchange never does; and the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done (as for ds_and/or/xor_b64). Until 2026-11-22 these three raised Unsupported. CPU-checked by tests/semantic/test_lds_wrxchg_b64.py (values, offset:, vdst aliasing the data, both 2 forms, st64 = 512-byte steps, bad operands rejected). Measured on native gfx1100: M[vaddr] takes the data pair and vdst gets the old pair, the 2 form's offsets 0/2 read vaddr + 0 and vaddr + 16 with four old dwords in vdst, and the _st64_ form's offsets 1/2 read vaddr + 512 and vaddr + 1024 (64 pairs per step). Not GPU-verified.
ds_and_b64, ds_or_b64, ds_xor_b64 (and _rtn_) M = M op DATA on the 64-bit LDS element at vaddr + offset (two dwords, low first); the _rtn_ form returns the old 64 bits in a VGPR pair. A bitwise op works on each bit alone, so it is emitted as one 32-bit OpAtomicAnd/Or/Xor per dword. That leaves exactly the memory a 64-bit atomic would, without Int64 atomics on Workgroup memory (optional in Vulkan). Approximation: the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done; the memory result is exact. The other 64-bit LDS atomics (add/sub/min/max_u64, wrxchg_b64, cmpst_b64) carry between dwords or need the pair to move together, and still raise Unsupported. Until 2026-11-22 these three were rejected as well. CPU-checked by tests/semantic/test_lds_bitwise_b64.py (all six forms, offsets, vdst aliasing the data, seeded values). Not GPU-verified. Measured on native gfx1100 for all six forms, both dwords of each pair, with the returning forms giving the old pair.
ds_bpermute_b32 subgroup convergence Native wave32 and wave64 apply bitwise masks to the shuffle result and the destination write so both the ballot and shuffle execute before lane predication. If the ballot has no source lane, the shuffle reads the calling lane before the result is masked to zero. MoltenVK 1.4.2 lowered the scalar selects to nested Metal ternaries, placing the subgroup operations in divergent control flow. The cs_bpermute32 inactive-source case returned 64 on an Apple M1 Max, and all eight fixture words match with bitwise masking.
LDS 2-address b64 (ds_read2_b64, ds_write2_b64, ds_read2st64_b64, ds_write2st64_b64) Two elements at vaddr + offset0·unit and vaddr + offset1·unit, unit = 8 bytes (×64 for st64); each element is two consecutive dwords, low first. read2_b64 fills v[d:d+3] after all four loads (a vdst overlapping vaddr is safe); write2_b64 takes two VGPR pairs. The b32 forms share the code with unit 4. Source: RDNA2 ISA DS 2-address forms. CPU-checked by tests/semantic/test_lds_read2_write2_b64.py (compute listings, LDS as a Workgroup variable); GPU-checked by runtime/test/shaders/cs_lds_b64_cmpst.asm (unit 8 and the 512-byte st64 forms, plus vdst/vaddr overlap, on an RTX 3070, driver 621.01, Windows 11).
Compute workgroup IDs Y/Z With four user SGPRs and only TGID_Y and TGID_Z enabled (RSRC2 0x308), s4 receives Y and s5 receives Z. The synthetic cs_workgroup_yz.asm fixture checks a 2 × 3 × 4 dispatch and each of its 24 origins against a CPU reference.
Typed image stores image_store (2D, 2D array, 3D) writes the dmask components (missing ones = 0). The image's numeric type lives in the T# (word 1 FORMAT [28:20], 512 GFX10 formats), so it is decided at run time. A 512-bit table built from tools/gfx10_formats.json (30 UINT and 15 SINT formats) picks a sint, uint or float view (bindings 8 + 3·dim + class; dim 0 = 2D, 1 = 2D array, 2 = 3D; class 0 float, 1 uint, 2 sint). Views have Unknown format (shaderStorageImageWriteWithoutFormat). The runtime binds every storage image into all three arrays of its dimension, or at least the one matching its format. The earlier path wrote only component 0 as r32ui, which was wrong for every other format. GPU-checked with runtime/test/shaders/cs_imgstore.asm through runtime/test/vk_store_test.cpp: rgba8 unorm, r32 uint and r32 sint images, every texel correct.
Typed image loads A noncoherent cube image_load reads the 2D-array sampled binding (3) with integer coordinates and layer. Its T# format selects the float, uint or sint alias, including for D16. The RDNA2 ISA §8.2.1 assigns D16 conversion to the image format. The synthetic cube_load_d16.asm checks the generated views and format choices on the CPU. image_load on 1D/2D/2D-array/3D images uses the same T# FORMAT tables as stores, and fetches every format with OpImageFetch from the sampled array of its dimension (bindings 0, 3, 6, 5): UINT/SINT formats through uint/sint aliases of that array (same set and binding, an OpTypeImage of %uint/%int; Vulkan allows several variables on one binding when the descriptor type fits), everything else through the float array. A lookup miss (index 0) takes the float path, since the fallback there is RGBA8_UNORM. Results are the raw bits of the dmask components. The runtime binds each image's view in its own format at its index of the sampled array (what bind_image in runtime/shims/d3d12_vulkan_device.cpp already does for SRVs and UAVs), so the view's numeric type matches the alias that reads it. No storage image is read, so shaders that only load need neither shaderStorageImageReadWithoutFormat (missing on Intel Xe-LP, #619) nor shaderStorageImageWriteWithoutFormat (SHADER-151). Until 2026-11-22 integer formats were read with OpImageRead from the uint/sint storage arrays (bindings 8–19), which hold only unordered-access views and 256 entries: a read-only integer texture found the fallback there, or an index past the array's end. Like the float path, the fetch goes through the texture path, so it sees writes made before the dispatch, not ones made earlier in the same dispatch. d16 loads take the same branch (#1136) and pack the dmask components two per VGPR, low half first: f16 (round to nearest even, integer ops, no PackHalf2x16) from the float array, the low 16 bits of each value from the uint/sint aliases (truncated). d16 loads take the same branch (#1136) and pack the dmask components two per VGPR, low half first: f16 (round to nearest even, integer ops, no PackHalf2x16) from the float array, each value from the uint/sint aliases saturated to the 16-bit range of its signedness (saturate_int16). For odd component counts (1 or 3 in dmask), the trailing destination VGPR preserves its existing high 16 bits (write_lo16), matching native gfx1036 hardware where a seeded 0x5a5a high half survived 1-component UINT/SINT image_load and image_load_mip; until 2026-11-22 the unused high half was zeroed. Before #1136, a d16 load always read the float view, so a Texture2D<min16uint> Load returned garbage. CPU-checked by tests/test_image_load_typed.py (capabilities, bindings and component types for every dimension; the branch for all 512 FORMAT values, found and missed). GPU-checked with runtime/test/shaders/cs_imgload.asm through vk_store_test load, on a device made without shaderStorageImageReadWithoutFormat: r32 uint and r32 sint images filled before the dispatch, both read with image_load and their sum stored, every texel exact on an RTX 2080 Ti (NVIDIA 621.14, Windows 11), clean under the validation layer with GPU-assisted validation; the test fails a module that declares StorageImageReadWithoutFormat. d16: CPU-checked by tests/test_image_load_d16_typed.py (the uint/sint fetches go through the aliases, no storage image is read, the SPIR-V validates); GPU-checked with runtime/test/shaders/cs_imgload_d16.asm through vk_store_test load: both pre-filled texels read with d16 loads (the sint one sign-extended from bit 15 in the shader) and their sum stored, every texel exact on the RTX 2080 Ti with GPU-assisted validation (#1136 checked its first form, a store and d16 read-back in one dispatch, on an RTX 5070, and cs_imgload_d16 passes unchanged on an AMD RX 7600 (gfx1102, RADV Mesa 27.0.0-devel) in run_gpu_tests.py). GPU-checked with runtime/test/shaders/cs_imgload_d16.asm through vk_store_test load: both pre-filled texels read with d16 loads (the sint one sign-extended from bit 15 in the shader) and their sum stored, every texel exact on the RTX 2080 Ti with GPU-assisted validation (#1136 checked its first form, a store and d16 read-back in one dispatch, on an RTX 5070). 2D image_load_mip uses the same numeric-type selection and passes the address register's mip to each fetch. Its D16 form packs the selected components in ascending order, two per VGPR. An RGBA8 two-level texture was checked on RTX 5080 and Radeon Graphics: all four exported halves matched the CPU reference for UINT, SINT and UNORM, and forcing level 0 changed every pixel. Checked on RTX 5080 and Radeon Graphics with R8G8B8A8 UINT, SINT and UNORM textures: level 1 matched the CPU reference at every pixel with GPU-assisted validation, and forcing level 0 changed all 4096 pixels for each format. Native gfx1036 saturated 32-bit UINT/SINT texels to the unsigned/signed 16-bit range in both D16 load forms; the translated 2D load matched both limits on RTX 5080 and Radeon Graphics. Native gfx1036 does the same on every dimension (SHADER-387, tools/image_d16_probe.py): 32_UINT and 32_32_UINT texels saturate to [0, 0xffff] and 32_SINT and 32_32_SINT texels to [-32768, 32767], never truncate, in 1D, 2D, 2D-array and 3D images, through image_load and image_load_mip alike; two-channel results pack x low and y high, and a one-channel result keeps the seeded high half. The translated d16 loads on 1D, 2D-array and 3D images still lack GPU checks.
Packed 2D mip-load addresses For image_load_mip with a16, the first VGPR holds unsigned X (low half) and Y (high half). The low half of the second VGPR selects the mip and its high half is unused. Both ordinary and D16 results use the same address. LLVM gfx1030 assembles both forms in tests/semantic/fixtures/packed_mip_load_2d.asm. tests/test_image_load_typed.py checks the texel and mip operands of the float, UINT and SINT fetches, including noncontiguous address registers. AMD RDNA 2 ISA, MIMG A16 field
3D explicit-mip loads image_load_mip reads x, y, z and mip from four address VGPRs. T# FORMAT selects the float, UINT or SINT 3D sampled view at binding 6. D16 narrows the selected components before packing them low half first. The synthetic translator tests check the four address registers and the RGBA32 format selection. Native gfx1036 measured UINT and SINT saturation for 3D image_load_mip at mip zero. Volume load measurements
Typed 2D gathers image_gather4_lz(_o) takes one channel from four taps. For image_gather4_l(_o) the four manual fetches share the rounded, clamped mip and addressed footprint. The T# FORMAT selects the float, UINT or SINT sampled image at binding 0. For d16, integer taps are packed low half first, two per VGPR; float taps round to f16.
Half-precision coordinates for LOD queries For image_get_lod a16 on 2D and 2D-array images, the low and high halves of the first address VGPR supply U and V. The array layer is excluded from OpImageQueryLod; the selected clamped and raw LOD outputs are f32. tests/semantic/fixtures/get_lod_a16.asm assembles for gfx1030 and checks the query operands and output components through tests/test_image_load_typed.py. AMD RDNA2 ISA, MIMG
Image atomics, size and LOD queries image_atomic_add/sub/and/or/xor/smin/smax/umin/umax are OpAtomicIAdd/ISub/And/Or/Xor/SMin/SMax/UMin/UMax on the texel (OpImageTexelPointer) of an r32ui storage image, binding 4 for 2D and 7 for 3D, at the T#'s index (the view StorageViews::r32ui of runtime/src/vulkan_bindless.h). The data VGPR is the operand; with glc it receives the texel's previous value, without it it is not written (RDNA2 ISA, MIMG: the previous value is returned if glc is 1). image_atomic_cmpswap takes two data VGPRs, the new value and then the comparand (OpAtomicCompareExchange). A lane that EXEC turns off leaves memory alone: cmpswap is skipped, the others run with the operand that changes nothing. image_get_resinfo (2D, no sampler) gives, for the mip level in its address VGPR, width, height, depth (0 for 2D; a 2D array's layers minified from BASE_LEVEL, T# word 3 [15:12]) and the level count in VGPRs 0..3, with width, height and depth 0 past the last level (the size isn't queried there) (ISA: {num_mip_levels, depth, height, width} in VGPRs 3..0; image_get_resinfo (2D, no sampler) gives, for the mip level in its address VGPR, width, height, depth (1) and the level count in VGPRs 0..3 (ISA: {num_mip_levels, depth, height, width} in VGPRs 3..0; OpImageQuerySizeLod, OpImageQueryLevels). image_get_lod (pixel shaders; 2D and 2D array, the slice ignored) gives the clamped LOD and the calculated LOD in VGPRs 0..1 (ISA: {rawLOD, clampedLOD} in VGPRs 1..0; OpImageQueryLod). In both, dmask keeps components and packs them into consecutive VGPRs. GPU-checked (TEST-184) on an RX 7900 XTX and a Ryzen 9 7950X3D integrated GPU (RADV, Mesa 26.3.1) and on Mesa llvmpipe, with the expected words derived by hand in each .asm header: cs_imgatomic.asm (every op on a 2D image: 0xfffffff0 tells the signed min/max from the unsigned ones, each with a case that goes the other way; cmpswap hit and miss; an op without glc; 63 lanes off; 64 threads adding to one texel) and cs_imgatomic3d.asm (six cases on a 4x4x4 volume, the three coordinates all different), through vk_store_test words; cs_resinfo.asm (a 16x4 image with five levels: levels 0, 1 and 3 in full, then dmask 0x3, 0xa and 0x8); ps_get_lod.asm and ps_get_lod_array.asm through vk_texture_test (calculated LOD 1 and 3 on the two-mip texture, the clamped LOD held at the last level, and at 0 by a sampler MAX_LOD of 0.25; 2 and -3 on the one-level array). Measured natively on RDNA2 (gfx1036, SHADER-388: tools/image_query_probe.py, 614 results in wave32 and wave64, all as follows). resinfo's depth word is 0 for a 2D image whatever T# WORD4 DEPTH holds; for a 2D array it is the layer count minified like a 3D depth, max(1, layers >> (BASE_LEVEL + level)). Past the last level, width, height and depth are 0. The level count is LAST_LEVEL - BASE_LEVEL + 1 and sizes count from BASE_LEVEL. The translator follows all three (Gen.resinfo_words; cs_resinfo.asm checks the 2D depth word and level 5 of five on RTX 5080 and Radeon Graphics, tests/test_translate.py the array rule). The translator still differs in the first three: it writes 1 for the 2D depth word and the full layer count for a 2D array, and OpImageQuerySizeLod past the last level is undefined. image_get_lod's raw LOD includes the S#'s LOD_BIAS. Its clamped LOD is min(max(min(raw, MAX_LOD), MIN_LOD), levels - 1) under a linear mip filter (MIN_LOD wins when it is above MAX_LOD), that value rounded half up (the level read) under a point mip filter, and 0 with MIP_FILTER none: OpImageQueryLod's definition. u is scaled by the width and v by the height (a 64x4 image). Unverified: resinfo's depth word on hardware (1 is what the T#'s DEPTH field says for a 2D image), the clamped LOD under a linear mip filter (the test's sampler is point-filtered, where 0.25 selects level 0), and the order of u and v in the LOD query (the test textures are square, where it makes no difference). image_get_resinfo on other dimensions is Unsupported. A host quirk the LOD test steps around: Mesa llvmpipe 26.3.1 does not apply a sampler's LOD range to OpImageQueryLod when its minimum and maximum are equal (0..0 gave level 1), so the second draw uses 0..0.25.
Hand-written short assembler forms llvm-mc accepts v_add_co_ci_u32 vD, src0, src1 (also v_sub_co_ci_u32, v_subrev_co_ci_u32) with the carry out and in left to VCC, and a modifier list shorter than the operands (op_sel_hi:[0,0], neg_lo:[1,0] on a three-source op), whose missing entries are 0; it prints them as v_add_co_ci_u32_e32 vD, vcc_lo, src0, src1, vcc_lo and [0,0,0]. The GPU runner assembles through llvm-mc -show-encoding, so it sees the printed form; tests/semantic/regen_fixtures.py copies the .asm text as written, so the translator takes the source spelling too (it used to raise IndexError for these: the carry forms, v_pk_fma_f16, v_fma_mix_*). A probe of 42,000 operand and modifier variations of 302 ALU mnemonics, in the source spelling and as llvm-mc prints them, found no other IndexError, KeyError or TypeError. CPU-checked by tests/semantic/test_short_asm_forms.py.
SDWA _sdwa forms: each source is narrowed to src0_sel/src1_sel (BYTE_n/WORD_n, zero-extended, or sign-extended under sext()) before neg/abs and the op. A VGPR result goes to dst_sel, with dst_unused setting the other bits: PAD = 0, SEXT = sign copies above the field, PRESERVE = old bits kept. A byte or word destination with PRESERVE reads its incoming VGPR on first use. The synthetic sdwa_bary_input.asm checks this with two raw fragment weights, following the LLVM SDWA destination rules. VOPC has no dst_sel, and GFX10 v_cmpx has no written destination. Until 2026-11-20 the selects were silently ignored. That affected 3,826 of the 13,926 translated shaders: they passed spirv-val but computed wrong values. GPU-checked with runtime/test/shaders/ps_sdwa.asm and ps_ops.asm (also v_pk_fma_f16, v_min3_u32, v_max3_i32, v_bfe_i32): byte/word source selects, sext(), UNUSED_PRESERVE into WORD_1 and UNUSED_SEXT at BYTE_2 all match on every pixel. Measured natively on RDNA2 (gfx1036 iGPU, tools/hw_oracle, the game's MODE): all 172 distinct SDWA forms of the 26,503 listings (79,307 instructions: opcode, operand kinds, sels, sext, neg/abs, dst_unused, omod), 12 operand words per source, 21,204 cases. 18,885 give the translator's word. The rest are: a 16-bit result with dst_sel:DWORD, where the hardware zeroes the high half and the translator keeps it (1,888, #2187); a NaN result, where the hardware keeps the input's sign and payload (826 counting those also in the first group, as in the f16 transcendentals row); div:2 on -0, which gives +0 (1, as in the output-modifier rows); and 160 cases whose translation is undefined in SPIR-V (FClamp/FDiv/Sqrt on NaN, zero or negative operands). tests/semantic/test_alu_sdwa_hw.py replays 624 of the matching words, up to four per form.
VOP3 output and source modifiers in the game's forms, on RDNA2 Every distinct float VALU form in the 26,503 listings that carries clamp, an omod (mul:2/mul:4/div:2), op_sel/op_sel_hi or neg/abs: 572 forms, 1,270,932 instructions (v_mul_legacy_f32 … clamp alone is 147,499; v_fma_mix_f32 has 222 forms), up to 120 random operand triples each, run natively on gfx1036 (tools/hw_oracle, the game's MODE) and through the translator: 542 forms, 64,802 cases (the GFX10.1-only v_mad_f32/v_mad_legacy_f32/v_mac_f32 and v_permlanex16 are left out). 51,761 give the translator's word. The rest are differences already on record: NaN sign and payload (5,074); f32 denormal operands or results, and a denormal intermediate that the hardware flushes before the omod or clamp (1,178; SHADER-377); an omod turning a -0 result into +0 (121; the Output modifiers rows, #1281); 1 ulp or the known sin/cos precision in v_rcp/v_rcp_iflag/v_log/v_sin/v_cos with an omod (56); and 6,430 whose translation is undefined in SPIR-V, mostly FClamp of a NaN, where the hardware gives +0 under DX10_CLAMP (#2437). 182 cases were my harness's (three distinct SGPRs, over GFX10's two-read limit). No other modifier difference. tests/semantic/test_alu_vop3_mods_hw.py replays 1,616 matching words, up to three per form; it fails without clamp (326 rows) or without the omod (237).
Byte permute v_perm_b32: result byte i = BYTE_PERMUTE({src0, src1}, selector byte i), src1 = bytes 0–3 (AMD "RDNA 2" ISA reference, VOP3 opcode 836 V_PERM_B32, byte_permute pseudocode, page 189 of the PDF). Selector 0–7 picks that byte; 8, 9, 10, 11 give 0xff if bit 7 of byte 1, 3, 5, 7 is set, else 0x00; 12 gives 0x00; 13 and above give 0xff. Until 2026-11-21 selectors 8–11 gave 0x00 regardless of the sign bit. In the 26,503-shader disassembled corpus (measured via tools/feature_scan.py), 0 of 10,500 shaders (11,930 v_perm_b32 instructions) use selectors 8–11 or >= 13: all 11,258 immediate and 672 constant-register selectors (0 unresolved) use only bytes 0–7 (36,234) and 12 (11,486). GPU-checked with runtime/test/shaders/ps_ops7.asm (also v_alignbit_b32 with a shift of 36, v_med3_i32 vs v_med3_u32) and ps_ops8.asm (v_mul_hi_u32/i32, v_bcnt_u32_b32, v_ffbl_b32, v_ffbh_u32 of 0, v_xad_u32, v_add3_u32), 4096/4096 pixels on an AMD Radeon iGPU (Ryzen 7 9800X3D, RDNA2, AMD driver 25.10.36) and an NVIDIA GeForce RTX 5070 (driver 621.24); before the fix ps_ops7 gave 0x00000000 for the sign-selector word on both. Also executed by tests/semantic/test_value_semantics.py. When S2 is a literal or a currently known SGPR constant, the translator emits fixed byte extracts/inserts (including sign replication), folds the zero and 0xff bytes, and uses the selected source directly for a whole-word identity. tests/semantic/test_perm_known_selector.py checks the resulting words and that selector dispatch only remains for a clobbered SGPR.
Sum of absolute differences (v_sad_u8, v_sad_hi_u8, v_sad_u16, v_sad_u32, v_msad_u8) Unsigned, wrapping at 32 bits, with ABSDIFF(x, y) = UMax − UMin: v_sad_u8 = S2 + the sum over the four bytes; v_sad_hi_u8 = (that byte sum << 16) + S2; v_sad_u16 = S2 + the sum over the two halves; v_sad_u32 = \
Quad-byte SAD 64-bit source operands The GFX10.3 null operand supplies zero for the 64-bit input window in all three quad-byte SAD operations and for the 64-bit addend of the two packed forms. Confirmed with LLVM gfx1030 assembly and scalar byte-difference references in test_alu_qsad.py and test_alu_mqsad_u32.py.
v_mqsad_u32_u8 Four masked byte-SADs with full 32-bit accumulators: D[k] = S2[k] + v_msad_u8 of the 32-bit window S0[8k+31:8k] of the 64-bit S0 against S1, wrapping at 32 bits (S2 and D are four VGPRs). Every source is read before the first write; clamp raises Unsupported. Source: RDNA ISA pseudocode. CPU-checked by tests/semantic/test_alu_mqsad_u32.py. Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle across 64-bit sliding window and masked byte values against the 32-bit accumulators: bit-exact with the ISA reference. Not GPU-verified.
s_sext_i32_i8, s_sext_i32_i16, s_flbit_i32 The first two sign-extend the low byte or the low half of S0 to 32 bits (OpBitFieldSExtract). s_flbit_i32 counts how many bits in a row from the MSB equal the sign bit, and gives −1 when all bits are the same (0 and −1); it is the scalar form of v_ffbh_i32 and goes through the same code. None of the three writes SCC. Source: RDNA2 ISA SOP1 opcodes 23, 25 and 26. CPU-checked by tests/semantic/test_salu_sext_flbit.py (#549): edge words with SCC starting at 0 and at 1, and 30 seeded values with long runs of sign bits. Not in the translated corpus, not GPU-checked. Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137, SCC kept). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle and tools/salu_diff.py (500 programs, --oracle translator,hw): 500 pass, 0 mismatches against the reference; confirmed s_flbit_i32 gives 0xFFFFFFFF for 0 and -1.
v_lerp_u8 Per byte i: D.b[i] = (S0.b[i] + S1.b[i] + (S2.b[i] & 1)) >> 1, an unsigned average where bit 0 of S2's byte decides whether 0.5 rounds up. The 9-bit sum shifted right by 1 fits back in its byte, so nothing carries between bytes. clamp raises Unsupported (the ISA doesn't define it for this op). Source: RDNA2 ISA VOP3 opcode 333. CPU-checked by tests/semantic/test_alu_lerp_u8.py (#577): a 9×9×5 grid of edge and rounding words, 40 seeded cases, an SGPR source with an inline S2, clamp rejected. Not in the translated corpus, not GPU-checked. Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137). Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle across byte edge values and rounding bit variations: 0 mismatches against the ISA reference.
Scalar select and pack (s_cmov_b32, s_cmovk_i32, s_cmov_b64, s_pack_ll/lh/hh_b32_b16) s_cmov_b32 / s_cmovk_i32: D = SCC ? S0 : D (s_cmovk_i32's S0 is the 16-bit immediate, sign-extended); SCC is read, not written; the destination must be an SGPR (a lane-mask destination stays Unsupported, #210). s_cmov_b64: D[63:0] = SCC ? S0[63:0] : D[63:0] on plain 64-bit data pairs (SGPR pair, immediate or null), SCC read and not written; a pair that is or has been a lane mask stays Unsupported (#210). D[63:0], SCC read and not written, on plain 64-bit data pairs (SGPR pair, immediate or null); any dword that is or has been a lane mask (EXEC, VCC or a mask SGPR) makes the pair Unsupported — conservatively, because a CFG join can drop a register that is a mask on only one path — while 0/-1 EITHER constants are data; selecting a per-lane bit as data would silently return a bool instead of the wave's mask (#210). s_pack_*: the low half of D from S0, the high half from S1, the letters naming the half of each (l = 15:0, h = 31:16), S0 first; GFX10 has no s_pack_hl; SCC not written. Source: RDNA2 ISA SOP1/SOP2/SOPK. CPU-checked by tests/semantic/test_salu_cmov.py and test_salu_pack.py; the translated shaders were run on NVIDIA by reviewers (s_cmov*: RDNA2 ISA SOP1/SOP2/SOPK and LLVM AMDGPU SOPInstructions.td (S_CMOV_B64 : SOP1_64 under Uses = [SCC]). CPU-checked by tests/semantic/test_salu_cmov.py, tests/semantic/test_salu_cmov_b64.py and test_salu_pack.py; not GPU-verified, no corpus count; the translated shaders were run on NVIDIA by reviewers (s_cmov_b32/k_i32: no corpus count; GPU-checked for s_cmov_b32 (cs_w32_salu64.asm, SCC = 1 selects S0) and s_pack_lh_b32_b16 (cs_w32_int_ext.asm) on the Radeon iGPU of a Ryzen 9 9950X3D (RDNA2, gfx1036, driver 26.10.1) and an RTX 5080 (driver 616.92); s_cmovk_i32, s_cmov_b64 and the other s_pack_* forms have no GPU test on main; the translated shaders were also run on NVIDIA by reviewers (s_cmov_b32/k_i32: RTX 5090, RTX 4050 and Radeon 740M in #613; s_pack_*: RTX 5090 in #449). Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137, SCC kept). Also measured on RDNA2 gfx1036 (Radeon iGPU of a Ryzen 9 9950X3D, Windows 11, driver 26.10.1, tools/hw_oracle HIP launcher, rocm-sdk-core clang): tools/int_hw_probe.py --oracle both --wave both gives the same words as the translator for all five salu_cmov_pack cases in wave32 and wave64, and the 14 s_cmov_b64 cases of the salu_cmov_b64 group (python -I tools/int_hw_probe.py --oracle both --wave both --group salu_cmov_b64; SCC 0 and 1; source an SGPR pair, the inline constants -1, -16 and 64, the literal 0x89abcdef, null, and the destination itself; SCC preset and read back after) match the translator in wave32 and wave64: SCC = 1 takes S0 (a literal zero-extended, an inline constant sign-extended, null gives 0), SCC = 0 keeps D, SCC is never written. Measured on native gfx1036 (AMD Radeon Graphics, RDNA2) through tools/hw_oracle and tools/salu_diff.py: s_cmov_b32 verified under SCC=0 and SCC=1 (preserving destination and updating respectively); s_pack_ll/lh/hh_b32_b16 verified bit-exact on 500 random programs with 0 mismatches (--oracle translator,hw). Not measured on RDNA2.
s_bfe_u32 / s_bfe_i32 past bit 31 offset = S1[4:0], width = S1[22:16] (7 bits; S1 bits 23 to 31 are ignored). When offset + width > 32 the field stops at bit 31: width = min(width, 32 - offset), and s_bfe_i32 sign-extends from the top bit that exists. Example: s_bfe_i32 s4, 0xd2f90159, 0x7f001c gives 0xfffffffd (4-bit field 0xd), not 0xd. SCC = D ≠ 0. Source: measured on gfx1150 (Radeon 880M) with tools/salu_diff.py --oracle hw, 4000 random control words, all bit-exact, on gfx1201 (Radeon RX 9070, RDNA4) with 10,000 salu_diff --oracle hw programs, 0 mismatches (seed 500 with --bfe-any), and on RDNA2 (AMD Radeon 680M, gfx1035: tools/salu_diff.py --oracle hw,translator --bfe-any --programs 500 --seed 1, 500/500 match, plus tools/int_hw_probe.py --oracle both wave32 and wave64, SHADER-137; and RDNA2 gfx1036, Windows 11, driver 26.10.1, tools/hw_oracle HIP launcher: tools/salu_diff.py --oracle translator,hw --bfe-any --ops s_bfe_u32,s_bfe_i32 --programs 2000 with seeds 1, 2 and 3, 6,000 of 6,000 programs pass on both sides, plus seed 4 over every opcode with --bfe-any, 2,000 of 2,000, and int_hw_probe.py's salu_bfe_past31 cases in wave32 and wave64); the translator (bfe_width) already did this. tools/salu_diff.py --oracle hw,translator --bfe-any --programs 500 --seed 1, 500/500 match, plus tools/int_hw_probe.py --oracle both wave32 and wave64, SHADER-137); the translator (bfe_width) already did this. Source: measured on gfx1150 (Radeon 880M) with tools/salu_diff.py --oracle hw, 4000 random control words, all bit-exact, and on gfx1201 (Radeon RX 9070, RDNA4) with 10,000 salu_diff --oracle hw programs, 0 mismatches (seed 500 with --bfe-any); the translator (bfe_width) already did this. LLVM's v_bfe fold (constantFoldBFE) is analogous but has a 5-bit width. RDNA2 is not measured; the ISA pseudocode does not say.
64-bit scalar data ops (s_brev_b64, s_bfe_u64/s_bfe_i64, s_bitset0_b64/s_bitset1_b64, s_flbit_i32_b64/s_flbit_i32_i64) The SGPR pair is 64-bit data, as for s_lshl_b64; a pair that lane_masks.py marks as a lane mask (or EXEC) stays Unsupported (#210). s_brev_b64: D.lo = reverse(S0.hi), D.hi = reverse(S0.lo). s_bfe_*64: offset = S1[5:0], width = S1[22:16]; width 0 gives 0; a field past bit 63 stops there (the 64-bit form of the s_bfe_u32 rule, LLVM constantFoldBFE); SCC = D ≠ 0. s_bitset*_b64: bit S0 & 63 of the pair cleared / set. s_flbit_i32_b64: zeros above the top 1 from bit 63, −1 for 0; s_flbit_i32_i64: the same of ~S0 when S0 < 0, −1 for 0 and −1. None but s_bfe writes SCC. Source: RDNA2 ISA SOP1/SOP2. CPU-checked by tests/semantic/test_salu_brev_b64.py, test_salu_bfe_64.py, test_salu_bitset_b64.py, test_salu_flbit_64.py (#723, #726, #729, #733). Not GPU-verified. Hardware-verified on an AMD Radeon RX 7900 XTX (gfx1100, Windows 11, driver 26.10.1), one raw wave32 kernel per op through tools/hw_oracle: s_brev_b64 of 0x12345678_0000000F has low word 0x1E6A2C48, s_bfe_u64(0x00000123_45678000, w16 o28) = 0x1234, s_bfe_i64(0x00000001_80000000, w2 o31) has 0xFFFFFFFF in both words, s_bitset1_b64(0, 40) has high word 0x100, s_flbit_i32_b64(0x00010000) = 47 and s_flbit_i32_i64(0xFFFFFFFF_FFFF0000) = 48. These are the words runtime/test/shaders/cs_w32_salu64.asm expects. Also hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137).
v_bfe_u32 / v_bfe_i32 past bit 31 offset = S1[4:0] and width = S2[4:0]: the bits above are ignored, so an offset of 36 reads as 4 and a width of 32 as 0 (a width of 0 gives 0). When offset + width > 32 the field stops at bit 31, as for s_bfe: width = min(width, 32 - offset), and v_bfe_i32 sign-extends from bit 31. Example: v_bfe_i32 of 0xd2f90159 with offset 28 and width 16 gives 0xfffffffd (4-bit field 0xd), not 0xd, and 0x80000000 with offset 31 and width 4 gives 0xffffffff. The translator (bfe_width for VGPR or SGPR offset and width, the same cut folded at translation time for constants) already did this. Source: measured on RDNA2, AMD Radeon 610M (gfx1036, Windows 11, AMD driver 32.0.11016.14003), wave32 and wave64 identical, 16 words over VGPR, inline-constant and literal operands: tools/int_hw_probe.py --oracle both --group valu_bfe_past31, 4/4 cases match the translator. The words are pinned on the CPU by tests/test_int_hw_probe.py (ValuBfeMeasuredOnRdna2).
s_quadmask_b32/_b64, s_bitreplicate_b64_b32 On scalar data (RDNA2 ISA SOP1): s_quadmask_b32 sets D[i] to the OR of S0[4i+3:4i] for the 8 quads, s_quadmask_b64 does the same for the 16 quads of the 64-bit S0 (D[63:16] = 0), and both set SCC = D != 0. s_bitreplicate_b64_b32 copies each bit S0[i] to D[2i] and D[2i+1] and leaves SCC. Built from fixed shift/mask steps, with no loop. A lane-mask source (EXEC, VCC or an SGPR that holds_lane_mask) or an EXEC/VCC destination raises Unsupported: each invocation holds only its own lane's bit, and these ops read the other lanes of a quad or move bits between lanes. Until 2026-11-22 all three were rejected. CPU-checked by tests/semantic/test_salu_quadmask_bitreplicate.py (fixed and seeded values, SCC written or kept, immediates, aliasing, lane masks rejected). Hardware-verified on an AMD Radeon RX 7900 XTX (gfx1100, Windows 11, driver 26.10.1) through tools/hw_oracle, one raw wave32 kernel per op: s_quadmask_b32(0xF) = 1 with SCC 1, (0xF0000000) = 0x80, (0x0F0F0F0F) = 0x55 (the set quads are 0, 2, 4 and 6), (0) = 0 with SCC 0; s_quadmask_b64 of 0xF = 1 and of 0xF0000000_00000000 (quad 15, bits 60..63) = 0x8000 in the low word with D[63:16] = 0; s_bitreplicate_b64_b32 of 5 = 0x33 and of 0x80000000 = 0xC0000000_00000000, with SCC left as it was. GPU-checked by runtime/test/shaders/cs_w32_new_ops.asm (s_quadmask_b32(0x01020408) = 0x55, s_quadmask_b64(0x80000000_00000001) low word 0x8001, s_bitreplicate_b64_b32(0x80000001) high word 0xC0000000, with the expected words from the ISA pseudocode), exact on the Radeon iGPU of a Ryzen 9 9950X3D (RDNA2, gfx1036, driver 26.10.1) and an RTX 5080 (driver 616.92). Not GPU-verified.
64-bit scalar bitwise ops (s_and_b64, s_or_b64, s_xor_b64, s_andn2_b64, s_orn2_b64, s_nand_b64, s_nor_b64, s_xnor_b64, s_not_b64) Dispatched like s_cselect_b64: when destination is exec/vcc or any source is a lane mask (holds_lane_mask or exec/vcc), uses the per-lane mask path (mask_src/mask_dst including null dst) and votes SCC across the wave (scc_from_mask). Otherwise operates on both 32-bit dwords of non-mask 64-bit scalar data (SGPR pairs, sign-extended inline/literal immediates, null = 0), reads all source dwords before storing (preserving destination aliasing), accepts null destination, and sets `SCC = ((D.lo \
Scalar select and pack (s_cmov_b32, s_cmovk_i32, s_pack_ll/lh/hh_b32_b16) s_cmov_b32 / s_cmovk_i32: D = SCC ? S0 : D (s_cmovk_i32's S0 is the 16-bit immediate, sign-extended); SCC is read, not written; the destination must be an SGPR (a lane-mask destination, and s_cmov_b64, stay Unsupported, #210). s_pack_*: the low half of D from S0, the high half from S1, the letters naming the half of each (l = 15:0, h = 31:16), S0 first; GFX10 has no s_pack_hl; SCC not written. Source: RDNA2 ISA SOP1/SOP2/SOPK. CPU-checked by tests/semantic/test_salu_cmov.py and test_salu_pack.py; the translated shaders were run on NVIDIA by reviewers (s_cmov*: RTX 5090, RTX 4050 and Radeon 740M in #613; s_pack_*: RTX 5090 in #449). Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137, SCC kept).
Constant lane masks (Gen.mask_src immediates) A constant read as a lane mask is one bit per lane: lane L takes bit L. The 64-bit forms (s_and/or/andn2_saveexec_b64, s_andn2_wrexec_b64, s_mov_b64/s_not_b64 into EXEC or VCC, s_and/or/xor/andn2/orn2_b64 and s_cselect_b64 on the lane-mask path) read the 64-bit value, an inline constant sign-extended (-16 = lanes 4-63) and a literal with a zero high word, as src64_data reads 64-bit constants; the b32 forms (s_*_saveexec_b32, s_andn2_wrexec_b32) read the 32-bit value at bit L mod 32. 0 and -1 still give no lane and every lane, with no per-lane code. s_bcnt0/1_i32_b64 of a constant counts the constant's 64 bits (scalar data, like s_ff0/1_i32_b64). Before this fix every lane took bit 0 of the constant: s_and_saveexec_b32 s7, 0xff00 with all 32 lanes on left none on, 5 left all 32 on, and s_bcnt1_i32_b64 s0, 0xff00ff gave 32. llvm-mc rejects a constant as the mask operand of v_cndmask_b32_e64 / v_add_co_ci_u32_e64 and decodes one as "Invalid immediate", so those VALU callers never see a constant. A constant held in an SGPR (s_mov_b32 s20, 0x3ffffc00) is read the same way when it reaches a mask consumer: mask_src takes bit L of an SGPR that holds_lane_mask doesn't flag (a pair in a wave64 64-bit context: the high SGPR for lanes 32-63). In a wave32 program a 32-bit bitwise SOP2 (s_and/or/xor/andn2/orn2/nand/nor/xnor_b32, s_cselect_b32) that writes EXEC/VCC reads both operands through mask_src (Gen.sop2_b32_srcs); into a plain SGPR it stays a data read, because lane_masks.py classifies that SGPR as data when the other operand is a constant (s_and_b32 s20, exec_lo, 1 then s_bcnt1 must count the wave's bits: found by @Pierre-Kookis on #1792, GPU-reproduced), and s_mov_b32 exec_lo/exec_hi, sN takes each lane's bit. A real mask is unchanged: it holds 0 or ~0 per lane, and bit L of that is the same 0 or 1. Until 2026-11-22 these took the value whole, so s_and_saveexec_b32 s6, s20 with that constant, or s_and_b32 exec_lo, exec_lo, 0xff00, left every lane on (found writing cs_w32_saveexec_ext, #1771; CPU-checked by tests/semantic/test_mask_src_sgpr_const.py, and tools/cf_diff.py / tools/salu_diff.py still pass). Not covered here: Not covered: a b32 op on one half of a wave64 mask, masks read as data (#293), and a literal with bit 31 set in a 64-bit position (zero- vs sign-extension not measured). GPU-checked with runtime/test/shaders/cs_w32_mask_imm.asm and cs_w64_mask_imm.asm on an NVIDIA GeForce RTX 5080 (driver 616.92; wave64 with LEONIDA_W64_EMULATE=1) and an AMD Radeon RDNA2 iGPU (driver 26.10.1, native 64-wide subgroup): both failed before on both GPUs. Run across every lane in tests/semantic/test_value_semantics.py (LaneMaskConstants).
Vector integer additions (v_mul_hi_u32_u24/v_mul_hi_i32_i24, v_lshrrev_b64/v_ashrrev_i64, v_qsad_pk_u16_u8/v_mqsad_pk_u16_u8) v_mul_hi_*24: the high 32 bits of the 48-bit product of the low 24 bits, zero-extended (u24) or sign-extended from bit 23 (i24); the high halves of v_mul_u32_u24 / v_mul_i32_i24. v_lshrrev_b64 / v_ashrrev_i64: the pair (or a 64-bit constant) shifted right by S0 & 63, logically or arithmetically, through the v_lshlrev_b64 code. v_qsad_pk_u16_u8 / v_mqsad_pk_u16_u8: D.u16[k] = (S2.u16[k] + byte SAD of the 32-bit window S0[8k+31:8k] against S1) & 0xFFFF; the m form skips bytes where S1's byte is 0; clamp raises Unsupported. Source: RDNA ISA pseudocode. CPU-checked by tests/semantic/test_alu_mul_hi_24.py, test_alu_shift_b64.py, test_alu_qsad.py; run on NVIDIA by reviewers (v_mul_hi_*24: RTX 5090 and RTX 5070 in #440; v_qsad/v_mqsad: 24 cases bit-exact on an RTX 3060 in #623). Not measured on RDNA2. Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137), and on native gfx1036 (AMD Radeon Graphics) with 0 mismatches across signed/unsigned products, shifts, and sliding windows. Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137).
64-bit constant vector compares For i64, u64 and f64, V_CMP writes the predicate to VCC or the named scalar mask, with inactive lane bits cleared. V_CMPX ANDs the predicate into EXEC and preserves VCC. Both predicates ignore the source values, including NaNs. The 12 instructions in tests/semantic/fixtures/vopc_constant_64.asm assemble for gfx1030 and are CPU-checked with active and inactive lanes in test_vopc_const_ordered.py. AMD RDNA 2 ISA, VOPC
Constant and ordered VOPC, v_cmp(x)_nlg_*, v_cvt_off_f32_i4, v_pipeflush v_cmp(x)_f_* is always false, v_cmp(x)_t_* (integers) and v_cmp(x)_tru_* (floats) always true; v_cmp(x)_o_{f32,f16} is true when neither source is NaN, _u_ when either is (OpIsNan), and _nlg_ when x == y or either source is NaN (OpFUnordEqual, completing all 16 IEEE-754 RDNA2 float VOPC predicates; LLVM gfx10_asm_vopc.s); the result goes through the usual VOPC path (VCC, an SGPR mask, or EXEC for v_cmpx; off lanes give 0). v_cvt_off_f32_i4: D = sext(S0[3:0]) / 16 (the ISA's CVT_OFF_TABLE, -0.5 .. 0.4375), exact, output modifiers apply. v_pipeflush only flushes the VALU pipeline and is translated as nothing, like v_nop. Source: RDNA2 ISA VOPC and VOP1. CPU-checked by tests/semantic/test_vopc_const_ordered.py, tests/semantic/test_float_compares.py (nlg; GPU-checked by ps_cmp_nlg.asm: f32 and f16 with ±0, quiet and signalling NaN, ±inf and ignored f16 high halves, the e64 form with abs/neg, and v_cmpx_nlg on equal and NaN operands, Tesla V100 (NVIDIA 580.95.05, Linux)), test_alu_cvt_off.py (GPU-checked by ps_cvt_off.asm, upper bits ignored and mul:4 with and without clamp), test_valu_pipeflush.py; the constant/ordered float compares were run on an RTX 5090 (16 draws, quiet and signalling NaNs) and the suite on RTX 4050 / Radeon 740M in #620; v_pipeflush on RTX 5090 / RTX 3060 in #735. All 16 f16 predicates (v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f16, e32 and e64) are GPU-checked on quiet and signalling NaN, +-0, +-inf, denormals and junk high halves by ps_vcmp_f16.asm and ps_vcmp_f16_e64.asm (RTX 5080 and Radeon gfx1036, 4096/4096 exact), CPU side tests/semantic/test_vcmp_f16.py. The 16 v_cmpx_*_f16 forms (e32 and e64) are GPU-checked the same way by ps_vcmpx_f16.asm and ps_vcmpx_f16_e64.asm (EXEC result on every case, VCC kept, EXEC only narrowed; RTX 5080 and Radeon gfx1036), CPU side tests/semantic/test_vcmpx_f16.py.
Relative VGPR moves (v_movrel*) The VGPR file is a Function-scope uint array, so v_movrels_b32/v_movreld_b32/v_movrelsd_b32 become dynamic array accesses at reg + M0 (the whole of M0, as the RDNA2 ISA's opcode descriptions say). v_movrelsd_2_b32 (VOP1 opcode 72) offsets each side by its own field: VGPR[D + M0[25:16]] = VGPR[S0 + M0[9:0]], other M0 bits ignored (RDNA2 ISA §12.8 opcode description and the RDNA3 ISA; the RDNA2 §6.6 summary table prints M0[7:0] for the source). The write keeps inactive lanes. Not modelled: the hardware's range check against the wave's VGPR allocation (an out-of-range source reads VGPR0, an out-of-range write is dropped). CPU-checked by tests/semantic/test_alu_movrelsd_2.py (including set ignored M0 bits); GPU-checked with runtime/test/shaders/cs_movrelsd_2.asm (the ISA's own example, v25 ← v17 with M0 = (20 << 16) \
v_swaprel_b32 GFX10 VOP1 opcode 104: swap VGPR[D + M0[25:16]] and VGPR[S0 + M0[9:0]], the two M0 fields v_movrelsd_2_b32 uses; the other M0 bits are ignored (RDNA2 ISA opcode description). Both registers are read before either is written. When both name one register it keeps its value. Inactive lanes keep both registers (OpSelect on active). As for v_movrel*, the hardware's range check against the VGPR allocation is not modelled. A non-VGPR operand raises Unsupported. Until 2026-11-22 the op raised Unsupported. CPU-checked by tests/semantic/test_alu_swaprel.py (both fields, ignored M0 bits, a self-swap, a register-file model). Hardware-verified on RDNA2 (gfx1035, Windows 11, driver 26.5.1, wave32 & wave64 via tools/int_hw_probe.py --oracle both --group valu_swaprel): M0[25:16] & M0[9:0] offsets, ignored upper M0 bits (0xfc01fc02), self-swap, and inactive EXEC lanes all match bit-for-bit.
Relative SGPR reads (s_movrels_b32, s_movrels_b64) D = SGPR[S0 + M0]; the b64 form reads the pair at S0 + M0 and S0 + M0 + 1 (RDNA2 ISA SOP1). The SGPR file is a Function-scope uint array, so this is a dynamic load, as for v_movrels. Every SGPR write stores into that array (store_reg), so the load sees the current value. All reads happen before the destination is written, so D may overlap the source. SCC is not written. The index wraps to the 128 array slots, so it cannot reach the lane-mask parking slots past them. An SGPR that lane_masks.py marks as a lane mask (a saved EXEC, a v_cmp result) holds only this lane's bit, so the whole wave's mask word is collected for each such SGPR (as for s_bcnt1) and read instead when the index lands on it; D then holds the mask as data (SHADER-284, CPU-checked by tests/semantic/test_salu_movrels_lane_mask.py, wave32 and wave64). Not modelled: the hardware's range check, and reads past s105 landing on VCC and the other special registers. s_movreld_b32/b64, the relative writes, stay Unsupported, because the translator keeps translate-time knowledge of SGPR values (literal S# words, descriptor caches) that a dynamic write would invalidate. Until 2026-11-22 both reads raised Unsupported. CPU-checked by tests/semantic/test_salu_movrels.py (M0 from 0 to 5 and from a register, the b64 pair, an overlapping destination, SCC kept, s_movreld rejected). Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137, SCC kept; lane-mask SGPR collection is CPU-checked only). Not GPU-verified.
d16 and f16 format narrowing The f16 of every d16 result (image samples and gathers, the image_sample_c_lz compare result, typed buffer loads) and of the f16 formats a typed buffer store writes is narrowed with integer ops (Gen.f16_bits; #489, #711), not with PackHalf2x16: to nearest even, except the typed-buffer float conversions, which round toward zero (below). AMD drivers lower PackHalf2x16 to v_cvt_pkrtz_f16_f32, which rounds toward zero (#489), and there about half of all unorm8, unorm16 and snorm8 values loaded with d16 came out 1 ulp low (123 of 256, 31,742 of 65,536 and 110 of 256). Packed MUBUF and MTBUF loads clamp unsigned 32-bit channels to 65535 before writing each half. On native gfx1036, values 65534 and 65535 survived, while 65536, 65537 and 0xffffffff all produced 0xffff, across all four load widths in wave32 and wave64. Packed buffer_load_format_d16_x and _xyz write only the low 16 bits of the final VGPR. Its upper half survives even when the load is out of bounds. Native gfx1036 wave32 and wave64 confirmed this with RGBA8_UINT and RGBA8_UNORM, two destination seeds, and both even-component loads as full-write controls. Full pairs are packed by pack_f16_pair_int and an odd final buffer component is narrowed with f16_bits for float/normalized formats. These memory conversions do not use f16_pack2: they come from the texture and buffer units, not the VALU whose rounding MODE.FP_ROUND sets (#753). Typed buffer floats are narrowed toward zero (SHADER-358). Measured natively on gfx1036 (RDNA2, wave32 and wave64, tools/hw_oracle): buffer_store_format_* into 16_FLOAT/16_16_FLOAT/16_16_16_16_FLOAT and buffer_load_format_d16_* from 32_FLOAT/32_32_FLOAT/32_32_32_32_FLOAT round an f32 toward zero, give ±65504 for a finite value past the f16 range (65520 stores 0x7bff, not infinity), flush an f32 denormal to a signed zero, keep infinities, and keep a NaN's sign and top 10 payload bits without quieting it (1 if those are 0: 0x7fa00000 gives 0x7d00, 0x7f800001 gives 0x7c01); gfx1150 does the same for the stores (#1548). The translator does that with Gen.mem_f16; until 2026-11-22 it rounded these to nearest even and overflowed to infinity. UNORM/SNORM d16 loads keep the rounding above (nearest even of the exact quotient, re-measured on gfx1036 for every 8-bit value and a 16-bit sample). Checked by tests/semantic/test_buffer_f16_narrowing_hw.py (45 measured values in four forms). Image d16 results are still inferred to round to nearest even (SHADER-308). #489's own narrower, f32_to_f16_int, was folded into f16_bits on 2026-11-22: the two gave the same bits on 30,648 inputs (every f32 exponent, ties, the subnormal and overflow edges, NaN), and f16_bits lost its one GLSL.std.450 instruction (UMin) so the packer stays free of them. For typed buffer loads the rounding is measured (BUILD-161, tools/d16_format_probe.py). On an RX 6700 (gfx1031, AMD Windows driver 32.0.21045.29003), every UNORM8, SNORM8, UNORM10, UNORM16 and SNORM16 value was loaded through buffer_load_format_d16_x and tbuffer_load_format_d16_x, in wave32 and wave64. The hardware rounds the exact quotient once, straight to f16, to nearest even, with f16 denormals kept (65,536 of 65,536 UNORM16 and SNORM16 values). It does not round to f32 first: that double rounding is 1 ulp high on exactly four values (UNORM16 0xffaf and 0xffef, SNORM16 0x7ff7 and 0x8009). Over every width from 1 to 16 bits, only two f32 quotients land on an f16 halfway point: 0x3f7ff000 (16379/16383, 32759/32767, 65519/65535) and 0x3f7fb000 (65455/65535). Gen.d16_norm_f16 takes the f16 below for those two, for normalized formats only; a 32_FLOAT 0x3f7ff000 is a real tie and still rounds to even. buffer_load_format_x without d16 returned the correctly rounded f32 quotient for all of them, the decode norm_bits builds. A 16_FLOAT d16 load returned its own bits for all 65,536 encodings. MUBUF and MTBUF agreed everywhere. For d16 image results, round to nearest even is still inferred, as in #489, not measured. #489's own narrower, f32_to_f16_int, was folded into f16_bits on 2026-11-22: the two gave the same bits on 30,648 inputs (every f32 exponent, ties, the subnormal and overflow edges, NaN), and f16_bits lost its one GLSL.std.450 instruction (UMin) so the packer stays free of them. Checked by tests/test_translate.py (test_depth_compare_sample_result_width, test_buffer_format_f16_narrowing_avoids_packhalf2x16), tests/test_d16_pack.py and tests/semantic/test_buffer_load_format.py (D16NormalizedRounding).
v_div_fixup_f16, v_div_fixup_f64 Final IEEE-754 special-case fixup for division (VOP3, S0 quotient, S1 denominator, S2 numerator): sign_out = sign(S1) ^ sign(S2); NaN(S2) → quieted S2; NaN(S1) → quieted S1; (0/0) or (±inf/±inf) → canonical negative qNaN (0xFE00 for f16, 0xFFF80000_00000000 for f64); (x/±inf), (±0/y), or guaranteed exponent underflow (exp(S2) - exp(S1) <= -25 for f16, <= -1075 for f64) → ±0 with sign_out; (x/±0), (±inf/y), or guaranteed exponent overflow (exp(S2) - exp(S1) >= 16 for f16, >= 1024 for f64) → ±inf with sign_out; otherwise copysign(S0, sign_out) (including NaN(S0) keeping its payload with sign_out). Computed bit-exactly on integer words (no OpCapability Float64 for plain v_div_fixup_f64); VOP3 input modifiers (abs/neg, plus op_sel:[s0,s1,s2,dst] on f16 with the unwritten half preserved) and output modifiers (mul:2/mul:4/div:2/clamp, enabling Float64 on f64) apply. Source: AMD RDNA 2 ISA reference (V_DIV_FIXUP_F16, V_DIV_FIXUP_F64). Not measured on RDNA2 hardware (translated GPU output checked on RTX 5070 by @duudiis). Checked bit-for-bit on the CPU (spirv_mini_interp) and with spirv-val by tests/semantic/test_alu_div_fixup.py; not run on the shader corpus.
Float-to-int saturation v_cvt_u32_f32 and v_cvt_i32_f32 truncate toward zero, saturate out-of-range values (including infinities) to the destination bounds, and return zero for NaN. The conversion operand is kept in range before emitting SPIR-V OpConvertFToU/OpConvertFToS. Source: AMD RDNA 2 ISA reference, §12.8, VOP1 opcodes 7 and 8. The synthetic cs_cvt_f32_sat.asm fixture is checked bit-for-bit by tests/semantic/test_float_to_int.py.
v_cvt_f16_u16, v_cvt_f16_i16, v_cvt_u16_f16, v_cvt_i16_f16 Conversions of the low 16-bit half (op_sel:[src,dst] picks the high half of the source / of the destination in the VOP3 form where supported; GFX10 does not accept op_sel on these opcodes); the other half of the destination is kept, like the other 16-bit-result ops (see 16-bit results). v_cvt_f16_u16 / v_cvt_f16_i16 convert the unsigned / sign-extended half and narrow with the usual f16 rounding (65520 and above give +infinity for the unsigned form). v_cvt_u16_f16 / v_cvt_i16_f16 truncate toward zero, saturate to [0, 65535] / [-32768, 32767] (an f16 infinity too) and give 0 for NaN, as the 32-bit conversions do (Float-to-int saturation). clamp and the output multipliers are rejected as Unsupported rather than guessed. Source: the AMD RDNA 2 ISA reference pseudocode. Checked on the CPU by tests/semantic/test_alu_cvt_16.py; hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137): all four _e64 forms keep the high half of the destination, v_cvt_u16/i16_f16 give 0 for ±qNaN and saturate ±inf, and v_cvt_f16_u16(65520) gives +inf (0x7c00). Not run on the shader corpus.
v_cvt_norm_i16_f16, v_cvt_norm_u16_f16 Normalized f16-to-16-bit integer conversions: round_even(clamp(S0, -1, 1) * 32767) (i16, snorm16) and round_even(clamp(S0, 0, 1) * 65535) (u16, unorm16), with NaN giving 0, source neg/abs and SDWA WORD_1 supported, and the unwritten half of the destination preserved (matching v_cvt_i16_f16/v_cvt_u16_f16; GFX10/LLVM does not accept VOP3 op_sel on these opcodes). For |cl| >= 0.25, cl * (scale + 1) is an exact even integer in f32, so cl * (scale + 1) - RoundEven(cl) rounds the exact product once without binary32 double-rounding ties near ±0.5. clamp and output multipliers (mul:*/div:*) are rejected as Unsupported. Source: AMD RDNA 2 ISA reference (V_CVT_NORM_I16_F16, V_CVT_NORM_U16_F16). Hardware-verified on RDNA2 (AMD Radeon RDNA2 iGPU gfx1036, Windows 11, driver 32.0.21043.5001, wave32 and wave64 via tools/hw_oracle, @Pierre-Kookis): 655,360 / 655,360 exact words across all 65,536 f16 inputs in five forms (_e32, _e32 ieee=1, _e64 -v1, _e64 |v1|, _sdwa WORD_1), including NaN → 0, ±inf clamps, denormals, single-rounding ties near ±0.5, and the untouched destination half. Checked on the CPU and with spirv-val by tests/semantic/test_alu_cvt_norm_f16.py; not run on the shader corpus.
v_frexp_mant_f32, v_frexp_exp_i32_f32, v_ldexp_f32 Computed on the binary32 word, with no float arithmetic. A normal input has a biased exponent of 1..254. v_frexp_mant_f32 returns the input with its exponent set to 126 (a mantissa in [0.5, 1), sign kept); v_frexp_exp_i32_f32 returns the biased exponent minus 126, so mantissa × 2^exponent is the input. Zero and denormals (read as zero) give a signed zero and exponent 0; infinities and NaNs give the input unchanged and exponent 0. v_ldexp_f32 is S0 × 2^S1 with S1 a signed integer: S1 is clamped to [-512, 512] and added to the exponent field; a new field above 254 gives ±infinity, one of 0 or below gives ±0 (no denormal results), and zero, infinities and NaNs ignore S1. Neg/abs, clamp and the output multipliers apply as for other float ops (not to the integer exponent result). Source: the AMD RDNA 2 ISA reference pseudocode for these three opcodes. Measured natively on an RDNA2 iGPU (gfx1036, tools/hw_oracle): under the MODE inferred for the game (IEEE 0, f32 denormals flushed) the hardware gives the translator's word for all 30 special inputs of each frexp op and 741 ldexp cases (denormal inputs, results in and below the denormal range, every exponent clamp edge, NaN payloads). With f32 denormals kept the hardware normalizes denormal inputs and returns denormal ldexp results, and with IEEE 1 it quiets signalling NaNs; neither is modelled, since the game runs with both off. Checked on the CPU by tests/semantic/test_alu_frexp_ldexp.py; not run on the shader corpus.
v_mad_u16, v_mad_i16 D = S0 * S1 + S2 on the low 16-bit halves (VOP3 only). The product and sum are formed in 32 bits, so nothing overflows, and the low 16 bits are the result. op_sel bits 0..2 read the high half of a source and bit 3 writes the high half of the destination; like the other opsel-capable 16-bit VOP3 ops the other half of the destination is kept (see 16-bit results). clamp saturates the full-width result to [0, 65535] (v_mad_u16) or [-32768, 32767] (v_mad_i16). Source: the AMD RDNA 2 ISA reference pseudocode and Mesa ACO's can_use_opsel. Checked on the CPU by tests/semantic/test_alu_mad_u16_i16.py; hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137): full-width clamp, op_sel and the untouched destination half match bit-for-bit. Not run on the shader corpus.
v_frexp_mant_f16, v_frexp_exp_i16_f16, v_ldexp_f16 The binary16 versions of v_frexp_mant_f32, v_frexp_exp_i32_f32 and v_ldexp_f32, computed on the f16 word of the low half with no float arithmetic (op_sel picks the high half of a source; the last op_sel bit sends the result to the high half of the destination; the other half of the destination is kept). A normal input has a biased exponent of 1..30. v_frexp_mant_f16 returns the input with its exponent set to 14 (a mantissa in [0.5, 1), sign kept); v_frexp_exp_i16_f16 returns the biased exponent minus 14 as a 16-bit integer, so mantissa × 2^exponent is the input. Zero and denormals (read as zero) give a signed zero and exponent 0; infinities and NaNs give the input unchanged and exponent 0. Zero gives a signed zero and exponent 0; infinities and NaNs give the input unchanged and exponent 0. f16 denormals are kept, as in the MODE inferred for the game (denorm_mode_16_64 = 3): a denormal input is normalized (v_frexp_mant_f16(0x0001) = 0.5 with exponent -23, 0x03ff gives 0x3bfe and -14). v_ldexp_f16 is S0 × 2^S1 with S1 the low 16 bits of the source read as a signed integer: S1 is clamped to [-64, 64] and added to the exponent field; a new field above 30 gives ±infinity, one of 0 or below gives ±0 (no denormal results), and zero, infinities and NaNs ignore S1. S1 is clamped to [-64, 64]; a result above the f16 range gives ±infinity, and one below the smallest normal is a denormal rounded to nearest even (1.0 × 2^-15 = 0x0200, 1.5 × 2^-24 = 0x0002, 1.0 × 2^-25 = 0, 65504 × 2^-30 rounds up to 0x0400); zero, infinities and NaNs ignore S1. Source neg/abs apply to the float operand. clamp and the output multipliers are rejected as unsupported rather than guessed. VOP3 clamp clamps the FP16 result of v_frexp_mant_f16 and v_ldexp_f16 to [0.0, 1.0] (negative values and NaNs clamp to +0.0, values > 1.0 and +Inf clamp to 1.0, [0.0, 1.0] kept; hardware-verified on gfx1036 with 302 kernels across wave32 and wave64). Output multipliers and clamp on v_frexp_exp_i16_f16 raise Unsupported. Source: the AMD RDNA 2 ISA reference pseudocode for these three opcodes. Not measured on hardware: the denormal input and result handling, the NaN payload, and whether v_frexp_exp_i16_f16 keeps the high half of its destination (it is modelled like the other 16-bit ops here, which keep it) are the translator's choice. Measured natively on an RDNA2 iGPU (gfx1036, AMD Windows driver 32.0.21045.16010, tools/hw_oracle) under IEEE 0, DX10_CLAMP 1, f32 denormals flushed and f16 denormals kept: the translated rule gives the hardware's word for every one of the 65,536 f16 inputs of both frexp ops and of v_ldexp_f16 under 16 exponents (1,048,576 cases), and the high half of the destination is kept by all three. Until 2026-11-22 the translator read f16 denormals as zero and flushed denormal ldexp results, which the hardware does only with denorm_mode_16_64 = 0. Not modelled (the game runs with IEEE 0): with IEEE 1 a signalling NaN is quieted (0x7c01 gives 0x7e01). Checked on the CPU by tests/semantic/test_alu_frexp_ldexp_f16.py, which holds measured words (including VOP3 clamp); not run on the shader corpus.
v_frexp_mant_f64, v_frexp_exp_i32_f64 Binary64 versions of v_frexp_mant_f32 and v_frexp_exp_i32_f32, computed bit-exactly on the (lo, hi) dword pair without requiring OpCapability Float64 or Int64 unless VOP3 output modifiers are used. A normal input has biased exponent 1..2046 (bits [62:52]): v_frexp_mant_f64 sets the biased exponent to 1022 (0x3FE00000, mantissa in [0.5, 1) with sign and low mantissa bits kept), and v_frexp_exp_i32_f64 returns e - 1022 as a 32-bit signed integer so mantissa × 2^exponent == input. Under the default f16/f64 denormal mode (denorm_mode_16_64 = 3, matching v_frexp_mant_f16/v_frexp_exp_i16_f16), non-zero subnormals (e == 0, 52-bit fraction ≠ 0) are normalized into [0.5, 1) with sign preserved and exponent msb − 1073 (-1073..-1022; e.g. 0x0000000000000001 → 0x3FE0000000000000 / -1073, 0x000FFFFFFFFFFFFF → 0x3FEFFFFFFFFFFFFE / -1022). Zero and denormals give signed zero and exponent 0; infinities and NaNs pass through unchanged with exponent 0. VOP3 source abs/neg flip/clear bit 31 of hi; VOP3 output modifiers (mul:2/mul:4/div:2, then clamp) apply to v_frexp_mant_f64 via clamp_mods_f64 (OpCapability Float64) and are rejected on v_frexp_exp_i32_f64. Source: AMD RDNA 2 ISA reference (V_FREXP_MANT_F64, V_FREXP_EXP_I32_F64) and LLVM VOP1Instructions.td. Measured natively on an AMD Radeon(TM) Graphics RDNA2 GPU (gfx1036, not the console's gfx1013; Windows driver 32.0.21042.62, tools/hw_oracle, wave32 and wave64 identical on every case): under IEEE=0, denorm_mode_16_64=3, DX10_CLAMP=1 all 71 cases (all 52 single-bit subnormal positions 0..51, lo/hi boundary-crossing multi-bit subnormals, negative subnormals, ±0, normals, ±inf, qNaN, sNaN, plus VOP3 abs/neg/clamp) matched bit-for-bit. Until 2026-11-22 the translator flushed binary64 subnormals to ±0 / exponent 0, which the hardware does only under denorm_mode_16_64=0. Not modelled (the game runs with IEEE=0, denorm_mode_16_64=3): IEEE=1 quieting signalling NaNs (0x7FF0000000000001 → 0x7FF8000000000001), denorm_mode_16_64=0 flushing subnormals, and denorm_mode_16_64=3 ignoring omod. Not measured on hardware (denormal input handling and NaN payload follow the f32 rule). Checked on the CPU and with spirv-val by tests/semantic/test_alu_frexp_f64.py; not run on the shader corpus.
v_min3_f16, v_max3_f16, v_min3_i16, v_min3_u16, v_max3_i16, v_max3_u16, v_med3_i16, v_med3_u16 Three-operand 16-bit min/max/median (VOP3 only). op_sel bits 0..2 read the high half of S0..S2, bit 3 writes the high half of D, and the unwritten half of D is kept (see 16-bit results). v_min3_f16 and v_max3_f16 read each selected f16 half through Gen.f16_in (neg/abs apply to the selected half), fold with NMin/NMax (so a NaN operand yields the other operand and −0 orders below +0, matching v_min3_f32/v_max3_f32 and v_med3_f16), then apply VOP3 omod/clamp and Gen.f16_out. The 16-bit integer ops zero-extend (u16) or sign-extend (i16) the selected 16-bit halves, evaluate UMin/UMax/UClamp or SMin/SMax/SClamp, and write the low 16 bits into the selected half of D; clamp is supported on integer min3/max3/med3 as an identity no-op on the 16-bit container (hardware-verified on gfx1036 across wave32 and wave64); non-VGPR op_sel destinations raise Unsupported. clamp and non-VGPR op_sel destinations raise Unsupported. Until 2026-11-22 all eight raised Unsupported. Source: AMD RDNA 2 ISA reference VOP3 opcodes 0x351–0x356, 0x359–0x35A, and Mesa ACO's can_use_opsel. Hardware-verified on RDNA2 (gfx1036 iGPU, AMD Windows driver 32.0.21045.16010, tools/hw_oracle, IEEE 0 with f16 denormals kept): 6,092 cases (every triple of ±0, a denormal, 1.0, -1.0, 2.0, ±inf, a quiet and a signalling NaN for each f16 op; every triple of 8 edge values for the i16/u16 ops; op_sel on each source and the destination; a 0xabcd high half on every source) give the translator's word, the kept destination half included, except one: with all three operands NaN the hardware returns src0's NaN bits unchanged (0x7c01 stays a signalling NaN under IEEE 0), the translator a quiet NaN, as for the 32-bit ops (Float min/max/med3 with NaN). tests/semantic/test_alu_min3_max3_med3_16_hw.py holds 540 of the measured words, and ALL_NAN_SRC0_SIGNALLING there holds the 8 all-NaN min3/max3 rows with a signalling src0 (an expectedFailure until the translator keeps src0's bits). tests/semantic/test_alu_min3_max3_med3_16_hw.py holds 540 of the measured words. Not GPU-verified. CPU-checked by tests/semantic/test_alu_min3_max3_med3_16.py, tests/test_f16_op_sel.py, and tests/test_f16_op_sel_values.py. CPU-checked by tests/semantic/test_alu_min3_max3_med3_16.py, tests/test_f16_op_sel.py, and tests/test_f16_op_sel_values.py; also hardware-verified on RDNA2 (gfx1035, Windows 11, driver 26.5.1, wave32 & wave64 via tools/int_hw_probe.py --oracle both --group valu_min3_max3_med3_16): all eight ops (op_sel, untouched destination half, NaN, −0/+0 ordering, and v_max3_f16 clamp) match bit-for-bit.
v_cvt_flr_i32_f32, v_cvt_rpi_i32_f32 RDNA ISA pseudocode: f32_to_i32(floor(S0)) and f32_to_i32(floor(S0 + 0.5)), the + 0.5 rounded in binary32 like any f32 add (so 0.49999997 gives 1, where an exact round-half-up would give 0). f32_to_i32 saturates as in the row above: INT_MAX / INT_MIN at or past ±2³¹ and for ±inf, 0 for NaN. sat_i32(floor(S0)) and exact sat_i32(floor(S0 + 0.5)) (computed via f = Floor(x); (x - f >= 0.5) ? f + 1 : f, with no binary32 rounding of S0 + 0.5: 0x3effffff → 0, 0x4b000001 → 0x00800001, 0x4b7fffff → 0x00ffffff). Out-of-range values (±2³¹ and beyond, ±inf) and NaNs all saturate by the sign bit of the operand (+NaN → 0x7FFFFFFF, -NaN → 0x80000000, unlike v_cvt_i32_f32 which returns 0 for NaN); the sign is read from x before Floor so driver NaN canonicalization cannot flip it. Source neg/abs apply first. Checked on the CPU by tests/semantic/test_alu_cvt_flr_rpi.py, not yet GPU-verified. Until 2026-11-22 the translator rounded S0 + 0.5 in binary32 and returned 0 for NaN. Hardware-verified natively on RDNA2 (AMD Radeon 680M gfx1035: 82/82 wave32 and 82/82 wave64 via tools/hw_oracle, plus gfx1036 confirmation in #1746) and CPU-checked by tests/semantic/test_alu_cvt_flr_rpi.py.
v_cvt_pknorm_i16_f32, v_cvt_pknorm_u16_f32 D[15:0] from S0 and D[31:16] from S1: the f32 is clamped to [-1, 1] (i16) or [0, 1] (u16), multiplied by 32767 or 65535 and rounded to nearest even once, from the exact product (SHADER-363). Mesa ACO emits these opcodes for NIR pack_snorm_2x16/pack_unorm_2x16, which nir_opcodes.py defines as fround_even(fclamp(x) * 32767.0 / 65535.0). Emitted as FClamp, OpFMul, RoundEven and a convert, not PackSnorm2x16, whose rounding GLSL leaves to the driver. The f32 OpFMul can land exactly on k + 0.5 when the exact product is just below or above it, and RoundEven would then pick the even neighbour; the product's error Fma(c, s, -p) is exact, so on such a tie the translator takes floor(p) + 1 when it is positive, floor(p) when negative, and RoundEven when it is 0 (an exact tie). Away from a tie the two roundings agree, since k + 0.5 is an f32 there. NaN gives 0, as v_cvt_i32_f32 does: measured on an RDNA2 iGPU (gfx1036, SHADER-339), 74 of 74 NaN halves (quiet and signalling, both signs, payloads, in S0 and S1) gave 0 in wave32 and wave64 under the game's MODE and with IEEE 1, DX10_CLAMP 0 or f32 denormals kept (tools/pknorm_probe.py --oracle hw). The rounding differs: the hardware rounds the exact product x · 32767 (or 65535) once, while the translator rounds the f32 OpFMul product and then RoundEven, so it is one off where the f32 product lands exactly on k + 0.5 (28 of 28 such near-tie inputs, both directions; docs/shader_validation.md, "v_cvt_pknorm_* NaN and rounding on RDNA2"). On gfx1035 (SHADER-137, tools/int_hw_probe.py --oracle both, wave32 and wave64) ±qNaN → 0, ±inf saturation and the round-to-nearest-even ties at ±0.5 match bit for bit. Not fixed here. NaN gives 0, as v_cvt_i32_f32 does; that is not measured on hardware. Source modifiers apply. clamp raises Unsupported. Until 2026-11-22 both ops were rejected. Measured on RDNA2: on an iGPU (gfx1036, SHADER-339/363, tools/pknorm_probe.py --oracle hw) 74 of 74 NaN halves (quiet and signalling, both signs, payloads, in S0 and S1) gave 0 and 28 of 28 near-tie inputs (both directions) gave the single-rounded word, in wave32 and wave64 under the game's MODE and with IEEE 1, DX10_CLAMP 0 or f32 denormals kept; the translator matches all 134 probe words in all ten runs (it was one off on the 28 near ties before SHADER-363; CPU-checked by tests/semantic/test_alu_cvt_pknorm_f32.py (the twelve measured near-tie words, ties at the scale steps, ±inf, ±NaN, subnormals, out-of-range values, 40 seeded pairs, abs/neg) and tests/test_pknorm_probe.py. Not checked through Vulkan on a GPU. Hardware-verified on RDNA2 (gfx1035, wave32 and wave64 via tools/int_hw_probe.py --oracle both, SHADER-137): ±qNaN → 0, ±inf saturation, and round-to-nearest-even ties at ±0.5 match bit-for-bit (the near-tie rounding above is a separate case). Not GPU-verified.
f16 rounding (SHADER-55, SHADER-56) Narrowing to f16 uses integer ops, not PackHalf2x16. Every f16 ALU result (v_*_f16 VOP1/VOP2/VOP3, v_pk_*_f16, v_cvt_f16_f32, v_interp_p2_f16, v_fma_mix*) and v_cvt_pkrtz_f16_f32 go through Gen.f16_bits (round to nearest even, or round toward zero for pkrtz; f16 denormals kept, f32 denormal inputs give ±0, NaN stays a quiet NaN). After a MODE.FP_ROUND toward-zero write the ALU results take the toward-zero form instead (Gen.f16_res; see Known approximations). GLSL.std.450 leaves PackHalf2x16's rounding to the implementation, and drivers fold a PackHalf2x16 → UnpackHalf2x16 round trip to a no-op, so the next f16 op saw the unrounded f32: #513 (RTX 6000 Ada, --wave64-emulate, v_pk_add_f16 → v_pk_mul_f16 1 ulp off), and pkrtz giving round-to-nearest on llvmpipe. f16 FMAs round once (v_fma_f16, v_fmac_f16, v_pk_fma_f16): x·y is exact in f32, TwoSum gives the exact error of the f32 sum, and round-to-odd at f32 then rounds correctly to f16. An RX 6700 matched a correctly rounded f16 FMA in 12,612 of 12,612 cases (#374); Fma then narrowing double-rounded. Checked by tests/semantic/test_f16_int_convert.py (edges + seeded sweep against Python's binary16), tests/semantic/test_f16_fma_rounding.py (exact rational reference; built near-tie cases fail on the old translation) and tools/valu_fuzz.py --family f16 on an RTX 6000 Ada. Image/buffer d16 packing (#489) and the 16-bit interpolant quantize (#512) are separate. Widening an f16 ALU operand doesn't trust UnpackHalf2x16 with denormals (Gen.f16_in): on an RTX 5060 Ti (610.88) it gives 0 for a denormal that an SDWA BYTE_1 select produced, from an inline constant or a VGPR alike, while the same denormal as a literal or already in a VGPR widens right (a local probe of all four, before and after). So a half whose exponent field is 0 is widened as sign × mantissa × 2^-24 with integer ops. Confirmed by the GPU test ps_sdwa_f16_const (word y, the denormal 0x0040 × 1024.0 = 0x1c00), which gave 0x0000 on an RTX 5060 Ti (610.88) natively and under --wave64-emulate before and 4096/4096 exact after, and by tests/semantic/test_value_semantics.py running it with a flushing UnpackHalf2x16. The other UnpackHalf2x16 uses (packed-f16 reads, interpolants, d16 image results) are not changed. v_fma_mix* with f32 sources rounds once straight to f16 via round-to-odd in both nearest and toward-zero modes (measured on an RDNA2 iGPU, gfx1036: tools/fma_mix_probe.py --oracle hw gave the single-rounded word for all 7 of 7 tie inputs where the two rules differ, SHADER-135; see Known approximations). v_fma_mix* rounds once straight to f16 via round-to-odd in both nearest-even and toward-zero modes, matching hardware (7 of 7 tie inputs of tools/fma_mix_probe.py --oracle hw on gfx1036, SHADER-135; see Known approximations). v_fma_mix* rounds once straight to f16 via round-to-odd in both nearest and toward-zero modes (see Known approximations); the hardware rounds once: 7 of 7 tie inputs of tools/fma_mix_probe.py --oracle hw on gfx1036 (SHADER-135). v_fma_mix* with f32 sources uses Fma then narrows (two roundings, unmeasured) in nearest-even mode; toward zero it rounds once (see Known approximations). 7 of 7 tie inputs of tools/fma_mix_probe.py --oracle hw on gfx1036 (SHADER-135; not fixed yet); toward zero it rounds once (see Known approximations).
s_round_mode SIMM16[3:0] sets FP_ROUND. The translator accepts FP32 nearest-even with FP16/64 nearest-even or toward-zero and writes the same per-invocation state as s_setreg_imm32_b32. Other rounding modes raise Unsupported. AMD RDNA2 ISA tables 15 and 24; synthetic positive and negative halfway-neighbour conversions in test_scalar_noop_waitcnt.py check both modes in one shader.
f16 narrowing size Gen.f16_bits leaves out or shares steps where that can't change the result. In nearest-even mode there is no separate infinity select: infinity is already at or above the overflow threshold (65520), which gives 0x7C00. For v_add_f16, v_sub_f16, v_subrev_f16 and v_pk_add_f16 without omod (exact_tiny), the range below 2^-14 is neither rounded nor tested for underflow: a sum of two f16 values is a multiple of 2^-24, so there it is already an f16 value, and clamp keeps that true. With an omod the rounding stays, since div:2 can create a tie. No range has an underflow test: below 2^-25 the shift is 25, which moves the mantissa (plus the rounding bias) out to 0. The subnormal range rounds like the normal one, by adding half - 1 + the kept low bit before the shift. When the program writes MODE, Gen.f16_res makes one pass: toward zero selects a bias of 0, the 65536 overflow threshold and 0x7BFF, and keeps the infinity select. Confirmed by running the emitted integer sequences before and after on all 2^32 f32 inputs (both roundings) and on all 2^32 f16 operand pairs (both roundings, with and without clamp): no difference. Regression test: tests/semantic/test_f16_sum_narrowing.py.
v_cvt_pknorm_i16_f16, v_cvt_pknorm_u16_f16 VOP3 packed normalized conversion from two f16 sources (D[15:0] from S0.f16, D[31:16] from S1.f16): each selected f16 half (op_sel[0..1], with neg/abs source modifiers and inline f16 constants via Gen.f16_in) is clamped to [-1, 1] (i16) or [0, 1] (u16), scaled by 32767 or 65535, and rounded once to nearest even (NaN → 0). Uses cl * (scale + 1) - RoundEven(cl) for `
v_interp_p2_f16 clamp The VOP3 clamp bit on v_interp_p2_f16 clamps its f16 result to [0, 1], applied before the narrowing like the other f16 results (Mesa ACO aco_opcodes.py declares the op dst(F16), which takes output modifiers; llvm-mc encodes clamp on it but no omod). Until 2026-11-22 the translator dropped it. Checked by tests/semantic/test_interp_f16.py: attributes 1.5 and -0.25 read with clamp give 1.0 and +0.0, and without it 1.5 and -0.25. No GPU test: vs_ids gives attributes in [0, 1) only.
16-bit interpolation (v_interp_p1ll_f16 / v_interp_p2_f16, high) A 16-bit varying shares its 32-bit param channel with another: the producer packs them as low half, high half (Mesa ac_nir_prerast_utils.c: nir_pack_32_2x16_split by io_sem.high_16bits), the PS sets FP16_INTERP_MODE (plus ATTR1_VALID when the high half is used, RADV radv_ps_input_type_bits), and the high bit picks the half on both ops of the pair (ACO emit_interp_instr, aco_isel_helpers.cpp; llvm-mc gfx1013 sets the same bit, byte 5 bit 0, on both: p1ll v2, v0, attr0.x high 0x00 → 0x01, p2 v2, v1, attr0.x, v3 high 0x02 → 0x03). The translated VS exports the channel's raw bits, so interpolating them as one f32 gives neither half. A location any *_f16 interp reads is therefore declared PerVertexKHR (vec4[3], no Flat; it still matches a producer's vec4 output at that location); this needs VK_KHR_fragment_shader_barycentric (fragmentShaderBarycentric) for every such PS, not just the raw-barycentric ones; the index records it like any capability (features: ["fragmentShaderBarycentric"]), so vk_pipeline_check and vk_harness skip such a PS on a device without it. Nothing picks --bary-fallback from the device: it is a translation-time flag. Each f16 read decodes its half of each vertex's word (UnpackHalf2x16 component 0 or 1) and weights them as AMD does, P0 + i(P1 − P0) + j(P2 − P0) with i, j = BaryCoordKHR.y/.z, then p2 clamps and narrows as before. f32 reads of such a location (p1/p2_f32) interpolate the raw word the same way, and v_interp_mov_f32 takes vertex 0's. Until 2026-11-22 high was ignored and both halves read the smooth-f32 interpolation of the whole word; abilliontokens counted high in 4,776 of 12,101 PS (39.5%, 51,684 instructions, always p1ll/p2 pairs, no p1lv), and Pipodi found 4,731 of those 4,776 read both halves of the same channel, with p1ll and p2 always agreeing on attribute, channel and high. Like the f32 path, the pair's I/J operands are not read: the weights come from BaryCoordKHR (213 PS that compute their own barycentrics into v0/v1 first are a separate gap). Confirmed by tests/semantic/test_interp_f16_high.py (per-vertex halves 0.5/1.5/2.5 and −4/8/16 at weights (0.25, 0.25, 0.5) give 1.75 and 9.0; fails on the old translation) and the GPU fixture ps_interp_f16_high drawn with vs_f16_pack (u and v packed in one channel both ways, f32 control) and, through scripts/run_gpu_tests.py, with the mesh producer ms_f16_pack (mesh exp paramN stores the same raw words, Gen.ms_export): both pass on an RTX 5070 and fail on the old translation (off by 0.984). spirv-val and vk_pipeline_check (real pipelines against the vec4 VS stubs, RTX 5070) also accept PS mixing high, low, f32 and flat reads of one location and of several. Measured natively on RDNA2 (AMD Radeon 680M, gfx1035, wave32 and wave64 via tools/vinterp_hw_probe.py --oracle both, SHADER-430): the VINTRP unit reads P0, P10 and P20 from LDS at M0 + 48·attr + {8·c, 8·c + 4, 32 + 4·c}; v_interp_p1ll_f16 (and v_interp_p1lv_f16, taking P0.half from vsrc2) widens the selected f16 half ([15:0] or [31:16] with high) to binary32 and writes the fused binary32 fma(i, f32(P10.half), f32(P0.half)), while v_interp_p2_f16 rounds the exact partial_f32 + j · f32(P20.half) once to f16 following MODE.FP_ROUND.16_64 (like v_fma_mixlo_f16, whereas the translator narrows the f32 sum) and writes vdst[15:0] while hardware keeps vdst[31:16]; f16 subnormal halves are preserved with denorm_mode_16_64 = 3 (0x0001 + 0.5·0x0200 + 0.5·0x0200 → 0x0201, flushed to ±0 when 0), and f16 NaN halves quiet with payload preserved (0x7e05 → 0x7e05, 0x7c01 → 0x7e01). ALU half measured on AMD hardware (SHADER-430, tools/interp_hw_probe.py, gfx1036, every case matched; docs/shader_validation.md): p1ll_f16 widens the chosen f16 halves exactly and computes fma(h10, I, h0) with one rounding to f32. p2_f16 computes fma(h20, J, p1ll) and rounds it once, straight to f16: 30 hand-built ties gave that result and never f32-then-f16. It keeps vdst's high 16 bits. The translator used to zero them and now keeps them (write_lo16; test_p2_f16_keeps_the_high_half_of_vdst). Still unverified: what the SPI writes into LDS for a packed channel in a real draw (P10/P20 as f32 differences of the raw words, or per-half f16 differences under FP16_INTERP_MODE), which needs a pixel-shader harness; also f16 inf/NaN halves and p1lv_f16. Unverified: AMD hardware (whether it computes P10/P20 in f16 or rounds the p1ll intermediate differently), f16 denormal and NaN halves. --bary-fallback has no per-vertex inputs, so it keeps the old smooth-f32 read and cannot honour high; check.py skips the fixture there. MoltenVK can't compile PerVertexKHR: see the next row.
16-bit interpolation without PerVertexKHR (--f16-interp-fallback) MoltenVK reports fragmentShaderBarycentric but can't create a pipeline with the row above's inputs: its SPIR-V to MSL conversion stops with "PerVertexKHR decoration is not supported in MSL" (MoltenVK 1.4.2 on an Apple A18 Pro and, reported by @DomasUrbonas in #166, an M4 Pro), so ps_interp_f16_high failed on every Mac. With the flag no PerVertexKHR (and, for these reads, no BaryCoordKHR) is used: every VS exp paramN, mesh param and --mesh-compute vertex (tools/mesh_compute_vs.py) also exports the channel's two f16 halves decoded to f32 (UnpackHalf2x16), low halves at location 29 − 2N and high halves at 30 − 2N, below MoltenVK's 31 locations (124 components); a PS *_f16 read of attrN.c takes component c of that ordinary smooth input, then p2 clamps and narrows as before. With the flag no PerVertexKHR (and, for these reads, no BaryCoordKHR) is used: every VS exp paramN, mesh param and --mesh-compute vertex (tools/mesh_compute_vs.py) also exports the channel's two f16 halves decoded to f32 (UnpackHalf2x16), low halves at location 28 − 2N and high halves at 29 − 2N, so nothing goes above location 29: MoltenVK's maxVertexOutputComponents is 124 because Metal counts gl_Position in its 128 vertex-output scalars, and the Khronos validation layer counts it too, so a VS output at location 30 failed VUID-RuntimeSpirv-Location-06272 on vs_ids (SHADER-291); a PS *_f16 read of attrN.c takes component c of that ordinary smooth input, then p2 clamps and narrows as before. Interpolation is linear, so the device interpolating the decoded halves gives the same P0 + i(P1 − P0) + j(P2 − P0) as the per-vertex path, with the interpolator's rounding instead of explicit f32 arithmetic. f32 and v_interp_mov_f32 reads of such a location are the raw word as on any location (flat = the provoking vertex's word, exact). A producer leaves out the halves of a param whose locations would land on one of its own params (params 0..P−1 leave room for the halves of params 0..(29 − P) / 2), and a PS whose decoded-half location is also an attribute it reads is rejected (Unsupported), not mislinked. A producer leaves out the halves of a param whose locations would land on one of its own params (params 0..P−1 leave room for the halves of params 0..(28 − P) / 2), and a PS whose decoded-half location is also an attribute it reads is rejected (Unsupported), not mislinked. The index records f16_halves ({param: [low, high location]}) on both sides; a pipeline links when the PS's entries are among its producer's. Chosen like the wave64 mode: tools/vk_subgroup_info.py reports per_vertex_inputs (false without fragmentShaderBarycentric or on driver ID MoltenVK), and make_game.py and run_gpu_tests.py turn the flag on where it is false (LEONIDA_F16_INTERP_FALLBACK=1/0 overrides the runner; build.py takes only the variable, since it may run in WSL). Without the flag the translation is unchanged: all 139 GPU-test modules are byte-identical to main's, with and without --bary-fallback and with --mesh-compute --wave64-emulate, so NVIDIA and AMD keep the exact per-vertex path. Confirmed on an Apple A18 Pro (macOS 26.6.2, MoltenVK 1.4.2): ps_interp_f16_high drawn with vs_f16_pack passes natively and with wave64 emulation, every one of its 4,096 pixels bit-exact to f16 of the exact u and v in both halves (it failed before at pipeline creation), and ms_f16_pack through --mesh-compute (LEONIDA_MESH_COMPUTE=1) passes too; tests/semantic/test_f16_interp_fallback.py checks the PS reads (1.75 and 9.0 from the decoded halves), the VS exports (one-lane interpreter), the overlap rules and the default being unchanged. Unverified: a PS whose producer exports more params than leave room for the halves it reads (it reads that producer's param, not halves: the f16_halves entries then don't match); devices with fewer than 31 output locations. CPU check (TEST-398, FallbackStagePair): with ordinary VS exports at 28 and 29, the PS reads those values (5 and 7 in the test) in place of attr0's decoded halves (2 and 3). Only the PS lists attr0 in f16_halves. With param28 as the last export, location 28 carries its ordinary value and location 29 has no VS output. When the last ordinary export is at 27, both stages list the pair and the PS reads 2 and 3. Unverified: devices with fewer than 124 vertex output components. Unverified: devices with fewer than 31 output locations. The move from 30 to 29 (SHADER-291) was checked on an Apple M5 (macOS 27.2.1, MoltenVK 1.4.2, Khronos validation layer 1.4.363): over the 170 GPU-test modules vk_pipeline_check reported VUID-RuntimeSpirv-Location-06272 on 6 vertex shaders at location 30 and on none at 29; the same 15 modules list f16_halves for the same params, run_gpu_tests.py gives the same result per test, and ps_interp_f16_high reads back byte-identical pixels. Dynamic packing and per-pipeline PSO linking (SHADER-378): when a PS's canonical 28 − 2N/29 − 2N slots collide with its raw attributes (266 corpus PS where f16-read attrs reach n >= 7 and raw attrs reach 12–14, all with 2· **Unverified:** a PS whose producer exports more params than leave room for the halves it reads (it reads that producer's param, not halves: the f16_halvesentries then don't match); devices with fewer than 124 vertex output components. Not combined with--bary-fallback`'s geometry shader.
v_fmac_f16, v_interp_p2/mov_f32 output modifiers VOP3 mul:2/mul:4/div:2 (applied first) and clamp to [0, 1] apply to v_fmac_f16_e64 (before narrowing to f16, matching v_fma_f16, high half preserved) and to v_interp_p2_f32_e64 / v_interp_mov_f32_e64 (no-op when no modifier is present). Until 2026-11-22 all three dropped output modifiers. Source: LLVM llvm/test/MC/AMDGPU/gfx10_asm_vop2.s (v_fmac_f16_e64) and gfx10_asm_vop3.s (v_interp_p2_f32_e64, v_interp_mov_f32_e64). Checked on the CPU by tests/semantic/test_f16_fma_rounding.py (test_fmac_output_modifiers) and tests/semantic/test_interp_f32_mods.py, and on a GPU by ps_fmac_f16_mods.asm, ps_interp_f32_mods.asm and ps_interp_mov_mods.asm (the last two drawn with vs_interp_consts.asm, whose params are constant over the triangle; each modifier and the omod-before-clamp order change a word; Tesla V100 (NVIDIA 580.95.05, Linux)). The hardware ignores the f16 omod in the MODE the translator assumes: on an RDNA2 iGPU (gfx1036) mul:2/mul:4/div:2 change an f16 result (v_fmac_f16, v_add/mul/fma_f16, v_cvt_f16_f32, v_exp/rcp_f16) only with IEEE 0 and denorm_mode_16_64 = 0, and do nothing with f16 denormals kept; omod comes before clamp, and clamp gives +0 for -0 and, with DX10_CLAMP 1, for a NaN (SHADER-135, docs/shader_validation.md). The translator is not changed yet: which of omod and the kept f16 denormals is wrong for the game is a corpus question.
v_cvt_f16_f32 output modifiers VOP3 clamp and mul:2/mul:4/div:2 apply to the f16 result (Mesa ACO declares the op dst(F16)), in the order an RX 6800 (gfx1030) and Radeon Graphics (gfx1036) apply them: the value is rounded to f16 first, then scaled, then clamped, so in RNE 65520 div:2 is inf, not 32768. The scaling works on the f16 bits (Gen.f16_omod): a zero or denormal f16, before or after it, gives +0, inf and NaN pass through, and a finite overflow gives inf (±65504 under MODE toward zero, unmeasured). The scaling works on the f16 bits (Gen.f16_omod): a pre-omod zero or denormal f16 (e == 0) gives +0, div:2 underflowing an exponent-1 normal (e == 1) gives signed zero (h & 0x8000, so negative inputs give -0.0, which a trailing clamp still turns into +0), inf and NaN pass through, and finite mul:2/mul:4 overflow gives ±inf in RNE or ±65504 under MODE toward zero (FP_ROUND = 3), where ±65520 / ±FLT_MAX with div:2 also round to ±65504 before halving to ±32752. Until 2026-11-22 both modifiers were dropped; Gen.f16_omod also flushed e == 1 div:2 to +0 until the gfx1036 measurement. Sources: @shelbykb2's RX 6800 words (gfx1030, not the console's gfx1013): @shelbykb2's RX 6800 words (gfx1030, not the console's gfx1013) and tools/cvt_f16_omod_probe.py on gfx1036 (Radeon(TM) Graphics, Windows 11 driver 32.0.21045.29003, wave32 & wave64, 2,880 evaluations, 0 diffs across static/dynamic MODE): clamp applies in every float mode, the omod only with IEEE off and f16 denormals flushed (with denorm16_64=3 or ieee=1 omod is ignored while clamp still applies), which is the mode a compiler emits an omod for, as the f32 rows above argue; 2^-15 mul:2 and -0 mul:2 gave 0x0000 there. That flush is modelled only on results that carry an omod. The f16 ALU results (v_fma_f16, v_fmac_f16, …) still scale before narrowing, which differs from this only on overflow, denormals and the sign of zero. Checked by ps_outmods_f16.asm (tests/semantic/test_value_semantics.py, and on a GPU in both runners): each of its six results changes a word when its modifier is dropped, and two words change when the omod is applied before the rounding. Checked by ps_outmods_f16.asm (tests/semantic/test_value_semantics.py, and on a GPU in both runners), tests/test_cvt_f16_omod_probe.py, and tests/semantic/test_cvt_f16_omod.py.
16-bit vector compare op_sel (v_cmp(x)_*_{f16,u16,i16}) VOP3 op_sel:[s0,s1] selects bit [15:0] (0) or [31:16] (1) of each source before f16 input modifiers (neg/abs, via Gen.f16_in) or u16/i16 zero-/sign-extension (OpBitFieldUExtract/OpBitFieldSExtract at bit offset 16 when set, 0 otherwise); VOPC writes a scalar lane mask (VCC/SGPR or EXEC for v_cmpx), so there is no destination op_sel bit. Until 2026-11-22 Gen.compare hardcoded the low half and ignored mods. Source: AMD RDNA2 ISA VOP3 op_sel and Mesa ACO can_use_opsel. Measured natively on RDNA2 (gfx1036, AMD Ryzen 7000 iGPU, driver 26.11.2) across wave32 and wave64: v_cmp writes 0 for inactive lanes in sdst (s4 in wave32, s[4:5] in wave64); v_cmpx kills inactive lanes in EXEC; inline float constants (1.0, -2.0, 0.5, 4.0) read f16 in low half with op_sel=0 and +0.0 with op_sel=1; inline integer constants (1, -1) read low half with op_sel=0 and high half with op_sel=1 (0 for 1, 0xFFFF for -1); 32-bit literals read [15:0] (op_sel=0) and [31:16] (op_sel=1, including signed negative high halves in i16); SGPR high halves as src0 and src1 with modifiers (neg, abs); and f16 ordered vs unordered relations on qNaN/sNaN. Probed natively with zero divergences by tools/probe_gfx1036_vcmp16.py, and checked on the CPU by tests/semantic/test_vcmp16_opsel.py (all four op_sel combinations, spirv-val compliance, wave32/wave64 EXEC updates and inactive-lane 0 writes in sdst). Checked on the CPU by tests/semantic/test_vcmp16_opsel.py (all four op_sel combinations across f16 relations/ordered/unordered/NaN/neg/abs, u16, signed i16, and v_cmpx wave32/wave64 EXEC updates via spirv_mini_interp and spirv_wave_interp); not GPU-verified.
v_cmp_class_f16, v_cmpx_class_f16, v_cmp_class_f64, v_cmpx_class_f64 IEEE-754 floating-point class tests against the 10-bit class mask (0: sNaN, 1: qNaN, 2: -inf, 3: -normal, 4: -denormal, 5: -0, 6: +0, 7: +denormal, 8: +normal, 9: +inf), writing VCC/SGPR or narrowing EXEC (v_cmpx). Computed bit-exactly on integer words (so sNaN is never quieted by float ops and v_cmp(x)_class_f64 does not require OpCapability Float64): f16 reads the selected half (op_sel[0], inline f16 constants via src_h) and applies abs/neg on bits [15:0]; f64 reads the (lo, hi) pair (32-bit literals placed in the upper word with lo = 0 per RDNA2 ISA) and applies abs/neg on hi. Output modifiers (clamp, mul:*, div:*) and unsupported op_sel bits raise Unsupported. Source: AMD RDNA 2 ISA reference (VOPC V_CMP_CLASS_F16/F64, V_CMPX_CLASS_F16/F64). Checked bit-for-bit across all 10 classes on the CPU (spirv_mini_interp) and with spirv-val by tests/semantic/test_alu_cmp_class_f16_f64.py; not GPU-verified and not run on the shader corpus.
Float-to-byte pack v_cvt_pk_u8_f32 rounds to nearest even (the default MODE round mode; the hardware follows the MODE register's f32 round mode, which the translator ignores, see #358), clamps to [0, 255], and gives 0 for NaN and negative values, then inserts the byte at src1[1:0] of src2 and keeps the other three. NaN is replaced by +0 before FClamp, which is undefined for a NaN operand. Measured natively on RDNA2 (gfx1036, the Ryzen 7 9800X3D iGPU, AMD driver 25.10, the instruction run through inline assembly): all 256 inputs k + 0.5 round to even, 0.5 gives 0, 0x3f000001 gives 1, +inf and 300.0 give 255, -inf, -1.0, ±0, denormals and quiet, signalling and negative NaNs give 0 (#358). cs_cvt_pk_u8.asm holds eight of these words, checked by check.py/run_gpu_tests.py and bit-for-bit by tests/semantic/test_cvt_pk_u8.py.
Known approximations v_cvt_pkrtz_f16_f32 is now exact round-toward-zero (finite overflow gives ±65504, not inf). The GPU smoke test caught the old round-to-nearest version producing inf in PS_ImposterShadow. The other f16 packs (v_cvt_f16_f32, d16 results, mix ops) round to nearest, which matches the default mode; the ALU ones follow a MODE toward-zero write (below; v_fma_mixlo/mixhi_f16 round the exact x*y+z once in every mode (measured on an RDNA2 iGPU, gfx1036, 7 of 7 discriminating tie inputs, SHADER-135); the translator does that in both modes through Gen.fma_mix_odd; the ALU ones follow a MODE toward-zero write (below; v_fma_mixlo/mixhi_f16 round the exact x*y+z once in every mode (measured on an RDNA2 iGPU, gfx1036, 7 of 7 discriminating tie inputs, SHADER-135); toward zero the translator does that already, while in nearest-even mode it still narrows an f32 Fma, which is 1 f16 ulp off on ties until #1774 (SHADER-296) lands; the ALU ones follow a MODE toward-zero write (below; ALU sites: see the f16 rounding row). MODE: s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2) (f16/f64 rounding) is tracked in a per-invocation variable, the only MODE field the corpus writes (9,417 writes in 6,333 shaders: 6,694 toward zero, 2,723 back to nearest even). While it is toward zero, every VALU f16 result except the transcendentals listed below (v_cvt_f16_f32, f16 arithmetic, v_pk_*_f16, v_fma_mix{lo,hi}_f16, v_interp_p2_f16) rounds toward zero exactly, with the integer conversion v_cvt_pkrtz_f16_f32 uses (f16_bits(rtz=True), see the f16 rounding row), and v_add_f64 steps back one ulp when the TwoSum error shows it rounded away from zero; finite overflow gives the largest finite value. The v_add_f64 output modifiers apply after that step and round to nearest, so an omod that overflows or lands on a subnormal is not toward zero. omod versus denormal mode is unmodelled: the translator applies mul:2/mul:4/div:2 regardless of the MODE denormal fields (as before this change), whereas hardware ignores omod when denormals are kept (denorm fields = 3) and applies it when they are flushed (both measured on an RX 6800: v_add_f64 (1 - 2^-60) mul:2 with denormals kept gave 3ff00000:00000000 nearest and 3fefffff:ffffffff toward zero, unscaled; mul:2 was applied with denormals flushed); the tests therefore claim no omod order. CPU-checked by tests/test_mode_round.py (the RX 6800 words for f16 add/sub, v_fma_mix, the transcendentals, f64 overflow). f16 add and sub (f16 operands) and v_pk_add_f16 take the exact TwoSum error of the f32 result into account, so they are exact toward zero too (f32 then f16 rounding alone would be wrong: 2 - 2^-24 is an f32 tie that rounds up to 2.0); f16 FMAs need nothing extra, since their round-to-odd f32 value (SHADER-55) narrows exactly in either mode. v_fma_mix{lo,hi}_f16 rounds the exact fma once, straight to f16, in both nearest-even and toward-zero modes (measured on AMD RDNA2 gfx1036, finding 7079901079; an RX 6800 gave 0x3fff for 1 * 2 - 2^-30, where rounding to f32 first and then narrowing gives 0x4000): v_fma_mix{lo,hi}_f16 rounds the exact fma once, straight to f16, in both nearest-even and toward-zero modes (measured on AMD RDNA2 gfx1036 across 7 of 7 discriminating tie inputs with tools/fma_mix_probe.py --oracle hw, SHADER-135, finding 7079901079, and on an RX 6800 where toward zero gave 0x3fff for 1 * 2 - 2^-30 vs 0x4000 with double rounding; fixed for nearest mode in SHADER-296 / #1774; see docs/shader_validation.md, "v_fma_mix* f16 rounding in nearest mode"): v_fma_mix{lo,hi}_f16 rounds the exact fma once, straight to f16, toward zero (an RX 6800 gave 0x3fff for 1 * 2 - 2^-30, where rounding to f32 first and then narrowing gives 0x4000): v_fma_mix{lo,hi}_f16 rounds the exact fma once, straight to f16, in both nearest-even and toward-zero modes (measured on AMD RDNA2 gfx1036 and verified by tools/fma_mix_probe.py; finding 7079901079; toward zero an RX 6800 gave 0x3fff for 1 * 2 - 2^-30, where rounding to f32 first and then narrowing gives 0x4000): Gen.fma_mix_odd corrects the f32 Fma to round-to-odd by the sign of its exact residual (product error by Fma(x, y, -x*y), TwoSum of the sum), which narrows exactly in either direction; the nearest-even path is unchanged (f32 Fma, then narrow). fma_mix_odd also handles a tiny product (
Denormal flush in v_mad_f32, v_mac_f32, v_mad_legacy_f32 (SHADER-118) The three have no f32 denormal support: a subnormal operand, the rounded product or the result reads as signed zero, whatever the MODE register says. Gen.flush_f32 emits `
16-bit high-half reads (Gen.u16_half / Gen.i16_half, #1506) Reading the high 16 bits of a 32-bit word emits OpShiftRightLogical %uint u 16 (u16_half) or OpShiftRightArithmetic %int (as_int(u)) 16 (i16_half) alone, without a trailing OpBitwiseAnd ... 0xFFFF or OpBitFieldSExtract ... 0 16 (used for the low half only). On 32-bit inputs >> 16 already zero- or sign-extends bits 31..16, and AMD's Windows LLPC compiler (measured on RDNA2, drivers 22.40.84.06 in #1506 and 24.10.24 on Ryzen 5 7600 iGPU) miscompiles both (u >> 16) & 0xFFFF and OpBitFieldSExtract (u >> 16) 0 16 after two partial-half writes to u by dropping the >> 16 when the result feeds OpIAdd, OpIMul, or OpShiftLeftLogical (e.g. (0x41b1 << 1) & 0xFFFF became 0x0000 instead of 0x8362 in cs_f16fuzz_s2_163_w64, s_bitreplicate's `((0x41b1 << 8)
v_mac_legacy_f32 The GFX10.1 VOP2 form of v_mad_legacy_f32 with D as the addend: D = legacy(S0 * S1) + D, where 0 times anything (inf and NaN included) is +0, with the same denormal flush and VOP3 modifiers. D is read before it is written, as for v_mac_f32 (LLVM VOP2Instructions.td: V_MAC_LEGACY_F32 has $src2 tied to $vdst). Until 2026-11-22 it raised Unsupported. CPU-checked by MacLegacyF32Tests in tests/semantic/test_valu_f32_min3_max3_mad.py (a 15x8x6 grid against the v_mad_legacy_f32 reference, the zero rule, clamp/neg, D aliased as a source). Not GPU-verified: like the other mad opcodes it exists on gfx1010-1013 only, so no RDNA2 desktop part runs it.
v_cmp_*_f64, v_cmpx_*_f64 All 16 binary64 vector compare predicates (f, lt, eq, le, gt, lg, ge, o, u, nge, nlg, ngt, nle, neq, nlt, tru) for both v_cmp_ (VCC/SGPR lane mask) and v_cmpx_ (EXEC narrowing), lowered in Gen.compare_f64_cond via pure 32-bit %uint IEEE-754 ordering (NaN detection, -0.0 canonicalized to +0.0, sign-magnitude to monotonic unsigned 64-bit key) with no Float64 capability required and no denormal flushing. Supports VGPR/SGPR pairs, fimm, sign-extended inline integers (-16..64), 32-bit upper-half literals, and VOP3 abs/neg sign-bit modifiers on both sources; inactive lanes write 0 for v_cmp_*_f64 and stay inactive for v_cmpx_*_f64. Source: AMD RDNA2 ISA VOPC/VOP3 binary64 compares. CPU-checked by tests/semantic/test_cmp_f64.py (all 16 predicates across full IEEE-754 edge grid including subnormals/1-ULP pairs/±0/±inf/sNaN/qNaN, SGPR pairs, constants, abs/neg, v_cmpx_*_f64, inactive lanes, no Float64 capability, bad-operand rejections). Not GPU-verified.
Whole-quad mode (s_wqm_b64 / s_wqm_b32) A lane mask register holds only this lane's bit, so WQM on one (EXEC, VCC, an SGPR the mask analysis found) ORs the bit of the lane's quad, lanes 4n..4n+3 of the wave: two OpGroupNonUniformQuadSwap (horizontal, then vertical; capability GroupNonUniformQuad) in the default mode in fragment and compute shaders (quad operations are only guaranteed there; vertex, geometry and mesh shaders shuffle from the quad's four lanes), or the four lanes' values read through %x_buf under --wave64-emulate (no subgroup operation there). A quad never crosses lane 31/32, so the mask bits are exact per half on a 32-wide subgroup; SCC is a wave vote, so on wave64 it needs a 64-wide subgroup or --wave64-emulate (as every wave-wide mask op). The result goes to EXEC, VCC or an SGPR pair as a mask, SCC = the wave-wide any of it (same vote as the other mask ops). A 32-bit form in wave64 (exec_lo/exec_hi, vcc_lo/vcc_hi, a half-mask SGPR) writes only its own half (exec_half_write) and votes SCC over that half only (cs_wqm_w64_half). A source that is not a lane mask (a value loaded from memory, a literal) is data: `((x
buffer_atomic_{and,or,xor,swap}_x2 M = op(M, DATA) on the 64-bit element at the MUBUF address (two dwords, low first); with glc the old 64 bits are returned in vdata[0:1]. Each dword is its own 32-bit OpAtomic*, so no Int64 atomics are needed; a bitwise op leaves the same memory that way, since its bits are independent. Approximation: an exchange can tear, since two lanes swapping into one element at once can leave one's low dword with the other's high dword (A.lo, B.lo, B.hi, A.hi), and the returned pair comes from two reads, so another lane's 64-bit op on the same element between them can show up half done. Bounds: the check covers the whole 8-byte element, all or nothing, as for a typed 32_32 element (buffer_address(elem="fmt")). An out-of-range or inactive lane leaves memory alone and returns 0, as buffer_atomic does. How hardware treats a 64-bit atomic that is only partly in range is not measured. Still Unsupported: add/sub/min/max_x2 and cmpswap_x2. Until 2026-11-22 every _x2 buffer atomic was rejected. CPU-checked by tests/semantic/test_buffer_atomics_x2.py (the four ops with and without glc, an element ending exactly at num_records, half and fully out of range, seeded values, rejected forms). Not GPU-verified.
Wave64 graphics: partition invariance (SHADER-10) A wave64 VS/PS/GS on a 32-wide subgroup is exact iff its observable results do not change when the wave is cut into two 32-lane halves (the host forms the subgroups of graphics stages, so there is no partner half to exchange with). tools/wave64_halves.py decides it from the code (forward taint dataflow over the basic blocks, plus control dependence on wave-wide votes) and the translator records it in index.json as wave64_graphics (A/B/C), wave64_graphics_reasons (tier C) and wave64_graphics_idioms (tier B). A: only per-lane arithmetic, votes that skip lane-masked work (s_cbranch_execz/execnz; vccz/vccnz whose run side starts by narrowing EXEC to that VCC and whose other side is the join, with no code of its own: a half that votes no runs that side, the wave does not; the same holds for s_cbranch_execz/execnz: the side that runs when EXEC is zero is taken by a half with no active lane, so it must be the join (or only jumps to it) or the exit of a loop the vote closes, else tier C unsafe-execz-branch; s_cbranch_scc* after a vote is the same kind of skip, any other reader of that SCC, s_cselect/s_cmov/s_addc, is tier C), whole-quad masks, ds_bpermute/ds_permute/v_permlane16/v_permlanex16/ds_swizzle (they stay inside a half), a ds_bpermute/ds_permute address made from the lane id (v_mbcnt_lo then v_mbcnt_hi of -1) when it is the same modulo 128 bytes in the wave and in a half (the id is 0..63 there and 0..31 here, equal modulo 32 lanes; sums, differences and bitwise ops with invariant values keep that, a left shift by c multiplies the modulus by 2^c, and the permute uses address bits 2..6 of its half only: (id ^ 1) << 2 is exact, id << 1, a right shift of the id or the low count alone stay tier C lane-id), loops closed by execnz with no scalar state carried. s_cbranch_scc* after a vote is the same kind of skip, any other reader of that SCC, s_cselect/s_cmov/s_addc, is tier C), whole-quad masks, ds_bpermute/v_permlane16 (they stay inside a half, not GPU-tested here: no fixture; ds_swizzle and v_permlanex16 likewise), loops closed by execnz with no scalar state carried. B: also a waterfall loop (v_readfirstlane of a varying value, v_cmp_eq against the same VGPR, saveexec, body, s_xor exec, execnz; the scalar only used inside the body), a wave-aggregated atomic (s_bcnt1 of EXEC, v_mbcnt rank of that same EXEC, one buffer_atomic_add of that count (the count of the mask the rank ranks) by the rank-0 lane only, v_readfirstlane of the result with EXEC restored, base + rank as a store address, the rank counting the very mask the atomic's count was taken of (a rank of the entry EXEC or of a saved copy next to a base of the narrowed one is tier C lane-rank); the rank alone or the base alone is not a slot: exact as a set of slots, the order of the slots within a wave is not preserved, a 64-lane wave takes one run of slots, two halves take two), v_readfirstlane / v_readlane of a VGPR written from scalars and constants while EXEC was the launch mask (the same in every lane), a v_writelane / v_readlane spill pair on one constant lane below 32. C: anything else that reaches an export, a store's data, a branch or EXEC: lane count / rank / first-lane index / raw lane id (v_mbcnt of -1), v_readlane of a varying value at any lane (on a wave64 every lane gets hardware lane N, in halves each half gets its own lane N, so lane 7 is as wrong as lane 40; the research note's row 9 is too generous here); an analysis failure is tier C with reason analysis-error (the translation does not fail), v_writelane to a non-constant or >= 32 lane, a 32-bit access to half of a lane mask (exec_hi, vcc_hi, a mask pair's odd register), a mask read as data (including a mask combined by s_and/or/andn2_b64 with a register that is not one: a user value, a loaded mask), a scalar defined behind a wave-wide vote and read where it may not have run (s_add s5, s5, 1 after s_cbranch_vccz; a trip count in an SGPR of a divergent loop: the halves vote differently), a branch on a count, an elected-lane side effect that is not a count, ds_append/ds_consume. The check is conservative: unknown means C. --wave64-graphics=warn (default) marks tier C and counts it in the summary line, error refuses it (Unsupported), off skips the analysis; python tools/wave64_halves.py --census <spirv>/index.json prints tier, reason and idiom counts (no names); it complements tools/wave64_graphics_scan.py (#1132), which counts candidate cross-half opcodes in the disassembly before translation and decides nothing. Corpus census (TEST-319, 1.0.2.1, --census over the translated index, re-run with the GS ring rule below and #1982): 11,405 wave64 graphics shaders (1,179 VS, 10,031 PS, 195 GS); tier A 2,117 (18.6%), B 17 (0.1%), C 9,271 (81.3%): VS 479/14/686, PS 1,443/3/8,585, GS 195/0/0. Tier C reasons (a shader can have several): unsafe-vote-branch 8,285, tainted-branch 6,550, tainted-exec 5,189, cross-lane 4,760, stale-scalar 3,415, mask-half 758, unsafe-execz-branch 583, first-lane 353, waterfall-scalar 161, lane-id 152, lane-count 1. 11,405 wave64 graphics shaders (1,179 VS, 10,031 PS, 195 GS); tier A 1,919 (16.8%), B 17 (0.1%), C 9,469 (83.0%): VS 465/14/700, PS 1,454/3/8,574, GS 0/0/195. Tier C reasons (a shader can have several): unsafe-vote-branch 8,175, tainted-branch 6,582, cross-lane 6,111, tainted-exec 4,959, stale-scalar 3,162, mask-half 758, unsafe-execz-branch 583, first-lane 353, lane-id 277, waterfall-scalar 167, lane-count 1. Tier B idioms: readfirstlane-uniform 558, lane-spill 287, waterfall 35. The lane-id bpermute rule moves no corpus shader. Corpus coverage is not measured here: it needs a run over the game's shaders by someone who has them. Rewrite (the only one the emission needs): v_readlane_b32 of a proven-uniform VGPR reads the lane's own copy instead of shuffling from lane N, because a subgroup shuffle from lane >= 32 of a 32-wide subgroup is undefined (143 of 144 test shaders translate byte-identically to origin/main, only ps_w64_b_readlane_uniform changed). Everything else tier B needs is what the translator already emits per subgroup: the ballot/count/rank/first-lane words of wave_mask are the subgroup's own (the high word is 0), v_readfirstlane is the subgroup's first active lane, a waterfall runs once per distinct value of the subgroup. GPU-checked on AMD Radeon 880M (driver 26.11.2; requiredSubgroupSizeStages has FRAGMENT, size 32..64) with runtime/test/shaders/w64_graphics.py: each ps_w64_* fixture drawn with the fragment subgroup size required to 64 (one hardware wave) and to 32 (two halves). ps_w64_a_skip, _b_waterfall, _b_readfirstlane, _b_readlane_uniform and _b_ballot_atomic (counter 1024 and the 1024 slot words as a set; slot order differs) match each other and the words their headers derive; _c_bcnt_export, _c_lane_id, _c_readlane, _c_vote_stale, _c_vote_else, _c_scc_vote, _c_execz_sgpr (an SGPR written on the exec-zero side and exported) and _c_waterfall_count differ between 64 and 32 (the detector is right). ps_w64_a_one_lane is the case where only one pixel votes yes (so one half votes and the other does not, in the wave and in the halves): its skip regions (execz, vccz, vccnz with a jump-only fall-through) give equal images at 64 and 32; _c_vote_else (code on the vote's no side) and _c_scc_vote (SCC of a vote as data) differ. NVIDIA GeForce RTX 5070 Laptop (32 only, driver 617.42): tier A/B fixtures equal the derived words and the 880M@64 images (W64G_SAVE_REF / W64G_REF), tier C fixtures differ from the 880M@64 images. ps_w64_a_permlane, _a_swizzle and _a_bpermute (TEST-319: permlane16 neighbour selects, permlanex16 there and back, swizzle quad-permute, swap and broadcast modes, bpermute from lane-id addresses; every read stays in the pixel's 2x2 quad or comes back, so the words do not depend on how pixels are packed into lanes) give the derived words on an NVIDIA GeForce RTX 5070 (Linux, driver 620.73.04, 32 only). With an AMD Radeon RX 580 (Polaris, RADV Mesa 26.0.8) as the 64-lane reference (W64G_SAVE_REF; GCN has one subgroup size, 64, in every stage but no FRAGMENT in requiredSubgroupSizeStages, so vk_harness counts a requested size equal to a device's only size as applied), the RTX 5070 run of every fixture (W64G_REF) equals the reference for all 13 tier A/B fixtures and differs from it for all 11 tier C ones, pixel and vertex; the same reads in a vertex shader run on the wave interpreter (64 lanes against two waves of 32, equal) because a GPU's partial vertex waves leave the lanes they would read empty. Vertex shaders: the VS stage cannot be forced on the 880M (no VERTEX in requiredSubgroupSizeStages), so VS is covered by the strict wave interpreter (tests/semantic/test_wave64_halves.py: 64 lanes against two waves of 32; tier A/B equal, tier C differs); geometry shaders are not tested (the corpus ones are wave32; no fixture). 64 lanes against two waves of 32; tier A/B equal, tier C differs), and on RADV also on the GPU (TEST-251): RADV runs the VS stage (NGG) as wave64 by default and as wave32 with RADV_PERFTEST=gewave32 (GFX10+, seen in the RADV_DEBUG=shaders dump: 64-bit EXEC operations against exec_lo), so w64_graphics.py draws each vs_w64_* fixture both ways, 960 zero-area vertices (VKH_VERTICES) that store four words each to the heap, with vs_w64_c_lane_id as the probe that the wave size changed (largest lane id 63, then 31). RADV packs 62 or 64 vertices into a wave64 and 30 or 32 into a wave32, so the 32-lane run repacks the vertices rather than halving the waves; tier A/B words are keyed on the vertex index, which makes this the stricter test. vs_w64_a_skip, _b_waterfall, _b_readlane_uniform (readfirstlane and readlane 40/63 of uniform VGPRs) and _b_ballot_atomic (240 slots as a set) give the derived words at both sizes; _c_bcnt_export, _c_readlane and _c_lane_id differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (no fixture; the corpus has 195 wave64 geometry shaders, all tier C, see the census). _c_bcnt_export, _c_readlane and _c_lane_id differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders likewise (TEST-251): RADV runs the GS stage (NGG) as wave64 by default and as wave32 with gewave32, and w64_graphics.py draws each gs_w64_* fixture after vs_ids (960 vertices, 320 triangles, VKH_GS), each invocation finding its triangle from vs_ids's vertex number and storing four words to the heap, with gs_w64_c_lane_id as the probe (largest lane id 41, RADV puts at most 42 GS invocations in a wave64, then 31). LDS writes of a legacy GS: rdna2spirv.gs_ds maps one to an output slot from its offset alone and drops the VGPR address (the lane's GSVS area), so wave64_halves.py checks only the data a GS ds_write writes, not its address; before, a lane id that only formed the GSVS base made the shader tier C lane-id. Confirmed three ways: a hand-written GS with the base lane id * 96 translates, after spirv-opt -O, to the same instructions as without it; gs_w64_a_ring (that shape) gives the derived records at wave64 and wave32 on both GPUs; and tests/semantic/test_wave64_halves.py (GeometryRing) keeps the lane id in the written data, or in a memory store's address, tier C. The corpus GS form their GSVS base from v_mbcnt_lo/hi (all 195 contain v_mbcnt_hi): they were all a false tier C, and the census above has all 195 at tier A. wave64_halves.py --census on a translated corpus shows it. _c_bcnt_export, _c_readlane and _c_lane_id differ (the detector is right), on an RX 9070 XT (GFX1201) and a Ryzen 9800X3D iGPU (GFX1036, RDNA2), RADV Mesa 26.3.1; geometry shaders are not tested (the corpus ones are wave32; no fixture). Not checked: helper lanes of partial quads; VK_KHR_shader_maximal_reconvergence is assumed for waterfall and election loops. Tiers A and B assume subgroups of at least 32 lanes: a fragment stage may run fewer live lanes than the subgroup size it reports (Intel UHD 770: gl_SubgroupSize 32, ballot count 16, a shuffle from lane L^16 returns garbage; measured by kapitche, TEST-433), so w64_graphics.py skips the tier A/B pixel fixtures on a device whose minimum subgroup size is below 32 when neither the 64 nor the 32 run took effect; deriving the skip from a measured live fragment width (ballot count) in vk_harness is a follow-up.
Buffer bounds checking MUBUF buffer_load*, buffer_store*, and buffer_atomic* enforce num_records (V# word 2). Out-of-bounds stores/atomics skip memory access completely and out-of-bounds loads return 0 without a load. The RX 6800 measurement behind RAW loads (buffer_load_dword/x2/x3/x4, stride 0, no idxen, OOB_SELECT 3; the per-mode rule below covers every mode, stride and idxen): the byte offset O = inst_offset + soffset + (offen ? vaddr : 0) is exact (nothing truncated, and the address keeps base & 3), and dword i is data when O + 4·i + 4 ≤ num_records, else 0, measured on AMD Radeon RX 6800 (gfx1030, Windows driver 32.0.21045.29003) by running the instructions as a raw compute kernel, wave32 and wave64 (155 runs, every result either 0 or the stored data, wave32 = wave64 in every dword), for x1/x2/x4 with V# word3 0x31016fac (OOB_SELECT 3) at offsets 0..63 per lane, NUM_RECORDS 17..23 and 0x1000, base & 3 = 0 and 3: a dword at 0xf with NUM_RECORDS 18 is 0 (a start-only check reads it); x4 at 3 with 18 gives three data dwords and 0 for the fourth, which starts at 15 < 18 (so neither a whole-load nor a per-dword start check), and the zero is a whole 0, not partial bytes; x4 at offset:13 with 20 gives data, 0, 0, 0; inst_offset, soffset and offen are summed before the check; base & 3 = 3 flips at the same offsets. x3 gets the rule without a measurement. Per-mode check (V# OOB_SELECT, word3 bits [29:28]), for every MUBUF/MTBUF access, as measured natively on RDNA2 (gfx1036, 732 cases, docs/buffer_bounds.md; Mesa's GFX11 column, not its GFX10 one). idx = vindex (0 without idxen), off = inst_offset + vaddr offset (offen), offs = off + soffset. A dword at byte 4·k of the access is out of range when: 0 STRUCTURED_WITH_OFFSET idx >= num_records or off + 4k + 4 > stride; 1 STRUCTURED idx >= num_records (no idxen: idx 0, so only num_records == 0); 2 DISABLED num_records == 0; 3 RAW offs + 4k + 4 > num_records (idx * stride is in the address, not in the check). A literal word3 (s_mov_b32 earlier in the block) folds the mode, a run-time one selects with OpSelect. Multi-dword accesses, measured on the Radeon 880M (gfx1150, a valid proxy: gfx1036 follows the same column and gfx1150 matched it bit-exactly): in modes 0 and 3 buffer_load_dwordx2..x4 and buffer_store_dwordx2..x4 are per dword, for loads and stores alike (x4 at off 20 of 32 in RAW loads/stores 3 dwords, at 28 one, at 32 none; mode 0 likewise at the stride); modes 1 and 2 check once and always take the whole access. A typed element (buffer_load_format_*, buffer_store_format_*) is all or nothing and ends at its format's size (32_32_32_32 at off 20 of 32 reads or writes nothing), and an atomic checks its dword's end like a dword access. The translator does the same: per-dword guarded loads and stores for modes 0 and 3 (a store that straddled the edge used to write past it), the element size from the instruction's format, a literal word3 or the V#. The same oracle confirmed the terms (504 buffer_load_dword probes, idxen/offen/inst_offset/soffset at the stride and record edges, 0 disagreements): mode 0's off has inst_offset and no soffset, mode 1 reads nothing but the index, mode 3 adds inst_offset and soffset. s_buffer_load (SMEM) is separate: it keeps the num_records bound of the Scalar/buffer row and ignores OOB_SELECT (the same pattern for 0 to 3). Swizzle: SWIZZLE_ENABLE (V# word1 bit 31, Mesa gfx10-rsrc.json line 326; word1 [31:30] on GFX11, gfx11-rsrc.json line 259) and ADD_TID_ENABLE (word3 bit 23, line 337) change the address and the bounds in every mode and are modelled; see the Swizzled buffer addressing row. SWIZZLE_ENABLE and ADD_TID_ENABLE are modelled; see the Swizzled buffer addressing row. SWIZZLE_ENABLE (V# word1 bit 31, Mesa gfx10-rsrc.json line 326; word1 [31:30] on GFX11, gfx11-rsrc.json line 259) and ADD_TID_ENABLE (word3 bit 23, line 337) change the address and the bounds in every mode and are not modelled: a literal V# with either set is Unsupported, a run-time V# with them is translated unswizzled, which is silently wrong (known gap). Until 2026-11-22 the translator ignored OOB_SELECT and checked by stride alone (offset < num_records, index < num_records, or offset < num_records * stride): a V# with word3 = 0 (mode 0, stride 0) was fully readable and is now always out of range, as on hardware, so the test harnesses' output V# is 0x31016fac now (vk_compute_test, the interpreter tests, cs_bounds.asm, cs_fmt_1010102.asm, cs_store.asm). How confirmed: the native RDNA2 measurement (gfx1036) and the gfx1150 oracle (RDNA3.5, same column); GPU test cs_oob_select.asm (every mode, literal and run-time V#, words derived from the rules) on an NVIDIA RTX 5070 and an AMD Radeon 880M, which checks the translation, not RDNA2; tests/semantic/test_buffer_oob_select.py (a hand-written table of 33 cases over the four modes, loads and stores, both V# forms, plus the multi-dword stores and typed elements); cs_oob_tail.asm pins the end-based edge, per-dword x4 loads and stores and the all-or-nothing element, where Mesa's GFX10 column gives other words. Unmeasured: gfx1013/GFX10.1 itself (see docs/buffer_bounds.md), swizzle, unaligned addresses, and the mode 1/2 boundary of buffer_load_dwordx2..x4 on RDNA2 hardware proper (the gfx1150 proxy shows all dwords in). Checked by tests/semantic/test_value_semantics.py (RawBufferTailBounds: the RX 6800 rows, values and the addresses loaded) and the GPU tests runtime/test/shaders/cs_bounds.asm (AMD Radeon RX 9070 XT, RX 6800), cs_buf_tail.asm (RX 6800, Vulkan, driver 26.11.2; aligned offsets only, since the translator's Aligned 4 loads at byte-exact addresses were not checked on a Vulkan driver) cs_oob_select.asm and cs_oob_tail.asm. cs_fmt_xy_xyz.asm shows the whole element deciding for _xy and _xyz too, measured natively on a Radeon 680M (gfx1035, RDNA2): components that end inside num_records, in an element that doesn't, read 0 and store nothing.
Swizzled buffer addressing (V# SWIZZLE_ENABLE, ADD_TID_ENABLE) MUBUF/MTBUF buffer_load*, buffer_store*, buffer_atomic*, buffer_load_format_*/buffer_store_format_* and tbuffer_load/store_format_* follow the rules measured natively on RDNA2 (AMD Radeon(TM) Graphics, gfx1036, Windows driver 32.0.21042.62, wave32 and wave64; tools/buffer_swizzle_probe.py, SHADER-343). MUBUF/MTBUF buffer_load*, buffer_store*, buffer_atomic*, buffer_load_format_*/buffer_store_format_* and tbuffer_load_format_* follow the RDNA2 ISA ("RDNA 2" Instruction Set Architecture, 8.1.5 Buffer Addressing, "Swizzled Buffer Addressing" and tables 33, 35 and 37). Fields, Mesa 24.0.6 src/amd/registers/gfx10-rsrc.json (SQ_BUF_RSRC_WORD1, SQ_BUF_RSRC_WORD3 and its _gfx103 twin, the same bits): SWIZZLE_ENABLE word1 bit 31, STRIDE word1 [29:16], INDEX_STRIDE word3 [22:21] (IS = 8 << n, i.e., 8, 16, 32 or 64), ADD_TID_ENABLE word3 bit 23; element size is fixed at 4 bytes (word3[20:19] and word1[30] do not alter addressing or stepping). Effective index: index = idxen ? vindex : 0), where lane is the wave lane (thread_id[5:0] within the wave, wrapping at 32 in wave32 and 64 in wave64; Gen.wave_lane); idxen = 1 completely ignores ADD_TID_ENABLE (linear or swizzled, address and bounds, loads/stores/typed/atomics). Activation: SWIZZLE_ENABLE activates (swz_active) only when idxen = 1 or ADD_TID_ENABLE = 1; with neither, addressing is linear (base + soffset + off) and OOB_SELECT 3 stays RAW even when stride ≠ 0. Address formula (when swz_active): off = uint32((offen ? vaddr : 0) + inst_offset) (32-bit wrap), buffer_offset = (index / IS · stride + (off & ~3)) · IS + (index % IS) · 4 + (off & 3), address = base + soffset + buffer_offset (confirmed byte-exact for IS 8/16/32/64, non-4-multiple strides, stride 0, and unaligned offsets). Two swizzle sub-modes: (1) Scratch swizzle (SWIZZLE_ENABLE = 1, idxen = 0, ADD_TID_ENABLE = 1): raw multi-dword buffer_load/store_dwordx2..x4 step by +4 · IS bytes per dword (and unaligned 4-byte raw accesses crossing a dword boundary split across +4 · IS on hardware), while typed formats > 4 bytes (8/12/16-byte MUBUF and MTBUF loads/stores, regardless of component count) and 8-byte buffer_atomic_*_x2 are suppressed (loads return 0, stores/atomics are no-ops, even in OOB_SELECT 2); typed formats ≤ 4 bytes work normally. (2) Indexed swizzle (SWIZZLE_ENABLE = 1, idxen = 1, regardless of ADD_TID_ENABLE): raw x2..x4, typed formats (8/12/16 bytes), and buffer_atomic_*_x2 step linearly by +4 bytes from the swizzled base address, even across IS boundaries, and typed formats > 4 bytes execute normally. Bounds (OOB_SELECT): modes 0, 1 and 2 follow the Buffer bounds checking row with idx = index; OOB_SELECT 3 with swz_active and stride ≠ 0 checks uint64(index) + uint64(soffset) >= num_records or off + payload > stride (per-dword for raw x1..x4, whole element for typed), while inactive swizzle or stride = 0 keeps the RAW check uint64(off) + uint64(soffset) + payload > num_records (no 32-bit wrap on off + soffset, whereas vaddr + inst_offset wraps at 32 bits before bounds checking). A literal word1 / word3 (s_mov_b32 earlier in the block) folds each bit; a run-time V# selects dynamically with L = swz_u · (3 + INDEX_STRIDE) (IS = 1 gives the linear address). Until 2026-11-22 the translator added vindex + lane when idxen = 1 and ADD_TID_ENABLE = 1, swizzled even when both were 0, stepped all swizzled multi-dword/typed accesses by 4 · IS, allowed > 4-byte typed/atomic_x2 accesses in scratch-swizzle mode, omitted soffset from swizzled mode 3's index check, and wrapped off + soffset at 32 bits in RAW mode 3. How confirmed: native RDNA2 measurement on AMD Radeon(TM) Graphics (gfx1036, Windows driver 32.0.21042.62, wave32 & wave64) via tools/buffer_swizzle_probe.py --oracle both (22/22 cases across 8 groups match bit-exactly, 0 unexpected mismatches, 0 unexpected wave32/64 diffs, 64-thread ADD_TID_ENABLE wave-lane wrap verified at both wave sizes); CPU semantic tests tests/semantic/test_buffer_swizzle.py (literal and run-time V#, both sub-modes, mode 3 soffset, 32-bit wrap, typed/atomic_x2 suppression, and cs_buf_swizzle.asm); tests/test_buffer_swizzle_probe.py. Remaining approximations / unmeasured: unaligned raw accesses splitting across +4 · IS in scratch-swizzle mode (the translator uses Aligned 4 PSB loads/stores), general typed-format / buffer_atomic_*_x2 natural alignment suppression (16_UINT at odd offsets, 32_* at non-4B offsets, atomic_*_x2 at non-8B addresses, observed on gfx1036 in both linear and swizzled modes), and GFX11's two-bit SWIZZLE_ENABLE (word1[31:30]). SWIZZLE_ENABLE word1 bit 31, STRIDE word1 [29:16], INDEX_STRIDE word3 [22:21] (IS = 8, 16, 32 or 64 indices), ADD_TID_ENABLE word3 bit 23; there is no ELEMENT_SIZE field, the element is fixed at 4 bytes (ISA 8.1.5; LLVM SIInstrInfo::getScratchRsrcWords23 sets it only up to GFX8). index = (idxen ? vindex : 0) + (ADD_TID_ENABLE ? lane : 0), where the lane is thread_id[5:0] within the wave (Gen.wave_lane), swizzled or not: table 33 adds the thread id with no swizzle condition and table 36's ring column is linear with add_tid. offset = (offen ? vaddr : 0) + inst_offset, without soffset. Swizzled: buffer_offset = (index / IS · stride + offset / 4 · 4) · IS + index % IS · 4 + offset % 4, address = base + soffset + buffer_offset, so dword k of a multi-dword access (and of a typed element over 4 bytes) is 4 · IS bytes after dword k − 1, not 4. Bounds as in Buffer bounds checking, with idx = index (the lane included), except that OOB_SELECT 3 with SWIZZLE_ENABLE and stride ≠ 0 checks index >= num_records or off + 4k + 4 > stride (table 35), like mode 0; stride 0 keeps the raw check. A literal word1 / word3 (s_mov_b32 earlier in the block) folds each bit. A run-time word1 makes IS = 2^(SWIZZLE_ENABLE · (3 + INDEX_STRIDE)): IS = 1 is the linear address, so one formula serves both and nothing is selected but the mode 3 check; a run-time word3 multiplies the lane by ADD_TID_ENABLE. Cost, measured on the 116 shaders of runtime/test/shaders that both versions translate (all spirv-val clean before and after): the 56 with a MUBUF access through a run-time V# grow by 15.1 % in SPIR-V lines (+10.4 % over all 116), 30 to 45 instructions per access (address, lane, 4 per extra dword, a select per dword of the bounds check); a literal linear V# gives the same SPIR-V as before. Outside compute and mesh shaders the lane is SubgroupLocalInvocationId, so a VS, PS or GS with a run-time V# now declares GroupNonUniform. The offset arithmetic is 32-bit, like the linear address. Until 2026-11-22 a literal V# with either bit was Unsupported and a run-time one was translated unswizzled. How confirmed: Mesa/LLVM and AMD's ISA reference (fields and formula), not measured on hardware; tests/semantic/test_buffer_swizzle.py (hand-worked addresses for IS 8/16/64, index msb/lsb, soffset after the swizzle, the mode 3 rule with and without a stride, per-dword x2/x3/x4 loads and stores, a 16-byte typed element, ADD_TID on lane 5 linear and swizzled, each with a literal and a run-time V#); GPU test runtime/test/shaders/cs_buf_swizzle.asm (check.py, scripts/run_gpu_tests.py), which checks the translation, not RDNA2. Unmeasured (the layout itself is measured: docs/shader_validation.md, SHADER-343, gfx1036, 22 of 22 cases bit-exact): offsets that are not dword aligned (the ISA requires alignment for swizzled accesses; the translation adds offset % 4), wrap of the 32-bit offset, and GFX11's two-bit SWIZZLE_ENABLE (word1 [31:30]). In the corpus SCRATCH_EN is 0 in every CS, so a swizzled V# can only come from a descriptor the game writes itself.
Null mask source The scalar register null supplies zero when read as a lane mask. The wave64 fixture in tests/semantic/fixtures/null_mask_source.asm checks a high-bit test, a zero-bit count, a first-set-bit search and a masked vector write after s_and_saveexec_b64. LLVM 21.1.8 assembles each instruction for gfx1030. LLVM GFX10 null operand
Wave64 mask ballot tools/lane_masks.py tracks per-lane masks (including 32-bit MASK_LO/MASK_HI halves, vcc_lo/vcc_hi, s_bfm_b64 bitfields, _b64 copies of immediates into vcc, and _b64 bitwise/select ops combining a lane mask or vcc destination with immediates; 32-bit mask + non-0/-1 immediate into an SGPR stays plain data, #1792). Split wave64 SGPR pairs whose two dwords hold separately written half-masks or a half-mask paired with a 0/-1 EITHER constant (include_either=True) are recognized by holds_lane_mask and read s[r] for lanes 0–31 and s[r+1] for lanes 32–63 in mask_src, and --wave64-emulate's x_mcache keys wave_mask on every dword of an SGPR operand so rewriting s[r+1] invalidates a cached 64-bit exchange. s_bcnt1_i32_b64/b32, s_bcnt0_i32_b64/b32, s_ff1_i32_b64/b32, s_ff0_i32_b64/b32, s_bitcmp0/1_b32/b64, and v_mbcnt_lo/hi_u32_b32 reconstruct the 64-bit wave mask via OpGroupNonUniformBitwiseOr (GroupNonUniformArithmetic), restricting 32-bit half ops (including v_mbcnt_lo/hi_u32_b32 on vcc_hi/vcc_lo/exec_lo via mask_half) and s_cmp_eq/lg_u32 (wave_equal) to the known 32-bit half in wave64. tools/lane_masks.py tracks per-lane masks (including 32-bit MASK_LO/MASK_HI halves, vcc_lo/vcc_hi, and s_bfm_b64 bitfields). s_bcnt1_i32_b64/b32, s_bcnt0_i32_b64/b32, s_ff1_i32_b64/b32, s_ff0_i32_b64/b32, and s_bitcmp0/1_b32/b64 reconstruct the 64-bit wave mask via OpGroupNonUniformBitwiseOr (GroupNonUniformArithmetic), restricting 32-bit half ops and s_cmp_eq/lg_u32 (wave_equal) to the known 32-bit half in wave64. Opposite-half s_cmp_*_u32/i32 comparisons (lo vs hi), ordering comparisons on mask halves, and s_cmp_*_u32/i32/u64 comparing a lane mask against an arbitrary scalar or immediate reconstruct the exact 32/64-bit mask words via wave_mask. A compare with 0 keeps the vote, but a compare with -1 (all ones) does not: lanes that were never launched (a group smaller than the wave) don't vote, while their bits are 0 in the real mask, so until 2026-11-22 s_cmp_eq_u32 vcc_hi, -1 read 1 in a 40-thread wave64 for vcc_hi = 0xff. GPU-checked with cs_w64x_partial_scmp.asm (40-thread wave64, native and --wave64-emulate) and cs_w32_partial_scmp.asm (20-thread wave32) on an AMD Radeon RX 7800 XT (RADV, Mesa 26.2.6): all 8 words as the headers derive, and 4 of 8 wrong in each with the old translator. GPU-checked with runtime/test/shaders/cs_wave64_ballot.asm and cs_wm_*.asm on AMD Radeon RX 9070 XT (64-wide subgroup); semantic test coverage in tests/semantic/test_scalar_bitcmp.py, tests/semantic/test_scalar_alu_shifts.py, tests/semantic/test_loop_ballot_barrier.py, and tests/test_lane_masks.py (split SGPR pairs, dual-dword x_mcache, _b64 mask+imm, and v_mbcnt half selection CPU-checked, not yet GPU-verified). GPU-checked with runtime/test/shaders/cs_wave64_ballot.asm and cs_wm_*.asm on AMD Radeon RX 9070 XT (64-wide subgroup); semantic test coverage in tests/semantic/test_scalar_bitcmp.py and tests/semantic/test_scalar_alu_shifts.py.
VOP3 FP modifiers on constants tools/shader_ir.py keeps VOP3 FP source modifiers (neg(...), `
v_cmp_class_f64, v_cmpx_class_f64 IEEE-754 binary64 numeric class test against the 10-bit mask (0 sNaN, 1 qNaN, 2 -inf, 3 -normal, 4 -subnormal, 5 -0, 6 +0, 7 +subnormal, 8 +normal, 9 +inf), lowered in Gen.cmp_class_f64 using pure 32-bit %uint bit extraction on (lo, hi) with no Float64 capability required. Supports VGPR/SGPR pairs, float inline constants (fimm), sign-extended inline integers (-16..64), 32-bit literals placed in bits [63:32] (as on RDNA2), and VOP3 abs/neg sign-bit modifiers on src0 (abs clears bit 63, neg flips bit 63 without quieting sNaN). Inactive lanes produce 0 for v_cmp_class_f64 and stay inactive for v_cmpx_class_f64. Source: AMD RDNA2 ISA VOPC/VOP3 V_CMP_CLASS_F64 / V_CMPX_CLASS_F64. CPU-checked by tests/semantic/test_cmp_class_f64.py (all 10 classes with low- and high-word payload bits, mask combinations and high-bit ignores, SGPR pairs, fimm/inline/literal constants, abs/neg/-|x|, v_cmpx_class_f64 EXEC narrowing, inactive lanes, no Float64 capability, bad-operand rejections). Not GPU-verified.
Mesh/compute input registers (historical measurement) An early read-before-write analysis over all compute and mesh shaders found compute v0 (880), v0–v1 (614), v0–v2 (50), consistent with AMD's local thread ID x/y/z in v0/v1/v2, and scalar inputs centred on a pointer at s[4:5] and s6/s7. Mesh: every one of 2,969 reads exactly v5, plus s3 (always arithmetic), s[16:17] and s19–s23. The early pass also read FSSM 0x13C as the group width and compared the first SGPR multiply against it (82 match, 151 don't, 1,447 no simple multiply) and wrongly concluded that 0x13C was not the group width; the matching register varied by shader (s6/s10/s7/s9…). PSV0 gave the real thread-group sizes (32×1×1 for 1,253, 8×8×1 for 416, …). Superseded: 0x13C/0x140/0x144 are the thread-group size, COMPUTE_PGM_RSRC2 at 0x138 gives the per-shader user-SGPR count and enabled workgroup IDs, and mesh takes NumThreads, limits and topology from PSV0 with v5 = linearGroupIndex * NumThreads + LocalInvocationIndex. All 2,689 CS and 9,282 mesh shaders translate now (see the Compute shaders and Mesh shaders rows).
Formerly untranslated Mesh (9,282), geometry (195) and compute (2,689) now translate; s_swappc_b64 is replaced by Vulkan vertex inputs (see Vertex fetch) and the tbuffer_load_format_* forms use the instruction's format. Packed tbuffer_load_format_d16_{x,xy,xyz,xyzw} load two 16-bit components per VGPR, with the same final partial write as MUBUF. Native gfx1036 wave32/64 confirmed all four widths for RGBA8_UINT and RGBA8_UNORM with a conflicting 32_UINT V# format. Both packed and ordinary MTBUF loads ignore the V# channel selectors and use identity for the instruction format, zero-filling missing channels. Native gfx1036 measurements compared multiple V# permutations with MUBUF as a control. An INVALID V# format (0) suppresses the MTBUF fetch even at a valid address inside its bounds. Native gfx1036 wave32/64 returned zero components at all four widths and preserved the untouched half of an odd D16 destination, as specified for unbound resources in the RDNA2 ISA, §8.1.4. A translated vertex fetch on RTX 5080 and Radeon Graphics also followed a change to the instruction format between two draws with identical vertex records and V#. Fixed UNORM and SNORM loads share the exact integer quotient for each magnitude width across instructions and channels (checked against rationally rounded binary32 values on RTX 5080 and Radeon Graphics). The gfx1013 disassembler omits format: for the GFX10 MTBUF default, BUF_FMT_8_UNORM (code 1). A few rare ops are still reported by name rather than guessed.
v_cubema_f32 signed zero Whenever the selected major axis is ±0.0, v_cubema_f32 returns +0.0 (0x00000000), never -0.0 (0x80000000), while preserving NaNs and signed non-zero major-axis values (2.0 * m). Emitted as OpFOrdEqual %bool m %f0 selecting %f0 over OpFMul m 2.0, so -0.0 maps to +0.0, NaN compares false and propagates, and non-zero finite/infinite values double with sign preserved. Until 2026-11-22 both tools/rdna2spirv.py and tools/f32_fuzz.py multiplied m by 2.0 directly and returned -0.0 when z = -0.0 on (±0.0, ±0.0, -0.0) (or when -0.0 was selected alongside NaN axes). Measured natively on RDNA2 (gfx1036, AMD Radeon(TM) Graphics, Windows driver 32.0.21042.62, wave32 & wave64, all four MODE combinations flush/keep/no_dx10/ieee via tools/hw_oracle/): all 8 (±0.0, ±0.0, ±0.0) triples, -v source negation of +0.0, mul:2, negative denormals, and (-0.0, qNaN, qNaN) returned 0x00000000, while (-qNaN, 1.0, 1.0) returned 0xffc00000 and (-1.0, qNaN, qNaN) returned 0xc0000000. Checked by tests/semantic/test_valu_cube.py (test_signed_zero_triples_and_nan_cubema), tests/test_f32_fuzz.py (test_cube_major_axis), and tools/f32_fuzz.py --oracle hw --ops v_cubema_f32,v_cubeid_f32,v_cubesc_f32,v_cubetc_f32.
v_dot2c_i32_i16, v_dot8c_i32_i4 VOP2/VOP3 accumulating forms of v_dot2_i32_i16 and v_dot8_i32_i4 (D = sum(S0.elem[k] * S1.elem[k]) + D, signed 2×16-bit and 8×4-bit). Wraps at 32 bits by default and saturates to [INT32_MIN, INT32_MAX] with VOP3 clamp (sharing the v_dot2_i32_i16/v_dot8_i32_i4 signed-carry path); op_sel, neg/abs, and DPP/SDWA are refused. Registered in read-before-write VGPR tracking alongside v_dot4c_i32_i8. Source: LLVM AMDGPU VOP2Instructions.td (HasDot4Insts / HasDot3Insts, gfx908 VOP2/VOP3 syntax; not in the default gfx1013/gfx103x feature set). Not measured on AMD hardware (translated Vulkan lowering checked on RTX 5070 by @duudiis: 40,960/40,960 exact words across wave32 and emulated wave64). Checked bit-for-bit on the CPU (spirv_mini_interp) and with spirv-val by tests/semantic/test_alu_dotc.py; not run on the shader corpus.
Out-of-bounds typed buffer loads and DST_SEL=1 When a MUBUF buffer_load_format_{x,xy,xyz,xyzw} or buffer_load_format_d16_{x,xy,xyz,xyzw} is out of bounds (OOB_SELECT 0–3, num_records == 0, partial-element spill, or swizzled OOB), memory is not accessed and raw data channels (DST_SEL 4..7) read 0, while the V# DST_SEL swizzle still runs: DST_SEL=0 returns 0 and DST_SEL=1 returns 1.0f (0x3F800000, d16 0x3C00) iff V# FORMAT[6:0] is a valid float, normalized or scaled buffer format (1..77 ending in _UNORM, _SNORM, _USCALED, _SSCALED, or _FLOAT), and integer 1 (0x00000001, d16 0x0001) for UINT/SINT, INVALID (0), and reserved codes (78..127). d16_x and d16_xyz preserve the unaddressed upper 16 bits of the final destination VGPR, and MTBUF tbuffer_load_format_* ignores V# DST_SEL on both out-of-bounds and FORMAT=0 loads (returning 0 in addressed channels). Until 2026-11-22 Gen.buffer_load_format clamped the post-swizzle result to 0 when in_b was false (SHADER-429), dropping DST_SEL=1 on out-of-bounds loads and returning 1.0f instead of 1 for DST_SEL=1 with FORMAT=0. Hardware-verified on RDNA2 (gfx1036, Windows 11, driver 32.0.21042.62, wave32 and wave64, 746 kernels via tools/hw_oracle: all 41 Gen.FORMATS across xyzw/d16_xyzw/d16_xyz/d16_x, all 128 7-bit FORMAT codes 0..127 for both f32 and d16, OOB_SELECT 0–3, partial spill, swizzled OOB, MTBUF controls, and inactive EXEC lanes), Vulkan GPU-checked across all 128 7-bit FORMAT codes (xyzw, d16_xyzw, d16_xyz, d16_x) and the cs_fmt_*/cs_oob_*/cs_bounds/cs_buf_* fixtures on NVIDIA GeForce RTX 5090 (driver 32.0.16.1088) and AMD Radeon Graphics (gfx1036, driver 32.0.21042.62), and CPU/spirv-val-checked by tests/semantic/test_buffer_oob_dst_sel.py.
v_div_fixup_f32 Measured natively on an AMD Radeon(TM) Graphics RDNA2 GPU (gfx1036, not the console's gfx1013; Windows driver 32.0.21042.62, tools/hw_oracle, wave32 and wave64 identical on every case: 256 seeded triples across 4 MODEs plus 73 targeted special-case/modifier rows, 0 mismatches). Computes div_fixup_f32(S0=quotient, S1=denom, S2=numer) with pure integer SPIR-V ops under the game's inferred MODE (IEEE=0, denorm32=0, DX10_CLAMP=1): VOP3 abs (clear bit 31) then neg (flip bit 31) apply bitwise to S0/S1/S2 before classification (including NaN payloads); S1/S2 subnormals flush to signed zero (exp == 0) while S0 subnormals are preserved; priority order is (1) NaN(S2) → S2, (2) NaN(S1) → S1 (signalling NaNs pass unchanged under IEEE=0, quieted only when IEEE=1), (3) 0/0 or ±inf/±inf → 0xFFC00000 (-qNaN), (4) zero(S2) ∨ inf(S1) → ±0.0, (5) zero(S1) ∨ inf(S2) → ±inf, (6) exp(S2) − exp(S1) ≤ −151 → ±0.0 (pure biased-exponent check, beats NaN(S0) and inf(S0); no overflow check), (7) NaN(S0) → ±inf, (8) copysign(S0, sign(S1) ⊕ sign(S2)). Output modifiers mul:2/mul:4/div:2 apply before clamp, and clamp maps NaN to +0.0 (DX10_CLAMP=1) before FClamp to [0, 1]. Not modelled: IEEE=1 sNaN quieting, denorm32=3 keeping S1/S2 subnormals, and the hardware omod -0 → +0 quirk (same as the other f32 ops). Checked bit-for-bit against 73 measured gfx1036 words in tests/semantic/test_alu_div_fixup_f32.py.

System values confirmed on the corpus (SHADER-4)

Counted with scripts/audit_shader4_regs.py on the disassembled game shaders (counts only):

  • Compute shaders: Confirmed by corpus counts across all 2,689 CS (TIDIG_COMP_CNT 0/1/2/3 = 724/1,786/179/0; TGID X/Y/Z 100/110/111 = 724/1,786/179; TG_SIZE_EN = 0, SCRATCH_EN = 0, TRAP_PRESENT = 0; RBW VGPRs: v0 in 2,602, v1 in 893, v2 in 57) + GPU tests cs_lds.asm and #186's cs_workgroup_yz.asm (Y/Z WorkgroupId).
  • Mesh shaders: Confirmed by corpus counts (all 9,282 MS are 128×1×1 in PSV0, 100% read v5 once, through v_readfirstlane_b32 followed only by s_lshr_b32 D, sX, 7, 100% read s3 exclusively via s_bfe_u32 D, s3, 0x40018 for bits [27:24]; 0 read s3 [31:28], [23:16], or [15:0]; audited with scripts/audit_shader4_regs.py) + GPU tests ms_tri.asm, ms_wave_info_s3.asm (s3[27:24] across both waves), and #219 (mesh v5 workgroup index on a 2 × 3 × 4 grid).
  • Geometry shaders: Confirmed by corpus counts (all 195 GS read only v0 and v1; 0 read v2, v3, or v4) + GPU test gs_tri.asm.

Main blocker at the time (superseded): descriptor loads. On a 3,000-shader sample, s_load_dwordx4/x8 stop over half of them. Shaders load texture, buffer and sampler descriptors through user-data SGPR pointers, and how the game's root signatures map onto those SGPRs is set up by game code. Reading that mapping from the exe (root signature creation plus the FSSM user-data metadata) before building the binding layer was the next step; guessing it would give silent rendering bugs. The translator now handles those loads against the push-constant user-data contract (User data, Scalar/buffer memory and the descriptor rows); the D3D12 layer still has to supply the root-signature mapping. The other blockers listed then (mesh, the vertex-fetch call, geometry, compute and compressed exports) are closed for the corpus: all 26,503 shaders translate (see Translator status). The remaining fidelity gap is wave64 cross-half code on 32-wide subgroups.

Day one, in order

  1. scripts\first_look.ps1 -Exe ... checks the exe is plain, lists the imports to shim, and does a dry run.
  2. Read the RPF9 table of contents only where it is already plain on disk. Five archives have tables that look packed or encrypted; under the ground rules above they stay unread and are recorded, not decrypted. Where a table is readable, a reader in rpf9_carve.py gives carved blobs real names and types, and the remaining unread data shows what it is.
  3. Find the texture and mesh resource structures in the exe (their loaders give exact field layouts), which turns carved blobs into named textures and meshes.
  4. Shader translation: already complete for all 26,503 shaders (see Translator status); the day-one work is validating them through the runtime.

Disassembling shaders

The AMDGPU disassembler needs LLVM 21+ built with the AMDGPU target (llvm-mc; on Linux the llvm-21 package installs it at /usr/lib/llvm-21/bin/llvm-mc). The official Windows LLVM build has no AMDGPU target and ships no llvm-mc.exe. On Windows, either build a native one or run it from WSL.

Native: scripts\build_llvm_mc.ps1 fetches the LLVM sources the tool needs (sparse, shallow), builds llvm-mc alone with LLVM_TARGETS_TO_BUILD=AMDGPU, static CRT and the DIA SDK off (its headers need ATL, which the C++ build tools don't always include), checks it disassembles an s_endpgm for gfx1013, keeps only llvm-mc.exe (by default in %USERPROFILE%\.leonida\llvm-mc) and sets LLVM_MC for the user. It needs git, Python and Visual Studio with the C++ x64 tools, about 2 GB of temporary space and 20-40 minutes. -Dest, -NoEnv, -Keep and -Version change the defaults. Keep -Dest out of AppData: python from the Python install manager (the WindowsApps alias) doesn't see folders that other programs create under %LOCALAPPDATA% or %APPDATA%, so make_game.py reports llvm-mc missing and the fuzzers stop with WinError 2, although LLVM_MC names the file; py, or the same python.exe started by its full path, sees it (measured with Python 3.14.7 on Windows 11).

powershell -ExecutionPolicy Bypass -File scripts\build_llvm_mc.ps1
python -I make_game.py --game "D:\path\to\your\package" --stages shaders

WSL: install llvm-21 and give LLVM_MC the whole command:

set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc
python -I make_game.py --game "D:\path\to\your\package" --stages shaders

The same form works in every tool that reads LLVM_MC. tools/mc_command.py splits it for shader_disasm.py, the tests, runtime/test/shaders/build.py and scripts/run_gpu_tests.py; the assembler callers pass the assembly on stdin, so a WSL command never receives a Windows file path.

shader_disasm.py disassembles one s_endpgm before starting, so a missing tool or AMDGPU target stops the run with that reason instead of writing empty .s files. To disassemble by hand inside WSL:

LLVM_MC=/usr/lib/llvm-21/bin/llvm-mc python3 -I <repo>/tools/shader_disasm.py <work>/shaders/fssm

Code starts at the u32 at FSSM offset 0xC0 (the code-section offset) plus 0x28 bytes into that section, and ends at the last s_endpgm. Use --mcpu gfx1013. On 300 random shaders it decoded 284 cleanly (134 invalid words in total), against 201 clean and 6,560 invalid for gfx1030 and 283 clean for gfx1010–1012.

Pixel-shader inputs

tools/fssm_header.py decodes the FSSM input table: 8-byte records from 0x138 while the first byte is 6. Byte 1 is the semantic id, byte 2 the component mask, byte 3 the running index, byte 6 the parameter slot, and byte 7 holds flags (bits 0–1 = the read method: 0x01 read through v_interp_mov_f32, 0x02 through 32-bit v_interp_p1/p2; values 0 and 3 never occur; bit 3 marks a Float16-typed parameter; bit 4 = 16-bit interpolant). The record's position is the v_interp attr number. read_methods() returns those bits by position (the #1246 accessor was named interpolation_modes; #1301 renamed it) — they are the read method, not the D3D interpolation mode (the mode is PSV0's; see the "PS interpolation modes (SHADER-181)" row and the "PS v_interp read methods" row). interpolants() returns the count and a fp16 bitmask by position; rdna2spirv.py uses it for the pixel-input declarations. wave_size() decodes the compiled wave size from the header flags word u32[0xD4] bit 5 (0x20 = wave32, 0 = wave64), consumed by rdna2spirv.py for every stage (see Wave64 handling). Measured on the 26,503-blob corpus: every blob starts with FSSM and is at least 0xD8 bytes long, 2,662 are wave32 (1,535 CS, 1,127 PS) and 23,841 are wave64 (1,154 CS, 195 GS, 9,282 MS, 10,974 PS, 2,236 VS) with 0 contradictions against GFX10 code-proven wave32/wave64 instructions; 25,643 satisfy u32[0x120] + u32[0x12C] == u32[0x130] (the 860 that do not store 0xDEADBEEF at 0x130); 12,101 are PS, 10,307 with a non-empty table (55,791 records, 11,199 of them 16-bit). The count equals the number of distinct v_interp attr numbers in 11,316/12,101 PS (93.5%); 300 more declare one unread input, 475 declare two or more, and the 10 undercounts are one family whose first record at 0x138 has kind 7. A 200-PS spot check agreed on 187/200. Flag bit 4 matches the *_f16 interpolation opcodes in 12,067/12,101 (99.7%).

tools/ps_interp_modes.py decodes the interpolation mode of each PS input from the DXBC container carved next to the FSSM, and runs the census. The mode is not in the FSSM: no FSSM word stores SPI_PS_INPUT_ENA/ADDR (every u16 in bytes 0x00–0x138 of all 12,101 PS was compared against the value reconstructed from the DXBC signature; only constants coincide). The PSV0 chunk (writer: dxc lib/DxilContainer/DxilPipelineStateValidation.{h,cpp}) holds, after the runtime info, resource bindings, string table and semantic-index table, a u32 element size (16) and then one 16-byte input element per row: u32 semantic-name offset (0 = system value), u32 semantic-index offset, u8 rows, u8 start row, u8 cols[3:0] | start col[5:4] | allocated[6], u8 semantic kind (DXIL::SemanticKind: 0 Arbitrary, 3 Position, 6 ClipDistance, 7 CullDistance, 13 IsFrontFace), u8 component type (DxilProgramSigCompType: 1 UInt32, 3 Float32, 6 Float16), u8 interpolation mode, u8 dynamic mask | output stream, u8 reserved. The ISG1 chunk (the repo's 32-byte elements) supplies the read mask that marks live rows. The FSSM record flags decode as the read method — bit 0 (0x01) v_interp_mov_f32, bit 1 (0x02) 32-bit v_interp_p1/p2, bit 3 (0x08) Float16-typed parameter, bit 4 (0x10) *_f16 opcodes — and the disassembly supplies the I/J operand of every interpolation. Per shader the code reads one barycentric pair (v0/v1 in 10,259 PS, none in 1,841, one v14 copy), and the pair's class follows the read rows: perspective-centre when a perspective generic is read, linear only in the 4 PS that interpolate SV_Position through the parameter cache (D3D forces noperspective on SV_Position), flat otherwise. Synthetic tests: tests/test_ps_interp_modes.py.

Baseline already recorded

  • reports/manifest.json: SHA-256 of all 108 files in Documents\GTA6 (208.5 GiB). Run python -I tools\manifest.py verify <game> to check a copy against it.
  • reports/rpf_probe.json: all 22 archives are RPF9. Five have tables that look packed or encrypted (levels, movies, core_bvh4, navmeshes, data).
  • reports/pe/: the 16 bundled DLLs are plain x86-64 PE with no encrypted sections. Through the loader their xmem.dll imports and two d3d12_xs.dll root-signature calls bind to shims. Every other import resolves on desktop Windows. The proxy covers the measured device slots and forwards the rest in PC vtable order; the Xbox queue/fence/command-list extensions and PresentX remain unknown.