perf: constexpr reciprocals, cache redundant lookups, consolidate texture maps

- Hoist DBC field index lookups before loops in game_handler (7 DBC iteration loops)
- Cache getSkybox()/getPosition() calls instead of redundant per-frame queries
- Merge textureHasAlphaByPtr_ + textureColorKeyBlackByPtr_ into single map
- Add constexpr for DEG_TO_RAD, reciprocal constants, physics delta
- Add reserve() for WMO/M2 collision grid queries and portal BFS
- Frustum plane normalize: inversesqrt instead of length+divide
- M2 particle emission: inversesqrt for direction normalization
- Parse creature display IDs from query response
- UI: show spell names/IDs as fallback instead of "Unknown"
This commit is contained in:
Kelsi 2026-03-27 16:47:30 -07:00
parent b0466e9029
commit d26eed1e7c
9 changed files with 153 additions and 104 deletions

View file

@ -293,8 +293,11 @@ private:
bool normalMapPending = false; // deferred normal map generation
};
std::unordered_map<std::string, TextureCacheEntry> textureCache;
std::unordered_map<VkTexture*, bool> textureHasAlphaByPtr_;
std::unordered_map<VkTexture*, bool> textureColorKeyBlackByPtr_;
struct TextureProperties {
bool hasAlpha = false;
bool colorKeyBlack = false;
};
std::unordered_map<VkTexture*, TextureProperties> texturePropsByPtr_;
std::unordered_map<std::string, VkTexture*> compositeCache_; // key → texture for reuse
std::unordered_set<std::string> failedTextureCache_; // negative cache for budget exhaustion
std::unordered_map<std::string, uint64_t> failedTextureRetryAt_;

View file

@ -483,8 +483,11 @@ private:
bool colorKeyBlack = false;
};
std::unordered_map<std::string, TextureCacheEntry> textureCache;
std::unordered_map<VkTexture*, bool> textureHasAlphaByPtr_;
std::unordered_map<VkTexture*, bool> textureColorKeyBlackByPtr_;
struct TextureProperties {
bool hasAlpha = false;
bool colorKeyBlack = false;
};
std::unordered_map<VkTexture*, TextureProperties> texturePropsByPtr_;
size_t textureCacheBytes_ = 0;
uint64_t textureCacheCounter_ = 0;
size_t textureCacheBudgetBytes_ = 2048ull * 1024 * 1024;