A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(render): the per-object record texture is created from storage as tall as the texture, and a world that has aborted reports its despawns once
yhhfece18f7807c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f698676e1..3d9de7c2b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -74,6 +74,7 @@ published separately; it ships inside the editor.### Fixed+- **Many placed objects no longer crash the renderer.** The texture that holds every object's record in a frame grew by doubling but was created from storage sized to the frame's need, so a frame with many objects read past its end and the engine aborted with `memory access out of bounds`; stopping then reported one warning for every entity. The texture is created from storage as tall as itself, and an aborted engine is reported once.- **A cloud's shadow stays where the cloud is.** The shadow a sky's clouds cast on the scene added the camera's position to the cloud's, so it slid across the ground as the camera moved while the cloud in the sky stood still; it is taken from the same place the sky draws the cloud from.- **A leaf or a blade of grass no longer has a pale edge.** A cutout texture (one with a Mip Coverage) has the colour of its solid texels carried into its clear ones when it is cooked, as a model's cutouts already did: what an artist leaves under alpha 0, often white, was averaged in at every leaf's edge by the filter and the mips. The source image is not touched.- **A world's layers over an area are counted over the area.** The chunks of a procedural layer are walked over the part of the wanted radius that lies in the layer's extent, not over the whole radius, and a generated world on an area of terrain takes the terrain's bounds as its extent: a layer wanted a thousand chunk-widths out no longer costs seconds a frame.diff --git a/sdk/src/ecs/world.ts b/sdk/src/ecs/world.tsindex 4ed7126ce..7ce002bcc 100644--- a/sdk/src/ecs/world.ts+++ b/sdk/src/ecs/world.ts@@ -5,6 +5,7 @@* @brief ECS World with C++ Registry integration*/+import { WasmModuleAborted } from '../wasm/moduleHealth';import { Entity, entityGeneration, entityIndex, makeEntity, INVALID_ENTITY } from '../types';import { AnyComponentDef, ComponentDef, ComponentData, BuiltinComponentDef, isBuiltinComponent, builtinComponentRegistry, extraBuiltinComponentRegistry, getUserComponents, getComponent, Disabled, Name, Parent, Children, type ParentData, type ChildrenData } from './component';import type { CppRegistry, ESEngineModule } from '../wasm';@@ -382,11 +383,17 @@ export class World {}}+ private abortedReported_ = false;+private despawnOne_(entity: Entity, cppRegistry: CppRegistry | null): void {notifyBridge('onEntityDespawned', entity);for (const cb of this.despawnCallbacks_) {- try { cb(entity); } catch (e) { log.warn('world', 'Despawn callback error', e); }+ try { cb(entity); } catch (e) {+ // A module that has aborted fails every callback the same way, and one report says so for all of them.+ if (e instanceof WasmModuleAborted) { if (!this.abortedReported_) { this.abortedReported_ = true; log.warn('world', 'Despawn callbacks stopped: the engine module has aborted', e); } continue; }+ log.warn('world', 'Despawn callback error', e);+ }}this.names_.remove(entity);diff --git a/src/esengine/renderer/rhi/TransientBufferPool.cpp b/src/esengine/renderer/rhi/TransientBufferPool.cppindex 2f5a62667..a0b43efdb 100644--- a/src/esengine/renderer/rhi/TransientBufferPool.cpp+++ b/src/esengine/renderer/rhi/TransientBufferPool.cpp@@ -84,7 +84,12 @@ void TransientBufferPool::uploadInstanceRows(Stream& s, u32& grows, u32& writes)if (rows > s.texture_rows) {// Doubling, the way the staging grows: a workload creeping upward// otherwise reallocates a texture every frame.- const u32 want = std::max(rows, s.texture_rows * 2);+ // The texture is created from the staging, so the staging is as tall as the texture, and neither is taller than a device guarantees.+ const u32 limit = MESH_INSTANCE_MAX_RECORDS * MESH_INSTANCE_TEXELS / MESH_INSTANCE_TEXTURE_WIDTH;+ const u32 want = std::min(std::max(rows, s.texture_rows * 2), std::max(rows, limit));+ if (s.vertex_staging.size() < static_cast<usize>(want) * rowBytes) {+ s.vertex_staging.resize(static_cast<usize>(want) * rowBytes);+ }if (s.texture != TextureHandle::Invalid) device_.deleteTexture(s.texture);TextureDesc desc;desc.width = MESH_INSTANCE_TEXTURE_WIDTH;diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex abfb6c42d..31902fd4d 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -2896,6 +2896,8 @@ export const NOTED = {{"note":"Plants are instances of one mesh."},"fix(ci): the static gates earlier reds hid pass again":{"internal":"Gate baselines and a module split; nothing a creator sees."},+ "fix(render): the per-object record texture is created from storage as tall as the texture, and a world that has aborted reports its despawns once":+ {"note":"Many placed objects no longer crash the renderer."},"feat(assets): a project names folders its asset database leaves alone":{"note":"A project can keep folders out of its asset database."},"feat(worldgen): a plant part may cast no shadow, and far cells are capped at two cells wide":