from Hacker News

Multithreading for Game Engines

by vblanco on 3/21/21, 9:25 AM with 66 comments

  • by vvanders on 3/22/21, 12:00 AM

    While broadly right this has some inaccurate parts, in particular:

    > If we were talking about OpenGL, there would be absolutely nothing you can do. In OpenGL or other older APIs, it’s only possible to do API calls from one thread.

    Isn't really true. You can load textures off thread[1] and other things which come in handy. Vulkan expands that but I've done multithreaded texture loading for instance almost a decade ago.

    This is particular important if your not loading compressed textures as there's usually a tiling/swizzle pass and the texture copy can be significant on large textures(unless you're using something like eglCreateImageKHR).

    [1] https://www.khronos.org/opengl/wiki/OpenGL_and_multithreadin...

  • by m12k on 3/22/21, 9:40 AM

    IMO the Burst compiler that can "jobify" and multi-thread your code relatively painlessly is the most impressive piece of tech Unity has produced (disclosure: used to work there, though this was made after my time there). It's not that hard to fit into its constraints, and it often provides 2x-200x speedups. It's still mind-boggling to me that it's possible to get (a constrained subset of) C# to beat hand-optimized C++.
  • by Animats on 3/22/21, 12:46 AM

    "Unreal Engine 4 will have a Game Thread and a Render Thread ..."

    This seems dated. UE4 shipped in 2015.

  • by geswit2x on 3/22/21, 1:22 AM

    >”Unreal 4 will have...”

    Unreal Engine 5 is coming...

  • by Dowwie on 3/22/21, 10:43 AM

    Does anyone know of a collection of coding problems like "Dining Philosophers" for working through common concurrency scenarios and synchronization issues?
  • by tempnowreal on 3/22/21, 5:53 PM

    Can someone point me to good sourced where I can learn more about the inner workings of graphics? Something thats probably beginner friendly?
  • by bullen on 3/22/21, 10:13 AM

    When you multi-thread the rendering you _always_ push the motion-to-photon latency up, because you need to hand off the previous work to the renderer, sometimes by up to 10 frames!? That's is why AAA titles like the last guardian and RDR2 are unplayable.

    The only way to solve this is to make the GPU concurrent so it can receive instuctions on separate threads at the same time!