Dispatch ran the whole queue whatever quota it was given. It now runs
queued events oldest first, at least one per call (a quota of 0 runs
exactly one, as the GDK documents), takes no further event once the
quota has passed, and returns whether events remain. While events
remain the wait handle is signalled again, so a title that waits on it
before each call comes back for the rest.
The automatic path (no dispatcher, poll thread) still delivers the
whole queue. gameinput_test checks Dispatch(0), a 1 ms quota against a
5 ms callback, a large quota draining the queue, and an empty queue.
Integer volume texels require matching sampled image types. Route the explicit mip through the shared typed fetch so sparse masks and D16 narrowing also preserve the intended channel values.
tools/interp_hw_probe.py runs v_interp_* in a compute wave through tools/hw_oracle (the ops read the
attribute words from LDS at M0) and checks them against exact models: p1/p2_f32 and p1ll_f16 are single
fmas rounded to f32, p2_f16 rounds once straight to f16 (30 discriminating ties), and a 32-bit read of a
packed channel takes the raw words as f32. f32 denormal words follow MODE. All 292,474 checks match per
mode on a Radeon gfx1036 iGPU.
v_interp_p2_f16 keeps the high 16 bits of vdst on hardware; the translator zeroed them. It now writes
the low half only (write_lo16), with a semantic test that fails on the old code.
The SPI half (what a real draw writes into LDS for a packed channel) stays unverified; it needs a
pixel-shader harness.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IGameInputDevice answered the force-feedback and haptic half of the API with
nothing: no motors in GameInputDeviceInfo, E_INVALIDARG from
CreateForceFeedbackEffect, false from IsForceFeedbackMotorPoweredOn, a no-op
SetForceFeedbackMotorGain and E_INVALIDARG from SetHapticMotorState. A pad SDL
opens as a haptic device now reports one force-feedback motor with the effect
kinds SDL lists, and a pad with trigger motors reports two haptic motors.
Force feedback goes to SDL_CreateHapticEffect/RunHapticEffect on the poll
thread, so title calls still never touch SDL; the eleven GameInput effect kinds
are SDL's eleven force-feedback effects. The trigger haptic motors play their
one waveform as an intensity on the existing trigger output. A pad with neither
keeps the old answers, and LEONIDA_RUMBLE=0 silences both. gameinput_test drives
all of it through a fake haptic backend, because SDL's virtual joysticks report
no haptics.
AI-assisted.
d3d12_private_data_test runs the same 672 GetPrivateData / SetPrivateData /
SetPrivateDataInterface / SetName steps on the device, a fence, a buffer, a
command allocator and a descriptor heap of the Vulkan-backed device and of the
host runtime, and compares every HRESULT, returned size, byte and reference
count. On main 130 of them differed (RTX 3060, driver 610.88), the same four
rules on every object:
- SetPrivateData with null data removes the entry whatever the size: S_OK
when there was one, S_FALSE when there wasn't. The layer answered
E_INVALIDARG for a nonzero size and kept the entry, and S_OK for a missing
one.
- Zero bytes with data keep an empty entry (size 0); the layer removed it.
- SetPrivateDataInterface(null) releases the interface and keeps a
pointer-sized entry that reads back as null; the layer removed it.
- SetName is not readable through GetPrivateData: the host sets neither
WKPDID_D3DDebugObjectNameW nor the narrow key. The layer stored the name
there; it now keeps it apart (debug_name()).
SetName(nullptr) faults in the host runtime; the layer still clears the name,
and the test reports those 5 steps as not compared.
d3d12_debug_markers_test's private-data checks expected the old answers and
now expect the host's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two pixel tests, ps_vcmp_f16 (e32, VCC) and ps_vcmp_f16_e64 (SGPR destination,
swapped operands), with NaN, +-0, +-inf, f16 denormals and junk high halves.
Words derived by hand in the headers; semantic fixture and test added.
AI-assisted.
- corpus: make_game.py writes <work>/shaders/dxbc and <work>/shaders/spirv; the tool
looked for <work>/dxbc and <work>/spirv and found nothing on a real work folder. The
shaders folder itself is accepted too. The test now builds that layout.
- GPU tests: --gpu-log <file>[=<GPU, driver, OS>] reads the saved output of
runtime/test/shaders/check.py, one group per GPU. ok is a pass, SKIP is not counted,
anything else is a failure with its one-line detail; a log older than the last commit
touching runtime/test/shaders or tools/rdna2spirv.py counts as needing a re-run.
Result lines are told from the other lines check.py prints by its {name:20} column.
Checked on a real work folder: 26,501 of 26,503 carved shaders pass spirv-val, and none
of the 26,503 shader names appears in the page or the JSON.
story_index gave any stream starting with a u32 of 2 or 3 and the bytes
01 01 00 00 the historical clip-stream signature, reported the count as a
version and called it a 24-byte header, even when only the eight-byte
prefix was present.
Reuse anim_index.aux_table from #2496 (u32 count 2 or 3, count
{u32 tag, u32 payloadBytes} pairs with first tag 0x101, every payload
inside the stream) and report the same record as anim_index: signature
clip-stream, count = entry count, no version, detail with the tags and
payload end. Streams that fail the check fall through to the generic
zero-prefix/text/raw handling. The tool still runs with python -I; the
other classes and the scan, directory and output paths are unchanged.
Synthetic tests cover the record, parity with anim_index, exact fit,
trailing bytes, payload overrun and oversized sizes, the bare and
truncated old prefix, wrong counts or first tags, and an archive scan.
Claim: https://github.com/ItsNotRexed/Leonida/issues/2300#issuecomment-7082717677
Depends on: #2496
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
audio_config hashed the lowercased UTF-8 bytes, and world_names encoded to UTF-8
before lower-casing the bytes, so both gave a different 32-bit hash for any
non-ASCII name than hashdict.py and awc_names.py, which hash the lowercased
latin-1 bytes that tests/test_hashdict.py pins. A title with an accent then
produced a stream id no AWC bank stores. Both copies now use the dictionary
form, and a cross-tool test holds every joaat copy in tools/ to it.
RDNA2 lighting and geometry programs can convert an integer to a double without losing low bits. Emit the conversion at binary64 precision and use the same scaled, masked VGPR-pair writes as double addition.
A separate exact-rational ISA model for v_fract_f32, v_frexp_mant/exp_f32, v_ldexp_f32, v_cvt_u32/i32_f32, v_cvt_off_f32_i4, v_fmamk_f32, the 16 v_cmp_*_f32 conditions and v_cmp_class_f32, with neg/abs, omod and clamp and every source kind within the constant-bus rules, compared one lane at a time with rdna2spirv run in tests/semantic/spirv_mini_interp.py, optionally with the hardware through tools/hw_oracle (run under IEEE off, f32 denormals flushed). Denormals, NaN payloads read as integers, clamp of a NaN and omod giving a zero are counted skips. v_cmp_class_f32 with neg/abs on a signalling NaN only with --known.
AI-assisted.
Update docs/embedded_shaders.md §4 and §5 and related references in
docs/d3d12_vulkan.md to reflect current main: 51 of 52 XboxBvhBuilder.dll
compute shaders now translate and pass spirv-val since #1871
(GFX10_FORMAT_8_UINT) and #1968 (427c1376: global_atomic_fmax/fmin and
buffer_load_ushort) landed.
Only Box16Rehydration remains blocked, awaiting buffer_store_short (#1864).
Claim: https://github.com/ItsNotRexed/Leonida/issues/2300#issuecomment-7082579530
These forms were refused. Measured on RDNA2 (gfx1036, raw kernels through
tools/hw_oracle, wave32 and wave64): op_sel bit 2 adds S2[31:16]
zero-extended (in the i16 op too), op_sel bit 3 writes the result shifted
left by 16, and clamp saturates the sum to u32 / i32 before that shift.
GPU test ps_valu16_mad_sel (4096/4096 on RTX 5080 and the gfx1036 iGPU), the
same shader as a semantic fixture, test_alu_mad_32_16 checks the measured
rule instead of the refusal, and a docs/design.md row (EGEN-HW-MAD-U32-U16).
AI-assisted.
A native readfirstlane is a ballot of the EXEC lanes, its lowest set bit
and a shuffle from that lane. MoltenVK lowers OpGroupNonUniformBallotFindLSB,
like the SubgroupSize built-in, to Metal's threads_per_simdgroup input,
which a vertex function can't declare, so every VS with a readfirstlane
failed to compile on Apple GPUs.
In a vertex shader the lowest bit is now taken with FindILsb over the
ballot's four words, the form the --wave64-emulate path already uses on
its mask words. It gives the same lane, since a ballot has no bit at or
above the subgroup size. Other stages keep BallotFindLSB.
On an Apple M4 (MoltenVK 1.4.2), with the 1.0.2.1 corpus translated from
4eb6155d: exactly the 572 VS that contain v_readfirstlane_b32 change, and
all 2,236 stay spirv-val-valid. VS pipelines go from 667 to 672 on main,
and from 1,662 to 2,233 of 2,236 with #1784's --no-vertex-subgroups.
tests/semantic/test_vs_readfirstlane.py runs it on the wave interpreter,
with the first EXEC lane in word 0 and word 1 of the ballot.
AI-assisted.
Merges after 4eb6155d repeated 16 more topics in design.md (DPP, EXEC,
Control flow, 32-bit global atomics, 2D array resource dimensions,
v_pack_b32_f16, Multiply-add and output modifiers, Float min/max/med3,
Wave64 handling, ds_cmpst_b32, the 16-bit frexp/ldexp and min3/max3/med3
rows, v_cvt_flr/rpi, buffer_atomic_*_x2, wave64 partition invariance and
Buffer bounds checking). Each is one row again at the first copy's place.
Copies that were an older version of the row brought back by a merge
(EXEC, global atomics, ds_cmpst_b32, v_cvt_flr/rpi, partition invariance,
buffer bounds) give way to the current row. Where two copies each added
something (control flow, global atomics, multiply-add, 16-bit min3/max3/
med3), the row keeps both.
AI-assisted.
In `replay_cpu_bench` and real game execution, recording draws was the largest
remaining per-draw overhead (~155-160 ns and 4 heap allocations per draw call,
measured by @traeb0n in #2123 follow-up finding D3D-289).
Previously:
- `d3d12_com.cpp` heap-allocated a dynamic `std::vector<TargetView>`
for render targets and another `std::vector<VertexBufferView>` for vertex buffers
(copying from the list's 32-element array).
- `CommandList::draw(const Draw&)` then copied both vectors again into the `Command`
variant inside `commands_`, resulting in 4 heap allocations per draw.
This change:
- In `runtime/src/command_list.h` (`leonida::Draw`):
- Replaces `std::vector<TargetView>` with fixed inline `std::array<TargetView, 8> render_targets`
(matching `D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT` = 8) and tracks `render_target_count`.
- Replaces `std::vector<VertexBufferView>` with fixed inline `std::array<VertexBufferView, 32> vertex_buffers`
(matching `D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT` = 32).
- Adds rvalue `bool draw(Draw&&)` overload that moves the command into `append(std::move(draw))`.
- In `runtime/shims/d3d12_com.cpp`:
- Stores `render_targets_` as an inline `std::array<leonida::TargetView, D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT>`,
eliminating heap reallocations on `OMSetRenderTargets`.
- Directly passes `vertex_buffers_` without copying into a temporary vector.
- Moves `draw` with `check(list_.draw(std::move(draw)))`.
- In `runtime/src/vulkan_replay.h`:
- Iterates over bound render targets using `slot < draw.render_target_count && slot < draw.render_targets.size()`.
- In `runtime/test/d3d12_com_test.cpp`:
- Adds static assertions verifying `Draw` move constructibility, move assignability,
and fixed inline array sizes.
- Updated `docs/d3d12_vulkan.md` with the contract details.
Result: 0 heap allocations per draw call (down from 4), eliminating ~155-160 ns
recording overhead per draw call.
Tested:
- `python -m compileall -q make_game.py tools tests`: OK
- `python -I make_game.py --help`: OK
- `static_assert` checks in `d3d12_com_test.cpp`: verified
Hardware: Tested on AMD Radeon RX 7800 XT (driver 24.20.19.05 / Vulkan 1.4.359 / Windows 11).
AI-assisted. Standard library / C++ only; no game content or carved assets.
Item: D3D-289
Depends on: #2123
D3D12 only forbids beginning the same query element twice while it runs, so a
command list may overlap two pipeline-statistics queries, or an ordinary
occlusion query and a binary one, on different slots of one heap. The replay
refused all of those with ReplayResult::unsupported. The overlapping-ordinary
occlusion machinery already virtualizes concurrent queries as non-overlapping
physical segments whose results are summed; this extends it to the remaining
cases:
- Binary occlusion joins the ordinary kind in the same physical pool (both are
VK_QUERY_TYPE_OCCLUSION, so one physical query is open at a time and the
shared intersection interval is counted by both logical queries). A binary
resolve of a multi-segment query sums its segments and normalizes the total
to 0/1 (OcclusionResolve::sum_binary; run flag needs_sum_binary).
- Overlapping pipeline-statistics queries split into the statistics pool with
the same one-slot-per-event layout (plan_overlapping_statistics_segments);
every non-timestamp resolve while a query runs closes and reopens the open
segment for D3D-162's helper-dispatch exclusion. The single-list replay()
helper still has no segment pool and refuses such lists outright instead of
running two Vulkan queries of one type whole.
The device test's old pin of the occlusion+binary refusal now expects a
replay; vk_overlapping_occlusion adds crossing statistics queries checked
word-by-word against three unsplit references and an ordinary query around a
binary one; replay_query_predication pins the segment layouts, the composite
binary resolve and the helper's refusal without a GPU. docs/d3d12_vulkan.md
4.6 moves the case out of "Not implemented yet".
AI-assisted: yes
The FORMATS table encodes the sint 8/16 formats (6, 12, 19, 28, 61, 70 in
tools/rdna2spirv.py) next to uint 8/16. Noted by HQasper on #2063.
AI-assisted.
Recounted with main 49475796 on the 1.0.2.1 package (counts only): 52/52 unpack,
42 clean and 10 with invalid words in the disassembly, 51 translate and pass
spirv-val. The four rules embedded_shaders.md listed are three since 427c1376
(#1968); Box16Rehydration stops at buffer_store_short (#1864). d3d12_vulkan.md
and the docs index quoted 41/42 and four rules in seven places.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/test_docs_design_rows.py failed on main again: merges after
64ece042 and abbb3dce kept both sides of rows two branches had edited.
design.md had 24 topics repeated (two to five rows each), README.md one
and testing.md two.
Each group is now one row at the first copy's place, keeping every fact
any copy stated. Where copies disagreed, the newer wording (by git blame
and the commit that wrote it) wins: for example, the --f16-interp-fallback
row no longer also gives the pre-SHADER-291 locations 29 - 2N / 30 - 2N,
the "Not GPU-verified" notes give way to the SHADER-137 hardware results
added to the same rows, and "tbuffer_store_format_* is not translated"
gives way to the paragraph describing how it is translated.
A sentence-by-sentence check of every copy against the merged row finds
only those deliberately replaced. The four docs tests pass.
AI-assisted.
progress_dashboard.py (standard library, python -I) collects outcomes the project already
produces and writes a self-contained progress.html, JSON snapshots and a history into a
folder outside the repository (a folder inside it is refused):
- unit tests: --run-tests runs tests/test_*.py with ci.yml's selection, one process each;
a test counts as current only if neither it nor tools/, scripts/, make_game.py changed
since it passed (content digests, so uncommitted edits are handled too)
- runtime tests: runtime/build LastTest.log and --junit files (CTest or pytest)
- the translator contract table in docs/design.md, each row classified by how it says it
was confirmed, with the matched words shown
- the measured tables in docs/runtime_imports.md
- --work: per-stage counts from the user's own carve and translation (numbers only)
- --github (read-only gh): latest completed CI run per workflow on main, the D3D- table
of #313, the coordination issue's section sizes and, with --login, claims and PRs
No game data: counts, pass/fail and error classes only; no shader names or paths into the
game copy. The page has no packages and no network access. tests/test_progress_dashboard.py
covers the parsers, the classification, freshness, the no-names rule and the output folder.
Integer images need an integer sampled type for defined Vulkan texels. Use the descriptor format to select it while carrying the supplied mip level into every branch.
CreateGraphicsPipelineState refused any desc.GS, although all 195 geometry
shaders translate (triangles in, a triangle strip out; docs/design.md
"Geometry shaders"). The stage table now holds VS, GS and PS; a GS needs the
geometryShader feature (enabled on the standalone and test devices where
the GPU has it, E_NOTIMPL otherwise), and the PSO's topology type must be
TRIANGLE, the GS's input (E_INVALIDARG otherwise). The push-constant range
names the geometry stage only where the device has it. Hull, domain and
stream output stay refused.
d3d12_geometry_test (in ctest): a GS that emits each triangle twice, against
a pipeline without one, and a line topology refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge every repeated topic in docs/design.md, docs/README.md and docs/testing.md into one row, keeping the current measured numbers (382,781 models; 4,686 fragments / 30,343 bone-bound / 126,301,454 triangles excluding levels.rpf) and folding in the unique verified facts from the shorter duplicates.
compare_placed_reserved (d3d12_vulkan_device_test) runs 76 CreatePlacedResource
and CreateReservedResource cases against the host runtime on the standalone
device. On main 31 of them differed (RTX 3060, driver 610.88):
- CreatePlacedResource checked none of the description, initial-state and
clear-value rules CreateCommittedResource has, and checked a plain texture's
size against nothing: a texture larger than its heap, or past its end, was
accepted. A small texture (4 KiB alignment) at a 4 KiB offset was refused.
- CreateReservedResource checked those rules only for textures (through the
committed backing) and never the initial state or clear value.
- Both answered a null output with S_FALSE; the host checks the arguments,
then answers E_UNEXPECTED.
The initial state was not checked for committed resources either. The host
takes exactly GENERIC_READ, one write state alone (RENDER_TARGET,
UNORDERED_ACCESS and DEPTH_WRITE with their flag), or a mix of read states on a
texture; any bits on a buffer except the acceleration-structure state without
UAV access. initial_state_refusal holds that rule, in committed_resource_refusal,
so committed, placed and reserved resources share it; 23 "committed: ... state"
cases pin it in compare_invalid_arguments.
A placed buffer in an upload or readback heap takes any initial state on the
host (a committed one must start in GENERIC_READ or COPY_DEST); UAV access is
refused there as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A compute fixture loads through the nine narrow integer formats (DST_SEL
XYZW, X011 and d16) and stores edge values through each with the
runtime's selectors. check.py's 136 expected words are the same program's
output run natively on gfx1036 (tools/hw_oracle, wave32 and wave64), and
the interpreter test runs the fixture against them too.
Depends on #1871.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A separate ISA model for the v_pk_* integer ops (op_sel, op_sel_hi, clamp) and the 16-bit VOP3 integer ops (op_sel on sources and the destination half, the kept other half, clamp), with VGPR, SGPR, inline-constant and literal sources within the constant-bus rules, compared one lane at a time with rdna2spirv run in tests/semantic/spirv_mini_interp.py, optionally with the hardware through tools/hw_oracle. A constant whose high half a packed op reads (#2224) only with --known.
AI-assisted.
Measured natively on gfx1036 (f32 and f16, every quarter turn from 0.25 to
2^24 of either sign, around +-256, specials): sin at an odd half turn and
cos at an odd quarter turn are exactly +0, where Sin/Cos of the rounded
2*pi gave about -+8.7e-8 (or a 1-ulp f16 denormal). The test holds 500
measured words (whole, half and quarter turns, infinities, NaN).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Floor of the kept denormal gave -1. 44 more measured words (gfx1036) for
v_cvt_flr_i32_f32 and v_cvt_rpi_i32_f32 (the control) in the test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured natively on gfx1036 (IEEE 0, f32 denormals flushed): floor(-1e-45)
is -0, ceil(+1e-45) +0 and fract of either 0, where a translation that keeps
the denormal (any driver that keeps f32 denormals) gives -1.0, +1.0 and
0x3f7fffff. fract(+-inf) is exactly 0xffc00000 and a NaN operand passes
through unchanged. The new test holds 75 measured words.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_min3/v_max3/v_med3 on f16, i16 and u16 were 'Not GPU-verified'. 6,092
cases run natively on gfx1036 (tools/hw_oracle, IEEE 0, f16 denormals
kept) give the translator's word except src0's NaN payload when all three
operands are NaN, which the row already lists as not modelled for the
32-bit ops. The new test holds 540 of the measured words.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>