Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear CachedPSO data for CreatePipelineState replay #1848

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions framework/decode/dx12_replay_consumer_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3580,6 +3580,39 @@ HRESULT Dx12ReplayConsumerBase::OverrideCreateComputePipelineState(
return replay_result;
}

HRESULT Dx12ReplayConsumerBase::OverrideCreatePipelineState(
DxObjectInfo* device_object_info,
HRESULT original_result,
StructPointerDecoder<Decoded_D3D12_PIPELINE_STATE_STREAM_DESC>* pDesc,
Decoded_GUID riid,
HandlePointerDecoder<void*>* ppPipelineState)
{
GFXRECON_UNREFERENCED_PARAMETER(original_result);

GFXRECON_ASSERT(device_object_info != nullptr);
GFXRECON_ASSERT(device_object_info->object != nullptr);

auto device = static_cast<ID3D12Device2*>(device_object_info->object);

auto pDesc2 = pDesc->GetPointer();
if (!options_.use_cached_psos)
{
auto desc = pDesc->GetMetaStructPointer();
GFXRECON_ASSERT(desc != nullptr);

if (desc->cached_pso.decoded_value != nullptr)
{
desc->cached_pso.decoded_value->pCachedBlob = nullptr;
desc->cached_pso.decoded_value->CachedBlobSizeInBytes = 0;
}
}

HRESULT replay_result =
device->CreatePipelineState(pDesc2, *riid.decoded_value, ppPipelineState->GetHandlePointer());

return replay_result;
}

HRESULT
Dx12ReplayConsumerBase::OverrideSetFullscreenState(DxObjectInfo* swapchain_info,
HRESULT original_result,
Expand Down
6 changes: 6 additions & 0 deletions framework/decode/dx12_replay_consumer_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,12 @@ class Dx12ReplayConsumerBase : public Dx12Consumer
Decoded_GUID riid,
HandlePointerDecoder<void*>* pipelineState);

HRESULT OverrideCreatePipelineState(DxObjectInfo* device_object_info,
HRESULT original_result,
StructPointerDecoder<Decoded_D3D12_PIPELINE_STATE_STREAM_DESC>* pDesc,
Decoded_GUID riid,
HandlePointerDecoder<void*>* ppPipelineState);

HRESULT OverrideSetFullscreenState(DxObjectInfo* swapchain_info,
HRESULT original_result,
BOOL Fullscreen,
Expand Down
3 changes: 3 additions & 0 deletions framework/generated/dx12_generators/replay_overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"ID3D12Device1": {
"CreatePipelineLibrary": "OverrideCreatePipelineLibrary"
},
"ID3D12Device2": {
"CreatePipelineState": "OverrideCreatePipelineState"
},
"ID3D12Device3": {
"EnqueueMakeResident": "OverrideEnqueueMakeResident",
"OpenExistingHeapFromAddress": "OverrideOpenExistingHeapFromAddress"
Expand Down
14 changes: 8 additions & 6 deletions framework/generated/generated_dx12_replay_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10214,14 +10214,16 @@ void Dx12ReplayConsumer::Process_ID3D12Device2_CreatePipelineState(
ppPipelineState);
MapStructObjects(pDesc->GetMetaStructPointer(), GetObjectInfoTable(), GetGpuVaTable());
if(!ppPipelineState->IsNull()) ppPipelineState->SetHandleLength(1);
auto out_p_ppPipelineState = ppPipelineState->GetPointer();
auto out_hp_ppPipelineState = ppPipelineState->GetHandlePointer();
auto replay_result = reinterpret_cast<ID3D12Device2*>(replay_object->object)->CreatePipelineState(pDesc->GetPointer(),
*riid.decoded_value,
out_hp_ppPipelineState);
DxObjectInfo object_info_ppPipelineState{};
ppPipelineState->SetConsumerData(0, &object_info_ppPipelineState);
auto replay_result = OverrideCreatePipelineState(replay_object,
return_value,
pDesc,
riid,
ppPipelineState);
if (SUCCEEDED(replay_result))
{
AddObject(out_p_ppPipelineState, out_hp_ppPipelineState, format::ApiCall_ID3D12Device2_CreatePipelineState);
AddObject(ppPipelineState->GetPointer(), ppPipelineState->GetHandlePointer(), std::move(object_info_ppPipelineState), format::ApiCall_ID3D12Device2_CreatePipelineState);
}
CheckReplayResult("ID3D12Device2_CreatePipelineState", return_value, replay_result);
CustomReplayPostCall<format::ApiCallId::ApiCall_ID3D12Device2_CreatePipelineState>::Dispatch(
Expand Down
Loading