Unity: how to use all CPU cores for Camera.Render with multi-threaded graphics? Optimization - Doesn't Work?

How to use the optimization of multi-threaded graphics?

I have a project (less game, more application) that uses dozens of cameras in the scene, and each rendering at a time. (Don't ask why this should be so!)

Needless to say, when you run the application, it almost maximizes one CPU core, since the rendering pipeline is single-threaded. As a result, it reduces the frame rate. (GPU, memory, etc. Significantly lower than 100% of the load - the CPU is the bottleneck here)

I was very pleased to see that Unity has the “Graphics Jobs (experimental)” option, which is specifically designed to split the rendering into multiple threads and, as such, across multiple cores.

However, if this option is enabled and DirectX12 is installed at the top of the list of graphical APIs, I would expect that the processor can now be fully used, namely all CPU cores can be involved in active rendering. However, it seems that the application still uses only about 40% of my processor potential, providing a low frame rate. Of course, it should only reduce the frame rate as soon as it exceeds the CPU? It seems that individual kernels are not used in different ways. Why can't I maximize the output frame rate using almost 100% of all the cores on my processor (in total, including any additional running programs)?

In fact, I would like to know how I can force Unity to use all my processor cores in full to get the highest frame rate possible, having so many cameras on my stage at the same time ..... I thought Graphics Jobs would solve is it? ... If I use them incorrectly or do not use the correct combination of settings?

Aside, my processor is i7-4790 @ 3.6ghz, and my GPU is 980Ti using DX12. 32 GB of RAM.

+5
source share
1 answer

During camera rendering, your processor should talk to the GPU in what is called drawcall . Under the hood, Unity already uses a multi-threaded approach ( ctrl + f "threads" ) to make the CPU talk to the GPU, and this process of solving tasks for workflows takes place in a black box. Please note: "Not all platforms support multi-threaded rendering; at the time of writing, WebGL does not support this feature. On platforms that do not support multi-threaded rendering, all CPU tasks are performed in a single thread."

So, if your application is connected with a processor, then perhaps your platform is not supported, or the tasks simply cannot be divided into small enough pieces to fill all your kernels or some other "black box", the reason, as it may the processor iterates through each camera sequentially, instead of grouping the bundle (this makes sense to me, because mainthread should be the one that should interact with the Unity API in streaming mode to determine what to draw).

It seems that your only option is to read the links given here and try to optimize your scene to minimize calls for a call back, but with that said, I think that trying to create “dozens of cameras” is a very bad idea to start especially if everything they perform a complex scene with high resolution, followed by processing, etc. - although I have never tried anything like this.

0
source

Source: https://habr.com/ru/post/1266173/


All Articles