Raw buffer_load_format_xyzw, tbuffer_load_format_xyzw and buffer_store_format_xyzw /
tbuffer_store_format_xyzw kernels per format on the AMD GPU (tools/hw_oracle), compared word for
word with a CPU model. Formats are mapped by name because GFX11 numbers them differently; the
twelve 10_11_11 / 11_11_10 non-FLOAT codes and the two SCALED 10_10_10_2 codes have no GFX11
spelling. On a Radeon 880M (gfx1150, RDNA3.5, not RDNA2): 1,264,744 elements over 63 formats,
V# and tbuffer, loads and stores, 0 mismatches; --negative-control shows a wrong V# format is
caught.
docs/buffer_formats.md records the measured rules (SCALED stores convert as NORM, float stores
round toward zero and saturate, a 2-bit SNORM half rounds away, NaN payloads, channel fill) and
where the translator's older stores differ.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
find_harness/harness() check runtime/build/windows and add .exe on Windows; the
skip/error text names LEONIDA_VK_HARNESS. The tool and the test use fixed
image.raw / image_first_light.raw paths, unlinked before each run, so no random
raw files pile up. manifest.json records the OBJ SHA-256 and docs/first_light.md
names the 4,213/7,968 model and its hash.
--check now loads an existing manifest, writes a fresh raw path, and calls the
same check_image the test imports. The oracle adds four UV probes whose U and V
differ by more than 0.15, because a symmetric centre alone cannot catch a swapped
UV. Fake harnesses that exit 0 without writing, write a solid image or swap UV
all exit 1; the real draw exits 0. The test has seven cases, including the CLI.
The draw writes a fresh raw path (a harness that writes nothing cannot pass on a
stale file); the check adds a coverage maximum, a corner that must keep the clear
value and the centre UV the mesh's last covering triangle predicts on the CPU.
OracleTests cover the accepted fixture plus all-opaque, swapped-UV and short
negatives without a GPU or a package.
tools/first_light.py carves the game's shaders, translates one real VS/PS pair,
converts an exported OBJ to a mesh, writes a manifest and runs vk_harness. The
harness gains VKH_DRAW_MESH/VKH_VERTEX_LAYOUT (indexed mesh, vertex input), inert
when unset. The package-gated test draws the model and checks coverage and the
centre pixel; docs/first_light.md records the measured result.
A listing is LLVM's text for the instruction it decoded, not the bytes it
read. translate() compared the two only for listings with undecodable words
(the re-anchoring path); a clean listing was translated from the text alone,
so a field the disassembler drops would be translated as 0 without a word.
llvm-mc's gfx1013 decoder does drop the VOP3 op_sel bits (14:11) of 16-bit
VOPC compares and re-encodes them as 0.
check_printed_encodings() runs for every other listing whose header names
its code range and whose fssm/ or fspx/ blob holds that range: each
instruction's printed encoding must be the bytes at its offset, with
same_encoding's exceptions, or the shader is Unsupported. Hand-written
listings, run_gpu_tests.py's synthetic listings and the tests' header-only
blobs are not checked.
On the 1.0.2.1 corpus the 25,030 clean listings hold 30,335,381
instructions and none differs (754 fall under same_encoding's exceptions);
the 166 16-bit VOPC compares have op_sel clear.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #1911: two containers with the same kind-6 program and different kind-0 entries (32x1x1 and 64x1x1)
translate to different modules but got the same fspx_code_sha256, so both resolved to the same pipeline.
- tools/fspx_unpack.py writes the kind-0 entry as fspx/<name>.state; tools/shader_meta.py records its SHA-256 as
fspx_state_sha256 next to fspx_code_sha256.
- make_game.py: entries with the same code and state keys must have identical modules, otherwise the FSPX step fails
naming both programs and drops the index. The same code key with other state keys is allowed.
- runtime: a container or bare payload (kinds 0 and 6 present) matches the code key and then the state key; no match
is E_INVALIDARG. A bare kind-6 program (slot 67, no kind 0) takes the code key's entries when their modules are
identical, and is refused with E_INVALIDARG and an "ambiguous" log line when they differ.
- Tests: the review case in tests/test_fspx_shaders_stage.py, shader_library_test and d3d12_fspx_compute_test.
- docs/fspx.md: the two keys and the ambiguous case.
On 1.0.2.1 the 29 kind-6 programs are distinct, so nothing resolved wrongly before: 17 translated entries, 17
distinct code keys, 17 distinct (code, state) pairs, all 17 found from the container and from the bare program.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A host run on an RTX 4070 SUPER and a UHD 770 (@CowBoYdu76) creates a
HARDWARE_PROTECTED default heap, though the D3D12_HEAP_FLAGS
documentation calls it unsupported. heap_desc_refusal no longer refuses
it; it moves from the refusal cases to compare_heap_neighbours and the
accepted list. ALLOW_DISPLAY stays refused, now confirmed on those hosts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The runtime's standalone device (d3d12_vulkan_device.cpp) still took
"the first usable device, replaced by every later discrete GPU". #915
fixed that rule in the test harnesses because Mesa's Dozen (Microsoft
vendor 0x1414, "Microsoft Direct3D12 (<gpu>)") reports a discrete GPU, so
on a PC with the OpenCL/OpenGL/Vulkan Compatibility Pack the runtime
could run on the Vulkan-on-D3D12 wrapper while the tests used the native
driver. Even without Dozen, on a two-dGPU PC the runtime took the last
GPU and vk_test_device.h the first.
- runtime/src/vulkan_device_filter.h: vulkan_device_rank() (native over
Microsoft's layers, then discrete > integrated > virtual > CPU), with
the device type as an int so the header stays Vulkan-free.
- d3d12_vulkan_device.cpp: the first usable device of the highest rank.
- vk_device_pick.h: device_rank forwards to it (static_assert on the
VkPhysicalDeviceType values).
- d3d12_indirect_rt_test, dxgi_swapchain_test, vk_image_fuzz,
vk_sampler_test had the old loop and ignored LEONIDA_VK_DEVICE: they
now filter and rank like the rest, and an unmatched filter fails
instead of skipping.
- vulkan_device_filter_test: the rank order; docs/testing.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes M2's open item "texture formats other than R8G8B8A8_UNORM, mips and arrays
through a PSO". d3d12_m2_formats_test samples, through the M2 descriptor path
(heap slots 9/10, CreateShaderResourceView, CreateSampler, two root tables,
translated vs_m2/ps_m2): an 8x8 BC1 and an 8x8 BC7 texture with 4 mips each and
an R8G8B8A8 2D array of 3 slices (new ps_m2_array.asm). Every subresource is
uploaded at its GetCopyableFootprints layout; POINT samplers with MinLOD = MaxLOD
pin each level; a view from mip 1 and two array views check that level and slice
are relative to the view. Blocks use endpoint colours only, so all 12 cases are
compared with the CPU byte for byte (error 0). Validation clean on RTX 4070 Ti
SUPER; no layer change was needed. Synthetic data only, no game files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PiKMETzszqwfnV8QQyzocY
spirv-val's structured-control-flow checking cost grows roughly with the cube
of the nesting depth: over the 1.0.2.1 corpus the deepest block sits 118
constructs deep and about 85% of validation time is in modules nested 20 or
deeper. cfg_structure.depth() measures the tree and a module deeper than
MAX_STRUCTURED_DEPTH (16) is emitted in the existing flat dispatch-loop form
instead, which emits the same blocks and only changes the routing. Depth
5-12 shows no gain, hence the bound at 16.
- int_hw_probe: VOP3 clamp on the carry-out add/sub ops (#1831) and v_cvt_rpi/flr's exact floor(x+0.5) and NaN
sign saturation (#1856) now translate as gfx1035 measured, so KNOWN_DIVERGENCES is empty. The known-divergence
test reports a synthetic entry. shader_validation.md says so, and design.md loses the stale duplicate
v_cvt_flr/rpi row a "both" merge left that still called them open.
- docs/README.md: one Other languages line (fr, pt-BR, zh-CN, pl-PL, tr, ru, ja); docs/i18n/README.md: one row
each for pt-BR and zh-CN (the newer).
- anim_rigs, d16_format_probe, pe_shader_containers: text writes name newline="\n" (#1615);
pe_shader_containers guards stdout (#1428).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add `tools/bcpack_history_calib.py` to derive external `--history <path>` JSON
tables (`bc1.json`..`bc7.json` or combined JSON) locally from a player's own
texture pools or exact reference block/DDS pairs using only the Python
standard library (`python -I`):
- Exact reference inversion (`--ref-dds POOL:INDEX=REF.dds`, `--ref-pairs`):
algebraically inverts direct built-in history references (`d > i` in blocks
0..255) across BC1/BC3/BC4/BC5/BC6H/BC7 into confirmed strict-mode entries.
- Read-only TTPF pool self-calibration (`inputs ...`): uses a prefix rANS lane
decoder (`decode_lanes_prefix`) together with exact BC6H/BC7 anchor MSB and
BC7 Mode-1 shared p-bit parity constraints, intra-block index smoothness
voting, and sibling raw/zlib mip endpoint fitting to derive provisional
tables usable with `--history <path> --allow-provisional`.
- Extend `tools/bcpack_tables_bptc.py`, `tools/bcpack.py`, and
`tools/ttpf_mips.py` so `--history` also accepts optional BC1-BC5 JSON
tables (`confirmed`, `provisional`, optional `replace`) alongside BC6H/BC7.
- Add synthetic unit tests in `tests/test_bcpack_history_calib.py` and document
the schemas and CLI workflow in `docs/textures.md`.
Say that blending into a B8G8R8X8 render target reads destination alpha
as 1, which factors the PSO rewrites, and that what a draw leaves in the
X byte is not defined.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both were rejected while v_add_nc_u16 / v_sub_nc_u16 are translated.
They take the same 16-bit path (op_sel source and destination halves, the
other half kept); without clamp they are bit-identical to the u16 forms,
and clamp saturates the exact signed result to [-32768, 32767].
tests/semantic/test_valu_add_sub_nc_i16.py covers a value grid with and
without clamp, op_sel and equality with the u16 forms. docs/design.md
row added.
translate() clips the LDS array to 16,384 dwords, so a native compute
shader whose RSRC2 LDS_SIZE allocates more than 64 KiB passed the cap
check with a cut array (review on #1882). The check now counts the LDS
at max(array, RSRC2 allocation) and refuses it. A need that comes only
from a constant ds offset keeps the clipped array: the +4-dword slack
makes an in-range b32 at offset 65,524 compute as 65,540 B, and a real
offset past 64 KiB is out of range on hardware.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ResolveSubresourceRegion of a depth or stencil plane runs in a rendering scope whose render area is the source
rectangle, and Vulkan resolves only inside it. MoltenVK (1.4.2 and 1.4.3) resolves the whole destination
subresource: it resolves through Metal's store action, which has no render area. d3d12_depth_resolve failed its
eight MIN/MAX rectangle cases under Wine on an M3 Max for that reason.
The texels around the rectangle now go into copy_scratch before the scope and back after it, in up to four bands, on
every GPU: no device property reports the behaviour. vk_command_replay_test part I resolves a D32 rectangle natively
and checks the texels around it; it failed on MoltenVK before this change (all 28 overwritten) and passes on
MoltenVK and KosmicKrisp, with no validation errors on KosmicKrisp.
AI-assisted.
M = (M & ~DATA) | DATA2, the _rtn_ form returning the old M. Emitted as
an atomic AND with ~DATA (its result is the old M, exactly) and an atomic
OR with DATA2; the memory is exact unless another lane's op on the same
dword lands between the two.
tests/semantic/test_lds_mskor.py runs them in the interpreter.
docs/design.md row added.
- For samplers with custom border colours (BorderColor::table), retain is_int in the fallback path when VK_EXT_custom_border_color is unavailable.
- Select VK_BORDER_COLOR_INT_TRANSPARENT_BLACK for UINT custom borders and VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK for float custom borders, satisfying Vulkan input validation rules on integer views (reported by Vonsek, #760).
- In vulkan_sampler(), default to VK_BORDER_COLOR_INT_TRANSPARENT_BLACK when sampler.integer_border is set for table colours.
- Update d3d12_sampler2_test with a fallback device and vkCreateSampler interception to verify that VK_BORDER_COLOR_INT_TRANSPARENT_BLACK and VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK are requested as expected.
Tested on Windows 11, MSVC 2022 x64 (Ninja, RelWithDebInfo), NVIDIA GeForce RTX 2070 SUPER.
Clean-room verification suite passed with exit code 0.
Co-Authored-By: Antigravity <antigravity@google.com>
- Implements custom float and UINT sampler border colours on VK_EXT_custom_border_color in runtime/shims/d3d12_vulkan_device.cpp.
- Maintains a device-wide border colour table of up to 4000 entries.
- Assigns table indices into S# BORDER_COLOR_PTR [11:0] (with BORDER_COLOR_TYPE = table), ensuring distinct custom colours produce distinct keys in the bindless descriptor hash table while identical colours reuse existing indices.
- Chains VkSamplerCustomBorderColorCreateInfoEXT with VK_BORDER_COLOR_FLOAT_CUSTOM_EXT / VK_BORDER_COLOR_INT_CUSTOM_EXT and format = VK_FORMAT_UNDEFINED when customBorderColorWithoutFormat is enabled. Falls back to transparent black with a diagnostic warning when the extension is absent.
- Enables VK_EXT_custom_border_color in standalone device creation and vk_test_device.h.
- Updates d3d12_sampler2_test to verify table index assignment, index reuse, S# distinction between float and UINT representations, and Vulkan sampler creation.
- Documents the architecture in docs/d3d12_vulkan.md.
Tested on Windows 11, MSVC 2022 x64 (Ninja, RelWithDebInfo), NVIDIA GeForce RTX 2070 SUPER, Driver 595.79.
Clean-room verification suite (python compileall, make_game.py CLI, 27/27 CTest, d3d12_vulkan_device_test, d3d12_sampler2_test, d3d12_descriptor_test) passed with exit code 0.
Item: D3D-73 (#634)
Co-Authored-By: Antigravity <antigravity@google.com>
- On GFX10 a device-scope load is `glc dlc` and a device-scope store `glc` (Mesa ac_get_hw_cache_flags sets
exactly these bits for ACCESS_COHERENT). The 10 POPS pixel shaders read-modify-write their ordered images that
way, but a glc image_load was translated as a read of the sampled array (no coherent form in SPIR-V) and no
storage view was Coherent, so under the fragment-shader interlock a read could miss the previous fragment's store.
- A glc image_load now reads the storage view the stores write (OpImageRead, StorageImageReadWithoutFormat, class
picked from the T# FORMAT as for stores); a shader with a glc image load or store decorates its storage views
Coherent. Every other image_load keeps SHADER-151's sampled path (byte-identical output).
- glc on a sampled read (image_sample*, image_gather*, image_load_mip) or on a dimension without storage views is
Unsupported instead of silently non-coherent; dlc alone (CU scope) stays non-coherent.
- tests/semantic/test_image_coherent.py (real translator; 7 of 10 fail on the old one) and a docs/design.md row.
buffer_store_format_d16_xyzw into every narrow UINT/SINT format, read back
from gfx1036 (wave32 and wave64 alike): a SINT half is sign-extended before
the clamp. Dropping the signed d16 source for sint now fails 10 rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Section 3.5a names the four-word inline dispatch. The BVH builder also
writes a five-word form, 0x4003cc00, x, 1, 1, W, at 0x14972, 0x15215,
0x1536a and 0x1d002. It is the inline form of console slot 80: when the
buffer is full each site calls +0x280 with the same (x, 1, 1, W). W is
0x8020 at two sites and 0x20 at the other two.
Byte +0x143 is read at 31 sites in the builder and one in the FSR DLL
and written by neither; every store into +0x140..+0x143 is a byte store
to +0x140 or +0x141. A replacement list can leave it 0. The slot-80 row
of section 3.3a points at the packet and the 0x20 calls.
Section 3.5a names the four-word inline dispatch. The BVH builder also
writes a five-word form, 0x4003cc00, x, 1, 1, W, at 0x14972, 0x15215,
0x1536a and 0x1d002. It is the inline form of console slot 80: when the
buffer is full each site calls +0x280 with the same (x, 1, 1, W). W is
0x8020 at two sites and 0x20 at the other two.
Byte +0x143 is read at 31 sites in the builder and one in the FSR DLL
and written by neither; every store into +0x140..+0x143 is a byte store
to +0x140 or +0x141. A replacement list can leave it 0. The slot-80 row
of section 3.3a points at the packet and the 0x20 calls.
#1686 folded a known SGPR offset into the immediate before the 32-bit
truncation (s_buffer_load) or the 21-bit sign extension (s_load), so
s12 = -4 with offset:20 read byte 16 instead of being out of range, and an
s_load sOFF of 2^20 or more turned negative. Hardware does not wrap
(@Pierre-Kookis, gfx1036); the run-time path adds zext(sOFF & ~3) to the
normalised immediate in 64 bits. The fold now does the same. Found and
GPU-reproduced by @Impre-visible.
tests/semantic/test_smem_const_offset.py runs each case with the offset
as a constant and through v_readfirstlane, against the measured rule.
docs/design.md: the row says it (and a duplicated copy of the row goes).
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>
The paragraph still said 13, from before the dot-product rule (#1754). docs/fspx.md, "Translation status", has 17
and lists what stops the other 12; the paragraph now points there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crosslane_fuzz.py --dpp-sweep runs one program per DPP case instead of random
ones: every DPP16 control (335) x bound_ctrl x fi x 3 EXEC patterns, all 256
row_mask/bank_mask pairs, and 19 DPP8 select sets x fi (7,206 per wave size).
Ops rotate through mov/not/add/xor, half of them in place. Failures print
the case label, and a per-family table follows the summary.
Gen.op_dpp now builds through dpp_op() with the same random draws, so
existing --dpp seeds give the same programs (pinned by a test).
On an RX 6700 XT (gfx1031, Windows HIP oracle): --dpp-sweep --oracle hw
--wave both gives 14,412/14,412 matching, and random --dpp seeds 1-8 give
8,000/8,000. Docs updated (shader_validation.md FUZZ-7, design.md DPP row).
AI-assisted (Claude Code).
Measured natively on gfx1036 under the MODE inferred for the game (IEEE 0,
f32 denormals flushed, f16 denormals kept): a denormal f16 operand is
normalized by both frexp ops, and v_ldexp_f16 returns denormal results
rounded to nearest even. The translator read f16 denormals as zero and
flushed denormal ldexp results, which the hardware does only with
denorm_mode_16_64 = 0. The f32 trio already matches the hardware in the
game's mode (f32 denormals flushed); docs/design.md says so now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>