gr2: resolve skins once per skin change on the GPU draw cache

The cached GPU draws keep the skinned texture names and the unskinned
originals; SetSkin/ClearSkins bump a generation so the cache re-resolves
once instead of lowercasing every texture path every frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-12 16:30:32 +09:00
co-authored by Claude Opus 5.5
parent 9ec7fa10c0
commit 16d16de90d
2 changed files with 36 additions and 7 deletions
+7 -1
View File
@@ -73,7 +73,7 @@ public:
void SetAttachmentAnimated(const std::string& bone_name, bool animated);
void SetAttachmentScale(const std::string& bone_name, float sx, float sy, float sz);
void SetSkin(const std::string& src_file_name, const std::string& dst_file_name);
void ClearSkins() { m_skins.clear(); }
void ClearSkins() { m_skins.clear(); ++m_skinGeneration; }
const std::string& GetFilePath() const { return m_filepath; }
// Build draw commands for this model and all attached components (weapons, hair, armor parts)
@@ -101,6 +101,12 @@ private:
float scale[3] = {1.0f, 1.0f, 1.0f};
};
std::vector<Gr2MeshDraw> m_gpuMain, m_gpuParts;
// The GPU caches hold skinned texture names; the unskinned originals are kept so a skin change
// (SetSkin/ClearSkins bump m_skinGeneration) re-resolves them once instead of every frame.
std::vector<std::string> m_gpuMainBaseTex, m_gpuPartsBaseTex;
size_t m_gpuMainSkinGen = 0, m_gpuPartsSkinGen = 0, m_skinGeneration = 1;
void CacheGpuDraws(std::vector<Gr2MeshDraw>& cache, std::vector<std::string>& base, size_t& gen, const std::vector<Gr2MeshDraw>& draws) const;
void RefreshGpuSkins(std::vector<Gr2MeshDraw>& cache, const std::vector<std::string>& base, size_t& gen) const;
const gr2::Skeleton* m_gpuPartParent = nullptr;
size_t m_gpuPartPaletteSize = 0;
// Part bone -> parent bone by name, and the parent bind world per part bone; both depend only