17 DirectX12Buffer(ID3D12Device* device,
size_t size, D3D12_HEAP_TYPE heapType,
18 D3D12_RESOURCE_STATES resourceState);
36 void Unmap() override;
38 void Update(
void* data,
size_t size) override;
40 bool Initialize(const
void* data,
size_t size);
48 ID3D12GraphicsCommandList*
GetCommandList()
const {
return m_commandList.Get(); }
54 bool IsValid()
const {
return m_buffer !=
nullptr; }
60 D3D12_RESOURCE_DESC CreateBufferDesc()
const;
66 bool CreateUploadBuffer(
const void* data,
size_t dataSize);
68 void SetAsVertexBuffer (ID3D12GraphicsCommandList* commandList, UINT slot, UINT stride, UINT offset = 0);
69 void SetAsIndexBuffer (ID3D12GraphicsCommandList* commandList, DXGI_FORMAT format, UINT offset = 0);
70 void SetAsConstantBuffer(ID3D12GraphicsCommandList* commandList, UINT rootParameterIndex);
73 void WaitForUploadComplete();
80 static void DeferCleanup(Microsoft::WRL::ComPtr<ID3D12Resource> resource);
86 Microsoft::WRL::ComPtr<ID3D12Device> m_device;
87 ID3D12CommandQueue* m_commandQueue =
nullptr;
88 Microsoft::WRL::ComPtr<ID3D12Resource> m_buffer;
89 Microsoft::WRL::ComPtr<ID3D12Resource> m_uploadBuffer;
90 Microsoft::WRL::ComPtr<ID3D12CommandAllocator> m_commandAllocator;
91 Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList> m_commandList;
93 D3D12_HEAP_TYPE m_heapType = D3D12_HEAP_TYPE_DEFAULT;
94 D3D12_RESOURCE_STATES m_resourceState = D3D12_RESOURCE_STATE_COMMON;
96 D3D12_RESOURCE_STATES m_currentState = D3D12_RESOURCE_STATE_COMMON;
97 void* m_mappedData =
nullptr;