Repository navigation
Conversation
tools/render_buckets.py streams every rpf9dump models manifest's Items (the levels manifest is several GB), enumerates archives with os.listdir, checks each archive's total against the manifest's Count, and counts RenderBucket & 0x7F, bit 7, values outside 0-6 and distinct shader hashes per bucket, per material and per unique model. docs/models.md gets the whole-export table next to the 3,000-model sample; the RenderBucketMask rule stays sample-only (the field is not in the manifests). Synthetic tests only; counts only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tsNotRexed#4946) iter_items returned at the closing bracket of Items, so a top-level Count after Items was never read. After Items closes it now parses the remaining top-level members one by one (a Count nested in a later value doesn't count), keeping the incremental read of the items. Tests cover Count before and after Items, a nested Count after Items, small read chunks, and the exit code on a mismatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
At Run this from the repository root with from pathlib import Path
from tempfile import TemporaryDirectory
import subprocess, sys
with TemporaryDirectory(dir="E:/") as export, TemporaryDirectory() as tmp:
report = Path(tmp) / "report.json" # TEMP is on C:
cmd = [sys.executable, "-I", "tools/texture_dicts.py", export, "--json", str(report)]
for _ in range(2):
print(subprocess.run(cmd).returncode)On Windows 11 with CPython 3.14.7, the first run writes the report and exits with code 0. The second exits with code 1 and prints In AI-assisted. |
…earer unique counts (review on ItsNotRexed#4946) - A value after Items that reaches the end of the read buffer is read on before it is accepted: the digits of a Count split between reads gave a shorter number (shdann). Test sweeps every chunk size over a four-digit Count. - A material without a shader hash is counted on its own, not as a "none" hash. - Docstring and docs/models.md say exactly what a unique model is (the ordered material list: reordered materials count again, full collisions merge), that per-archive unique figures are first-seen-in-listing-order, and that the sample's "Shaders" column counts rows while the new column counts hashes (tupacfan04). Counts on the export are unchanged; 0 materials lack a hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Head moved to |
|
Independent check of Environment: Windows 11, CPython 3.15.2, CPU only. Synthetic export fixtures, no game files, no GPU.
Read the tool: counts-only output (no names — consistent with the no-game-data rule), chunked manifest parsing with the buffer-boundary fix in the head commit, One caveat worth noting: the manifest shapes it parses ( AI-assisted (Devin). |
kacper-serewis
left a comment
There was a problem hiding this comment.
Material texture Name is already the stored 32-bit hash formatted as eight hexadecimal digits by rpf9dump (Program.cs, r.NameHash.ToString("X8")). The census hashes those digits again. This representation occurred throughout three cached retail manifests, and the same nh = joaat(t["Name"]) expression remains at c9828cc2. Please parse the hexadecimal value, compare stored hashes, and distinguish candidate 32-bit matches from exact 64-bit key matches. A synthetic case with two candidates sharing a hash would cover the ambiguity. The published dictionary and embedded match counts need a corrected run. We verified the material denominators on each of three cached subsets. Those subsets contained no texture dictionaries or embedded textures. AI-assisted Windows CPU review.
|
Approve with two small fixes; nothing blocking. Verified: Issues:
AI-assisted review, no game files, no GPU. |
…eview on ItsNotRexed#4946) The reader now parses the top-level object member by member: Count is the top-level member wherever it stands, and a missing, doubled, leading or trailing comma in Items, an unclosed object or data after it raise ValueError; the CLI reports that and exits 2 (kacper-serewis). A second manifest with an archive label already used gets a numbered label, so per-archive entries no longer overwrite each other while both stay in the totals. Tests cover the malformed cases at several read sizes, top-level-only Count, and the label collision. Counts on the export are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Head moved to |
|
Independent Windows review at
|
|
The census rejects a valid manifest when a read ends at the Run this script from the repository root with import json, pathlib, subprocess, sys, tempfile
with tempfile.TemporaryDirectory() as d:
p = pathlib.Path(d, "a", "models", "manifest.json")
p.parent.mkdir(parents=True)
for pad in (0, (8 << 20) - len('{"scale":1e')):
s = " " * pad + '{"scale":1e3,"Items":[{}],"Count":1}'
p.write_text(s, encoding="ascii")
assert json.loads(s)["Count"] == 1
r = subprocess.run([sys.executable, "-I", "tools/texture_dicts.py", d], capture_output=True, text=True)
print(pad, r.returncode, r.stderr.splitlines()[-1:] or r.stdout.splitlines()[-1:])Expected: both runs exit 0 and report one model. The parent AI-assisted. |
|
Independent Windows CPU verification on
|
… (review on ItsNotRexed#4946) Members other than Items and Count (e.g. a large ModelDecodeFailures list before a trailing Count) were decoded into Python lists and dicts just to step over them (shdann). They are now skipped structurally: brackets must match and strings end, nothing is built. On shdann's 14.8 MB fixture the peak traced allocation is the same with Count first or last (about 29.6 MB, the read buffer). Tests cover the memory bound and malformed skipped values. Counts on the export are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Head moved to |
shdann found on ItsNotRexed#4980 that the shared reader accepted "1" from "1e3" when a read ended at the e. When the number characters run on to the end of the buffer, the reader now reads more before it accepts the number. Test sweeps every chunk size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, coverage gaps (review on ItsNotRexed#4980) - rpf9dump writes a material binding's Name as its stored 32-bit name hash in eight hex digits; the census hashed those digits again, so the dictionary and embedded name matches were wrong (kacper-serewis, whattheflop). Stored hashes are now compared (joaat only for a name that is not eight hex digits), and embedded rows use their stored Hash. - Each reference is an exact 64-bit key match, else a 32-bit name-hash candidate (ambiguous when the hash is on more than one entry), else unresolved; the three add up, per-source counts are listed separately and can overlap. - A manifest Count above its rows is export coverage, not a problem; more rows than Count is (whattheflop). - --json: never inside the export folder, new path or existing; a different drive is outside (no commonpath ValueError); written with LF (shdann, tupacfan04, whattheflop). - A number cut at a read boundary ("1e" of "1e3") is read on before it is accepted (shdann). - docs/world.md:384 rewritten with the corrected run. Still 0 references match a levels.rpf dictionary entry; 50 share a hash with core_restofworld's or textures.rpf's dictionaries (42 also match a pool key exactly). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fix round at Name hashes (@kacper-serewis, @whattheflop): confirmed, and it changes the numbers. Old and new numbers over the same export (418,714 distinct material texture keys, 20,781,927 bindings):
The conclusion Count gaps (@whattheflop): a manifest
LF report (@whattheflop): the writer opens with
Thanks @Atomic258 and @kotekompotek for the checks, and @Atomic258 for the caveat about running against a real export, which turned out to matter. AI-assisted. |
|
I verified both earlier fixes at One non-blocking performance finding at Run this synthetic probe with import sys,time,statistics
from pathlib import Path
sys.path.insert(0,str(Path("tools").resolve()))
import texture_dicts as t
refs={k:{123456} for k in range(20000)}
for n in (1,64,256):
archives={str(i):{i} for i in range(n)}
src=(set(),set(),set(),set(range(n)),archives,{})
times=[]
for _ in range(3):
start=time.perf_counter()
result=t.summarise(refs,src,len(refs),0,1)
times.append(time.perf_counter()-start)
print(n,result["resolution"]["unresolved"],round(statistics.median(times),3))AI-assisted. |
kacper-serewis
left a comment
There was a problem hiding this comment.
TEST-1133 at c6562aa0: the exporter’s stored hexadecimal hash now matches directly and the double-hashed decoy stays unresolved. An independent collision fixture confirmed exact 64-bit precedence and an ambiguous 32-bit-only candidate. All 16 focused tests passed. The 89-entry retail window confirmed the dictionary representation. The author’s full-export partition reconciles to 418,714 distinct keys; we checked its arithmetic without repeating the full export. This resolves my original change request. AI-assisted CPU review.
…ts uses it (review on ItsNotRexed#4946) tools/manifest_stream.py holds the reader both census tools need, with one rule in one place: a decoded value is accepted only when a terminator (, } ] :, or whitespace) is visible after it or the file has ended; otherwise it is read on and decoded again from its start. That covers every split the reviews found (digits, ".", "e", signs) and split literals and strings (kacper-serewis). Members other than Items and Count are validated without being built: commas, colons, keys and brackets are checked while discarding (shdann's missing comma between skipped records), with memory bounded. tests/test_manifest_stream.py reads 8 valid documents at every read size from 1 to their length and requires json.loads' result, rejects 44 invalid ones at every read size, checks the reviewers' splits at the default 8 MiB read, and bounds memory for a large skipped member. Counts on the export are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Retested the three findings from my earlier review on |
…, coverage gaps (review on ItsNotRexed#4980) - rpf9dump writes a material binding's Name as its stored 32-bit name hash in eight hex digits; the census hashed those digits again, so the dictionary and embedded name matches were wrong (kacper-serewis, whattheflop). Stored hashes are now compared (joaat only for a name that is not eight hex digits), and embedded rows use their stored Hash. - Each reference is an exact 64-bit key match, else a 32-bit name-hash candidate (ambiguous when the hash is on more than one entry), else unresolved; the three add up, per-source counts are listed separately and can overlap. - A manifest Count above its rows is export coverage, not a problem; more rows than Count is (whattheflop). - --json: never inside the export folder, new path or existing; a different drive is outside (no commonpath ValueError); written with LF (shdann, tupacfan04, whattheflop). - A number cut at a read boundary ("1e" of "1e3") is read on before it is accepted (shdann). - docs/world.md:384 rewritten with the corrected run. Still 0 references match a levels.rpf dictionary entry; 50 share a hash with core_restofworld's or textures.rpf's dictionaries (42 also match a pool key exactly). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c6562aa to
f0d1c34
Compare
|
Head is now
AI-assisted. |
…mber for real (review on ItsNotRexed#4946) Python's json accepts NaN, Infinity and -Infinity, so the shared decoder let them through in skipped members and as metadata values (kacper-serewis). The decoder now rejects them, and six such documents join the invalid set that is checked at every read size. The default-read boundary test computed its padding from a different prefix than it wrote, so the boundary missed the number; it now pads from the exact prefix and asserts that the read ends inside the number, in both field orders. Counts on the export are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f0d1c34 to
27fb0f9
Compare
Same parser as render_buckets after review on ItsNotRexed#4946: top-level members parsed one by one, separators and the enclosing object checked. Numbers unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same change as render_buckets after review on ItsNotRexed#4946. Numbers unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, coverage gaps (review on ItsNotRexed#4980) - rpf9dump writes a material binding's Name as its stored 32-bit name hash in eight hex digits; the census hashed those digits again, so the dictionary and embedded name matches were wrong (kacper-serewis, whattheflop). Stored hashes are now compared (joaat only for a name that is not eight hex digits), and embedded rows use their stored Hash. - Each reference is an exact 64-bit key match, else a 32-bit name-hash candidate (ambiguous when the hash is on more than one entry), else unresolved; the three add up, per-source counts are listed separately and can overlap. - A manifest Count above its rows is export coverage, not a problem; more rows than Count is (whattheflop). - --json: never inside the export folder, new path or existing; a different drive is outside (no commonpath ValueError); written with LF (shdann, tupacfan04, whattheflop). - A number cut at a read boundary ("1e" of "1e3") is read on before it is accepted (shdann). - docs/world.md:384 rewritten with the corrected run. Still 0 references match a levels.rpf dictionary entry; 50 share a hash with core_restofworld's or textures.rpf's dictionaries (42 also match a pool key exactly). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e loop without candidates The private copy of the streaming reader is gone: texture_dicts imports tools/manifest_stream.py from ItsNotRexed#4946 (one reader, exhaustively tested at every read size), so the two tools cannot drift apart. summarise() only walks the dictionary archives when a reference has a name-hash candidate (shdann's performance note). Numbers on the export are identical. Depends on: ItsNotRexed#4946 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r's ItsNotRexed#4946 pattern) Manifest arrays read by the census must hold objects; a top level, model entry, material, texture or dictionary that is not one exits 2 instead of raising AttributeError. A non-string dictionary Name is no longer hashed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r names in the docstring (review on ItsNotRexed#4980) - A stored hash is ambiguous only when it is on more than one distinct texture (same 64-bit Key, or without a key the same format and size, is one texture); one texture embedded in several models no longer counts as ambiguous (tedin7). - Embedded must be absent, null, a list of objects or an object whose Textures is one; Materials {} / "" / 0 / false is an input error (LILILI2007). - The docstring says the counts are keyed by archive and pool folder names (cynbun, TheAnirudhan). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he count stays 2) (ItsNotRexed#4980) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3edfe79 to
6565b4a
Compare
…d, folder names in the docstring (review on ItsNotRexed#4980/ItsNotRexed#5067) - A name hash is a candidate when it is on one distinct texture (same usable Key, or without one the same format and size); one texture embedded in several models is no longer ambiguous (tedin7). - Embedded and Materials go through texture_dicts' strict readers, so {} / "" / 0 / false is an input error (LILILI2007). - The docstring says the output is keyed by archive and pool folder names (cynbun). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @tedin7, @cynbun (and @TheAnirudhan for the original finding). Fixed in
Tests: |
|
Follow-up on 6565b4a with an exporter-shaped synthetic dictionary fixture. Two rows at separate dictionary offsets had the same stored name/hash, null Key, 4x4 dimensions and BC1_UNORM format. Both DDS files were valid. The decoder returned solid red for one and solid green for the other. Adding the second row kept the result at 1 candidate and 0 ambiguous. #5067 at daa3ff3 reproduced that classification in its slot report. The keyed repeat control still counted one candidate as intended. Changing the second keyless row's dimensions made both tools report ambiguity. Exact pool and embedded keys continued to take precedence over ambiguous name-hash fallback. Matching format and dimensions establishes a metadata group. The rows in it can represent distinct textures. Could the report and docs describe the result as one matching metadata group with unknown texture identity, or surface the multiple keyless rows as uncertain? This fixture does not establish a change to the published full-export counts. The 19 census tests passed on both snapshots. Windows, uv CPython 3.12.13, synthetic CPU inputs. AI-assisted. |
…mat and size is uncertain (review on ItsNotRexed#4980) Keyless rows with the same format and size form one metadata group, but they can be different textures (whattheflop). Such a candidate is now counted as "uncertain" instead of a clean match. On the full export none of the 8 candidates is uncertain (2 stay ambiguous). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d, folder names in the docstring (review on ItsNotRexed#4980/ItsNotRexed#5067) - A name hash is a candidate when it is on one distinct texture (same usable Key, or without one the same format and size); one texture embedded in several models is no longer ambiguous (tedin7). - Embedded and Materials go through texture_dicts' strict readers, so {} / "" / 0 / false is an input error (LILILI2007). - The docstring says the output is keyed by archive and pool folder names (cynbun). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s of one format and size as uncertain (review on ItsNotRexed#4980) Same rule as texture_dicts (whattheflop): such rows form one metadata group but can be different textures. On the map none of the 35 candidates is uncertain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent retest at a1e701e, AI-assisted. The original pair of distinct keyless DDS files with equal metadata now reports one uncertain candidate. Combining two matching hashes with equal keyless metadata also reports one uncertain candidate. Different metadata groups still report ambiguity, same-key repeats stay a single ordinary candidate, and both exact-key controls retain precedence. The synthetic two-archive report also reconciled: seven distinct keys overall, two exact, four name-hash candidates (one ordinary, one ambiguous, two uncertain), and one unresolved. One key with an ordinary candidate in each archive becomes uncertain when the overall report combines their hashes. All 20 census, 23 render-bucket and 5 manifest-reader tests passed on Windows with uv CPython 3.12.13. Synthetic CPU inputs only. This resolves the keyless finding here. The dependent slot branch's separate behavior is recorded on #5067. |
|
Thanks @whattheflop, agreed: matching format and size only makes a metadata group, and the rows in it can be different textures. Fixed in
Full export: nothing moves. #4980 still has 8 candidates, 2 ambiguous and 0 uncertain. #5067 has 35 candidates on the map, 0 of them uncertain. |
…s an uncertain candidate again, as in texture_dicts 71e8636 made two matching hashes ambiguous, but texture_dicts (ItsNotRexed#4980, a1e701e) reports one keyless metadata group reached through two hashes as an uncertain candidate, and whattheflop confirmed that rule on both tools. This restores it; two metadata groups stay ambiguous. The test covers both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isfcrctfs
left a comment
There was a problem hiding this comment.
Read the PR's own three files at a1e701e (the rest of the range is #4946, which this branch carries): tests/test_texture_dicts.py 20 OK (1 skip), tests/test_manifest_stream.py 5 OK, tests/test_render_buckets.py 23 OK, and the ten test_docs_* files OK at this head. I cannot reproduce the corpus numbers in docs/world.md without an export, but they are arithmetically self-consistent with the tool's categories (296,789 + 8 + 121,917 = 418,714; 296,785 + 137 - 133 = 296,789; 38 + 12 = 50 keys share a dictionary hash, 42 of them exact, leaving 8 candidates).
One defect: a texture-dictionary or pool manifest whose top-level Count is not an integer crashes with a traceback instead of the tool's input error. iter_items ignores a non-integer Count for models manifests (_is_count accepts only int), but census passes json.load's value straight to check_count, which compares rows > declared:
mkdir -p /tmp/e/lv/textures
printf '{"Count": "3", "Items": []}' > /tmp/e/lv/textures/manifest.json
python -I tools/texture_dicts.py /tmp/e # TypeError: '>' not supported between 'int' and 'str'; exit 1
Same on the pool path (ttpf/<pool>/manifest.json with {"Count": "2", "Textures": []}, line 218). This should exit 2 with invalid manifest JSON, like the other fourteen malformed shapes in test_non_object_entries_exit_2; validating declared as int and not bool in check_count would make the two paths agree with the shared reader.
Minor: read_all() (texture_dicts.py:43) is unused (CHUNK is re-exported for the tests and is still used there); read_all is not.
AI-assisted.
|
Thanks @isfcrctfs. The
|
Depends on: #4946 (this branch now builds on its shared
tools/manifest_stream.py).ASSET-397, claimed in the coordination issue: #4933 (comment)
What and why
docs/world.md:384said no.#tdsystem page was found in the sampledlevels.rpfwindows, and that world textures are the loose RDS5 pools plustextures.rpf. This PR measures both points over a full asset export and rewrites the bullet with the counts. It also says what the counts do and don't establish.tools/texture_dicts.py(stdlib,python -I) reads amake_game.pyexport, enumerating everything withos.listdir:<archive>/textures/manifest.json(rpf9dump textures). Dictionary and texture counts are checked against each manifest'sCount. It also reports single-texture and empty dictionaries, distinct hashes, formats, the offset band, the offset position within a 4 KiB page, and whetherHash == joaat(Name).ttpf/<pool>/,ttpf_pack/<pack>/<pool>/), each checked against itsCount.<archive>/models/manifest.json. These are streamed item by item, since the levels manifest is several GB, and include the textures embedded in models.Each distinct material texture key (
Id64) is an exact 64-bit key match (poolAssetKeyor embeddedKey), else a 32-bit name-hash candidate, else unresolved; the three add up to the total, and per-source counts (which overlap) are listed too. Name hashes are compared as stored:rpf9dumpwrites a material binding'sNameas its stored name hash in eight hex digits (NameHash.ToString("X8")), and dictionary and embedded rows carry a storedHash(corrected inc6562aa0after review; the first version hashed the hex digits again). A candidate is ambiguous when its hash is on more than one entry. Output is counts only, and--jsonmay not be inside the export folder (another drive counts as outside).Result on my own Xbox Series 1.0.2.1 copy
levels.rpfdictionaries: the export's full page+16 scan (rpf9-explorer's texture recovery) finds 23,180 candidates and recovers 1,009 texture dictionaries, holding 1,013 textures. Every offset sits at page+16, all of them at 70.80-70.92 GiB, inside the tail window thatworld.mdlists as sampled. Their 1,013 textures have only 9 distinct name hashes, and 1,008 of the dictionaries hold a single texture.Hash == joaat(Name)holds for all 1,013, and none has a 64-bit key.textures.rpf: 1,356 dictionaries with 4,604 textures and 1,972 distinct hashes, at 0-0.18 GiB, all at page+16.c6562aa0): 382,781 models, 20,781,927 bindings (all with the stored hex hash), 418,714 distinct keys. 296,789 match exactly by 64-bit key (296,785 a poolAssetKey, 137 an embeddedKey, 133 both), 8 only by a 32-bit name hash in a dictionary (2 ambiguous), and 121,917 (29.1%) match nothing. 50 keys share a hash with a dictionary entry (38 incore_restofworld's dictionaries, 12 intextures.rpf's; 42 of them also match a pool key exactly), and none shares a hash with alevels.rpfdictionary entry. The first version reported 0 dictionary matches and 121,925 unresolved because it hashed the stored hex names again; the old-vs-new table is in the PR thread.Limits, stated plainly
.#tdlink not established: whether these 1,009 dictionaries are what a.#tdentry name would label can't be told until the RPF9 directory is decoded. The earlier note doesn't record how.#tdpages were looked for. So the doc says "standalone texture dictionaries found by the full scan", not "the.#tdpages exist after all".world.mdwording: the earlier sentence "World textures ... plustextures.rpf" is replaced by what was measured: the material textures that resolve exactly come from the 57 pools and a few embedded textures;textures.rpf's andcore_restofworld's dictionaries only share name hashes with 50 keys, andlevels.rpf's with none.Tested
Windows 11, Python 3.13, CPU only:
python -I tests/test_texture_dicts.py: 16 tests, OK (synthetic exports: dictionary statistics, pack pools, stored-hex name hashes vs a decoy, an ambiguous hash, exact vs candidate vs unresolved, coverage gaps vs impossible counts, dot-named archives, the read boundary, the report guard incl. a repeat write and other drives, LF output, no names in the output). The shared reader from models: render buckets over the whole export (ASSET-396) #4946 (tools/manifest_stream.py) has its own exhaustive tests.tests/test_docs_links.py,tests/test_tool_startup.pyandtests/test_docs_design_rows.py: OK.git diff --checkis clean.python -I tools/texture_dicts.py <export dir> --json <report>: about 2 min, exit 0, with noCountmismatch in any manifest.docs/world.mdnear this bullet (the nearest are world_build: place interior (MLO) entities (--interiors, ASSET-127) #1981 at 354-361 and world: resolve InteriorNames keys to interior archetypes and placements (ASSET-275) #3813 from 400). tex_headers: decode texture dictionary system pages and verify DXGI formats (ASSET-274) #3491 (textures.rpfpage decoding intools/tex_headers.py,docs/textures.md) isn't touched.No game data in the PR: synthetic fixtures only, and counts only in the doc. AI-assisted.
🤖 Generated with Claude Code