From 546ed0ff07cad63cb07612d8aff8d63213f71ecd Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 11 Nov 2020 09:42:30 +0100 Subject: changes to RW layer so loading foreign files works --- src/core/Streaming.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 3c5689fd..4f721f17 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -390,6 +390,7 @@ CStreaming::LoadCdDirectory(const char *dirname, int n) assert(sizeof(direntry) == 32); while(CFileMgr::Read(fd, (char*)&direntry, sizeof(direntry))){ dot = strchr(direntry.name, '.'); + assert(dot); if(dot) *dot = '\0'; if(direntry.size > (uint32)ms_streamingBufferSize) ms_streamingBufferSize = direntry.size; -- cgit v1.2.3 From 8374a346e52b99552228e80726305376c1853952 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 13 Nov 2020 18:28:15 +0200 Subject: Fix loading island LODs with big buildings --- src/core/Streaming.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 4f721f17..e9a7af88 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -742,7 +742,9 @@ CStreaming::RequestBigBuildings(eLevelName level) b = CPools::GetBuildingPool()->GetSlot(i); if(b && b->bIsBIGBuilding #ifdef NO_ISLAND_LOADING - && ((CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_LOW) || (b->m_level == level)) + && (((CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_LOW) && (b != pIslandLODindustEntity) && (b != pIslandLODcomIndEntity) && + (b != pIslandLODcomSubEntity) && (b != pIslandLODsubIndEntity) && (b != pIslandLODsubComEntity) + ) || (b->m_level == level)) #else && b->m_level == level #endif -- cgit v1.2.3 From 491274f188c953ae0528248a7fcbe25fb78701f7 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 26 Nov 2020 18:11:55 +0200 Subject: CStreaming::PrintStreamingBufferState --- src/core/Streaming.cpp | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index e9a7af88..77d1773b 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -33,6 +33,7 @@ #endif #include "main.h" #include "Frontend.h" +#include "Font.h" bool CStreaming::ms_disableStreaming; bool CStreaming::ms_bLoadingBigModel; @@ -289,6 +290,11 @@ CStreaming::Shutdown(void) } } +#ifndef MASTER +uint64 timeProcessingTXD; +uint64 timeProcessingDFF; +#endif + void CStreaming::Update(void) { @@ -296,6 +302,11 @@ CStreaming::Update(void) CStreamingInfo *si, *prev; bool requestedSubway = false; +#ifndef MASTER + timeProcessingTXD = 0; + timeProcessingDFF = 0; +#endif + UpdateMemoryUsed(); if(ms_channelError != -1){ @@ -331,6 +342,14 @@ CStreaming::Update(void) LoadRequestedModels(); +#ifndef MASTER + if (CPad::GetPad(1)->GetLeftShoulder1JustDown() && CPad::GetPad(1)->GetRightShoulder1() && CPad::GetPad(1)->GetRightShoulder2()) + PrintStreamingBufferState(); + + // TODO: PrintRequestList + //if (CPad::GetPad(1)->GetLeftShoulder2JustDown() && CPad::GetPad(1)->GetRightShoulder1() && CPad::GetPad(1)->GetRightShoulder2()) + // PrintRequestList(); +#endif for(si = ms_endRequestedList.m_prev; si != &ms_startRequestedList; si = prev){ prev = si->m_prev; @@ -2636,3 +2655,71 @@ CStreaming::UpdateForAnimViewer(void) CStreaming::RetryLoadFile(CStreaming::ms_channelError); } } + + +void +CStreaming::PrintStreamingBufferState() +{ + char str[128]; + wchar wstr[128]; + uint32 offset, size; + + CTimer::Stop(); + int i = 0; + while (i < NUMSTREAMINFO) { + while (true) { + int j = 0; + DoRWStuffStartOfFrame(50, 50, 50, 0, 0, 0, 255); + CPad::UpdatePads(); + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + DefinedState(); + + CRect unusedRect(0, 0, RsGlobal.maximumWidth, RsGlobal.maximumHeight); + CRGBA unusedColor(255, 255, 255, 255); + CFont::SetFontStyle(FONT_BANK); + CFont::SetBackgroundOff(); + CFont::SetWrapx(DEFAULT_SCREEN_WIDTH); + CFont::SetScale(0.5f, 0.75f); + CFont::SetCentreOff(); + CFont::SetCentreSize(DEFAULT_SCREEN_WIDTH); + CFont::SetJustifyOff(); + CFont::SetColor(CRGBA(200, 200, 200, 200)); + CFont::SetBackGroundOnlyTextOff(); + int modelIndex = i; + if (modelIndex < NUMSTREAMINFO) { + int y = 24; + for ( ; j < 34 && modelIndex < NUMSTREAMINFO; modelIndex++) { + CStreamingInfo *streamingInfo = &ms_aInfoForModel[modelIndex]; + CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelIndex); + if (streamingInfo->m_loadState != STREAMSTATE_LOADED || !streamingInfo->GetCdPosnAndSize(offset, size)) + continue; + + if (modelIndex >= STREAM_OFFSET_TXD) + sprintf(str, "txd %s, refs %d, size %dK, flags 0x%x", CTxdStore::GetTxdName(modelIndex - STREAM_OFFSET_TXD), + CTxdStore::GetNumRefs(modelIndex - STREAM_OFFSET_TXD), 2 * size, streamingInfo->m_flags); + else + sprintf(str, "model %d,%s, refs%d, size%dK, flags%x", modelIndex, modelInfo->GetName(), modelInfo->GetNumRefs(), 2 * size, + streamingInfo->m_flags); + AsciiToUnicode(str, wstr); + CFont::PrintString(24.0f, y, wstr); + y += 12; + j++; + } + } + + if (CPad::GetPad(1)->GetCrossJustDown()) + i = modelIndex; + + if (!CPad::GetPad(1)->GetTriangleJustDown()) + break; + + i = 0; + CFont::DrawFonts(); + DoRWStuffEndOfFrame(); + } + CFont::DrawFonts(); + DoRWStuffEndOfFrame(); + } + CTimer::Update(); +} \ No newline at end of file -- cgit v1.2.3 From d857758c167ee06840ec806524191e95ff37f98a Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 26 Nov 2020 16:47:19 +0100 Subject: start using CMemoryHeap --- src/core/Streaming.cpp | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index e9a7af88..8f1a8891 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -33,6 +33,7 @@ #endif #include "main.h" #include "Frontend.h" +#include "MemoryHeap.h" bool CStreaming::ms_disableStreaming; bool CStreaming::ms_bLoadingBigModel; @@ -470,8 +471,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) // Set Txd to use CTxdStore::AddRef(mi->GetTxdSlot()); - CTxdStore::SetCurrentTxd(mi->GetTxdSlot()); + PUSH_MEMID(MEMID_STREAM_MODELS); + CTxdStore::SetCurrentTxd(mi->GetTxdSlot()); +// TODO(USE_CUSTOM_ALLOCATOR): register mem pointers if(mi->IsSimple()){ success = CFileLoader::LoadAtomicFile(stream, streamId); } else if (mi->GetModelType() == MITYPE_VEHICLE) { @@ -483,6 +486,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) }else{ success = CFileLoader::LoadClumpFile(stream, streamId); } + POP_MEMID(); UpdateMemoryUsed(); // Txd no longer needed unless we only read part of the file @@ -506,12 +510,14 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) return false; } + PUSH_MEMID(MEMID_STREAM_TEXUTRES); if(ms_bLoadingBigModel || cdsize > 200){ success = CTxdStore::StartLoadTxd(streamId - STREAM_OFFSET_TXD, stream); if(success) ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_STARTED; }else success = CTxdStore::LoadTxd(streamId - STREAM_OFFSET_TXD, stream); + POP_MEMID(); UpdateMemoryUsed(); if(!success){ @@ -561,7 +567,9 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) // Mark objects as loaded if(ms_aInfoForModel[streamId].m_loadState != STREAMSTATE_STARTED){ ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; +#ifndef USE_CUSTOM_ALLOCATOR ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE; +#endif } endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); @@ -600,32 +608,40 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId) if(streamId < STREAM_OFFSET_TXD){ // Model +// TODO(USE_CUSTOM_ALLOCATOR): register pointers mi = CModelInfo::GetModelInfo(streamId); + PUSH_MEMID(MEMID_STREAM_MODELS); CTxdStore::SetCurrentTxd(mi->GetTxdSlot()); success = CFileLoader::FinishLoadClumpFile(stream, streamId); if(success) success = AddToLoadedVehiclesList(streamId); + POP_MEMID(); mi->RemoveRef(); CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot()); }else{ // Txd CTxdStore::AddRef(streamId - STREAM_OFFSET_TXD); + PUSH_MEMID(MEMID_STREAM_TEXUTRES); success = CTxdStore::FinishLoadTxd(streamId - STREAM_OFFSET_TXD, stream); + POP_MEMID(); CTxdStore::RemoveRefWithoutDelete(streamId - STREAM_OFFSET_TXD); } RwStreamClose(stream, &mem); - ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; + + ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; // only done if success on PS2 +#ifndef USE_CUSTOM_ALLOCATOR ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE; +#endif if(!success){ RemoveModel(streamId); ReRequestModel(streamId); - UpdateMemoryUsed(); + UpdateMemoryUsed(); // directly after pop on PS2 return false; } - UpdateMemoryUsed(); + UpdateMemoryUsed(); // directly after pop on PS2 endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); timeDiff = endTime - startTime; @@ -858,7 +874,11 @@ CStreaming::RemoveModel(int32 id) CModelInfo::GetModelInfo(id)->DeleteRwObject(); else CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD); +#ifdef USE_CUSTOM_ALLOCATOR + UpdateMemoryUsed(); +#else ms_memoryUsed -= ms_aInfoForModel[id].GetCdSize()*CDSTREAM_SECTOR_SIZE; +#endif } if(ms_aInfoForModel[id].m_next){ @@ -880,6 +900,9 @@ CStreaming::RemoveModel(int32 id) RpClumpGtaCancelStream(); else CTxdStore::RemoveTxd(id - STREAM_OFFSET_TXD); +#ifdef USE_CUSTOM_ALLOCATOR + UpdateMemoryUsed(); +#endif } ms_aInfoForModel[id].m_loadState = STREAMSTATE_NOTLOADED; @@ -2044,19 +2067,25 @@ CStreaming::FlushRequestList(void) void CStreaming::ImGonnaUseStreamingMemory(void) { - // empty + PUSH_MEMID(MEMID_STREAM); } void CStreaming::IHaveUsedStreamingMemory(void) { + POP_MEMID(); UpdateMemoryUsed(); } void CStreaming::UpdateMemoryUsed(void) { - // empty +#ifdef USE_CUSTOM_ALLOCATOR + ms_memoryUsed = + gMainHeap.GetMemoryUsed(MEMID_STREAM) + + gMainHeap.GetMemoryUsed(MEMID_STREAM_MODELS) + + gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES); +#endif } #define STREAM_DIST 80.0f -- cgit v1.2.3 From a8035b64662e9b9fe6689ec60e5087ff95bc2672 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 28 Nov 2020 16:16:15 +0100 Subject: moved some stuff to MemoryMgr --- src/core/Streaming.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 628d4923..a28fe39d 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -34,6 +34,7 @@ #include "main.h" #include "Frontend.h" #include "Font.h" +#include "MemoryMgr.h" #include "MemoryHeap.h" bool CStreaming::ms_disableStreaming; -- cgit v1.2.3 From 4b9fb631fc1b250a1e353da2e319d49371573bcc Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 30 Nov 2020 23:44:58 +0100 Subject: added a few registered pointers and memory debug --- src/core/Streaming.cpp | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index a28fe39d..03b49fd6 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -458,6 +458,35 @@ CStreaming::LoadCdDirectory(const char *dirname, int n) CFileMgr::CloseFile(fd); } +#ifdef USE_CUSTOM_ALLOCATOR +RpAtomic* +RegisterAtomicMemPtrsCB(RpAtomic *atomic, void *data) +{ +#if THIS_IS_COMPATIBLE_WITH_GTA3_RW31 + // not quite sure what's going on here: + // gta3's RW 3.1 allocates separate memory for geometry data of RpGeometry. + // Is that a R* change? rpDefaultGeometryInstance also depends on it + RpGeometry *geo = RpAtomicGetGeometry(atomic); + if(geo->triangles) + REGISTER_MEMPTR(&geo->triangles); + if(geo->matList.materials) + REGISTER_MEMPTR(&geo->matList.materials); + if(geo->preLitLum) + REGISTER_MEMPTR(&geo->preLitLum); + if(geo->texCoords[0]) + REGISTER_MEMPTR(&geo->texCoords[0]); + if(geo->texCoords[1]) + REGISTER_MEMPTR(&geo->texCoords[1]); +#else + // normally RpGeometry is allocated in one block (excluding morph targets) + // so we don't really have allocated pointers in the struct. + // NB: in librw we actually do it in two allocations (geometry itself and data) + // so we could conceivably come up with something here +#endif + return atomic; +} +#endif + bool CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) { @@ -494,9 +523,11 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) PUSH_MEMID(MEMID_STREAM_MODELS); CTxdStore::SetCurrentTxd(mi->GetTxdSlot()); -// TODO(USE_CUSTOM_ALLOCATOR): register mem pointers if(mi->IsSimple()){ success = CFileLoader::LoadAtomicFile(stream, streamId); +#ifdef USE_CUSTOM_ALLOCATOR + RegisterAtomicMemPtrsCB(((CSimpleModelInfo*)mi)->m_atomics[0], nil); +#endif } else if (mi->GetModelType() == MITYPE_VEHICLE) { // load vehicles in two parts CModelInfo::GetModelInfo(streamId)->AddRef(); @@ -505,6 +536,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_STARTED; }else{ success = CFileLoader::LoadClumpFile(stream, streamId); +#ifdef USE_CUSTOM_ALLOCATOR + if(success) + RpClumpForAllAtomics((RpClump*)mi->GetRwObject(), RegisterAtomicMemPtrsCB, nil); +#endif } POP_MEMID(); UpdateMemoryUsed(); @@ -628,13 +663,16 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId) if(streamId < STREAM_OFFSET_TXD){ // Model -// TODO(USE_CUSTOM_ALLOCATOR): register pointers mi = CModelInfo::GetModelInfo(streamId); PUSH_MEMID(MEMID_STREAM_MODELS); CTxdStore::SetCurrentTxd(mi->GetTxdSlot()); success = CFileLoader::FinishLoadClumpFile(stream, streamId); - if(success) + if(success){ +#ifdef USE_CUSTOM_ALLOCATOR + RpClumpForAllAtomics((RpClump*)mi->GetRwObject(), RegisterAtomicMemPtrsCB, nil); +#endif success = AddToLoadedVehiclesList(streamId); + } POP_MEMID(); mi->RemoveRef(); CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot()); -- cgit v1.2.3 From f3a356375e084caf50eed38b06ca6885d2d92b9d Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 18 Dec 2020 14:19:03 +0100 Subject: added MemoryHeap from III, MemoryMgr --- src/core/Streaming.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 40d4acee..76430a5c 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -32,6 +32,8 @@ #include "ColStore.h" #include "DMAudio.h" #include "Script.h" +#include "MemoryMgr.h" +#include "MemoryHeap.h" //--MIAMI: file done (possibly bugs) -- cgit v1.2.3 From fb97335d9f66d1cce6fba106e7b0f4e9bc7e5662 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 21 Dec 2020 12:34:29 +0100 Subject: push/pop memids --- src/core/Streaming.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index afc6704d..8c1b839c 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -480,6 +480,14 @@ GetObjectName(int streamId) return objname; } +#ifdef USE_CUSTOM_ALLOCATOR +RpAtomic* +RegisterAtomicMemPtrsCB(RpAtomic *atomic, void *data) +{ + // empty because we expect models to be pre-instanced + return atomic; +} +#endif bool CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) @@ -514,9 +522,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) // Set Txd and anims to use CTxdStore::AddRef(mi->GetTxdSlot()); +#if GTA_VERSION > GTAVC_PS2 if(animId != -1) CAnimManager::AddAnimBlockRef(animId); - CTxdStore::SetCurrentTxd(mi->GetTxdSlot()); +#endif PUSH_MEMID(MEMID_STREAM_MODELS); CTxdStore::SetCurrentTxd(mi->GetTxdSlot()); @@ -542,8 +551,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) // Txd and anims no longer needed unless we only read part of the file if(ms_aInfoForModel[streamId].m_loadState != STREAMSTATE_STARTED){ CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot()); +#if GTA_VERSION > GTAVC_PS2 if(animId != -1) CAnimManager::RemoveAnimBlockRefWithoutDelete(animId); +#endif } if(!success){ @@ -580,7 +591,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) return false; } }else if(streamId >= STREAM_OFFSET_COL && streamId < STREAM_OFFSET_ANIM){ - if(!CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length)){ + PUSH_MEMID(MEMID_STREAM_COLLISION); + bool success = CColStore::LoadCol(streamId-STREAM_OFFSET_COL, mem.start, mem.length); + POP_MEMID(); + if(!success){ debug("Failed to load %s.col\n", CColStore::GetColName(streamId - STREAM_OFFSET_COL)); RemoveModel(streamId); ReRequestModel(streamId); @@ -595,8 +609,10 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) RwStreamClose(stream, &mem); return false; } + PUSH_MEMID(MEMID_STREAM_ANIMATION); CAnimManager::LoadAnimFile(stream, true, nil); CAnimManager::CreateAnimAssocGroups(); + POP_MEMID(); } RwStreamClose(stream, &mem); @@ -678,8 +694,10 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId) POP_MEMID(); mi->RemoveRef(); CTxdStore::RemoveRefWithoutDelete(mi->GetTxdSlot()); +#if GTA_VERSION > GTAVC_PS2 if(mi->GetAnimFileIndex() != -1) CAnimManager::RemoveAnimBlockRefWithoutDelete(mi->GetAnimFileIndex()); +#endif }else if(streamId >= STREAM_OFFSET_TXD && streamId < STREAM_OFFSET_COL){ // Txd CTxdStore::AddRef(streamId - STREAM_OFFSET_TXD); @@ -693,7 +711,7 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId) RwStreamClose(stream, &mem); - ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; // only done if success on PS2 + ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; #ifndef USE_CUSTOM_ALLOCATOR ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE; #endif @@ -701,11 +719,11 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId) if(!success){ RemoveModel(streamId); ReRequestModel(streamId); - UpdateMemoryUsed(); // directly after pop on PS2 + UpdateMemoryUsed(); return false; } - UpdateMemoryUsed(); // directly after pop on PS2 + UpdateMemoryUsed(); endTime = CTimer::GetCurrentTimeInCycles() / CTimer::GetCyclesPerMillisecond(); timeDiff = endTime - startTime; @@ -2471,7 +2489,9 @@ CStreaming::UpdateMemoryUsed(void) ms_memoryUsed = gMainHeap.GetMemoryUsed(MEMID_STREAM) + gMainHeap.GetMemoryUsed(MEMID_STREAM_MODELS) + - gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES); + gMainHeap.GetMemoryUsed(MEMID_STREAM_TEXUTRES) + + gMainHeap.GetMemoryUsed(MEMID_STREAM_COLLISION) + + gMainHeap.GetMemoryUsed(MEMID_STREAM_ANIMATION); #endif } -- cgit v1.2.3 From 7959b7fd1fa0b4dbe46485c111277eae3c374dde Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sun, 27 Dec 2020 18:26:30 +0200 Subject: NO_ISLAND_LOADING ported from re3 --- src/core/Streaming.cpp | 69 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 22 deletions(-) (limited to 'src/core/Streaming.cpp') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 8c1b839c..2fd8bf1c 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -35,6 +35,7 @@ #include "MemoryMgr.h" #include "MemoryHeap.h" #include "Font.h" +#include "Frontend.h" //--MIAMI: file done (possibly bugs) @@ -797,7 +798,15 @@ CStreaming::RequestBigBuildings(eLevelName level) n = CPools::GetBuildingPool()->GetSize()-1; for(i = n; i >= 0; i--){ b = CPools::GetBuildingPool()->GetSlot(i); - if(b && b->bIsBIGBuilding && b->m_level == level) + if(b && b->bIsBIGBuilding +#ifdef NO_ISLAND_LOADING + && (((FrontEndMenuManager.m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_LOW) && (b != pIslandLODmainlandEntity) && + (b != pIslandLODbeachEntity)) || + (b->m_level == level)) +#else + && b->m_level == level +#endif + ) if(!b->bStreamBIGBuilding) RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS); } @@ -814,8 +823,11 @@ CStreaming::RequestBigBuildings(eLevelName level, const CVector &pos) for(i = n; i >= 0; i--){ b = CPools::GetBuildingPool()->GetSlot(i); if(b && b->bIsBIGBuilding -#ifndef NO_ISLAND_LOADING - && b->m_level == level +#ifdef NO_ISLAND_LOADING + && (((FrontEndMenuManager.m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_LOW) && (b != pIslandLODmainlandEntity) && (b != pIslandLODbeachEntity) + ) || (b->m_level == level)) +#else + && b->m_level == level #endif ) if(b->bStreamBIGBuilding){ @@ -885,7 +897,7 @@ CStreaming::InstanceLoadedModels(const CVector &pos) void CStreaming::RequestIslands(eLevelName level) { -#ifndef NO_ISLAND_LOADING + ISLAND_LOADING_ISNT(HIGH) switch(level){ case LEVEL_MAINLAND: if(islandLODbeach != -1) @@ -897,7 +909,6 @@ CStreaming::RequestIslands(eLevelName level) break; default: break; } -#endif } static char *IGnames[] = { @@ -1227,12 +1238,13 @@ CStreaming::RemoveBuildingsNotInArea(int32 area) void CStreaming::RemoveUnusedBigBuildings(eLevelName level) { -#ifndef NO_ISLAND_LOADING + ISLAND_LOADING_IS(LOW) + { if(level != LEVEL_BEACH) RemoveBigBuildings(LEVEL_BEACH); if(level != LEVEL_MAINLAND) RemoveBigBuildings(LEVEL_MAINLAND); -#endif + } RemoveIslandsNotUsed(level); } @@ -1252,7 +1264,6 @@ DeleteIsland(CEntity *island) void CStreaming::RemoveIslandsNotUsed(eLevelName level) { -#ifndef NO_ISLAND_LOADING int i; if(pIslandLODmainlandEntity == nil) for(i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--){ @@ -1264,7 +1275,12 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level) if(building->GetModelIndex() == islandLODbeach) pIslandLODbeachEntity = building; } - +#ifdef NO_ISLAND_LOADING + if(FrontEndMenuManager.m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_HIGH) { + DeleteIsland(pIslandLODmainlandEntity); + DeleteIsland(pIslandLODbeachEntity); + } else +#endif switch(level){ case LEVEL_MAINLAND: DeleteIsland(pIslandLODmainlandEntity); @@ -1274,7 +1290,6 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level) break; } -#endif // !NO_ISLAND_LOADING } void @@ -1875,26 +1890,36 @@ CStreaming::LoadBigBuildingsWhenNeeded(void) CTimer::Suspend(); CGame::currLevel = CTheZones::m_CurrLevel; - DMAudio.SetEffectsFadeVol(0); - CPad::StopPadsShaking(); - CCollision::LoadCollisionScreen(CGame::currLevel); - DMAudio.Service(); - - RemoveUnusedBigBuildings(CGame::currLevel); - RemoveUnusedBuildings(CGame::currLevel); - RemoveUnusedModelsInLoadedList(); - CGame::TidyUpMemory(true, true); - + ISLAND_LOADING_IS(LOW) + { + DMAudio.SetEffectsFadeVol(0); + CPad::StopPadsShaking(); + CCollision::LoadCollisionScreen(CGame::currLevel); + DMAudio.Service(); + + RemoveUnusedBigBuildings(CGame::currLevel); + RemoveUnusedBuildings(CGame::currLevel); + RemoveUnusedModelsInLoadedList(); + CGame::TidyUpMemory(true, true); + } CReplay::EmptyReplayBuffer(); if(CGame::currLevel != LEVEL_GENERIC) LoadSplash(GetLevelSplashScreen(CGame::currLevel)); - CStreaming::RequestBigBuildings(CGame::currLevel, TheCamera.GetPosition()); + ISLAND_LOADING_IS(LOW) + CStreaming::RequestBigBuildings(CGame::currLevel, TheCamera.GetPosition()); + else if(FrontEndMenuManager.m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_MEDIUM) { + RemoveIslandsNotUsed(CGame::currLevel); + CStreaming::RequestIslands(CGame::currLevel); + } + CStreaming::LoadAllRequestedModels(false); CGame::TidyUpMemory(true, true); CTimer::Resume(); - DMAudio.SetEffectsFadeVol(127); + + ISLAND_LOADING_IS(LOW) + DMAudio.SetEffectsFadeVol(127); } -- cgit v1.2.3