gpu/pack: scan() drops 2,634 labelled shaders — : in the name tail, and the data_end jump hides 143 fragments #34

Closed
opened 2026-11-26 04:05:29 +00:00 by github-bot · 3 comments
Owner

@⁠MoonYueya on GitHub · 2026-11-22 14:14 UTC · original

One line: complete the RPF9 record scan, so 2,634 labelled shaders stop falling out of the extractor.

Background — we re-implemented scan() and ran it on our own copy. It reports 23,869 records. Of the 26,721 records in that layer, 2,707 are rejected by ident() (line 27) because their names carry a stage suffix such as …:CS_<8 hex>_Wrapped — yet rpf.rs:32 already rewrites : to _ when writing files. 143 more are hidden by i = data_end (line 69): each starts inside the compressed span of a record you already accept, sharing its end offset and payload digest. 2 more have a bad first byte. Net: 2,634 labelled shaders never reach the extractor. Longest name: 126 bytes with terminator, so the ">255" note at lines 10-11 does not apply.

Stages

  • S1 allow : in the name tail; other predicates unchanged. Accept: cargo test green plus a mod tests case on one synthetic …:CS_… record; the family then appears in the listing (26,576 candidates).
  • S2 resume at i + 1 instead of the payload end, collapsing duplicates by (end offset, payload digest) and keeping the earlier start. Accept: a fixture of two overlapping records yields one, and the count settles at 26,503 distinct.
  • S3 print both numbers at rpf.rs:147: 26,719 raw, 26,503 de-duplicated.

Field layout — your p = i + len is the NUL byte, so this lines up with your p + 1 / p + 2 / p + 10 / p + 14 and header_end = p + 18:

Field Where Check
name d[i+1..p] printable ASCII, len - 1 bytes
terminator d[p] == 0
flag d[p+1] u8, opaque to us
compressed size d[p+2] u32 LE, == d[p+10], 0 < cs < 16 MiB
unknown d[p+6] u32 LE, we do not read it
compressed size again d[p+10] == d[p+2]
inflated size d[p+14] u32 LE, 0 < us < 64 MiB
payload d[p+18] raw deflate, no zlib header, cs bytes; the record ends at p + 18 + cs

Four predicates. We accept a candidate only when all four hold: (1) p + 18 + cs is inside the buffer and the two size fields agree; (2) the raw-deflate stream ends and inflates to exactly us bytes; (3) the output starts with DXBC; (4) the container's own total-size field, its u32 at +24, equals us. Byte order is little-endian throughout.

De-dup key. Enumerating every offset gives 26,721 accepted records. 218 of them start inside the previous record's name (suffix aliases; corrected below) and share its end offset, its DXBC digest (container bytes 4..20) and its tag; keep the earlier start and drop the later copy — 26,503 records, 25,889 distinct digests. Two consequences worth knowing before S2: your i = data_end currently suppresses 143 of those 218, so switching to i + 1 without this rule adds all 143 back as phantom records; and 55 of the 218 already get through today. The one shape the enumeration cannot see is a 3-character name, whose length byte is not part of a printable run — the shortest name in this archive is 20 bytes.

We can also offer: patch review, and we will do S1 if nobody claims it.

Open question: is the identifier-only filter deliberate — is …:STAGE… not a shader record for your pipeline?

Drafted with AI assistance; numbers independently re-checked.

