ps_ops7 checks v_perm_b32 (selectors 0x0c0d0700 and 0x0b0a0908, the sign
selectors fixed in #216), v_alignbit_b32 with a shift of 36, and
v_med3_i32 against v_med3_u32. ps_ops8 checks v_mul_hi_u32/i32,
v_bcnt_u32_b32, v_ffbl_b32, v_ffbh_u32 (also of 0), v_xad_u32 and
v_add3_u32. Both run on the GPU (check.py, run_gpu_tests.py) and in
test_value_semantics.py against plain-Python references.
The mini interpreter gains OpUMulExtended, OpSMulExtended, FindILsb,
FindUMsb, UMax, SMin, UClamp and SClamp. docs/design.md gets the byte
permute contract row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GFX10 format names list the channel widths from the top bit, so 2_10_10_10
(50) is R10G10B10A2 and 10_10_10_2 (44) has a 2-bit x. FORMATS read them
from bit 0, which swapped the two for typed buffer loads and stores.
cs_store now writes its R10G10B10A2 word through 50. cs_fmt_1010102 covers
both formats; to run it, buffer_load_format masks a shift that was 32 for
aligned elements, and the test interpreter gains the conversions it needs.
With src2 & 3 == 0 the byte shift is 0 and the left shift of src0 is 32 - 0 =
32, undefined in SPIR-V. Its result is discarded by the OpSelect, but SPIR-V
leaves the shift undefined even there. (32 - b) & 31 keeps it in range, as #201
does for v_alignbit_b32.
tests/semantic/test_alu_alignbyte.py checks every byte shift, the 2-bit
selector mask and an inline selector against a plain-Python reference.
v_bfe_u32/v_bfe_i32 and s_bfe_u32/s_bfe_i32 passed offset and width straight to
OpBitFieldU/SExtract. SPIR-V leaves offset + count > 32 undefined, and that
happens for any field that runs past bit 31 (v_bfe: both are 5 bits; s_bfe: the
width is 7 bits). The width is now cut to 32 - offset, so the field stops at
bit 31: zero-filled for the unsigned extract, sign-filled for the signed one.
That is the value LLVM's constantFoldBFE (AMDGPUISelLowering.cpp) gives,
Src0 >> Offset.
test_alu_bfe.py: the i32 reference shifts arithmetically, the sweep no longer
skips offset + width > 32, and new tests cover such fields and s_bfe with
widths up to 127. test_mutations.py follows the renamed width operand.
LLVM 23 prints a VOP3/VOP3P source it doesn't read (SRC1/SRC2 of one- and
two-source ops) as 0x80, inline constant 0, where the game's compiler stores 0.
Re-anchoring in shaders with code-embedded data compares the printed encoding
with the blob, so those instructions never matched and 1,471 of the 1,473 such
shaders were rejected ("reachable instruction with normalized encoding").
same_encoding now ignores an SRC1/SRC2 field only when it is 0 in the blob and
0x80 as printed; a source LLVM does read prints as decoded (s0), so a real
difference still fails. The existing VOP3P op_sel_hi rule now combines with it.
make_game.py: `dotnet` is on PATH with only the .NET runtime, and the asset
stage then fails in `dotnet build` ("No .NET SDKs were found"). The preflight
now asks `dotnet --list-sdks` for an SDK 8 or newer.
Tested on Windows 11, LLVM 23.1.5 (MSYS2 UCRT64 llvm-tools), the 1,473
shaders with embedded data, disassembled with this branch's shader_disasm.py:
main: 2 translated, 1471 "normalized encoding"
this branch: 1473 translated, 1473 pass spirv-val
Full corpus on the earlier tree with the same rule: 26,503/26,503 pass.
.NET check: false with only the runtime installed, true after adding SDK 8.0.428.
No GPU pipeline run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013qV4hmKSJmU6cXAgrehZzr
There was no resolve, and a multisampled committed texture was refused.
- IR: ResolveSubresource (two different resources).
- Replay: ResolveSubresource is vkCmdResolveImage in the layouts copies
use: a multisampled colour subresource into a single-sampled 2D one of
the same size and format. Depth-stencil resolves and resolves between
two formats of a typeless family stay unsupported. ResourceBinding gains
samples: a multisampled texture copies only to its own sample count and
has no footprint.
- Device: committed multisampled 2D textures (single-mip render targets or
depth-stencils, when the GPU has the sample count for the format; the
other shapes are E_INVALIDARG as in D3D12), and TEXTURE2DMS
render-target and depth-stencil views.
- COM: ID3D12GraphicsCommandList::ResolveSubresource.
Tests: command_list_test (recording rules, and a copy with a z range);
vk_command_replay_test part C (a 4x resolve and the refused resolves and
multisampled copies; it also runs the volume copies that are already on
main at the Vulkan level, on Linux too: a 4x4x4 volume uploaded, copied as
a block and whole, read back, and the z ranges that must be refused);
d3d12_vulkan_device_test (a resolve through the Xbox-ABI proxy and the
refused shapes).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ItsNotRexed asked in #156 for claims to be made there before a PR is
opened. Say so where contributors and their agents look first:
CONTRIBUTING.md, AGENTS.md and the pull request template.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
partial_wave_test always set VKC_SUBGROUP_SIZE=64. With LEONIDA_W64_EMULATE=1 the
shader is translated for any subgroup width, and on AMD, where 64 is available,
the emulated path was never run at 32 (#166, RX 6700 XT entry). Under emulation
it now asks for 32; without emulation it still asks for 64.
v_perm_b32 returned 0x00 for selectors 8-11. Per the RDNA ISa BYTE_PERMUTE
they give 0xff when bit 7 of byte 1, 3, 5 or 7 of {src0, src1} is set. Each
byte pick also shifted both sources by up to 56 bits (undefined in SPIR-V,
the select kept the right one); the shift is now (sel & 3) * 8 on the source
chosen by sel < 4.
New test shaders, checked on the GPU (check.py, run_gpu_tests.py) and in
tests/semantic with expected words derived from the ISA:
- ps_ops7: v_perm_b32 (byte picks, 0x00/0xff, sign selectors), v_alignbit_b32
with a shift of 36, v_med3_i32 vs v_med3_u32.
- ps_ops8: v_mul_hi_u32/i32, v_bcnt_u32_b32, v_ffbl_b32, v_ffbh_u32 (of 0),
v_xad_u32, v_add3_u32.
The semantic interpreter gains OpUMulExtended/OpSMulExtended,
OpUGreaterThanEqual and GLSL FindILsb, FindUMsb, UMax, SMin, UClamp, SClamp,
with direct tests; the unsupported-ext example moves from FindUMsb to Ldexp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selector bytes 8-11 gave 0x00. The RDNA2 ISA reference defines them as the sign
bit of a 16-bit half of {S0, S1} repeated over the byte: bit 15, 31, 47 or 63.
The byte's low two bits pick the half (0, 1 in S1; 2, 3 in S0), and the shift
is 15 or 31, so it stays below 32.
test_alu_perm_alignbit.py now covers 8-11 in every result byte, with #211's
probe values.
Each element now carries attrs_actual, children and content_count. The JSON summary reports the measured depth and child-count histograms, leaf/empty/text-only counts and parent-child edges. --csv writes one flat row per node with parent, slot and sibling columns. Tests cover sibling order, malformed close tags against the flat parser, tree-shape summary and CSV output. The docs replace the game-name sample trees with aggregate tree shape and a synthetic example.
vk_harness exits 77, the code vk_compute_test and vk_store_test already use for a
device that cannot run a test, when VKH_GS is set and the device has no
geometryShader, or VKH_MESH is set and it has no VK_EXT_mesh_shader. Before, a
missing mesh extension exited 1 and a missing geometryShader failed in
vkCreateDevice with VK_ERROR_FEATURE_NOT_PRESENT (MoltenVK, #166).
run_gpu_tests.py (gs_tri, ms_tri, ms_w64x_ballot, ms_clip) and check.py
(ms_w64x_ballot) turn that exit code into SKIP, quoting the harness's reason.
Since 7cc6068 (#126) the disassembly counts as finished only by disasm.done.
Work folders built before it have none, so their next build disassembled
the whole corpus again and, as that drops spirv/index.json, translated it
all again too: hours of work on a build that was already finished.
- A folder whose translation finished (spirv/index.json) but has no
disasm.done gets the marker: translation only ever ran after disassembly.
- The disasm moved from its old place next to the carve folder is marked
finished, so it is translated again as intended, not disassembled again.
Two tests in tests/test_shader_stage_resume.py; both fail before this change.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The viewer binds to 127.0.0.1, which keeps other machines out but not
other web pages: a page on any site can point its own domain at 127.0.0.1
(DNS rebinding) and then fetch http://<its domain>:8765/world/... as
same-origin, reading world.json and the .glb chunks built from the
player's copy. Those requests still carry the page's domain in the Host
header.
send_head now refuses (403) any request whose Host is not 127.0.0.1,
localhost or [::1] (any port, any case, trailing dot allowed). A request
with no Host header (a local tool, never a browser) is still served.
tests/test_world_build.py: host_allowed cases, and a live-server test
where Host rebind.example gets 403 without the world data while
localhost/127.0.0.1 get 200. Both fail on main.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>