Submit cached map-object draws by pointer instead of copying

MapObjectManager::AppendDrawRefs references each visible object's cached
Render3DDraw (writing the per-frame light into the cache) rather than
copying the whole command (two texture strings, shared_ptrs, matrices)
every frame. main.cpp flattens owned draws and refs in submission order
(FlattenDraws) and passes a pointer list to RenderSceneGPU/RenderScene.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-12 17:09:45 +09:00
co-authored by Claude Opus 5.5
parent b5a15871f4
commit 46880be537
9 changed files with 89 additions and 12 deletions
+7
View File
@@ -16,6 +16,13 @@
#include <filesystem>
#include <fstream>
int main() {
{ // Referenced (cached) commands splice in before owned[before], in submission order.
std::vector<ava2::Render3DDraw> owned(3);ava2::Render3DDraw cachedA,cachedB,cachedC;
std::vector<ava2::Render3DDrawRef> refs{{1,&cachedA},{1,&cachedB},{3,&cachedC}};
std::vector<const ava2::Render3DDraw*> list;ava2::FlattenDraws(owned,refs,list);
const std::vector<const ava2::Render3DDraw*> expect{&owned[0],&cachedA,&cachedB,&owned[1],&owned[2],&cachedC};
assert(list==expect);
}
if(!SDL_Init(SDL_INIT_VIDEO))return 77;
auto* device=SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_MSL|SDL_GPU_SHADERFORMAT_SPIRV,true,nullptr);
if(!device){SDL_Quit();return 77;}