A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(rc6): track texture VRAM bytes + expose in ResourceStats (E2, safe scope)
yhhabb44948f7e0
diff --git a/src/esengine/resource/ResourceManager.cpp b/src/esengine/resource/ResourceManager.cppindex feeed7777..d611a1856 100644--- a/src/esengine/resource/ResourceManager.cpp+++ b/src/esengine/resource/ResourceManager.cpp@@ -138,7 +138,8 @@ TextureHandle ResourceManager::createTexture(const TextureSpecification& spec) {ES_LOG_ERROR("Failed to create texture from spec");return TextureHandle();}- return textures_.add(std::move(texture));+ const usize bytes = static_cast<usize>(texture->getWidth()) * texture->getHeight() * 4;+ return textures_.add(std::move(texture), "", bytes);}TextureHandle ResourceManager::createTexture(u32 width, u32 height, ConstSpan<u8> pixels,@@ -150,7 +151,8 @@ TextureHandle ResourceManager::createTexture(u32 width, u32 height, ConstSpan<u8ES_LOG_ERROR("Failed to create texture from pixels");return TextureHandle();}- return textures_.add(std::move(texture));+ const usize bytes = static_cast<usize>(width) * height * 4;+ return textures_.add(std::move(texture), "", bytes);}TextureHandle ResourceManager::loadTexture(const std::string& path) {@@ -203,7 +205,8 @@ TextureHandle ResourceManager::registerExternalTexture(u32 glTextureId, u32 widtES_LOG_ERROR("Failed to register external texture (GL ID: {})", glTextureId);return TextureHandle();}- return textures_.add(std::move(texture));+ const usize bytes = static_cast<usize>(width) * height * 4;+ return textures_.add(std::move(texture), "", bytes);}void ResourceManager::registerTextureWithPath(TextureHandle handle, const std::string& path) {@@ -408,6 +411,7 @@ ResourceStats ResourceManager::getStats() const {stats_.textureCount = textures_.size();stats_.vertexBufferCount = vertexBuffers_.size();stats_.indexBufferCount = indexBuffers_.size();+ stats_.textureBytes = textures_.residentBytes();return stats_;}diff --git a/src/esengine/resource/ResourceManager.hpp b/src/esengine/resource/ResourceManager.hppindex 1e5419d4d..4f3f2e010 100644--- a/src/esengine/resource/ResourceManager.hpp+++ b/src/esengine/resource/ResourceManager.hpp@@ -51,6 +51,7 @@ struct ResourceStats {usize indexBufferCount = 0; ///< Number of active index buffersusize cacheHits = 0; ///< Number of cache hits since resetusize cacheMisses = 0; ///< Number of cache misses since reset+ usize textureBytes = 0; ///< Resident texture bytes (RGBA8 estimate) — VRAM usage (RC6)};// =============================================================================