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<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 +#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