RHI: Fix view type signatures in CommandList abstraction

- Unified RHICommandList interface to use RHIResourceView* for all view types
- Fixed OpenGLCommandList override signatures (SetVertexBuffers, SetIndexBuffer, etc.)
- Fixed D3D12CommandList by removing duplicate SetVertexBuffer methods
- Updated OpenGLCommandList.cpp to match new signatures
- Build and all 845 tests pass
This commit is contained in:
2026-03-24 23:41:57 +08:00
parent 7a66913f2b
commit 1e88beacb8
10 changed files with 505 additions and 44 deletions

View File

@@ -369,29 +369,6 @@ void D3D12CommandList::SetRenderTargetsHandle(uint32_t count, const D3D12_CPU_DE
}
}
void D3D12CommandList::SetVertexBuffer(uint32_t slot, RHIResourceView* buffer, uint64_t offset) {
if (!buffer || !buffer->IsValid()) return;
D3D12ResourceView* view = static_cast<D3D12ResourceView*>(buffer);
D3D12_VERTEX_BUFFER_VIEW vbView = {};
vbView.BufferLocation = view->GetResource()->GetGPUVirtualAddress() + offset;
vbView.SizeInBytes = static_cast<UINT>(view->GetResource()->GetDesc().Width) - static_cast<UINT>(offset);
vbView.StrideInBytes = 0;
m_commandList->IASetVertexBuffers(slot, 1, &vbView);
}
void D3D12CommandList::SetVertexBuffer(uint32_t slot, ID3D12Resource* buffer, uint64_t offset, uint32_t stride) {
SetVertexBufferInternal(slot, buffer, offset, stride);
}
void D3D12CommandList::SetVertexBufferInternal(uint32_t slot, ID3D12Resource* buffer, uint64_t offset, uint32_t stride) {
D3D12_VERTEX_BUFFER_VIEW view = {};
view.BufferLocation = buffer->GetGPUVirtualAddress() + offset;
view.SizeInBytes = static_cast<UINT>(buffer->GetDesc().Width) - static_cast<UINT>(offset);
view.StrideInBytes = stride;
m_commandList->IASetVertexBuffers(slot, 1, &view);
}
void D3D12CommandList::SetVertexBuffers(uint32_t startSlot, uint32_t count, RHIResourceView** buffers, const uint64_t* offsets, const uint32_t* strides) {
std::vector<D3D12_VERTEX_BUFFER_VIEW> views(count);
for (uint32_t i = 0; i < count; ++i) {

View File

@@ -609,17 +609,6 @@ void OpenGLCommandList::SetPipelineState(RHIPipelineState* pipelineState) {
}
}
void OpenGLCommandList::SetVertexBuffer(uint32_t slot, RHIResourceView* buffer, uint64_t offset) {
if (!buffer) return;
OpenGLResourceView* view = static_cast<OpenGLResourceView*>(buffer);
if (!view->IsValid()) return;
GLuint glBuffer = view->GetBuffer();
glBindBuffer(GL_ARRAY_BUFFER, glBuffer);
glVertexAttribPointer(slot, 4, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<void*>(static_cast<uintptr_t>(offset)));
glEnableVertexAttribArray(slot);
}
void OpenGLCommandList::SetVertexBuffers(uint32_t startSlot, uint32_t count, RHIResourceView** buffers, const uint64_t* offsets, const uint32_t* strides) {
for (uint32_t i = 0; i < count; i++) {
if (!buffers[i]) continue;