Round 9b translator fixes for rendering correctness and Mandy d3d12/ parity:
1. Unconditional CS & MS LDS OOB bounds (Mandy 21633b328 parity):
- Record g.lds_declared from PSV0.shared for MS and RSRC2.LDS_SIZE for CS.
- Whenever g.lds_declared > 0 (opt-out --no-lds-bounds), set
g.lds_dwords = g.lds_bound = min(g.lds_declared, 16384) so every LDS
read, write, sub-dword, wide, and atomic op goes through lds_access()
(OOB reads return 0, OOB writes/atomics dropped instead of wrapping).
2. PS DB_SHADER_CONTROL bit 12 EarlyFragmentTests (Mandy f33940415/bf479a3cd):
- Add fssm_header.db_shader_control() reading u32 at E + 0x138 (0x24C for
rec = 0xB0; 3,023/12,101 corpus PS have bit 12 DEPTH_BEFORE_SHADER set).
- Emit OpExecutionMode %main EarlyFragmentTests (opt-out --no-early-depth)
and record early_depth in shader_meta when bit 12 is set and the PS does
not export depth/stencil (no exp mrtz, DB_SHADER_CONTROL & 0x7 == 0, no
OSG1 SV_Depth*/SV_StencilRef).
3. Defensive mesh epilogue & PS helper-lane quad swizzle:
- MeshEXT and --mesh-compute epilogues explicitly write CullPrimitiveEXT =
true (1) and (0, 0, 0) when %mli < %msp and !%ms_has_prim.
- Lower quad-local ds_swizzle_b32 in PS via OpGroupNonUniformQuadBroadcast /
OpGroupNonUniformQuadSwap (GroupNonUniformQuad capability) so Vulkan 2x2
helper invocations participate on AMD RADV while EXEC-masked lanes still
read 0.
Verified: compileall, check_no_game_data.py, 6,674/6,674 semantic tests (0
failures), 200/200 corpus slice (200/200 spirv-val), plus targeted LDS MS
(5/5), LDS CS (60/60), early-depth PS (120/120), and PS quad-swizzle (50/50)
corpus slices (100% spirv-val). AI-assisted.
Emit VulkanMemoryModel NonPrivatePointer/MakePointerVisible/Available for
glc/dlc buffer ops and reads_glc_buffer metadata, specialize literal S#
samplers via OpSpecConstant, elide dead uint/sint image_read_typed paths
when float-only, replace the 77-way buffer_store_format switch with a
compact lookup table, and emit writes_buffer + buffer_write_slots metadata.
AI-assisted: Antigravity (Gemini 4 Neon).
s_load_dwordx2/4/8/16 and s_buffer_load_dwordx2/4/8/16 read their dwords as
uvec4 / uvec2 loads instead of one uint each. An s_buffer_load with a
run-time bound checks its last dword once and takes the wide loads; a load
that is partly out of range keeps the per-dword path, so out-of-range dwords
are still 0 and not read. The vectors go through a NonWritable block (SMEM
on RADV) only in modules that write no memory: with the decoration in a
module that stores, RADV ordered the load before the store and
valu_fuzz --family mem read old words in 18 of 600 programs.
Tested: tests/semantic/test_wide_scalar_load.py (new fixture),
SmemHardwareRuleTests, the translator suite, valu_fuzz --family mem on the
Radeon iGPU (600/600, wave32 and wave64), scripts/run_gpu_tests.py on the
iGPU (same results as before), a synthetic GPU program on the RX 7900 XTX
(docs/design.md row).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_dot4_i32_i8, v_dot4c_i32_i8, v_dot4_u32_u8 and v_dot4c_u32_u8 become one
OpSDot / OpUDot on the packed bytes plus OpIAdd for the addend, and
OpSDotAccSat / OpUDotAccSat under clamp (both saturate the addend plus the
exact sum, as the hardware does). op_sel halves are put together into one
dword first. RADV did not re-form v_dot4 from the old expansion (four
extracts, multiplies and adds each), which made the FidelityFX upscaler
passes ALU bound.
--integer-dot-fallback keeps the expansion for a device without
shaderIntegerDotProduct (required by Vulkan 1.3): vk_subgroup_info.py
reports integer_dot_product and make_game.py turns the flag on where it is
false. The runtime and vk_pipeline_check enable the feature where the
device has it; the interpreters of the semantic tests run the new ops.
Tested: tests/semantic/test_packed_dot4.py (new fixtures), the translator
suite, tools/dot_diff.py on the four ops, a wave32 GPU program on the
Radeon iGPU (gfx1036) and the RX 7900 XTX against the gfx1036-measured
words, RADV statistics of the upscaler passes (docs/design.md row).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A buffer_load_format_* with a run-time FORMAT called the four per-component
decode functions %fmt_dec_c0..3 at every load, whatever it wrote. One
function %fmt_dec(format, element, component) replaces them, and a load
calls it once per register it writes, with the component that register's
DST_SEL picks: _x makes one call, not four. The function computes the four
components' channel width and offset as before and the parameter selects
one, so the values are the same.
fconst (and tof of a uint constant) emitted a new OpBitcast of the uint
constant at every use; they now give one cached OpConstant %float per bit
pattern, written so spirv-as reads back the same 32 bits (float_literal:
shortest decimal for a finite value, the SPIRV-Tools hex-float spelling for
an infinity or a NaN). The test interpreters read that spelling.
Tests: test_buffer_format_decode_one.py with hand-written fixtures
(calls per load, values for 16 codes, swizzles, out of bounds, _x/_xy
against _xyzw for all 128 codes) and test_fconst_constant.py (exact bits of
+-0, denormals, infinities and NaN payloads).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lower computed v_interp_p1/p2 (I, J) pairs under --f16-interp-fallback (without --bary-fallback) without PerVertexKHR or a geometry shader by hoisting OpDPdxFine/OpDPdyFine screen-quad barycentric and attribute derivatives into uniform %entry (OpCapability DerivativeControl, guarded by an integer IEEE-754 normal determinant check) and evaluating P_0 + I*P_10 + J*P_20 per site.
Merges main at 1154976d4 into the integration branch at 273b3bdf9 (merge base ece4ba5b3). 42 files conflicted;
this commit is the resolution only. Build and test repairs follow in their own commits.
Rule of resolution: where both sides added different things, both stay; where both made the same change in two
forms, main's reviewed form stays and whatever #984's form did in addition is carried into it; where the two
changed the same code for different purposes, both purposes are kept.
Xbox proxy code (runtime/shims/d3d12_xs_device.cpp, d3d12_xs_device.h, d3d12_xs.cpp, d3d12_xs_alloc_size.h,
d3d12_xs_desc_clean.h, registry.cpp):
- d3d12_xs_device.cpp is #984's file with main's differing pieces ported in: env_slot and the configurable device
routes, XboxQueueSlotRoutes, PresentationHandler / set_presentation_handler, the console caller rule for device
slots 61 and 74 (#383, #385), route_xbox_device_slot, slot 81 as GetFrameStatisticsX, create_host_device, the
console-form rule for slots 25 and 56, the console list IID of #359, and the forms of queue slot 18 (#403) and
list slot 139 (#396).
- Kept from #984: the list proxy with handle translation, queue slots 16/17 as Signal/Wait, the fence's
completed-value mirror, the shared FrameTokenSource, PresentX through queue_present_x when no handler is
attached (slot 30, or 32 on a queue detected as the newer layout), slots 27/53/55/57/70/71/133, the wider
pc_resource_desc, S_OK for queue slots past the PC table.
- Dropped: #984's GetFrameEventsX and LEONIDA_XS_FRAME_EVENTS_SLOT, its second-word rule for slot 61, its
undetected-layout rule for queue slot 18, its list IID mapping to GraphicsCommandList6; main's copy of the base
list proxy, its null-view slot 70 and its refusing slot 133.
Proxy tests (runtime/test/xs_proxy_mock_test.cpp, device_proxy_test.cpp, queue_proxy_test.cpp):
- Checks of both sides, each run once; main's forms of the render-target size and layout checks with #984's extra
cases added; main's --env-slots-74 and #984's --env-slots-70.
- Adapted to the merged code: the queue tail answers S_OK, slot 73 answers an unknown IID with the list proxy,
the queue slot 18 case installs a console caller. Dropped: #984's slot 81 GetFrameEventsX cases.
D3D12/Vulkan layer (runtime/shims/d3d12_com.cpp, d3d12_vulkan_device.cpp, runtime/src/command_list.h,
frame_pacer.h, shader_library.h, vulkan_backend.h, vulkan_replay.h, runtime/test/command_list_test.cpp,
d3d12_close_parity_test.cpp, d3d12_execute_indirect_validation_test.cpp, replay_texture_barrier_test.cpp,
vk_pipeline_check.cpp, vk_test_device.h):
- Resource::create_texture: #984's title images (deferred placed, pending streamed, title pool) and main's
ordinary textures (#1413 shared blocks, #1364 staging fallback) are exclusive branches chosen by the texture's
origin, so both pools run on disjoint sets of textures.
- frame_pacer.h is main's pacer (#402) with #984's FrameTokenSource as the token counter.
- main's forms kept for ExecuteIndirect (#1066, #377), the barrier into LAYOUT_UNDEFINED (#1055), the B4G4R4A4
stand-in, per-face stencil masks, the unaligned tile staging (#528) and the device-lost flag (#980).
- shader_library.h: main's block inflate; #984's `bulk` parameter now defaults to true so main's callers keep it.
- Dropped: #984's B8G8R8A8 stand-in for B4G4R4A4 targets, its refusal of separate stencil masks, its zero-count
refusal in ExecuteIndirect, its wider UNDEFINED -> UNDEFINED release and the test case for it.
Other shims (runtime/shims/dstorage.cpp, file_system.cpp, gameinput.cpp, xgameruntime_offline.cpp,
runtime/test/xgameruntime_offline_test.cpp, xmem_test.cpp):
- ReadFile and DirectStorage reads: #984's pinned kernel_writes read, then main's touch_pages retry on
ERROR_NOACCESS. main's rt::fs::read_file is folded into #984's read_file.
- gameinput: main's strict LEONIDA_INPUT_SCRIPT parser with #984's rsup/rsdown entries.
- Speech synthesis: main's one silent voice and handle checks; #984's accept-anything form dropped.
Build, tools, docs (runtime/CMakeLists.txt, runtime/cmake/translator_deps.cmake, scripts/build_runtime.ps1,
make_game.py, tools/rdna2spirv.py, shader_disasm.py, shader_ir.py, shader_library.py,
runtime/test/shaders/cs_imgload_tfe.asm, cs_imgload_d16_tfe.asm, docs/README.md, boot.md, d3d12_vulkan.md,
runtime/README.md):
- Unions of the test, target and source lists; spirv_loop_guard.py added to translator_deps.cmake.
- rdna2spirv.py: main's DPP compare rule (#957), SMEM vcc base (#647) and widen_wave64_masks (#1021); #984's
restore_skipped_instructions and restore_dot4_inline_sel. #984's duplicate widen_wave64_valu_masks dropped.
- shader_disasm.py and shader_ir.py: main's structure with #984's one-line-per-dword llvm-mc input and wave flags.
- shader_library.py: main's structure with #984's --compute-hashes and per-state compute variants.
One file that did not conflict is changed here: tools/rdna2_decode.py. Git kept both sides' decoders for a VOPC
compare with a DPP operand, and #984's narrower one shadowed main's; it is main's file again.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
One squashed commit of a fork that was developed on a Linux/Proton machine and
tested on two native Windows machines. On all of them the retail 1.0.2.1
package now launches, shows its launch movie, first-run pages and landing
prompt, runs the story load to its end with the loading slideshow drawing its
artwork, and enters the world phase. A first world frame is not verified yet.
docs/linux_proton.md has the setup, a healthy boot's timeline, the machines
and where it stops.
Runtime: frames in the title's own window; DirectStorage pinned reads,
page-list scatter/gather, BCPack and unshuffle with a locally generated
predictor file; pooled, device-local and deferred image backing for streamed
and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table
that degrades instead of refusing a submission; a descriptor hash finalizer
(off until a library carries it); directly indexed heap offsets for compute
dispatches and VS/PS/GS draws; title buffer windows outside a fragmented
arena; opt-in device-local copies of streamed buffer views; write-fault
retries under the tracker lock, shared trackers and write-watched title memory
for native Windows; device-loss, compute-input and memory probes.
Translator: loop bounds at structured exits, the eight FidelityFX programs
that use a packed-dot form the disassembler skips, buffer bounds modes per
view kind, a compaction option, the hash finalizer option.
Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows
boot script, the paired compute translation script.
No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted
by people on the machines named in docs/linux_proton.md.
Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
GLSL.std.450 Sqrt and InverseSqrt rounded a double result to binary32: the translated v_sqrt_f64 of 2.0 gave
0x3ff6a09e60000000 instead of 0x3ff6a09e667f3bcd, and v_rsq_f64 likewise. OpFAdd, OpFSub and OpFDiv on binary64 raised
UnsupportedConstruct, so v_add_f64 and v_rcp_f64 could not run in this interpreter at all.
A double Sqrt is math.sqrt (correctly rounded). A double InverseSqrt is the new rsqrt_f64, rounded once from the
exact value through an integer square root: 1.0 / math.sqrt(x) rounds twice and misses by an ulp on about a quarter
of random doubles (5,219 of 20,008, checked against a 90-digit decimal; rsqrt_f64 matched all of them). Binary64
OpFAdd/OpFSub/OpFDiv follow the binary32 path's rules: a division by zero is still refused as undefined, and a NaN
made from non-NaN operands goes through ieee_nan.
tests/semantic/test_mini_interp_f64.py translates v_sqrt_f64, v_rsq_f64, v_rcp_f64 and v_add_f64 and checks the
pair against Python's binary64 operations and, for the inverse root, a 60-digit decimal reference; against main's
interpreter it gives 2 failures and 14 errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lower_addr64 rewrites the assembled module's 64-bit address arithmetic (the zero-extend, shift-by-32, OR/AND, add and
subtract with carry, narrowing, sign-extension, 64-bit bitcasts and pair compares the address idiom uses) into uint
pairs and an OpBitcast of a 2x32 vector to the PhysicalStorageBuffer pointer, and drops OpCapability Int64 when
nothing else needs it, so translated shaders run on devices without shaderInt64. --int64-addresses keeps the 64-bit
form. Semantic tests for the lowering, the interpreters learn the pair pointer form, design.md row.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
fixtures/ms_prim_export.asm (72 threads, two wave64 waves) runs as a mesh shader and with --mesh-compute: m0 = prims << 12 | verts gives the counts, the three 9-bit index fields exclude the edge flags, bit 31 sets CullPrimitiveEXT, and threads at or past a count write nothing. spirv_mini_interp learns OpSetMeshOutputsEXT, struct zero values, aggregate outputs and OpAtomicStore.
OpFNegate went through f32(), whose struct round trip sets the quiet bit of a signalling NaN before
CPython 3.14 (issue #509), so -v1 on 0x7F800001 gave 0xFFC00001 and test_float_nan_fract's
AllNaNSrc0PayloadTests failed for v_min3/v_max3/v_med3_f32 on 3.12 and 3.13, CI's 3.12 included.
IEEE 754 negate only flips the sign bit, so the interpreter does that for binary32; binary64 is
unchanged.
Claude-Session: https://claude.ai/code/session_013GadNheKKmV2dMw6NR5TUu
Co-authored-by: Adm1H <322105863+Adm1H@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Squash-merged after diff review of PR #6898 - rdna2spirv: a wave32 pixel shader reads its descriptor index from a running lane of its half, not lane 0 (SHADER-1016, the #4225 RDNA1 regression)
Every invocation of run_workgroup had its own zero-initialised Workgroup
variables, so no CPU test could check lanes communicating through LDS or
racing on an LDS dword, and OpControlBarrier was refused. The Workgroup boxes
are now the workgroup's (created by the first invocation, shared by the
rest), and OpControlBarrier is a point every invocation must reach together,
as a subgroup operation is. run_fragment still refuses it
(test_barrier_control pins that).
tests/semantic/test_interp_shared_lds.py: one lane writes and all read after
s_barrier (one and two waves), lanes racing with ds_add_u32 and its
returned values, the ds_add_f32 CAS loop on shared LDS, separate workgroups,
and a barrier only one invocation reaches.
run_workgroup runs one generator per invocation over the same SPIR-V text, and each one split and regex-matched every line again. The parsed lines are now cached by text (a line that does not parse still raises where it is reached). test_saveexec_b64 40.9 s -> 24.5 s, test_wave64_scmp_masks 38.2 s -> 19.9 s; the 366 semantic test files give the same results.
The measured words pinned in the semantic tests use 0xFFC00000 for a NaN made
from non-NaN operands (inf - inf, 0 * inf). The interpreter left that sign to
the host CPU, so 30 rows in test_alu_vop3_mods_hw and test_alu_sdwa_hw failed
on ARM64 (Apple Silicon), where the host gives 0x7FC00000. ieee_nan() makes the
sign explicit for OpFAdd, OpFSub, OpFMul and fma_f32. x86-64 results are
unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
buffer_load_format with a run-time V# format picked the element size twice per load through a select chain over
all of FORMATS (dwords spanned, and the bounds-check size): about 150 of the ~390 instructions a load cost. The sizes
are now one Private constant array, %fmt_size_tab (128 entries, 0 for a code FORMATS does not decode), read once
per use; a tbuffer's fixed format still folds at translate time. Same results: an unknown format loads one dword
and bounds-checks 4 bytes, as before.
indirect_diffuse_lighting's ScreenProbes_ActivateProbes (3,281 such loads, the module NVIDIA's compiler failed on):
52.4 MB / 2.50 M ids -> 29.8 MB / 1.43 M ids under --wave64-emulate, 43.8 -> 29.4 MB native; passes spirv-val.
spirv_mini_interp reads OpConstantComposite and Private variables so the semantic tests run through the table.
Typed-buffer, image and d16 tests (383), the shader checks and both GPU suites (164/210, 195/210 W64) pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both interpreters accept OpTypeInt 64 but treated a 64-bit operand of
OpBitCount, SMin, SMax, SClamp, SAbs, FindILsb, FindUMsb and FindSMsb as
32-bit: OpBitCount of 0xFFFFFFFF00000000 gave 0, and SMin(2^31, 1) on a
64-bit type gave 2^31.
OpBitCount now counts every bit of its operand's type, and SMin, SMax,
SClamp and SAbs read their operands as signed at the width of their type.
FindILsb, FindUMsb and FindSMsb raise UnsupportedConstruct for a type that
is not 32-bit, since GLSL.std.450 limits them to 32-bit components. Results
for 32-bit types are unchanged.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
spirv_mini_interp.py evaluated the OpPhi of a block one after another and
wrote each result at once, so a later OpPhi that names an earlier one of the
same block read its new value. A loop header that swaps two values
(%a = OpPhi ... %b %cont, %b = OpPhi ... %a %cont) gave (2, 2) after three
iterations from (1, 2); SPIR-V and spirv_wave_interp.py give (2, 1). The
first OpPhi of a block now evaluates the whole run against the values from
before the block, and each one then takes its own.
The module docstring and the README's Limits said backward branches, loops
and calls are rejected; the interpreter runs them (10000 backward branches
at most), and only rejects switches.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
struct's '<e' drops NaN payloads before 3.14 and keeps them from 3.14
(CPython gh-130317), so spirv_mini_interp's half_to_float/float_to_half
returned version-dependent words while CI (3.12) pins the pre-3.14
canonical-quiet results. Convert both helpers bit-level with the pinned
rule (a NaN keeps its sign, payload dropped to the canonical quiet NaN)
and add direct regression tests; RNE rounding, subnormals and overflow
are unchanged, so no expected word moves on any Python.