0
\$\begingroup\$

Let's say that I have two threads.

Both of them generates and binds to a vbo separately.

If I join and run these threads the behavior will be undefined obviously.

Because one may generate the vbo and one may Bind the vbo.

So how do AAA games like doom resolve this problem.

I chose that game because it most likely to be run in multiple threads. Thank you

\$\endgroup\$
  • \$\begingroup\$ Didn't Doom use Vulkan? \$\endgroup\$ – Krythic Nov 14 '16 at 12:41
  • \$\begingroup\$ Older doom games!!! \$\endgroup\$ – Yashwanth CB Nov 14 '16 at 12:41
  • \$\begingroup\$ I thought it had openGL backend \$\endgroup\$ – Yashwanth CB Nov 14 '16 at 12:45
  • \$\begingroup\$ Hey mate. Doom has both openGL and Vulcan backends and no direct x for pc. There are 4 doom games all using openGL \$\endgroup\$ – Yashwanth CB Nov 14 '16 at 13:10
  • \$\begingroup\$ neowin.net/forum/topic/202708-is-doom-3-dx9-or-opengl \$\endgroup\$ – Yashwanth CB Nov 14 '16 at 13:17
2
\$\begingroup\$

There are a number of ways to handle this cleanly, but the simplest way is to use an API that's actually designed to work well with multithreading.

That means not using OpenGL, because OpenGL's global state, implied context, and bind-to-modify makes it work poorly with multithreading.

Most AAA games actually don't use OpenGL so this isn't a problem for them.

If you must use OpenGL there are of course solutions, including using wglShareLists (or equivalent) to share objects between contexts (and then being very very careful about how threads use objects), or restricting all GL calls to a single thread.

\$\endgroup\$
  • \$\begingroup\$ What do you mean by implied context \$\endgroup\$ – Yashwanth CB Nov 14 '16 at 14:07
  • \$\begingroup\$ All GL calls are relevant to the current context, but how do you know which context is current? You don't (unless you track it yourself), so the current context is effectively a hidden "this" parameter on all calls. \$\endgroup\$ – Maximus Minimus Nov 14 '16 at 17:15
  • \$\begingroup\$ You mean Implicit context?? \$\endgroup\$ – Yashwanth CB Nov 14 '16 at 17:58
  • \$\begingroup\$ @YashwanthCB - I believe that either is valid terminology (and certainly neither is official terminology). \$\endgroup\$ – Maximus Minimus Nov 14 '16 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.