feat(RHI): 实现 RHICommandQueue 抽象基类
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <d3d12.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "../RHICommandQueue.h"
|
||||
#include "../RHIEnums.h"
|
||||
#include "D3D12Enum.h"
|
||||
|
||||
@@ -13,26 +14,29 @@ namespace RHI {
|
||||
|
||||
class D3D12Fence;
|
||||
|
||||
class D3D12CommandQueue {
|
||||
class D3D12CommandQueue : public RHICommandQueue {
|
||||
public:
|
||||
D3D12CommandQueue();
|
||||
~D3D12CommandQueue();
|
||||
~D3D12CommandQueue() override;
|
||||
|
||||
bool Initialize(ID3D12Device* device, CommandQueueType type = CommandQueueType::Direct);
|
||||
void Shutdown();
|
||||
void Shutdown() override;
|
||||
|
||||
void ExecuteCommandLists(uint32_t count, ID3D12CommandList** lists);
|
||||
void Signal(D3D12Fence* fence, uint64_t value);
|
||||
void Signal(ID3D12Fence* fence, uint64_t value);
|
||||
void Wait(D3D12Fence* fence, uint64_t value);
|
||||
void Wait(ID3D12Fence* fence, uint64_t value);
|
||||
uint64_t GetCompletedValue();
|
||||
void WaitForIdle();
|
||||
void ExecuteCommandLists(uint32_t count, void** lists) override;
|
||||
void Signal(RHIFence* fence, uint64_t value) override;
|
||||
void Wait(RHIFence* fence, uint64_t value) override;
|
||||
uint64_t GetCompletedValue() override;
|
||||
void WaitForIdle() override;
|
||||
|
||||
CommandQueueType GetType() const { return m_type; }
|
||||
uint64_t GetTimestampFrequency() const { return m_timestampFrequency; }
|
||||
CommandQueueType GetType() const override { return m_type; }
|
||||
uint64_t GetTimestampFrequency() const override { return m_timestampFrequency; }
|
||||
|
||||
ID3D12CommandQueue* GetCommandQueue() const { return m_commandQueue.Get(); }
|
||||
void* GetNativeHandle() override { return m_commandQueue.Get(); }
|
||||
|
||||
void ExecuteCommandListsInternal(uint32_t count, ID3D12CommandList** lists);
|
||||
void Signal(ID3D12Fence* fence, uint64_t value);
|
||||
void Wait(ID3D12Fence* fence, uint64_t value);
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12CommandQueue> m_commandQueue;
|
||||
|
||||
28
engine/include/XCEngine/RHI/OpenGL/OpenGLCommandQueue.h
Normal file
28
engine/include/XCEngine/RHI/OpenGL/OpenGLCommandQueue.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "../RHICommandQueue.h"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class OpenGLCommandQueue : public RHICommandQueue {
|
||||
public:
|
||||
OpenGLCommandQueue();
|
||||
~OpenGLCommandQueue() override;
|
||||
|
||||
void Shutdown() override;
|
||||
|
||||
void ExecuteCommandLists(uint32_t count, void** lists) override;
|
||||
void Signal(RHIFence* fence, uint64_t value) override;
|
||||
void Wait(RHIFence* fence, uint64_t value) override;
|
||||
uint64_t GetCompletedValue() override;
|
||||
void WaitForIdle() override;
|
||||
|
||||
CommandQueueType GetType() const override { return CommandQueueType::Direct; }
|
||||
uint64_t GetTimestampFrequency() const override { return 0; }
|
||||
|
||||
void* GetNativeHandle() override { return nullptr; }
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
29
engine/include/XCEngine/RHI/RHICommandQueue.h
Normal file
29
engine/include/XCEngine/RHI/RHICommandQueue.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "RHITypes.h"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
class RHIFence;
|
||||
|
||||
class RHICommandQueue {
|
||||
public:
|
||||
virtual ~RHICommandQueue() = default;
|
||||
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void ExecuteCommandLists(uint32_t count, void** lists) = 0;
|
||||
virtual void Signal(RHIFence* fence, uint64_t value) = 0;
|
||||
virtual void Wait(RHIFence* fence, uint64_t value) = 0;
|
||||
virtual uint64_t GetCompletedValue() = 0;
|
||||
virtual void WaitForIdle() = 0;
|
||||
|
||||
virtual CommandQueueType GetType() const = 0;
|
||||
virtual uint64_t GetTimestampFrequency() const = 0;
|
||||
|
||||
virtual void* GetNativeHandle() = 0;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
@@ -36,13 +36,17 @@ void D3D12CommandQueue::Shutdown() {
|
||||
m_commandQueue.Reset();
|
||||
}
|
||||
|
||||
void D3D12CommandQueue::ExecuteCommandLists(uint32_t count, ID3D12CommandList** lists) {
|
||||
void D3D12CommandQueue::ExecuteCommandLists(uint32_t count, void** lists) {
|
||||
ExecuteCommandListsInternal(count, reinterpret_cast<ID3D12CommandList**>(lists));
|
||||
}
|
||||
|
||||
void D3D12CommandQueue::ExecuteCommandListsInternal(uint32_t count, ID3D12CommandList** lists) {
|
||||
m_commandQueue->ExecuteCommandLists(count, lists);
|
||||
}
|
||||
|
||||
void D3D12CommandQueue::Signal(D3D12Fence* fence, uint64_t value) {
|
||||
void D3D12CommandQueue::Signal(RHIFence* fence, uint64_t value) {
|
||||
if (fence) {
|
||||
m_commandQueue->Signal(fence->GetFence(), value);
|
||||
m_commandQueue->Signal(static_cast<D3D12Fence*>(fence)->GetFence(), value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +56,9 @@ void D3D12CommandQueue::Signal(ID3D12Fence* fence, uint64_t value) {
|
||||
}
|
||||
}
|
||||
|
||||
void D3D12CommandQueue::Wait(D3D12Fence* fence, uint64_t value) {
|
||||
void D3D12CommandQueue::Wait(RHIFence* fence, uint64_t value) {
|
||||
if (fence) {
|
||||
m_commandQueue->Wait(fence->GetFence(), value);
|
||||
m_commandQueue->Wait(static_cast<D3D12Fence*>(fence)->GetFence(), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
33
engine/src/RHI/OpenGL/OpenGLCommandQueue.cpp
Normal file
33
engine/src/RHI/OpenGL/OpenGLCommandQueue.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLCommandQueue.h"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
OpenGLCommandQueue::OpenGLCommandQueue() {
|
||||
}
|
||||
|
||||
OpenGLCommandQueue::~OpenGLCommandQueue() {
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void OpenGLCommandQueue::Shutdown() {
|
||||
}
|
||||
|
||||
void OpenGLCommandQueue::ExecuteCommandLists(uint32_t count, void** lists) {
|
||||
}
|
||||
|
||||
void OpenGLCommandQueue::Signal(RHIFence* fence, uint64_t value) {
|
||||
}
|
||||
|
||||
void OpenGLCommandQueue::Wait(RHIFence* fence, uint64_t value) {
|
||||
}
|
||||
|
||||
uint64_t OpenGLCommandQueue::GetCompletedValue() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OpenGLCommandQueue::WaitForIdle() {
|
||||
}
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user