mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
Record a fake creation for D3D12 AS objects to create them at load time
This commit is contained in:
@@ -1063,6 +1063,10 @@ void WrappedID3D12GraphicsCommandList::BuildRaytracingAccelerationStructure(
|
||||
|
||||
record->AddParent(
|
||||
resManager->GetResourceRecord(accStructAtOffset->GetBackingBufferResourceId()));
|
||||
|
||||
// register this AS so its resource can be created during replay
|
||||
m_pDevice->CreateAS(asbWrappedResource, asbWrappedResourceBufferOffset, preBldInfo,
|
||||
accStructAtOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -985,6 +985,7 @@ bool WrappedID3D12CommandQueue::ProcessChunk(ReadSerialiser &ser, D3D12Chunk chu
|
||||
case D3D12Chunk::Device_CreateReservedResource2:
|
||||
case D3D12Chunk::Device_CreateStateObject:
|
||||
case D3D12Chunk::Device_AddToStateObject:
|
||||
case D3D12Chunk::CreateAS:
|
||||
RDCERR("Unexpected chunk while processing frame: %s", ToStr(chunk).c_str());
|
||||
return false;
|
||||
|
||||
|
||||
@@ -944,6 +944,7 @@ DECLARE_REFLECTION_STRUCT(D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_GEOMETRY_DESC);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_GEOMETRY_AABBS_DESC);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC);
|
||||
@@ -1114,5 +1115,6 @@ enum class D3D12Chunk : uint32_t
|
||||
List_EmitRaytracingAccelerationStructurePostbuildInfo,
|
||||
List_DispatchRays,
|
||||
List_SetPipelineState1,
|
||||
CreateAS,
|
||||
Max,
|
||||
};
|
||||
|
||||
@@ -3616,6 +3616,68 @@ void WrappedID3D12Device::SetName(ID3D12DeviceChild *pResource, const char *Name
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
bool WrappedID3D12Device::Serialise_CreateAS(
|
||||
SerialiserType &ser, ID3D12Resource *pResource, UINT64 resourceOffset,
|
||||
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO &preBldInfo,
|
||||
D3D12AccelerationStructure *as)
|
||||
{
|
||||
SERIALISE_ELEMENT(pResource);
|
||||
SERIALISE_ELEMENT(resourceOffset);
|
||||
SERIALISE_ELEMENT(preBldInfo);
|
||||
SERIALISE_ELEMENT_LOCAL(asId, as->GetResourceID());
|
||||
|
||||
SERIALISE_CHECK_READ_ERRORS();
|
||||
|
||||
if(IsReplayingAndReading() && pResource)
|
||||
{
|
||||
WrappedID3D12Resource *asbWrappedResource = (WrappedID3D12Resource *)pResource;
|
||||
D3D12AccelerationStructure *accStructAtOffset = NULL;
|
||||
if(asbWrappedResource->CreateAccStruct(resourceOffset, preBldInfo, &accStructAtOffset))
|
||||
{
|
||||
GetResourceManager()->AddLiveResource(asId, accStructAtOffset);
|
||||
|
||||
AddResource(asId, ResourceType::AccelerationStructure, "Acceleration Structure");
|
||||
// ignored if there's no heap
|
||||
DerivedResource(pResource, asId);
|
||||
}
|
||||
else
|
||||
{
|
||||
SET_ERROR_RESULT(m_FailedReplayResult, ResultCode::APIReplayFailed,
|
||||
"Couldn't recreate acceleration structure object");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template bool WrappedID3D12Device::Serialise_CreateAS(
|
||||
ReadSerialiser &ser, ID3D12Resource *pResource, UINT64 resourceOffset,
|
||||
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO &preBldInfo,
|
||||
D3D12AccelerationStructure *as);
|
||||
template bool WrappedID3D12Device::Serialise_CreateAS(
|
||||
WriteSerialiser &ser, ID3D12Resource *pResource, UINT64 resourceOffset,
|
||||
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO &preBldInfo,
|
||||
D3D12AccelerationStructure *as);
|
||||
|
||||
void WrappedID3D12Device::CreateAS(ID3D12Resource *pResource, UINT64 resourceOffset,
|
||||
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO &preBldInfo,
|
||||
D3D12AccelerationStructure *as)
|
||||
{
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
D3D12ResourceRecord *record = as->GetResourceRecord();
|
||||
|
||||
{
|
||||
WriteSerialiser &ser = GetThreadSerialiser();
|
||||
SCOPED_SERIALISE_CHUNK(D3D12Chunk::CreateAS);
|
||||
Serialise_CreateAS(ser, pResource, resourceOffset, preBldInfo, as);
|
||||
record->AddChunk(scope.Get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
bool WrappedID3D12Device::Serialise_SetShaderExtUAV(SerialiserType &ser, GPUVendor vendor,
|
||||
uint32_t reg, uint32_t space, bool global)
|
||||
@@ -4346,6 +4408,7 @@ 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);
|
||||
|
||||
// in order to get a warning if we miss a case, we explicitly handle the list/queue chunks here.
|
||||
// If we actually encounter one it's an error (we should hit CaptureBegin first and switch to
|
||||
|
||||
@@ -81,6 +81,7 @@ struct QueueReadbackData
|
||||
class WrappedID3D12Device;
|
||||
class WrappedID3D12Resource;
|
||||
class WrappedID3D12PipelineState;
|
||||
class D3D12AccelerationStructure;
|
||||
|
||||
class D3D12Replay;
|
||||
class D3D12TextRenderer;
|
||||
@@ -1251,6 +1252,11 @@ public:
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(HRESULT, SetShaderDebugPath, ID3D12DeviceChild *pResource,
|
||||
const char *Path);
|
||||
|
||||
IMPLEMENT_FUNCTION_THREAD_SERIALISED(
|
||||
void, CreateAS, ID3D12Resource *pResource, UINT64 resourceOffset,
|
||||
const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO &preBldInfo,
|
||||
D3D12AccelerationStructure *as);
|
||||
|
||||
// IHV APIs
|
||||
IMPLEMENT_FUNCTION_SERIALISED(void, SetShaderExtUAV, GPUVendor vendor, uint32_t reg,
|
||||
uint32_t space, bool global);
|
||||
|
||||
@@ -276,7 +276,7 @@ bool WrappedID3D12Device::Serialise_CreateResource(
|
||||
type = ResourceType::Buffer;
|
||||
if(InitialLayout.ToStates() == D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE)
|
||||
{
|
||||
prefix = "Acceleration Structure";
|
||||
prefix = "AS Buffer";
|
||||
((WrappedID3D12Resource *)ret)->MarkAsAccelerationStructureResource();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1965,6 +1965,14 @@ void DoSerialise(SerialiserType &ser, D3D12_RAYTRACING_GEOMETRY_AABBS_DESC &el)
|
||||
SERIALISE_MEMBER(AABBs);
|
||||
}
|
||||
|
||||
template <class SerialiserType>
|
||||
void DoSerialise(SerialiserType &ser, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO &el)
|
||||
{
|
||||
SERIALISE_MEMBER(ResultDataMaxSizeInBytes);
|
||||
SERIALISE_MEMBER(ScratchDataSizeInBytes);
|
||||
SERIALISE_MEMBER(UpdateScratchDataSizeInBytes);
|
||||
}
|
||||
|
||||
template <class SerialiserType>
|
||||
void DoSerialise(SerialiserType &ser, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC &el)
|
||||
{
|
||||
@@ -2456,6 +2464,7 @@ INSTANTIATE_SERIALISE_TYPE(D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS)
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_GEOMETRY_DESC);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_GEOMETRY_AABBS_DESC);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_SRV);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
template <>
|
||||
rdcstr DoStringise(const D3D12Chunk &el)
|
||||
{
|
||||
RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1131, "Chunks changed without updating names");
|
||||
RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1132, "Chunks changed without updating names");
|
||||
|
||||
BEGIN_ENUM_STRINGISE(D3D12Chunk)
|
||||
{
|
||||
@@ -233,6 +233,7 @@ rdcstr DoStringise(const D3D12Chunk &el)
|
||||
STRINGISE_ENUM_CLASS_NAMED(List_DispatchRays, "ID3D12GraphicsCommandList4::DispatchRays");
|
||||
STRINGISE_ENUM_CLASS_NAMED(List_SetPipelineState1,
|
||||
"ID3D12GraphicsCommandList4::SetPipelineState1");
|
||||
STRINGISE_ENUM_CLASS_NAMED(CreateAS, "Internal::Acceleration Structure Create");
|
||||
STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk");
|
||||
}
|
||||
END_ENUM_STRINGISE()
|
||||
@@ -276,6 +277,7 @@ rdcstr DoStringise(const D3D12ResourceType &el)
|
||||
STRINGISE_ENUM_NAMED(Resource_RootSignature, "Root Signature");
|
||||
STRINGISE_ENUM_NAMED(Resource_PipelineLibrary, "Pipeline Library");
|
||||
STRINGISE_ENUM_NAMED(Resource_ProtectedResourceSession, "Protected Resource Session");
|
||||
STRINGISE_ENUM_NAMED(Resource_AccelerationStructure, "Acceleration Structure");
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
@@ -1654,4 +1656,4 @@ rdcstr DoStringise(const D3D12_STATE_OBJECT_TYPE &el)
|
||||
STRINGISE_ENUM(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE);
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user