File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,7 +86,12 @@ size_t TextureDataManager::getTotalSize()
8686{
8787 size_t total = 0 ;
8888 for (auto tex : mTextures )
89- total += tex->width () * tex->height () * 4 ;
89+ {
90+ // Only count textures whose dimensions are known — calling width()/height()
91+ // on an unloaded texture triggers a synchronous load().
92+ if (tex->isLoaded ())
93+ total += tex->width () * tex->height () * 4 ;
94+ }
9095 return total;
9196}
9297
@@ -222,12 +227,15 @@ void TextureLoader::remove(std::shared_ptr<TextureData> textureData)
222227size_t TextureLoader::getQueueSize ()
223228{
224229 // Gets the amount of video memory that will be used once all textures in
225- // the queue are loaded
230+ // the queue are loaded. Only count textures whose dimensions are already
231+ // known — calling width()/height() on an unloaded texture triggers a
232+ // synchronous load() which blocks the main thread on NAS I/O.
226233 size_t mem = 0 ;
227234 std::unique_lock<std::mutex> lock (mMutex );
228235 for (auto tex : mTextureDataQ )
229236 {
230- mem += tex->width () * tex->height () * 4 ;
237+ if (tex->isLoaded ())
238+ mem += tex->width () * tex->height () * 4 ;
231239 }
232240 return mem;
233241}
You can’t perform that action at this time.
0 commit comments