diff --git a/renderdoc/driver/d3d12/d3d12_device_rescreate_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_rescreate_wrap.cpp index ba6588ea1..d4277277a 100644 --- a/renderdoc/driver/d3d12/d3d12_device_rescreate_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_rescreate_wrap.cpp @@ -248,7 +248,7 @@ bool WrappedID3D12Device::Serialise_CreateResource( SetObjName(ret, StringFormat::Fmt("%s Resource %s %s", ResourceTypeName, ToStr(desc.Dimension).c_str(), ToStr(pResource).c_str())); - ret = new WrappedID3D12Resource(ret, pHeap, HeapOffset, this); + ret = new WrappedID3D12Resource(ret, pHeap, HeapOffset, this, gpuAddress); switch(chunkType) { diff --git a/renderdoc/driver/d3d12/d3d12_replay.cpp b/renderdoc/driver/d3d12/d3d12_replay.cpp index b06195fcf..d8f11a079 100644 --- a/renderdoc/driver/d3d12/d3d12_replay.cpp +++ b/renderdoc/driver/d3d12/d3d12_replay.cpp @@ -414,6 +414,7 @@ BufferDescription D3D12Replay::GetBuffer(ResourceId id) ret.length = desc.Width; ret.creationFlags = BufferCategory::NoFlags; + ret.gpuAddress = it->second->GetOriginalVA(); const rdcarray &usage = m_pDevice->GetQueue()->GetUsage(id); diff --git a/renderdoc/driver/d3d12/d3d12_resources.h b/renderdoc/driver/d3d12/d3d12_resources.h index 9d4560f77..a828bcf5e 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.h +++ b/renderdoc/driver/d3d12/d3d12_resources.h @@ -1170,6 +1170,8 @@ class WrappedID3D12Resource rdcflatmap m_accelerationStructMap; bool m_isAccelerationStructureResource = false; + UINT64 m_OrigAddress; + public: ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D12Resource, false); @@ -1231,6 +1233,8 @@ public: m_Addresses.GetResIDFromAddrAllowOutOfBounds(addr, id, offs); } + UINT64 GetOriginalVA() const { return m_OrigAddress; } + // overload to just return the id in case the offset isn't needed static ResourceId GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr) { @@ -1248,9 +1252,10 @@ public: }; WrappedID3D12Resource(ID3D12Resource *real, ID3D12Heap *heap, UINT64 HeapOffset, - WrappedID3D12Device *device) + WrappedID3D12Device *device, UINT64 origAddress = 0) : WrappedDeviceChild12(real, device) { + m_OrigAddress = origAddress; if(IsReplayMode(device->GetState())) device->AddReplayResource(GetResourceID(), this);