@@ -1,103 +0,0 @@ | |||||
//SCENE SETUP END | |||||
//addlight 0.0 position (1 0 1) color #0ff | |||||
//addlight 0.0 position (-0.2 -1 -0.5) color (.0 .2 .5 1) | |||||
//custom setmesh "sc#f00 ab 2 ty 1.5 ab 2" | |||||
custom setmesh " | |||||
//tqw | |||||
//CMD TEST | |||||
//sc#0f0 asph 1 10 | |||||
//sc#0f0 ab 10 | |||||
//sc#0f0 afcb 1 -.2 | |||||
//sc#0f0 acg 8 1 1 1 2 2 1.5 1.5 -.4 | |||||
//sc#0f0 as 6 1 2 | |||||
//sc#0f0 scb#f00 aes 6 1 2 2 | |||||
//sc#0f0 ac 6 5 2 2 false true true | |||||
//sc#0f0 aq 1 | |||||
//splt 2 smth 4 0 1 | |||||
//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup [ rz 90 ry 90 scv#00f dup [ ry 90 scv#f00 ] ] ] | |||||
//[sc#fff ab .1] | |||||
//[sc#0f0 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 dup[rz 90 ry 90 scv#00f dup[ry 90 scv#f00]]][sc#fff ab .1] | |||||
//[sc#fff ab 1 tx .5 ty .5] | |||||
//[sc#fff ab 1 tx -.5 ty -.5] | |||||
//[sc#fff ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 ty .5 [ad 3 .1 sy -1] ty 1] | |||||
//smth 3 1 1 smth 8 0 1 | |||||
//[sc#fff loop 4 [ [loop 4 [ab 1 tx 2]] tz 2]] | |||||
//[sc#f00 scb#f00 ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 .1 ty .5 rz -90] | |||||
//[sc#00f scb#00f ac 3 .5 .4 0 ty .25 [ad 3 .4 sy -1] ty .5 ac 3 1 .1 .1 ty .5 rx 90] | |||||
//[sc#f00 ab .2 tx 1] | |||||
//[sc#0f0 ab .2 ty 1] | |||||
//[sc#00f ab .2 tz 1] | |||||
//sc#0f0 ab 2 ty 1.5 ab 2 | |||||
//sc#00f ab 2 ty 1.5 ab 2 | |||||
//sc#00f tqw lp 5[tz 11 [lp 6 [tx 5 ty 5 afcb 10 -1 ]]] tz -22 | |||||
// tqw | |||||
sc#f00 ab 10 | |||||
//tz 5 | |||||
//vm | |||||
// splt 1 | |||||
// rj .2 | |||||
// splt 1 | |||||
// rj .2 | |||||
// smth 1 0 1 | |||||
//[sc#66f afcb(10) .25tx0]csgs[sc#fff afcb(10).25t(2)][[sc#6f6 afcb(7).25]csgs[sc#fff afcb(7).25t(1.5)]][[sc#f44 asph4 12t(-2.5)]csga[sc#fff afcb(7).25t(1.4)]csgs[sc#fff afcb(7).25t(2.5)]][[sc#ff0 ato6 2.5 1.2rx90tz-1.25tx-.9][sc#ff0 ab.5 2.1 .5dup[rz90sx.5ty-.8tx-.28]ty.55tx.25tz-.4taz1 1sy.8sx.8ty-.55tx-.25tz.4tz-1.2tx1.2]tz1.25tx1.25dup[sx-1ry90]tz-1.25tx-1.25] | |||||
" | |||||
//splt 0 | |||||
//test | |||||
//[sc#f8f ab 1 splt 4 twy 90] | |||||
// splt 5 twy 90 0 | |||||
//[sc#f8f afcb 10 10 10 .25 tx 0 splt 4 twy 1.6 0 ] | |||||
//sc#fff | |||||
//[afcb 1 1 1 -.1 tx 1] | |||||
//[afcb 1 1 1 -.1 tx 0] | |||||
//[afcb 1 1 1 -.1 tx -1] | |||||
//[[afcb 1 1 1 -.1 tx 1] | |||||
//[afcb 1 1 1 -.1 tx 0] | |||||
//[afcb 1 1 1 -.1 tx -1]tz 1] | |||||
//[[afcb 1 1 1 -.1 tx 1] | |||||
//[afcb 1 1 1 -.1 tx 0] | |||||
//[afcb 1 1 1 -.1 tx -1]tz -1] | |||||
//[afcb 3 .2 3 -.05 ty -.6] | |||||
//[sc#fff scb#fff ato 20 8 12 rx0] | |||||
//[sc#fff scb#fff acg 8 2 5 1 6 8 4 2 .1 1] | |||||
//[sc#fff ab 4 4 4 ]//twy 45 0 bdxy 90 0 splt 5 tz 2 | |||||
//[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 tax .4 .4 0] | |||||
//[sc#88f ab .25 1 1 tx .25 ab .25 1 1 tx .25 ab .25 1 1 tx .25 ab .25 1 1 tx .125 stx 10 0 0] | |||||
// tax -2 0 0 0 | |||||
//[sc#88f ab 4 4 4 tx 4 ab 4 4 4 tx -2 shz 1 0 0 0] | |||||
//[sc#fff asph 4 4] | |||||
//[sc#ff2 asph 4 4 tax .4 .4 0] | |||||
//[sc#ff2 asph 2 4] | |||||
//[sc#fff acap 1 4 4] | |||||
//[sc#fff scb#fff ac 10 4 4 4 0 0 1] | |||||
//[sc#ff2 scb#ff2 ad 10 4 0] | |||||
//[sc#fff scb#fff at 4 1] | |||||
//[sc#fff scb#000 aq 4 1] | |||||
//[sc#fff scb#2ff aes 5 3 6 2] | |||||
//[sc#fff scb#2ff as 4 2 4 0 0] | |||||
//[sc#fff scb#fff acg 2 10 .1 .1 .4 .4 .1 .1 0 1] | |||||
//[sc#ff2 asph 2 10 10 10] | |||||
//[sc#400 asph 2 10 10 10 t 2 2 2 csgs] |
@@ -147,7 +147,7 @@ void MeshViewer::Start() | |||||
m_entities << (m_file_check = new FileUpdateTester()); | m_entities << (m_file_check = new FileUpdateTester()); | ||||
m_file_status = m_file_check->RegisterFile(m_file_name); | m_file_status = m_file_check->RegisterFile(m_file_name); | ||||
m_entities << (m_file_loader = new DefaultThreadManager(1, 1)); | |||||
//m_entities << (m_file_loader = new DefaultThreadManager(1, 1)); | |||||
//Camera setup | //Camera setup | ||||
m_camera = new Camera(); | m_camera = new Camera(); | ||||
@@ -222,7 +222,7 @@ void MeshViewer::TickGame(float seconds) | |||||
//Check file update | //Check file update | ||||
ASSERT(m_file_status); | ASSERT(m_file_status); | ||||
if (m_file_status->HasUpdated()) | |||||
if (false && m_file_status->HasUpdated()) | |||||
{ | { | ||||
MeshViewerLoadJob* job = GetLoadJob(m_file_name); | MeshViewerLoadJob* job = GetLoadJob(m_file_name); | ||||
if (!job) | if (!job) | ||||
@@ -230,6 +230,7 @@ void MeshViewer::TickGame(float seconds) | |||||
} | } | ||||
//Check work done | //Check work done | ||||
if (false) | |||||
{ | { | ||||
array<ThreadJob*> result; | array<ThreadJob*> result; | ||||
m_file_loader->GetWorkResult(result); | m_file_loader->GetWorkResult(result); | ||||
@@ -155,7 +155,7 @@ public: | |||||
SceneSetupLuaLoader(); | SceneSetupLuaLoader(); | ||||
virtual ~SceneSetupLuaLoader(); | virtual ~SceneSetupLuaLoader(); | ||||
//Virtual Store lua object ------------------------------------------------ | //Virtual Store lua object ------------------------------------------------ | ||||
virtual void Store(LuaObject* obj) { } | |||||
virtual void Store(LuaObject* obj); | |||||
array<SceneSetupLuaObject*>& GetInstances(); | array<SceneSetupLuaObject*>& GetInstances(); | ||||
//------------------------------------------------------------------------- | //------------------------------------------------------------------------- | ||||
@@ -240,7 +240,7 @@ public: | |||||
bool IsEmpty() const | bool IsEmpty() const | ||||
{ | { | ||||
return !(GetKeyCount() && GetAxisCount()); | |||||
return !GetKeyCount() && !GetAxisCount(); | |||||
} | } | ||||
int GetKeyCount() const | int GetKeyCount() const | ||||
{ | { | ||||
@@ -10,9 +10,9 @@ | |||||
#pragma once | #pragma once | ||||
#include <lol/sys/timer.h> | |||||
#include <lol/sys/thread.h> | #include <lol/sys/thread.h> | ||||
#include <lol/sys/threadtypes.h> | #include <lol/sys/threadtypes.h> | ||||
#include <lol/sys/init.h> | #include <lol/sys/init.h> | ||||
#include <lol/sys/file.h> | #include <lol/sys/file.h> | ||||
#include <lol/sys/timer.h> | |||||
@@ -130,7 +130,7 @@ protected: | |||||
void StopThreads(int nb); | void StopThreads(int nb); | ||||
//Work stuff | //Work stuff | ||||
bool AddWork(ThreadJob* job); | |||||
bool AddWork(ThreadJob* job, bool force = false); | |||||
//Fetch Results | //Fetch Results | ||||
bool FetchResult(array<ThreadJob*>& results); | bool FetchResult(array<ThreadJob*>& results); | ||||
@@ -145,10 +145,11 @@ protected: | |||||
int m_thread_count; | int m_thread_count; | ||||
int m_thread_min; | int m_thread_min; | ||||
array<thread*> m_threads; | array<thread*> m_threads; | ||||
array<ThreadJob*> m_job_dispatch; | |||||
private: | |||||
queue<ThreadStatus> m_spawnqueue, m_donequeue; | queue<ThreadStatus> m_spawnqueue, m_donequeue; | ||||
queue<ThreadJob*> m_jobqueue; | queue<ThreadJob*> m_jobqueue; | ||||
queue<ThreadJob*> m_resultqueue; | queue<ThreadJob*> m_resultqueue; | ||||
array<ThreadJob*> m_job_dispatch; | |||||
}; | }; | ||||
} /* namespace lol */ | } /* namespace lol */ | ||||
@@ -50,6 +50,7 @@ class FileUpdateTester : public BaseThreadManager | |||||
public: | public: | ||||
class Status | class Status | ||||
{ | { | ||||
friend class FileUpdateTester; | |||||
protected: | protected: | ||||
mutex m_mutex; | mutex m_mutex; | ||||
long int m_time = 0; | long int m_time = 0; | ||||
@@ -41,7 +41,7 @@ bool BaseThreadManager::Start() | |||||
return false; | return false; | ||||
//Add minimum threads | //Add minimum threads | ||||
m_threads.Resize(m_thread_count); | |||||
m_threads.reserve(m_thread_count); | |||||
AddThreads(m_thread_min); | AddThreads(m_thread_min); | ||||
return true; | return true; | ||||
@@ -91,11 +91,12 @@ void BaseThreadManager::StopThreads(int nb) | |||||
} | } | ||||
//Work stuff | //Work stuff | ||||
bool BaseThreadManager::AddWork(ThreadJob* job) | |||||
bool BaseThreadManager::AddWork(ThreadJob* job, bool force) | |||||
{ | { | ||||
if (m_jobqueue.try_push(job)) | |||||
return true; | |||||
return false; | |||||
if (!force) | |||||
return m_jobqueue.try_push(job); | |||||
m_jobqueue.push(job); | |||||
return true; | |||||
} | } | ||||
//---- | //---- | ||||
@@ -110,20 +111,20 @@ bool BaseThreadManager::FetchResult(array<ThreadJob*>& results) | |||||
//Base thread work function | //Base thread work function | ||||
void BaseThreadManager::BaseThreadWork() | void BaseThreadManager::BaseThreadWork() | ||||
{ | { | ||||
#if !LOL_FEATURE_THREADS | |||||
#if LOL_FEATURE_THREADS | |||||
//Register that the thread has started | //Register that the thread has started | ||||
m_spawnqueue.push(ThreadStatus::THREAD_STARTED); | m_spawnqueue.push(ThreadStatus::THREAD_STARTED); | ||||
for ( ; ; ) | for ( ; ; ) | ||||
#endif //!LOL_FEATURE_THREADS | |||||
#endif //LOL_FEATURE_THREADS | |||||
{ | { | ||||
//Try to retrieve a job | //Try to retrieve a job | ||||
ThreadJob* job = m_jobqueue.pop(); | ThreadJob* job = m_jobqueue.pop(); | ||||
//Stop thread | //Stop thread | ||||
if (job->GetJobType() == ThreadJobType::THREAD_STOP) | if (job->GetJobType() == ThreadJobType::THREAD_STOP) | ||||
{ | { | ||||
#if !LOL_FEATURE_THREADS | |||||
#if LOL_FEATURE_THREADS | |||||
break; | break; | ||||
#endif //!LOL_FEATURE_THREADS | |||||
#endif //LOL_FEATURE_THREADS | |||||
} | } | ||||
//Or work | //Or work | ||||
else if (*job == ThreadJobType::WORK_TODO) | else if (*job == ThreadJobType::WORK_TODO) | ||||
@@ -135,10 +136,10 @@ void BaseThreadManager::BaseThreadWork() | |||||
m_resultqueue.push(job); | m_resultqueue.push(job); | ||||
} | } | ||||
} | } | ||||
#if !LOL_FEATURE_THREADS | |||||
#if LOL_FEATURE_THREADS | |||||
//Register that the thread has stopped | //Register that the thread has stopped | ||||
m_donequeue.push(ThreadStatus::THREAD_STOPPED); | m_donequeue.push(ThreadStatus::THREAD_STOPPED); | ||||
#endif //!LOL_FEATURE_THREADS | |||||
#endif //LOL_FEATURE_THREADS | |||||
} | } | ||||
//---- | //---- | ||||
@@ -150,7 +151,7 @@ void BaseThreadManager::TickGame(float seconds) | |||||
Start(); | Start(); | ||||
//Dispatch work task | //Dispatch work task | ||||
while (m_job_dispatch.Count() > 0 && AddWork(m_job_dispatch.Last())) | |||||
while (m_job_dispatch.count() > 0 && AddWork(m_job_dispatch.last())) | |||||
m_job_dispatch.pop(); | m_job_dispatch.pop(); | ||||
//Execute one task per frame if thread are not available | //Execute one task per frame if thread are not available | ||||
@@ -131,39 +131,6 @@ public: | |||||
current_count = (ptrdiff_t)m_count; | current_count = (ptrdiff_t)m_count; | ||||
#if defined HAVE_PTHREAD_H | |||||
/* If there were poppers waiting, signal the "empty" cond var. */ | |||||
if (m_poppers) | |||||
pthread_cond_signal(&m_empty_cond); | |||||
pthread_mutex_unlock(&m_mutex); | |||||
#elif defined _WIN32 | |||||
LeaveCriticalSection(&m_mutex); | |||||
ReleaseSemaphore(m_full_sem, 1, nullptr); | |||||
#endif | |||||
return current_count; | |||||
} | |||||
ptrdiff_t try_count() | |||||
{ | |||||
ptrdiff_t current_count = 0; | |||||
#if defined HAVE_PTHREAD_H | |||||
pthread_mutex_lock(&m_mutex); | |||||
/* If queue is full, wait on the "full" cond var. */ | |||||
if (m_count == CAPACITY) | |||||
{ | |||||
pthread_mutex_unlock(&m_mutex); | |||||
return false; | |||||
} | |||||
#elif defined _WIN32 | |||||
DWORD status = WaitForSingleObject(m_empty_sem, 0); | |||||
if (status == WAIT_TIMEOUT) | |||||
return 0; | |||||
EnterCriticalSection(&m_mutex); | |||||
#endif | |||||
current_count = (ptrdiff_t)m_count; | |||||
#if defined HAVE_PTHREAD_H | #if defined HAVE_PTHREAD_H | ||||
/* If there were poppers waiting, signal the "empty" cond var. */ | /* If there were poppers waiting, signal the "empty" cond var. */ | ||||
if (m_poppers) | if (m_poppers) | ||||