After the merge the tree held this branch's older states of files main maintains. Run against main's code,
tests/test_acphal_abi.py and 11 of the 15 translator tests that differed failed, and the C++ runtime would have
been built from two generations of its sources. So that the merge cannot break what main builds and tests:
- runtime/ is main's, file for file (68 files only this branch had are not carried over);
- every file under tools/, tests/ and docs/ that both sides have is main's (80 files);
- ten translator tests only this branch has, which test rules main's translator does not have, and their
fixtures are left out.
What main gains: d3d12/ (the Rust D3D12 runtime), its launchers and helpers (Launcher.bat, scripts/play*.ps1,
play-linux.sh, port_ctl.py, smooth-motion.ps1, fetch_vkd3d_proton.py, sync_victory.py), mods/example_lua, eleven
notes under docs/, seven tools and the tests that pass with main's code, the README's sections and credits, and
the "Runtime traps" section of AGENTS.md. Everything left out here is on the branch port/d3d12-nvidia.
Checked: compileall; make_game.py --help; check_no_game_data.py over every file this adds to main; the
line-ending, docs-encoding, CI-registration and docs tests; each test file that differs from main, on its own.
Not run: the whole translator suite, the C++ build, cargo over d3d12/ after the merge (d3d12/ is byte for byte the
branch's), CI.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Brings the D3D12 runtime branch (d3d12/, its launcher scripts and notes, and the pull requests reviewed and applied
on it) together with mandy's main.
Conflicts (67 files, none under d3d12/): docs/, make_game.py, runtime/, scripts/build_runtime.ps1, tests/ and
tools/. Every one takes main's side: main is where that code is maintained, and this branch's copies were older
states of the same files or the same pull requests in another form. tests/test_fspx_unpack.py is main's too, as it
tests main's tools/fspx_unpack.py. Nothing under d3d12/ is changed by the merge.
Checked before pushing: python -m compileall over make_game.py, tools and tests; make_game.py --help;
scripts/check_no_game_data.py over the files this adds to main; tests/test_text_write_line_endings.py. The
translator suite, the C++ runtime build and CI have not run on the result.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
When writing world JSON atomically, if os.replace fails (for instance due to
permission errors), resetting os.chmod to 0o600 ensures unlinking the
temporary file does not fail on Windows with PermissionError.
agent: yes
AI-assisted: yes
The staged build (spatial, grid and baked placements) decoded every chunk texture into a per-build
cache that kept each PNG until the build returned, so the decoded PNGs held grew with the chunk
count. Count each chunk's use of a texture before the chunks are written and drop the cache entry
when its last chunk takes it. A texture is still decoded once per build, waiters still share one
decode, and the chunks and world.json are byte-identical.
In a synthetic 24-chunk build, decoded PNGs alive while the last chunk is written fall from 26 to 3
(spatial, 1 worker) and the grid layout's peak from 26 to 11.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_exclusive_output hashed normcase(abspath(out_dir)), so an 8.3 name or a
junction/symlink spelling of the same output folder took a different lock
and a second build ran into the first one's staging. Hash
normcase(realpath(out_dir)) instead; for an output folder that does not
exist yet, realpath resolves the existing parent and appends the rest, so
two first runs through different spellings still collide.
The new tests hold the lock in a child through one spelling and expect a
build through the 8.3 spelling (skipped when the volume has no 8.3 names)
and through a junction (symlink off Windows) to be refused, both before
and after the output folder exists.
The round-42 merges added a second `import tempfile` after the
fcntl/msvcrt fallbacks; the module already imports it a few lines above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Staging cleanup, publication and stale-chunk pruning all work on the shared
output directory, so two builds into it could delete each other's staged
chunks. Hold an OS file lock keyed by the normalized output path for the whole
build; a second build gets a clear error instead of interfering. The lock lives
in the system temp directory, so output contents and failure cleanup are
unchanged.
Credit @lucastayaralvarenga-ui for the finding.
Windows waits on a pool's workers with WaitForMultipleObjects, which takes
at most 64 handles. With --jobs 62 or more, awc_opus.py, awc_shorts.py,
world_lights_paths.py and world_build.py stopped with "ValueError:
max_workers must be <= 61" (ProcessPoolExecutor), and anim_clips.py
(multiprocessing.Pool) printed "ValueError: need at most 63 handles" from
a helper thread and never returned: 62 workers were killed after 60 s where
61 finish in 0.8 s (Windows 11, Python 3.12.5).
awc_opus.py and awc_shorts.py default --jobs to half the CPU count, and
make_game.py hands its own --jobs to awc_opus.py, so a machine with 124
logical CPUs reached this with no option given.
tools/pool_workers.py holds the limit, and the five pools are created with
process_workers(jobs): unchanged elsewhere, 61 at most on Windows. The
job count is lowered rather than refused so that a build with a large
--jobs keeps running. world_census.py, which refuses --jobs above 61, is
not changed.
tests/test_pool_workers.py runs each tool's own code: with the limit
patched in and a recording pool (every platform), the audio tools from the
command line with --jobs 62, and the real pool with 62 jobs on Windows.
8 of its 10 tests fail on the tools as they were.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A one-worker build can reuse textures from an earlier build in the same process. Include the requested size in the cache key so subsequent builds embed the expected resolution.
#1615's detector read the mode only at position 1, so Path.open(mode)
and tempfile.NamedTemporaryFile(mode) were not seen: three atomic report
writes (rbf0_tree, rtti_scan, world_build) still get CRLF on Windows.
They now pass newline="\n".
The test now reads the mode where each call takes it: open, io/gzip/
bz2/lzma.open and os.fdopen at position 1, Path.open and the tempfile
classes at position 0 (binary by default). It accepts only real mode
strings, and skips codecs, os, tarfile, zipfile and webbrowser opens.
Found by @undeadhuman37 in their review of #1615.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_write_json_atomic wrote world.json through a fixed "world.json.tmp": an
existing file of that name was overwritten and, when the write failed,
deleted; two builds into one output folder shared it; and its plain
os.replace had no retry for a Windows sharing violation, though the viewer
may hold world.json open during a rebuild.
It now stages through a NamedTemporaryFile in the same folder, as #425 did
for the GLB export, gives the result the mode of the file it replaces
(file_mode.published_mode), and _publish_world passes glb_writer._replace,
the retrying replace the chunks already go through.
tests/test_world_json_atomic.py: four tests fail on main (the sibling is
consumed on success and deleted on failure, two writes share a staging file,
world.json skips the retrying replace); the POSIX mode test runs on Linux.
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").
tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--placements used to copy a model's geometry into every placement and keep
all copies until chunking (#1183 review: 22 GB for a 700 m box). Now each
model's OBJ is parsed once into a packed cache file, each chunk stores every
model it uses once, and the placements are instance transforms:
EXT_mesh_gpu_instancing by default (three.js GLTFLoader reads it), one plain
glTF node per placement with --instancing nodes, or the old baked copies
with --instancing bake. Chunks are written as soon as they are built; with
--jobs N, packing and chunk writing run in N processes, at most 4N jobs in
flight. Memory is about 100 bytes per placement plus the models of the
chunks being written.
Every instance TRS has a positive determinant. A negative XY scale is folded
into the rotation; a negative Z scale draws a mirrored copy of the mesh
(glTF Y negated, winding reversed). Zero-scale placements are counted as
degenerate_scale. iter_placements streams the rows load_placements selects,
with the same checks (load_placements is unchanged).
--lod-sets builds one chunk set per lodLevel tier (c_<tier>_<x>_<z>, with
the tier and grid cell in each chunk record) and writes lod_bands to
world.json: a camera-distance band per tier from the entities' median
childLodDist/lodDist. The viewer loads a tiered chunk while the horizontal
distance to its cell is in the band (32 m slack before unloading), so each
cell shows one tier; worlds without lod_bands stream as before, and the
manifest check rejects unknown tiers, unordered bands and missing cells.
glb_writer: pack_primitive and _MaterialTable are factored out of build_glb
(output unchanged), plus build_instanced_glb / write_instanced_glb and
instance_bounds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Count unhashable LOD values and overflowing position/rotation components as malformed rows, then continue loading valid neighbors. Preserve the existing unit fallback for invalid optional scales, including integers too large to convert to finite floats.
Add synthetic loader and complete-world regressions covering row counts, scale defaults, unchanged finite/zero/negative scales, region/LOD filters and resulting geometry bounds. New regressions reproduced nine errors on the unmodified base; all 178 world-related tests now pass.
world_build placed every model at its own coordinates or in rows; it never read the CEntityDef records.
- world_index.py --entities-out writes one JSON line per complete entity: archetype hash and 64-bit key,
position, stored rotation, scales and LOD fields.
- world_build.py --placements matches each selected entity to an exported model the way world_names.py does
(lower-cased joaat of the manifest name, confirmed by the Murmur3-64 key when the row has one). It then
scales by (scaleXY, scaleXY, scaleZ), rotates by the conjugate of the stored quaternion, translates and
converts to glTF Y-up. Normals use the inverse-transpose; a mirroring scale flips the winding.
--lod-levels (default 0,5) and --region select the entities. world.json reports the count of each outcome
in stats.placements.
- tests/test_world_place.py: 15 synthetic tests.
- docs/world.md: "Building a placed world", with measurements on a 700 m downtown box.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_remove_stale_staging deleted every .chunks-staging-* directory, including one
whose previous/ held chunks a failed publish could not put back, so the recovery
copy named in the error was gone on the next build. Such a directory is now kept;
empty or incomplete staging is still removed. The build_world docstring now says
that readers can see old and new chunks mixed while publishing renames them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stage chunk generation in .chunks-staging-*/ on the output volume, verify sizes and headers, and publish via rename once all chunks succeed. Previous chunks are kept in a staging backup until world.json is committed; any error or interrupt rolls back to the previous intact world.json and chunk files. Leftover staging directories from killed builds are cleaned up on the next run. Adds WorldBuildStagingTest (6 synthetic tests covering failed chunk generation, corrupt chunk rejection, world.json write failure rollback, and leftover cleanup).