softgpu: Avoid thread ordering hazard.

Must run the primitives in the right order.  No shortcutting allowed.
This commit is contained in:
Unknown W. Brackets
2022-01-13 23:03:42 -08:00
parent 970e9c2f51
commit dffc333120
3 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -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++;