Add GetDescriptorHandleIncrementSize to D3D12Device and update main.cpp to use wrapper

This commit is contained in:
2026-03-15 20:31:37 +08:00
parent 3e6388c221
commit 2a5fc4f0d4
5 changed files with 19 additions and 3 deletions

View File

@@ -27,6 +27,8 @@ public:
uint64_t GetSize() const { return GetDesc().Width; }
D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress() const { return m_resource->GetGPUVirtualAddress(); }
void UpdateData(const void* data, uint64_t size);
private:
ComPtr<ID3D12Resource> m_resource;
};

View File

@@ -51,6 +51,8 @@ public:
std::vector<AdapterInfo> EnumerateAdapters();
UINT GetDescriptorHandleIncrementSize(DescriptorHeapType type) const;
bool CheckFeatureSupport(D3D12_FEATURE feature, void* featureSupportData, uint32_t featureSupportDataSize);
void SetDeviceRemoved() { m_isDeviceRemoved = true; }

View File

@@ -147,5 +147,13 @@ void D3D12Buffer::Shutdown() {
m_resource.Reset();
}
void D3D12Buffer::UpdateData(const void* data, uint64_t size) {
D3D12_RANGE range = { 0, static_cast<SIZE_T>(size) };
unsigned char* pBuffer = nullptr;
m_resource->Map(0, &range, reinterpret_cast<void**>(&pBuffer));
memcpy(pBuffer, data, static_cast<size_t>(size));
m_resource->Unmap(0, nullptr);
}
} // namespace RHI
} // namespace XCEngine

View File

@@ -165,5 +165,9 @@ std::vector<AdapterInfo> D3D12Device::EnumerateAdapters() {
return adapters;
}
UINT D3D12Device::GetDescriptorHandleIncrementSize(DescriptorHeapType type) const {
return m_device->GetDescriptorHandleIncrementSize(ToD3D12(type));
}
} // namespace RHI
} // namespace XCEngine