mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-22 13:45:55 +00:00
Serialise ray pipeline binding and dispatching as-is
* This does not contain patching of shader records so currently the ray dispatch is not replayed
This commit is contained in:
@@ -1133,28 +1133,170 @@ template <typename SerialiserType>
|
||||
bool WrappedID3D12GraphicsCommandList::Serialise_SetPipelineState1(SerialiserType &ser,
|
||||
_In_ ID3D12StateObject *pStateObject)
|
||||
{
|
||||
// TODO AMD
|
||||
return false;
|
||||
ID3D12GraphicsCommandList4 *pCommandList = this;
|
||||
SERIALISE_ELEMENT(pCommandList);
|
||||
SERIALISE_ELEMENT(pStateObject).Important();
|
||||
|
||||
SERIALISE_CHECK_READ_ERRORS();
|
||||
|
||||
if(IsReplayingAndReading())
|
||||
{
|
||||
if(GetWrapped(pCommandList)->GetReal4() == NULL)
|
||||
{
|
||||
SET_ERROR_RESULT(m_Cmd->m_FailedReplayResult, ResultCode::APIHardwareUnsupported,
|
||||
"Capture requires ID3D12GraphicsCommandList4 which isn't available");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_pDevice->GetOpts5().RaytracingTier == D3D12_RAYTRACING_TIER_NOT_SUPPORTED)
|
||||
{
|
||||
SET_ERROR_RESULT(m_Cmd->m_FailedReplayResult, ResultCode::APIHardwareUnsupported,
|
||||
"Capture requires ray tracing support which isn't available");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList));
|
||||
|
||||
bool stateUpdate = false;
|
||||
|
||||
if(IsActiveReplaying(m_State))
|
||||
{
|
||||
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
|
||||
{
|
||||
Unwrap4(m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID))->SetPipelineState1(Unwrap(pStateObject));
|
||||
|
||||
stateUpdate = true;
|
||||
}
|
||||
else if(!m_Cmd->IsPartialCmdList(m_Cmd->m_LastCmdListID))
|
||||
{
|
||||
stateUpdate = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Unwrap4(pCommandList)->SetPipelineState1(Unwrap(pStateObject));
|
||||
|
||||
stateUpdate = true;
|
||||
}
|
||||
|
||||
if(stateUpdate)
|
||||
{
|
||||
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
|
||||
state.pipe = ResourceId();
|
||||
state.stateobj = GetResID(pStateObject);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WrappedID3D12GraphicsCommandList::SetPipelineState1(_In_ ID3D12StateObject *pStateObject)
|
||||
{
|
||||
// TODO AMD
|
||||
RDCERR("SetPipelineState1 called but raytracing is not supported!");
|
||||
SERIALISE_TIME_CALL(m_pList4->SetPipelineState1(Unwrap(pStateObject)));
|
||||
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
CACHE_THREAD_SERIALISER();
|
||||
SCOPED_SERIALISE_CHUNK(D3D12Chunk::List_SetPipelineState1);
|
||||
Serialise_SetPipelineState1(ser, pStateObject);
|
||||
|
||||
m_ListRecord->AddChunk(scope.Get(m_ListRecord->cmdInfo->alloc));
|
||||
m_ListRecord->MarkResourceFrameReferenced(GetResID(pStateObject), eFrameRef_Read);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
bool WrappedID3D12GraphicsCommandList::Serialise_DispatchRays(SerialiserType &ser,
|
||||
_In_ const D3D12_DISPATCH_RAYS_DESC *pDesc)
|
||||
{
|
||||
// TODO AMD
|
||||
return false;
|
||||
ID3D12GraphicsCommandList4 *pCommandList = this;
|
||||
SERIALISE_ELEMENT(pCommandList);
|
||||
SERIALISE_ELEMENT_LOCAL(Desc, *pDesc).Named("pDesc").Important();
|
||||
|
||||
SERIALISE_CHECK_READ_ERRORS();
|
||||
|
||||
if(IsReplayingAndReading())
|
||||
{
|
||||
if(GetWrapped(pCommandList)->GetReal4() == NULL)
|
||||
{
|
||||
SET_ERROR_RESULT(m_Cmd->m_FailedReplayResult, ResultCode::APIHardwareUnsupported,
|
||||
"Capture requires ID3D12GraphicsCommandList4 which isn't available");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_pDevice->GetOpts5().RaytracingTier == D3D12_RAYTRACING_TIER_NOT_SUPPORTED)
|
||||
{
|
||||
SET_ERROR_RESULT(m_Cmd->m_FailedReplayResult, ResultCode::APIHardwareUnsupported,
|
||||
"Capture requires ray tracing support which isn't available");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Cmd->m_LastCmdListID = GetResourceManager()->GetOriginalID(GetResID(pCommandList));
|
||||
|
||||
if(IsActiveReplaying(m_State))
|
||||
{
|
||||
if(m_Cmd->InRerecordRange(m_Cmd->m_LastCmdListID))
|
||||
{
|
||||
ID3D12GraphicsCommandListX *list = m_Cmd->RerecordCmdList(m_Cmd->m_LastCmdListID);
|
||||
|
||||
uint32_t eventId = m_Cmd->HandlePreCallback(list, ActionFlags::DispatchRay);
|
||||
// this can't work yet as the shader records have not been patched
|
||||
// Unwrap4(list)->DispatchRays(&Desc);
|
||||
if(eventId && m_Cmd->m_ActionCallback->PostDraw(eventId, list))
|
||||
{
|
||||
// Unwrap4(list)->DispatchRays(&Desc);
|
||||
m_Cmd->m_ActionCallback->PostRedraw(eventId, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Unwrap4(pCommandList)->DispatchRays(&Desc);
|
||||
|
||||
m_Cmd->AddEvent();
|
||||
|
||||
ActionDescription action;
|
||||
action.dispatchDimension[0] = Desc.Width;
|
||||
action.dispatchDimension[1] = Desc.Height;
|
||||
action.dispatchDimension[2] = Desc.Depth;
|
||||
|
||||
action.flags |= ActionFlags::DispatchRay;
|
||||
|
||||
m_Cmd->AddAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WrappedID3D12GraphicsCommandList::DispatchRays(_In_ const D3D12_DISPATCH_RAYS_DESC *pDesc)
|
||||
{
|
||||
// TODO AMD
|
||||
RDCERR("DispatchRays called but raytracing is not supported!");
|
||||
SERIALISE_TIME_CALL(m_pList4->DispatchRays(pDesc));
|
||||
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
CACHE_THREAD_SERIALISER();
|
||||
ser.SetActionChunk();
|
||||
SCOPED_SERIALISE_CHUNK(D3D12Chunk::List_DispatchRays);
|
||||
Serialise_DispatchRays(ser, pDesc);
|
||||
|
||||
m_ListRecord->AddChunk(scope.Get(m_ListRecord->cmdInfo->alloc));
|
||||
if(pDesc->CallableShaderTable.SizeInBytes > 0)
|
||||
m_ListRecord->MarkResourceFrameReferenced(
|
||||
WrappedID3D12Resource::GetResIDFromAddr(pDesc->CallableShaderTable.StartAddress),
|
||||
eFrameRef_Read);
|
||||
if(pDesc->RayGenerationShaderRecord.SizeInBytes > 0)
|
||||
m_ListRecord->MarkResourceFrameReferenced(
|
||||
WrappedID3D12Resource::GetResIDFromAddr(pDesc->RayGenerationShaderRecord.StartAddress),
|
||||
eFrameRef_Read);
|
||||
if(pDesc->MissShaderTable.SizeInBytes > 0)
|
||||
m_ListRecord->MarkResourceFrameReferenced(
|
||||
WrappedID3D12Resource::GetResIDFromAddr(pDesc->MissShaderTable.StartAddress),
|
||||
eFrameRef_Read);
|
||||
if(pDesc->HitGroupTable.SizeInBytes > 0)
|
||||
m_ListRecord->MarkResourceFrameReferenced(
|
||||
WrappedID3D12Resource::GetResIDFromAddr(pDesc->HitGroupTable.StartAddress), eFrameRef_Read);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_FUNCTION_SERIALISED(void, WrappedID3D12GraphicsCommandList, BeginRenderPass,
|
||||
|
||||
@@ -1329,6 +1329,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_SetPipelineState(SerialiserType
|
||||
{
|
||||
D3D12RenderState &state = m_Cmd->m_BakedCmdListInfo[m_Cmd->m_LastCmdListID].state;
|
||||
state.pipe = GetResID(pPipelineState);
|
||||
state.stateobj = ResourceId();
|
||||
|
||||
if(pPipelineState)
|
||||
{
|
||||
|
||||
@@ -965,6 +965,9 @@ DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_PIPELINE_CONFIG);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_HIT_GROUP_DESC);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_RAYTRACING_PIPELINE_CONFIG1);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_EXPORT_DESC);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_GPU_VIRTUAL_ADDRESS_RANGE);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE);
|
||||
DECLARE_REFLECTION_STRUCT(D3D12_DISPATCH_RAYS_DESC);
|
||||
|
||||
DECLARE_DESERIALISE_TYPE(D3D12_DISCARD_REGION);
|
||||
DECLARE_DESERIALISE_TYPE(D3D12_GRAPHICS_PIPELINE_STATE_DESC);
|
||||
|
||||
@@ -527,6 +527,7 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
|
||||
RDCEraseEl(m_D3D12Opts1);
|
||||
RDCEraseEl(m_D3D12Opts2);
|
||||
RDCEraseEl(m_D3D12Opts3);
|
||||
RDCEraseEl(m_D3D12Opts5);
|
||||
RDCEraseEl(m_D3D12Opts6);
|
||||
RDCEraseEl(m_D3D12Opts7);
|
||||
RDCEraseEl(m_D3D12Opts9);
|
||||
@@ -596,6 +597,10 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara
|
||||
sizeof(m_D3D12Opts3));
|
||||
if(hr != S_OK)
|
||||
RDCEraseEl(m_D3D12Opts3);
|
||||
hr = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &m_D3D12Opts5,
|
||||
sizeof(m_D3D12Opts5));
|
||||
if(hr != S_OK)
|
||||
RDCEraseEl(m_D3D12Opts5);
|
||||
hr = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS6, &m_D3D12Opts6,
|
||||
sizeof(m_D3D12Opts6));
|
||||
if(hr != S_OK)
|
||||
|
||||
@@ -808,6 +808,7 @@ private:
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS1 m_D3D12Opts1;
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS2 m_D3D12Opts2;
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS3 m_D3D12Opts3;
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS5 m_D3D12Opts5;
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS6 m_D3D12Opts6;
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS7 m_D3D12Opts7;
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS9 m_D3D12Opts9;
|
||||
@@ -845,6 +846,7 @@ public:
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS1 &GetOpts1() { return m_D3D12Opts1; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS2 &GetOpts2() { return m_D3D12Opts2; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS3 &GetOpts3() { return m_D3D12Opts3; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS5 &GetOpts5() { return m_D3D12Opts5; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS6 &GetOpts6() { return m_D3D12Opts6; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS7 &GetOpts7() { return m_D3D12Opts7; }
|
||||
const D3D12_FEATURE_DATA_D3D12_OPTIONS9 &GetOpts9() { return m_D3D12Opts9; }
|
||||
|
||||
@@ -2397,6 +2397,33 @@ void Deserialise(const D3D12_EXPORT_DESC &el)
|
||||
delete[] el.ExportToRename;
|
||||
}
|
||||
|
||||
template <class SerialiserType>
|
||||
void DoSerialise(SerialiserType &ser, D3D12_GPU_VIRTUAL_ADDRESS_RANGE &el)
|
||||
{
|
||||
SERIALISE_MEMBER_TYPED(D3D12BufferLocation, StartAddress).Important();
|
||||
SERIALISE_MEMBER(SizeInBytes);
|
||||
}
|
||||
|
||||
template <class SerialiserType>
|
||||
void DoSerialise(SerialiserType &ser, D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE &el)
|
||||
{
|
||||
SERIALISE_MEMBER_TYPED(D3D12BufferLocation, StartAddress).Important();
|
||||
SERIALISE_MEMBER(SizeInBytes);
|
||||
SERIALISE_MEMBER(StrideInBytes);
|
||||
}
|
||||
|
||||
template <class SerialiserType>
|
||||
void DoSerialise(SerialiserType &ser, D3D12_DISPATCH_RAYS_DESC &el)
|
||||
{
|
||||
SERIALISE_MEMBER(RayGenerationShaderRecord);
|
||||
SERIALISE_MEMBER(MissShaderTable);
|
||||
SERIALISE_MEMBER(HitGroupTable);
|
||||
SERIALISE_MEMBER(CallableShaderTable);
|
||||
SERIALISE_MEMBER(Width).Important();
|
||||
SERIALISE_MEMBER(Height).Important();
|
||||
SERIALISE_MEMBER(Depth).Important();
|
||||
}
|
||||
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12RootSignature);
|
||||
INSTANTIATE_SERIALISE_TYPE(PortableHandle);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_CPU_DESCRIPTOR_HANDLE);
|
||||
@@ -2482,3 +2509,6 @@ INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_PIPELINE_CONFIG);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_HIT_GROUP_DESC);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_RAYTRACING_PIPELINE_CONFIG1);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_EXPORT_DESC);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_GPU_VIRTUAL_ADDRESS_RANGE);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE);
|
||||
INSTANTIATE_SERIALISE_TYPE(D3D12_DISPATCH_RAYS_DESC);
|
||||
|
||||
@@ -209,6 +209,9 @@ void D3D12RenderState::ApplyState(WrappedID3D12Device *dev, ID3D12GraphicsComman
|
||||
if(pipe != ResourceId())
|
||||
cmd->SetPipelineState(GetResourceManager()->GetCurrentAs<ID3D12PipelineState>(pipe));
|
||||
|
||||
if(stateobj != ResourceId())
|
||||
cmd->SetPipelineState1(GetResourceManager()->GetCurrentAs<ID3D12StateObject>(stateobj));
|
||||
|
||||
if(type == D3D12_COMMAND_LIST_TYPE_DIRECT || type == D3D12_COMMAND_LIST_TYPE_BUNDLE)
|
||||
{
|
||||
if(!views.empty())
|
||||
|
||||
@@ -181,6 +181,7 @@ struct D3D12RenderState
|
||||
} compute, graphics;
|
||||
|
||||
ResourceId pipe;
|
||||
ResourceId stateobj;
|
||||
|
||||
UINT viewInstMask = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user