Minor cleanup in texcache, fix some warnings

This commit is contained in:
Henrik Rydgard 2013-07-22 19:22:21 +02:00
parent eaf5cc169d
commit 9d76ba7dd2
5 changed files with 38 additions and 33 deletions

View file

@ -477,7 +477,7 @@ u32 scePsmfGetNumberOfSpecificStreams(u32 psmfStruct, int streamType)
WARN_LOG(HLE, "scePsmfGetNumberOfSpecificStreams(%08x, %08x)", psmfStruct, streamType); WARN_LOG(HLE, "scePsmfGetNumberOfSpecificStreams(%08x, %08x)", psmfStruct, streamType);
int streamNum = 0; int streamNum = 0;
int type = (streamType == PSMF_AUDIO_STREAM ? PSMF_ATRAC_STREAM : streamType); int type = (streamType == PSMF_AUDIO_STREAM ? PSMF_ATRAC_STREAM : streamType);
for (int i = psmf->streamMap.size() - 1; i >= 0; i--) { for (int i = (int)psmf->streamMap.size() - 1; i >= 0; i--) {
if (psmf->streamMap[i]->type == type) if (psmf->streamMap[i]->type == type)
streamNum++; streamNum++;
} }
@ -803,7 +803,7 @@ int _PsmfPlayerFillRingbuffer(PsmfPlayer *psmfplayer) {
size = std::min(psmfplayer->streamSize - psmfplayer->readSize, size); size = std::min(psmfplayer->streamSize - psmfplayer->readSize, size);
if (size <= 0) if (size <= 0)
break; break;
size = pspFileSystem.ReadFile(psmfplayer->filehandle, buf, size); size = (int)pspFileSystem.ReadFile(psmfplayer->filehandle, buf, size);
psmfplayer->readSize += size; psmfplayer->readSize += size;
psmfplayer->mediaengine->addStreamData(buf, size); psmfplayer->mediaengine->addStreamData(buf, size);
} while (size > 0); } while (size > 0);
@ -822,7 +822,7 @@ int _PsmfPlayerSetPsmfOffset(PsmfPlayer *psmfplayer, const char * filename, int
pspFileSystem.SeekFile(psmfplayer->filehandle, offset, FILEMOVE_BEGIN); pspFileSystem.SeekFile(psmfplayer->filehandle, offset, FILEMOVE_BEGIN);
u8* buf = psmfplayer->tempbuf; u8* buf = psmfplayer->tempbuf;
u32 tempbufSize = sizeof(psmfplayer->tempbuf); u32 tempbufSize = sizeof(psmfplayer->tempbuf);
int size = pspFileSystem.ReadFile(psmfplayer->filehandle, buf, 2048); int size = (int)pspFileSystem.ReadFile(psmfplayer->filehandle, buf, 2048);
int mpegoffset = bswap32(*(u32*)(buf + PSMF_STREAM_OFFSET_OFFSET)); int mpegoffset = bswap32(*(u32*)(buf + PSMF_STREAM_OFFSET_OFFSET));
psmfplayer->readSize = size - mpegoffset; psmfplayer->readSize = size - mpegoffset;
psmfplayer->streamSize = bswap32(*(u32*)(buf + PSMF_STREAM_SIZE_OFFSET)); psmfplayer->streamSize = bswap32(*(u32*)(buf + PSMF_STREAM_SIZE_OFFSET));

View file

@ -733,7 +733,7 @@ void TextureCache::StartFrame() {
} }
} }
static const u8 bitsPerPixel[11] = { static const u8 bitsPerPixel[16] = {
16, //GE_TFMT_5650, 16, //GE_TFMT_5650,
16, //GE_TFMT_5551, 16, //GE_TFMT_5551,
16, //GE_TFMT_4444, 16, //GE_TFMT_4444,
@ -745,6 +745,11 @@ static const u8 bitsPerPixel[11] = {
4, //GE_TFMT_DXT1, 4, //GE_TFMT_DXT1,
8, //GE_TFMT_DXT3, 8, //GE_TFMT_DXT3,
8, //GE_TFMT_DXT5, 8, //GE_TFMT_DXT5,
0, // INVALID,
0, // INVALID,
0, // INVALID,
0, // INVALID,
0, // INVALID,
}; };
static inline u32 MiniHash(const u32 *ptr) { static inline u32 MiniHash(const u32 *ptr) {
@ -783,7 +788,7 @@ static inline u32 QuickClutHash(const u8 *clut, u32 bytes) {
} }
static inline u32 QuickTexHash(u32 addr, int bufw, int w, int h, GETextureFormat format) { static inline u32 QuickTexHash(u32 addr, int bufw, int w, int h, GETextureFormat format) {
const u32 sizeInRAM = (bitsPerPixel[format < 11 ? format : 0] * bufw * h) / 8; const u32 sizeInRAM = (bitsPerPixel[format] * bufw * h) / 8;
const u32 *checkp = (const u32 *) Memory::GetPointer(addr); const u32 *checkp = (const u32 *) Memory::GetPointer(addr);
u32 check = 0; u32 check = 0;
@ -1136,7 +1141,7 @@ void TextureCache::SetTexture() {
// This would overestimate the size in many case so we underestimate instead // This would overestimate the size in many case so we underestimate instead
// to avoid excessive clearing caused by cache invalidations. // to avoid excessive clearing caused by cache invalidations.
entry->sizeInRAM = (bitsPerPixel[format < 11 ? format : 0] * bufw * h / 2) / 8; entry->sizeInRAM = (bitsPerPixel[format] * bufw * h / 2) / 8;
entry->fullhash = fullhash == 0 ? QuickTexHash(texaddr, bufw, w, h, format) : fullhash; entry->fullhash = fullhash == 0 ? QuickTexHash(texaddr, bufw, w, h, format) : fullhash;
entry->cluthash = cluthash; entry->cluthash = cluthash;
@ -1355,7 +1360,6 @@ void *TextureCache::DecodeTextureLevel(GETextureFormat format, GEPaletteFormat c
} }
} }
finalBuf = tmpTexBuf32.data(); finalBuf = tmpTexBuf32.data();
ConvertColors(finalBuf, finalBuf, dstFmt, bufw * h);
w = (w + 3) & ~3; w = (w + 3) & ~3;
} }
break; break;
@ -1378,11 +1382,10 @@ void *TextureCache::DecodeTextureLevel(GETextureFormat format, GEPaletteFormat c
} }
w = (w + 3) & ~3; w = (w + 3) & ~3;
finalBuf = tmpTexBuf32.data(); finalBuf = tmpTexBuf32.data();
ConvertColors(finalBuf, finalBuf, dstFmt, bufw * h);
} }
break; break;
case GE_TFMT_DXT5: // These work fine now case GE_TFMT_DXT5:
dstFmt = GL_UNSIGNED_BYTE; dstFmt = GL_UNSIGNED_BYTE;
{ {
int minw = std::min(bufw, w); int minw = std::min(bufw, w);
@ -1400,7 +1403,6 @@ void *TextureCache::DecodeTextureLevel(GETextureFormat format, GEPaletteFormat c
} }
w = (w + 3) & ~3; w = (w + 3) & ~3;
finalBuf = tmpTexBuf32.data(); finalBuf = tmpTexBuf32.data();
ConvertColors(finalBuf, finalBuf, dstFmt, bufw * h);
} }
break; break;
@ -1519,23 +1521,21 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level, bool replac
int h = 1 << ((gstate.texsize[level] >> 8) & 0xf); int h = 1 << ((gstate.texsize[level] >> 8) & 0xf);
gpuStats.numTexturesDecoded++; gpuStats.numTexturesDecoded++;
// Can restore these and remove the above fixup on some platforms.
// Can restore these and remove the fixup at the end of DecodeTextureLevel on desktop GL and GLES 3.
// glPixelStorei(GL_UNPACK_ROW_LENGTH, bufw); // glPixelStorei(GL_UNPACK_ROW_LENGTH, bufw);
// glPixelStorei(GL_PACK_ROW_LENGTH, bufw); // glPixelStorei(GL_PACK_ROW_LENGTH, bufw);
glPixelStorei(GL_UNPACK_ALIGNMENT, texByteAlign); glPixelStorei(GL_UNPACK_ALIGNMENT, texByteAlign);
glPixelStorei(GL_PACK_ALIGNMENT, texByteAlign); glPixelStorei(GL_PACK_ALIGNMENT, texByteAlign);
// INFO_LOG(G3D, "Creating texture level %i/%i from %08x: %i x %i (stride: %i). fmt: %i", level, entry.maxLevel, texaddr, w, h, bufw, entry.format);
u32 *pixelData = (u32 *)finalBuf;
int scaleFactor = g_Config.iTexScalingLevel; int scaleFactor = g_Config.iTexScalingLevel;
// Don't scale the PPGe texture. // Don't scale the PPGe texture.
if (entry.addr > 0x05000000 && entry.addr < 0x08800000) if (entry.addr > 0x05000000 && entry.addr < 0x08800000)
scaleFactor = 1; scaleFactor = 1;
u32 *pixelData = (u32 *)finalBuf;
if (scaleFactor > 1 && entry.numInvalidated == 0) if (scaleFactor > 1 && entry.numInvalidated == 0)
scaler.Scale(pixelData, dstFmt, w, h, scaleFactor); scaler.Scale(pixelData, dstFmt, w, h, scaleFactor);
// Or always? // Or always?
@ -1592,50 +1592,50 @@ bool TextureCache::DecodeTexture(u8* output, GPUgstate state)
switch (dstFmt) switch (dstFmt)
{ {
case GL_UNSIGNED_SHORT_4_4_4_4: case GL_UNSIGNED_SHORT_4_4_4_4:
for(int x = 0; x < h; x++) for(int y = 0; y < h; y++)
for(int y = 0; y < bufw; y++) for(int x = 0; x < bufw; x++)
{ {
u32 val = ((u16*)finalBuf)[x*bufw + y]; u32 val = ((u16*)finalBuf)[y*bufw + x];
u32 r = ((val>>12) & 0xF) * 17; u32 r = ((val>>12) & 0xF) * 17;
u32 g = ((val>> 8) & 0xF) * 17; u32 g = ((val>> 8) & 0xF) * 17;
u32 b = ((val>> 4) & 0xF) * 17; u32 b = ((val>> 4) & 0xF) * 17;
u32 a = ((val>> 0) & 0xF) * 17; u32 a = ((val>> 0) & 0xF) * 17;
((u32*)output)[x*w + y] = (a << 24) | (r << 16) | (g << 8) | b; ((u32*)output)[y*w + x] = (a << 24) | (r << 16) | (g << 8) | b;
} }
break; break;
case GL_UNSIGNED_SHORT_5_5_5_1: case GL_UNSIGNED_SHORT_5_5_5_1:
for(int x = 0; x < h; x++) for(int y = 0; y < h; y++)
for(int y = 0; y < bufw; y++) for(int x = 0; x < bufw; x++)
{ {
u32 val = ((u16*)finalBuf)[x*bufw + y]; u32 val = ((u16*)finalBuf)[y*bufw + x];
u32 r = Convert5To8((val>>11) & 0x1F); u32 r = Convert5To8((val>>11) & 0x1F);
u32 g = Convert5To8((val>> 6) & 0x1F); u32 g = Convert5To8((val>> 6) & 0x1F);
u32 b = Convert5To8((val>> 1) & 0x1F); u32 b = Convert5To8((val>> 1) & 0x1F);
u32 a = (val & 0x1) * 255; u32 a = (val & 0x1) * 255;
((u32*)output)[x*w + y] = (a << 24) | (r << 16) | (g << 8) | b; ((u32*)output)[y*w + x] = (a << 24) | (r << 16) | (g << 8) | b;
} }
break; break;
case GL_UNSIGNED_SHORT_5_6_5: case GL_UNSIGNED_SHORT_5_6_5:
for(int x = 0; x < h; x++) for(int y = 0; y < h; y++)
for(int y = 0; y < bufw; y++) for(int x = 0; x < bufw; x++)
{ {
u32 val = ((u16*)finalBuf)[x*bufw + y]; u32 val = ((u16*)finalBuf)[y*bufw + x];
u32 a = 0xFF; u32 a = 0xFF;
u32 r = Convert5To8((val>>11) & 0x1F); u32 r = Convert5To8((val>>11) & 0x1F);
u32 g = Convert6To8((val>> 5) & 0x3F); u32 g = Convert6To8((val>> 5) & 0x3F);
u32 b = Convert5To8((val ) & 0x1F); u32 b = Convert5To8((val ) & 0x1F);
((u32*)output)[x*w + y] = (a << 24) | (r << 16) | (g << 8) | b; ((u32*)output)[y*w + x] = (a << 24) | (r << 16) | (g << 8) | b;
} }
break; break;
default: default:
for(int x = 0; x < h; x++) for(int y = 0; y < h; y++)
for(int y = 0; y < bufw; y++) for(int x = 0; x < bufw; x++)
{ {
u32 val = ((u32*)finalBuf)[x*bufw + y]; u32 val = ((u32*)finalBuf)[y*bufw + x];
((u32*)output)[x*w + y] = ((val & 0xFF000000)) | ((val & 0x00FF0000)>>16) | ((val & 0x0000FF00)) | ((val & 0x000000FF)<<16); ((u32*)output)[y*w + x] = ((val & 0xFF000000)) | ((val & 0x00FF0000)>>16) | ((val & 0x0000FF00)) | ((val & 0x000000FF)<<16);
} }
break; break;
} }

View file

@ -1751,7 +1751,7 @@ void KeyMappingScreen::render() {
if (UIButton(GEN_ID, Pos(10, dp_yres-10), LARGE_BUTTON_WIDTH, 0, generalI18N->T("Prev"), ALIGN_BOTTOMLEFT)) { if (UIButton(GEN_ID, Pos(10, dp_yres-10), LARGE_BUTTON_WIDTH, 0, generalI18N->T("Prev"), ALIGN_BOTTOMLEFT)) {
currentMap_--; currentMap_--;
if (currentMap_ < 0) if (currentMap_ < 0)
currentMap_ = controllerMaps.size() - 1; currentMap_ = (int)controllerMaps.size() - 1;
} }
if (UIButton(GEN_ID, Pos(10 + 10 + LARGE_BUTTON_WIDTH, dp_yres-10), LARGE_BUTTON_WIDTH, 0, generalI18N->T("Next"), ALIGN_BOTTOMLEFT)) { if (UIButton(GEN_ID, Pos(10 + 10 + LARGE_BUTTON_WIDTH, dp_yres-10), LARGE_BUTTON_WIDTH, 0, generalI18N->T("Next"), ALIGN_BOTTOMLEFT)) {
currentMap_++; currentMap_++;

View file

@ -69,6 +69,11 @@ UI::EventReturn PromptScreen::OnNo(UI::EventParams &e) {
} }
NewLanguageScreen::NewLanguageScreen() : ListPopupScreen("Language") { NewLanguageScreen::NewLanguageScreen() : ListPopupScreen("Language") {
// Disable annoying encoding warning
#ifdef _MSC_VER
#pragma warning(disable:4566)
#endif
langValuesMapping["ja_JP"] = std::make_pair("日本語", PSP_SYSTEMPARAM_LANGUAGE_JAPANESE); langValuesMapping["ja_JP"] = std::make_pair("日本語", PSP_SYSTEMPARAM_LANGUAGE_JAPANESE);
langValuesMapping["en_US"] = std::make_pair("English",PSP_SYSTEMPARAM_LANGUAGE_ENGLISH); langValuesMapping["en_US"] = std::make_pair("English",PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
langValuesMapping["fr_FR"] = std::make_pair("Français", PSP_SYSTEMPARAM_LANGUAGE_FRENCH); langValuesMapping["fr_FR"] = std::make_pair("Français", PSP_SYSTEMPARAM_LANGUAGE_FRENCH);

2
native

@ -1 +1 @@
Subproject commit dd99cfbbe808a62528cfb2f51864ad596812c1f6 Subproject commit ee0f3848272b6eb5446b468a1c55868e3b3c455c