Multi-Threaded Rendering (Windows Store only)

Some parts of book removed due to page counts, so I decided to add these sections to the website of the book. This section is about Multi-threaded rendering in DirectX 11.1 or the later version (that is DirectX 11.2).

Direct3D 11 has introduced some very interesting and powerful new features such as tessellation and multi-threaded rendering. I covered tessellation in chapter 4 of “DirectX 11.1 Game Programming”, but I couldn’t cover the most important one, I mean multi-threaded rendering.

In past few years, the average number of CPU and GPU cores has been vastly increasing.   Most computers possess multiple cores within their processors. Prior versions of Direct3D 11 did not take the advantage of multiple cores and multiple threads of execution, but in Direct3D11 and the later versions, provide an ability for your program to use the maximum performance of target machine and scale with the number of CPU cores.

In this section will cover how to implement multi-threaded rendering with Direct3D 11.2 on Windows 8.1, also it can be run on Direct3D 11.1 and Windows 8.

The Prerequisites

The following are some essential prerequisites that should be considered before developing an application using DirectX 11.2:

  • The first important requirement is a personal computer or tablet running on Windows 8.1.
  • You need to set up Microsoft Visual Studio Express 2013 for Windows 8.1 as a developer environment.
  • Make sure you set up the Windows Software Development Kit (SDK) for Windows 8.1. The Windows SDK for Windows 8.1 contains headers, libraries, and tools that can be used when creating Windows 8.1 applications.
  • Download the source code of this project which uploaded by me on MSDN Code Gallery.

We are going to demonstrate how to split rendering 100 models among multiple threads. As you might know, since Direct3D 11, we had two contexts type, the immediate context and the deferred context. The first one can only create on main thread once the device is created, just like the context which we created on “game.cpp”, and this context interacts with pipeline as the primary interface. On the other hand, the deferred context can record a command list from other threads except the main rendering thread.

Take a look at the following figure, the immediate context first draws primitives then executes the each command list of deferred contexts.


Now open the “SimpleScene.cpp” from the solution. The main methods are InitializeThreads and Render which defined in this class.

In the InitializeThreads method, we need to create the deferred contexts and events, note that events in C++/CX can be created with CreateEventExW function.

Now what’s really happening on Render method? Well first we set the render target view and clear the render target view and depth stencil view like as before.

Note that the command list must not change in each frame, this cause the additional costs over the performance. That’s all, you can get the source code from here. I hope it will be useful.


References: MultithreadedRendering11 Sample, DirectX SDK June 2010

10 thoughts on “Multi-Threaded Rendering (Windows Store only)”

  1. I see you are sharing valuable content on your website, do you know that you can monetize your site and earn a lot of money, just search in google for – Make money online by Nelpersempre – additional $100-$200 a day is worth a try

  2. Pingback: Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *