From 0db999ac712eb8ed015f3ced940f58bdc8401b25 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 5 Mar 2018 14:33:42 +0000 Subject: [PATCH] Ensure any buffer created is at least 64 bytes * Avoids some edge-case problems. We copy the minimum of the size so we won't overwrite the bounds. --- renderdoc/driver/d3d12/d3d12_initstate.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_initstate.cpp b/renderdoc/driver/d3d12/d3d12_initstate.cpp index da256419f..77ca67614 100644 --- a/renderdoc/driver/d3d12/d3d12_initstate.cpp +++ b/renderdoc/driver/d3d12/d3d12_initstate.cpp @@ -441,7 +441,7 @@ bool D3D12ResourceManager::Serialise_InitialState(SerialiserType &ser, ResourceI desc.MipLevels = 1; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; - desc.Width = ContentsLength; + desc.Width = RDCMAX(ContentsLength, 64ULL); ID3D12Resource *copySrc = NULL; HRESULT hr = m_Device->GetReal()->CreateCommittedResource( @@ -692,7 +692,10 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, D3D12Init if(copyDst->GetDesc().Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) { - list->CopyBufferRegion(copyDst, 0, copySrc, 0, copySrc->GetDesc().Width); + D3D12_RESOURCE_DESC srcDesc = copySrc->GetDesc(); + D3D12_RESOURCE_DESC dstDesc = copyDst->GetDesc(); + + list->CopyBufferRegion(copyDst, 0, copySrc, 0, RDCMIN(srcDesc.Width, dstDesc.Width)); } else {