Skip to content

Commit

Permalink
feat: add default load/unload extension functions in core
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Apr 16, 2024
1 parent 5c271b2 commit 30b9c0e
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 21 deletions.
15 changes: 8 additions & 7 deletions apps/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,14 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)

// load extensions
const plExtensionRegistryI* ptExtensionRegistry = ptApiRegistry->first(PL_API_EXTENSION_REGISTRY);
ptExtensionRegistry->load("pl_image_ext", "pl_load_image_ext", "pl_unload_image_ext", false);
ptExtensionRegistry->load("pl_stats_ext", "pl_load_stats_ext", "pl_unload_stats_ext", false);
ptExtensionRegistry->load("pl_graphics_ext", "pl_load_graphics_ext", "pl_unload_graphics_ext", false);
ptExtensionRegistry->load("pl_debug_ext", "pl_load_debug_ext", "pl_unload_debug_ext", true);
ptExtensionRegistry->load("pl_ecs_ext", "pl_load_ecs_ext", "pl_unload_ecs_ext", false);
ptExtensionRegistry->load("pl_resource_ext", "pl_load_resource_ext", "pl_unload_resource_ext", false);
ptExtensionRegistry->load("pl_ref_renderer_ext", "pl_load_ext", "pl_unload_ext", true);
ptExtensionRegistry->load("pl_image_ext", NULL, NULL, false);
ptExtensionRegistry->load("pl_stats_ext", NULL, NULL, false);
ptExtensionRegistry->load("pl_graphics_ext", NULL, NULL, false);
ptExtensionRegistry->load("pl_gpu_allocators_ext", NULL, NULL, false);
ptExtensionRegistry->load("pl_debug_ext", NULL, NULL, true);
ptExtensionRegistry->load("pl_ecs_ext", NULL, NULL, false);
ptExtensionRegistry->load("pl_resource_ext", NULL, NULL, false);
ptExtensionRegistry->load("pl_ref_renderer_ext", NULL, NULL, true);

// load apis
gptWindows = ptApiRegistry->first(PL_API_WINDOW);
Expand Down
4 changes: 2 additions & 2 deletions extensions/pl_debug_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ pl__show_logging(bool* bValue)
//-----------------------------------------------------------------------------

PL_EXPORT void
pl_load_debug_ext(plApiRegistryI* ptApiRegistry, bool bReload)
pl_load_ext(plApiRegistryI* ptApiRegistry, bool bReload)
{
gptApiRegistry = ptApiRegistry;
ptDataRegistry = ptApiRegistry->first(PL_API_DATA_REGISTRY);
Expand All @@ -1085,7 +1085,7 @@ pl_load_debug_ext(plApiRegistryI* ptApiRegistry, bool bReload)
}

PL_EXPORT void
pl_unload_debug_ext(plApiRegistryI* ptApiRegistry)
pl_unload_ext(plApiRegistryI* ptApiRegistry)
{
pl_sb_free(sbppdValues);
pl_sb_free(sbppdFrameValues);
Expand Down
4 changes: 2 additions & 2 deletions extensions/pl_ecs_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ pl_calculate_tangents(plMeshComponent* atMeshes, uint32_t uComponentCount)
//-----------------------------------------------------------------------------

PL_EXPORT void
pl_load_ecs_ext(plApiRegistryI* ptApiRegistry, bool bReload)
pl_load_ext(plApiRegistryI* ptApiRegistry, bool bReload)
{
const plDataRegistryI* ptDataRegistry = ptApiRegistry->first(PL_API_DATA_REGISTRY);
pl_set_memory_context(ptDataRegistry->get_data(PL_CONTEXT_MEMORY));
Expand Down Expand Up @@ -1511,7 +1511,7 @@ pl_load_ecs_ext(plApiRegistryI* ptApiRegistry, bool bReload)
}

PL_EXPORT void
pl_unload_ecs_ext(plApiRegistryI* ptApiRegistry)
pl_unload_ext(plApiRegistryI* ptApiRegistry)
{

}
4 changes: 2 additions & 2 deletions extensions/pl_image_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pl_load_image_api(void)
//-----------------------------------------------------------------------------

PL_EXPORT void
pl_load_image_ext(plApiRegistryI* ptApiRegistry, bool bReload)
pl_load_ext(plApiRegistryI* ptApiRegistry, bool bReload)
{
const plDataRegistryI* ptDataRegistry = ptApiRegistry->first(PL_API_DATA_REGISTRY);
pl_set_memory_context(ptDataRegistry->get_data(PL_CONTEXT_MEMORY));
Expand All @@ -110,7 +110,7 @@ pl_load_image_ext(plApiRegistryI* ptApiRegistry, bool bReload)
}

PL_EXPORT void
pl_unload_image_ext(plApiRegistryI* ptApiRegistry)
pl_unload_ext(plApiRegistryI* ptApiRegistry)
{

}
Expand Down
4 changes: 2 additions & 2 deletions extensions/pl_metal_ext.m
Original file line number Diff line number Diff line change
Expand Up @@ -3332,7 +3332,7 @@ - (instancetype)initWithBuffer:(id<MTLBuffer>)buffer
}

