Skip to content

First Light: replay custom vertex layouts and validate packed meshes - #2766

Open
toeeshchaudhary wants to merge 3 commits into
ItsNotRexed:mainfrom
toeeshchaudhary:codex/first-light-custom-mesh
Open

toeeshchaudhary wants to merge 3 commits into
ItsNotRexed:mainfrom
toeeshchaudhary:codex/first-light-custom-mesh

Conversation

@toeeshchaudhary

Copy link
Copy Markdown
Contributor

Groundwork for TEST-525. Replay takes the mesh filename and float vertex layout from the manifest. The harness checks the file size and index bounds before Vulkan initialization. Windows g++ build passed. Three malformed mesh cases were rejected. Five Python tests passed and three GPU integration tests were skipped. AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of 3d311342 (I didn't run it). Looks right. read_mesh now requires the file to be exactly 8 + vcount·stride + icount·4 bytes and every index to be < vcount, and it runs before any Vulkan setup, so a malformed mesh is exit 2 rather than an out-of-bounds draw. first_light.py falls back to mesh.bin and 0:3f,1:2f for manifests without the new fields, and new manifests write vertex_layout explicitly, so old and new outputs both replay.

AI-assisted review (Claude Code).

@Desamodeth Desamodeth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_draw_matches_the_manifest still passes mesh.bin and 0:3f,1:2f to the harness. On 3d311342, a prepared draw using prop.bin and 0:3f,1:3f,2:4f,3:2f passed the real first_light.py --check CLI, then failed the direct replay test because the test requested a nonexistent mesh.bin.

With the two-line change below, all eight tests passed for each of two manifests (legacy and custom). I used a CPU-only harness stand-in on Windows that checked the selected packed mesh and stride and returned synthetic readback. Rendering was outside this check. AI-assisted with Codex Astra 6.2 High.

diff --git a/tests/test_first_light.py b/tests/test_first_light.py
index 00cc5699..3b44c57c 100644
--- a/tests/test_first_light.py
+++ b/tests/test_first_light.py
@@ -92,8 +92,8 @@ class FirstLightTests(unittest.TestCase):
             )  # a fresh run: a harness that writes nothing cannot pass on a stale file
         env = dict(
             os.environ,
-            VKH_DRAW_MESH=os.path.join(self.out, "mesh.bin"),
-            VKH_VERTEX_LAYOUT="0:3f,1:2f",
+            VKH_DRAW_MESH=os.path.join(self.out, self.manifest.get("files", {}).get("mesh", "mesh.bin")),
+            VKH_VERTEX_LAYOUT=self.manifest.get("vertex_layout", "0:3f,1:2f"),
         )
         subprocess.run(
             [

@whattheflop

Copy link
Copy Markdown
Contributor

AI-assisted independent Windows GPU verification for the synthetic mesh-replay groundwork under TEST-525.

I built the stock vk_harness at 3d311342ebb4a5a0b0181a099a977f9aa7558251 against base ec8ec4c9a46c6623f1a9c125afd3566da97f1e0c with MSVC x64 19.38.33145, Windows SDK 10.0.26100.0, and Vulkan SDK 1.4.363.0. The stock build was compile-only because it lacks the host readback barrier. GPU replay used the clean prospective merge tree a7f0c19fcd5d2d04b3760ec2a140ff1464282c92 with #2635 at 458c21946d150c28dacddc105f84dba33994fd94. The tree adds only #2635's barrier diff.

Using uv CPython 3.12.13, first_light.py --check passed both the legacy manifest defaults (mesh.bin, 0:3f,1:2f, 20-byte stride) and a generated packed-prop.bin with 6:2f,4:2f,1:4f,3:2f (40-byte stride, offsets 0/8/16/32). The custom VS consumed the two padding fields. Both VS inputs matched their layouts, and all three synthetic modules passed Vulkan 1.2 spirv-val.

RTX 3080 (616.64) and Radeon iGPU (32.0.21030.2001) each matched the CPU barycentric oracle on all 512 RGBA32F pixels per draw. Coverage was 124/512 legacy and 144/512 custom on both GPUs. Clear pixels and covered B/A matched exactly, and maximum absolute UV error was 1.40e-7. All four runs were serial with a 30-second deadline, one native ICD per process, an empty implicit-layer path, and Khronos 1.4.363 core and synchronization validation confirmed active with zero validation errors or warnings.

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested 3d31134 on Steam Deck LCD (AMD Custom GPU 0405 "Van Gogh" / RDNA2, RADV Mesa 26.2.0-devel, Vulkan 1.4.350, SteamOS 3.9.5): pass (Python tests).

  • PYTHONPATH=.:tests:tools python3 tests/test_first_light.py — 8 tests, 5 ran, 3 skipped, OK.

Caveat: I did not rebuild runtime/test/vk_harness.cpp from this PR in a PR-specific runtime build on Deck, so the C++ harness change was not exercised by a compiled GPU run here; only the Python-side coverage in tests/test_first_light.py was verified.

AI-assisted (OpenCode).

@sh1shu1

sh1shu1 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

3d31134 no longer merges with main (98fa503): tests/test_first_light.py and tools/first_light.py conflict, and the vk_harness.cpp hunk merges but predates the host-readback barrier of #2635, so a readback needs the rebase. Desamodeth's two-line fix above (the test taking the mesh and layout from the manifest) still applies.
AI-assisted (Claude Code, Claude Fable 5.1).

@ray3242

ray3242 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

BUILD-804 independent readback review — claim. Finished; no competing PR from me.

Setup: PR head 3d311342 no longer merges into current main (as @sh1shu1 noted); I merged locally to 1e8e2c0f, resolving the two conflicts by keeping main's harness_env() and applying the PR's manifest-driven layout as an override, and keeping both import sets in tests/test_first_light.py. Built vk_harness from that tree.

Environment (AI-assisted, OpenCode): Windows 11 Pro 26300, NVIDIA GeForce GTX 1060 6GB / driver 582.78 (Vulkan 1.4.312, subgroup 32..32, no ReBAR), MSVC 19.44.35230, CMake 4.4.4 + Ninja, RelWithDebInfo, Python 3.12.10. No game data, keys or decryption; all inputs synthetic.

Readback: asymmetric synthetic triangle (-0.85,-0.75), (0.95,-0.55), (-0.30,0.90), packed into a 12-byte-stride mesh, with a deliberately non-default manifest vertex_layout: "0:3f" — so the draw only succeeds if the PR's manifest layout is actually used. python -I tools/first_light.py --check --out ... --harness <vk_harness> → exit 0, covered 5867/16384 (0.358). I rasterized the same triangle independently on the CPU: 5867 covered pixels, 5867 common, 0 only-GPU, 0 only-CPU with the y-up viewport convention; the alternative orientation differs by 2,125 pixels each way, so the match is unambiguous. Corner pixel is the -1 clear sentinel.

Negative control: changing only the manifest layout to the default 0:3f,1:2f makes the harness reject the 12-byte mesh and exit 2 — the test is sensitive to the feature under review.

Other tests on the merged tree: test_first_light.py 29 OK (8 skipped), test_first_light_mesh_draw.py, test_first_light_stale_mesh.py, test_first_light_bad_json.py (9 tests), test_first_light_harness_paths.py (4 tests) — all RC=0.

Conclusion: the manifest-driven vertex-layout replay works correctly on Pascal; no defect found. Depends on: none.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 45bff4e4fe8baa770260e91eb3ca55d3e9eda8f3 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

At 45bff4e4 on Linux RTX 5090, I built the stock Vulkan harness and passed it the environment produced by first_light.harness_env for a synthetic manifest naming quad.bin with layout 0:3f. The mesh had four position-only vertices and six indices. In the 32×32 readback, exactly the expected central 16×16 pixels had RGBA (0.25, 0.5, 0.75, 1); none of the surrounding 768 pixels had that color.

Removing only the layout from the manifest selected the default stride. The same mesh was then rejected with exit 2. This exercised the manifest-to-harness path with hand-written shaders and synthetic geometry.

AI-assisted verification.

@whattheflop

Copy link
Copy Markdown
Contributor

Current-head Windows CPU integration at 45bff4e4 with #4763 e04cee84 on 3faac557, AI-assisted. The old 3d311342 conflicts reproduced. The current revisions merge cleanly as tree 30561d2e.

On the combined tree a synthetic OBJ quad, triangle and UV seam packed into 7 vertices and 9 indices. Normal preparation, default replay and custom replay with layout 6:2f,4:2f,1:4f,3:2f all matched the 22/64 covered-pixel CPU fixture through a harness test double. The viewer GLB preserved the UV seam and V flip. The catalog copied the PNG byte for byte. I fixed the combined replay test failure in #4763 by making a missing optional PNG field default to false. All 26 focused Python tests and seven Node tests passed in the combined tree. No game data or GPU execution.

@GustawMatuszewski

Copy link
Copy Markdown

Tested 45bff4e on NVIDIA GeForce RTX 5060 Laptop GPU (the mobile chip, Blackwell, 32-lane subgroups), driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04.1 (Linux). The package-gated integration checks stay untested here (no game copy); the mesh-draw path itself now has a synthetic GPU check:

  • tests/test_first_light.py: 29 OK (4 skipped); tests/test_first_light_mesh_draw.py: 3 OK
  • vk_harness with VKH_DRAW_MESH, the same full-screen triangle twice: default layout 0:3f,1:2f (stride 5) against the custom layout 0:3f,1:3f,2:4f,3:2f (stride 12, junk in the extra attributes) → both exit 0 and the 64×64 RGBA32F readbacks are byte-identical, all 4096 pixels covered
  • tools/first_light.py --check end to end on the same GPU: a manifest with files.mesh "prop.bin" and vertex_layout 0:3f,1:3f,2:4f,3:2f → covered 4096/4096 (1.000), exit 0; an older manifest with neither key replays mesh.bin with 0:3f,1:2f → covered 4096/4096, exit 0; the two image.raw files are byte-identical
  • the VS/FS pair for the synthetic draws is hand-assembled SPIR-V (spirv-as, passes spirv-val): one location-0 vec3 input, constant-colour FS; no package, no game files

AI-assisted (Claude Code): it built the PR, made the synthetic meshes and shaders, ran the checks and wrote this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants