Add IRHIDevice interface implementation to D3D12Device

- D3D12Device now inherits from IRHIDevice
- Implement factory methods: CreateCommandQueue, CreateCommandList, CreateFence, etc.
- Make D3D12CommandQueue implement ICommandQueue
- Add backward-compatible overloads for existing main.cpp code
- Remove duplicate Viewport/Rect definitions from D3D12CommandList.h
- Update main.cpp to use IRHIDevice* pointer
This commit is contained in:
2026-03-15 23:03:06 +08:00
parent dfbd218435
commit fb2b794156
7 changed files with 262 additions and 60 deletions

View File

@@ -1,4 +1,7 @@
#include "XCEngine/RHI/D3D12/D3D12CommandQueue.h"
#include "XCEngine/RHI/D3D12/D3D12CommandList.h"
#include "XCEngine/RHI/D3D12/D3D12Fence.h"
#include <vector>
namespace XCEngine {
namespace RHI {
@@ -33,22 +36,45 @@ void D3D12CommandQueue::Shutdown() {
m_commandQueue.Reset();
}
void D3D12CommandQueue::ExecuteCommandLists(uint32_t count, ICommandList** lists) {
std::vector<ID3D12CommandList*> d3d12Lists(count);
for (uint32_t i = 0; i < count; ++i) {
if (lists[i]) {
d3d12Lists[i] = reinterpret_cast<D3D12CommandList*>(lists[i])->GetCommandList();
}
}
m_commandQueue->ExecuteCommandLists(count, d3d12Lists.data());
}
void D3D12CommandQueue::ExecuteCommandLists(uint32_t count, ID3D12CommandList** lists) {
m_commandQueue->ExecuteCommandLists(count, lists);
}
void D3D12CommandQueue::Signal(IFence* fence, uint64_t value) {
if (fence) {
m_commandQueue->Signal(reinterpret_cast<D3D12Fence*>(fence)->GetFence(), value);
}
}
void D3D12CommandQueue::Signal(ID3D12Fence* fence, uint64_t value) {
m_commandQueue->Signal(fence, value);
if (fence) {
m_commandQueue->Signal(fence, value);
}
}
void D3D12CommandQueue::Wait(IFence* fence, uint64_t value) {
if (fence) {
m_commandQueue->Wait(reinterpret_cast<D3D12Fence*>(fence)->GetFence(), value);
}
}
void D3D12CommandQueue::Wait(ID3D12Fence* fence, uint64_t value) {
m_commandQueue->Wait(fence, value);
if (fence) {
m_commandQueue->Wait(fence, value);
}
}
uint64_t D3D12CommandQueue::GetCompletedValue(ID3D12Fence* fence) {
if (fence) {
return fence->GetCompletedValue();
}
uint64_t D3D12CommandQueue::GetCompletedValue() {
return 0;
}