Skip to content

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.

feat(ci): the native texture path has a guard, and it is a real one

esengine256bb151815e
diff --git a/examples/platformer/assets/scenes/main.esscene b/examples/platformer/assets/scenes/main.esscene
index 2c7478ad7..458a22eba 100644
--- a/examples/platformer/assets/scenes/main.esscene
+++ b/examples/platformer/assets/scenes/main.esscene
@@ -1,7 +1,12 @@
{
"version": "1.0",
"name": "Main",
- "folders": ["Environment", "Platforms", "Coins", "UI"],
+ "folders": [
+ "Environment",
+ "Platforms",
+ "Coins",
+ "UI"
+ ],
"entities": [
{
"id": 0,
@@ -9,8 +14,25 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 10 } } },
- { "type": "Camera", "data": { "projectionType": 1, "orthoSize": 350, "isActive": true, "priority": 0 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 350,
+ "isActive": true,
+ "priority": 0
+ }
+ }
],
"visible": true
},
@@ -21,8 +43,27 @@
"children": [],
"folder": "Environment",
"components": [
- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 800, "y": 700 }, "texture": "@uuid:74b832b1-40ae-4095-a620-c027735cb482", "layer": -10 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 800,
+ "y": 700
+ },
+ "texture": "@uuid:74b832b1-40ae-4095-a620-c027735cb482",
+ "layer": -10
+ }
+ }
],
"visible": true
},
@@ -33,10 +74,49 @@
"children": [],
"folder": "Environment",
"components": [
- { "type": "Transform", "data": { "position": { "x": 0, "y": -250, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 800, "y": 40 }, "color": { "r": 0.4, "g": 0.7, "b": 0.3, "a": 1 }, "texture": "@uuid:931ebe66-cded-4b32-8444-0737da446c0d" } },
- { "type": "RigidBody", "data": { "bodyType": 0 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 4.0, "y": 0.2 }, "categoryBits": 1, "maskBits": 65535 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": -250,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 800,
+ "y": 40
+ },
+ "color": {
+ "r": 0.4,
+ "g": 0.7,
+ "b": 0.3,
+ "a": 1
+ },
+ "texture": "@uuid:931ebe66-cded-4b32-8444-0737da446c0d"
+ }
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 4,
+ "y": 0.2
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ }
],
"visible": true
},
@@ -47,10 +127,49 @@
"children": [],
"folder": "Platforms",
"components": [
- { "type": "Transform", "data": { "position": { "x": -200, "y": -120, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 160, "y": 24 }, "color": { "r": 0.6, "g": 0.5, "b": 0.3, "a": 1 }, "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7" } },
- { "type": "RigidBody", "data": { "bodyType": 0 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 0.8, "y": 0.12 }, "categoryBits": 1, "maskBits": 65535 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -200,
+ "y": -120,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 160,
+ "y": 24
+ },
+ "color": {
+ "r": 0.6,
+ "g": 0.5,
+ "b": 0.3,
+ "a": 1
+ },
+ "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7"
+ }
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 0.8,
+ "y": 0.12
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ }
],
"visible": true
},
@@ -61,10 +180,49 @@
"children": [],
"folder": "Platforms",
"components": [
- { "type": "Transform", "data": { "position": { "x": 100, "y": -20, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 160, "y": 24 }, "color": { "r": 0.6, "g": 0.5, "b": 0.3, "a": 1 }, "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7" } },
- { "type": "RigidBody", "data": { "bodyType": 0 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 0.8, "y": 0.12 }, "categoryBits": 1, "maskBits": 65535 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 100,
+ "y": -20,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 160,
+ "y": 24
+ },
+ "color": {
+ "r": 0.6,
+ "g": 0.5,
+ "b": 0.3,
+ "a": 1
+ },
+ "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7"
+ }
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 0.8,
+ "y": 0.12
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ }
],
"visible": true
},
@@ -75,10 +233,49 @@
"children": [],
"folder": "Platforms",
"components": [
- { "type": "Transform", "data": { "position": { "x": -80, "y": 100, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 200, "y": 24 }, "color": { "r": 0.6, "g": 0.5, "b": 0.3, "a": 1 }, "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7" } },
- { "type": "RigidBody", "data": { "bodyType": 0 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 1.0, "y": 0.12 }, "categoryBits": 1, "maskBits": 65535 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -80,
+ "y": 100,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 200,
+ "y": 24
+ },
+ "color": {
+ "r": 0.6,
+ "g": 0.5,
+ "b": 0.3,
+ "a": 1
+ },
+ "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7"
+ }
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 1,
+ "y": 0.12
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ }
],
"visible": true
},
@@ -89,10 +286,49 @@
"children": [],
"folder": "Platforms",
"components": [
- { "type": "Transform", "data": { "position": { "x": 220, "y": 180, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 140, "y": 24 }, "color": { "r": 0.6, "g": 0.5, "b": 0.3, "a": 1 }, "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7" } },
- { "type": "RigidBody", "data": { "bodyType": 0 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 0.7, "y": 0.12 }, "categoryBits": 1, "maskBits": 65535 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 220,
+ "y": 180,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 140,
+ "y": 24
+ },
+ "color": {
+ "r": 0.6,
+ "g": 0.5,
+ "b": 0.3,
+ "a": 1
+ },
+ "texture": "@uuid:0258e55e-9aa0-47eb-8092-7386e03f97c7"
+ }
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 0.7,
+ "y": 0.12
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ }
],
"visible": true
},
@@ -103,9 +339,33 @@
"children": [],
"folder": "Environment",
"components": [
- { "type": "Transform", "data": { "position": { "x": -420, "y": 0, "z": 0 } } },
- { "type": "RigidBody", "data": { "bodyType": 0 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 0.1, "y": 4.0 }, "categoryBits": 1, "maskBits": 65535 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -420,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 0.1,
+ "y": 4
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ }
],
"visible": true
},
@@ -116,9 +376,33 @@
"children": [],
"folder": "Environment",
"components": [
- { "type": "Transform", "data": { "position": { "x": 420, "y": 0, "z": 0 } } },
- { "type": "RigidBody", "data": { "bodyType": 0 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 0.1, "y": 4.0 }, "categoryBits": 1, "maskBits": 65535 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 420,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 0.1,
+ "y": 4
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ }
],
"visible": true
},
@@ -128,12 +412,60 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": -200, "y": -180, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 32, "y": 48 }, "color": { "r": 0.2, "g": 0.6, "b": 1, "a": 1 }, "texture": "@uuid:2bde6b7d-0dbe-4434-9e30-ed1cd8e3fe82", "layer": 1 } },
- { "type": "Player", "data": {} },
- { "type": "RigidBody", "data": { "bodyType": 1 } },
- { "type": "BoxCollider", "data": { "halfExtents": { "x": 0.16, "y": 0.24 }, "categoryBits": 1, "maskBits": 65535 } },
- { "type": "CharacterController", "data": { "maskBits": 65533 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -200,
+ "y": -180,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 32,
+ "y": 48
+ },
+ "color": {
+ "r": 0.2,
+ "g": 0.6,
+ "b": 1,
+ "a": 1
+ },
+ "texture": "@uuid:2bde6b7d-0dbe-4434-9e30-ed1cd8e3fe82",
+ "layer": 1
+ }
+ },
+ {
+ "type": "Player",
+ "data": {}
+ },
+ {
+ "type": "RigidBody",
+ "data": {
+ "bodyType": 1
+ }
+ },
+ {
+ "type": "BoxCollider",
+ "data": {
+ "halfExtents": {
+ "x": 0.16,
+ "y": 0.24
+ },
+ "categoryBits": 1,
+ "maskBits": 65535
+ }
+ },
+ {
+ "type": "CharacterController",
+ "data": {
+ "maskBits": 65533
+ }
+ }
],
"visible": true
},
@@ -144,8 +476,24 @@
"folder": "Coins",
"prefab": "@uuid:57ad3eb0-4a0c-49b5-bfba-c98418989915",
"overrides": [
- { "prefabEntityId": "0", "type": "property", "componentType": "Transform", "propertyName": "position", "value": { "x": -200, "y": -80, "z": 0 } },
- { "prefabEntityId": "0", "type": "property", "componentType": "Coin", "propertyName": "baseY", "value": -80 }
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Transform",
+ "propertyName": "position",
+ "value": {
+ "x": -200,
+ "y": -80,
+ "z": 0
+ }
+ },
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Coin",
+ "propertyName": "baseY",
+ "value": -80
+ }
],
"added": [],
"removed": []
@@ -157,8 +505,24 @@
"folder": "Coins",
"prefab": "@uuid:57ad3eb0-4a0c-49b5-bfba-c98418989915",
"overrides": [
- { "prefabEntityId": "0", "type": "property", "componentType": "Transform", "propertyName": "position", "value": { "x": 100, "y": 20, "z": 0 } },
- { "prefabEntityId": "0", "type": "property", "componentType": "Coin", "propertyName": "baseY", "value": 20 }
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Transform",
+ "propertyName": "position",
+ "value": {
+ "x": 100,
+ "y": 20,
+ "z": 0
+ }
+ },
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Coin",
+ "propertyName": "baseY",
+ "value": 20
+ }
],
"added": [],
"removed": []
@@ -170,8 +534,24 @@
"folder": "Coins",
"prefab": "@uuid:57ad3eb0-4a0c-49b5-bfba-c98418989915",
"overrides": [
- { "prefabEntityId": "0", "type": "property", "componentType": "Transform", "propertyName": "position", "value": { "x": -80, "y": 140, "z": 0 } },
- { "prefabEntityId": "0", "type": "property", "componentType": "Coin", "propertyName": "baseY", "value": 140 }
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Transform",
+ "propertyName": "position",
+ "value": {
+ "x": -80,
+ "y": 140,
+ "z": 0
+ }
+ },
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Coin",
+ "propertyName": "baseY",
+ "value": 140
+ }
],
"added": [],
"removed": []
@@ -183,8 +563,24 @@
"folder": "Coins",
"prefab": "@uuid:57ad3eb0-4a0c-49b5-bfba-c98418989915",
"overrides": [
- { "prefabEntityId": "0", "type": "property", "componentType": "Transform", "propertyName": "position", "value": { "x": 220, "y": 220, "z": 0 } },
- { "prefabEntityId": "0", "type": "property", "componentType": "Coin", "propertyName": "baseY", "value": 220 }
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Transform",
+ "propertyName": "position",
+ "value": {
+ "x": 220,
+ "y": 220,
+ "z": 0
+ }
+ },
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Coin",
+ "propertyName": "baseY",
+ "value": 220
+ }
],
"added": [],
"removed": []
@@ -196,8 +592,24 @@
"folder": "Coins",
"prefab": "@uuid:57ad3eb0-4a0c-49b5-bfba-c98418989915",
"overrides": [
- { "prefabEntityId": "0", "type": "property", "componentType": "Transform", "propertyName": "position", "value": { "x": 0, "y": -200, "z": 0 } },
- { "prefabEntityId": "0", "type": "property", "componentType": "Coin", "propertyName": "baseY", "value": -200 }
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Transform",
+ "propertyName": "position",
+ "value": {
+ "x": 0,
+ "y": -200,
+ "z": 0
+ }
+ },
+ {
+ "prefabEntityId": "0",
+ "type": "property",
+ "componentType": "Coin",
+ "propertyName": "baseY",
+ "value": -200
+ }
],
"added": [],
"removed": []
@@ -206,12 +618,29 @@
"id": 12,
"name": "UICanvas",
"parent": null,
- "children": [14],
+ "children": [
+ 14
+ ],
"folder": "UI",
"components": [
- { "type": "Transform", "data": {} },
- { "type": "Canvas", "data": { "designResolution": { "x": 800, "y": 600 }, "scaleMode": 2 } },
- { "type": "UINode", "data": {} }
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "Canvas",
+ "data": {
+ "designResolution": {
+ "x": 800,
+ "y": 600
+ },
+ "scaleMode": 2
+ }
+ },
+ {
+ "type": "UINode",
+ "data": {}
+ }
],
"visible": true
},
@@ -221,18 +650,92 @@
"parent": 12,
"children": [],
"components": [
- { "type": "Transform", "data": {} },
- { "type": "UINode", "data": {
- "position": 1,
- "width": { "value": 300.0, "unit": 0 },
- "height": { "value": 40.0, "unit": 0 },
- "insetLeft": { "value": 0.0, "unit": 1 },
- "marginLeft": { "value": 24.0, "unit": 0 },
- "insetTop": { "value": 0.0, "unit": 1 },
- "marginTop": { "value": 20.0, "unit": 0 }
- } },
- { "type": "Text", "data": { "content": "Score: 0", "fontSize": 28, "color": { "r": 1, "g": 1, "b": 1, "a": 1 }, "align": 0, "verticalAlign": 1 } },
- { "type": "ScoreDisplay", "data": { "score": 0 } }
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "width": {
+ "value": 300,
+ "unit": 0
+ },
+ "height": {
+ "value": 40,
+ "unit": 0
+ },
+ "insetLeft": {
+ "value": 0,
+ "unit": 1
+ },
+ "marginLeft": {
+ "value": 24,
+ "unit": 0
+ },
+ "insetTop": {
+ "value": 0,
+ "unit": 1
+ },
+ "marginTop": {
+ "value": 20,
+ "unit": 0
+ }
+ }
+ },
+ {
+ "type": "Text",
+ "data": {
+ "content": "Score: 0",
+ "fontSize": 28,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "align": 0,
+ "verticalAlign": 1
+ }
+ },
+ {
+ "type": "ScoreDisplay",
+ "data": {
+ "score": 0
+ }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 18,
+ "name": "BlockGuard",
+ "parent": null,
+ "children": [],
+ "folder": "Environment",
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -380,
+ "y": 280,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 24,
+ "y": 24
+ },
+ "texture": "@uuid:b10c6a11-0000-4000-8000-000000000001",
+ "layer": 10
+ }
+ }
],
"visible": true
}
diff --git a/examples/platformer/assets/textures/block-guard.ktx2 b/examples/platformer/assets/textures/block-guard.ktx2
new file mode 100644
index 000000000..b58b817c0
Binary files /dev/null and b/examples/platformer/assets/textures/block-guard.ktx2 differ
diff --git a/examples/platformer/assets/textures/block-guard.ktx2.meta b/examples/platformer/assets/textures/block-guard.ktx2.meta
new file mode 100644
index 000000000..394664f53
--- /dev/null
+++ b/examples/platformer/assets/textures/block-guard.ktx2.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "b10c6a11-0000-4000-8000-000000000001",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {}
+}
diff --git a/tools/check-golden.mjs b/tools/check-golden.mjs
index b65e2a9b6..2ecef77f8 100644
--- a/tools/check-golden.mjs
+++ b/tools/check-golden.mjs
@@ -122,6 +122,20 @@ for (const g of GOLDEN) {
fail(`"${g.id}" claims texture-atlas with no atlas: no <name>.atlas/ folder and no \`atlases\` entry`);
}
}
+ // The fixture is only a guard while it is still there AND still odd-sized.
+ if (g.oddSizedKtx2) {
+ const abs = path.join(projectDir(g.id), g.oddSizedKtx2);
+ if (!existsSync(abs)) fail(`"${g.id}" names oddSizedKtx2 ${g.oddSizedKtx2}, which is not there`);
+ else {
+ // KTX2 header: 12-byte identifier, vkFormat, typeSize, then width, height.
+ const head = readFileSync(abs).subarray(0, 28);
+ const w = head.readUInt32LE(20);
+ const h = head.readUInt32LE(24);
+ if (w % 4 === 0 && h % 4 === 0) {
+ fail(`"${g.id}" names oddSizedKtx2 ${g.oddSizedKtx2}, but ${w}x${h} IS whole blocks — it guards nothing`);
+ }
+ }
+ }
const sa = g.safeArea;
if (sa) {
if (!sa.entity || !sa.reference) fail(`"${g.id}" declares safeArea without both an entity and a reference`);
diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjs
index 9e8464531..44f45793a 100644
--- a/tools/goldenProjects.mjs
+++ b/tools/goldenProjects.mjs
@@ -98,6 +98,18 @@ export const GOLDEN = [
targets: ['web', 'desktop', 'android'],
tier: 'pr',
interact: { keys: ['ArrowRight'], frames: 40 },
+ // A KTX2 that is not whole 4x4 blocks, on purpose: WebGPU refuses one, and a
+ // single failed texture blanks the frame — so the desktop run guards
+ // ktx2_decode.cpp's fallback. The cook only encodes .png, so this passes through.
+ oddSizedKtx2: 'assets/textures/block-guard.ktx2',
+ // Two textured platforms and the sky behind them. Measured over three runs
+ // and stable to the byte; the falling player is NOT, which is why it is not
+ // here. A frame that lost its textures still spreads, and still fails these.
+ desktopPixels: [
+ { x: 0.30, y: 0.35, rgb: [121, 76, 32], tol: 12 },
+ { x: 0.70, y: 0.20, rgb: [121, 76, 32], tol: 12 },
+ { x: 0.10, y: 0.10, rgb: [208, 244, 247], tol: 12 },
+ ],
},
{
id: 'space-shooter',
@@ -330,6 +342,16 @@ export function atlasFor(g) {
return { packed: g.atlas.packed };
}
+/**
+ * Points a packaged NATIVE frame must contain, or null when the project names
+ * none. The host's own verdict only says something drew — a game that lost every
+ * texture and cleared to a gradient passes that, so what drew has to be asked
+ * for. `x`/`y` are fractions of the surface, `y` from the top.
+ */
+export function desktopPixels(g) {
+ return g?.desktopPixels ?? null;
+}
+
/** Absolute path to a golden project's directory. */
export function projectDir(id) {
return path.join(EXAMPLES, id);
diff --git a/tools/verify-desktop-render.mjs b/tools/verify-desktop-render.mjs
index 3446f4748..2bf0e71b8 100644
--- a/tools/verify-desktop-render.mjs
+++ b/tools/verify-desktop-render.mjs
@@ -28,7 +28,7 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { installedTemplateDir } from '../build-tools/utils/nativeTemplate.js';
-import { atTier, projectDir } from './goldenProjects.mjs';
+import { atTier, projectDir, GOLDEN, desktopPixels } from './goldenProjects.mjs';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const HOST_OS = process.platform === 'darwin' ? 'macos' : process.platform === 'win32' ? 'windows' : 'linux';
@@ -46,6 +46,29 @@ function parseArgs(argv) {
return opts;
}
+/**
+ * Points a packaged game must have drawn, read out of the raw capture — the
+ * host's verdict only answers "did anything draw".
+ *
+ * The capture is bottom-up and BGRA unless the host says RGBA (Shot.cpp logs
+ * which); `y` is measured from the TOP, as every other expectation here is.
+ */
+function probePixels(rawPath, verdict, output, points) {
+ const bytes = readFileSync(rawPath);
+ const { w, h } = { w: verdict.w, h: verdict.h };
+ if (bytes.length < w * h * 4) return [{ ok: false, why: `capture is ${bytes.length} bytes, ${w}x${h} needs ${w * h * 4}` }];
+ const bgra = !/shot: \d+x\d+ RGBA bottom-up/.test(output);
+ return points.map((pt) => {
+ const px = Math.min(w - 1, Math.max(0, Math.round(pt.x * (w - 1))));
+ const py = Math.min(h - 1, Math.max(0, Math.round(pt.y * (h - 1))));
+ const i = ((h - 1 - py) * w + px) * 4;
+ const got = bgra ? [bytes[i + 2], bytes[i + 1], bytes[i]] : [bytes[i], bytes[i + 1], bytes[i + 2]];
+ const tol = pt.tol ?? 30;
+ const ok = got.every((c, k) => Math.abs(c - pt.rgb[k]) <= tol);
+ return { ok, why: ok ? '' : `${pt.x}x${pt.y}: want [${pt.rgb}] ±${tol}, got [${got}]` };
+ });
+}
+
/** The verdict line the host logs, parsed. Null when it never got that far. */
function verdictIn(output) {
const at = output.lastIndexOf('shot verdict:');
@@ -86,7 +109,17 @@ function packageAndRun(project, templateDir, work) {
encoding: 'utf8',
timeout: 120_000,
});
- return { verdict: verdictIn(`${run.stdout ?? ''}${run.stderr ?? ''}`), status: run.status, output: `${run.stdout ?? ''}${run.stderr ?? ''}` };
+ const output = `${run.stdout ?? ''}${run.stderr ?? ''}`;
+ return { verdict: verdictIn(output), status: run.status, output, raw: path.join(out, 'frame.raw') };
+}
+
+/** What a golden project says its packaged frame must contain, or null. */
+function desktopPixelsFor(id) {
+ try {
+ return desktopPixels(GOLDEN.find((g) => g.id === id));
+ } catch {
+ return null;
+ }
}
const opts = parseArgs(process.argv.slice(2));
@@ -148,7 +181,17 @@ try {
console.error(`✗ ${label}: ran and drew nothing — ${JSON.stringify(verdict)}`);
failed += 1;
} else {
- console.log(`✓ ${label}: ${verdict.w}x${verdict.h}, spread ${verdict.spread}`);
+ const points = desktopPixelsFor(label);
+ const probes = points ? probePixels(result.raw, verdict, result.output, points) : [];
+ const bad = probes.filter((r) => !r.ok);
+ if (bad.length > 0) {
+ console.error(`✗ ${label}: drew, but not what it declared`);
+ for (const b of bad) console.error(` ${b.why}`);
+ failed += 1;
+ } else {
+ console.log(`✓ ${label}: ${verdict.w}x${verdict.h}, spread ${verdict.spread}`
+ + (probes.length ? `, ${probes.length} point(s) as declared` : ''));
+ }
}
}
} finally {
@@ -156,7 +199,7 @@ try {
}
if (failed > 0) {
- console.error(`verify-desktop-render: ${failed} of ${projects.length} did not draw.`);
+ console.error(`verify-desktop-render: ${failed} of ${projects.length} did not draw what they declare.`);
process.exit(1);
}
console.log(`verify-desktop-render: ${projects.length} packaged game(s) drew on ${HOST_OS}.`);