mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
softgpu: Avoid thread ordering hazard.
Must run the primitives in the right order. No shortcutting allowed.
This commit is contained in:
parent
970e9c2f51
commit
dffc333120
3 changed files with 5 additions and 4 deletions
|
@ -258,13 +258,13 @@ void ThreadManager::EnqueueTask(Task *task) {
|
|||
chosenThread->cond.notify_one();
|
||||
}
|
||||
|
||||
void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task) {
|
||||
void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task, bool enforceSequence) {
|
||||
_assert_msg_(threadNum >= 0 && threadNum < (int)global_->threads_.size(), "Bad threadnum or not initialized");
|
||||
ThreadContext *thread = global_->threads_[threadNum];
|
||||
|
||||
// Try first atomically, as highest priority.
|
||||
Task *expected = nullptr;
|
||||
bool queued = thread->private_single.compare_exchange_weak(expected, task);
|
||||
bool queued = !enforceSequence && thread->private_single.compare_exchange_weak(expected, task);
|
||||
// Whether we got that or will have to wait, increase the queue counter.
|
||||
thread->queue_size++;
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ public:
|
|||
// just ignore it and let the OS handle it.
|
||||
void Init(int numCores, int numLogicalCoresPerCpu);
|
||||
void EnqueueTask(Task *task);
|
||||
void EnqueueTaskOnThread(int threadNum, Task *task);
|
||||
// Use enforceSequence if this must run after all previously queued tasks.
|
||||
void EnqueueTaskOnThread(int threadNum, Task *task, bool enforceSequence = false);
|
||||
void Teardown();
|
||||
|
||||
bool IsInitialized() const;
|
||||
|
|
|
@ -257,7 +257,7 @@ void BinManager::Drain() {
|
|||
|
||||
waitable_->Fill();
|
||||
DrawBinItemTask *task = new DrawBinItemTask(waitable_, item, range, states_[item.stateIndex]);
|
||||
g_threadManager.EnqueueTaskOnThread(i, task);
|
||||
g_threadManager.EnqueueTaskOnThread(i, task, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue