Commit Graph

5744 Commits

Author SHA1 Message Date
f5b444a826 Merge pull request #323 from Ayinaki 2026-11-21 18:37:54 -05:00
82da63479f Merge pull request #322 from Koert Lichtendonk 2026-11-21 18:37:54 -05:00
ea1d34dc61 Docs: the images row covers d16 compare results 2026-11-21 19:33:39 -04:00
6ae02af006 Merge main into d3d-25-uav-clears
Conflicts: main moved texture create info into texture_create_info (the UAV
attachment usage now goes there, so placed-resource sizing agrees) and edited
the same docs paragraphs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:33:19 +00:00
fe12da7edd D3D-35: implement ExecuteBundle IR inlining and validation 2026-11-22 00:32:28 +01:00
5df3d01a5a Merge commit 'd937b7f092dbc188b59754e5c73c1a9dac553cf9' into codex/med3-result-modifiers
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
2026-11-21 16:29:40 -07:00
467b1d1ff9 runtime: ClearUnorderedAccessViewUint/Float on the Vulkan device (D3D-25)
The CPU handle's slot is read while recording as the GFX10 T#/V# a shader
would load (docs section 3.4), so the clear works with whichever view
creation lands (#157, #328, #334) and with game-built descriptors.

- Buffers: vkCmdFillBuffer for elements up to 4 bytes, with the unaligned
  ends copied from the filled middle; 8/16-byte elements are written with
  vkCmdUpdateBuffer and doubled with copies. Rects are element ranges.
- Textures: vkCmdClearColorImage for whole views, vkCmdClearAttachments
  for rects (UAV textures also get COLOR_ATTACHMENT usage when the format
  supports it), in place in GENERAL; mip and layer range from the T#.
- Values follow D3D's Uint (raw low bits) and Float (converting) rules,
  encoded in the view's format and cleared into the image as the value
  that decodes those bytes in the image's own format (typeless resources).
- d3d12_uav_clear_test: hand-computed conversion checks, then raw,
  structured and typed buffers and 2D, array and volume textures cleared
  and read back through D3D12; refusals at record and replay.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:29:32 +00:00
993a2cbf72 Runtime: install static TLS for mapped images 2026-11-21 23:29:24 +00:00
85a4e7b2a7 Translator: v_subrev_f16 (S1 - S0 on the selected halves)
v_subrev_f16 (VOP2 0x34 on GFX10) raised Unsupported. Translate it with the
other f16 VOP2/VOP3 ops, swapping the two operands of the subtraction: op_sel
still names src0/src1 and the destination half, neg/abs/clamp apply as for
v_sub_f16, and the half that is not written is kept.

Tests: tests/semantic/test_alu_subrev_f16.py (VOP2 and VOP3 forms, every
op_sel combination, neg and clamp, and a seeded comparison with v_sub_f16 on
swapped operands), plus v_subrev_f16 rows in the f16 op_sel tables.
2026-11-21 20:28:24 -03:00
438e144270 Runtime: build with MSVC; the descriptor test shows a missed sampler lookup
Two findings from the review of #328, on MSVC 19.44 and an RTX 5080.

- bind_image did not compile with MSVC (C2397): the view's aspect, picked
  between two VkImageAspectFlagBits values, went into a VkImageAspectFlags
  field in braces. MSVC's enums are ints, so that is a narrowing
  conversion there; GCC and clang give the enum an unsigned type and accept
  it. The value is cast now.
- d3d12_descriptor_test passed with the sampler index forced to 0, because
  its point, clamping sampler and the fallback sampler read the same
  texels. The test's sampler now wraps in U and the shader samples one
  tile to the right: the right sampler gives the texture, the fallback its
  right edge. With the index forced to 0 the test fails (texel 0 reads
  224, 0, 135, 255 instead of 0, 0, 128, 255).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 18:28:13 -05:00
bc14565c45 Runtime: texture views and samplers go into the bindless set (M2, the device's part)
The device now keeps set 0 of the translated shaders and puts into it what
views and samplers name. No pipeline binds the set yet: that comes with
the compute path. Until then rt::d3d12::bindless_set / bindless_set_layout
hand it out.

- Device: CreateShaderResourceView and CreateUnorderedAccessView of
  textures write a T# into the slot, CreateSampler an S#
  (gfx10_descriptors.h); each makes sure set 0 has the view or sampler and
  the hash table has the key. The key is the descriptor's bytes, so a
  copied descriptor needs nothing more. A view that cannot be shown (a
  volume, a multisampled texture, the stencil plane, a range past the
  texture) leaves a null descriptor, which finds the fallback. A texture
  is named by an address of its own above 4 GiB that nothing dereferences;
  its keys are erased and its indices freed when it is destroyed.
- VulkanDeviceInfo::bindless says the Vulkan device has the features; the
  standalone device and the test helper enable them where the GPU has
  them, with samplerAnisotropy and samplerMirrorClampToEdge.
- Every ExecuteCommandLists flushes the set before its commands are
  written (VulkanContext::set_bindless_prepare).
- Layouts: a bindless descriptor has one image layout, but D3D12 samples a
  texture both in a shader-resource state and while promoted from COMMON
  (GENERAL here). With the set, a texture's shader-resource states use
  GENERAL too (ResourceBinding::sampled_in_general). This follows from the
  Vulkan rule for descriptor layouts; no test can see it broken, since the
  validation layer does not follow dynamic indices into runtime arrays.

Not done, and listed in docs/d3d12_vulkan.md: buffer and constant-buffer
views, 1D/3D/multisampled and stencil views, descriptors the game writes
itself, static samplers and shaders' literal S#s, and holding back a flush
that moves table entries while earlier command lists still run.

Test: d3d12_descriptor_test, through the Xbox-ABI proxy. It decodes what
the slots hold (a view of an uploaded 8x8 texture, a sampler, a BGRA cube
view with a component mapping, an unordered-access view, null
descriptors). Then a compute shader (test/glsl/cs_sample.comp, compiled
with glslangValidator where it is found) is handed a slot's T# and the
sampler's S#, looks them up in the hash table as a translated shader does
and samples; the test creates that pipeline in Vulkan and binds the
device's set. It reads the texture through the view's own slot and
through a copy of it, and gets the fallback from a slot of bytes no view
was made for and, once the texture is destroyed, from the view's own
bytes. Without the table insert, or without the removal at destruction,
the test fails. The test no longer compiles d3d12_xs_device.cpp itself:
the COM library has it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 18:28:13 -05:00
ed6da6b699 FUZZ-3: float VALU differential fuzzer; v_mac_f32 unfused, conversion output modifiers
tools/f32_fuzz.py runs seeded VOP1/VOP2/VOP3 float programs (neg/abs, clamp,
omod) through an exact-arithmetic RDNA2 model and through the translated
SPIR-V in tests/semantic's interpreter, and compares them bit-exact.
Denormals, and inputs the emitted SPIR-V leaves undefined, are counted
separately instead of being compared.

Translator fixes it found:
- v_mac_f32 is the VOP2 form of v_mad_f32 (product rounded before the add),
  not of v_fma_f32 (LLVM getNewFMAInst: V_MAC_F32 -> V_MAD_F32_e64). It
  emitted Fma.
- VOP3 clamp and mul:2/mul:4/div:2 were dropped on v_cvt_f32_i32/u32,
  v_cvt_f32_ubyte0..3, v_cvt_f32_f16 and v_rcp_iflag_f32 (LLVM
  VOPProfileI2F: $src0, $clamp, $omod).

Interpreter: RoundEven keeps the sign of a zero result; Fma rounds once
(it double-rounded through a double); adds OpFDiv, OpIsNan, OpIsInf,
Floor/Ceil/Trunc/Exp2/Log2/Sqrt/InverseSqrt, raising where SPIR-V or
GLSL.std.450 leave the result undefined.

Pinned by runtime/test/shaders/ps_f32_mods.asm (check.py, run_gpu_tests.py,
tests/semantic/test_f32_valu.py) and tests/test_f32_fuzz.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:26:30 +01:00
fbffbce383 Runtime: preserve explicit RGBA8 typeless RTV formats for clears 2026-11-21 19:26:08 -04:00
682ba4aa32 Merge branch 'main' into fix/f64-conversion-output-modifiers 2026-11-22 00:25:53 +01:00
49cd093d84 Docs: record the multiply-add literal rule in the contract table 2026-11-21 19:24:48 -04:00
3a9e32ee1c Address packed buffer-store atomics through a dword array element 2026-11-21 16:23:36 -07:00
2a122c7cbc Cite BVH4 header source and report version field 2026-11-21 23:21:07 +00:00
fc7a3d9ca7 FUZZ-4: scalar ALU differential fuzzer; s_ff0_i32_b32 on a constant
tools/salu_diff.py runs seeded SOP1/SOP2/SOPC/SOPK programs through its
own reference and through the translator plus spirv_mini_interp, and
compares three SGPRs and SCC. It found that s_ff0_i32_b32 read a 32-bit
constant source as a lane mask; constants are now values, as for
s_bcnt*_b32. GPU-checked with ps_salu_ff.asm.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:21:00 +01:00
b225beea11 Document f64 conversion output modifiers 2026-11-22 00:19:42 +01:00
19742b531a Runtime: DiscardResource, WriteBufferImmediate and atomic copies on Vulkan (D3D-26)
Three command-list IR commands, recorded through COM and replayed by
vulkan_replay.h:

- DiscardResource: an oldLayout = UNDEFINED barrier to the layout the
  tracker already has for each subresource. Buffers, rectangle discards,
  parts never used yet, untracked replays and one plane of a combined
  depth-stencil without separate layouts are no-ops.
- WriteBufferImmediate: a 4-byte vkCmdUpdateBuffer at the address,
  resolved at execution through ResourceBinding::va / buffer_offset and
  ReplayFunctions::buffer_at (the same fields and lookup as #291).
  MARKER_OUT waits for and sees every earlier write; MARKER_IN gets an
  execution-only ALL_COMMANDS dependency (Vulkan cannot say "started");
  DEFAULT is ordered by the application's barriers.
- AtomicCopyBufferUINT/UINT64: one vkCmdCopyBuffer region after a
  barrier that covers every earlier write, the dependent resources'
  included. Recording follows the debug layer's ATOMICCOPYBUFFER_* and
  WRITEBUFFERIMMEDIATE_* rules.

Tests: command_list_test (recording rules), vk_command_replay_test part D
(GPU readback of writes in all three modes, ordered atomic copies,
discards, and the lists that must be refused), and the COM path in
d3d12_vulkan_device_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:16:54 +00:00
71646d8507 Docs: correct stale status and duplicated mesh notes
shader_validation.md now describes the shipped CPU differential oracle in tools/shader_diff.py instead of saying it is not implemented, and keeps the GPU runner explicitly as future work. design.md drops a duplicated, contradictory mesh workgroup paragraph. pipeline_check.md records the later full 26,503/26,503 corpus run with 0 failures instead of presenting the two stalled shards as the final state.

New PROC item claimed in #156. AI-assisted (OpenCode).
2026-11-21 17:14:16 -06:00
3eb5ad9892 docs: drop the open-question rows the #284 merge duplicated again
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 18:14:04 -05:00
4fe8cdf38d Tools: LDS / ds_* differential fuzzer on the GPU (FUZZ-6)
tools/lds_fuzz.py generates seeded 64-thread compute programs (wave64 or wave32, 4 KiB LDS) over the ds_*
instructions the translator accepts: every read width (also u16 d16/d16_hi), byte/short writes (also d16_hi),
read2/write2 (+st64), the add/sub/min/max/and/or/xor atomics with and without return, wrxchg, cmpst, ds_swizzle
and ds_bpermute, under random EXEC masks. It translates them, runs them with vk_compute_test and compares every
thread's 16 result VGPRs and the whole LDS bit for bit with a model written from the ISA, naming the op that last
wrote a wrong register. vk_compute_test gets VKC_OUT_WORDS / VKC_DUMP to read the whole buffer back.

On an RX 6700 XT the only mismatch is the wave32 ds_bpermute inactive-source case #253 fixes. docs/design.md no
longer claims the 8-bit d16 reads, which the translator rejects.
2026-11-22 01:13:21 +02:00
e0d68c8bb2 Docs: link the coordination issue by its title, not its number
The coordination issue (#156) will move to a successor when its thread
gets long. CONTRIBUTING.md, AGENTS.md, the PR template and the testing
guide now find it as the open issue titled "Coordinating who works on
what" (a search link, and a gh command for agents), so they stay right
without an edit each time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:11:59 +01:00
5b8dd6854b Tools: index named RPF9 resources without the TOC 2026-11-21 23:11:56 +00:00
a94e30d3a9 Docs: record the full-archive model validation 2026-11-21 23:10:55 +00:00
dbc785f9e5 Merge pull request #332 from fearkov
# Conflicts:
#	tests/semantic/regen_fixtures.py
2026-11-21 18:09:52 -05:00
697625209a Apply output modifiers to v_med3_f32 results 2026-11-21 16:09:40 -07:00
273e53c8fc Merge pull request #300 from FreddyxS
# Conflicts:
#	tests/semantic/regen_fixtures.py
2026-11-21 18:09:14 -05:00
401b824937 Save files: document JSAV/ASAV/SLAYER1 and add tools/saves.py
docs/saves.md records the measured layout of the game's save containers:
JSAV v3 (20-byte index + one JSON document of CodeSaveBlocks/ScriptSaveBlocks,
rebuilt byte-for-byte), the ASAV header (checksum at 0x160 still unknown) and
the SLAYER1 wrapper, whose packed body is noted and not decoded.

tools/saves.py (stdlib only): info, extract, pack, verify, diff, and import
into the offline XGameSave folder layout of xgameruntime_services.cpp (#279)
with the same %-encoding. tests/test_saves.py covers it on synthetic files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:08:41 +00:00
03ff5f4bd8 Merge pull request #338 from mrb-eel 2026-11-21 18:08:03 -05:00
2f076083fe Merge pull request #327 from Parakeet-Wheat 2026-11-21 18:08:00 -05:00
b98068ea7c Merge pull request #318 from 73N1X 2026-11-21 18:08:00 -05:00
099a5c8848 Merge pull request #309 from Luis Baker 2026-11-21 18:08:00 -05:00
68ade67da9 Merge pull request #324 from Luis Baker 2026-11-21 18:07:59 -05:00
6eb245f59d Merge pull request #284 from S1m0ne1997
# Conflicts:
#	docs/d3d12_vulkan.md
#	tools/feature_scan.py
2026-11-21 18:07:59 -05:00
7761916406 Merge pull request #303 from mrb-eel 2026-11-21 18:07:42 -05:00
77fb672cf2 Merge pull request #312 from Tim Elery
# Conflicts:
#	docs/textures.md
2026-11-21 18:07:40 -05:00
1d2e9cc5ae Merge pull request #323 from Ayinaki 2026-11-21 18:07:37 -05:00
93953ebd75 Merge pull request #320 from Rayhan Robin 2026-11-21 18:07:37 -05:00
17072e2237 Merge pull request #322 from Koert Lichtendonk 2026-11-21 18:07:36 -05:00
a42b1990da Merge pull request #311 from Kam471 2026-11-21 18:07:35 -05:00
abefe80779 Merge origin/main into shader-34-wqm; WQM review fixes
- vs/gs/ms: no OpGroupNonUniformQuadSwap (only guaranteed in fragment and
  compute); shuffle from the quad's four lanes there.
- 32-bit forms in wave64 write only their own half of EXEC/VCC and vote SCC
  over that half; mask_src accepts exec_hi. New GPU test cs_wqm_w64_half.
- cs_wqm_w32: read SCC right after s_wqm.
- test_wqm_on_data checks the real constants and shifts; new vs and half tests.
- docs: narrowed claims (SCC vote needs 64-wide or emulation, lane
  assumptions, partial quads, helper invocations untested).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:06:34 +01:00
489258fda5 Resolve colour MSAA regions into destination offsets 2026-11-22 00:05:17 +01:00
1718e02155 Merge origin/main into shader-36-gather-wrap
Keep both sides: main's ps_vcc_x2 / ps_tex / bindless and irreducible-CFG tests
next to ps_gather_wrap, main's buffer-format-store row next to the updated
gather row, and both the literal-SGPR table and #298's mask tokens in store_reg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:01:57 +01:00
1186f99340 Merge updated Leonida GPU runner into class compare fix 2026-11-21 23:57:44 +01:00
437081fdb6 Runtime: parse version 1.2 root signatures, and read RTS0 table ranges from their offset
parse_rts0 refused D3D_ROOT_SIGNATURE_VERSION_1_2 blobs. 1.2 is 1.1 plus
D3D12_STATIC_SAMPLER_DESC1::Flags: the PC serializer writes RTS0 version 3 with
14-dword static samplers (13 before). The model gains Version::V1_2 and
StaticSampler::flags. The canonical codec writes the flags only for 1.2, so 1.0/1.1
encodings are byte-for-byte unchanged.

Checking it against the real serializer found an older bug: a descriptor table's
payload is {num_ranges, ranges_offset} with the ranges at that offset, but the
parser read them inline after the count. Every table came back with a wrong range
type and count. The oracle test only covered constants and a CBV, so it never saw it.

root_signature_oracle_test now serializes 1.0, 1.1 and 1.2 signatures with a
two-range table, a root SRV and two static samplers (1.2 with a UINT border colour,
then non-normalized coordinates). Every sampler field, the ranges and the canonical
round trip must match. root_signature_test adds hand-built 1.2 and table payloads
and their truncation controls.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:57:07 +01:00
5560ac86ce Merge origin/main into bpermute-wave32
Resolve the conflicts with the GPU test lists and counts (#203, #212, #218,
#222, #235, #246, #219, #298, #230), and keep main's partial-wave rule for
ds_bpermute_b32 in wave64. The wave32 path gets the same ballot, so a
source lane that isn't running reads 0 there too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:56:56 +01:00
eb629d41a8 Decode BVH4 header and node pointer fields
The indexer treated the pre-header wrapper words as the root and labelled the real header fields as counts. Parse the documented XboxBvh4Header fields, decode root node pointers, and document the runtime node and leaf layouts while keeping the dehydrated packed stream open.
2026-11-21 22:55:52 +00:00
257e3856cc Runtime: GetResourceAllocationInfo on the Vulkan device (D3D-23)
GetResourceAllocationInfo, GetResourceAllocationInfo1 and
GetResourceAllocationInfo2 were generated stubs. Buffers take their width
rounded up to 64 KiB. A texture's size is what its VkImage needs
(vkGetDeviceImageMemoryRequirements, or a throwaway image without it),
rounded up to its D3D12 alignment: 64 KiB, 4 MiB with MSAA, or the small
alignment the description asks for. A 4 KiB request that doesn't qualify
is invalid, as on the PC runtime; the MSAA 64 KiB one has no size limit
there. Texture creation and these queries share one VkImageCreateInfo.

d3d12_vulkan_device_test compares buffer sizes, alignments and invalid
descriptions with the host PC runtime, and checks the per-resource layout
of the Device4/Device8 variants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:55:11 +11:00