Skip to content

Commit b1a43bf

Browse files
committed
Add proper cleanup of DDI Driver Tables
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent aa7e72d commit b1a43bf

13 files changed

+128
-501
lines changed

scripts/templates/ldrddi.cpp.mako

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ namespace loader
183183
}
184184
%endif
185185
%endfor
186+
187+
///////////////////////////////////////////////////////////////////////////////
188+
/// @brief function for removing the ddi driver tables for ${n}
189+
__${x}dlllocal void ${X}_APICALL
190+
${n}DestroyDDiDriverTables(${n}_dditable_driver_t* pDdiTable)
191+
{
192+
// Delete ddi tables
193+
%for tbl in th.get_pfntables(specs, meta, n, tags):
194+
delete pDdiTable->${tbl['name']};
195+
%endfor
196+
delete pDdiTable;
197+
}
198+
186199
} // namespace loader
187200

188201
#if defined(__cplusplus)

scripts/templates/ldrddi.h.mako

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ namespace loader
3232

3333
%endif
3434
%endfor
35+
__${x}dlllocal void ${X}_APICALL
36+
${n}DestroyDDiDriverTables(${n}_dditable_driver_t* pDdiTable);
3537
}
3638

3739
#if defined(__cplusplus)

scripts/templates/ldrddi_legacy.cpp.mako

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,6 @@ extern "C" {
314314
%for tbl in th.get_pfntables(specs, meta, n, tags):
315315
///////////////////////////////////////////////////////////////////////////////
316316
/// @brief function for filling the legacy api pointers for ${tbl['name']} table
317-
/// with current process' addresses
318-
///
319-
/// @returns
320-
/// - ::${X}_RESULT_SUCCESS
321-
/// - ::${X}_RESULT_ERROR_UNINITIALIZED
322-
/// - ::${X}_RESULT_ERROR_INVALID_NULL_POINTER
323-
/// - ::${X}_RESULT_ERROR_UNSUPPORTED_VERSION
324317
__${x}dlllocal void ${X}_APICALL
325318
${tbl['export']['name']}Legacy()
326319
{

source/loader/ze_ldrddi.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4837,6 +4837,44 @@ namespace loader
48374837
return result;
48384838
}
48394839

4840+
4841+
///////////////////////////////////////////////////////////////////////////////
4842+
/// @brief function for removing the ddi driver tables for ze
4843+
__zedlllocal void ZE_APICALL
4844+
zeDestroyDDiDriverTables(ze_dditable_driver_t* pDdiTable)
4845+
{
4846+
// Delete ddi tables
4847+
delete pDdiTable->Global;
4848+
delete pDdiTable->RTASBuilderExp;
4849+
delete pDdiTable->RTASParallelOperationExp;
4850+
delete pDdiTable->Driver;
4851+
delete pDdiTable->DriverExp;
4852+
delete pDdiTable->Device;
4853+
delete pDdiTable->DeviceExp;
4854+
delete pDdiTable->Context;
4855+
delete pDdiTable->CommandQueue;
4856+
delete pDdiTable->CommandList;
4857+
delete pDdiTable->CommandListExp;
4858+
delete pDdiTable->Event;
4859+
delete pDdiTable->EventExp;
4860+
delete pDdiTable->EventPool;
4861+
delete pDdiTable->Fence;
4862+
delete pDdiTable->Image;
4863+
delete pDdiTable->ImageExp;
4864+
delete pDdiTable->Kernel;
4865+
delete pDdiTable->KernelExp;
4866+
delete pDdiTable->Mem;
4867+
delete pDdiTable->MemExp;
4868+
delete pDdiTable->Module;
4869+
delete pDdiTable->ModuleBuildLog;
4870+
delete pDdiTable->PhysicalMem;
4871+
delete pDdiTable->Sampler;
4872+
delete pDdiTable->VirtualMem;
4873+
delete pDdiTable->FabricEdgeExp;
4874+
delete pDdiTable->FabricVertexExp;
4875+
delete pDdiTable;
4876+
}
4877+
48404878
} // namespace loader
48414879

48424880
#if defined(__cplusplus)

source/loader/ze_ldrddi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ namespace loader
6969
using ze_rtas_parallel_operation_exp_object_t = object_t < ze_rtas_parallel_operation_exp_handle_t >;
7070
using ze_rtas_parallel_operation_exp_factory_t = singleton_factory_t < ze_rtas_parallel_operation_exp_object_t, ze_rtas_parallel_operation_exp_handle_t >;
7171

72+
__zedlllocal void ZE_APICALL
73+
zeDestroyDDiDriverTables(ze_dditable_driver_t* pDdiTable);
7274
}
7375

7476
#if defined(__cplusplus)

0 commit comments

Comments
 (0)