D3D12HelloTriangle
- Downloaded programs from : https://github.com/Microsoft/DirectX-Graphics-Samples
- Project file is placed on DirectX-Graphics-Samples/Samples/Desktop/D3D12HelloTriangle.
- Draws vertex colored triangle. VSync buffer flip code is still not optimal.
Difference from D3D12HelloWorld
Took diff with WinMerge to find difference.
–D3D12HelloTriangle
class has several new members
•CD3DX12_VIEWPORT
m_viewport;
•CD3DX12_RECT
m_scissorRect;
•ComPtr<ID3D12RootSignature> m_rootSignature;
•ComPtr<ID3D12PipelineState> m_pipelineState;
•ComPtr<ID3D12Resource> m_vertexBuffer;
•D3D12_VERTEX_BUFFER_VIEW
m_vertexBufferView;
–New
struct declaration of triangle vertex
struct Vertex
{
XMFLOAT3 position;
XMFLOAT4 color;
};
D3D12HelloTriangle.cpp objects and their relations
•m_rootSignature
–rootSignature
specifies shader input parameters such as vertex buffer location or shader
constants.
–But
vertex buffer is specified by m_commandList->IASetVertexBuffers()
and shader does not use shader constants.
–m_rootSignature is
referenced by pipeline state object and pso uses it internally.
–m_commandList also
referenced m_rootSignature but
it seems it is not absolute necessary on this sample.
•m_viewPort
–specifies
viewport size (used to scale images to fit client area)
•m_scissorRect
–this
parameter is used for “scissoring” : scissors triangles which crosses window
edge to prevent corruption of geometry shape.
•m_pipelineState
–contains
rendering pipeline parameters such as vertex shader, pixel shader, alpha
blending, render target format and m_rootSignature
•m_vertexBuffer
–contains
triangle vertices position and vertex colors data.
–data
is placed on GPU memory.
•m_vertexBufferView
–struct
to store GPU memory address of vertex buffer and its size info.
–used
by m_commandList
Shader code
•Shader
is a program that runs on GPU.
•D3D12HelloTriangle
sample contains shaders.hlsl
•shaders.hlsl
contains vertex shader VSMain()
and pixel shader PSMain().
•VSMain()
processes one vertex, input vertex position and color from arg, and
send it to subsequent stage. VSMain() is called 3 times.
•PSMain() is
called on every pixel of triangle with VSMain() return value and calculate pixel
color.
•Shader
program is compiled to the executable code on D3D12HelloTriangle::OnInit() by calling D3DCompileFromFile()
and those shader binaries is passed to pipeline state object.
DirectX-Graphics-Samples-master\Samples\Desktop\D3D12HelloWorld\src\HelloBundles
Shows efficient triangle drawing using bundles.
D3D12HelloBundles sample
DirectX-Graphics-Samples-master\Samples\Desktop\D3D12HelloWorld\src\HelloBundles
Shows efficient triangle drawing using bundles.
Difference from HelloTriangle sample
•D3D12HelloBundles.h
–
ComPtr<ID3D12CommandAllocator>
m_bundleAllocator;
–
ComPtr<ID3D12GraphicsCommandList>
m_bundle;
•D3D12HelloBundles.cpp
–m_bundleAllocator
created as COMMAND_LIST_TYPE_BUNDLE
–m_bundle
command list is created as COMMAND_LIST_TYPE_BUNDLE and record pipeline setup and draw commands
–m_commandList->ExecuteBundle() to
execute recorded pipeline setup and draw command
No comments:
Post a Comment