PL_EXPORT void
pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
pl_load_ext(plApiRegistryI* ptApiRegistry, bool bReload)
{
const plDataRegistryI* ptDataRegistry = ptApiRegistry->first(PL_API_DATA_REGISTRY);
pl_set_memory_context(ptDataRegistry->get_data(PL_CONTEXT_MEMORY));
Expand All @@ -3355,7 +3355,7 @@ - (instancetype)initWithBuffer:(id<MTLBuffer>)buffer
}

PL_EXPORT void
pl_unload_graphics_ext(plApiRegistryI* ptApiRegistry)
pl_unload_ext(plApiRegistryI* ptApiRegistry)
{

}
Expand Down
4 changes: 2 additions & 2 deletions extensions/pl_resource_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pl_is_resource_valid(plResourceHandle tResourceHandle)
//-----------------------------------------------------------------------------

PL_EXPORT void
pl_load_resource_ext(plApiRegistryI* ptApiRegistry, bool bReload)
pl_load_ext(plApiRegistryI* ptApiRegistry, bool bReload)
{
gptApiRegistry = ptApiRegistry;
ptDataRegistry = ptApiRegistry->first(PL_API_DATA_REGISTRY);
Expand All @@ -193,7 +193,7 @@ pl_load_resource_ext(plApiRegistryI* ptApiRegistry, bool bReload)
}

PL_EXPORT void
pl_unload_resource_ext(plApiRegistryI* ptApiRegistry)
pl_unload_ext(plApiRegistryI* ptApiRegistry)
{
for(uint32_t i = 0; i < pl_sb_size(gptResourceManager->sbtResources); i++)
{
Expand Down
4 changes: 2 additions & 2 deletions extensions/pl_stats_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pl__get_counter_data(char const* pcName)
//-----------------------------------------------------------------------------

PL_EXPORT void
pl_load_stats_ext(plApiRegistryI* ptApiRegistry, bool bReload)
pl_load_ext(plApiRegistryI* ptApiRegistry, bool bReload)
{
const plDataRegistryI* ptDataRegistry = ptApiRegistry->first(PL_API_DATA_REGISTRY);
pl_set_memory_context(ptDataRegistry->get_data(PL_CONTEXT_MEMORY));
Expand All @@ -245,7 +245,7 @@ pl_load_stats_ext(plApiRegistryI* ptApiRegistry, bool bReload)
}

PL_EXPORT void
pl_unload_stats_ext(plApiRegistryI* ptApiRegistry)
pl_unload_ext(plApiRegistryI* ptApiRegistry)
{
pl_sb_free(gtStatsContext.sbtBlocks);
pl_sb_free(gtStatsContext.sbtNames);
Expand Down
4 changes: 2 additions & 2 deletions extensions/pl_vulkan_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -5981,7 +5981,7 @@ pl_load_device_api(void)
}

PL_EXPORT void
pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
pl_load_ext(plApiRegistryI* ptApiRegistry, bool bReload)
{
const plDataRegistryI* ptDataRegistry = ptApiRegistry->first(PL_API_DATA_REGISTRY);
pl_set_memory_context(ptDataRegistry->get_data(PL_CONTEXT_MEMORY));
Expand Down Expand Up @@ -6017,7 +6017,7 @@ pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
}

PL_EXPORT void
pl_unload_graphics_ext(plApiRegistryI* ptApiRegistry)
pl_unload_ext(plApiRegistryI* ptApiRegistry)
{

}
Expand Down
6 changes: 6 additions & 0 deletions src/pilotlight_exe.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@ static void
pl__load_extension(const char* pcName, const char* pcLoadFunc, const char* pcUnloadFunc, bool bReloadable)
{

if(pcLoadFunc == NULL)
pcLoadFunc = "pl_load_ext";

if(pcUnloadFunc == NULL)
pcUnloadFunc = "pl_unload_ext";

const plApiRegistryI* ptApiRegistry = pl__load_api_registry();

plExtension tExtension = {0};
Expand Down

0 comments on commit 30b9c0e

Please sign in to comment.