Skip to content

Claude/fix gpu index buffer k fucj#1161

Merged
braedonsaunders merged 2 commits into
mainfrom
claude/fix-gpu-index-buffer-kFUCJ
Jan 30, 2026
Merged

Claude/fix gpu index buffer k fucj#1161
braedonsaunders merged 2 commits into
mainfrom
claude/fix-gpu-index-buffer-kFUCJ

Conversation

@braedonsaunders

Copy link
Copy Markdown
Owner

No description provided.

…er sharing

The previous fix using geometry.clone() + needsUpdate still allowed internal
buffer references to be shared between source and cloned geometry. When the
source geometry was disposed, the shared GPU buffer references became invalid.

This fix creates completely fresh TypedArrays using array.slice(0) for all
attributes and index buffers, ensuring zero shared state with the source
geometry. This prevents "setIndexBuffer" crashes even when source geometry
is disposed while clones are still being rendered.

Changes:
- UnitRenderer: Deep copy all attributes and index
- ResourceRenderer: Deep copy all attributes and index
- BuildingRenderer: Deep copy all attributes and index
- InstancedDecorations: Deep copy all attributes and index
- GPUIndirectRenderer: Deep copy all attributes and index

Also copies morph attributes, bounding volumes, and groups for completeness.

https://claude.ai/code/session_01RVGDnXRzL5S5tELbcBqYrN
…cedDecorations

- AssetManager.cloneModel() now creates completely independent geometry
  for all cloned meshes using deepCloneGeometry() which copies all
  TypedArrays with slice(0) to prevent WebGPU buffer sharing
- Added deepCloneModelHierarchy() for static models and enhanced
  animated model cloning to also deep clone geometry after SkeletonUtils.clone()
- Added geometry quarantine system to all 5 InstancedDecorations classes
  (Trees, Rocks, Crystals, Grass, Pebbles) that delays disposal by 4 frames
  to ensure GPU commands have completed before buffer destruction
- This prevents "Failed to execute 'setIndexBuffer' on 'GPURenderPassEncoder'"
  crashes that occurred when source geometry was disposed while still in use

https://claude.ai/code/session_01RVGDnXRzL5S5tELbcBqYrN
@braedonsaunders braedonsaunders merged commit f9c91af into main Jan 30, 2026
4 checks passed
@braedonsaunders braedonsaunders deleted the claude/fix-gpu-index-buffer-kFUCJ branch January 31, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants