Ember

DirectX versus OpenGL

Jun 8th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. But only one thread may use the context at a time. Multiple threads may use the same context, but not at the same time. DX11 gets around this by having separate command queues for each additional thread, but only one primary context.
  2.  
  3. Each thread can write to its own queue without blocking, which OpenGL can not do.
  4. Parent Share
  5.  
  6. Several objects may be sent to the GPU at the same time. Sending data to the GPU typically causes a context switch, which is expensive. DX11 gets around this by letting each worker thread write to its own command queue, then the primary context thread will notify the GPU when to read from the command queues. This effectively allows communications to the GPU to be batched instead of tossing around the GPU context between threads, which incurs a lot of overhead and is serialized.
  7.  
  8. Because the GPU is notified by the primary context, there is effectively one context switch to offload a lot of data. The driver knows where these command queues are and will read from them.
  9.  
  10. DX11 even allows the CPU to help the GPU. GPUs are great for certain types of calculations, but not as great for others. DICE had a nice blog many years ago about how they can send data to the GPU to be processed for one stage, then stream the data from the GPU as it completes, back to the CPU. The CPU then starts working on the data one one 16x16 tile at a time and streams the changes back to the GPU as each tile is completed.
  11.  
  12. They were able to keep the CPU and GPU well-loaded, while increasing efficiency and reducing memory pressure by data streaming.
  13.  
  14. They had the classic latency vs throughput issue. Because each stage was only dependent on the prior stage, they were able to keep streaming input into the engine to keep both the GPU and CPU busy. While the CPU was busy crunch special pixel shaders that ran slowly on the GPU, the GPU would be working on physics on the upcoming scene. etc etc
  15.  
  16. DX11 effectively made the rendering pipeline modular and customization, allowing data to be shifted back-and-forth, but hid the latency by allowing the stages to be done asynchronously.
  17.  
  18. OpenGL doesn't care about latency vs throughput because professional rendering does not have a latency issue, like video-games do.
Advertisement
Add Comment
Please, Sign In to add comment