this post was submitted on 29 Jun 2023
119 points (100.0% liked)
Gaming
30532 readers
75 users here now
From video gaming to card games and stuff in between, if it's gaming you can probably discuss it here!
Please Note: Gaming memes are permitted to be posted on Meme Mondays, but will otherwise be removed in an effort to allow other discussions to take place.
See also Gaming's sister community Tabletop Gaming.
This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I'm really curious how they're doing it, too! I'm making a multithreaded simulation game and the parts that can't multithread well are related to AI / character logic / tasks and errands / pathfinding, and anything to do with rendering.
Would you mind explaining to me why you would include "anything to do with rendering" in that list? I haven't tried myself at multithreading yet, but rendering was easy enough (in my limited experience) to completely decouple from the actual game state or game logic.
I'm simply curious, because I'm toying with the idea to utilize multithreading in my next project.
By "rendering" I mean when you interact with OpenGL, the GPU, etc - at least in my engine (lwjgl/libgdx), it's expected to be on the main thread. From what I understand too when you get into GPU land everything is already kinda-asynchronous on the driver side - it's only when you call
flush()
that it actually blocks your thread - which makes it difficult to profile some things.But I am still a newb at all of this! I'd love to hear your experiences!!
Yes, would be cool to get some technical overview on how they do it. Maybe a lengthy blog post or something.
Rendering can be multi-threaded if you do it grounds up and use a rendering API made for it such as Vulkan or DX12. I used Vulkan a bit and you can create command-buffers from threads, and assemble them into your queue then. So you could have one thread creating the command buffer to draw all static meshes, and another one doing it for the particle system. And there is the "Async Compute" that allows the GPU to do compute shader tasks while CPU is busy building draw commands etc. I don't know enough to tell you details as my own work with Vulkan is very basic. But the in-house engine at my workplace uses those techniques to multithread.
There are systems that can run in parallel to each other. The sound system often needs to be their own threads. Low priority tasks such as wayfinding for NPCs. They don't need to recalculate their paths in a tight loop every frame, they "interpolate" to the next waypoint in between.
Parallel stuff is so dang hard to get correct and actually gather speed. Kudos to you that you are doing that. May your data access never be a race condition. :)
Yeah in the future I've already decided I want to try creating IntBuffers and stuff on threads but I'll need to do a lot of testing to make sure it's actually faster across a wide range of hardware 😀
I wrote a little blog post about my latest work if you're curious!