Commit Graph
63 Commits
Author SHA1 Message Date
elforeign 425327a0f2 shader: add s_add_i32 and s_sub_i32 with signed-overflow SCC
#185 left both forms unsupported because the pinned XML says only
"carry-out" for them. The AMD RDNA 2 ISA reference guide (GPUOpen,
section 12.1 SOP2 Instructions, p. 101-102, and section 5.3 Scalar
Condition Code, p. 33) defines SCC for both as signed overflow:
add overflows when the operands share a sign that the result lacks;
subtract when the operands' signs differ and the result's sign differs
from S0's. The guide also confirms the unsigned rules used in #185.

Adds both forms to the generated opcodes, the decoder, the reference
(exact signed result must fit in i32), the independent interpreter (the
guide's sign-bit rule over its ripple adder) and the translator, plus
400 boundary programs, eight hand-worked overflow and no-overflow cases
(-1 + 1 and 0 - 1 carry or borrow but do not overflow) and two signed
overflows in the scalar ALU fixture. Inverting the overflow rule in any
one implementation fails three tests. s_min_i32 and the other SOP2
forms stay unsupported.

Refs #185

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:48:52 -06:00
Ranveer Soni 1212280ab8 Merge pull request #224 from elforeign/task/171-bc7-decoder
feat(texture): BC7 block decoder, all eight modes, with independent vectors (#171)
2026-11-24 13:13:55 +05:30
elforeign 994efd38f9 shader: decode and execute SOP2 scalar add, subtract and bitwise forms
Adds s_add_u32, s_sub_u32, s_addc_u32, s_subb_u32, s_and_b32, s_or_b32
and s_xor_b32 across the chain: generated opcodes from the pinned AMD
XML, a typed ScalarAlu instruction, decoding, the reference interpreter,
the independent semantic-review interpreter and the translator, which
resolves scalar state and SCC as it already does for s_mov/s_cmp.
v_mov_b32_e32 may now read a normal SGPR, so results reach vector code
as constants.

SCC: the XML states carry-out for additions, carry-in for ADDC/SUBB and
nonzero results for bitwise forms. For subtraction it says carry-out
without fixing the polarity; LLVM's lowering of usubo and of 64-bit
subtraction to s_sub_u32/s_subb_u32 requires SCC to be the borrow.
s_add_i32/s_sub_i32 stay unsupported: no pinned source settles whether
their SCC is the carry or signed overflow.

Verified with an original LLVM-assembled fixture and 1,400 boundary
programs (every form, 10x10 operands, SCC clear and set) against exact
integer definitions; translator, reference (exact integers) and
independent interpreter (bit-serial ripple adder) all agree, and all
1,401 programs match on native Metal with validation. LLVM agrees on
every encoding. Breaking any one implementation fails the tests.

Fixes #185
Independent review fixes: both interpreters now require a known SGPR
for v_mov_b32 from an SGPR even in an inactive lane, as translation
does; alias, literal and inline cases also assert the translated result
and run on Metal; rejections are pinned to the SOP2 word's offset; GPU
status is recorded as local evidence with acceptance pending.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:38:54 -06:00
Ranveer Soni 68fc4e25dc Merge branch 'main' into task/171-bc7-decoder 2026-11-24 13:07:25 +05:30
Ranveer Soni cdaff0a391 Merge pull request #223 from elforeign/task/169-metal-bc4-bc5
feat(metal): native BC4 and BC5 UNORM/SNORM upload and readback (#169)
2026-11-24 13:06:51 +05:30
elforeign 9318e68840 Merge remote-tracking branch 'origin/main' into feat/gpu-compatibility-expansion
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:34:37 -06:00
elforeign abd6698a66 Merge remote-tracking branch 'origin/main' into task/171-bc7-decoder 2026-11-24 01:32:50 -06:00
elforeign 5f8867bd30 Merge remote-tracking branch 'origin/main' into task/169-metal-bc4-bc5 2026-11-24 01:32:50 -06:00
Ranveer Soni 5ca90bfac0 Merge pull request #221 from atesahmet0/task/177-probe-report-consistency
Test probe report consistency across JSON, Markdown, and CSV
2026-11-24 12:59:38 +05:30
elforeign 7cc35ffd41 Merge remote-tracking branch 'origin/main' into task/169-metal-bc4-bc5
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
2026-11-24 01:28:23 -06:00
elforeign 57f10c1d7c Merge remote-tracking branch 'origin/main' into task/171-bc7-decoder
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
#	crates/texture/src/lib.rs
2026-11-24 01:26:50 -06:00
elforeign 76620e274b texture: iterate texels directly in the BC7 tests
Strict Clippy (needless_range_loop) rejects indexing the output by the
loop counter; the assertions are unchanged.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:26:34 -06:00
elforeign 240302fabe texture: add a BC7 block decoder from the Khronos BPTC text (#171)
Issue #171 asks for bounded BC7 decoding with independent vectors for
partitions, endpoint precision and indices. All eight modes are decoded:
the partition and anchor tables are extracted mechanically from Khronos
Data Format Specification 1.3 section 20.1, and blocks with a zero low
byte decode to zero as that section requires.

Hand-derived tests cover each mode's distinctive field (P-bits, shared
P-bits, anchors, rotation, index selection, the section's own mode 2
bit-position example), and 430 known-answer vectors come from a separate
clean-room reference decoder. CPU only; no Metal BC7 path is claimed.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:25:45 -06:00
Ranveer Soni 01deb3f8a8 Merge branch 'main' into feat/gpu-compatibility-expansion 2026-11-24 12:55:06 +05:30
Ranveer Soni e6b9a27242 Merge pull request #218 from elforeign/task/168-bc23-audit
test(metal): BC2/BC3 edge blocks, invalid payloads and capability reporting (follow-up to #214)
2026-11-24 12:54:35 +05:30
ates a533d8107e Test cross-format probe reports against fixture counts and offsets
Signed-off-by: ates <ahmetrizaates@hotmail.com>
2026-11-24 10:16:45 +03:00
elforeign 3109b620fd texture: decode the single-subset BC6H modes
#170 asks for a documented, bounded BC6H subset with explicit rejection
of what is not implemented. This adds a CPU decoder for the four
single-subset modes (Khronos 3, 7, 11 and 15; Microsoft 11 to 14) in
signed and unsigned form, written from the Khronos Data Format 1.3 text
(Tables 121 and 122, unquantization and final unquantization). Reserved
modes decode to zero as the specification requires; the ten two-subset
modes return Bc6hError::UnsupportedMode, and BC6H_SUPPORTED_MODES lists
coverage by mode.

Tests use hand-derived values (saturation to 65504 and -65504, the
11-bit transform wrap, both reversed-bit fields, signed -32768 to
negative infinity) and 128 known-answer vectors from a separate
clean-room reference decoder, 16 per supported and reserved mode.
Flipping the reversed bit order, dropping the wrap mask, using 31/64
for signed data, a 4-bit anchor, accepting mode 0 or not zeroing
reserved modes each fails the tests.

Refs #170

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:16:24 -06:00
elforeign 878f554dcd Merge task/168-bc23-audit into task/169-metal-bc4-bc5
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
#	crates/metal/tests/native/texture_bc_alpha.rs
2026-11-24 01:12:31 -06:00
elforeign 46e2d36064 metal: compare non-interpolated BC4/BC5 codes exactly
The full-texel check applied the two-code tolerance to every channel, so
an endpoint or six-value fixed code outside the anchors could be off by
two and still pass. Each texel's tolerance now comes from its own index:
zero for stored and fixed codes and constant channels, two only for
interpolated codes. A readback kernel that lowers near-maximum red by two
now fails the BC4 and BC5 UNORM tests.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:12:20 -06:00
elforeign d94121bbb0 metal: compare non-interpolated BC2/BC3 codes exactly
An independent review of the #214 tests found that the full-texel check
applied the two-code interpolation tolerance to every channel, so an
endpoint, a BC2 alpha nibble or BC3's fixed 0 or 255 outside the anchors
could be off by two and still pass. The tolerance now comes from each
texel's own indices: zero for stored and fixed codes, two only for
interpolated ones. A readback kernel that lowers near-opaque alpha by two
now fails all three tests. The 1.14-code bound is stated as 8/7.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:11:43 -06:00
elforeign ef4fbba797 Merge upstream main into task/169-metal-bc4-bc5
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:08:59 -06:00
elforeign 97ea2541bb metal: cover BC2/BC3 edge blocks and report missing BC support apart
The section 12 audit of #214 found three gaps: no level narrower than a
block row (Metal's zero-stride single-row upload) or of 1x1, no checks
for zero extents or oversized and block-count-mismatched payloads, and a
missing BC capability surfaced the same way as an implementation fault.

Adds a 5x3 and 1x1 GPU test with hand-derived anchors, the extra upload
rejections, and MetalError::is_capability_unavailable; the GPU tests now
print CAPABILITY UNAVAILABLE or IMPLEMENTATION FAILURE. Rounding the
texture to whole blocks, accepting oversized payloads, or a device
without BC support each makes the tests fail with the matching message.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:08:34 -06:00
elforeign 7a10d7eac8 metal: cover BC4/BC5 edge blocks and invalid payloads
Section 12's audit asks for levels that are not whole blocks and for
rejected payloads. Adds a 5x3 (single block row, zero Metal stride) and
1x1 GPU test over BC4/BC5 UNORM and SNORM with hand-derived anchors, the
zero-extent and wrong-length upload rejections, and routes the GPU reads
through the shared capability-aware unwrap. Rounding the texture to whole
blocks, accepting oversized payloads, or a device without BC support each
makes the tests fail with the matching message.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:03:48 -06:00
elforeign 0e51ddda76 Merge test/metal-bc2-bc3 into the BC4/BC5 branch
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
2026-11-24 01:02:47 -06:00
elforeign b5a462fb54 Merge remote-tracking branch 'origin/main' into feat/gpu-compatibility-expansion
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:02:17 -06:00
elforeign 09e0bea55d shaders, isa: tighten inspection wording and review-found test gaps
From independent review:
- The summary said "not executable" for instructions that merely have
  no semantic decoding; a decoded program can still fail compilation.
  Say "without semantic decoding".
- When identification stops early, a branch target past the identified
  prefix was reported invalid although its boundaries are unknown;
  report it as unverified.
- The VOP3 and VOP3P literal probes used 1.0, which LLVM encodes as an
  inline constant (8 bytes), so neither exercised a literal. Use
  0x3f800001 and 0x3c01 and assert the 12-byte encoding and trailer.
- The coverage JSON test now also checks the document's shape.

Refs #183, #184

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:01:38 -06:00
elforeign 1260e07ba1 metal: cover BC2/BC3 edge blocks and report missing BC support apart
The section 12 audit of #214 found three gaps: no level narrower than a
block row (Metal's zero-stride single-row upload) or of 1x1, no checks
for zero extents or oversized and block-count-mismatched payloads, and a
missing BC capability surfaced the same way as an implementation fault.

Adds a 5x3 and 1x1 GPU test with hand-derived anchors, the extra upload
rejections, and MetalError::is_capability_unavailable; the GPU tests now
print CAPABILITY UNAVAILABLE or IMPLEMENTATION FAILURE. Rounding the
texture to whole blocks, accepting oversized payloads, or a device
without BC support each makes the tests fail with the matching message.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 01:01:26 -06:00
Ranveer Soni 0cac6c4fcf Merge pull request #214 from elforeign/test/metal-bc2-bc3
test(metal): BC2/BC3 upload and sampling conformance (#168)
2026-11-24 12:30:21 +05:30
elforeign 3a598a83e1 shaders: assert add.bin inspects as 7 semantic instructions
Refs #183

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:59:45 -06:00
Ranveer Soni 97598903e2 Merge branch 'main' into feat/gpu-compatibility-expansion 2026-11-24 12:26:13 +05:30
elforeign 6d7523f5d1 Merge upstream main into test/metal-bc2-bc3
Resolves the CHANGELOG.md conflict with the claim-rules entry; both
entries are kept.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:55:23 -06:00
elforeign cf2d0cfb0b isa, shaders: test that coverage totals and documented counts match FORMS
At 5450612 the generated table held 1,460 forms while the docs and PR
said 1,465; 1493dcf added the five literal-only forms the LLVM oracle
found, so the table, xenora shaders coverage (text and JSON) and docs
now agree on 1,465 across 21 families. Nothing checked that they stay
in step. Test the JSON and text totals and per-family sum against
FORMS and SEMANTIC_FORMS, and the counts stated in docs/research/rdna2.md
and CHANGELOG.md against FORMS.len().

The branch inspection fix for #183 is the previous commit 9640269.

Fixes #183, fixes #184

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:54:07 -06:00
elforeign 585edd313f metal: upload and read BC4 and BC5 blocks natively
BC4 and BC5 had CPU decoders (#167) but no native Metal path, so nothing
showed that single- and dual-channel blocks reach the GPU and decode as
the specifications describe, signed formats included. This adds a pitched
BcChannelUpload (8-byte BC4 or 16-byte BC5 blocks, sharing the pitch
rules) and NativeCompute::read_bc_channel_upload, which places the blocks
in BC4_R/BC5_RG UNORM or SNORM textures behind the BC capability check.
Signed texels are read back as channel * 127 in two's-complement bytes.

The GPU tests cover six- and eight-value interpolation, equal and extreme
endpoints (stored -128 reads as -1.0, as specified), red-green order,
padded row and slice pitches, two layers and two mips: 232 texels against
the CPU decoders and hand-derived anchors. On an Apple M5 Pro interpolated
codes lie within 1.71 codes of the exact values and two codes of the
truncating CPU reference, which set the tolerances. Uploading SNORM as
UNORM, BC5 as BC4, scaling signed readback by 128 or swapping red and
green each fails the tests.

Refs #169

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:53:30 -06:00
elforeign 69812d97c0 Merge remote-tracking branch 'origin/main' into feat/gpu-compatibility-expansion
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
2026-11-24 00:52:10 -06:00
elforeign 59ee786a12 metal: upload and read BC2 and BC3 blocks natively
BC2 and BC3 had CPU decoders (#167) but no native Metal path, so nothing
showed that the original 16-byte blocks reach the GPU and decode as the
specifications describe. This adds a pitched BcAlphaUpload with the BC1
upload's validation (shared, now measured in 16-byte blocks) and
NativeCompute::read_bc_alpha_upload, which places the blocks in BC2_RGBA
or BC3_RGBA textures behind the existing BC capability check.

The GPU tests cover explicit 4-bit alpha, six- and eight-value
interpolated alpha (equal endpoints included), descending, ascending and
equal colour endpoints, padded row and slice pitches, two layers and two
mips. Texels are compared with the CPU decoders and hand-derived anchors.
On an Apple M5 Pro interpolated values lie within 1.14 codes of the exact
values, two codes at most from the truncating CPU reference, which sets
the tolerance. Uploading BC3 as BC2, BC2 as BC1, or ignoring the row
pitch each fails the tests.

Refs #168

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:49:17 -06:00
Ranveer Soni 48e42d6d4b Merge pull request #182 from atesahmet0/fix/75-static-probe-c7
Fix C7 instruction boundaries and trusted fixture probe reporting
2026-11-24 12:12:44 +05:30
elforeign 964026901f shaders: decode inspected instructions at their stream offset
xenora shaders inspect passed each identified instruction to decode() on
its own. decode() checks that every branch target lands on an instruction
in the stream it was given, and a lone branch has no other instruction to
land on, so every supported s_branch and s_cbranch_* was reported as
"unsupported operands" (3 of 15 rows in bitwise-branch.bin).

Add decode_at(), which decodes one instruction at its real stream offset
without the stream-wide target check, and DecodedInstruction::branch_target().
inspect now identifies the whole stream first and checks each branch
target against those boundaries, reporting a bad target separately.
decode() is rebuilt on decode_at() with unchanged behaviour.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:40:55 -06:00
elforeign 5baa630ff0 Merge remote-tracking branch 'origin/main' into feat/gpu-compatibility-expansion
Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
2026-11-24 00:38:51 -06:00
ates 60f4f38da1 Fix C7 instruction boundaries and trusted fixture probe reporting
Signed-off-by: ates <ahmetrizaates@hotmail.com>
2026-11-24 09:32:34 +03:00
elforeign 1493dcf83b isa: check identification against LLVM and add literal-only forms
The extension-word length rules were written by hand because the XML
gives none, so they needed an outside oracle. An LLVM test now compares
names and lengths for one instruction per family and extension word.
It found five instructions the XML lists only under a literal encoding,
which the first table omitted; they are now base forms that always carry
a literal.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:20:26 -06:00
elforeign 54506125d4 Merge remote-tracking branch 'origin/main' into feat/gpu-compatibility-expansion
# Conflicts:
#	CHANGELOG.md
2026-11-24 00:11:41 -06:00
elforeign f19d57967d Merge remote-tracking branch 'origin/main' into feat/texture-bc-formats 2026-11-24 00:11:08 -06:00
elforeign 62c933051b isa: generate complete gfx1030 instruction metadata and identification
The decoder knew 25 hand-matched forms, so any other instruction stopped
decoding with no record of what it was or how long it was. A two-stage
generator now reduces AMD's public RDNA 2 XML to all 1,460 base forms,
with a committed snapshot so CI can check the generated table offline.
identify() finds any form's exact length, including literal, SDWA, DPP
and NSA words, and the shaders CLI reports discovered against executable
forms so metadata coverage is never read as GPU support.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:11:00 -06:00
Ranveer Soni c88359b379 stuff 2026-11-24 11:37:34 +05:30
Ranveer Soni c12ad2e2f8 feat: expand X19 native ARM64 DBT and guest CPU runtime
Signed-off-by: Ranveer Soni <git@ranveersoni.me>
2026-11-24 11:34:39 +05:30
elforeign ef1a94ce71 texture: add BC2, BC3, BC4 and BC5 block decoders
Adds spec-derived CPU decoders (UNORM and SNORM for BC4/BC5) with
truncating integer interpolation and hand-computed tests, so later
texture work has verified references for these formats.

Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
2026-11-24 00:01:14 -06:00
Ranveer Soni 93bd04c70f feat(imports): automated API compatibility generation pipeline and metadata ingestion (X18) 2026-11-24 10:50:57 +05:30
Ranveer Soni 0be6220e47 feat(add): x17things, as well as more d3d12 testing 2026-11-24 09:49:53 +05:30
Ranveer Soni e3c082ca9d Add synthetic PE32+ guest runtime support 2026-11-24 07:15:26 +05:30
Andre EncarnacaoandClaude Opus 5.5 6722c041d1 fix: restore a compiling, green main (#60)
The static PE probe commit left main failing CI at every step after formatting:

- cargo fmt: apply rustfmt to cli/main.rs, loader/probe.rs and
  loader/tests/probe_static.rs.
- clippy: collapse the four nested if / if-let blocks in probe.rs into
  let-chains (edition 2024); no behaviour change.
- build: make the probe library match its two callers.
  run_probe_and_export now takes the PE bytes and a ProbeConfig (the
  CLI's config was previously ignored in favour of the default),
  ProbeReport.pe is renamed to ProbeReport.parsed, and
  pe::IMAGE_SCN_CNT_CODE (0x00000020, PE/COFF section flag) is added.
- tests: gate test_guest_dbt_first_rendered_frame_with_metal behind a new
  xenora-loader gpu-tests feature. CI's paravirtual Metal device lacks
  Apple family 7; the two CPU-only DBT tests in the same file keep
  running in CI. scripts/test-gpu.sh now runs the gated test.

Signed-off-by: Andre Encarnacao <andreencar@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 06:57:07 +05:30