3D engine that AI agents drive
Record the measured mesh blend cost (part of #489)
Nguyen Xuan Anba434e8ba9fd
diff --git a/changes/489.md b/changes/489.mdindex 09b2900f..af8c75fb 100644--- a/changes/489.md+++ b/changes/489.md@@ -1 +1 @@-- Make the mesh blend pass cheaper (issue #489). The shader reads its 24 taps from a constant table instead of computing a square root, sine and cosine per tap, the ID attachment is cleared each frame so an ID lookup needs no depth fetch, and a batch whose parts share one radius and one level keeps its frustum culling. On the nature scene at 1080p on an RTX 3060 the pass costs 0.25 to 0.58 ms of GPU time over 12 rounds (median 0.31 ms), down from about 0.55 ms; scenes without `blend` draw the same pixels.+- Make the mesh blend pass cheaper (issue #489). The shader reads its 24 taps from a constant table instead of computing a square root, sine and cosine per tap, the ID attachment is cleared each frame so an ID lookup needs no depth fetch, and a batch whose parts share one radius and one level keeps its frustum culling. On the nature scene at 1080p on an RTX 3060 the pass costs 0.26 to 0.30 ms of GPU time per round over 12 rounds (median 0.27 ms), down from about 0.55 ms; scenes without `blend` draw the same pixels.diff --git a/docs/mesh-blend.md b/docs/mesh-blend.mdindex 3a09f90c..e0df0d9e 100644--- a/docs/mesh-blend.md+++ b/docs/mesh-blend.md@@ -14,7 +14,7 @@ For each pixel of a blend part, the pass looks at 24 taps on a spiral within `ra## Cost and limits-- No second draw of the geometry: the cost is the extra RGBA8 attachment (multisample, resolved) and one fullscreen pass that returns at once for every pixel outside a blend part. Measured on an RTX 3060 at 1080p (4x MSAA, a terrain with five sunk rocks and a trunk, median of 6 rounds of 150 frames): 2.19 ms with the addon installed and no blend part (2.24 ms with no addon), 2.92 ms with blend, so about 0.74 ms. The first version drew the object IDs in a second pass and cost 0.97 ms. What is left is the extra multisampled attachment, its resolve, the fullscreen pass and the unculled blend batches. `node bench/reference/mesh-blend.mjs --only-cost` repeats it.+- No second draw of the geometry: the cost is the extra RGBA8 attachment (multisample, resolved, cleared each frame) and one fullscreen pass that returns at once for every pixel outside a blend part. Measured on an RTX 3060 at 1080p (4x MSAA, a terrain with five sunk rocks and a trunk, 12 rounds of 120 frames, GPU timer query): 0.665 ms of GPU time with the addon installed and no blend part, 0.932 ms with blend, a cost per round of 0.26 to 0.30 ms (median 0.27 ms; 0.25 to 0.58 ms on a card shared with other jobs). Before issue #489 it was about 0.55 ms: the tap loop computed a square root, sine and cosine per tap, and the two normals rebuilt from depth kept that work alive. What is left is about 0.035 ms each for the attachment and its resolve, 0.07 ms for the fullscreen pass itself and the rest in the taps. `node bench/reference/mesh-blend.mjs --only-cost` repeats it and prints the wall clock and GPU time per round.- Needs a renderer with `depth: true`; the render passes addon is not needed. The MCP preview has depth.- Opaque and cutout parts only. A blended part writes no ID, and translucent water or glass drawn over a blend part leaves that pixel unblended or with a stale ID (the liquid programs do not write the attachment).- A blend part mixes toward the part on the other side of its seam; the other part changes only if it has `blend` too. Marking both gives the soft seam from both sides.