36 lines
934 B
C++
36 lines
934 B
C++
#include "XCEngine/RHI/D3D12/D3D12ConstantBufferView.h"
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
D3D12ConstantBufferView::D3D12ConstantBufferView()
|
|
: m_handle({0})
|
|
, m_resource(nullptr) {
|
|
}
|
|
|
|
D3D12ConstantBufferView::~D3D12ConstantBufferView() {
|
|
Shutdown();
|
|
}
|
|
|
|
void D3D12ConstantBufferView::Initialize(ID3D12Device* device, ID3D12Resource* buffer, const D3D12_CONSTANT_BUFFER_VIEW_DESC* desc) {
|
|
m_resource = buffer;
|
|
m_handle = {};
|
|
|
|
if (desc) {
|
|
device->CreateConstantBufferView(desc, m_handle);
|
|
} else {
|
|
D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {};
|
|
cbvDesc.BufferLocation = buffer->GetGPUVirtualAddress();
|
|
cbvDesc.SizeInBytes = static_cast<UINT>(buffer->GetDesc().Width);
|
|
device->CreateConstantBufferView(&cbvDesc, m_handle);
|
|
}
|
|
}
|
|
|
|
void D3D12ConstantBufferView::Shutdown() {
|
|
m_handle = {};
|
|
m_resource = nullptr;
|
|
}
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|