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): a post-process shader with more than seven textures has units for them, and WebGPU says what made a frame invalid - material texture params take units 8 to 14, and past them a Lit shader takes a unit below 8 it never reads while a PostProcess one took none: the eighth texture of a fullscreen pass had no unit (on WebGPU no binding); 4 and 5, which no fullscreen pass is handed anything on, are now free for it. A WebGPU validation error was dropped in silence, leaving only the queue refusing an invalid command buffer: the first eight are now logged
yhh5f7881c56bcb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 93a7189fc..4046ea4b3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -40,6 +40,7 @@ published separately; it ships inside the editor.### Fixed+- **A post-process shader can read more than seven textures.** A fullscreen shader's eighth texture parameter found no texture unit and was not bound; units 4 and 5 now take the eighth and ninth. On WebGPU the first validation errors of a run are logged, where before only a refused command buffer reached the console.- **A Spine skeleton is selected by the character it draws.** A skeleton could be picked only on the small icon at its origin, so clicking the character selected nothing. The editor hands the pick box the skeleton's own bounds through the new `extentOf` option of `entityWorldBox` and `pickEntitiesByRay`, and the selection outline follows the same box.- **Nudging a selection moves each selected root once, so a selected child no longer travels twice.** With a parent and its child both selected, an arrow key moved the child by the nudge and again with its parent; each selected root now moves once and what is under it follows.- **A click selects a shape by its drawn size, and a bare Canvas no longer takes the click.** A ShapeRenderer could be selected only on the small icon at its origin, and any scene with a Canvas answered every click in the design screen with the Canvas, so the sprites beneath could not be clicked at all. A shape is picked by its size and its own sorting layer, and a UI node that draws nothing is picked only where nothing else is.diff --git a/src/esengine/renderer/webgpu/WebGPUDevice.cpp b/src/esengine/renderer/webgpu/WebGPUDevice.cppindex e648158a7..01ab0f996 100644--- a/src/esengine/renderer/webgpu/WebGPUDevice.cpp+++ b/src/esengine/renderer/webgpu/WebGPUDevice.cpp@@ -130,6 +130,11 @@ void WebGPUDevice::reportUncapturedError(u32 wgpuErrorType, const char* message)} else if (type == WGPUErrorType_Internal) {markDeviceLost(GfxDeviceLostReason::Internal, message ? message : "","uncaptured error");+ } else if (type == WGPUErrorType_Validation && validation_errors_logged_ < 8) {+ // Said, the first few: otherwise all that reaches the console is the queue refusing an invalid command buffer, which names+ // nothing that made it invalid.+ ++validation_errors_logged_;+ ES_LOG_WARN("WebGPU validation error: {}", message ? message : "(no message)");}}diff --git a/src/esengine/renderer/webgpu/WebGPUDevice.hpp b/src/esengine/renderer/webgpu/WebGPUDevice.hppindex 44117ae7e..c4ab71b35 100644--- a/src/esengine/renderer/webgpu/WebGPUDevice.hpp+++ b/src/esengine/renderer/webgpu/WebGPUDevice.hpp@@ -101,6 +101,8 @@ public:/** @brief Routes the device's uncaptured-error callback; only fatal kinds become losses. */void reportUncapturedError(u32 wgpuErrorType, const char* message);+ /// Validation errors said so far (reportUncapturedError says the first few).+ u32 validation_errors_logged_ = 0;bool pollDeviceLost() override;diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex b847109b5..1d6e3ffce 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -4643,6 +4643,12 @@ u32 ShaderParser::materialOverflowUnits(const ParsedShader& shader) {| (1u << LIGHTMAP_TEXTURE_UNIT) | (1u << SHAPE_2D_TEXTURE_UNIT) | (1u << SHADOW_2D_TEXTURE_UNIT);} else if (shader.domain == "Unlit") {reads = 1u << MORPH_DELTA_TEXTURE_UNIT;+ } else if (shader.domain == "PostProcess") {+ // A fullscreen pass is handed its input and the scene on 0 and 1, the shadow atlas and the environment on 2 and 3, and the+ // surface record and the scene's depth on 6 and 7, which its WGSL declares whether it reads them (PostProcessPipeline::renderPass):+ // 4 and 5 are left for a pass with more textures than the units above the base hold (a terrain's surface bake reads eight).+ reads = (1u << 0) | (1u << 1) | (1u << SHADOW_MAP_TEXTURE_UNIT) | (1u << ENV_MAP_TEXTURE_UNIT) | (1u << kGBufferUnit)+ | (1u << kSceneDepthUnit);} else {return 0;}diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex b1076e4dd..12542f097 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -4838,4 +4838,6 @@ export const NOTED = {{"note": "A click selects a shape by its drawn size, and a bare Canvas no longer takes the click."},"feat(render): a mesh, a material, a texture and the frame's probes each carry a revision that changes whenever their content does - one counter for all of them (core/Revision.hpp), so what the renderer derives from a resource can be kept until the resource itself changes":{"note": "Resources carry a revision that changes with their content."},+ "fix(render): a post-process shader with more than seven textures has units for them, and WebGPU says what made a frame invalid - material texture params take units 8 to 14, and past them a Lit shader takes a unit below 8 it never reads while a PostProcess one took none: the eighth texture of a fullscreen pass had no unit (on WebGPU no binding); 4 and 5, which no fullscreen pass is handed anything on, are now free for it. A WebGPU validation error was dropped in silence, leaving only the queue refusing an invalid command buffer: the first eight are now logged":+ {"note": "A post-process shader can read more than seven textures."},};