feat: 添加CommandList常量和DSV支持,完善RenderContext

This commit is contained in:
2026-03-15 00:08:03 +08:00
parent ab29013c01
commit 15f42a1af5
12 changed files with 125 additions and 23 deletions

View File

@@ -25,6 +25,9 @@ public:
virtual void SetIndexBuffer(IResource* buffer, uint32_t offset = 0) = 0;
virtual void SetDescriptorHeap(IDescriptorHeap* heap) = 0;
virtual void SetGraphicsDescriptorTable(uint32_t rootParameterIndex, uint64_t baseDescriptor) = 0;
virtual void SetGraphicsRootConstantBufferView(uint32_t slot, IResource* buffer) = 0;
virtual void SetGraphicsRootConstantBufferViewCBV(uint32_t slot, void* nativeResource) = 0;
virtual void SetGraphicsRoot32BitConstants(uint32_t rootParameterIndex, uint32_t num32BitValues, const void* data, uint32_t destOffsetIn32BitValues) = 0;
virtual void SetComputeDescriptorTable(uint32_t rootParameterIndex, uint64_t baseDescriptor) = 0;
virtual void DrawInstanced(uint32_t vertexCountPerInstance, uint32_t instanceCount, uint32_t startVertex, uint32_t startInstance) = 0;
virtual void DrawIndexedInstanced(uint32_t indexCountPerInstance, uint32_t instanceCount, uint32_t startIndex, int32_t baseVertex, uint32_t startInstance) = 0;

View File

@@ -7,6 +7,8 @@
namespace XCEngine {
namespace RHI {
class D3D12DescriptorHeap;
class RenderContext {
public:
RenderContext(D3D12Device* device);
@@ -19,9 +21,14 @@ public:
void EndFrame();
ICommandList* GetCommandList() { return m_commandList; }
ICommandAllocator* GetCommandAllocator() { return m_commandAllocator; }
ISwapChain* GetSwapChain() { return m_swapChain; }
IRenderTarget* GetCurrentRenderTarget() { return m_currentRenderTarget; }
IDepthStencil* GetDepthStencil() { return m_depthStencil; }
IFence* GetFence() { return m_fence; }
uint64_t GetFenceValue() { return m_fenceValue; }
void IncrementFenceValue() { m_fenceValue++; }
void WaitForCompletionOfCommandList() { m_fence->Wait(m_fenceValue); }
void SetViewport(float width, float height);
void SetScissor(int32_t width, int32_t height);
@@ -37,6 +44,7 @@ private:
ISwapChain* m_swapChain = nullptr;
IRenderTarget* m_currentRenderTarget = nullptr;
IDepthStencil* m_depthStencil = nullptr;
D3D12DescriptorHeap* m_dsvHeap = nullptr;
uint64_t m_fenceValue = 0;
uint32_t m_width = 0;
uint32_t m_height = 0;

View File

@@ -7,10 +7,12 @@ namespace RHI {
class D3D12Device;
class D3D12SwapChain;
class D3D12DescriptorHeap;
class IDepthStencil : public ITexture2D {
public:
virtual ~IDepthStencil() = default;
virtual void SetDSVHeap(void* heap) = 0;
};
class IRenderTarget : public ITexture2D {