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>
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>
root_sig_test only exercised the high byte clearing for 1.0 and 1.1. Add the
1.2 case (Desc_1_2 is D3D12_ROOT_SIGNATURE_DESC2, whose static samplers are
D3D12_STATIC_SAMPLER_DESC1) so the shim's 1.2 path is covered, and extend
test_registered_shim to prove the registered d3d12_xs serializer clears the
byte for 1.2 end-to-end.
AI-assisted (Cline).
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>
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>
The d3d12_xs root-signature shim cleared bits 24-31 of
D3D12_ROOT_SIGNATURE_FLAGS for 1.0 and 1.1 but forwarded 1.2 unchanged, so a
1.2 descriptor with the Xbox high flag byte would reach the PC serializer and
fail. Add the 1.2 case with the same clear_high_byte treatment.
d3d12_xs_root_signature_test gains test_version_1_2: it serializes a 1.2
signature with a descriptor table and the IA-input-layout flag, checks the
versioned reflection, compares legacy deserialization against Windows, and
creates the signature on WARP when the feature level allows.
AI-assisted (Cline).
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.
On Windows with Trend Micro Maximum Security (Defender and Smart App Control
off), images the test writes to %TEMP% can be written but not opened for a
while: each takes 50-800 ms, the first case failed, the truncation case
stalled for about ten minutes, and an uncaught write error then ended the
process with 0xc0000409. Held images from one run also made the next fail.
- Each run writes to leonida_loader_test\<process id>, so the previous run's
held images cannot collide; LEONIDA_TEST_DIR picks the parent folder.
- A start-up check writes and reads back 8 images and stops with the reason
and the folder to exclude if one is refused or they average over 25 ms.
- A failed write ends the run as one FAIL instead of std::terminate.
- A run folder that cannot be removed is reported as a note.
The loader and its 48 checks are unchanged. ctest 15/15 on Windows 11 with
the antivirus active. AI-assisted (Claude Code).
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>
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>
vk_sampler_test binds a 128x128 two-level texture with the VkSampler from
vulkan_sampler(decode(S#)) and the view range from decode(T#). ps_ssharp
samples it with image_sample_lz and image_sample. check.py judges eight
S#/T# cases per pixel against levels worked out from the S# and T# bits.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep the cube array at its original extent and allocate a separate upload range for the two-dimensional mip chain. Both shader registrations now run through the updated upstream runner.
A literal S# mode emits only its own wrap/mirror/mirror-once code (no dead
chains); a run-time S# still selects among all four. The S# value mapping now
cites Mesa gfx6.json and RADV radv_tex_wrap. FORCE_UNNORMALIZED on a run-time
S# is not applied (not confirmed on hardware, so not guessed): documented as
the second remaining approximation. Tests cover all 16 literal x/y mode pairs
with per-axis op counts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gta6rt --run <exe> [-- args] maps and binds the executable, initialises its
modules and calls its entry point on a game thread. shims/process.cpp answers
the process-level imports through the game's own import table: argv/argc and
GetCommandLine are the game's (UCRT api-set/ucrtbase and msvcrt forms), and
exit/_exit/quick_exit/ExitProcess/abort end the run with that exit code
instead of the host. gta6rt then exits with the game's code directly, so the
game's atexit handlers don't run during host shutdown.
tiny_game.exe (CTest run_tiny_game, run_tiny_game_exit_code) does what a title
does in its first second: arguments, a static initializer, a 4 MiB allocation,
a file round trip, a thread, and xgameruntime.dll imports, which the shim
registry answers instead of the link-time stub. thread_local and a C++
exception are opt-in (LEONIDA_RUN_TLS / LEONIDA_RUN_EH) until #93 and #176.
s_wqm on EXEC/VCC/an SGPR mask is no longer the identity: the lane ORs its
bit with its quad's (two OpGroupNonUniformQuadSwap, or four x_buf reads under
--wave64-emulate), SCC is the wave-wide any. Data operands compute the quad
bits directly. GPU tests cs_wqm_w64, cs_wqm_w32, ps_wqm; design.md row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D3D12 lets an access be named with a sync scope whose Vulkan stages cannot perform it:
SYNC_ALL_SHADING with ACCESS_VERTEX_BUFFER is valid D3D12, but VERTEX_ATTRIBUTE_READ needs
VERTEX_ATTRIBUTE_INPUT. Vulkan rejects such barriers (docs/d3d12_vulkan.md listed it as a known gap).
vulkan_barrier_scope maps each side of a global, buffer or texture barrier and adds the narrowest
stage that supports any access left without one (the synchronization2 "supported access types"
table). The access is never dropped, so the dependency still covers everything the application
named. CLEAR only writes, and ALL_GRAPHICS holds no transfer stage, so transfer reads get ALL_TRANSFER.
vk_command_replay_test part D records all 360 D3D12 sync/access pairs as global, buffer and texture
barriers: 462 validation errors before, 0 after, on Intel(R) Graphics. d3d12_state_map_test checks
that stages only grow, accesses never change, and pairs Vulkan already accepts are left alone.
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>