Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 516 vs 542 for /trunk/Source Code/Platform/Video/GFXState.cpp

Diff revisions: vs.
  @@ -12,14 +12,11 @@
12 12 // Atomic boolean use to signal the loading thread to stop
13 13 _closeLoadingThread = false;
14 14 _loadQueueDataReady = false;
15 - _renderingPool.size_controller().resize(HARDWARE_THREAD_COUNT() / 2);
16 15 }
17 16
18 17 GPUState::~GPUState()
19 18 {
20 - _renderingPool.wait();
21 - _renderingPool.clear();
22 - WAIT_FOR_CONDITION(_renderingPool.active() == 0);
19 + stopLoaderThread();
23 20 }
24 21
25 22 bool GPUState::startLoaderThread(const DELEGATE_CBK<>& loadingFunction) {
  @@ -30,48 +27,31 @@
30 27 _loaderThread.reset(new std::thread(loadingFunction));
31 28 }
32 29
33 - vectorImpl<Task_ptr> tasks;
34 - tasks.reserve(_renderingPool.size());
35 - size_t threadCount = tasks.size();
36 -
37 - for (size_t i = 0; i < threadCount; ++i) {
38 - tasks.push_back(std::make_shared<Task>(_renderingPool,
39 - 1,
40 - 1,
41 - []() {
42 - Attorney::GFXDeviceGPUState::threadedLoadCallback();
43 - }));
44 - }
45 -
46 - for (Task_ptr task : tasks) {
47 - task->startTask();
48 - }
49 -
50 - _renderingPool.wait();
51 -
52 - tasks.clear();
53 30 return true;
54 31 }
55 32
56 33 bool GPUState::stopLoaderThread() {
57 - if (Config::USE_GPU_THREADED_LOADING) {
58 - DIVIDE_ASSERT(_loaderThread != nullptr,
59 - "GPUState::stopLoaderThread error: stop called without "
60 - "calling start first!");
61 - closeLoadingThread(true);
62 - {
63 - std::unique_lock<std::mutex> lk(_loadQueueMutex);
64 - _loadQueueDataReady = true;
65 - _loadQueueCV.notify_one();
34 + if (_loaderThread.get()) {
35 + if (Config::USE_GPU_THREADED_LOADING) {
36 + DIVIDE_ASSERT(_loaderThread != nullptr,
37 + "GPUState::stopLoaderThread error: stop called without "
38 + "calling start first!");
39 + closeLoadingThread(true);
40 + {
41 + std::unique_lock<std::mutex> lk(_loadQueueMutex);
42 + _loadQueueDataReady = true;
43 + _loadQueueCV.notify_one();
44 + }
45 + while (loadingThreadAvailable()) {
46 + std::this_thread::sleep_for(std::chrono::milliseconds(10));
47 + }
48 + _loaderThread->join();
49 + _loaderThread.reset(nullptr);
66 50 }
67 - while (loadingThreadAvailable()) {
68 - std::this_thread::sleep_for(std::chrono::milliseconds(10));
69 - }
70 - _loaderThread->join();
71 - _loaderThread.reset(nullptr);
51 + return true;
72 52 }
73 53
74 - return true;
54 + return false;
75 55 }
76 56
77 57 void GPUState::addToLoadQueue(const DELEGATE_CBK<>& callback) {