**@⁠MoonYueya** on GitHub · 2026-11-22 14:14 UTC · [original](https://github.com/xcl-dev/xcl/issues/34) **One line**: complete the RPF9 record scan, so 2,634 labelled shaders stop falling out of the extractor. **Background** — we re-implemented `scan()` and ran it on our own copy. It reports 23,869 records. Of the 26,721 records in that layer, 2,707 are rejected by `ident()` (line 27) because their names carry a stage suffix such as `…:CS_<8 hex>_Wrapped` — yet `rpf.rs:32` already rewrites `:` to `_` when writing files. 143 more are hidden by `i = data_end` (line 69): each starts inside the compressed span of a record you already accept, sharing its end offset and payload digest. 2 more have a bad first byte. Net: 2,634 labelled shaders never reach the extractor. Longest name: 126 bytes with terminator, so the ">255" note at lines 10-11 does not apply. **Stages** - **S1** allow `:` in the name tail; other predicates unchanged. Accept: `cargo test` green plus a `mod tests` case on one synthetic `…:CS_…` record; the family then appears in the listing (26,576 candidates). - **S2** resume at `i + 1` instead of the payload end, collapsing duplicates by (end offset, payload digest) and keeping the earlier start. Accept: a fixture of two overlapping records yields one, and the count settles at 26,503 distinct. - **S3** print both numbers at `rpf.rs:147`: 26,719 raw, 26,503 de-duplicated. **Field layout** — your `p = i + len` is the NUL byte, so this lines up with your `p + 1` / `p + 2` / `p + 10` / `p + 14` and `header_end = p + 18`: | Field | Where | Check | | --- | --- | --- | | name | `d[i+1..p]` | printable ASCII, `len - 1` bytes | | terminator | `d[p]` | `== 0` | | flag | `d[p+1]` | u8, opaque to us | | compressed size | `d[p+2]` | u32 LE, `== d[p+10]`, `0 < cs < 16 MiB` | | unknown | `d[p+6]` | u32 LE, we do not read it | | compressed size again | `d[p+10]` | `== d[p+2]` | | inflated size | `d[p+14]` | u32 LE, `0 < us < 64 MiB` | | payload | `d[p+18]` | raw deflate, no zlib header, `cs` bytes; the record ends at `p + 18 + cs` | **Four predicates.** We accept a candidate only when all four hold: (1) `p + 18 + cs` is inside the buffer and the two size fields agree; (2) the raw-deflate stream ends and inflates to exactly `us` bytes; (3) the output starts with `DXBC`; (4) the container's own total-size field, its u32 at +24, equals `us`. Byte order is little-endian throughout. **De-dup key.** Enumerating every offset gives 26,721 accepted records. 218 of them start inside the previous record's name (suffix aliases; corrected below) and share its end offset, its DXBC digest (container bytes 4..20) and its tag; keep the earlier start and drop the later copy — 26,503 records, 25,889 distinct digests. Two consequences worth knowing before S2: your `i = data_end` currently suppresses 143 of those 218, so switching to `i + 1` without this rule adds all 143 back as phantom records; and 55 of the 218 already get through today. The one shape the enumeration cannot see is a 3-character name, whose length byte is not part of a printable run — the shortest name in this archive is 20 bytes. **We can also offer**: patch review, and we will do S1 if nobody claims it. **Open question**: is the identifier-only filter deliberate — is `…:STAGE…` not a shader record for your pipeline? Drafted with AI assistance; numbers independently re-checked.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:05:29 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-22 15:41 UTC · original

Thanks – S1 is right and is fixed (it lands with our next push). S2 and S3 are not needed: the extra hits they surface are not fragments, they are aliases of records we already have. Details below, measured on v1.0.2.1 shaders.rpf (411,695,600 bytes) with a separate Python re-implementation and with xcl rpf after the fix.

S1 – : in the name. 2,689 records have an effect-qualified name (alphaResolve:CS_AlphaTransmissionDenoise_2871f2e9_Wrapped). All of them inflate to DXBC and all of them are compute shaders. ident() rejected them. This was not deliberate – the filter assumed plain identifiers. scan() now accepts : after the first byte (the first-byte rule is unchanged) and finds 26,503 records.

The net gain is 2,634, not 2,689: 55 of those records were already being picked up, under the wrong name. Once the real record was rejected, the scan moved on byte by byte, and where the : byte (0x3A = 58) happened to equal the length of the rest of the name plus its terminator, the tail (CS_AutofocusSceneDepthScanFinalReduction_a00a21f4_Wrapped) parsed as a record with the same header and payload. Those 55 were the "CS 55" in our corpus numbers. The new test qualified_names_are_whole_records builds exactly that case. It fails on the old predicate with the alias name and a lost record.

S2 – resuming at i + 1. The 143 extra hits (216 once : is allowed) do not start inside a compressed span. Every one of them starts inside the name of an accepted record, at a name byte that equals its distance to the terminator, and shares that record's terminator, header and payload. They are suffix aliases of the same record. The i = data_end jump is what discards them. Resume-at-i + 1 plus your (end offset, payload digest) de-dup gives 26,503 – the same set S1 alone gives with the existing jump. Your 26,576 for S1 counts all 2,707 raw : hits, 18 of which are such aliases. The 2 "bad first byte" hits are aliases too (:CS_WavePerSplineConstraint_32_a913d34f_Wrapped, 2UInt:CS_RGBA8AsR32UInt_Broadcast_4db369a6_Wrapped).

S3. 26,719 counts aliases, so xcl rpf prints only the record count (26,503).

The module note about names longer than 255 bytes was also wrong. The longest name is 125 bytes; the "truncated" names it described were these aliases. The note has been rewritten.

The 2,634 records through the recompiler. They exposed three translator gaps, now fixed:

  • ds_swizzle_b32 in the bit mode with xor ≥ 16 (0x401F, which swaps the 16-lane halves) was misread as FFT/rotate mode. The real FFT and rotate modes are now implemented as the ISA defines them.
  • 12 programs use the compiler's far jump (s_getpc_b64 / s_add_u32 / s_addc_u32 / s_setpc_b64 with a constant offset, for targets beyond the ±128 KB s_branch range). It is now treated as a direct branch.
  • A quadratic scan in the control-flow structurer kept the largest of them (indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays_d60186e6_Wrapped: 76,699 instructions, 1,377 far jumps) translating for more than ten minutes. It now takes seconds.

The whole pack now translates in full: 26,698 / 26,698 programs.

**@⁠ivall** on GitHub · 2026-11-22 15:41 UTC · [original](https://github.com/xcl-dev/xcl/issues/34#issuecomment-7081499651) Thanks – S1 is right and is fixed (it lands with our next push). S2 and S3 are not needed: the extra hits they surface are not fragments, they are aliases of records we already have. Details below, measured on v1.0.2.1 `shaders.rpf` (411,695,600 bytes) with a separate Python re-implementation and with `xcl rpf` after the fix. **S1 – `:` in the name.** 2,689 records have an effect-qualified name (`alphaResolve:CS_AlphaTransmissionDenoise_2871f2e9_Wrapped`). All of them inflate to DXBC and all of them are compute shaders. `ident()` rejected them. This was not deliberate – the filter assumed plain identifiers. `scan()` now accepts `:` after the first byte (the first-byte rule is unchanged) and finds **26,503 records**. The net gain is 2,634, not 2,689: 55 of those records were already being picked up, under the wrong name. Once the real record was rejected, the scan moved on byte by byte, and where the `:` byte (0x3A = 58) happened to equal the length of the rest of the name plus its terminator, the tail (`CS_AutofocusSceneDepthScanFinalReduction_a00a21f4_Wrapped`) parsed as a record with the same header and payload. Those 55 were the "CS 55" in our corpus numbers. The new test `qualified_names_are_whole_records` builds exactly that case. It fails on the old predicate with the alias name and a lost record. **S2 – resuming at `i + 1`.** The 143 extra hits (216 once `:` is allowed) do not start inside a compressed span. Every one of them starts inside the *name* of an accepted record, at a name byte that equals its distance to the terminator, and shares that record's terminator, header and payload. They are suffix aliases of the same record. The `i = data_end` jump is what discards them. Resume-at-`i + 1` plus your (end offset, payload digest) de-dup gives 26,503 – the same set S1 alone gives with the existing jump. Your 26,576 for S1 counts all 2,707 raw `:` hits, 18 of which are such aliases. The 2 "bad first byte" hits are aliases too (`:CS_WavePerSplineConstraint_32_a913d34f_Wrapped`, `2UInt:CS_RGBA8AsR32UInt_Broadcast_4db369a6_Wrapped`). **S3.** 26,719 counts aliases, so `xcl rpf` prints only the record count (26,503). The module note about names longer than 255 bytes was also wrong. The longest name is 125 bytes; the "truncated" names it described were these aliases. The note has been rewritten. **The 2,634 records through the recompiler.** They exposed three translator gaps, now fixed: - `ds_swizzle_b32` in the bit mode with xor ≥ 16 (`0x401F`, which swaps the 16-lane halves) was misread as FFT/rotate mode. The real FFT and rotate modes are now implemented as the ISA defines them. - 12 programs use the compiler's far jump (`s_getpc_b64` / `s_add_u32` / `s_addc_u32` / `s_setpc_b64` with a constant offset, for targets beyond the ±128 KB `s_branch` range). It is now treated as a direct branch. - A quadratic scan in the control-flow structurer kept the largest of them (`indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays_d60186e6_Wrapped`: 76,699 instructions, 1,377 far jumps) translating for more than ten minutes. It now takes seconds. The whole pack now translates in full: 26,698 / 26,698 programs.
Author
Owner

@⁠ivall on GitHub · 2026-11-22 15:46 UTC · original

Landed in e80ce8d.

**@⁠ivall** on GitHub · 2026-11-22 15:46 UTC · [original](https://github.com/xcl-dev/xcl/issues/34#issuecomment-7081554888) Landed in e80ce8d.
Author
Owner

@⁠MoonYueya on GitHub · 2026-11-22 16:11 UTC · original

Thanks, and thanks for the correction. You're right about S2: we checked our own index, and all 218 of our re-detections start inside the previous record's name. None start in its header or its payload, so they're suffix aliases, as you describe, and not fragments. We've fixed our notes and the two other threads where we said otherwise. Good to see the 2,634 records also shook out three translator gaps.

Drafted with AI assistance.

**@⁠MoonYueya** on GitHub · 2026-11-22 16:11 UTC · [original](https://github.com/xcl-dev/xcl/issues/34#issuecomment-7081888196) Thanks, and thanks for the correction. You're right about S2: we checked our own index, and all 218 of our re-detections start inside the previous record's *name*. None start in its header or its payload, so they're suffix aliases, as you describe, and not fragments. We've fixed our notes and the two other threads where we said otherwise. Good to see the 2,634 records also shook out three translator gaps. Drafted with AI assistance.
This discussion has been locked. Commenting is limited to contributors.
No description provided.