Skip to content
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
16 changes: 15 additions & 1 deletion include/Residency.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace D3D12TranslationLayer
};

// This represents a set of objects which are referenced by a command list i.e. every time a resource
// is bound for rendering, clearing, copy etc. the set must be updated to ensure the it is resident
// is bound for rendering, clearing, copy etc. the set must be updated to ensure the it is resident
// for execution.
class ResidencySet
{
Expand Down Expand Up @@ -155,6 +155,7 @@ namespace D3D12TranslationLayer
Set.clear();
}

// Walks the set to clear CommandListsUsedOn for each object; callers must ensure the resources are still valid.
void Close()
{
for (auto pObject : Set)
Expand All @@ -166,6 +167,13 @@ namespace D3D12TranslationLayer
}

private:
// Used at teardown to clear the set without walking its resources; resources may already be destroyed at this time so we don't touch them.
void Discard()
{
Set.clear();
CommandListIndex = InvalidIndex;
}

UINT32 CommandListIndex = InvalidIndex;
std::vector<ManagedObject*> Set;
};
Expand Down Expand Up @@ -373,6 +381,12 @@ namespace D3D12TranslationLayer
return PrepareToExecuteMasterSet(Queue, CommandListIndex, pMasterSet);
}

// Teardown-only path: clear the set without walking its resources.
void DiscardResidencySet(ResidencySet* pSet)
{
pSet->Discard();
}

private:
HRESULT PrepareToExecuteMasterSet(ID3D12CommandQueue* Queue, UINT CommandListIndex, ResidencySet* pMasterSet)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CommandListManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ namespace D3D12TranslationLayer
ResetCommandListTrackingData();
m_pCommandList = nullptr;

m_pResidencySet->Close();
m_pParent->GetResidencyManager().DiscardResidencySet(m_pResidencySet.get());
}

D3D12_COMMAND_LIST_TYPE CommandListManager::GetD3D12CommandListType(COMMAND_LIST_TYPE type)
Expand Down