Skip to content

Commit 0e9ebc3

Browse files
fix more
1 parent 0375ad0 commit 0e9ebc3

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

es-core/src/resources/TextureDataManager.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff 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)
222227
size_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
}

0 commit comments

Comments
 (0)