Skip to content

Commit

Permalink
Remove redundant thread sync counter draw_pending
Browse files Browse the repository at this point in the history
The functions that used it already use a threadsafe FIFO queue
to communicate between threads and a sync to have the main thread
wait for the render thread.

Fixes #35718
  • Loading branch information
zmanuel committed Jan 30, 2020
1 parent 4e7d75c commit 151eb41
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
10 changes: 1 addition & 9 deletions servers/visual/visual_server_wrap_mt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@ void VisualServerWrapMT::thread_exit() {

void VisualServerWrapMT::thread_draw(bool p_swap_buffers, double frame_step) {

if (!atomic_decrement(&draw_pending)) {

visual_server->draw(p_swap_buffers, frame_step);
}
visual_server->draw(p_swap_buffers, frame_step);
}

void VisualServerWrapMT::thread_flush() {

atomic_decrement(&draw_pending);
}

void VisualServerWrapMT::_thread_callback(void *_instance) {
Expand Down Expand Up @@ -83,7 +78,6 @@ void VisualServerWrapMT::sync() {

if (create_thread) {

atomic_increment(&draw_pending);
command_queue.push_and_sync(this, &VisualServerWrapMT::thread_flush);
} else {

Expand All @@ -95,7 +89,6 @@ void VisualServerWrapMT::draw(bool p_swap_buffers, double frame_step) {

if (create_thread) {

atomic_increment(&draw_pending);
command_queue.push(this, &VisualServerWrapMT::thread_draw, p_swap_buffers, frame_step);
} else {

Expand Down Expand Up @@ -178,7 +171,6 @@ VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_
visual_server = p_contained;
create_thread = p_create_thread;
thread = NULL;
draw_pending = 0;
draw_thread_up = false;
alloc_mutex = Mutex::create();
pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
Expand Down
1 change: 0 additions & 1 deletion servers/visual/visual_server_wrap_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class VisualServerWrapMT : public VisualServer {
volatile bool draw_thread_up;
bool create_thread;

uint64_t draw_pending;
void thread_draw(bool p_swap_buffers, double frame_step);
void thread_flush();

Expand Down

0 comments on commit 151eb41

Please sign in to comment.