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
feat(render): geometry can stay on the GPU
esenginef9798bd4f786
diff --git a/desktop/scripts/headless-verify.mjs b/desktop/scripts/headless-verify.mjsindex 77351487b..3d20ccd87 100644--- a/desktop/scripts/headless-verify.mjs+++ b/desktop/scripts/headless-verify.mjs@@ -122,10 +122,13 @@ function finish(result, server) {.every((k) => (last.tables[k] - first.tables[k]) <= spans * 6))(rounds[1], rounds[rounds.length - 1], rounds.length - 2);const deviceLossOk = lossSeen && cameBack && drivenSteps && growthOk;+ // Freezing nothing would pass every pixel assertion by not having changed the+ // scene — the shape of a check that cannot fail.+ const meshOk = !result.meshResident || result.meshResident.frozen > 0;const renderedOk = result.capture?.rendered ?? false;const ok = result.ok && renderedOk && (result.expect?.ok ?? true) &&(result.resize?.ok ?? true) && (result.preview?.ok ?? true) && (result.grid?.ok ?? true) &&- deviceLossOk;+ deviceLossOk && meshOk;console.log(`\n[verify:render] ${ok ? 'PASS' : 'FAIL'} — ${SCENE} (${BACKEND})`);console.log('DRIVE_RESULT ' + JSON.stringify(result));try {@@ -158,6 +161,7 @@ app.whenReady().then(async () => {const exec = (code) => win.webContents.executeJavaScript(code, true);let deviceLoss = null;+ let meshResident = null;await exec('window.__estellaHeadless.ready');const entityCount = await exec(`window.__estellaHeadless.api.loadScene(${JSON.stringify(SCENE)}, ${JSON.stringify(MANIFEST)})`,@@ -241,6 +245,17 @@ app.whenReady().then(async () => {await exec(`window.__estellaHeadless.api.step(${STEPS}, 1 / 60)`);}+ // Freezes the scene's inline geometry onto the GPU, keeping every other+ // assertion: nothing about the geometry changes, so the frame after must+ // equal the frame before. That equality IS the claim.+ if (process.env.ESTELLA_VERIFY_MESH_RESIDENT === '1') {+ meshResident = await exec(`(async () => {+ const frozen = window.__estellaHeadless.makeMeshesResident();+ await window.__estellaHeadless.api.step(2, 1 / 60);+ return { frozen };+ })()`);+ }+// ESTELLA_VERIFY_DEVICE_LOSS=auto is the player's case: the GPU goes away,// the browser hands a context back, and NOTHING here asks for a recovery.// Only frames pass. What comes back has to come back on the engine's own.@@ -454,7 +469,7 @@ app.whenReady().then(async () => {return { differingPixels: differing, ok: differing > 300 };`);}- finish({ ok: true, entityCount, drawCalls, capture, expect, resize, preview, grid, deviceLoss }, server);+ finish({ ok: true, entityCount, drawCalls, capture, expect, resize, preview, grid, deviceLoss, meshResident }, server);} catch (e) {finish({ ok: false, error: String((e && e.stack) || e) }, server);}diff --git a/desktop/src/headless.ts b/desktop/src/headless.tsindex 528c6d1b1..ac569069c 100644--- a/desktop/src/headless.ts+++ b/desktop/src/headless.ts@@ -41,6 +41,8 @@ declare global {guard(): { target: string; lostEventsSeen: number };restore(): boolean;};+ /** Freezes the scene's inline mesh geometry onto the GPU; returns how many. */+ makeMeshesResident: () => number;};}}@@ -144,6 +146,17 @@ window.__estellaHeadless = {return true;},},+ // Every Mesh2D in the scene, frozen onto the GPU. The point of driving it from+ // here is that nothing about the geometry changes — same entity, same vertices,+ // the other path — so the frame afterwards has to be the same frame.+ makeMeshesResident: () => {+ const m = EngineHost.module as unknown as {+ mesh2d_makeAllResident?(registry: unknown): number;+ } | null;+ const registry = EngineHost.mutableWorld()?.getCppRegistry();+ if (!m?.mesh2d_makeAllResident || !registry) return 0;+ return m.mesh2d_makeAllResident(registry);+ },};// Referenced so the unused-import check sees it; DeviceStatus is the vocabularydiff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.mdindex 772b51f07..9b96f574e 100644--- a/sdk/etc/wasm.api.md+++ b/sdk/etc/wasm.api.md@@ -258,7 +258,11 @@ material_define: (materialId: number, shaderHandle: number, blendMode: number, fmaterial_setTexture: (materialId: number, name: string, textureHandle: number) => voidmaterial_setUniform: (materialId: number, name: string, arity: number, v0: number, v1: number, v2: number, v3: number) => voidmaterial_undefine: (materialId: number) => void+mesh2d_makeAllResident: ((registry: CppRegistry) => number) | undefined+mesh2d_makeResident: ((registry: CppRegistry, entity: number) => number) | undefinedmesh2d_setGeometry: ((registry: CppRegistry, entity: number, posUvPtr: number, vertexCount: number, colorsPtr: number, indicesPtr: number, indexCount: number) => void) | undefined+mesh2d_setMesh: ((registry: CppRegistry, entity: number, meshHandle: number) => void) | undefined+mesh_create: ((posUvPtr: number, vertexCount: number, colorsPtr: number, indicesPtr: number, indexCount: number) => number) | undefinednotifyDeviceLost: ((reason: number, message: string) => void) | undefinedparticle_getAliveCount: ((entity: number) => number) | undefinedparticle_play: ((registry: CppRegistry, entity: number) => void) | undefineddiff --git a/sdk/src/wasm.ts b/sdk/src/wasm.tsindex 689dafae4..271a64e3a 100644--- a/sdk/src/wasm.ts+++ b/sdk/src/wasm.ts@@ -224,6 +224,24 @@ export interface ESEngineModule {* restores a context when it is ready, so this is expected to be retried.* On success the device is Recovering: drawing, with placeholder textures.*/+ /**+ * Upload geometry that STAYS on the GPU: interleaved f32 [x,y,z,u,v] per+ * vertex, optional RGBA8 colors, u32 triangle indices. Any number of entities+ * can draw the result, each with its own transform. Where the inline+ * `mesh2d_setGeometry` payload is rewritten per frame, this is uploaded once.+ */+ mesh_create?(posUvPtr: number, vertexCount: number, colorsPtr: number,+ indicesPtr: number, indexCount: number): number;+ /** Point a Mesh2D at a resident mesh; 0 returns it to its inline payload. */+ mesh2d_setMesh?(registry: CppRegistry, entity: number, meshHandle: number): void;+ /**+ * Freeze a Mesh2D's inline geometry onto the GPU — the same vertices, uploaded+ * once and drawn with a per-object transform. Returns the mesh handle, 0 if+ * the entity had no geometry to freeze.+ */+ mesh2d_makeResident?(registry: CppRegistry, entity: number): number;+ /** The same for every Mesh2D in the world; returns how many were frozen. */+ mesh2d_makeAllResident?(registry: CppRegistry): number;recoverDevice?(): boolean;/*** Take up the replacement device left on `Module.pendingWebGPUDevice`. Adiff --git a/src/esengine/bindings/RendererBindings.cpp b/src/esengine/bindings/RendererBindings.cppindex b9552d229..cc08fec83 100644--- a/src/esengine/bindings/RendererBindings.cpp+++ b/src/esengine/bindings/RendererBindings.cpp@@ -200,6 +200,112 @@ void mesh2d_setGeometry(ecs::Registry& registry, u32 entity,mesh->localMax = mx;}+// Geometry that STAYS on the GPU: interleaved f32 [x,y,z,u,v] plus optional RGBA8+// colors, validated exactly as the inline path is. createMesh appends the+// per-object transform, so nothing here knows how a mesh reaches the shader.+u32 mesh_create(uintptr_t posUvPtr, u32 vertexCount, uintptr_t colorsPtr,+ uintptr_t indicesPtr, u32 indexCount) {+ auto* rm = ctx().tryGet<resource::ResourceManager>();+ if (!rm || posUvPtr == 0 || indicesPtr == 0 || vertexCount == 0 || indexCount == 0) return 0;+ if (indexCount % 3 != 0) {+ ES_LOG_WARN("mesh_create: indexCount {} is not a triangle list; rejected", indexCount);+ return 0;+ }++ const f32* posUv = boundarySpan<f32>(posUvPtr, static_cast<u64>(vertexCount) * 5, "mesh_create.posUv");+ const u32* colors = colorsPtr ? boundarySpan<u32>(colorsPtr, vertexCount, "mesh_create.colors") : nullptr;+ const u32* indices = boundarySpan<u32>(indicesPtr, indexCount, "mesh_create.indices");+ if (!posUv || !indices || (colorsPtr && !colors)) return 0;++ for (u32 i = 0; i < indexCount; ++i) {+ if (indices[i] >= vertexCount) {+ ES_LOG_WARN("mesh_create: index {} out of range (vertexCount {}); rejected",+ indices[i], vertexCount);+ return 0;+ }+ }++ struct MeshVertex { f32 x, y, z, u, v; u32 color; };+ static_assert(sizeof(MeshVertex) == 24, "vertex stride must match the mesh layout");+ std::vector<MeshVertex> verts(vertexCount);+ glm::vec3 mn(posUv[0], posUv[1], posUv[2]);+ glm::vec3 mx = mn;+ for (u32 i = 0; i < vertexCount; ++i) {+ const f32* p = posUv + i * 5;+ verts[i] = { p[0], p[1], p[2], p[3], p[4], colors ? colors[i] : 0xFFFFFFFFu };+ mn = glm::min(mn, glm::vec3(p[0], p[1], p[2]));+ mx = glm::max(mx, glm::vec3(p[0], p[1], p[2]));+ }++ const GfxVertexAttribute channels[3] = {+ {0, 3, GfxDataType::Float, false, 0, 0},+ {1, 2, GfxDataType::Float, false, 12, 0},+ {2, 4, GfxDataType::UnsignedByte, true, 20, 0},+ };+ auto handle = rm->createMesh(+ ConstSpan<u8>(reinterpret_cast<const u8*>(verts.data()), verts.size() * sizeof(MeshVertex)),+ ConstSpan<u32>(indices, indexCount),+ ConstSpan<GfxVertexAttribute>(channels, 3), sizeof(MeshVertex), mn, mx);+ return handle.id();+}++// Freezes a Mesh2D's inline geometry onto the GPU: the same vertices, uploaded+// once and drawn with a per-object transform instead of being rewritten into+// every frame. The inline payload is cleared, so the two can never disagree.+namespace {+u32 freezeMeshGeometry(ecs::Mesh2D* mesh) {+ auto* rm = ctx().tryGet<resource::ResourceManager>();+ if (!mesh || !rm || mesh->vertices.empty() || mesh->indices.empty()) return 0;++ struct MeshVertex { f32 x, y, z, u, v; u32 color; };+ std::vector<MeshVertex> verts(mesh->vertices.size());+ for (usize i = 0; i < mesh->vertices.size(); ++i) {+ const auto& in = mesh->vertices[i];+ verts[i] = { in.position.x, in.position.y, 0.0f, in.uv.x, in.uv.y, in.color };+ }++ const GfxVertexAttribute channels[3] = {+ {0, 3, GfxDataType::Float, false, 0, 0},+ {1, 2, GfxDataType::Float, false, 12, 0},+ {2, 4, GfxDataType::UnsignedByte, true, 20, 0},+ };+ auto handle = rm->createMesh(+ ConstSpan<u8>(reinterpret_cast<const u8*>(verts.data()), verts.size() * sizeof(MeshVertex)),+ ConstSpan<u32>(mesh->indices.data(), mesh->indices.size()),+ ConstSpan<GfxVertexAttribute>(channels, 3), sizeof(MeshVertex),+ glm::vec3(mesh->localMin, 0.0f), glm::vec3(mesh->localMax, 0.0f));+ if (!handle.isValid()) return 0;++ mesh->mesh = handle;+ mesh->vertices.clear();+ mesh->indices.clear();+ return handle.id();+}+} // namespace++u32 mesh2d_makeResident(ecs::Registry& registry, u32 entity) {+ return freezeMeshGeometry(registry.tryGet<ecs::Mesh2D>(Entity::fromRaw(entity)));+}++u32 mesh2d_makeAllResident(ecs::Registry& registry) {+ u32 frozen = 0;+ for (auto entity : registry.view<ecs::Mesh2D>()) {+ if (freezeMeshGeometry(registry.tryGet<ecs::Mesh2D>(entity)) != 0) ++frozen;+ }+ return frozen;+}++/** @brief Points a Mesh2D at resident geometry; 0 returns it to its inline payload. */+void mesh2d_setMesh(ecs::Registry& registry, u32 entity, u32 meshHandle) {+ const Entity ent = Entity::fromRaw(entity);+ auto* mesh = registry.tryGet<ecs::Mesh2D>(ent);+ if (!mesh) {+ ES_LOG_WARN("mesh2d_setMesh: entity {} has no Mesh2D component", entity);+ return;+ }+ mesh->mesh = resource::MeshHandle(meshHandle);+}+void renderFrame(ecs::Registry& registry, i32 viewportWidth, i32 viewportHeight) {if (!g_initialized || !g_renderFrame) return;diff --git a/src/esengine/bindings/RendererBindings.hpp b/src/esengine/bindings/RendererBindings.hppindex 15738f9a9..78bc50db1 100644--- a/src/esengine/bindings/RendererBindings.hpp+++ b/src/esengine/bindings/RendererBindings.hpp@@ -69,6 +69,15 @@ void mesh2d_setGeometry(uintptr_t colorsPtr,uintptr_t indicesPtr, u32 indexCount);+/** @brief Uploads geometry that stays on the GPU; returns its handle, 0 on failure. */+u32 mesh_create(uintptr_t posUvPtr, u32 vertexCount, uintptr_t colorsPtr,+ uintptr_t indicesPtr, u32 indexCount);+/** @brief Points a Mesh2D at resident geometry; 0 returns it to its inline payload. */+void mesh2d_setMesh(ecs::Registry& registry, u32 entity, u32 meshHandle);+/** @brief Freezes a Mesh2D's inline geometry onto the GPU; returns its handle. */+u32 mesh2d_makeResident(ecs::Registry& registry, u32 entity);+/** @brief Freezes every Mesh2D in the world; returns how many were frozen. */+u32 mesh2d_makeAllResident(ecs::Registry& registry);#ifdef ES_ENABLE_PARTICLESvoid renderer_submitParticles(ecs::Registry& registry);#endifdiff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cppindex 1f4693f1e..f03f9876b 100644--- a/src/esengine/bindings/WebSDKEntry.cpp+++ b/src/esengine/bindings/WebSDKEntry.cpp@@ -523,6 +523,10 @@ EMSCRIPTEN_BINDINGS(esengine_renderer) {#endifemscripten::function("renderer_submitTextBatch", &esengine::renderer_submitTextBatch);emscripten::function("mesh2d_setGeometry", &esengine::mesh2d_setGeometry);+ emscripten::function("mesh_create", &esengine::mesh_create);+ emscripten::function("mesh2d_setMesh", &esengine::mesh2d_setMesh);+ emscripten::function("mesh2d_makeResident", &esengine::mesh2d_makeResident);+ emscripten::function("mesh2d_makeAllResident", &esengine::mesh2d_makeAllResident);emscripten::function("material_compileEsshader", &esengine::material_compileEsshader);emscripten::function("esshader_cookInfo", &esengine::esshader_cookInfo);diff --git a/src/esengine/data/shaders/mesh.esshader b/src/esengine/data/shaders/mesh.esshadernew file mode 100644index 000000000..28601d52b--- /dev/null+++ b/src/esengine/data/shaders/mesh.esshader@@ -0,0 +1,96 @@+#pragma shader "Mesh"+#pragma version 300 es++// GPU-resident geometry. Slot 0 is the mesh's own vertices, which are LOCAL+// space and are never rewritten; slot 1 is the per-object record the frame+// streams, so the same mesh drawn twice costs one more transform rather than+// one more copy of its vertices.++#pragma vertex+layout(location = 0) in vec3 a_position;+layout(location = 1) in vec2 a_texCoord;+layout(location = 2) in vec4 a_color;++layout(location = 3) in vec4 a_model0;+layout(location = 4) in vec4 a_model1;+layout(location = 5) in vec4 a_model2;+layout(location = 6) in vec4 a_model3;+layout(location = 7) in vec4 a_instTint;++layout(std140) uniform FrameConstants {+ mat4 u_projection;+};++out vec2 v_texCoord;+out vec4 v_color;++void main() {+ mat4 model = mat4(a_model0, a_model1, a_model2, a_model3);+ gl_Position = u_projection * model * vec4(a_position, 1.0);+ v_texCoord = a_texCoord;+ v_color = a_color * a_instTint;+}+#pragma end++#pragma fragment+precision mediump float;++in vec2 v_texCoord;+in vec4 v_color;++uniform sampler2D u_texture;++out vec4 fragColor;++void main() {+ vec4 texColor = texture(u_texture, v_texCoord);+ fragColor = texColor * v_color;+}+#pragma end++#pragma vertex wgsl+struct FrameConstants { projection : mat4x4f };+@group(0) @binding(0) var<uniform> frame : FrameConstants;++struct VSIn {+ @location(0) a_position : vec3f,+ @location(1) a_texCoord : vec2f,+ @location(2) a_color : vec4f,+ @location(3) a_model0 : vec4f,+ @location(4) a_model1 : vec4f,+ @location(5) a_model2 : vec4f,+ @location(6) a_model3 : vec4f,+ @location(7) a_instTint : vec4f,+};+struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_texCoord : vec2f,+ @location(1) v_color : vec4f,+};++@vertex fn vs_main(v : VSIn) -> VSOut {+ let model = mat4x4f(v.a_model0, v.a_model1, v.a_model2, v.a_model3);++ var out : VSOut;+ out.pos = frame.projection * model * vec4f(v.a_position, 1.0);+ out.v_texCoord = v.a_texCoord;+ out.v_color = v.a_color * v.a_instTint;+ return out;+}+#pragma end++#pragma fragment wgsl+@group(1) @binding(0) var t0 : texture_2d<f32>;+@group(1) @binding(8) var s0 : sampler;++struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_texCoord : vec2f,+ @location(1) v_color : vec4f,+};++@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {+ let texColor = textureSampleLevel(t0, s0, v.v_texCoord, 0.0);+ return texColor * v.v_color;+}+#pragma enddiff --git a/src/esengine/ecs/components/Mesh2D.hpp b/src/esengine/ecs/components/Mesh2D.hppindex b77d89fe2..0477c1c4d 100644--- a/src/esengine/ecs/components/Mesh2D.hpp+++ b/src/esengine/ecs/components/Mesh2D.hpp@@ -81,6 +81,15 @@ struct Mesh2D {// keep their asserted offsets because these members come last).// -------------------------------------------------------------------------+ /**+ * @brief GPU-resident geometry; when valid it is drawn INSTEAD of the vertices+ * below, which then stay empty.+ * @details The difference is where the vertices live, not what they are. The+ * inline payload is rewritten into every frame — right for geometry+ * that changes every frame, a re-upload of anything that does not.+ */+ resource::MeshHandle mesh;+/** @brief Local-space vertices (triangle list, indexed). */std::vector<MeshVertex2D> vertices;diff --git a/src/esengine/renderer/draw/BatchBuilder.cpp b/src/esengine/renderer/draw/BatchBuilder.cppindex 39b5d5088..2493b7d04 100644--- a/src/esengine/renderer/draw/BatchBuilder.cpp+++ b/src/esengine/renderer/draw/BatchBuilder.cpp@@ -86,6 +86,9 @@ void pushBatchDraw(DrawList& drawList, const ClipState& clips,cmd.vertex_byte_offset = vertexByteOffset;cmd.vertex_count = vertexCount;cmd.instance_count = key.instanceCount;+ cmd.vertex_buffer = key.vertexBuffer;+ cmd.index_buffer = key.indexBuffer;+ cmd.vertex_layout = key.vertexLayout;cmd.shader_id = key.shaderId;cmd.blend_mode = key.blend;cmd.layout_id = key.layoutId;diff --git a/src/esengine/renderer/draw/BatchBuilder.hpp b/src/esengine/renderer/draw/BatchBuilder.hppindex 940cab0b6..6dfdfc9a7 100644--- a/src/esengine/renderer/draw/BatchBuilder.hpp+++ b/src/esengine/renderer/draw/BatchBuilder.hpp@@ -103,6 +103,12 @@ struct BatchDrawKey {// > 0 selects an instanced draw: indexCount indices drawn instanceCount times, with// per-instance attributes based at the vertex byte offset (see DrawCommand).u32 instanceCount = 0;+ // Geometry the GPU already holds. Set together with a MeshInstance stream, whose+ // offset is the draw's vertexByteOffset: the mesh supplies the vertices and the+ // frame supplies only the transforms.+ BufferHandle vertexBuffer = BufferHandle::Invalid;+ BufferHandle indexBuffer = BufferHandle::Invalid;+ VertexLayoutHandle vertexLayout = VertexLayoutHandle::Invalid;};/**diff --git a/src/esengine/renderer/draw/DrawCommand.hpp b/src/esengine/renderer/draw/DrawCommand.hppindex fcde7971d..3654a9be5 100644--- a/src/esengine/renderer/draw/DrawCommand.hpp+++ b/src/esengine/renderer/draw/DrawCommand.hpp@@ -109,6 +109,15 @@ struct DrawCommand {// with per-instance attributes based at vertex_byte_offset (see LayoutId::ParticleInstance).u32 instance_count = 0;+ // Geometry on the GPU rather than in this frame's pool. Set together or not+ // at all; index_offset/index_count then index INTO these. Sorting, material and+ // depth state are unchanged — where vertices live is not what is drawn.+ BufferHandle vertex_buffer = BufferHandle::Invalid;+ BufferHandle index_buffer = BufferHandle::Invalid;+ VertexLayoutHandle vertex_layout = VertexLayoutHandle::Invalid;++ bool hasPersistentGeometry() const { return vertex_buffer != BufferHandle::Invalid; }+// Vertices owned by this command (from vertex_byte_offset). Needed so the merge pass// can rewrite their texIndex when coalescing into a multi-texture batch.u32 vertex_count = 0;@@ -219,7 +228,9 @@ struct DrawCommand {* is what kept them apart. canMergeWith is this, read as a bool.*/BatchBreak mergeBlocker(const DrawCommand& next) const {- // Instanced draws are one command per emitter — never coalesce them.+ // Instanced draws are one command per emitter — never coalesce them. This+ // covers resident meshes too: their per-object transform IS the instance+ // stream, so every such draw carries a count.if (instance_count != 0 || next.instance_count != 0) return BatchBreak::Instanced;if (shader_id != next.shader_id) return BatchBreak::Shader;if (blend_mode != next.blend_mode) return BatchBreak::Blend;diff --git a/src/esengine/renderer/draw/DrawList.cpp b/src/esengine/renderer/draw/DrawList.cppindex 4cfafab2b..5285c5216 100644--- a/src/esengine/renderer/draw/DrawList.cpp+++ b/src/esengine/renderer/draw/DrawList.cpp@@ -137,7 +137,9 @@ void DrawList::execute(GfxDevice& device, TransientBufferPool& buffers,// caches; a one-entry memo skips the lookup for identical consecutive (sorted) commands.PipelineDesc desc{};desc.program = ShaderHandle{cmd.shader_id};- desc.vertexLayout = buffers.layoutHandle(cmd.layout_id);+ desc.vertexLayout = cmd.hasPersistentGeometry()+ ? cmd.vertex_layout+ : buffers.layoutHandle(cmd.layout_id);desc.blend = cmd.blend_mode;// Opaque is a blend mode, not a second switch beside one: a material that// says None is asking for the source to replace the destination, and any@@ -192,7 +194,19 @@ void DrawList::execute(GfxDevice& device, TransientBufferPool& buffers,}}- if (cmd.instance_count > 0) {+ if (cmd.hasPersistentGeometry()) {+ // The mesh's buffers for geometry, the frame's pool for transforms.+ // Only the second was written this frame: an unchanged mesh costs no+ // upload, and drawing it twice costs one more transform.+ device.setVertexBuffer(0, cmd.vertex_buffer, 0);+ device.setVertexBuffer(1, buffers.vertexBuffer(LayoutId::MeshInstance),+ cmd.vertex_byte_offset);+ device.setIndexBuffer(cmd.index_buffer);+ device.drawElementsInstanced(+ cmd.index_count, GfxDataType::UnsignedInt,+ static_cast<u32>(static_cast<uintptr_t>(cmd.index_offset) * sizeof(u32)),+ cmd.instance_count);+ } else if (cmd.instance_count > 0) {// Instanced: static geometry (index_count indices from offset 0) drawn// instance_count times, instance attributes rebased at vertex_byte_offset.buffers.bindInstanceLayout(cmd.layout_id, cmd.vertex_byte_offset);diff --git a/src/esengine/renderer/plugins/MeshPlugin.cpp b/src/esengine/renderer/plugins/MeshPlugin.cppindex 2cdc45752..2f6b6cf58 100644--- a/src/esengine/renderer/plugins/MeshPlugin.cpp+++ b/src/esengine/renderer/plugins/MeshPlugin.cpp@@ -5,10 +5,17 @@#include "../store/MaterialStore.hpp"#include "../frame/RenderFrame.hpp"#include "../rhi/Texture.hpp"+#include "../rhi/ShaderEmbeds.generated.hpp"#include "../../ecs/components/Transform.hpp"#include "../../ecs/components/Mesh2D.hpp"+#include "../../resource/Mesh.hpp"+#include "../../resource/ShaderParser.hpp"+#include "../../core/Log.hpp"++#include <glm/gtc/matrix_transform.hpp>#include <cmath>+#include <cstring>namespace esengine {@@ -23,6 +30,26 @@ u32 mulColor(u32 a, u32 b) {}} // namespace+void MeshPlugin::init(RenderFrameContext& ctx) {+ // Authored as mesh.esshader, WGSL twin included. Its vertex stage is the one+ // that reads a model matrix, which is what lets the vertices stay local.+ const auto target = ctx.resources.preferredShaderTarget();+ auto parsed = resource::ShaderParser::parse(ShaderEmbeds::MESH);+ resource::ShaderHandle handle = ctx.resources.createShaderWithBindings(+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Vertex, "", {}, target),+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Fragment, "", {}, target),+ {}, ctx.resources.preferredShaderLanguage());+ Shader* shader = ctx.resources.getShader(handle);+ if (shader && shader->isValid()) {+ mesh_shader_id_ = shader->getProgramId();+ if (shader->language() == GfxShaderLanguage::GLSL_ES300) {+ shader->bind();+ shader->setUniform("u_texture", 0);+ shader->unbind();+ }+ }+}+void MeshPlugin::collect(RenderCollectContext& collect_ctx) {auto& registry = collect_ctx.registry;auto& frustum = collect_ctx.frustum;@@ -36,21 +63,28 @@ void MeshPlugin::collect(RenderCollectContext& collect_ctx) {for (auto entity : meshView) {const auto& mesh = meshView.get<ecs::Mesh2D>(entity);- if (!mesh.enabled || mesh.indices.empty()) continue;+ // Empty indices no longer mean "nothing to draw": a resident mesh keeps+ // its geometry on the GPU and its inline payload deliberately empty.+ if (!mesh.enabled || (mesh.indices.empty() && !mesh.mesh.isValid())) continue;auto& transform = meshView.get<ecs::Transform>(entity);glm::vec3 position = parallaxedWorldPosition(transform, mesh.parallax, collect_ctx.camera);const auto& rotation = transform.worldRotation;const auto& scale = transform.worldScale;+ // Bounds come from whichever geometry this is: a resident mesh keeps its+ // own, and the inline payload's are recomputed on upload. Reading the+ // component's for a resident mesh would cull it against an empty box.+ const Mesh* resident = mesh.mesh.isValid() ? ctx.resources.getMesh(mesh.mesh) : nullptr;+ const glm::vec3 localMin = resident ? resident->localMin : glm::vec3(mesh.localMin, 0.0f);+ const glm::vec3 localMax = resident ? resident->localMax : glm::vec3(mesh.localMax, 0.0f);+// Cull at the local AABB scaled into world space (rotation ignored — the// same approximation the sprite path uses).- glm::vec2 localCenter = (mesh.localMin + mesh.localMax) * 0.5f;- glm::vec2 localHalf = (mesh.localMax - mesh.localMin) * 0.5f;- glm::vec3 aabbCenter = position- + glm::vec3(localCenter.x * scale.x, localCenter.y * scale.y, 0.0f);- glm::vec3 halfExtents(std::abs(localHalf.x * scale.x),- std::abs(localHalf.y * scale.y), 0.0f);+ glm::vec3 localCenter = (localMin + localMax) * 0.5f;+ glm::vec3 localHalf = (localMax - localMin) * 0.5f;+ glm::vec3 aabbCenter = position + localCenter * scale;+ glm::vec3 halfExtents = glm::abs(localHalf * scale);if (!frustum.intersectsAABB(aabbCenter, halfExtents)) continue;u32 textureId = ctx.white_texture_id;@@ -89,6 +123,32 @@ void MeshPlugin::collect(RenderCollectContext& collect_ctx) {if (litProgram != 0) key.shaderId = litProgram;}+ // Resident geometry: only the transform is written for the frame. Its+ // vertices are local-space and untouched, so the CPU loop below — which+ // exists to bake world space into every vertex — is skipped entirely.+ if (resident && mesh_shader_id_ != 0) {+ if (resident->isDrawable()) {+ u32 instOffset = buffers.allocVertices(LayoutId::MeshInstance, MESH_INSTANCE_STRIDE);+ auto* dst = buffers.vertexData(LayoutId::MeshInstance) + instOffset;+ glm::mat4 model = glm::translate(glm::mat4(1.0f), position)+ * glm::mat4_cast(rotation)+ * glm::scale(glm::mat4(1.0f), scale);+ std::memcpy(dst, &model[0][0], 64);+ u32 tintRGBA = packColor(mesh.color);+ std::memcpy(dst + 64, &tintRGBA, 4);++ key.shaderId = (mesh.material != 0 && key.materialId != 0)+ ? key.shaderId : mesh_shader_id_;+ key.layoutId = LayoutId::MeshInstance;+ key.instanceCount = 1;+ key.vertexBuffer = resident->vertexBuffer;+ key.indexBuffer = resident->indexBuffer;+ key.vertexLayout = resident->layout;+ pushBatchDraw(draw_list, clips, instOffset, 0, 0, resident->indexCount, key);+ }+ continue;+ }+f32 angle = 2.0f * std::atan2(rotation.z, rotation.w);bool rotated = std::abs(angle) > 0.001f;f32 cosA = 1.0f, sinA = 0.0f;diff --git a/src/esengine/renderer/plugins/MeshPlugin.hpp b/src/esengine/renderer/plugins/MeshPlugin.hppindex 004852caf..b04512c87 100644--- a/src/esengine/renderer/plugins/MeshPlugin.hpp+++ b/src/esengine/renderer/plugins/MeshPlugin.hpp@@ -18,10 +18,12 @@ namespace esengine {*/class MeshPlugin : public RenderTypePlugin {public:+ void init(RenderFrameContext& ctx) override;void collect(RenderCollectContext& ctx) override;private:std::vector<BatchVertex> scratch_; ///< Reused per mesh; amortizes the transform buffer.+ u32 mesh_shader_id_ = 0; ///< Draws resident geometry with a per-object transform.};} // namespace esenginediff --git a/src/esengine/renderer/rhi/GfxEnums.hpp b/src/esengine/renderer/rhi/GfxEnums.hppindex e3983f402..2eb9e9aea 100644--- a/src/esengine/renderer/rhi/GfxEnums.hpp+++ b/src/esengine/renderer/rhi/GfxEnums.hpp@@ -81,9 +81,18 @@ enum class LayoutId : u8 {Batch = 0,ParticleInstance = 1, ///< Instanced: a static unit quad + a per-particle instance stream.Shape = 2,+ /// Per-object transforms for GPU-resident meshes. Only the stream is the+ /// pool's; the layout belongs to the mesh, which is the one that knows what+ /// its own vertices look like.+ MeshInstance = 3,};-static constexpr u32 LAYOUT_COUNT = 3;+static constexpr u32 LAYOUT_COUNT = 4;++/// One per-object record for a resident mesh: a model matrix and a tint.+static constexpr u32 MESH_INSTANCE_STRIDE = 68;+/// The attributes that record occupies (4 matrix rows + the tint).+static constexpr u32 MESH_INSTANCE_ATTRIBUTES = 5;// =============================================================================// Data Type (vertex attributes, index type, pixel data type)@@ -101,7 +110,10 @@ enum class GfxDataType : u8 {// Vertex Layout (part of a pipeline's identity; see PipelineDesc)// =============================================================================-static constexpr u32 MAX_VERTEX_ATTRIBUTES = 8;+// 16 because that is what GLES3 and WebGPU both guarantee, and because a mesh+// carrying its own channels plus a per-instance transform passes 8 as soon as it+// has normals — the limit was the batch layouts' size, not the hardware's.+static constexpr u32 MAX_VERTEX_ATTRIBUTES = 16;static constexpr u32 MAX_VERTEX_BUFFER_SLOTS = 2;struct GfxVertexAttribute {diff --git a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hppindex 869cc9627..fab670fae 100644--- a/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp+++ b/src/esengine/renderer/rhi/ShaderEmbeds.generated.hpp@@ -271,6 +271,104 @@ void main() {#pragma end)esshader";+inline constexpr const char* MESH = R"esshader(#pragma shader "Mesh"+#pragma version 300 es++// GPU-resident geometry. Slot 0 is the mesh's own vertices, which are LOCAL+// space and are never rewritten; slot 1 is the per-object record the frame+// streams, so the same mesh drawn twice costs one more transform rather than+// one more copy of its vertices.++#pragma vertex+layout(location = 0) in vec3 a_position;+layout(location = 1) in vec2 a_texCoord;+layout(location = 2) in vec4 a_color;++layout(location = 3) in vec4 a_model0;+layout(location = 4) in vec4 a_model1;+layout(location = 5) in vec4 a_model2;+layout(location = 6) in vec4 a_model3;+layout(location = 7) in vec4 a_instTint;++layout(std140) uniform FrameConstants {+ mat4 u_projection;+};++out vec2 v_texCoord;+out vec4 v_color;++void main() {+ mat4 model = mat4(a_model0, a_model1, a_model2, a_model3);+ gl_Position = u_projection * model * vec4(a_position, 1.0);+ v_texCoord = a_texCoord;+ v_color = a_color * a_instTint;+}+#pragma end++#pragma fragment+precision mediump float;++in vec2 v_texCoord;+in vec4 v_color;++uniform sampler2D u_texture;++out vec4 fragColor;++void main() {+ vec4 texColor = texture(u_texture, v_texCoord);+ fragColor = texColor * v_color;+}+#pragma end++#pragma vertex wgsl+struct FrameConstants { projection : mat4x4f };+@group(0) @binding(0) var<uniform> frame : FrameConstants;++struct VSIn {+ @location(0) a_position : vec3f,+ @location(1) a_texCoord : vec2f,+ @location(2) a_color : vec4f,+ @location(3) a_model0 : vec4f,+ @location(4) a_model1 : vec4f,+ @location(5) a_model2 : vec4f,+ @location(6) a_model3 : vec4f,+ @location(7) a_instTint : vec4f,+};+struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_texCoord : vec2f,+ @location(1) v_color : vec4f,+};++@vertex fn vs_main(v : VSIn) -> VSOut {+ let model = mat4x4f(v.a_model0, v.a_model1, v.a_model2, v.a_model3);++ var out : VSOut;+ out.pos = frame.projection * model * vec4f(v.a_position, 1.0);+ out.v_texCoord = v.a_texCoord;+ out.v_color = v.a_color * v.a_instTint;+ return out;+}+#pragma end++#pragma fragment wgsl+@group(1) @binding(0) var t0 : texture_2d<f32>;+@group(1) @binding(8) var s0 : sampler;++struct VSOut {+ @builtin(position) pos : vec4f,+ @location(0) v_texCoord : vec2f,+ @location(1) v_color : vec4f,+};++@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {+ let texColor = textureSampleLevel(t0, s0, v.v_texCoord, 0.0);+ return texColor * v.v_color;+}+#pragma end+)esshader";+inline constexpr const char* PARTICLE = R"esshader(#pragma shader "ParticleInstance"#pragma version 300 esdiff --git a/src/esengine/renderer/rhi/TransientBufferPool.cpp b/src/esengine/renderer/rhi/TransientBufferPool.cppindex b0f035c21..f61e232ec 100644--- a/src/esengine/renderer/rhi/TransientBufferPool.cpp+++ b/src/esengine/renderer/rhi/TransientBufferPool.cpp@@ -17,7 +17,8 @@ void TransientBufferPool::init(u32 initialVertexBytes, u32 initialIndexCount) {initial_vertex_bytes_ = initialVertexBytes;initial_index_count_ = initialIndexCount;- for (auto layout : {LayoutId::Batch, LayoutId::ParticleInstance, LayoutId::Shape}) {+ for (auto layout : {LayoutId::Batch, LayoutId::ParticleInstance, LayoutId::Shape,+ LayoutId::MeshInstance}) {setupStream(layout);}@@ -197,6 +198,17 @@ u32 TransientBufferPool::vertexStride(LayoutId layout) const {void TransientBufferPool::setupStream(LayoutId layout) {Stream& s = stream(layout);+ if (layout == LayoutId::MeshInstance) {+ // Only a stream. The geometry is the mesh's and so is the layout — this+ // holds the per-object transforms written for the frame, which is the one+ // part of drawing a resident mesh that is not resident.+ s.vertex_staging.resize(initial_vertex_bytes_);+ s.vbo_capacity = initial_vertex_bytes_;+ s.vbo = device_.createBuffer({GfxBufferUsage::Vertex, s.vbo_capacity, /*dynamic=*/true}, nullptr);+ s.vertex_stride = MESH_INSTANCE_STRIDE;+ return;+ }+if (layout == LayoutId::ParticleInstance) {// Per-instance (per-particle) stream: dynamic, streamed each frame.s.vertex_staging.resize(initial_vertex_bytes_);diff --git a/src/esengine/resource/Handle.hpp b/src/esengine/resource/Handle.hppindex 7b73ae0f1..a8e781ba9 100644--- a/src/esengine/resource/Handle.hpp+++ b/src/esengine/resource/Handle.hpp@@ -187,6 +187,7 @@ namespace esengine {class Texture;class VertexBuffer;class IndexBuffer;+ class Mesh;}// Forward-declared only — the native spine runtime was removed (spine is fully@@ -219,6 +220,9 @@ using VertexBufferHandle = Handle<esengine::VertexBuffer>;/** @brief Handle to an index buffer resource */using IndexBufferHandle = Handle<esengine::IndexBuffer>;+/** @brief Handle to GPU-resident geometry */+using MeshHandle = Handle<esengine::Mesh>;+/** @brief Handle to a Spine skeleton data resource (vestigial — see fwd decl) */using SpineDataHandle = Handle<esengine::spine::SpineSkeletonData>;diff --git a/src/esengine/resource/Mesh.hpp b/src/esengine/resource/Mesh.hppnew file mode 100644index 000000000..378103e92--- /dev/null+++ b/src/esengine/resource/Mesh.hpp@@ -0,0 +1,47 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file Mesh.hpp+ * @brief Geometry that lives on the GPU rather than in a frame.+ */+#pragma once++#include "../core/Types.hpp"+#include "../math/Math.hpp"+#include "../renderer/rhi/GfxEnums.hpp"+#include "./Handle.hpp"++namespace esengine {++/**+ * @brief Buffers, the layout that describes them, and the bounds culling reads.+ *+ * @details One record because the three are inseparable: a buffer without its+ * layout cannot be drawn, and bounds kept elsewhere go stale. Material,+ * layer and transform belong to the entity, so one mesh serves many.+ */+class Mesh {+public:+ resource::VertexBufferHandle vertices;+ resource::IndexBufferHandle indices;++ /** GPU-side handles, cached so a draw does not walk two pools per frame. */+ BufferHandle vertexBuffer = BufferHandle::Invalid;+ BufferHandle indexBuffer = BufferHandle::Invalid;+ VertexLayoutHandle layout = VertexLayoutHandle::Invalid;++ u32 indexCount = 0;++ /** Local-space bounds of the vertices, for the frustum cull. */+ glm::vec3 localMin{0.0f, 0.0f, 0.0f};+ glm::vec3 localMax{0.0f, 0.0f, 0.0f};++ bool isDrawable() const {+ return vertexBuffer != BufferHandle::Invalid+ && indexBuffer != BufferHandle::Invalid+ && layout != VertexLayoutHandle::Invalid+ && indexCount > 0;+ }+};++} // namespace esenginediff --git a/src/esengine/resource/ResourceManager.cpp b/src/esengine/resource/ResourceManager.cppindex 67ad8f12a..47a57d5a9 100644--- a/src/esengine/resource/ResourceManager.cpp+++ b/src/esengine/resource/ResourceManager.cpp@@ -471,6 +471,78 @@ void ResourceManager::releaseVertexBuffer(VertexBufferHandle handle) {}}+// =============================================================================+// Mesh Resources+// =============================================================================++MeshHandle ResourceManager::createMesh(ConstSpan<u8> vertexBytes, ConstSpan<u32> indices,+ ConstSpan<GfxVertexAttribute> channels, u32 vertexStride,+ const glm::vec3& localMin, const glm::vec3& localMax) {+ if (!device_ || vertexBytes.empty() || indices.empty() || channels.empty()) return MeshHandle();++ // The mesh describes its own vertices; the per-object transform is the+ // engine's and is appended here, so no caller has to know how a transform+ // reaches the shader — the reason a mesh is drawn without touching its bytes.+ VertexLayoutDesc layout;+ if (channels.size() + MESH_INSTANCE_ATTRIBUTES > MAX_VERTEX_ATTRIBUTES) {+ ES_LOG_ERROR("createMesh: {} channels exceeds the layout budget", channels.size());+ return MeshHandle();+ }+ for (usize i = 0; i < channels.size(); ++i) {+ layout.attributes[i] = channels[i];+ layout.attributes[i].bufferSlot = 0;+ }+ layout.strides[0] = vertexStride;+ layout.strides[1] = MESH_INSTANCE_STRIDE;+ layout.instanceStep[1] = true;+ u32 next = static_cast<u32>(channels.size());+ const u32 firstInstanceLocation = next;+ for (u32 row = 0; row < 4; ++row) {+ layout.attributes[next++] = {firstInstanceLocation + row, 4, GfxDataType::Float,+ false, row * 16u, 1};+ }+ layout.attributes[next++] = {firstInstanceLocation + 4, 4, GfxDataType::UnsignedByte,+ true, 64, 1};+ layout.attributeCount = next;++ auto mesh = makeUnique<Mesh>();+ mesh->vertices = createVertexBuffer(vertexBytes);+ mesh->indices = createIndexBuffer(indices);+ if (!mesh->vertices.isValid() || !mesh->indices.isValid()) {+ releaseVertexBuffer(mesh->vertices);+ releaseIndexBuffer(mesh->indices);+ return MeshHandle();+ }++ const VertexBuffer* vb = getVertexBuffer(mesh->vertices);+ const IndexBuffer* ib = getIndexBuffer(mesh->indices);+ mesh->vertexBuffer = vb ? vb->handle() : BufferHandle::Invalid;+ mesh->indexBuffer = ib ? ib->handle() : BufferHandle::Invalid;+ mesh->layout = device_->createVertexLayout(layout);+ mesh->indexCount = static_cast<u32>(indices.size());+ mesh->localMin = localMin;+ mesh->localMax = localMax;+ return meshes_.add(std::move(mesh));+}++Mesh* ResourceManager::getMesh(MeshHandle handle) {+ return meshes_.get(handle);+}++const Mesh* ResourceManager::getMesh(MeshHandle handle) const {+ return meshes_.get(handle);+}++void ResourceManager::releaseMesh(MeshHandle handle) {+ Mesh* mesh = meshes_.get(handle);+ if (!mesh) return;+ // The buffers are the mesh's own, so they go with it; the layout is not, since+ // createVertexLayout caches by description and other meshes share the result.+ releaseVertexBuffer(mesh->vertices);+ releaseIndexBuffer(mesh->indices);+ meshes_.release(handle.id());+}+// =============================================================================// Index Buffer Resources// =============================================================================diff --git a/src/esengine/resource/ResourceManager.hpp b/src/esengine/resource/ResourceManager.hppindex 2e7a19fb2..6c4c3db01 100644--- a/src/esengine/resource/ResourceManager.hpp+++ b/src/esengine/resource/ResourceManager.hpp@@ -27,6 +27,7 @@#include "../renderer/rhi/Shader.hpp"#include "../renderer/rhi/Texture.hpp"#include "../renderer/rhi/Buffer.hpp"+#include "Mesh.hpp"#include "../text/BitmapFont.hpp"// Standard library@@ -447,6 +448,27 @@ public:*/VertexBufferHandle createVertexBuffer(u32 sizeBytes);+ /**+ * @brief Uploads geometry that stays on the GPU, drawn from its own buffers.+ * @details The frame's transient pool, which every renderable uses today, is+ * rewritten by the CPU each frame — a per-frame re-upload of anything+ * that does not change. The layout travels with the buffers: one whose+ * attribute description lives elsewhere is a rename from garbage.+ * @param vertexBytes Raw vertex data, laid out as @p layout describes.+ * @param indices Triangle-list indices into it.+ * @return Handle to the mesh, or invalid on failure.+ */+ MeshHandle createMesh(ConstSpan<u8> vertexBytes, ConstSpan<u32> indices,+ ConstSpan<GfxVertexAttribute> channels, u32 vertexStride,+ const glm::vec3& localMin, const glm::vec3& localMax);++ /** @brief The mesh a handle names, or null. */+ Mesh* getMesh(MeshHandle handle);+ const Mesh* getMesh(MeshHandle handle) const;++ /** @brief Releases a mesh and the buffers it owns. */+ void releaseMesh(MeshHandle handle);+/*** @brief Gets a vertex buffer by handle* @param handle The buffer handle@@ -585,6 +607,7 @@ private:ResourcePool<Texture> textures_;ResourcePool<VertexBuffer> vertexBuffers_;ResourcePool<IndexBuffer> indexBuffers_;+ ResourcePool<Mesh> meshes_;ResourcePool<text::BitmapFont> fonts_;/// Handles whose GPU texture died with the device, still showing the/// placeholder. Empty means the content is whole again.diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex 2075392ca..e10196ce9 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -112,6 +112,10 @@ export const SCENES = [{ id: "material-preview", tier: "pr", webgpu: { ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" }, env: { ESTELLA_VERIFY_SCENE: "/scenes/mat-tint.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mat-tint.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_PREVIEW: "{\"w\":64,\"h\":64,\"rgb\":[255,0,0],\"tol\":45}" } },{ id: "tilemap-hex", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/tilemap-hex.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/tilemap-hex.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "6", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.40,\"y\":0.40,\"rgb\":[255,0,0]},{\"x\":0.60,\"y\":0.40,\"rgb\":[0,255,0]},{\"x\":0.50,\"y\":0.55,\"rgb\":[0,0,255]},{\"x\":0.70,\"y\":0.55,\"rgb\":[255,255,0]}]" } },{ id: "postprocess-lut", tier: "nightly", webgpu: true, env: { ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_SCENE: "/scenes/lut-grade.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/lut-grade.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "10", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.292,\"y\":0.5,\"rgb\":[0,0,255],\"tol\":40},{\"x\":0.708,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" } },+ // mesh2d's scene and assertions, with its geometry frozen onto the GPU mid-run.+ // Equal pixels IS the claim, so it borrows the assertions rather than restating+ // them; a run that froze nothing fails on its own count.+ { id: "mesh-resident", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_MESH_RESIDENT: "1", ESTELLA_VERIFY_SCENE: "/scenes/mesh2d.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mesh2d.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.30,\"y\":0.556,\"rgb\":[255,0,0],\"tol\":40},{\"x\":0.70,\"y\":0.556,\"rgb\":[0,255,0],\"tol\":40},{\"x\":0.30,\"y\":0.40,\"rgb\":[255,0,0],\"tol\":40}]" } },// Takes the GPU away for real and captures AFTER the cycle: the four points// sample the atlas, so they fail unless the content came back. A vertex-colour// scene passed with the re-upload deleted. No webgpu — no GL extension there.