Repository navigation
Conversation
|
The importer keeps a full copy of the same embedded PNG for each node that uses the mesh. On c17b62e, 64 nodes that reference mesh 0 retain 64 distinct bytes objects for one 262,548-byte base-color image. All copies contain the correct pixels. The copies alone occupy 16,803,072 bytes of payload. I measured live Python allocations just after read_glb_parts returned on Windows 11, CPython 3.14.7. The 1-, 16-, and 64-node cases retained 273,946, 4,245,295, and 16,974,231 bytes respectively. The input keeps the same image table in all three cases. To reproduce, run this script from the repository root with import random
import runpy
t = runpy.run_path("tests/test_ped_glb_textures.py")
c = t["PedGlbTextureTests"]()
c.setUp()
try:
png = t["dds_png"].encode_png(256, 256, random.Random(5824).randbytes(256*256*4))
for part in c.parts:
part.material.base_color_png = png
t["pa"].write_assembled_glb(str(c.source), c.parts, apply_standing=False)
doc, buf = t["split_glb"](c.source.read_bytes())
doc["nodes"] = [{"mesh": 0} for _ in range(64)]
doc["scenes"] = [{"nodes": list(range(64))}]
c.source.write_bytes(t["container"](doc, buf))
parts = t["pa"].read_glb_parts(str(c.source))
blobs = [p.material.base_color_png for p in parts]
assert all(b == png for b in blobs)
print(len(set(map(id, blobs)))) # 64
finally:
c.doCleanups()Please cache the immutable PNG bytes by buffer view within one import. Each material can then reuse the same payload. The writer deduplicates images later, after these allocations have occurred. All 19 importer and assembly tests pass on the head. Parent 561b65a drops the textures and fails nine subcases of the new suite. AI-assisted. |
|
Round-tripped a 32 MiB material-heavy GLB through the actual assembly CLI on CachyOS. The project’s world writer generated the input from 194 synthetic triangle primitives and textures decoded from my Xbox 1.0.2.1 DDS pool. It contained 192 distinct embedded PNGs and two untextured primitives. I ran This covers base-color preservation with many distinct images; the normal and metallic/roughness slots were absent from this input. CPU-only, AI-assisted. |
|
Reviewed c17b62e (code read + CPU, Windows 11, Python 3.14.4): works as described, three notes below.
Notes, none blocking:
Pre-existing, not from this PR: a material or pbrMetallicRoughness that is not an object, and a BIN chunk AI-assisted review. |
Cache immutable bytes only after validating each reference so repeated nodes and material slots share one payload without bypassing bounds or URI rules. AI-assisted: yes.
|
Fixed in The importer now keeps one immutable PNG payload per validated buffer-0 span for the duration of one import. Every texture/image/view/buffer reference, URI rule and bounds check still runs before cache lookup. Different image identities that use the same span share bytes, and a later import receives its own cache. I reproduced your exact synthetic PNG and node-count setup on published c17b62e with Python 3.14.6:
The 64-node case retains 262,548 bytes of that PNG payload instead of 16,803,072. Geometry and per-node material data still scale with node count. Three added regression methods cover 64 nodes sharing a PNG across three material slots and different image identities, a changed image at the same span in a later import, and URI/invalid-metadata references encountered after that span has been cached. The repeated-node/shared-slot case fails on c17b62e with 50,409,216 retained payload bytes and passes with 262,548. The existing CLI, material-factor, independent-index and boundary cases remain green. All eight texture methods and 14 existing ped assembly methods pass. Exact adjacent #5764 f9e2ff3 still applies cleanly; the combined checkout passes eight texture and 15 assembly methods. Full compileall, make_game help and diff checks pass. An independent reviewer inspected the cache placement and reran all eight methods. Synthetic inputs only, no game files or GPU. AI-assisted: yes. |
Validate every embedded PNG reference before cache lookup and document the existing sampler defaults. Keep explicit TEXCOORD_0 roundtrips intact. AI-assisted: yes.
|
Addressed these input-contract notes in
The regression supplies a valid The bytes remain opaque PNG payloads; this is bounds and supported-coordinate validation, not a full PNG decoder. Synthetic inputs only, no game files or GPU. AI-assisted: yes. |
|
AI-assisted Windows CPU verification on A repeated-node input gave three parts and nine PNG references with only three distinct Python byte objects, confirming the per-import sharing fix. The actual The probe used valid synthetic GLBs and checked assembly output and ownership on CPU. It did not measure browser or GPU memory. |
Kam471
left a comment
There was a problem hiding this comment.
Reviewed at c17b62ea21 on Windows 11 / Python 3.13.
python -I -m pytest tests/test_ped_glb_textures.py -q: 5 passed, 5 subtests passed.tests/test_ped_assemble.py: 14 passed.tests/test_ci_registration.py: 14 passed, 16 subtests passed.- Negative control on
561b65a83: the same new test file is 9 failed / 1 passed (the five regression methods), matching the PR description. - Checked the new resolution path: it follows texture -> image -> bufferView -> buffer 0, rejects declared-buffer and BIN-chunk overruns plus negative/non-int metadata, preserves the PNG bytes verbatim, and does not open external URIs. Untextured and external-URI controls keep the old behaviour.
Verdict: LGTM.
Problem
ped_assemblesilently dropped every embedded material texture when reading GLB parts. A valid synthetic GLB written by the project's own writer contained three PNG images for base color, normal and metallic/roughness. Reading it returnedNonefor all threeMaterialSpecfields, and the actual assembly CLI exited successfully with zero output images or textures.Change
Resolve the three existing material slots through the texture, image and bufferView tables. For embedded
image/pngdata in GLB buffer 0, preserve the exact PNG bytes after checking both the declared buffer extent and the actual BIN chunk bounds. The existing writer retains its byte-based image deduplication and material factors.This is limited to the existing embedded PNG path. External image/buffer URIs are not opened, and unsupported image formats retain their previous behavior.
Validation
Windows, Python 3.14.6, current main
561b65a832218fbb9e6d2effd392a8eef093a3f8. Synthetic fixtures only; no game files or GPU.compileall,make_game.py --help, andgit diff --checkpassed.Follow-up: reuse embedded PNG payloads within one import
Addresses #5824 (comment).
A per-import cache now shares immutable PNG bytes by validated buffer-0 span across repeated nodes and material slots. All reference, URI and bounds checks still execute before cache lookup. A later import starts with a new cache.
For the reviewer's synthetic 262,548-byte image and 64 nodes, distinct payload copies fall from 64 to one, retained PNG data from 16,803,072 to 262,548 bytes, and live traced Python allocation after import from 16,983,991 to 428,602 bytes. This measures that synthetic import, not total scene memory.
Three added methods cover repeated nodes/shared slots, cache lifetime and validation/URI behavior after a cache hit. Eight texture and 14 existing assembly methods pass; exact #5764 f9e2ff3 combined integration passes eight plus 15. Required compileall/help and diff checks pass. Independent source review and eight-method rerun are clear.
Follow-up: embedded image input contract
At
ffc26593, empty embedded buffer views and unsupported texture coordinate references raise contextualPedAssembleErrordiagnostics before cache lookup. Implicit or explicittexCoord: 0remains supported. The importer docstring also records the existing repeat/linear/mipmap sampler defaults.The same final nine-method fixture has four failing subcases at the preceding
782f52a3head and passes after this change: one empty image and all three texture slots referencing a valid second UV set on a later material. All 14 existing assembly methods pass. The exact #5764 integration now passes nine texture plus 15 assembly methods. Full compileall, make_game help, diff checks and an independent source/evidence review pass.Coordination and integration
ASSET-495, claimed at #5581 (comment) and carried to #5781.
Adjacent #5764 owns CLI error/output-path handling. Its exact head
f9e2ff3ebec61a632a7aed51b57413fa368f196dhas separate source hunks; our patch applies cleanly. The latest combined checkout atffc26593passes all nine texture methods and all 15 of that PR's ped assembly methods. No dependency on #5764 is needed.Open #5141 and #5238 affect separate ped-kit/skinned exporters and do not modify this importer.
AI-assisted: yes.