RecordingDevice: lend cached geometry instead of copying it per draw

A geometry-cache hit moved every vertex vector out of the cache into the draw
(deep copy of positions/normals/uv/diffuse/indices/bones each frame). The cache
now lends its vectors to the frame's first draw of that geometry and takes them
back in Render3DBeginFrame; later draws of the same key+revision in the frame
(terrain splat layers, shadow-map pass) are marked shared_geometry and carry no
vectors -- the native host looks the GPU geometry up by key+revision, and draw
captures expand them (Render3DExpandSharedGeometry). Index reads reuse a scratch
buffer. Desktop live game: RenderGame rnd 1.7 -> 1.2 ms, no visual change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-30 11:39:01 +09:00
co-authored by Claude Opus 5.5
parent 44a020f01e
commit 6bfcac7d68
5 changed files with 128 additions and 29 deletions
+9
View File
@@ -61,6 +61,12 @@ struct Render3DDraw {
std::vector<float> bone_weights; // 4 floats per vertex
std::vector<float> bone_matrices; // 16 floats per bone in the mesh's palette (D3D row-vector layout)
bool lines = false;
// A repeat, within one frame, of an earlier draw's geometry (same geometry_key and revision, e.g.
// the terrain splat layers of a patch or a character's shadow-map pass): positions..bone_weights
// are left empty and the consumer takes them from that earlier draw of Render3DDraws().
// shared_diffuse says whether the geometry has vertex colours (!diffuse.empty() there).
bool shared_geometry = false;
bool shared_diffuse = false;
// D3DRS_* / D3DTSS_* values in effect for the draw.
std::uint32_t alpha_blend = 0, src_blend = 0, dest_blend = 0;
@@ -146,3 +152,6 @@ void Render3DAdd(Render3DDraw draw);
void Render3DBeginScene();
void Render3DEndScene();
const std::vector<Render3DDraw>& Render3DDraws();
// Fills the vectors of shared_geometry draws from the earlier draw that carries them (for consumers
// that need every draw self-contained, e.g. a draw capture).
void Render3DExpandSharedGeometry(std::vector<Render3DDraw>& draws);