mirror of
https://gitlab.com/shinovon/re3-symbian.git
synced 2026-05-23 01:57:21 +03:00
No more out of memory errors on VC3
This commit is contained in:
parent
689c76b4c5
commit
30fff6bbab
5 changed files with 76 additions and 36 deletions
|
|
@ -145,6 +145,8 @@ int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW;
|
||||||
#ifdef GAMEPAD_MENU
|
#ifdef GAMEPAD_MENU
|
||||||
#ifdef __SWITCH__
|
#ifdef __SWITCH__
|
||||||
int8 CMenuManager::m_PrefsControllerType = CONTROLLER_NINTENDO_SWITCH;
|
int8 CMenuManager::m_PrefsControllerType = CONTROLLER_NINTENDO_SWITCH;
|
||||||
|
#elif defined __SYMBIAN32__
|
||||||
|
int8 CMenuManager::m_PrefsControllerType = CONTROLLER_DUALSHOCK2;
|
||||||
#else
|
#else
|
||||||
int8 CMenuManager::m_PrefsControllerType = CONTROLLER_XBOXONE;
|
int8 CMenuManager::m_PrefsControllerType = CONTROLLER_XBOXONE;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -371,7 +371,7 @@ enum Config {
|
||||||
# define CUSTOM_FRONTEND_OPTIONS
|
# define CUSTOM_FRONTEND_OPTIONS
|
||||||
|
|
||||||
# ifdef CUSTOM_FRONTEND_OPTIONS
|
# ifdef CUSTOM_FRONTEND_OPTIONS
|
||||||
# define MENU_MAP // VC-like menu map. Won't appear if you don't have our menu.txd
|
//# define MENU_MAP // VC-like menu map. Won't appear if you don't have our menu.txd
|
||||||
# define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable
|
# define GRAPHICS_MENU_OPTIONS // otherwise Display settings will be scrollable
|
||||||
//# define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
|
//# define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
|
||||||
# define CUTSCENE_BORDERS_SWITCH
|
# define CUTSCENE_BORDERS_SWITCH
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ void debugRaster(RwRaster *r){
|
||||||
}
|
}
|
||||||
|
|
||||||
static void downscaleTexture(RwTexture *texture){
|
static void downscaleTexture(RwTexture *texture){
|
||||||
#ifdef RW_GLES1
|
// #ifdef RW_GLES1
|
||||||
if(texture == nil)
|
if(texture == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -146,7 +146,11 @@ static void downscaleTexture(RwTexture *texture){
|
||||||
// crear nuevo raster en formato compatible con GLES1
|
// crear nuevo raster en formato compatible con GLES1
|
||||||
int32 w, h, d, f;
|
int32 w, h, d, f;
|
||||||
rw::Raster::imageFindRasterFormat(resized, rw::Raster::TEXTURE, &w, &h, &d, &f);
|
rw::Raster::imageFindRasterFormat(resized, rw::Raster::TEXTURE, &w, &h, &d, &f);
|
||||||
|
#ifdef RW_GLES1
|
||||||
RwRaster *newRaster = rw::Raster::create(w, h, d, f | rw::Raster::TEXTURE, rw::PLATFORM_GLES1);
|
RwRaster *newRaster = rw::Raster::create(w, h, d, f | rw::Raster::TEXTURE, rw::PLATFORM_GLES1);
|
||||||
|
#else
|
||||||
|
RwRaster *newRaster = rw::Raster::create(w, h, d, f | rw::Raster::TEXTURE, rw::PLATFORM_GL3);
|
||||||
|
#endif
|
||||||
if(newRaster == nil){
|
if(newRaster == nil){
|
||||||
debug("downscaleTexture: raster create FAILED");
|
debug("downscaleTexture: raster create FAILED");
|
||||||
RwImageDestroy(resized);
|
RwImageDestroy(resized);
|
||||||
|
|
@ -163,36 +167,36 @@ static void downscaleTexture(RwTexture *texture){
|
||||||
RwImageDestroy(resized);
|
RwImageDestroy(resized);
|
||||||
RwTextureSetRaster(texture, newRaster);
|
RwTextureSetRaster(texture, newRaster);
|
||||||
RwRasterDestroy(oldRaster);
|
RwRasterDestroy(oldRaster);
|
||||||
#else
|
// #else
|
||||||
RwRaster *oldRaster = RwTextureGetRaster(texture);
|
// RwRaster *oldRaster = RwTextureGetRaster(texture);
|
||||||
if (oldRaster == nil)
|
// if (oldRaster == nil)
|
||||||
return;
|
// return;
|
||||||
|
//
|
||||||
extern bool moreVram;
|
// extern bool moreVram;
|
||||||
int targetSize = moreVram ? 64 : 32;
|
// int targetSize = moreVram ? 64 : 32;
|
||||||
|
//
|
||||||
int oldWidth = RwRasterGetWidth(oldRaster);
|
// int oldWidth = RwRasterGetWidth(oldRaster);
|
||||||
int oldHeight = RwRasterGetHeight(oldRaster);
|
// int oldHeight = RwRasterGetHeight(oldRaster);
|
||||||
if (oldWidth <= targetSize && oldHeight <= targetSize) return;
|
// if (oldWidth <= targetSize && oldHeight <= targetSize) return;
|
||||||
|
//
|
||||||
int newWidth = clamp(oldWidth, targetSize);
|
// int newWidth = clamp(oldWidth, targetSize);
|
||||||
int newHeight = clamp(oldHeight, targetSize);
|
// int newHeight = clamp(oldHeight, targetSize);
|
||||||
if (newWidth == oldWidth && newHeight == oldHeight) return;
|
// if (newWidth == oldWidth && newHeight == oldHeight) return;
|
||||||
|
//
|
||||||
RwImage *image = oldRaster->toImage();
|
// RwImage *image = oldRaster->toImage();
|
||||||
if (image == nil) return;
|
// if (image == nil) return;
|
||||||
|
//
|
||||||
RwImage *resized = resizeImage(image, newWidth, newHeight);
|
// RwImage *resized = resizeImage(image, newWidth, newHeight);
|
||||||
RwImageDestroy(image);
|
// RwImageDestroy(image);
|
||||||
if (resized == nil) return;
|
// if (resized == nil) return;
|
||||||
|
//
|
||||||
RwRaster *newRaster = rw::Raster::createFromImage(resized);
|
// RwRaster *newRaster = rw::Raster::createFromImage(resized);
|
||||||
RwImageDestroy(resized);
|
// RwImageDestroy(resized);
|
||||||
if (newRaster == nil) return;
|
// if (newRaster == nil) return;
|
||||||
|
//
|
||||||
RwTextureSetRaster(texture, newRaster);
|
// RwTextureSetRaster(texture, newRaster);
|
||||||
RwRasterDestroy(oldRaster);
|
// RwRasterDestroy(oldRaster);
|
||||||
#endif
|
// #endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -219,6 +223,11 @@ RwTextureGtaStreamRead(RwStream *stream)
|
||||||
if (gGameState == GS_INIT_PLAYING_GAME) {
|
if (gGameState == GS_INIT_PLAYING_GAME) {
|
||||||
texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1);
|
texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1);
|
||||||
texNumLoaded++;
|
texNumLoaded++;
|
||||||
|
} else /*if (gGameState != GS_PLAYING_GAME)*/ {
|
||||||
|
if (tex != nil && tex->raster != nil && RwRasterGetWidth(tex->raster) > 128 || RwRasterGetHeight(tex->raster) > 128) {
|
||||||
|
// debug("downscaling %s", tex->name);
|
||||||
|
downscaleTexture(tex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ANISOTROPIC_FILTERING
|
#ifdef ANISOTROPIC_FILTERING
|
||||||
|
|
|
||||||
23
vendor/librw/src/gl/gl3raster.cpp
vendored
23
vendor/librw/src/gl/gl3raster.cpp
vendored
|
|
@ -64,6 +64,7 @@ getLevelSize(Raster *raster, int32 level)
|
||||||
static Raster*
|
static Raster*
|
||||||
rasterCreateTexture(Raster *raster)
|
rasterCreateTexture(Raster *raster)
|
||||||
{
|
{
|
||||||
|
CHECK_GL_ERROR("-rasterCreateTexture");
|
||||||
if(raster->format & (Raster::PAL4 | Raster::PAL8)){
|
if(raster->format & (Raster::PAL4 | Raster::PAL8)){
|
||||||
RWERROR((ERR_NOTEXTURE));
|
RWERROR((ERR_NOTEXTURE));
|
||||||
return nil;
|
return nil;
|
||||||
|
|
@ -138,11 +139,14 @@ rasterCreateTexture(Raster *raster)
|
||||||
natras->numLevels = 1;
|
natras->numLevels = 1;
|
||||||
|
|
||||||
glGenTextures(1, &natras->texid);
|
glGenTextures(1, &natras->texid);
|
||||||
uint32 prev = bindTexture(natras->texid);
|
CHECK_GL_ERROR("glGenTextures");
|
||||||
|
// re3_debug("creating texture, format: %d, size: %d x %d", natras->internalFormat, raster->width, raster->height);
|
||||||
|
// uint32 prev = bindTexture(natras->texid);
|
||||||
// glTexImage2D(GL_TEXTURE_2D, 0, natras->internalFormat,
|
// glTexImage2D(GL_TEXTURE_2D, 0, natras->internalFormat,
|
||||||
//// raster->width, raster->height,
|
// raster->width, raster->height,
|
||||||
// 1,1,
|
//// 1,1,
|
||||||
// 0, natras->format, natras->type, nil);
|
// 0, natras->format, natras->type, nil);
|
||||||
|
// CHECK_GL_ERROR("glTexImage2D");
|
||||||
// TODO: allocate other levels...probably
|
// TODO: allocate other levels...probably
|
||||||
#ifndef __SYMBIAN32__
|
#ifndef __SYMBIAN32__
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, natras->numLevels-1);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, natras->numLevels-1);
|
||||||
|
|
@ -152,7 +156,7 @@ rasterCreateTexture(Raster *raster)
|
||||||
natras->addressV = 0;
|
natras->addressV = 0;
|
||||||
natras->maxAnisotropy = 1;
|
natras->maxAnisotropy = 1;
|
||||||
|
|
||||||
bindTexture(prev);
|
// bindTexture(prev);
|
||||||
return raster;
|
return raster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,6 +224,7 @@ rasterCreateCameraTexture(Raster *raster)
|
||||||
// raster->width, raster->height,
|
// raster->width, raster->height,
|
||||||
1,1,
|
1,1,
|
||||||
0, natras->format, natras->type, nil);
|
0, natras->format, natras->type, nil);
|
||||||
|
CHECK_GL_ERROR("glTexImage2D");
|
||||||
natras->filterMode = 0;
|
natras->filterMode = 0;
|
||||||
natras->addressU = 0;
|
natras->addressU = 0;
|
||||||
natras->addressV = 0;
|
natras->addressV = 0;
|
||||||
|
|
@ -488,6 +493,7 @@ uint8*
|
||||||
rasterLock(Raster *raster, int32 level, int32 lockMode)
|
rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||||
{
|
{
|
||||||
#ifdef RW_OPENGL
|
#ifdef RW_OPENGL
|
||||||
|
CHECK_GL_ERROR("+rasterLock");
|
||||||
Gl3Raster *natras GETGL3RASTEREXT(raster);
|
Gl3Raster *natras GETGL3RASTEREXT(raster);
|
||||||
uint8 *px;
|
uint8 *px;
|
||||||
uint32 allocSz;
|
uint32 allocSz;
|
||||||
|
|
@ -536,8 +542,10 @@ rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||||
glGenFramebuffers(1, &fbo);
|
glGenFramebuffers(1, &fbo);
|
||||||
bindFramebuffer(fbo);
|
bindFramebuffer(fbo);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, natras->texid, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, natras->texid, 0);
|
||||||
|
CHECK_GL_ERROR("glFramebufferTexture2D");
|
||||||
GLenum e = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum e = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
glReadPixels(0, 0, raster->width, raster->height, natras->format, natras->type, px);
|
glReadPixels(0, 0, raster->width, raster->height, natras->format, natras->type, px);
|
||||||
|
CHECK_GL_ERROR("glReadPixels");
|
||||||
//e = glGetError(); printf("GL err4 %x (%x)\n", e, natras->format);
|
//e = glGetError(); printf("GL err4 %x (%x)\n", e, natras->format);
|
||||||
bindFramebuffer(0);
|
bindFramebuffer(0);
|
||||||
glDeleteFramebuffers(1, &fbo);
|
glDeleteFramebuffers(1, &fbo);
|
||||||
|
|
@ -571,6 +579,7 @@ rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||||
glReadBuffer(GL_BACK);
|
glReadBuffer(GL_BACK);
|
||||||
#endif
|
#endif
|
||||||
glReadPixels(0, 0, raster->width, raster->height, GL_RGB, GL_UNSIGNED_BYTE, px);
|
glReadPixels(0, 0, raster->width, raster->height, GL_RGB, GL_UNSIGNED_BYTE, px);
|
||||||
|
CHECK_GL_ERROR("glReadPixels");
|
||||||
|
|
||||||
raster->privateFlags = lockMode;
|
raster->privateFlags = lockMode;
|
||||||
break;
|
break;
|
||||||
|
|
@ -580,6 +589,7 @@ rasterLock(Raster *raster, int32 level, int32 lockMode)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECK_GL_ERROR("-rasterLock");
|
||||||
return px;
|
return px;
|
||||||
#else
|
#else
|
||||||
return nil;
|
return nil;
|
||||||
|
|
@ -590,6 +600,7 @@ void
|
||||||
rasterUnlock(Raster *raster, int32 level)
|
rasterUnlock(Raster *raster, int32 level)
|
||||||
{
|
{
|
||||||
#ifdef RW_OPENGL
|
#ifdef RW_OPENGL
|
||||||
|
CHECK_GL_ERROR("+rasterUnlock");
|
||||||
Gl3Raster *natras = GETGL3RASTEREXT(raster);
|
Gl3Raster *natras = GETGL3RASTEREXT(raster);
|
||||||
|
|
||||||
assert(raster->pixels);
|
assert(raster->pixels);
|
||||||
|
|
@ -606,6 +617,7 @@ rasterUnlock(Raster *raster, int32 level)
|
||||||
raster->width, raster->height, 0,
|
raster->width, raster->height, 0,
|
||||||
getLevelSize(raster, level),
|
getLevelSize(raster, level),
|
||||||
raster->pixels);
|
raster->pixels);
|
||||||
|
CHECK_GL_ERROR("glCompressedTexImage2D");
|
||||||
if(natras->backingStore){
|
if(natras->backingStore){
|
||||||
assert(level < natras->backingStore->numlevels);
|
assert(level < natras->backingStore->numlevels);
|
||||||
memcpy(natras->backingStore->levels[level].data, raster->pixels,
|
memcpy(natras->backingStore->levels[level].data, raster->pixels,
|
||||||
|
|
@ -631,12 +643,14 @@ rasterUnlock(Raster *raster, int32 level)
|
||||||
}
|
}
|
||||||
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16);
|
glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, raster->width, raster->height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, pixels16);
|
||||||
free(pixels16);
|
free(pixels16);
|
||||||
|
CHECK_GL_ERROR("glTexImage2D 1");
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
// glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat,
|
glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat,
|
||||||
raster->width, raster->height,
|
raster->width, raster->height,
|
||||||
0, natras->format, natras->type, raster->pixels);
|
0, natras->format, natras->type, raster->pixels);
|
||||||
|
CHECK_GL_ERROR("glTexImage2D 2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if(level == 0 && natras->autogenMipmap)
|
// if(level == 0 && natras->autogenMipmap)
|
||||||
|
|
@ -652,6 +666,7 @@ rasterUnlock(Raster *raster, int32 level)
|
||||||
|
|
||||||
rwFree(raster->pixels);
|
rwFree(raster->pixels);
|
||||||
raster->pixels = nil;
|
raster->pixels = nil;
|
||||||
|
CHECK_GL_ERROR("-rasterUnlock");
|
||||||
#endif
|
#endif
|
||||||
raster->width = raster->originalWidth;
|
raster->width = raster->originalWidth;
|
||||||
raster->height = raster->originalHeight;
|
raster->height = raster->originalHeight;
|
||||||
|
|
|
||||||
14
vendor/librw/src/gl/rwgl3.h
vendored
14
vendor/librw/src/gl/rwgl3.h
vendored
|
|
@ -18,6 +18,20 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
extern void re3_debug(const char *format, ...);
|
||||||
|
extern void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...);
|
||||||
|
#define CHECK_GL_ERROR(trace) do { \
|
||||||
|
int glerror = glGetError(); \
|
||||||
|
if (glerror != 0) { \
|
||||||
|
re3_trace(__FILE__, __LINE__, __FUNCTION__, "GL Error %x on %s", glerror, trace); \
|
||||||
|
} \
|
||||||
|
} while(0);
|
||||||
|
#else
|
||||||
|
#define CHECK_GL_ERROR(a)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
|
|
||||||
#ifdef RW_GL3
|
#ifdef RW_GL3
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue