•DirectX-Graphics-Samples-master\Samples\Desktop\D3D12HelloWorld\src\HelloConstBuffers
•Describe how to pass
constant buffer to shaders.
Diff from D3DXHelloTriangle.h
struct
SceneConstantBuffer
{
XMFLOAT4 offset;
};
SceneConstantBuffer m_constantBufferData;
// constant buffer view (CBV) descriptor heap.
ComPtr<ID3D12DescriptorHeap> m_cbvHeap;
ComPtr<ID3D12Resource> m_constantBuffer;
UINT8* m_pCbvDataBegin;
D3D12HelloConstBuffers objects and their relations
•m_constantBuffer->Map()
is called to get mapped pointer m_cbvDataBegin on OnInit()
and m_constantBuffer is
never Unmap()
ed. Keep constant buffer mapped is OK
•OnUpdate(),
constant buffer data is updated and memcpy() ed to m_cbvDataBegin.
•m_commandList->SetDescriptorHeaps()
and m_commandList->SetGraphicsRootDesrptorTable() to
set m_cbvHeap.
•on Shaders.hlsl,
constant buffer is exposed at register(b0):
cbuffer SceneConstantBuffer : register(b0)
{
float4 offset;
};
No comments:
Post a Comment