ifcviewer: quantize VBO to 16 B/vertex (sidecar v6)

Position now u16x3 normalized against each mesh's local AABB; normal
oct-encoded to i16x2; RGBA8 colour unchanged. Per-mesh dequant basis
lives in a new MeshGpu SSBO at binding 2; both main and pick shaders
mix() against it before applying the instance transform.

Drops VBO and sidecar size by ~43 % (28 -> 16 B/vert), which matters
mostly for warm-load downloads of precomputed sidecars and steady-state
VRAM. LodBuilder dequantizes positions into a scratch buffer before
calling meshopt, since meshoptimizer needs float positions.

Also fixes a streaming-time crash in cullAndUploadVisible: bvh_items
was only populated at finalize, but the linear fallback indexes it
during streaming. Mirror BvhItem appends in uploadInstanceChunk so the
hot path stays valid before the BVH is built.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-04-14 21:54:15 +10:00
parent 09ffdd2028
commit 574bcfa6c5
9 changed files with 299 additions and 72 deletions
+5 -6
View File
@@ -17,17 +17,16 @@
* *
********************************************************************************/
// v5 layout (all multi-byte fields native-endian; endianness marker in header).
// Same sequence as v4; the only change is that MeshInfo grew two uint32_ts
// (lod1_ebo_byte_offset + lod1_index_count) and `indices` may contain extra
// appended LOD1 slices pointed at by those offsets.
// v6 layout (all multi-byte fields native-endian; endianness marker in header).
// Same sequence as v5; the only change is that vertex data is now raw bytes
// at the 16 B/vertex quantized layout (see InstancedGeometry.h).
//
//
// SidecarHeader (16 bytes)
// uint64_t source_file_size
//
// uint32_t num_vertices_floats
// float[] vertex data (28 B/vertex: pos3 + normal3 + color1_packed)
// uint32_t num_vertex_bytes
// uint8_t[] vertex data (16 B/vertex: pos u16x3 + pad2 + oct-normal i16x2 + rgba8)
// uint32_t num_indices
// uint32_t[] index data (mesh-local indices; base_vertex applied at draw time)
//