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
+3
View File
@@ -90,9 +90,11 @@ public:
// Rasterize a list of draw commands (CPU software rasterizer)
void RenderScene(SDL_Surface* targetSurface, const std::vector<Render3DDraw>& draws);
void RenderScene(SDL_Surface* targetSurface, const std::vector<const Render3DDraw*>& draws);
// Native SDL_GPU depth/perspective pipeline; SDL geometry fallback for software renderers.
void RenderSceneGPU(SDL_Renderer* renderer, const std::vector<Render3DDraw>& draws);
void RenderSceneGPU(SDL_Renderer* renderer, const std::vector<const Render3DDraw*>& draws);
void SetGPUDevice(SDL_GPUDevice* device);
void DestroyGPUTextures();
SDL_Texture* GetGPUTexture(SDL_Renderer* renderer, const std::string& texturePath);
@@ -166,6 +168,7 @@ private:
// Persistent scratch buffers to eliminate per-draw heap allocation churn in RenderSceneGPU
std::vector<DrawOrder> m_scratchSortedDraws;
std::vector<const Render3DDraw*> m_scratchDrawPtrs;
std::vector<GpuTransformedVertex> m_scratchGpuXverts;
std::vector<SDL_Vertex> m_scratchSdlVertices;
std::vector<int> m_scratchSdlIndices;