Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm creating a game engine that utilizes multiple threads. In its current state, it uses two threads: one for handling windows messages (main thread), and another specifically for OpenGL.

Its not of immediate concern, but I have discovered that the main thread bottlenecks the OpenGL thread. What this means is that if the update loop of the main thread takes longer to complete than loop in the other, it will slow it down. If the main thread is slower, the GL thread will only update as fast as the main thread.

Obviously this isn't a major issue since the main thread will never have more to do than the OpenGL thread, but I'd like to know whats going on to better understand the winapi and OpenGL on windows.

Does anyone know whats happening here?

Note: The GL thread will update normally whenever I interact with the window (move it, resize it, etc).
Posted
Updated 6-Jul-11 19:57pm
v2
Comments
Chuck O'Toole 7-Jul-11 1:58am    
How many cores / cpus on your machine?
James_722 7-Jul-11 2:08am    
4 cores (Intel q6600)

In your situation, 2 things affect time sharing
1) Thread priorities
2) If thread(s) is/are blocked due to waiting for a shared resource (a critical section for example)

If your OpenGL thread has a higher priority than the main thread, AND there are no blocking situations, it is not possible for your main thread to slow down your OpenGL thread.
 
Share this answer
 
After a little more experimentation I solved the issue.

I was monitoring the frame rate coming from the GL thread by displaying it in the window's title.

When I stopped displaying the frame rate it was clear that the GL thread was no longer being affected by the main.

What I have concluded is that SetWindowText() must not finish execution until it has passed through the windows messaging system. the GL thread could not continue until that message was processed and thus linked its performance to that of the main thread.

I appreciate the help I received and hopefully this post will helpful to others.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900