Commit Graph

23 Commits

Author SHA1 Message Date
fd42898706 Merge pull request #1540 from Rain156/rain/d3d12-first-light-camera
tests: draw the First Light perspective camera through D3D12 (TEST-D3D12-FIRST-LIGHT-CAMERA)
2026-11-29 02:06:11 +01:00
6e3a44259c tests: draw the First Light perspective camera through Xbox D3D12 2026-11-25 11:39:12 +08:00
fc2d07a1a4 docs/first_light: the test has 48 cases, not twenty-five (DOC-FIRST-LIGHT-TEST-COUNT)
The unittest loader counts 48 cases in tests/test_first_light.py, and the
sentence on the old breakdown no longer matched. The breakdown is dropped.
The pass/skip line now matches a real run: 48 tests, 44 passed, 4 skipped.
2026-11-24 16:09:29 +01:00
b26112bf23 docs/first_light: the no-package run is 46 tests (42 passed, 4 skipped), not 19 (EGEN-FIRSTLIGHT-TEST-COUNT) (#6228)
Squash-merged after diff review of PR #6228 - docs/first_light: the no-package run is 46 tests (42 passed, 4 skipped), not 19 (EGEN-FIRSTLIGHT-TEST-COUNT)
2026-11-23 08:22:18 -06:00
8150e95d57 Merge pull request #4490 from kapitche
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/design.md
2026-11-22 23:15:12 -05:00
bc0d227006 Merge pull request #3967 from inerthel-agi
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/first_light.md
2026-11-22 23:10:00 -05:00
8996e20228 Merge pull request #3350 from Jeremy Goldberg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/README.md
2026-11-22 23:07:21 -05:00
11ff3f3fc5 Merge pull request #2855 from sovljanskii
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:13 -05:00
405458fb6d docs: drop lines merges left twice, correct two test counts; test_docs_repeated_lines 2026-11-22 20:45:48 -05:00
3b598a9be4 docs(first-light): distinguish UV and textured draw defaults
Refs: #3350
2026-11-22 17:50:46 -05:00
98a9f7eda5 fix(first-light): clip expected UV probes to the visible depth range
Skip clipped fragments when retained mesh depth crosses the near or far plane. Check partial triangles, visibility in draw order, and clear probes with synthetic geometry (TEST-870).
2026-11-22 23:42:42 +01:00
bc79b55d1e first_light --camera: draw the model in perspective with a game VS that 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.
2026-11-22 23:02:49 +01:00
9be3d33974 Merge pull request #3577 from Emma 2026-11-22 17:02:48 -05:00
343a505ab2 Merge pull request #3350 from Jeremy Goldberg 2026-11-22 17:01:36 -05:00
35fe778eb6 first_light.py: start each run with empty first_light/dxbc and first_light/spirv
The tool staged the chosen VS and PS containers in <work>/first_light/dxbc and had them translated into
<work>/first_light/spirv, and emptied neither. fssm_unpack.py, shader_disasm.py and rdna2spirv.py take every file
in the folder they are given, so a second run with another shader translated the first run's container again:
"3 shaders: 2 translated" for a pair, the extra one with "stage ?", and its files stayed beside this run's.

reset_run_folders() removes both folders at the start of translate() and creates an empty dxbc. first_light/out,
another --out and <work>/shaders are not touched. A folder that is a symlink or a junction, or sits behind a
linked first_light, is refused before anything is removed; a link inside is unlinked without being entered; a
file that cannot be removed ends the run with one line naming it.

tests/test_first_light.py: RunFolderTests runs the tool twice in one synthetic work folder, with stand-ins for
the three tools that take every file like the real ones. docs/first_light.md says the two folders are per-run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 22:45:00 +02:00
88c1a9b376 docs(first-light): distinguish the UV shaders from the model material
Refs: #2519, #2893, #3036
2026-11-22 15:12:26 -05:00
7e1aecf0cb first_light: fix VKH_TSHARP_VA overflow guard, subgroup size, preview env, and test docs
Addresses @Kam471's review on #2806:
- Fix uint32 wraparound in VKH_TSHARP_VA bounds check (tsharp_va > heap_bytes - 32) so 0xFFFFFFE0 is rejected with exit 2 instead of writing OOB; add regression test in tests/test_first_light.py.
- Clarify exact test counts in docs/first_light.md (14 tests: 11 pass, 3 skip without LEONIDA_FIRST_LIGHT_DIR; 14/14 pass with LEONIDA_FIRST_LIGHT_DIR).
- Require --obj when --dds is passed so textured probes are always populated, include all texture env vars in the non---run preview command, and pass VKH_SUBGROUP_SIZE from manifest['ps']['subgroup_size'].
2026-11-22 21:06:15 +01:00
3763517741 First light: add textured draw path with T#/S# bindless set and CPU oracle (TEST-524)
Implements TEST-524:
- runtime/test/vk_harness.cpp: adds optional VKH_TEX_RGBA, VKH_TSHARP_VA, and VKH_SSHARP (inert when unset) to upload an RGBA8 texture to set 0 image index 1 (with 1x1 magenta fallback at index 0), write the 8-dword T# at VKH_TSHARP_VA in the 64 KiB heap, decode S# via gfx10_descriptors.h into sampler index 1, and bind DescriptorTable at binding 2.
- tools/first_light.py: adds --dds <path.dds> (decoding via tools/dds_png.py to texture.rgba), defaults --ps to PS_Copy_3ea4b38a_Wrapped (wave32, single image_sample_lz, compatible with DEFAULT_VS), reads ptr32_lo SGPR and literal_samplers from index.json, and adds a bilinear clamp-to-edge CPU texture oracle (centre_rgba + rgba_probes) in check_image.
- tests/test_first_light.py: shares fl.harness_env() so package-gated tests cover both untextured and textured runs, and adds 6 synthetic TexturedOracleTests (no GPU or game files).
- docs/first_light.md: documents the textured path and RTX 3060 verification (counts and hashes only; no game data).
2026-11-22 21:06:14 +01:00
6c73872cad first_light: draw the real model through the D3D12 layer
d3d12_first_light (package-gated by LEONIDA_FIRST_LIGHT_DIR, exit 77 when
unset) draws the mesh and translated VS/PS that tools/first_light.py wrote
through the Xbox-ABI device proxy: CreateGraphicsPipelineState gets the
game's own containers and finds both stages by FSSM hash, the input layout
feeds POSITION/TEXCOORD, DEFAULT vertex/index buffers, one
DrawIndexedInstanced, CopyTextureRegion readback. It checks vk_harness's
oracle (coverage window, clear corner, centre UV) with the rows flipped
for the y-up viewport, and compares every pixel with vk_harness's
image.raw.

first_light.py now also writes vs.dxbc, ps.dxbc and index.json (the
translator entries keyed vs/ps) to the output folder.

RTX 3060, driver 616.64: 12,804/16,384 covered, centre
(0.49756, 0.49634, 0, 1), as vk_harness; 16,383 pixels bit-exact and one
one f16 step apart (the PS exports with v_cvt_pkrtz_f16_f32; vk_harness
with the mesh mirrored in y matches the D3D12 image bit for bit).
Clean under LEONIDA_VK_VALIDATION=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:36:51 -03:00
e590a591cd first_light: Windows defaults, one raw path, OBJ hash (rafaelpssz's review)
find_harness/harness() check runtime/build/windows and add .exe on Windows; the
skip/error text names LEONIDA_VK_HARNESS. The tool and the test use fixed
image.raw / image_first_light.raw paths, unlinked before each run, so no random
raw files pile up. manifest.json records the OBJ SHA-256 and docs/first_light.md
names the 4,213/7,968 model and its hash.
2026-11-22 12:28:20 -03:00
f7edafaa2e first_light: --check shares the test's oracle (Vonsek follow-up)
--check now loads an existing manifest, writes a fresh raw path, and calls the
same check_image the test imports. The oracle adds four UV probes whose U and V
differ by more than 0.15, because a symmetric centre alone cannot catch a swapped
UV. Fake harnesses that exit 0 without writing, write a solid image or swap UV
all exit 1; the real draw exits 0. The test has seven cases, including the CLI.
2026-11-22 12:28:20 -03:00
3556ab9141 first_light: harden the readback oracle (Vonsek's review)
The draw writes a fresh raw path (a harness that writes nothing cannot pass on a
stale file); the check adds a coverage maximum, a corner that must keep the clear
value and the centre UV the mesh's last covering triangle predicts on the CPU.
OracleTests cover the accepted fixture plus all-opaque, swapped-UV and short
negatives without a GPU or a package.
2026-11-22 12:28:20 -03:00
07cc6efb20 first_light: a real game model with its own translated VS/PS
tools/first_light.py carves the game's shaders, translates one real VS/PS pair,
converts an exported OBJ to a mesh, writes a manifest and runs vk_harness. The
harness gains VKH_DRAW_MESH/VKH_VERTEX_LAYOUT (indexed mesh, vertex input), inert
when unset. The package-gated test draws the model and checks coverage and the
centre pixel; docs/first_light.md records the measured result.
2026-11-22 12:28:20 -03:00