diff options
| author | hrydgard <hrydgard@gmail.com> | 2009-02-09 20:35:30 +0000 |
|---|---|---|
| committer | hrydgard <hrydgard@gmail.com> | 2009-02-09 20:35:30 +0000 |
| commit | d209d4a577ccaade93ecde00fe37c68741602948 (patch) | |
| tree | fda0b26c61afb729a17dd1e3a52bc3eb996bdad4 /Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp | |
| parent | 5edef947536c1dc7aef41603530ad9b5545cd4f0 (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/Core/VideoCommon/Src/VertexLoader_Normal.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp | 62 |
1 files changed, 18 insertions, 44 deletions
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); |
