Cache vertex array pointers, a la magumagu's idea. Misc other stuff. Should give very minor speed boost.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2185 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-02-09 20:35:30 +00:00
parent 5edef94753
commit d209d4a577
12 changed files with 132 additions and 176 deletions

View File

@ -214,8 +214,8 @@ void CJitWindow::Compare(u32 em_address)
sptr += sprintf(sptr, "%i estimated cycles\n", st.numCycles);
sptr += sprintf(sptr, "Num instr: PPC: %i x86: %i (blowup: %i%%)\n", size, num_x86_instructions, 100 * num_x86_instructions / size);
sptr += sprintf(sptr, "Num bytes: PPC: %i x86: %i (blowup: %i%%)\n", size * 4, block->codeSize, 100 * block->codeSize / (4 * size));
sptr += sprintf(sptr, "Num instr: PPC: %i x86: %i (blowup: %i%%)\n", size, num_x86_instructions, 100 * (num_x86_instructions / size - 1));
sptr += sprintf(sptr, "Num bytes: PPC: %i x86: %i (blowup: %i%%)\n", size * 4, block->codeSize, 100 * (block->codeSize / (4 * size) - 1));
ppc_box->SetValue(wxString::FromAscii((char*)xDis));
} else {

View File

@ -21,6 +21,7 @@
// CP state
// STATE_TO_SAVE
u32 arraybases[16];
u8 *cached_arraybases[16];
u32 arraystrides[16];
TMatrixIndexA MatrixIndexA;
TMatrixIndexB MatrixIndexB;

View File

@ -244,6 +244,7 @@ union TMatrixIndexB
#pragma pack()
extern u32 arraybases[16];
extern u8 *cached_arraybases[16];
extern u32 arraystrides[16];
extern TMatrixIndexA MatrixIndexA;
extern TMatrixIndexB MatrixIndexB;

View File

@ -702,7 +702,7 @@ void VertexLoader::SetVAT(u32 _group0, u32 _group1, u32 _group2)
void VertexLoader::AppendToString(std::string *dest)
{
dest->reserve(150);
dest->reserve(250);
static const char *posMode[4] = {
"Inv",
"Dir",
@ -712,12 +712,32 @@ void VertexLoader::AppendToString(std::string *dest)
static const char *posFormats[5] = {
"u8", "s8", "u16", "s16", "flt",
};
dest->append(StringFromFormat("%ib skin: %i P: %i %s %s ",
static const char *colorFormat[8] = {
"565",
"888",
"888x",
"4444",
"6666",
"8888",
"Inv",
"Inv",
};
dest->append(StringFromFormat("%ib skin: %i P: %i %s-%s ",
m_VertexSize, m_VtxDesc.PosMatIdx,
m_VtxAttr.PosElements ? 3 : 2, posMode[m_VtxDesc.Position], posFormats[m_VtxAttr.PosFormat]));
dest->append(StringFromFormat("Nrm: %i %s %s ",
if (m_VtxDesc.Normal) {
dest->append(StringFromFormat("Nrm: %i %s-%s ",
m_VtxAttr.NormalElements, posMode[m_VtxDesc.Normal], posFormats[m_VtxAttr.NormalFormat]));
}
int color_mode[2] = {m_VtxDesc.Color0, m_VtxDesc.Color1};
for (int i = 0; i < 2; i++)
{
if (color_mode[i])
{
dest->append(StringFromFormat("C%i: %i %s-%s ", i, m_VtxAttr.color[i].Elements, posMode[color_mode[i]], colorFormat[m_VtxAttr.color[i].Comp]));
}
}
int tex_mode[8] = {
m_VtxDesc.Tex0Coord, m_VtxDesc.Tex1Coord, m_VtxDesc.Tex2Coord, m_VtxDesc.Tex3Coord,
m_VtxDesc.Tex4Coord, m_VtxDesc.Tex5Coord, m_VtxDesc.Tex6Coord, m_VtxDesc.Tex7Coord
@ -726,7 +746,7 @@ void VertexLoader::AppendToString(std::string *dest)
{
if (tex_mode[i])
{
dest->append(StringFromFormat("T%i: %i %s %s ",
dest->append(StringFromFormat("T%i: %i %s-%s ",
i, m_VtxAttr.texCoord[i].Elements, posMode[tex_mode[i]], posFormats[m_VtxAttr.texCoord[i].Format]));
}
}

View File

@ -34,4 +34,6 @@ namespace VertexLoaderManager
void AppendListToString(std::string *dest);
};
void RecomputeCachedArraybases();
#endif // _VERTEXLOADERMANAGER_H

View File

@ -67,23 +67,14 @@ void _SetCol565(u16 val)
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
inline u32 _Read24(u32 iAddress)
inline u32 _Read24(const u8 *iAddress)
{
// u32 col = Memory_Read_U8(iAddress) << RSHIFT; //should just get a pointer to main memory instead of going thru slow memhandler
// col |= Memory_Read_U8(iAddress+1) << GSHIFT; //we can guarantee that it is reading from main memory
// col |= Memory_Read_U8(iAddress+2) << BSHIFT;
// return col | (0xFF<<ASHIFT);
return Memory_Read_U32_Unswapped(iAddress)|0xFF000000;
return *(const u32 *)iAddress | 0xFF000000;
}
inline u32 _Read32(u32 iAddress)
inline u32 _Read32(const u8 *iAddress)
{
// u32 col = Memory_Read_U8(iAddress) << RSHIFT; //should just get a pointer to main memory instead of going thru slow memhandler
// col |= Memory_Read_U8(iAddress+1) << GSHIFT; //we can guarantee that it is reading from main memory
// col |= Memory_Read_U8(iAddress+2) << BSHIFT;
// col |= Memory_Read_U8(iAddress+3) << ASHIFT;
// return col;
return Memory_Read_U32_Unswapped(iAddress);
return *(const u32 *)iAddress;
}
//////////////////////////////////////////////////////////////////////////
@ -147,46 +138,38 @@ void LOADERDECL Color_ReadDirect_32b_8888()
void LOADERDECL Color_ReadIndex8_16b_565()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])));
_SetCol565(val);
}
void LOADERDECL Color_ReadIndex8_24b_888()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
const u8 *iAddress = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex8_32b_888x()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR]+colIndex);
const u8 *iAddress = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR]+colIndex);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex8_16b_4444()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])));
_SetCol4444(val);
}
void LOADERDECL Color_ReadIndex8_24b_6666()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8* pData = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u32 val = *(pData+2) | ((*(pData+1))<<8) | ((*pData)<<16);
//u32 val = Memory_Read_U8(iAddress+2) |
// (Memory_Read_U8(iAddress+1)<<8) |
// (Memory_Read_U8(iAddress)<<16);
_SetCol6666(val);
}
void LOADERDECL Color_ReadIndex8_32b_8888()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
const u8 *iAddress = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read32(iAddress));
}
//////////////////////////////////////////////////////////////////////////
@ -195,46 +178,39 @@ void LOADERDECL Color_ReadIndex8_32b_8888()
void LOADERDECL Color_ReadIndex16_16b_565()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])));
_SetCol565(val);
}
void LOADERDECL Color_ReadIndex16_24b_888()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
const u8 *iAddress = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex16_32b_888x()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
const u8 *iAddress = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read24(iAddress));
}
void LOADERDECL Color_ReadIndex16_16b_4444()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u16 val = Memory_Read_U16(iAddress);
u16 val = Common::swap16(*(const u16 *)(cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex])));
_SetCol4444(val);
}
void LOADERDECL Color_ReadIndex16_24b_6666()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8 *iAddress = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
const u8* pData = iAddress;
u32 val = *(pData+2) | ((*(pData+1))<<8) | ((*pData)<<16);
//u32 val = Memory_Read_U8(iAddress+2) |
// (Memory_Read_U8(iAddress+1)<<8) |
// (Memory_Read_U8(iAddress)<<16);
_SetCol6666(val);
}
void LOADERDECL Color_ReadIndex16_32b_8888()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
const u8 *iAddress = cached_arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
_SetCol(_Read32(iAddress));
}

View File

@ -183,8 +183,7 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectFloat3()
void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8* pData = cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
*VertexManager::s_pCurBufferPointer++ = *(pData); //Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = *(pData+1); //Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = *(pData+2); //Memory_Read_U8(iAddress+2);
@ -199,8 +198,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte()
void LOADERDECL VertexLoader_Normal::Normal_Index8_Short()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(*pData); //Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(*(pData+1)); //Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(*(pData+2)); //Memory_Read_U16(iAddress+4);
@ -211,8 +209,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Short()
void LOADERDECL VertexLoader_Normal::Normal_Index8_Float()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32* pData = (const u32 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*pData); //Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1)); //Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Common::swap32(*(pData+2)); //Memory_Read_U32(iAddress+8);
@ -223,12 +220,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Float()
void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices1()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8* pData = cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
for (int i = 0; i < 3; i++)
{
//u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = *(pData + 3*i); //Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = *(pData + 3*i + 1); //Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = *(pData + 3*i + 2); //Memory_Read_U8(iAddress+2);
@ -240,12 +234,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices1()
void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices1()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
for (int i = 0; i < 3; i++)
{
//u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(*(pData + 3*i)); //Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(*(pData + 3*i + 1)); //Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(*(pData + 3*i + 2)); //Memory_Read_U16(iAddress+4);
@ -257,11 +248,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices1()
void LOADERDECL VertexLoader_Normal::Normal_Index8_Float3_Indices1()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32* pData = (const u32 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
for (int i = 0; i < 3; i++)
{
//u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData + 3*i)); //Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData + 3*i + 1)); //Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Common::swap32(*(pData + 3*i + 2)); //Memory_Read_U32(iAddress+8);
@ -275,8 +264,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices3()
for (int i = 0; i < 3; i++)
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8* pData = cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = *(pData); //Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = *(pData+1); //Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = *(pData+2); //Memory_Read_U8(iAddress+2);
@ -290,8 +278,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices3()
for (int i = 0; i < 3; i++)
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i);
((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(*(pData)); //Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(*(pData+1)); //Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(*(pData+2)); //Memory_Read_U16(iAddress+4);
@ -305,8 +292,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Float3_Indices3()
for (int i = 0; i < 3; i++)
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32* pData = (const u32 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData)); //Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1)); //Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Common::swap32(*(pData+2)); //Memory_Read_U32(iAddress+8);
@ -322,8 +308,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Float3_Indices3()
void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8* pData = cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
*VertexManager::s_pCurBufferPointer++ = *(pData); //Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = *(pData+1); //Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = *(pData+2); //Memory_Read_U8(iAddress+2);
@ -334,8 +319,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte()
void LOADERDECL VertexLoader_Normal::Normal_Index16_Short()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(*(pData));//Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(*(pData+1));//Memory_Read_U16(iAddress+2);
@ -347,8 +331,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Short()
void LOADERDECL VertexLoader_Normal::Normal_Index16_Float()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32* pData = (const u32 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData));//Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1));//Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Common::swap32(*(pData+2));//Memory_Read_U32(iAddress+8);
@ -359,11 +342,9 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Float()
void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8* pData = cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
for (int i = 0; i < 3; i++)
{
//u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = *(pData + 3*i); //Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = *(pData + 3*i + 1); //Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = *(pData + 3*i + 2); //Memory_Read_U8(iAddress+2);
@ -375,12 +356,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices1()
void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
for (int i = 0; i < 3; i++)
{
//u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(*(pData + 3*i)); //Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(*(pData + 3*i + 1)); //Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(*(pData + 3*i + 2)); //Memory_Read_U16(iAddress+4);
@ -392,12 +371,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices1()
void LOADERDECL VertexLoader_Normal::Normal_Index16_Float3_Indices1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32* pData = (const u32 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
for (int i = 0; i < 3; i++)
{
//u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData + 3*i)); //Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData + 3*i + 1)); //Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Common::swap32(*(pData + 3*i + 2)); //Memory_Read_U32(iAddress+8);
@ -411,8 +388,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices3()
for (int i = 0; i < 3; i++)
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8* pData = cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = *(pData); //Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = *(pData+1); //Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = *(pData+2); //Memory_Read_U8(iAddress+2);
@ -426,8 +402,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices3()
for (int i = 0; i < 3; i++)
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i);
((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(*(pData)); //Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(*(pData+1)); //Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(*(pData+2)); //Memory_Read_U16(iAddress+4);
@ -442,8 +417,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Float3_Indices3()
for (int i = 0; i < 3; i++)
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32* pData = (const u32 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData)); //Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1)); //Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Common::swap32(*(pData+2)); //Memory_Read_U32(iAddress+8);

View File

@ -138,8 +138,7 @@ void LOADERDECL Pos_ReadDirect_Float()
}
#define Pos_ReadIndex_Byte(T) { \
u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \
u8* pData = Memory_Read_U8_Ptr(iAddress); \
const u8* pData = cached_arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]);\
((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)(*(pData))) * posScale; \
((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)(*(pData+1))) * posScale; \
if (pVtxAttr->PosElements) \
@ -151,8 +150,7 @@ void LOADERDECL Pos_ReadDirect_Float()
}
#define Pos_ReadIndex_Short(T) { \
u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress); \
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION])); \
((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)Common::swap16(*(pData))) * posScale; \
((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)Common::swap16(*(pData+1))) * posScale;\
if (pVtxAttr->PosElements) \
@ -164,8 +162,7 @@ void LOADERDECL Pos_ReadDirect_Float()
}
#define Pos_ReadIndex_Float() { \
u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]); \
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress); \
const u32* pData = (const u32 *)(cached_arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION])); \
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData)); \
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1)); \
if (pVtxAttr->PosElements) \

View File

@ -119,9 +119,8 @@ void LOADERDECL TexCoord_ReadDirect_Float2()
void LOADERDECL TexCoord_ReadIndex8_UByte1()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(*pData) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -129,9 +128,7 @@ void LOADERDECL TexCoord_ReadIndex8_UByte1()
void LOADERDECL TexCoord_ReadIndex8_UByte2()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -142,9 +139,9 @@ void LOADERDECL TexCoord_ReadIndex8_UByte2()
void LOADERDECL TexCoord_ReadIndex8_Byte1()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)(*pData) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -152,9 +149,7 @@ void LOADERDECL TexCoord_ReadIndex8_Byte1()
void LOADERDECL TexCoord_ReadIndex8_Byte2()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -165,9 +160,8 @@ void LOADERDECL TexCoord_ReadIndex8_Byte2()
void LOADERDECL TexCoord_ReadIndex8_UShort1()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
const u16 *pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Common::swap16(*pData) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -175,9 +169,7 @@ void LOADERDECL TexCoord_ReadIndex8_UShort1()
void LOADERDECL TexCoord_ReadIndex8_UShort2()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16 *pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Common::swap16(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Common::swap16(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -188,9 +180,8 @@ void LOADERDECL TexCoord_ReadIndex8_UShort2()
void LOADERDECL TexCoord_ReadIndex8_Short1()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
const u16 *pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Common::swap16(*(pData)) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -198,9 +189,7 @@ void LOADERDECL TexCoord_ReadIndex8_Short1()
void LOADERDECL TexCoord_ReadIndex8_Short2()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16 *pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Common::swap16(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Common::swap16(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -211,8 +200,8 @@ void LOADERDECL TexCoord_ReadIndex8_Short2()
void LOADERDECL TexCoord_ReadIndex8_Float1()
{
u16 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
const u32 *pData = (const u32 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData));
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -220,9 +209,7 @@ void LOADERDECL TexCoord_ReadIndex8_Float1()
void LOADERDECL TexCoord_ReadIndex8_Float2()
{
u16 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32 *pData = (const u32 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData));
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1));
LOG_TEX2();
@ -234,9 +221,8 @@ void LOADERDECL TexCoord_ReadIndex8_Float2()
void LOADERDECL TexCoord_ReadIndex16_UByte1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)(*(pData)) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -244,9 +230,7 @@ void LOADERDECL TexCoord_ReadIndex16_UByte1()
void LOADERDECL TexCoord_ReadIndex16_UByte2()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -257,9 +241,8 @@ void LOADERDECL TexCoord_ReadIndex16_UByte2()
void LOADERDECL TexCoord_ReadIndex16_Byte1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)(*(pData)) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -267,9 +250,7 @@ void LOADERDECL TexCoord_ReadIndex16_Byte1()
void LOADERDECL TexCoord_ReadIndex16_Byte2()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u8* pData = Memory_Read_U8_Ptr(iAddress);
const u8 *pData = cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -280,9 +261,8 @@ void LOADERDECL TexCoord_ReadIndex16_Byte2()
void LOADERDECL TexCoord_ReadIndex16_UShort1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Common::swap16(*(pData)) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -290,9 +270,7 @@ void LOADERDECL TexCoord_ReadIndex16_UShort1()
void LOADERDECL TexCoord_ReadIndex16_UShort2()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16* pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Common::swap16(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Common::swap16(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -303,9 +281,8 @@ void LOADERDECL TexCoord_ReadIndex16_UShort2()
void LOADERDECL TexCoord_ReadIndex16_Short1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
const u16 *pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Common::swap16(*pData) * tcScale[tcIndex];
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -313,9 +290,7 @@ void LOADERDECL TexCoord_ReadIndex16_Short1()
void LOADERDECL TexCoord_ReadIndex16_Short2()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
const u16 *pData = (const u16 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Common::swap16(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Common::swap16(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
@ -326,9 +301,8 @@ void LOADERDECL TexCoord_ReadIndex16_Short2()
void LOADERDECL TexCoord_ReadIndex16_Float1()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
const u32 *pData = (const u32 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData));
LOG_TEX1();
VertexManager::s_pCurBufferPointer += 4;
tcIndex++;
@ -336,9 +310,7 @@ void LOADERDECL TexCoord_ReadIndex16_Float1()
void LOADERDECL TexCoord_ReadIndex16_Float2()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
const u32 *pData = (const u32 *)(cached_arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]));
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData));
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1));
LOG_TEX2();

View File

@ -17,6 +17,7 @@
#include <map>
#include "VideoCommon.h"
#include "Statistics.h"
#include "VertexShaderManager.h"
@ -145,7 +146,8 @@ void LoadCPReg(u32 sub_cmd, u32 value)
// Pointers to vertex arrays in GC RAM
case 0xA0:
arraybases[sub_cmd & 0xF] = value & 0xFFFFFFFF; // huh, why the mask?
arraybases[sub_cmd & 0xF] = value;
cached_arraybases[sub_cmd & 0xF] = Memory_GetPtr(value);
break;
case 0xB0:
@ -153,3 +155,11 @@ void LoadCPReg(u32 sub_cmd, u32 value)
break;
}
}
void RecomputeCachedArraybases()
{
for (int i = 0; i < 16; i++)
{
cached_arraybases[i] = Memory_GetPtr(arraybases[i]);
}
}

View File

@ -254,7 +254,10 @@ void DoState(unsigned char **ptr, int mode) {
// Refresh state.
if (mode == PointerWrap::MODE_READ)
{
BPReload();
RecomputeCachedArraybases();
}
}
// This is called after Video_Initialize() from the Core