10
votes
Should I use Async & Await, instead of Coroutines, in Unity?
In contrast to Evorlor's answer, here are some good reasons to use Coroutines:
They've been the standard solution in Unity for many years and anyone else you bring onto the team should already be ...
8
votes
Would I need to develop a multi-threaded game or will a single thread suffice?
Generally it's best not to over-engineer, solving problems you may not really have.
If you want to make a "simple 2D fighter," well, remember we had those on the NES and even earlier.
Even a single ...
7
votes
Accepted
How Many Threads is 'Too Many'?
What matters is not the number of threads, but their CPU time
Probably you do not need your threads to have full utilization. If you do, get better hardware. In fact, you can use CPU utilization as ...
7
votes
Multithreading MMO Server. A thread per area OK?
I think this might be a viable architecture. The biggest source of bugs in multithreaded applications is shared access to data. So when the rooms have little to no communication with each other and ...
5
votes
Accepted
Two Gameloops instead of one, wouldn't it be better?
That's an interesting idea, however...
With multi-threading, you lose your advantage because you have to stop the update thread when you update your graphics.
Think about it: if you render at the ...
5
votes
Accepted
Multithreading: Each system on a different thread or a thread pool?
One important concern when deciding units of parallelization is usually to avoid sharing data between threads. Multiple threads operating on the same data is always hairy, because:
if those accesses ...
4
votes
Game loop with multithreading
First of all, heed the warning by DMGregory in the comments to the question. Multithreading is an evil source of weird, randomly appearing and impossible to reproduce bugs. Do not use it unless you ...
4
votes
Would I need to develop a multi-threaded game or will a single thread suffice?
Rule number one of multithreading: Don't even think about it, unless you really need to use multiple CPU cores for performance reasons*. Multithreading opens up a whole can of worms of obscure and ...
4
votes
Question on parallelizing ECS Systems
Pipelines
The simplest implementation of ECS will run systems sequentially one after the other. Perhaps you are familiar with the idea of fixing your timestep. Simply running systems sequentially in a ...
4
votes
How would you write a multithreaded gameloop in C++20 (+) or C++/WinRT?
When you are separating a game engine into threads, then there are two main concerns:
Each worker-thread should have roughly the same amount of work to do
Avoid communication and data sharing between ...
3
votes
Accepted
Return value from coroutine to non monobehaviour
It's not true that you can't make a method in a base class working as a coroutine.
If I understood you correctly, the AssessGeneration method is inside your base ...
3
votes
Can a loading screen be implemented using one thread only? If so, how?
You basically have to break down the loaded data into smaller chunks, and intersperse UI updates in between those bits of processing. The finer the granularity of the chunks of data you synchronously ...
3
votes
Accepted
OpenGL draw functions and multi-threading. How they work together?
It is definitely possible and useful to make your rendering multithreaded, but it wouldn't work the way you've proposed. Keep in mind that with OpenGL, you're drawing all the objects for a frame into ...
3
votes
Multithreaded design for a game server
The greatest problem when it comes to parallelization is sharing data between threads. When multiple threads read and write the same data structure simultaneously, then you will have a myriad of ...
3
votes
Accepted
Using Unity Jobs to encode file to PNG and then save it on Main Thread
After testing I found a few problems.
The png format does not save the color information of each pixel. It is a compressed image format. The length of the btyes written to the file is obviously ...
3
votes
Accepted
Python GLFW and PyOpenGL: How to update a VBO from a thread while rendering at the same time
If you want to be able to read and write buffers while they're being used, you can use "persistently-mapped buffers". Be aware that by using them, you will become responsible for handling ...
2
votes
Putting each animation on a thread
First off, threads are expensive. That does not mean that this technique cannot work, just that it is likely to be inefficient.
In your particular case, you will have threads waking up each 10 ...
2
votes
Accepted
C++ Thread, structuring thread so Gameloop can continue
Disclaimer; I am not a C++/gaming dev expert, but happened to run across your question, and think I understand the problem..
Every single loop you call this every every thread;
...
2
votes
SDL - Limiting loop with timer? Not polling
SDL_AddTimer is a problem here. SDL_AddTimer spawns a new thread, and things won't work like you expect when using multiple threads. When you call SDL_Init(), you likely do it from the main thread, ...
2
votes
Accepted
In Unity, how do I use the extra time in every frame to do some extra processing?
This (general) approach is used in several AAA engines, but isn't very compatible with the way current Unity (2017) works.
To do what you've described, you'd have to build your own task system that ...
2
votes
Accepted
Access a ID3D11Texture2D in another thread
Methods on the DirectX 11 Device are thread-safe, but methods on the DirectX 11 DeviceContext are not.
In other words, the application must manage the thread-safety when sharing the immediate context ...
2
votes
Two Gameloops instead of one, wouldn't it be better?
Just to expand on the other answers a bit:
Unity and Unreal both use separate threads for update (typically called the "game thread") & render, specifically to keep them from slowing ...
2
votes
Accepted
Unity: Loading screen without a coroutine (is it possible?)
The reason why the button gets stuck until the scene loads is, you are not loading the mesh in a parallel thread or a coroutine that allows the game loop to keep ticking, hence, you are loading it in ...
2
votes
My Java Game's movement looks awfull. Maybe Problem with Thread.sleep
There are three problems here:
When you call Thread.sleep(15) you forget to account for the time it took to calculate and render the previous frame. Before you ...
2
votes
Accepted
Should I create thread for both UDP and TCP?
30 threads on the server is no big deal... much less on a dedicated server. My PC has, at the moment of writing, around 1750 open threads (in Windows, you can find this in the task manager).
Well, ...
2
votes
In Unreal why is it safe to access a UTexture2D's properties from the render thread despite the documentation stating this is not allowed?
I think I've figured out how it works. I'll edit this answer if I find a definitive answer.
It was actually simpler than I was thinking. FRenderResource instances ...
2
votes
How would I optimize that piece of code using Unity?
Although a GPU solution is probably better and faster in your case, I don't have enough knowledge about this so I'll leave it to someone else to write that answer :)
Here I'll show you an example of ...
2
votes
Accepted
How would I optimize that piece of code using Unity?
Here is a vertex-fragment shader that imitates the action of your job:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
multithreading × 278c++ × 46
unity × 36
c# × 35
java × 35
opengl × 27
architecture × 22
xna × 18
optimization × 18
multiplayer × 16
game-loop × 16
android × 14
loading × 13
server × 10
rendering × 9
networking × 9
mmo × 9
coroutines × 9
input × 8
physics × 7
synchronization × 7
directx × 6
directx11 × 6
path-finding × 6
lwjgl × 6