Repository navigation
Conversation
…at reads world and view-projection (TEST-523) The default pair's VS applies no matrix, so first light was an orthographic fit. --camera uses VS_TransformVT_e6ebb353_Wrapped instead. That VS reads a descriptor table at s9, whose V#s point at a world matrix (table + 0x20) and a view-projection (table + 0x60, rows at 0x160). The tool builds a camera, writes the matrices, V#s and table into vk_harness's heap (VKH_HEAP, VKH_SGPRS), and predicts the image with the same float32 matrices, interpolating UV perspective-correctly. The manifest keeps the constants, so --check and tests/test_first_light.py draw the same way. The output goes to <work>/first_light/camera, so the folder d3d12_first_light_test reads is untouched. Apple M4 (MoltenVK 1.4.2), the section 1 model at 128x128: - coverage 6,851/16,384, with the centre, four probes and the clear corner as predicted; - a 32x32 grid agrees on coverage 1,024/1,024 and on UV 428/428 within 2e-3; - no constants, or a camera 2 degrees off, is rejected. AI-assisted.
…ams reads the archive in a bounded window fvf_layouts.py reuses the skin_streams walk (new on_mesh hook), histograms the (slot, size, format) layouts of non-skinned geometries and tests unit-length decodings per slot to find the NORMAL stream. skin_streams now reads through a seek+read block cache instead of mapping the whole archive (a 76 GB archive filled RAM), and names format byte 24 (R10G10B10A2_UNORM, measured as unit-length normals). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…EST-525) --camera now reads where the VS keeps its constants from the VS's own disassembly (table SGPR, V# offsets, view-projection offset, optional packed colour dword) instead of one hard-coded layout, and rejects a VS that does not fit. A constant-colour VS is checked exactly against the CPU prediction with a certain/possible coverage mask. tools/first_light_prop.py picks the prop by rule from the multi-GB models manifest by streaming it. docs/first_light.md section 7 records the prop (counts and OBJ SHA-256), the pair and the results. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e, table-pointer provenance) Fixtures rewritten with their own registers and order; the docs no longer quote a listing line or print hashes. check_image is NaN-safe and requires an edge-band pixel to be the clear value or the constant. constant_layout refuses a table pointer or copy whose source SGPR an earlier instruction wrote, and accepts the colour at 0x3C. The unreachable --colour message is reworded, EDGE_BAND's 8-bit subpixel assumption is documented, and Window gets a BytesIO test for block-straddling reads and the 1 MB find_zlib step. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
AI-assisted independent CPU review of Four hand-built matrix VS listings passed. I varied the table-pointer copy depth (zero, one, and two moves), descriptor order and offsets, the view-projection offset (including zero), and the packed-colour row (absent or at world +0x0C, +0x1C, or +0x3C). For each I checked the exact SGPR vector, both descriptors, all 40 heap dwords, and the row-vector transform read back from those words. An independent half-float lookup agreed with the CPU colour calculation for every byte value in each RGBA lane. Stock results were 28 pass / 3 package-gated skips for One scope issue with ?any fitting VS? in the description. Starting with the passing two-hop case (entry s7, world V# +0x34, view V# +0x88, view matrix +0x98, colour +0x0C), I copied the loaded colour dword from s39 to s66 after the scalar wait and changed the four byte conversions to read s66. Separately, I copied the loaded world coefficient from s36 to s67 and changed its multiply to read s67. Both variants round-tripped through LLVM and preserve the loads and arithmetic. Both exit in |
…inter check The "source written before the copy" refusal now applies only to the copy chain that feeds a table pointer (the s_load check refuses a non-user pointer). A copy of any other written SGPR only marks its destination written, and a copy of a loaded constant keeps its (V#, offset), so a colour read through a copy is still found as the colour. Tests for both copy variants. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @whattheflop, a real limitation, fixed in ee6da9c. The earlier-write refusal now applies only to the chain that feeds the table pointer (a user SGPR and its copies). A copy of anything the VS wrote just marks its destination as written. A copy of a loaded constant keeps the buffer and offset it came from. So your variant (a), the colour dword copied and unpacked from the copy, is still found as the colour. Your variant (b), a world coefficient read through a copy, leaves the match unchanged.
AI-assisted (Claude Code). |
|
Tested 20cf40e on Windows, desktop RTX 5070, NVIDIA 616.56. AI-assisted independent retail validation; #2855 dependency included at 84bf712. The same locally exported 942-triangle prop passed four native Vulkan draws: two camera yaws (30 and 75 degrees) and two packed colours. Each image was checked against the CPU certain/possible masks and independently decoded expected colour/clear values. All four passed; all 12 checks against another run's expectation failed. Changing only colour preserved coverage, while changing yaw changed 1,488 pixel positions. Both modules passed spirv-val and the pair passed shader_link_check. Draw logs with Khronos validation requested contained no VUIDs, validation warnings or errors. python -I tests/test_first_light.py passed 31/31 with the render directory configured, including fresh replay/CLI checks; test_skin_streams.py passed 28/28. This exercises a second prop from a bounded local export, not the full-package selector ranking. Source archive hashes were outside this run. Raw artifacts stayed private. The matcher restrictions raised in the preceding CPU review are outside this validation's scope. |
|
AI-assisted independent CPU follow-up at |
Kam471
left a comment
There was a problem hiding this comment.
The constant-layout logic fits the claimed sga_dr layout (table_sgpr=8, world_vsharp=0x0, view_vsharp=0x40, viewproj=0x160, colour_offset=0xC), and tests/test_first_light.py runs 31 OK, 3 skipped. But the fixture required by TEST-525 is not there:
- All 18 new cases are hand-written;
PropRuleTestscalls onlystream_items/qualifies/rank, neverpick()/has_uv(). - There is no real minimal prop OBJ/listing fixture. A 70-item synthetic repro shows
pick()can return[]after trimming even when a valid UV OBJ exists. - The docs say 27 cases while 31 run, and the body says section 7 records the OBJ SHA-256 while the docs say it does not.
Please add a real minimal prop path (or generate one from the manifest), test pick()/has_uv() against it, and correct the counts/SHA-256 statements. The documentation-only prop totals (543 vertices / 1,000 triangles; 4,174 of 149,811 candidates) are unverifiable here without the game manifest.
…test pick() end to end pick() trimmed its bounded front of the ranking before checking that an OBJ exists and has UVs, so 34 or more unusable top-ranked items hid a usable one ranked below them (Kam471's review). The trim now keeps the first usable items in rule order, so a dropped item can't be among the best. Tests: a box built in the test (588 triangles, UVs) goes through the manifest, pick(), the CLI line, read_obj and the coverage masks, past two higher-ranked decoys without UVs or without a file; 70 candidates with only the last two usable check the trim. The doc's case count is now the suite's (36, 3 package-gated). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @Kam471, the trim bug is real. Fixed in 360e4d7 and 5320ee1:
On the SHA-256: the body says the prop's name and hash stay on the user's machine. AI-assisted (Claude Code). |
|
@Pipodi heads-up: #2855 is rebased onto
AI-assisted. |
|
@Pipodi another heads-up: #2855 is rebased again, onto
If your prop path calls |
One harness_env (with ItsNotRexed#2855's text): the mesh path from manifest files, camera constants and the TEST-524 texture; --camera with --dds exits 2. first_light.md follows ItsNotRexed#2855's order (texture 6, camera 7, prop 8).
|
Merged main
|
|
Reviewed 605bb7d merged onto main de67135 on Linux (CPU only): questions Ran (python3.13 -I -m pytest -q): tests/test_first_light.py tests/test_skin_streams.py plus tests/test_ci_registration.py, test_docs_links.py, test_text_encoding.py: 117 passed, 4 skipped (the package-gated cases), 47 subtests passed. Merges cleanly into main. Read the full diff of tools/first_light.py (constant_layout, camera constants, coverage masks), tools/first_light_prop.py, tools/fvf_layouts.py, tools/skin_streams.py and the tests. The GPU numbers in docs/first_light.md section 8 (1,946 covered pixels on an RTX 4090) are not reproducible on this CPU-only pass and were not checked. Tried to break it:
Findings:
No blocking defect found in the CPU-checkable code. No game files. |
Conflicts in docs/first_light.md and tools/first_light.py: kept ItsNotRexed#2855's textured path, OBJ parsing and stage/stem lookup; our generalised --camera layout, --colour and prop path stay on top (section numbers 7 camera, 8 prop, 9 limits). Dropped the stale ~1 limit (ItsNotRexed#2855 no longer has it) and the duplicate copy of CameraTests that ItsNotRexed#2855's old version added at the end of the test file.
…; cite section 8 stream_items raises a message naming rpf9dump's layout when an item opens at another indent or a manifest with content has no items. Fixes the section reference (the rule is section 8) in the tool and first_light.py, and updates the test count in docs/first_light.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested 605bb7d merged with main 98fa503 on Linux (Python 3.12.16): pass. test_first_light.py, test_first_light_bad_json.py, test_first_light_harness_paths.py, test_first_light_mesh_draw.py and 2 more; the four tests/test_docs_*.py 10/10 ok. Negative control with main's |
|
Thanks @tedin7, all three points are addressed at 6a76c7c:
The section 8 draws re-run on the RTX 4090 at this head give the same 1,946 covered pixels with all three VS. Thanks also @kapitche for the Linux run. Both are in the Tested section. AI-assisted (Claude Code). |
|
Tested on Windows 11 / Python 3.12.10 at head SHA
AI-assisted review (Gemini 4 Neon). |
|
Reviewed and tested The delta since the reviewed Blocking:
All five fail with Smaller points
Otherwise. At the PR head, AI-assisted. |
next_stream falls back to ZHDR.search for bytes and mmap (anim_glb, fragment_children), an empty Items array is the 'no drawable' path rather than a format error, --limit below 1 is rejected, tests for next_stream, fvf_layouts and scan_archive on_mesh, and the stale case count is dropped from the doc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ty too (review) rpf9dump models writes ModelDecodeFailures after Items, so the line is ' "Items": [],'. Test with that layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @KkelebekK, all of it is addressed at eb6f235 (current
AI-assisted (Claude Code). |
Desamodeth
left a comment
There was a problem hiding this comment.
Verified the mmap repair on Windows at eb6f2354. All 32 anim_glb, 19 fragment_children and 51 skin_streams tests passed.
One prop-selection bug remains. I wrote a synthetic manifest using the exporter's indented .NET Utf8JsonWriter and JsonSerializer. The 1,000-triangle OBJ named café.obj appears in JSON as caf\u00E9.obj. The picker strips the quotes but leaves the escape literal. With that OBJ alone the CLI reports no matching drawable. With a qualifying 1,100-triangle ASCII-named OBJ alongside it, the CLI silently picks the runner-up. Decoding the File string with json.loads(value) preserves streaming and selects the correct path and SHA-256 in both cases.
The existing test_tool_stdout_encoding.py also fails on the two new CLI entry points. With the filename fix alone I reproduced a UnicodeEncodeError piping the selected path on a CP1251 Windows system. The patch below uses the same stdout guard as first_light.py. With the patch, the three CLI controls passed and the five focused suites had 159 passes and eight skips. No GPU or game files used. AI-assisted.
Tested patch
diff --git a/tests/test_first_light.py b/tests/test_first_light.py
index 08147d04..fc1f4d06 100644
--- a/tests/test_first_light.py
+++ b/tests/test_first_light.py
@@ -652,6 +652,16 @@ class PropRuleTests(unittest.TestCase):
passing = sorted((p for p in parsed if prop.qualifies(p)), key=prop.rank)
self.assertEqual([p["File"] for p in passing], ["h.obj", "i.obj", "g.obj"]) # 900 and 1100 tie; name breaks it
+ def test_pick_decodes_the_exported_obj_filename(self):
+ import first_light_prop as prop
+
+ with tempfile.TemporaryDirectory() as tmp:
+ root = Path(tmp)
+ (root / "caf\u00e9.obj").write_text("vt 0 0\n", encoding="utf-8", newline="\n")
+ manifest = '{\n "Items": [\n' + self.item(r"caf\u00E9.obj") + "\n ]\n}\n"
+ (root / "manifest.json").write_text(manifest, encoding="utf-8", newline="\n")
+ self.assertEqual([row["File"] for row in prop.pick(tmp)], ["caf\u00e9.obj"])
+
def test_a_reindented_or_compact_manifest_is_a_format_error(self):
import first_light_prop as prop
diff --git a/tools/first_light_prop.py b/tools/first_light_prop.py
index 4ae73f07..6189cc51 100644
--- a/tools/first_light_prop.py
+++ b/tools/first_light_prop.py
@@ -16,6 +16,7 @@ from __future__ import annotations
import argparse
import hashlib
+import json
import os
import sys
@@ -65,7 +66,7 @@ def stream_items(lines):
array = key
item[key] = []
elif key in SCALARS:
- item[key] = value.strip('"') if key == "File" else {"true": True, "false": False}.get(value, value)
+ item[key] = json.loads(value) if key == "File" else {"true": True, "false": False}.get(value, value)
if key in ("Meshes", "Verts", "Tris"):
item[key] = int(value)
if seen_content and not seen_items:
@@ -149,4 +150,8 @@ def main(argv=None) -> int:
if __name__ == "__main__":
+ try:
+ sys.stdout.reconfigure(errors="replace")
+ except (AttributeError, ValueError, OSError):
+ pass
sys.exit(main())
diff --git a/tools/fvf_layouts.py b/tools/fvf_layouts.py
index e3f42177..470adfa5 100644
--- a/tools/fvf_layouts.py
+++ b/tools/fvf_layouts.py
@@ -133,4 +133,8 @@ def main(argv=None):
if __name__ == "__main__":
+ try:
+ sys.stdout.reconfigure(errors="replace")
+ except (AttributeError, ValueError, OSError):
+ pass
sys.exit(main())…rd on the new CLIs Review by Desamodeth: stream_items left JSON escapes (é, \) literal in the File value, so an exported non-ASCII OBJ name was not found. Decode it with json.loads (still streaming). Adds their test plus an escaped backslash/quote case. tests/test_tool_stdout_encoding.py failed on tools/first_light_prop.py and tools/fvf_layouts.py; both __main__ blocks now reconfigure stdout with errors='replace' exactly as first_light.py does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r writes
The manifest line held the letter itself, so the test passed with the old strip('"') too. It now holds the JSON escape, and fails on eb6f235.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @Desamodeth, both fixed at cb25fc4:
AI-assisted (Claude Code). |
Desamodeth
left a comment
There was a problem hiding this comment.
Retested cb25fc4a on Windows using the same manifests written by .NET’s indented Utf8JsonWriter and JsonSerializer. The CLI selected café.obj both alone and alongside the 1,100-triangle ASCII runner-up. The selected SHA-256 matched the actual file. All three cases, including the ASCII control, exited zero with redirected output in UTF-8 and the Windows ANSI code page. The five focused suites passed (160 passed, eight skipped), including the stdout checks for both tools. Both findings from my previous review are resolved. CPU only, synthetic data. AI-assisted.
kacper-serewis
left a comment
There was a problem hiding this comment.
Native Windows RTX 5070 (616.56) at eb6f235, including #2855 bc79b55: the normal selector chose a cached 998-triangle levels prop. Both shaders translated and validated. Both colours covered 1,977/16,384 pixels and passed their own oracle. Changing only the colour caused the original oracle to reject an interior pixel. This was a different prop from the documented 1,000-triangle fixture and predates cb25fc4. AI-assisted.
|
Thanks @Desamodeth for the retest, and @kacper-serewis for the native RTX 5070 run. Both are in the Tested section now. A prop other than ours, picked from a different cache, giving matching coverage for both colours plus a rejected colour swap, is a useful independent check of the oracle. AI-assisted (Claude Code). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
No game files. AI-assisted (Claude Code). |
Claimed in the coordination issue as: TEST-525 (#2716 (comment); split with @toeeshchaudhary, whose #2766 is the harness half)
Depends on: none. #2855 (TEST-523,
--camera), which this built on, has merged; main is merged in at e563766, so the diff is our 7 files.AI-assisted: yes (Claude Code).
What and why
First light now draws a world prop from
levels.rpfthrough a gamesga_dr_*vertex shader that applies its own world and view-projection matrices. Until now it drew the §1 model through a VS that only passes positions through.constant_layout()intools/first_light.pyreads the VS listing and finds which user SGPR holds the table pointer (followings_mov_b32copies, with the high half zeroed). It also finds which table offsets hold the world and view-projection V#s, where the view-projection sits in its buffer, and, if present, the dword holding a packed colour constant.CAMERA_*constants become a derived case: itsVS_TransformVT_e6ebb353gives the same s9 / +0x20 / +0x60 / 0x160 layout as before, and a test pins that.sga_dr_vs_pos_tex_90997d1bgives s8 / +0x00 / +0x40 / 0x160 plus a colour at world+0x0C.--camera --vs <any fitting VS>now works, and--coloursets the packed constant (default0xC0C08040).tools/first_light_prop.py). It streams the multi-GB models manifest line by line.subPixelPrecisionBits; a 4-bit device needs about 1/32 px, and the doc says so.tools/fvf_layouts.py, a layout histogram oflevels.rpfwith a unit-length probe per slot. The counts are on the board (Coordinating who works on what (14) (moved to #3047) #2891, 7083960356).tools/skin_streams.pynow reads the archive through a bounded seek/read window with an 8 MB block cache instead of mmapping it whole. The mmap reached a 22 GB working set over a network share.docs/first_light.md§7 covers the prop rule, the pair, the layout derivation and the results. The "world prop" bullet leaves the limits (now §8). Quantized position formats and the COLOUR/NORMAL VS families are listed there as untested.Pair:
#sga_dr_vs_pos_tex_90997d1b_Wrappedwith first light's default PS ($PS_Rage_Untextured_14f8529b_Wrapped). It passesshader_link_check.py checkandspirv-val. This VS writes the packed colour constant to param0, with the UV in param1. So the default PS, which writes param0, gives a constant-colour image rather than a UV map, which makes an exact colour oracle possible. Texture sampling is TEST-524's (#2906) and is not touched here.Finding, not fixed here: with alpha 0xFF, 905 of the 1,946 covered pixels read 0.99951 instead of 1.0. Interpolating a constant 1.0 gives 1.0 − 1 ulp, and the round-toward-zero f16 pack then drops it one f16 step. The other three channels were exact. The default colour avoids that f16 boundary, and the doc records it.
Tested
RTX 4090, NVIDIA 617.42, Windows 11; own 1.0.2.1 copy; LLVM 23.1.5. Branch merged with
main1628210.first_light.py --camera --vs '#sga_dr_vs_pos_tex_90997d1b_Wrapped'on the picked prop, then--check: 1,946 / 16,384 covered (prediction: 1,794 certain, 1,953 possible). The centre (64,64) is bit-exact(0.2509766, 0.5019531, 0.7529297, 0.7529297), the clear corner stays clear, and no covered pixel differs from the constant. 159 edge-band pixels are each exactly clear or the constant.Cross-checks:
sga_dr_vs_pos_feff6b5f+sga_dr_ps_feff6b5fcovers the same 1,946 pixels with the same constant, and first_light --camera: the model in perspective through a game VS that reads world and view-projection (TEST-523) #2855's e6ebb353 on the same prop passes first_light --camera: the model in perspective through a game VS that reads world and view-projection (TEST-523) #2855's UV oracle.Negative controls are all rejected: no constants (the harness fails), table SGPR 0 (coverage 0), wrong expected channel.
python -I tests/test_first_light.py: 31 tests OK, 3 skipped without the GPU output. WithLEONIDA_FIRST_LIGHT_DIRandLEONIDA_VK_HARNESSset it is 31 OK, 0 skipped. The new unit tests need no game files: layout derivation on hand-written listings, error cases, register provenance, and colour-oracle fixtures (garbage and NaN edge pixels, NaN outside the mask).python -I tests/test_skin_streams.py: 28 OK, including theWindowreads across a block boundary and the 1 MBfind_zlibstep onio.BytesIO.python -m compileall -q make_game.py tools tests,python -I make_game.py --helpandpython -I tests/test_text_write_line_endings.py: OK.No translator change, so no corpus run.
Re-run at 6a76c7c (after merging first_light --camera: the model in perspective through a game VS that reads world and view-projection (TEST-523) #2855's current head bc79b55), same GPU: the prop pick is the same mesh (543 vertices, 1,000 triangles);
sga_dr_vs_pos_tex_90997d1b,VS_TransformVT_e6ebb353(UV oracle) andsga_dr_vs_pos_feff6b5f+ its PS each PASS with 1,946 covered and 159 edge pixels, as above.tests/test_first_light.py: 49 OK (3 skipped without the GPU output, 0 with it). The runtime C++ is unchanged by the merge.Independent CPU reviews of 605bb7d merged onto
main, Linux: @tedin7 (comment: 117 passed, plus a 25-manifestpick()comparison against brute force with 0 mismatches) and @kapitche (comment: pass).After @KkelebekK's review (comment), at eb6f235 (
main3faac55 merged):next_stream()takes abytes/mmapagain (oldZHDR.searchpath when there is nofind_zlib), sotests/test_anim_glb.py32 OK andtests/test_fragment_children.py19 OK; an empty"Items": [](also followed byModelDecodeFailures, asrpf9dump modelswrites it) reports "no drawable passes the rule";--limitbelow 1 is rejected; census tests added.tests/test_first_light.py60 OK (7 skipped without package/harness),tests/test_skin_streams.py51 OK,test_anim_skel_match.py,test_ci_registration.py,test_text_write_line_endings.pyand the 10tests/test_docs_*.pyOK.After @Desamodeth's review (review), at cb25fc4: the manifest's
Filestring is JSON-decoded, so an exporter-escaped name (é,\\,\") is picked and hashed correctly (tests fail on eb6f235); both new CLIs have the stdout guard, sotests/test_tool_stdout_encoding.pyis OK.tests/test_first_light.py62 OK (7 skipped).Independent runs: @Desamodeth retested cb25fc4 on Windows (review) with .NET-written manifests: the escaped
café.objis picked alone and next to an ASCII runner-up, the picked file's SHA-256 matches, and redirected output works in UTF-8 and the ANSI code page (160 passed, 8 skipped). @kacper-serewis ran it natively on an RTX 5070, NVIDIA 616.56, at eb6f235 (review): from their cache the selector picked a different, 998-triangle prop, both shaders translated and validated, both colours covered 1,977 / 16,384 pixels and passed their own oracle, and changing only the colour made the original oracle reject a pixel.Checklist
docs/design.md, with how it was confirmed. N/A: no translator change.🤖 Generated with Claude Code