mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
Schedule level pool to be freed at a later time
This commit is contained in:
parent
2eb2b8c18f
commit
ef9f323b9c
4 changed files with 28 additions and 3 deletions
|
@ -966,6 +966,7 @@ void DynOS_MovtexQC_ModShutdown();
|
|||
struct GraphNode* DynOS_Model_LoadGeo(enum ModelPool aModelPool, void* aAsset);
|
||||
struct GraphNode* DynOS_Model_LoadDl(enum ModelPool aModelPool, u8 aLayer, void* aAsset);
|
||||
void DynOS_Model_ClearPool(enum ModelPool aModelPool);
|
||||
void DynOS_Model_Update();
|
||||
|
||||
//
|
||||
// Bin
|
||||
|
|
|
@ -14,6 +14,7 @@ void *dynos_update_cmd(void *cmd) {
|
|||
}
|
||||
|
||||
void dynos_update_gfx() {
|
||||
DynOS_Model_Update();
|
||||
return DynOS_UpdateGfx();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
#include "dynos.cpp.h"
|
||||
|
||||
extern "C" {
|
||||
|
@ -6,8 +7,14 @@ extern "C" {
|
|||
#include "engine/graph_node.h"
|
||||
}
|
||||
|
||||
struct ScheduledFreePool {
|
||||
struct DynamicPool* pool;
|
||||
u32 timeout;
|
||||
};
|
||||
|
||||
static struct DynamicPool* sModelPools[MODEL_POOL_MAX] = { 0 };
|
||||
static std::map<void*, struct GraphNode*> sModelMap[MODEL_POOL_MAX];
|
||||
static std::vector<struct ScheduledFreePool> sPoolsToFree;
|
||||
|
||||
struct GraphNode* DynOS_Model_LoadGeo(enum ModelPool aModelPool, void* aAsset) {
|
||||
// sanity check pool
|
||||
|
@ -58,11 +65,27 @@ struct GraphNode* DynOS_Model_LoadDl(enum ModelPool aModelPool, u8 aLayer, void*
|
|||
void DynOS_Model_ClearPool(enum ModelPool aModelPool) {
|
||||
if (!sModelPools[aModelPool]) { return; }
|
||||
|
||||
// free and realloc pool
|
||||
dynamic_pool_free_pool(sModelPools[aModelPool]);
|
||||
// schedule pool to be freed
|
||||
sPoolsToFree.push_back({
|
||||
.pool = sModelPools[aModelPool],
|
||||
.timeout = 30
|
||||
});
|
||||
|
||||
// clear pointer
|
||||
sModelPools[aModelPool] = NULL;
|
||||
|
||||
// clear map
|
||||
auto& map = sModelMap[aModelPool];
|
||||
map.clear();
|
||||
}
|
||||
|
||||
void DynOS_Model_Update() {
|
||||
for (auto it = sPoolsToFree.begin(); it != sPoolsToFree.end(); ) {
|
||||
if (--it->timeout <= 0) {
|
||||
dynamic_pool_free_pool(it->pool);
|
||||
it = sPoolsToFree.erase(it);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -185,7 +185,7 @@ void DynOS_Warp_SetParam(s32 aLevel, s32 aIndex) {
|
|||
break;
|
||||
|
||||
case LEVEL_WDW:
|
||||
if (gEnvironmentRegions) {
|
||||
if (gEnvironmentRegions && gEnvironmentRegionsLength > 6) {
|
||||
switch (aIndex) {
|
||||
case 1: gEnvironmentRegions[6] = *gEnvironmentLevels = 31; gWdwWaterLevelSet = 1; break;
|
||||
case 2: gEnvironmentRegions[6] = *gEnvironmentLevels = 1024; gWdwWaterLevelSet = 1; break;
|
||||
|
|
Loading…
Reference in a new issue