mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 21:40:41 +00:00
Allow out of bounds GPU addresses when serialising
* Worst case this is just as invalid as an application, if it uses a totally bogus VA. However in D3D12 it is apparently valid to refer to VAs out of bounds of any resource as long as it's within bounds of an underlying heap. To handle this without serialising VAs as Heap+offset we instead just allow the address lookup to run out of bounds and pick the next lowest buffer. If the offset is greater than the buffer size then we're probably no worse than the application.
This commit is contained in:
@@ -1037,3 +1037,32 @@ void GPUAddressRangeTracker::GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr, Re
|
||||
id = range.id;
|
||||
offs = addr - range.start;
|
||||
}
|
||||
|
||||
void GPUAddressRangeTracker::GetResIDFromAddrAllowOutOfBounds(D3D12_GPU_VIRTUAL_ADDRESS addr,
|
||||
ResourceId &id, UINT64 &offs)
|
||||
{
|
||||
id = ResourceId();
|
||||
offs = 0;
|
||||
|
||||
if(addr == 0)
|
||||
return;
|
||||
|
||||
GPUAddressRange range;
|
||||
|
||||
// this should really be a read-write lock
|
||||
{
|
||||
SCOPED_READLOCK(addressLock);
|
||||
|
||||
auto it = std::lower_bound(addresses.begin(), addresses.end(), addr);
|
||||
if(it == addresses.end())
|
||||
return;
|
||||
|
||||
range = *it;
|
||||
}
|
||||
|
||||
if(addr < range.start)
|
||||
return;
|
||||
|
||||
id = range.id;
|
||||
offs = addr - range.start;
|
||||
}
|
||||
|
||||
@@ -529,6 +529,7 @@ struct GPUAddressRangeTracker
|
||||
void AddTo(const GPUAddressRange &range);
|
||||
void RemoveFrom(const GPUAddressRange &range);
|
||||
void GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr, ResourceId &id, UINT64 &offs);
|
||||
void GetResIDFromAddrAllowOutOfBounds(D3D12_GPU_VIRTUAL_ADDRESS addr, ResourceId &id, UINT64 &offs);
|
||||
};
|
||||
|
||||
struct MapState
|
||||
|
||||
@@ -969,6 +969,12 @@ public:
|
||||
m_Addresses.GetResIDFromAddr(addr, id, offs);
|
||||
}
|
||||
|
||||
static void GetResIDFromAddrAllowOutOfBounds(D3D12_GPU_VIRTUAL_ADDRESS addr, ResourceId &id,
|
||||
UINT64 &offs)
|
||||
{
|
||||
m_Addresses.GetResIDFromAddrAllowOutOfBounds(addr, id, offs);
|
||||
}
|
||||
|
||||
// overload to just return the id in case the offset isn't needed
|
||||
static ResourceId GetResIDFromAddr(D3D12_GPU_VIRTUAL_ADDRESS addr)
|
||||
{
|
||||
|
||||
@@ -334,7 +334,7 @@ void DoSerialise(SerialiserType &ser, D3D12BufferLocation &el)
|
||||
UINT64 offs = 0;
|
||||
|
||||
if(ser.IsWriting() || ser.IsStructurising())
|
||||
WrappedID3D12Resource::GetResIDFromAddr(el.Location, buffer, offs);
|
||||
WrappedID3D12Resource::GetResIDFromAddrAllowOutOfBounds(el.Location, buffer, offs);
|
||||
if(ser.IsStructurising() && rm)
|
||||
buffer = rm->GetOriginalID(buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user