Something with streaming

This commit is contained in:
Shinovon 2026-05-12 08:00:13 +05:00
parent e3ad2108f1
commit 6992f313a9
5 changed files with 37 additions and 30 deletions

View file

@ -85,8 +85,6 @@ int32 islandLODcomSub;
int32 islandLODsubInd; int32 islandLODsubInd;
int32 islandLODsubCom; int32 islandLODsubCom;
#define STREAMING_MEM_SIZE (10 * 1024 * 1024)
bool bool
CStreamingInfo::GetCdPosnAndSize(uint32 &posn, uint32 &size) CStreamingInfo::GetCdPosnAndSize(uint32 &posn, uint32 &size)
{ {
@ -221,14 +219,8 @@ CStreaming::Init2(void)
#ifdef GTA_PC #ifdef GTA_PC
#define MB (1024*1024) #define MB (1024*1024)
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
extern bool moreVram; extern size_t streamingMemSize;
if (moreVram) { ms_memoryAvailable = streamingMemSize;
extern size_t _dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10*MB)/2;
if(ms_memoryAvailable < 10*MB)
ms_memoryAvailable = 10*MB;
} else
ms_memoryAvailable = STREAMING_MEM_SIZE;
#else #else
extern size_t _dwMemAvailPhys; extern size_t _dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10 * MB) / 2; ms_memoryAvailable = (_dwMemAvailPhys - 10 * MB) / 2;
@ -647,7 +639,9 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(ms_aInfoForModel[streamId].m_loadState != STREAMSTATE_STARTED){ if(ms_aInfoForModel[streamId].m_loadState != STREAMSTATE_STARTED){
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED;
#ifndef USE_CUSTOM_ALLOCATOR #ifndef USE_CUSTOM_ALLOCATOR
if(streamId < STREAM_OFFSET_TXD) {
ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE; ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE;
}
#endif #endif
} }
@ -713,7 +707,9 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; // only done if success on PS2 ms_aInfoForModel[streamId].m_loadState = STREAMSTATE_LOADED; // only done if success on PS2
#ifndef USE_CUSTOM_ALLOCATOR #ifndef USE_CUSTOM_ALLOCATOR
if(streamId < STREAM_OFFSET_TXD) {
ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE; ms_memoryUsed += ms_aInfoForModel[streamId].GetCdSize() * CDSTREAM_SECTOR_SIZE;
}
#endif #endif
if(!success){ if(!success){
@ -959,7 +955,9 @@ CStreaming::RemoveModel(int32 id)
#ifdef USE_CUSTOM_ALLOCATOR #ifdef USE_CUSTOM_ALLOCATOR
UpdateMemoryUsed(); UpdateMemoryUsed();
#else #else
if (id < STREAM_OFFSET_TXD) {
ms_memoryUsed -= ms_aInfoForModel[id].GetCdSize()*CDSTREAM_SECTOR_SIZE; ms_memoryUsed -= ms_aInfoForModel[id].GetCdSize()*CDSTREAM_SECTOR_SIZE;
}
#endif #endif
} }
@ -2701,13 +2699,8 @@ CStreaming::MakeSpaceFor(int32 size)
#define MB (1024 * 1024) #define MB (1024 * 1024)
if(ms_memoryAvailable == 0) { if(ms_memoryAvailable == 0) {
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
extern bool moreVram; extern size_t streamingMemSize;
if (moreVram) { ms_memoryAvailable = streamingMemSize;
extern size_t _dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10 * MB) / 2;
if(ms_memoryAvailable < 10 * MB) ms_memoryAvailable = 10 * MB;
} else
ms_memoryAvailable = STREAMING_MEM_SIZE;
#else #else
extern size_t _dwMemAvailPhys; extern size_t _dwMemAvailPhys;
ms_memoryAvailable = (_dwMemAvailPhys - 10 * MB) / 2; ms_memoryAvailable = (_dwMemAvailPhys - 10 * MB) / 2;

View file

@ -532,6 +532,8 @@ CreateTxdImageForVideoCard()
// only works for textures that are not yet loaded // only works for textures that are not yet loaded
// so let's hope that is the case for all // so let's hope that is the case for all
rw::gl3::needToReadBackTextures = true; rw::gl3::needToReadBackTextures = true;
#elif defined RW_GLES1
rw::gl1::needToReadBackTextures = true;
#endif #endif
#ifdef DISABLE_VSYNC_ON_TEXTURE_CONVERSION #ifdef DISABLE_VSYNC_ON_TEXTURE_CONVERSION
@ -582,6 +584,8 @@ CreateTxdImageForVideoCard()
CStreaming::RemoveTxd(i); CStreaming::RemoveTxd(i);
#ifdef RW_GL3 #ifdef RW_GL3
rw::gl3::needToReadBackTextures = false; rw::gl3::needToReadBackTextures = false;
#elif defined RW_GLES1
rw::gl1::needToReadBackTextures = false;
#endif #endif
return false; return false;
} }
@ -617,6 +621,8 @@ CreateTxdImageForVideoCard()
#ifdef RW_GL3 #ifdef RW_GL3
rw::gl3::needToReadBackTextures = false; rw::gl3::needToReadBackTextures = false;
#elif defined RW_GLES1
rw::gl1::needToReadBackTextures = false;
#endif #endif
if (!pDir->WriteDirFile("models\\txd.dir")) { if (!pDir->WriteDirFile("models\\txd.dir")) {

View file

@ -49,6 +49,7 @@ psGlobalType psGlobal;
uint32 gGameState = 0; uint32 gGameState = 0;
long _dwOperatingSystemVersion = 0; long _dwOperatingSystemVersion = 0;
uint32 _dwMemAvailPhys = 0; uint32 _dwMemAvailPhys = 0;
size_t streamingMemSize;
static EGLDisplay eglDisplay; static EGLDisplay eglDisplay;
static EGLContext eglContext; static EGLContext eglContext;
@ -526,6 +527,13 @@ public:
VersionInfo::TPlatformVersion platformVersion; VersionInfo::TPlatformVersion platformVersion;
VersionInfo::GetVersion(platformVersion); VersionInfo::GetVersion(platformVersion);
moreVram = platformVersion.iMajorVersion == 5 && platformVersion.iMinorVersion >= 4; moreVram = platformVersion.iMajorVersion == 5 && platformVersion.iMinorVersion >= 4;
if (moreVram) {
streamingMemSize = 12 * 1024 * 1024;
} else {
streamingMemSize = 10 * 1024 * 1024;
}
#else
streamingMemSize = 8 * 1024 * 1024;
#endif #endif
TSize size = Size(); TSize size = Size();

View file

@ -630,7 +630,7 @@ rasterUnlock(Raster *raster, int32 level)
#endif #endif
) { ) {
// convert to 16-bit // convert to 16-bit
uint16_t* pixels16 = (uint16_t*)malloc(raster->width * raster->height * sizeof(uint16_t)); uint16_t* pixels16 = (uint16_t*)rwMalloc(raster->width * raster->height * sizeof(uint16_t));
uint8_t* pixels8 = (uint8_t*)raster->pixels; uint8_t* pixels8 = (uint8_t*)raster->pixels;
for (int i = 0; i < raster->width * raster->height; i++) { for (int i = 0; i < raster->width * raster->height; i++) {

View file

@ -456,7 +456,7 @@ void rasterUnlock(Raster *raster, int32 level){
// flip vertical (igual que antes) // flip vertical (igual que antes)
{ {
int stride = raster->width * natras->bpp; int stride = raster->width * natras->bpp;
uint8_t *tmp = (uint8_t*)malloc(stride); uint8_t *tmp = (uint8_t*)rwMalloc(stride);
for(int y = 0; y < raster->height / 2; y++){ for(int y = 0; y < raster->height / 2; y++){
uint8_t *a = (uint8_t*)raster->pixels + y * stride; uint8_t *a = (uint8_t*)raster->pixels + y * stride;
uint8_t *b = (uint8_t*)raster->pixels + (raster->height - 1 - y) * stride; uint8_t *b = (uint8_t*)raster->pixels + (raster->height - 1 - y) * stride;
@ -470,7 +470,7 @@ void rasterUnlock(Raster *raster, int32 level){
if(!natras->isCompressed){ if(!natras->isCompressed){
if(natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE){ if(natras->format == GL_RGBA && natras->type == GL_UNSIGNED_BYTE){
// convertir RGBA8888 → RGBA4444 // convertir RGBA8888 → RGBA4444
uint16_t *pixels16 = (uint16_t*)malloc(raster->width * raster->height * 2); uint16_t *pixels16 = (uint16_t*)rwMalloc(raster->width * raster->height * 2);
uint8_t *pixels8 = (uint8_t*)raster->pixels; uint8_t *pixels8 = (uint8_t*)raster->pixels;
for(int i = 0; i < raster->width * raster->height; i++){ for(int i = 0; i < raster->width * raster->height; i++){
uint8_t r = pixels8[i*4+0]; uint8_t r = pixels8[i*4+0];