Fix textures on VC4

This commit is contained in:
Shinovon 2026-04-29 13:17:43 +05:00
parent 3eb71f2cc5
commit d5a130fc29
5 changed files with 78 additions and 31 deletions

View file

@ -28,6 +28,7 @@
float texLoadTime;
int32 texNumLoaded;
#ifdef __SYMBIAN32__
static RwImage* resizeImage(RwImage *image, int newWidth, int newHeight)
{
image->convertTo32();
@ -84,9 +85,9 @@ static RwImage* resizeImage(RwImage *image, int newWidth, int newHeight)
}
static int clamp(int32 size)
static int clamp(int size, int targetSize)
{
while (size > 32 && size > 1) {
while (size > targetSize && size > 1) {
size = (size + 1) / 2;
}
return size;
@ -97,13 +98,16 @@ static void downscaleTexture(RwTexture *texture)
RwRaster *oldRaster = RwTextureGetRaster(texture);
if (oldRaster == nil)
return;
extern bool moreVram;
int targetSize = moreVram ? 64 : 32;
int oldWidth = RwRasterGetWidth(oldRaster);
int oldHeight = RwRasterGetHeight(oldRaster);
if (oldWidth <= 32 && oldHeight <= 32) return;
if (oldWidth <= targetSize && oldHeight <= targetSize) return;
int newWidth = clamp(oldWidth);
int newHeight = clamp(oldHeight);
int newWidth = clamp(oldWidth, targetSize);
int newHeight = clamp(oldHeight, targetSize);
if (newWidth == oldWidth && newHeight == oldHeight) return;
RwImage *image = oldRaster->toImage();
@ -120,6 +124,7 @@ static void downscaleTexture(RwTexture *texture)
RwTextureSetRaster(texture, newRaster);
RwRasterDestroy(oldRaster);
}
#endif
#ifdef LIBRW
#define READNATIVE(stream, tex, size) rwNativeTextureHackRead(stream, tex, size)
@ -490,11 +495,13 @@ CreateTxdImageForVideoCard()
sprintf(filename, "%s.txd", CTxdStore::GetTxdName(i));
if (CTxdStore::GetSlot(i)->texDict) {
#ifdef __SYMBIAN32__
RwTexDictionary *texDict = CTxdStore::GetSlot(i)->texDict;
FORLIST(lnk, texDict->textures){
rw::Texture *texture = rw::Texture::fromDict(lnk);
downscaleTexture(texture);
}
#endif
int32 pos = STREAMTELL(img);
if (RwTexDictionaryStreamWrite(CTxdStore::GetSlot(i)->texDict, img) == nil) {