Feat: Complete adaptive geodesic tracing with DP54
Add error-controlled DP5(4) integration and trusted first-crossing localization, including non-monotonic energy thresholds and representable-time stepping. Preserve adaptive state and independent step/time retry grants across RayPool, refinement and movie scheduling. Expose numerical controls, record actual persistent-sample costs, and add v3 lens-map provenance with legacy v2 RK4 import. Use DP54 by default and select an 8M Schwarzschild maximum step from bounded scans and a two-run 4K comparison. Retain the conservative minimum-step guard and document critical-ray and backend capability limits. Archive self-contained benchmark inputs and raw output; keep fixed RK4 HDR references explicit. Validation: make -B -j4 BUILD_TYPE=Debug test passed; explicit RK4 HDR references have zero differences. Bounded convergence checks, benchmark reproduction, Release build and focused reviews passed. No numerical-relativity backend is added.
This commit is contained in:
1 parent
c894fdb11a
commit
0a46a7095b
48 files changed
+11491
-380
No files matched your search
+25
-10
@@ -88,19 +88,31 @@ def image_payload(path, dimensions=(64, 48), allow_black=False):
|
||||
return raw
|
||||
|
||||
|
||||
# Version 3 wire layout. The first 100 bytes are the v2 provenance; the v3
|
||||
# adaptive policy appends 9 doubles and a u32 (76 bytes) so the provenance
|
||||
# block ends at 176. Each frame header is 48 bytes, so vertex payload starts at
|
||||
# 224. A v3 vertex keeps the 84-byte v2 record and appends three u64 cost
|
||||
# counters; a triangle stays 32 bytes. The CRC covers only the vertex+triangle
|
||||
# payload, never the header.
|
||||
MAP_PROVENANCE_END = 176
|
||||
MAP_FRAME_HEADER_START = MAP_PROVENANCE_END
|
||||
MAP_VERTEX_START = MAP_PROVENANCE_END + 48
|
||||
MAP_VERTEX_SIZE = 84 + 24
|
||||
MAP_TRIANGLE_SIZE = 32
|
||||
|
||||
|
||||
def map_vertices(path):
|
||||
data = path.read_bytes()
|
||||
assert data[:8] == b'GRLENS\x01\x00'
|
||||
assert struct.unpack_from('<I', data, 8)[0] == 3, 'expected v3 lens map'
|
||||
assert struct.unpack_from('<Q', data, 32)[0] == 1 # frame_count
|
||||
# Header: 40 bytes, then a 60-byte provenance block, then the 48-byte
|
||||
# per-frame header, so vertices start at offset 148 in the v2 format.
|
||||
vertices, triangles = struct.unpack_from('<QQ', data, 124)
|
||||
offset = 148
|
||||
vertices, triangles = struct.unpack_from('<QQ', data, MAP_FRAME_HEADER_START + 24)
|
||||
offset = MAP_VERTEX_START
|
||||
values = []
|
||||
for _ in range(vertices):
|
||||
values.append(struct.unpack_from('<9dIII', data, offset))
|
||||
offset += 84
|
||||
return values, data[offset:offset + triangles * 32]
|
||||
values.append(struct.unpack_from('<9dIIIQQQ', data, offset))
|
||||
offset += MAP_VERTEX_SIZE
|
||||
return values, data[offset:offset + triangles * MAP_TRIANGLE_SIZE]
|
||||
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix='gr-camera-cli-') as directory:
|
||||
@@ -282,7 +294,10 @@ with tempfile.TemporaryDirectory(prefix='gr-camera-cli-') as directory:
|
||||
assert len(a) == len(b) and ta == tb
|
||||
max_error = 0
|
||||
for x, y in zip(a, b):
|
||||
assert x[9:] == y[9:], 'ray endpoint provenance mismatch'
|
||||
# Indices 9..11 are end_id/outcome/reason; indices 12..14 are the
|
||||
# per-vertex integration cost counters, which are not physical ray
|
||||
# provenance and may differ between the single and movie schedulers.
|
||||
assert x[9:12] == y[9:12], 'ray endpoint provenance mismatch'
|
||||
max_error = max(max_error, *(abs(v - w) for v, w in zip(x[:9], y[:9])))
|
||||
assert max_error < 1e-9, max_error
|
||||
|
||||
@@ -305,9 +320,9 @@ with tempfile.TemporaryDirectory(prefix='gr-camera-cli-') as directory:
|
||||
# so this tests completion semantics rather than corruption detection.
|
||||
incomplete_map = tmp / f'{backend}_incomplete.grlens'
|
||||
payload = bytearray(single_map.read_bytes())
|
||||
struct.pack_into('<II', payload, 148 + 76, 3, 5) # INCOMPLETE / INVALID_METRIC
|
||||
struct.pack_into('<II', payload, MAP_VERTEX_START + 76, 3, 5) # INCOMPLETE / INVALID_METRIC
|
||||
struct.pack_into('<I', payload, len(payload)-4,
|
||||
zlib.crc32(payload[148:-4]))
|
||||
zlib.crc32(payload[MAP_VERTEX_START:-4]))
|
||||
incomplete_map.write_bytes(payload)
|
||||
refused = tmp / f'{backend}_refused.{ext}'
|
||||
failure = run(binary, *common, '--lens-map-input', incomplete_map,
|
||||
|
||||
Reference in new issue
Block a user