|
10 | 10 | #include <d3dx9.h> |
11 | 11 | #pragma warning(pop) |
12 | 12 |
|
| 13 | +#include <tbb/parallel_for_each.h> |
| 14 | + |
13 | 15 | #include "ResourceManager.h" |
14 | 16 | #include "tss.h" |
15 | 17 | #include "blenders/blender.h" |
@@ -341,59 +343,20 @@ void CResourceManager::Delete(const Shader* S) |
341 | 343 | Msg("! ERROR: Failed to find complete shader"); |
342 | 344 | } |
343 | 345 |
|
344 | | -#ifndef USE_OGL |
345 | | -xr_vector<CTexture*> textures_to_load; |
346 | | - |
347 | | -void LoadTextures(const size_t thread_num, const size_t textures_per_worker) |
348 | | -{ |
349 | | -#ifdef DEBUG |
350 | | - Msg("Thread %d, amount of textures = %d", thread_num, textures_per_worker); |
351 | | - |
352 | | - CTimer timer; |
353 | | - timer.Start(); |
354 | | -#endif |
355 | | - |
356 | | - const auto upperbound = thread_num * textures_per_worker; |
357 | | - const auto lowerbound = upperbound - textures_per_worker; |
358 | | - for (auto i = lowerbound; i < upperbound; i++) |
359 | | - { |
360 | | - if (i < textures_to_load.size()) |
361 | | - textures_to_load[i]->Load(); |
362 | | - else |
363 | | - break; |
364 | | - } |
365 | | - |
366 | | -#ifdef DEBUG |
367 | | - Msg("Thread %d, texture loading time = %d", thread_num, timer.GetElapsed_ms()); |
368 | | -#endif |
369 | | -} |
370 | | -#endif |
371 | | - |
372 | 346 | void CResourceManager::DeferredUpload() |
373 | 347 | { |
374 | 348 | if (!RDEVICE.b_is_Ready) |
375 | 349 | return; |
376 | 350 |
|
377 | 351 | #ifndef MASTER_GOLD |
378 | | - Msg("%s, amount of textures = %d", __FUNCTION__ , m_textures.size()); |
| 352 | + Msg("%s, amount of textures = %d", __FUNCTION__, m_textures.size()); |
379 | 353 |
|
380 | 354 | CTimer timer; |
381 | 355 | timer.Start(); |
382 | 356 | #endif |
383 | 357 |
|
384 | 358 | #ifndef USE_OGL |
385 | | - const auto nWorkers = ttapi.threads.size(); |
386 | | - const auto textures_per_worker = m_textures.size() / nWorkers; |
387 | | - |
388 | | - for (auto& t : m_textures) |
389 | | - textures_to_load.push_back(t.second); |
390 | | - |
391 | | - for (auto i = 1; i <= nWorkers; ++i) |
392 | | - ttapi.threads[i-1]->addJob([=] { LoadTextures(i, textures_per_worker); }); |
393 | | - |
394 | | - ttapi.wait(); |
395 | | - |
396 | | - textures_to_load.clear(); |
| 359 | + tbb::parallel_for_each(m_textures, [&](auto m_tex) { m_tex.second->Load(); }); |
397 | 360 | #else |
398 | 361 | for (auto& texture : m_textures) |
399 | 362 | texture.second->Load(); |
|
0 commit comments