Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-threaded rendering D3D/OpenGL/Whatever

I've been reading a lot about multi-threaded rendering. People have been proposing all kinds of weird and wonderful schemes for submitting work to the GPU with threads in order to speed up their frame rates and get more stuff rendered, but I'm having a bit of a conceptual problem with the whole thing and I thought I'd run it by the gurus here to see what you think.

As far as I know, the basic unit of concurrency on a GPU is the Warp. That is to say, it's down at the pixel level rather than higher up at the geometry submission level. So given that the unit of concurrency on the GPU is the warp, the driver must be locked down pretty tightly with mutexes to prevent multiple threads screwing up each other's submissions. If this is the case, I don't see where the benefit is of coding to D3D or OpenGL multi-threading primitives.

Surely the most efficient method of using your GPU in a multi-threading scenario is at the higher, abstract level, where you're collecting together batches of work to do, before submitting it? I mean rather than randomly interleving commands from multiple threads, I would have thought a single block accepting work from multiple threads, but with a little intelligence inside of it to make sure things are ordered for better performance before being submitted to the renderer, would be a much bigger gain if you wanted to work with multiple threads.

So, whither D3D/OpenGL multi-threaded rendering support in the actual API?

Help me with my confusion!

like image 877
Robinson Avatar asked May 28 '13 13:05

Robinson


People also ask

Should you have multi threaded rendering on?

If you're playing VALORANT on a high-end device, you may want to turn on Multithreaded Rendering – a video setting that can improve CPU performance and graphics quality on high spec devices (you can get more specifics in these patch notes).

Can OpenGL be multithreaded?

Use only one thread per context. OpenGL commands for a specific context are not thread safe. You should never have more than one thread accessing a single context simultaneously. Contexts that are on different threads can share object resources.

How do I enable multi threaded rendering?

To enable multithreaded rendering, go to Player Settings > Android and select the Multithreaded Rendering option.

Is Vulkan multithreaded?

Introduction. Multithreading is a cornerstone of Vulkan. Vulkan allows application to spread rendering workload across multiple CPU threads. This can have huge benefit for complex applications.


1 Answers

Your question comes from a misunderstanding of the difference between "make their renderers multi-threaded" and "multithreaded rendering".

A "renderer", or more precisely a "rendering system," does more than just issue rendering commands to the API. It has to shuffle memory around. It may have to load textures dynamically into and out-of graphics memory. It may have to read data back after some rendering process. And so forth.

To make a renderer multithreaded means exactly that: to make the rendering system make use of multiple threads. This could be threading scene graph management tasks like building the list of objects to render (frustum culling, BSPs, portals, etc). This could be having a thread dedicated to texture storage management, which swaps textures in and out as needed, loading from disk and such. This could be as in the D3D11 case of command lists, where you build a series of rendering commands in parallel with other tasks.

The process of rendering, the submission of actual rendering commands to the API, is not threaded. You generally have one thread who is responsible for the basic glDraw* or ::DrawIndexedPrimitive work. D3D11 command lists allow you to build sequences of these commands, but they are not executed in parallel with other rendering commands. It is the rendering thread and the main context that is responsible for actually issuing the command list; the command list is just there to make putting that list together more thread-friendly.

like image 134
Nicol Bolas Avatar answered Nov 15 '22 07:11

Nicol Bolas