Implement complex version of CopyDescriptors

This commit is contained in:
baldurk
2016-07-31 13:57:30 +07:00
parent 041018db69
commit 6ca41cc681
3 changed files with 48 additions and 10 deletions
+35 -10
View File
@@ -847,6 +847,40 @@ void WrappedID3D12Device::CopyDescriptors(
RDCUNIMPLEMENTED("CopyDescriptors does not copy our internal descriptor data");
UINT srcRange = 0, dstRange = 0;
UINT srcIdx = 0, dstIdx = 0;
D3D12Descriptor *src = GetWrapped(pSrcDescriptorRangeStarts[0]);
D3D12Descriptor *dst = GetWrapped(pDestDescriptorRangeStarts[0]);
for(; srcRange < NumSrcDescriptorRanges && dstRange < NumDestDescriptorRanges;)
{
dst[dstIdx].CopyFrom(src[srcIdx]);
srcIdx++;
dstIdx++;
// move source onto the next range
if(srcIdx >= pSrcDescriptorRangeSizes[srcRange])
{
srcRange++;
srcIdx = 0;
// check srcRange is valid - we might be about to exit the loop from reading off the end
if(srcRange < NumSrcDescriptorRanges)
src = GetWrapped(pSrcDescriptorRangeStarts[srcRange]);
}
if(dstIdx >= pDestDescriptorRangeSizes[srcRange])
{
dstRange++;
dstIdx = 0;
if(dstRange < NumDestDescriptorRanges)
dst = GetWrapped(pDestDescriptorRangeStarts[srcRange]);
}
}
SAFE_DELETE_ARRAY(dstStarts);
SAFE_DELETE_ARRAY(srcStarts);
}
@@ -863,16 +897,7 @@ void WrappedID3D12Device::CopyDescriptorsSimple(UINT NumDescriptors,
D3D12Descriptor *dst = GetWrapped(DestDescriptorRangeStart);
for(UINT i = 0; i < NumDescriptors; i++)
{
// save these so we can do a straight copy then restore them
WrappedID3D12DescriptorHeap *heap = dst[i].samp.heap;
uint32_t index = dst[i].samp.idx;
dst[i] = src[i];
dst[i].samp.heap = heap;
dst[i].samp.idx = index;
}
dst[i].CopyFrom(src[i]);
}
HRESULT WrappedID3D12Device::OpenSharedHandle(HANDLE NTHandle, REFIID riid, void **ppvObj)
+12
View File
@@ -145,6 +145,18 @@ void D3D12Descriptor::Create(ID3D12Device *dev, D3D12_CPU_DESCRIPTOR_HANDLE hand
}
}
void D3D12Descriptor::CopyFrom(const D3D12Descriptor &src)
{
// save these so we can do a straight copy then restore them
WrappedID3D12DescriptorHeap *heap = samp.heap;
uint32_t index = samp.idx;
*this = src;
samp.heap = heap;
samp.idx = index;
}
D3D12_CPU_DESCRIPTOR_HANDLE Unwrap(D3D12_CPU_DESCRIPTOR_HANDLE handle)
{
if(handle.ptr == 0)
+1
View File
@@ -149,6 +149,7 @@ struct D3D12Descriptor
void Init(ID3D12Resource *pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc);
void Create(ID3D12Device *dev, D3D12_CPU_DESCRIPTOR_HANDLE handle);
void CopyFrom(const D3D12Descriptor &src);
union
{