Skip to content

Commit f207607

Browse files
committed
Fix multithreaded textures precaching
Add additional logging
1 parent 6753611 commit f207607

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/Layers/xrRender/ResourceManager.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,13 @@ xr_vector<CTexture*> textures_to_load;
342342

343343
void LoadTextures(const size_t thread_num, const size_t textures_per_worker)
344344
{
345+
#ifdef DEBUG
346+
Msg("Thread %d, amount of textures = %d", thread_num, textures_per_worker);
347+
348+
CTimer timer;
349+
timer.Start();
350+
#endif
351+
345352
const auto upperbound = thread_num * textures_per_worker;
346353
const auto lowerbound = upperbound - textures_per_worker;
347354
for (auto i = lowerbound; i < upperbound; i++)
@@ -351,34 +358,38 @@ void LoadTextures(const size_t thread_num, const size_t textures_per_worker)
351358
else
352359
break;
353360
}
361+
362+
#ifdef DEBUG
363+
Msg("Thread %d, texture loading time = %d", thread_num, timer.GetElapsed_ms());
364+
#endif
354365
}
355366

356367
void CResourceManager::DeferredUpload()
357368
{
358369
if (!RDEVICE.b_is_Ready)
359370
return;
360371

361-
#ifdef DEBUG
372+
#ifndef MASTER_GOLD
362373
Msg("%s, amount of textures = %d", __FUNCTION__ , m_textures.size());
363-
#endif
364374

365375
CTimer timer;
366376
timer.Start();
377+
#endif
367378

368379
const auto nWorkers = ttapi.threads.size();
369380
const auto textures_per_worker = m_textures.size() / nWorkers;
370381

371382
for (auto& t : m_textures)
372383
textures_to_load.push_back(t.second);
373384

374-
for (auto i = 1; i < nWorkers; ++i)
375-
ttapi.threads[i]->addJob([=] { LoadTextures(i, textures_per_worker); });
385+
for (auto i = 1; i <= nWorkers; ++i)
386+
ttapi.threads[i-1]->addJob([=] { LoadTextures(i, textures_per_worker); });
376387

377388
ttapi.wait();
378389

379390
textures_to_load.clear();
380391

381-
#ifdef DEBUG
392+
#ifndef MASTER_GOLD
382393
Msg("%s, texture loading time = %d", __FUNCTION__, timer.GetElapsed_ms());
383394
#endif
384395
}

0 commit comments

Comments
 (0)