fix: 修复VertexBuffer/IndexBuffer SizeInBytes错误及Fence Signal类型问题

This commit is contained in:
2026-03-14 14:20:57 +08:00
parent 3ad317afb2
commit ab29013c01
3 changed files with 22 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
#include "D3D12RHI.h"
#include "D3D12Resources.h"
#include <RHI\RHIDefines.h>
#include <Rendering\Resources.h>
#include <string>
#include <windows.h>
#include <stdio.h>
@@ -717,10 +719,10 @@ void D3D12CommandList::SetPrimitiveTopology(PrimitiveTopology topology) {
void D3D12CommandList::SetVertexBuffer(uint32_t slot, IResource* buffer, uint32_t offset, uint32_t stride) {
if (buffer) {
D3D12Resource* d3dBuffer = static_cast<D3D12Resource*>(buffer);
D3D12VertexBuffer* vb = static_cast<D3D12VertexBuffer*>(buffer);
D3D12_VERTEX_BUFFER_VIEW vbView = {};
vbView.BufferLocation = d3dBuffer->GetNative()->GetGPUVirtualAddress() + offset;
vbView.SizeInBytes = (UINT)stride;
vbView.BufferLocation = vb->GetNative()->GetGPUVirtualAddress() + offset;
vbView.SizeInBytes = (UINT)vb->GetDesc().size;
vbView.StrideInBytes = stride;
m_commandList->IASetVertexBuffers(slot, 1, &vbView);
}
@@ -728,11 +730,11 @@ void D3D12CommandList::SetVertexBuffer(uint32_t slot, IResource* buffer, uint32_
void D3D12CommandList::SetIndexBuffer(IResource* buffer, uint32_t offset) {
if (buffer) {
D3D12Resource* d3dBuffer = static_cast<D3D12Resource*>(buffer);
D3D12IndexBuffer* ib = static_cast<D3D12IndexBuffer*>(buffer);
D3D12_INDEX_BUFFER_VIEW ibView = {};
ibView.BufferLocation = d3dBuffer->GetNative()->GetGPUVirtualAddress() + offset;
ibView.BufferLocation = ib->GetNative()->GetGPUVirtualAddress() + offset;
ibView.Format = DXGI_FORMAT_R32_UINT;
ibView.SizeInBytes = 0;
ibView.SizeInBytes = (UINT)ib->GetDesc().size;
m_commandList->IASetIndexBuffer(&ibView);
}
}