42 lines
952 B
C++
42 lines
952 B
C++
#include "XCEngine/RHI/D3D12/D3D12RootSignature.h"
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
D3D12RootSignature::D3D12RootSignature() {
|
|
}
|
|
|
|
D3D12RootSignature::~D3D12RootSignature() {
|
|
Shutdown();
|
|
}
|
|
|
|
bool D3D12RootSignature::Initialize(ID3D12Device* device, const D3D12_ROOT_SIGNATURE_DESC& desc) {
|
|
ID3DBlob* signature = nullptr;
|
|
ID3DBlob* error = nullptr;
|
|
|
|
HRESULT hResult = D3D12SerializeRootSignature(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error);
|
|
if (FAILED(hResult)) {
|
|
if (error) {
|
|
error->Release();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
hResult = device->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_rootSignature));
|
|
|
|
signature->Release();
|
|
|
|
if (FAILED(hResult)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void D3D12RootSignature::Shutdown() {
|
|
m_rootSignature.Reset();
|
|
}
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|