Serialise the AS type with its creation info

This commit is contained in:
baldurk
2024-11-14 15:55:43 +00:00
parent fd53c0f14f
commit 3a422fa92d
6 changed files with 54 additions and 36 deletions
@@ -600,6 +600,7 @@ public:
bool ProcessASBuildAfterSubmission(ResourceId asbWrappedResourceId,
D3D12BufferOffset asbWrappedResourceBufferOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type,
UINT64 byteSize, ASBuildData *buildData);
IMPLEMENT_FUNCTION_SERIALISED(
@@ -727,10 +727,9 @@ void WrappedID3D12GraphicsCommandList::ExecuteMetaCommand(
RDCERR("ExecuteMetaCommand called but no meta commands reported!");
}
bool WrappedID3D12GraphicsCommandList::ProcessASBuildAfterSubmission(ResourceId destASBId,
D3D12BufferOffset destASBOffset,
UINT64 byteSize,
ASBuildData *buildData)
bool WrappedID3D12GraphicsCommandList::ProcessASBuildAfterSubmission(
ResourceId destASBId, D3D12BufferOffset destASBOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type, UINT64 byteSize, ASBuildData *buildData)
{
D3D12ResourceManager *rm = m_pDevice->GetResourceManager();
@@ -744,7 +743,7 @@ bool WrappedID3D12GraphicsCommandList::ProcessASBuildAfterSubmission(ResourceId
//
// CreateAccStruct deletes any previous overlapping ASs on the ASB
D3D12AccelerationStructure *accStructAtDestOffset = NULL;
if(dstASB->CreateAccStruct(destASBOffset, byteSize, &accStructAtDestOffset))
if(dstASB->CreateAccStruct(destASBOffset, type, byteSize, &accStructAtDestOffset))
{
D3D12ResourceRecord *record = rm->AddResourceRecord(accStructAtDestOffset->GetResourceID());
record->type = Resource_AccelerationStructure;
@@ -755,7 +754,7 @@ bool WrappedID3D12GraphicsCommandList::ProcessASBuildAfterSubmission(ResourceId
record->AddParent(rm->GetResourceRecord(accStructAtDestOffset->GetBackingBufferResourceId()));
// register this AS so its resource can be created during replay
m_pDevice->CreateAS(dstASB, destASBOffset, byteSize, accStructAtDestOffset);
m_pDevice->CreateAS(dstASB, destASBOffset, type, byteSize, accStructAtDestOffset);
m_pDevice->AddForcedReference(record);
// in case we're currently capturing, immediately consider the AS as referenced
@@ -1196,11 +1195,13 @@ void WrappedID3D12GraphicsCommandList::BuildRaytracingAccelerationStructure(
UINT64 byteSize = preBldInfo.ResultDataMaxSizeInBytes;
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type = pDesc->Inputs.Type;
AddSubmissionASBuildCallback(
false,
[this, asbWrappedResourceId, asbWrappedResourceBufferOffset, byteSize, buildData]() {
[this, asbWrappedResourceId, asbWrappedResourceBufferOffset, type, byteSize, buildData]() {
return ProcessASBuildAfterSubmission(asbWrappedResourceId, asbWrappedResourceBufferOffset,
byteSize, buildData);
type, byteSize, buildData);
},
[buildData]() {
if(buildData)
@@ -1474,7 +1475,8 @@ void WrappedID3D12GraphicsCommandList::CopyRaytracingAccelerationStructure(
&DestAccelerationStructureData);
ASBuildData *buildData = NULL;
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type =
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL;
if(Mode == D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_DESERIALIZE)
{
RDCERR(
@@ -1505,15 +1507,16 @@ void WrappedID3D12GraphicsCommandList::CopyRaytracingAccelerationStructure(
// likely to be deleted and release its own ref)
SAFE_ADDREF(accStructAtSrcOffset->buildData);
buildData = accStructAtSrcOffset->buildData;
type = accStructAtSrcOffset->Type();
}
auto PostBldExecute = [this, destASBId, destASBOffset, sizeBuffer, buildData]() -> bool {
auto PostBldExecute = [this, destASBId, destASBOffset, type, sizeBuffer, buildData]() -> bool {
UINT64 *size = (UINT64 *)sizeBuffer->Map();
UINT64 destSize = *size;
sizeBuffer->Unmap();
sizeBuffer->Release();
return ProcessASBuildAfterSubmission(destASBId, destASBOffset, destSize, buildData);
return ProcessASBuildAfterSubmission(destASBId, destASBOffset, type, destSize, buildData);
};
AddSubmissionASBuildCallback(true, PostBldExecute, [buildData]() {
@@ -1554,9 +1557,9 @@ void WrappedID3D12GraphicsCommandList::CopyRaytracingAccelerationStructure(
// get a new refcount for this build data, it will be shared by the new copy (the old AS
// is likely to be deleted and release its own ref)
SAFE_ADDREF(accStructAtSrcOffset->buildData);
return ProcessASBuildAfterSubmission(destASBId, destASBOffset,
accStructAtSrcOffset->Size(),
accStructAtSrcOffset->buildData);
return ProcessASBuildAfterSubmission(
destASBId, destASBOffset, accStructAtSrcOffset->Type(),
accStructAtSrcOffset->Size(), accStructAtSrcOffset->buildData);
},
NULL);
}
+18 -11
View File
@@ -3931,11 +3931,13 @@ void WrappedID3D12Device::SetName(ID3D12DeviceChild *pResource, const char *Name
template <typename SerialiserType>
bool WrappedID3D12Device::Serialise_CreateAS(SerialiserType &ser, ID3D12Resource *pResource,
UINT64 resourceOffset, UINT64 byteSize,
D3D12AccelerationStructure *as)
UINT64 resourceOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type,
UINT64 byteSize, D3D12AccelerationStructure *as)
{
SERIALISE_ELEMENT(pResource);
SERIALISE_ELEMENT(resourceOffset);
SERIALISE_ELEMENT(type);
SERIALISE_ELEMENT(byteSize);
SERIALISE_ELEMENT_LOCAL(asId, as->GetResourceID());
@@ -3945,7 +3947,7 @@ bool WrappedID3D12Device::Serialise_CreateAS(SerialiserType &ser, ID3D12Resource
{
WrappedID3D12Resource *asbWrappedResource = (WrappedID3D12Resource *)pResource;
D3D12AccelerationStructure *accStructAtOffset = NULL;
if(asbWrappedResource->CreateAccStruct(resourceOffset, byteSize, &accStructAtOffset))
if(asbWrappedResource->CreateAccStruct(resourceOffset, type, byteSize, &accStructAtOffset))
{
GetResourceManager()->AddLiveResource(asId, accStructAtOffset);
@@ -3964,14 +3966,17 @@ bool WrappedID3D12Device::Serialise_CreateAS(SerialiserType &ser, ID3D12Resource
return true;
}
template bool WrappedID3D12Device::Serialise_CreateAS(ReadSerialiser &ser, ID3D12Resource *pResource,
UINT64 resourceOffset, UINT64 byteSize,
D3D12AccelerationStructure *as);
template bool WrappedID3D12Device::Serialise_CreateAS(WriteSerialiser &ser, ID3D12Resource *pResource,
UINT64 resourceOffset, UINT64 byteSize,
D3D12AccelerationStructure *as);
template bool WrappedID3D12Device::Serialise_CreateAS(
ReadSerialiser &ser, ID3D12Resource *pResource, UINT64 resourceOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type, UINT64 byteSize,
D3D12AccelerationStructure *as);
template bool WrappedID3D12Device::Serialise_CreateAS(
WriteSerialiser &ser, ID3D12Resource *pResource, UINT64 resourceOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type, UINT64 byteSize,
D3D12AccelerationStructure *as);
void WrappedID3D12Device::CreateAS(ID3D12Resource *pResource, UINT64 resourceOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type,
UINT64 byteSize, D3D12AccelerationStructure *as)
{
if(IsCaptureMode(m_State))
@@ -3983,7 +3988,7 @@ void WrappedID3D12Device::CreateAS(ID3D12Resource *pResource, UINT64 resourceOff
{
WriteSerialiser &ser = GetThreadSerialiser();
SCOPED_SERIALISE_CHUNK(D3D12Chunk::CreateAS);
Serialise_CreateAS(ser, pResource, resourceOffset, byteSize, as);
Serialise_CreateAS(ser, pResource, resourceOffset, type, byteSize, as);
record->AddChunk(scope.Get());
}
}
@@ -4777,7 +4782,9 @@ bool WrappedID3D12Device::ProcessChunk(ReadSerialiser &ser, D3D12Chunk context)
return Serialise_CreateStateObject(ser, NULL, IID(), NULL);
case D3D12Chunk::Device_AddToStateObject:
return Serialise_AddToStateObject(ser, NULL, NULL, IID(), NULL);
case D3D12Chunk::CreateAS: return Serialise_CreateAS(ser, NULL, 0, {}, NULL);
case D3D12Chunk::CreateAS:
return Serialise_CreateAS(ser, NULL, 0,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL, 0, NULL);
case D3D12Chunk::StateObject_SetPipelineStackSize:
return Serialise_SetPipelineStackSize(ser, NULL, 0);
case D3D12Chunk::Device_CreateRootSignatureFromSubobjectInLibrary:
+3 -2
View File
@@ -1334,8 +1334,9 @@ public:
const char *Path);
IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, CreateAS, ID3D12Resource *pResource,
UINT64 resourceOffset, UINT64 byteSize,
D3D12AccelerationStructure *as);
UINT64 resourceOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type,
UINT64 byteSize, D3D12AccelerationStructure *as);
// IHV APIs
IMPLEMENT_FUNCTION_SERIALISED(void, SetShaderExtUAV, GPUVendor vendor, uint32_t reg,
+9 -7
View File
@@ -141,13 +141,14 @@ ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr)
WRAPPED_POOL_INST(D3D12AccelerationStructure);
D3D12AccelerationStructure::D3D12AccelerationStructure(WrappedID3D12Device *wrappedDevice,
WrappedID3D12Resource *bufferRes,
D3D12BufferOffset bufferOffset,
UINT64 byteSize)
D3D12AccelerationStructure::D3D12AccelerationStructure(
WrappedID3D12Device *wrappedDevice, WrappedID3D12Resource *bufferRes,
D3D12BufferOffset bufferOffset, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type,
UINT64 byteSize)
: WrappedDeviceChild12(NULL, wrappedDevice),
m_asbWrappedResource(bufferRes),
m_asbWrappedResourceBufferOffset(bufferOffset),
type(type),
byteSize(byteSize)
{
}
@@ -158,8 +159,9 @@ D3D12AccelerationStructure::~D3D12AccelerationStructure()
Shutdown();
}
bool WrappedID3D12Resource::CreateAccStruct(D3D12BufferOffset bufferOffset, UINT64 byteSize,
D3D12AccelerationStructure **accStruct)
bool WrappedID3D12Resource::CreateAccStruct(D3D12BufferOffset bufferOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type,
UINT64 byteSize, D3D12AccelerationStructure **accStruct)
{
SCOPED_LOCK(m_accStructResourcesCS);
auto existing = m_accelerationStructMap.find(bufferOffset);
@@ -171,7 +173,7 @@ bool WrappedID3D12Resource::CreateAccStruct(D3D12BufferOffset bufferOffset, UINT
}
m_accelerationStructMap[bufferOffset] =
new D3D12AccelerationStructure(m_pDevice, this, bufferOffset, byteSize);
new D3D12AccelerationStructure(m_pDevice, this, bufferOffset, type, byteSize);
*accStruct = m_accelerationStructMap[bufferOffset];
+6 -2
View File
@@ -1332,7 +1332,8 @@ public:
return this->GetResourceID();
}
bool CreateAccStruct(D3D12BufferOffset bufferOffset, UINT64 byteSize,
bool CreateAccStruct(D3D12BufferOffset bufferOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type, UINT64 byteSize,
D3D12AccelerationStructure **accStruct);
bool GetAccStructIfExist(D3D12BufferOffset bufferOffset,
@@ -1665,7 +1666,8 @@ public:
ALLOCATE_WITH_WRAPPED_POOL(D3D12AccelerationStructure);
D3D12AccelerationStructure(WrappedID3D12Device *wrappedDevice, WrappedID3D12Resource *bufferRes,
D3D12BufferOffset bufferOffset, UINT64 byteSize);
D3D12BufferOffset bufferOffset,
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type, UINT64 byteSize);
~D3D12AccelerationStructure();
@@ -1675,12 +1677,14 @@ public:
{
return m_asbWrappedResource->GetGPUVirtualAddress() + m_asbWrappedResourceBufferOffset;
}
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE Type() const { return type; }
ASBuildData *buildData = NULL;
private:
WrappedID3D12Resource *m_asbWrappedResource;
D3D12BufferOffset m_asbWrappedResourceBufferOffset;
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE type;
UINT64 byteSize;
};