0. Requirements


 Sample code named 'D3D12HelloTriangle' which was downloaded in lecture 1. (Link)


1. Intro


   In the file 'D3D12HelloTriangle.cpp', we can find many functions. Among them, following four functions form a basic framework: 


- Oninit(): initialize the directx12 rendering environment. 

- OnUpdate(): update frame-based values such as animation matrix. 

- OnRender(): render the scene.

- OnDestroy(): release resources.


 Let's look at the components one by one. 



2. Oninit function


  Oninitfunction contains two additional sub-functions. LoadPipeline() and LoadAssets(). Let's take a closer look at the Loadpipeline() function. 


1) Loadpipeline()

1-1) Enabling the debug layer

  First, the code enables the debug layer by using Microsoft::WRL::ComPtr. 


1-2) CreateFactory

  Next, create a DXGI factory. It is an object that is capable of creating other DXGI objects. 


1-3) CreateDevice

  Then, DXGI device is created. To create device, adapter, and feature level is required. In the sample code, two types of adapter (warpAdapter and hardwareAdapter) and feature level 11 are used. 


1-4) Command Queue

  Command queue is the ordering of the commands. In the D3D11, both the immediate context and deferred context are supported. However, the immediate context is no longer supported by D3D12,  In the concept of deferred context, commands are queued up and run at a later time. For example, in multi-thread application, each threads can generate commands in parallel, and the commands are mounted on an API object called 'Command Queue'. We call it as a command parallelism. 


  Let's take a closer look at command queues and command lists. In D3D12, the process of transferring commands differes from D3D11 in three important ways: (For more details, you can visit the page: (Link) https://msdn.microsoft.com/en-us/library/windows/desktop/dn899114(v=vs.85).aspx


 1. Elimination of the immediate context. This enables multi-threading. 

 2. Apps own how rendering calls are grouped into GPU work items. This enables re-use.

 3. Apps explicitly control when work is transferred to the GPU. This enables item 1 and 2. 


   As mentioned above, D3D12 no longer supports immediate context. Instead, to render, command lists are used. A command list looks similar to the immediate context which is used in D3D11. Actually, they are similar. They contains commands such as drawing primitives or changing rendering state. However, command lists can be recorded to command queue concurrently, which takes advantage of multi-core processors. If the same process repeats over and over, a command list can be executed multiple times. 






'Cat.Storage > SubCat.Practice' 카테고리의 다른 글

[Directx12] 1. Settings  (0) 2017.04.13
[Matlab] Define 2D sinc() function  (0) 2016.09.21
C++ binary read/write sample  (0) 2016.03.15
D3D11 Rendertarget setting example.  (0) 2016.01.06
Magnitude and Phase Information of the FFT  (0) 2015.10.10
Posted by Cat.IanKang
,