- Add RHIDescriptorSet base class with Update/UpdateSampler/GetNativeHandle - Add RHIDescriptorPool with AllocateSet/FreeSet methods - Add SetGraphicsDescriptorSets/SetComputeDescriptorSets to RHICommandList - Implement D3D12DescriptorSet using descriptor heap allocation - Implement OpenGLDescriptorSet using TextureUnitAllocator - Add CreateDescriptorPool/CreateDescriptorSet factory methods to RHIDevice - Fix unit test SetVertexBuffer -> SetVertexBuffers API - Add SetVertexBuffer convenience method for D3D12 backward compatibility - Update CMakeLists.txt with new source files
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#include "XCEngine/RHI/D3D12/D3D12DescriptorSet.h"
|
|
#include "XCEngine/RHI/D3D12/D3D12DescriptorHeap.h"
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
D3D12DescriptorSet::D3D12DescriptorSet()
|
|
: m_heap(nullptr)
|
|
, m_offset(0)
|
|
, m_count(0)
|
|
, m_bindingCount(0)
|
|
, m_bindings(nullptr) {
|
|
}
|
|
|
|
D3D12DescriptorSet::~D3D12DescriptorSet() {
|
|
Shutdown();
|
|
}
|
|
|
|
bool D3D12DescriptorSet::Initialize(D3D12DescriptorHeap* heap, uint32_t offset, uint32_t count, const DescriptorSetLayoutDesc& layout) {
|
|
m_heap = heap;
|
|
m_offset = offset;
|
|
m_count = count;
|
|
m_bindingCount = layout.bindingCount;
|
|
|
|
if (layout.bindingCount > 0 && layout.bindings != nullptr) {
|
|
m_bindings = new DescriptorSetLayoutBinding[layout.bindingCount];
|
|
for (uint32_t i = 0; i < layout.bindingCount; ++i) {
|
|
m_bindings[i] = layout.bindings[i];
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void D3D12DescriptorSet::Shutdown() {
|
|
m_heap = nullptr;
|
|
m_offset = 0;
|
|
m_count = 0;
|
|
m_bindingCount = 0;
|
|
if (m_bindings != nullptr) {
|
|
delete[] m_bindings;
|
|
m_bindings = nullptr;
|
|
}
|
|
}
|
|
|
|
void D3D12DescriptorSet::Update(uint32_t offset, RHIResourceView* view) {
|
|
(void)offset;
|
|
(void)view;
|
|
}
|
|
|
|
void D3D12DescriptorSet::UpdateSampler(uint32_t offset, RHISampler* sampler) {
|
|
(void)offset;
|
|
(void)sampler;
|
|
}
|
|
|
|
void* D3D12DescriptorSet::GetNativeHandle() {
|
|
return this;
|
|
}
|
|
|
|
D3D12_GPU_DESCRIPTOR_HANDLE D3D12DescriptorSet::GetGPUHandle(uint32_t index) const {
|
|
if (m_heap == nullptr) {
|
|
return D3D12_GPU_DESCRIPTOR_HANDLE{0};
|
|
}
|
|
GPUDescriptorHandle handle = m_heap->GetGPUDescriptorHandle(m_offset + index);
|
|
return D3D12_GPU_DESCRIPTOR_HANDLE{ handle.ptr };
|
|
}
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|