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>
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>
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.
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>
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>
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>
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>
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>
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).
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.
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>
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>
- 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>
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>
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>
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>
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.
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>