Skip to content

Commit

Permalink
cleanup on-exit references deletion code
Browse files Browse the repository at this point in the history
bit more logging & extra assert for safety
  • Loading branch information
megai2 committed Aug 11, 2020
1 parent b40d7a6 commit 2e26f8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions d912pxy/d912pxy_gpu_cmd_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ d912pxy_gpu_cmd_list::~d912pxy_gpu_cmd_list()
Signal();
WaitNoCleanup();

CleanupAllReferenced();
FinalReferenceCleanup();

delete mGpuRefs;

Expand Down Expand Up @@ -142,16 +142,19 @@ void d912pxy_gpu_cmd_list::EnqueueCleanup(d912pxy_comhandler * obj)
mGpuRefs->WriteElement(obj);
}

void d912pxy_gpu_cmd_list::CleanupAllReferenced()
void d912pxy_gpu_cmd_list::FinalReferenceCleanup()
{
auto totalRefs = mGpuRefs->TotalElements();
while (mGpuRefs->HaveElements())
{
d912pxy_comhandler* obj = mGpuRefs->GetElement();
if (!obj->FinalRelease())
{
//for multithread holded objects
mGpuRefs->WriteElement(obj);
}
LOG_ASSERT(obj->FinalRelease(), "obj->FinalRelease() wrong cleanup");

if (!totalRefs && mGpuRefs->TotalElements())
LOG_WARN_DTDM("%u elements still pending in cmd list references", mGpuRefs->TotalElements());
else
--totalRefs;

mGpuRefs->Next();
}
}
Expand Down
2 changes: 1 addition & 1 deletion d912pxy/d912pxy_gpu_cmd_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class d912pxy_gpu_cmd_list :
void Signal();
void EnqueueCleanup(d912pxy_comhandler* obj);

void CleanupAllReferenced();
void FinalReferenceCleanup();
void CleanupReferenced(UINT items);

void EnableGID(d912pxy_gpu_cmd_list_group id, UINT32 prio);
Expand Down

0 comments on commit 2e26f8a

Please sign in to comment.