Skip to content

Commit

Permalink
WebGPU: fixed memory leaks in tests (close #647)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Jan 5, 2025
1 parent 951dba2 commit 8e604a9
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 Diligent Graphics LLC
* Copyright 2023-2025 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -98,6 +98,8 @@ void TestingEnvironmentWebGPU::SubmitCommandEncoder(WGPUCommandEncoder wgpuCmdEn
VERIFY_EXPR(wgpuCmdQueue != nullptr);

wgpuQueueSubmit(wgpuCmdQueue, 1, &wgpuCmdBuffer);
wgpuCommandBufferRelease(wgpuCmdBuffer);

if (WaitForIdle)
{
bool IsWorkDone = false;
Expand All @@ -108,8 +110,7 @@ void TestingEnvironmentWebGPU::SubmitCommandEncoder(WGPUCommandEncoder wgpuCmdEn
DEV_ERROR("Failed wgpuQueueOnSubmittedWorkDone: ", Status);
};

WGPUQueue wgpuQueue = wgpuDeviceGetQueue(m_wgpuDevice);
wgpuQueueOnSubmittedWorkDone(wgpuQueue, WorkDoneCallback, &IsWorkDone);
wgpuQueueOnSubmittedWorkDone(wgpuCmdQueue, WorkDoneCallback, &IsWorkDone);

while (!IsWorkDone)
{
Expand All @@ -118,6 +119,8 @@ void TestingEnvironmentWebGPU::SubmitCommandEncoder(WGPUCommandEncoder wgpuCmdEn
#endif
}
}

wgpuQueueRelease(wgpuCmdQueue);
}

GPUTestingEnvironment* CreateTestingEnvironmentWebGPU(const GPUTestingEnvironment::CreateInfo& CI,
Expand Down

0 comments on commit 8e604a9

Please sign in to comment.