feat: 实现D3D12CommandQueue和D3D12CommandAllocator
- 添加D3D12CommandQueue类封装ID3D12CommandQueue - 添加D3D12CommandAllocator类封装ID3D12CommandAllocator - 在D3D12Enum.h中添加CommandQueueType转换函数 - 在CMake中添加Res文件夹自动拷贝到输出目录 - 更新测试项目使用新的封装类
This commit is contained in:
32
engine/include/XCEngine/RHI/D3D12/D3D12CommandAllocator.h
Normal file
32
engine/include/XCEngine/RHI/D3D12/D3D12CommandAllocator.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "../Enums.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12CommandAllocator {
|
||||
public:
|
||||
D3D12CommandAllocator();
|
||||
~D3D12CommandAllocator();
|
||||
|
||||
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct);
|
||||
void Shutdown();
|
||||
|
||||
void Reset();
|
||||
bool IsReady() const;
|
||||
|
||||
ID3D12CommandAllocator* GetCommandAllocator() const { return m_commandAllocator.Get(); }
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12CommandAllocator> m_commandAllocator;
|
||||
CommandQueueType m_type;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
40
engine/include/XCEngine/RHI/D3D12/D3D12CommandQueue.h
Normal file
40
engine/include/XCEngine/RHI/D3D12/D3D12CommandQueue.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "../Enums.h"
|
||||
#include "D3D12Enum.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class D3D12CommandQueue {
|
||||
public:
|
||||
D3D12CommandQueue();
|
||||
~D3D12CommandQueue();
|
||||
|
||||
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct);
|
||||
void Shutdown();
|
||||
|
||||
void ExecuteCommandLists(uint32_t count, ID3D12CommandList** lists);
|
||||
void Signal(ID3D12Fence* fence, uint64_t value);
|
||||
void Wait(ID3D12Fence* fence, uint64_t value);
|
||||
uint64_t GetCompletedValue(ID3D12Fence* fence);
|
||||
void WaitForIdle();
|
||||
|
||||
CommandQueueType GetType() const { return m_type; }
|
||||
uint64_t GetTimestampFrequency() const { return m_timestampFrequency; }
|
||||
|
||||
ID3D12CommandQueue* GetCommandQueue() const { return m_commandQueue.Get(); }
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12CommandQueue> m_commandQueue;
|
||||
CommandQueueType m_type;
|
||||
uint64_t m_timestampFrequency;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
@@ -273,5 +273,14 @@ inline D3D12_STENCIL_OP ToD3D12(StencilOp op) {
|
||||
return D3D12_STENCIL_OP_KEEP;
|
||||
}
|
||||
|
||||
inline D3D12_COMMAND_LIST_TYPE ToD3D12(CommandQueueType type) {
|
||||
switch (type) {
|
||||
case CommandQueueType::Direct: return D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
case CommandQueueType::Compute: return D3D12_COMMAND_LIST_TYPE_COMPUTE;
|
||||
case CommandQueueType::Copy: return D3D12_COMMAND_LIST_TYPE_COPY;
|
||||
}
|
||||
return D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
}
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
|
||||
Reference in New Issue
Block a user