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\$
8
  • \$\begingroup\$ Didn't Doom use Vulkan? \$\endgroup\$
    – Krythic
    Commented Nov 14, 2016 at 12:41
  • \$\begingroup\$ Older doom games!!! \$\endgroup\$ Commented Nov 14, 2016 at 12:41
  • \$\begingroup\$ I thought it had openGL backend \$\endgroup\$ Commented Nov 14, 2016 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\$ Commented Nov 14, 2016 at 13:10
  • \$\begingroup\$ neowin.net/forum/topic/202708-is-doom-3-dx9-or-opengl \$\endgroup\$ Commented Nov 14, 2016 at 13:17

1 Answer 1

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\$
4
  • \$\begingroup\$ What do you mean by implied context \$\endgroup\$ Commented Nov 14, 2016 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\$ Commented Nov 14, 2016 at 17:15
  • \$\begingroup\$ You mean Implicit context?? \$\endgroup\$ Commented Nov 14, 2016 at 17:58
  • \$\begingroup\$ @YashwanthCB - I believe that either is valid terminology (and certainly neither is official terminology). \$\endgroup\$ Commented Nov 14, 2016 at 20:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .