summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-02-09 20:35:30 +0000
committerhrydgard <hrydgard@gmail.com>2009-02-09 20:35:30 +0000
commitd209d4a577ccaade93ecde00fe37c68741602948 (patch)
treefda0b26c61afb729a17dd1e3a52bc3eb996bdad4 /Source
parent5edef947536c1dc7aef41603530ad9b5545cd4f0 (diff)
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
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/Src/HW/MemmapFunctions.cpp4
-rw-r--r--Source/Core/DebuggerWX/Src/JitWindow.cpp6
-rw-r--r--Source/Core/VideoCommon/Src/CPMemory.cpp1
-rw-r--r--Source/Core/VideoCommon/Src/CPMemory.h1
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader.cpp36
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoaderManager.h2
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader_Color.cpp82
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp62
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader_Position.cpp9
-rw-r--r--Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp88
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp12
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/main.cpp5
12 files changed, 132 insertions, 176 deletions
diff --git a/Source/Core/Core/Src/HW/MemmapFunctions.cpp b/Source/Core/Core/Src/HW/MemmapFunctions.cpp
index 9e49c98d20..50db4dc741 100644
--- a/Source/Core/Core/Src/HW/MemmapFunctions.cpp
+++ b/Source/Core/Core/Src/HW/MemmapFunctions.cpp
@@ -265,7 +265,7 @@ u32 Read_U32(const u32 _Address)
if (mc)
{
mc->numHits++;
- mc->Action(_var, _Address,false,4,PC);
+ mc->Action(_var, _Address, false, 4, PC);
}
#endif
return _var;
@@ -281,7 +281,7 @@ u64 Read_U64(const u32 _Address)
if (mc)
{
mc->numHits++;
- mc->Action((u32)_var, _Address,false,8,PC);
+ mc->Action((u32)_var, _Address, false, 8, PC);
}
#endif
return _var;
diff --git a/Source/Core/DebuggerWX/Src/JitWindow.cpp b/Source/Core/DebuggerWX/Src/JitWindow.cpp
index 77c6d26770..63afb0c228 100644
--- a/Source/Core/DebuggerWX/Src/JitWindow.cpp
+++ b/Source/Core/DebuggerWX/Src/JitWindow.cpp
@@ -214,13 +214,13 @@ 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 {
ppc_box->SetValue(wxString::FromAscii(StringFromFormat("(non-code address: %08x)", em_address).c_str()));
- x86_box->SetValue(wxString::FromAscii("---"));
+ x86_box->SetValue(wxString::FromAscii("---"));
}
diff --git a/Source/Core/VideoCommon/Src/CPMemory.cpp b/Source/Core/VideoCommon/Src/CPMemory.cpp
index 32cd4f0b32..a51c2d1454 100644
--- a/Source/Core/VideoCommon/Src/CPMemory.cpp
+++ b/Source/Core/VideoCommon/Src/CPMemory.cpp
@@ -21,6 +21,7 @@
// CP state
// STATE_TO_SAVE
u32 arraybases[16];
+u8 *cached_arraybases[16];
u32 arraystrides[16];
TMatrixIndexA MatrixIndexA;
TMatrixIndexB MatrixIndexB;
diff --git a/Source/Core/VideoCommon/Src/CPMemory.h b/Source/Core/VideoCommon/Src/CPMemory.h
index 62a5fa118d..af5be4952f 100644
--- a/Source/Core/VideoCommon/Src/CPMemory.h
+++ b/Source/Core/VideoCommon/Src/CPMemory.h
@@ -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;
diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp
index e3abb2d3ef..65be39a539 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp
@@ -702,22 +702,42 @@ 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",
- "I8 ",
+ "I8",
"I16",
};
static const char *posFormats[5] = {
- "u8 ", "s8 ", "u16", "s16", "flt",
+ "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 ",
- m_VtxAttr.NormalElements, posMode[m_VtxDesc.Normal], posFormats[m_VtxAttr.NormalFormat]));
-
+ 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]));
}
}
diff --git a/Source/Core/VideoCommon/Src/VertexLoaderManager.h b/Source/Core/VideoCommon/Src/VertexLoaderManager.h
index 1061d85480..e6313f1f80 100644
--- a/Source/Core/VideoCommon/Src/VertexLoaderManager.h
+++ b/Source/Core/VideoCommon/Src/VertexLoaderManager.h
@@ -34,4 +34,6 @@ namespace VertexLoaderManager
void AppendListToString(std::string *dest);
};
+void RecomputeCachedArraybases();
+
#endif // _VERTEXLOADERMANAGER_H
diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp
index 5dbeae4750..16b8bb2a3b 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader_Color.cpp
@@ -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;
}
//////////////////////////////////////////////////////////////////////////
@@ -91,17 +82,17 @@ inline u32 _Read32(u32 iAddress)
void LOADERDECL Color_ReadDirect_24b_888()
{
- u32 col = DataReadU8()<<RSHIFT;
- col |= DataReadU8()<<GSHIFT;
- col |= DataReadU8()<<BSHIFT;
- _SetCol(col | (0xFF<<ASHIFT));
+ u32 col = DataReadU8() << RSHIFT;
+ col |= DataReadU8() << GSHIFT;
+ col |= DataReadU8() << BSHIFT;
+ _SetCol(col | (0xFF << ASHIFT));
}
void LOADERDECL Color_ReadDirect_32b_888x(){
- u32 col = DataReadU8()<<RSHIFT;
- col |= DataReadU8()<<GSHIFT;
- col |= DataReadU8()<<BSHIFT;
- _SetCol(col | (0xFF<<ASHIFT));
+ u32 col = DataReadU8() << RSHIFT;
+ col |= DataReadU8() << GSHIFT;
+ col |= DataReadU8() << BSHIFT;
+ _SetCol(col | (0xFF << ASHIFT));
DataReadU8();
}
void LOADERDECL Color_ReadDirect_16b_565()
@@ -131,13 +122,13 @@ void LOADERDECL Color_ReadDirect_32b_8888()
{
// TODO (mb2): check this
u32 col = DataReadU8()<<RSHIFT;
- col |= DataReadU8()<<GSHIFT;
- col |= DataReadU8()<<BSHIFT;
- col |= DataReadU8()<<ASHIFT;
+ col |= DataReadU8()<<GSHIFT;
+ col |= DataReadU8()<<BSHIFT;
+ col |= DataReadU8()<<ASHIFT;
// "kill" the alpha
if (!colElements[colIndex])
- col |= 0xFF<<ASHIFT;
+ col |= 0xFF << ASHIFT;
_SetCol(col);
}
@@ -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));
}
diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp
index df5975c31e..75fb9aef74 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp
@@ -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);
diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp
index 922d1d4db5..44d15ccc23 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp
@@ -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) \
diff --git a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp
index 1015049097..e277ca17ca 100644
--- a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp
+++ b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp
@@ -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();
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp
index 897e387207..88b1ec18b7 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoaderManager.cpp
@@ -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]);
+ }
+}
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp
index 119589ceff..4a24ad52fe 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp
@@ -253,8 +253,11 @@ void DoState(unsigned char **ptr, int mode) {
VideoCommon_DoState(p);
// Refresh state.
- if (mode == PointerWrap::MODE_READ)
+ if (mode == PointerWrap::MODE_READ)
+ {
BPReload();
+ RecomputeCachedArraybases();
+ }
}
// This is called after Video_Initialize() from the Core