Studying D3D12HelloWindow desktop project
- Download programs from : https://github.com/Microsoft/DirectX-Graphics-Samples
- Project file is placed on DirectX-Graphics-Samples/Samples/Desktop/D3D12HelloWorld.
- Creates Window and paint its client area to blue using DirectX12.
D3D12HelloWorld
Main.cpp- There is WinMain() function, the entry point of the program.
- Instanciate D3D12HelloWindow and pass it to Win32Application::Run() function.
- Handles Windows API calls such as CreateWindow() and WindowProc() callback.
- DXSample::GetHardwareAdapter() calls D3D12CreateDevice to get ID3D12Device ptr.
- ParseCommandLineArgs() reads argc and argv and decide to use Warp(reference rasterizer) or not.
- Contains interesting DirectX12 code.
- D3D12HelloWindow::OnInit() prepares DirectX 12 resources.
- D3D12HelloWindow::OnRender() redraws image of render buffer and swap foreground render buffer with background render buffer.
D3D12HelloWindow members
m_swapChain
- Has two Output Render Targets, its size is window size and pixel format is RGBA8888
- m_swapChain->Present() is called to swap front buffer and back buffer on the next display vbrank event. this mechanism exists to prevent é½creen tearing・ it happens when displaying render target is overwritten by graphics redraw.
- prepared on D3D12HelloWindow::OnInit()
- associated to m_swapChain for force flush. (?)
- on OnRender() m_commandQueue->ExecuteCommandLists() is called.
- m_commandQueue->Signal() is used to wait frame redraw update.
- contains draw call to run on GPU.
- ClearRenderTargetView() with blue color specified.
Render target state management
It is necessary to change render target state to RENDER_TARGET before drawing and revert to PRESENT state when drawing finished.m_commandList->ResourceBarrier() do this task.
Double Buffering
VBlank event waiting
D3D12HelloWindow.cpp implementation is not optimal. D3DHelloFrameBuffering is more efficient. So VBlank event waiting code review will be performed with D3DHelloFrameBuffering
Next: Draw a triangle!
https://yamamoto2002.blogspot.com/2018/12/studying-d3d12hellotriangle-project.html
No comments:
Post a Comment