【关键节点】RHICommandList添加RHIResourceView*方法重载实现统一资源绑定接口

- 在RHICommandList.h中添加7个RHIResourceView*方法重载:
  - TransitionBarrier(RHIResourceView*, ...)
  - SetRenderTargets(count, RHIResourceView**, RHIResourceView*)
  - SetVertexBuffer(slot, RHIResourceView*, ...)
  - SetIndexBuffer(RHIResourceView*, ...)
  - ClearRenderTarget(RHIResourceView*, ...)
  - ClearDepthStencil(RHIResourceView*, ...)
  - CopyResource(RHIResourceView*, RHIResourceView*)

- D3D12CommandList完整实现:
  - 通过D3D12ResourceView::GetResource()获取底层资源
  - 通过D3D12ResourceView::GetCPUHandle()获取RTV/DSV句柄

- OpenGLCommandList添加stub实现保持接口一致

- 验证: 144个单元测试全部通过, 4个D3D12集成测试全部通过
This commit is contained in:
2026-03-24 05:11:47 +08:00
parent eb4840eac4
commit e2050e35ec
5 changed files with 108 additions and 0 deletions

View File

@@ -432,6 +432,9 @@ void OpenGLCommandList::Close() {
void OpenGLCommandList::TransitionBarrier(void* resource, ResourceStates stateBefore, ResourceStates stateAfter) {
}
void OpenGLCommandList::TransitionBarrier(RHIResourceView* resource, ResourceStates stateBefore, ResourceStates stateAfter) {
}
void OpenGLCommandList::SetViewport(const Viewport& viewport) {
glViewport(static_cast<int>(viewport.topLeftX), static_cast<int>(viewport.topLeftY),
static_cast<int>(viewport.width), static_cast<int>(viewport.height));
@@ -468,16 +471,25 @@ void OpenGLCommandList::SetScissorRects(uint32_t count, const Rect* rects) {
void OpenGLCommandList::SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil) {
}
void OpenGLCommandList::SetRenderTargets(uint32_t count, RHIResourceView** renderTargets, RHIResourceView* depthStencil) {
}
void OpenGLCommandList::ClearRenderTarget(void* renderTarget, const float color[4]) {
glClearColor(color[0], color[1], color[2], color[3]);
glClear(GL_COLOR_BUFFER_BIT);
}
void OpenGLCommandList::ClearRenderTarget(RHIResourceView* renderTarget, const float color[4]) {
}
void OpenGLCommandList::ClearDepthStencil(void* depthStencil, float depth, uint8_t stencil) {
glClearDepth(depth);
glClear(GL_DEPTH_BUFFER_BIT);
}
void OpenGLCommandList::ClearDepthStencil(RHIResourceView* depthStencil, float depth, uint8_t stencil) {
}
void OpenGLCommandList::SetPipelineState(void* pipelineState) {
if (pipelineState) {
UseShader(reinterpret_cast<uintptr_t>(pipelineState));
@@ -491,6 +503,9 @@ void OpenGLCommandList::SetVertexBuffer(uint32_t slot, void* buffer, uint64_t of
glEnableVertexAttribArray(slot);
}
void OpenGLCommandList::SetVertexBuffer(uint32_t slot, RHIResourceView* buffer, uint64_t offset, uint32_t stride) {
}
void OpenGLCommandList::SetVertexBuffers(uint32_t startSlot, uint32_t count, const uint64_t* buffers, const uint64_t* offsets, const uint32_t* strides) {
for (uint32_t i = 0; i < count; i++) {
GLuint glBuffer = static_cast<GLuint>(buffers[i]);
@@ -508,9 +523,15 @@ void OpenGLCommandList::SetIndexBuffer(void* buffer, uint64_t offset, Format for
(void)format;
}
void OpenGLCommandList::SetIndexBuffer(RHIResourceView* buffer, uint64_t offset, Format format) {
}
void OpenGLCommandList::CopyResource(void* dst, void* src) {
}
void OpenGLCommandList::CopyResource(RHIResourceView* dst, RHIResourceView* src) {
}
void OpenGLCommandList::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t startVertex, uint32_t startInstance) {
glDrawArraysInstanced(GL_TRIANGLES, static_cast<GLint>(startVertex), static_cast<GLsizei>(vertexCount), static_cast<GLsizei>(instanceCount));
}