diff options
| author | hyperiris <hyperiris@gmail.com> | 2009-02-08 13:08:58 +0000 |
|---|---|---|
| committer | hyperiris <hyperiris@gmail.com> | 2009-02-08 13:08:58 +0000 |
| commit | c450e44b084d3edc2d9a5340e14f065eb4116437 (patch) | |
| tree | 6daa0a487cf6f859ce3300e5ee2b7e87ae801802 /Source/Core/VideoCommon/Src/VertexLoader_Position.cpp | |
| parent | 5045119da32f56b09d6dc66d56eabee5e09e44a9 (diff) | |
optimize memory access. reduce Memory_Read_U##_type call(it uses Memory::GetPointer, which is complex), and gain speed, may be 1 or more fps faster, I've tested on zelda tww,tp, starfox assault only.
Please review and may be the code need clean.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2144 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/VertexLoader_Position.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexLoader_Position.cpp | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp index 2a9d4bcb09..922d1d4db5 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader_Position.cpp @@ -137,40 +137,43 @@ void LOADERDECL Pos_ReadDirect_Float() VertexManager::s_pCurBufferPointer += 12; } -#define Pos_ReadIndex_Byte(T) { \ - u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ - ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)Memory_Read_U8(iAddress)) * posScale; \ - ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)Memory_Read_U8(iAddress+1)) * posScale; \ - if (pVtxAttr->PosElements) \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)Memory_Read_U8(iAddress+2)) * posScale; \ - else \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ - LOG_VTX(); \ - VertexManager::s_pCurBufferPointer += 12; \ -} - -#define Pos_ReadIndex_Short(T) { \ - u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ - ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)Memory_Read_U16(iAddress)) * posScale; \ - ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)Memory_Read_U16(iAddress+2)) * posScale; \ - if (pVtxAttr->PosElements) \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)Memory_Read_U16(iAddress+4)) * posScale; \ - else \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ - LOG_VTX(); \ - VertexManager::s_pCurBufferPointer += 12; \ -} - -#define Pos_ReadIndex_Float() { \ +#define Pos_ReadIndex_Byte(T) { \ + u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ + u8* pData = Memory_Read_U8_Ptr(iAddress); \ + ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)(*(pData))) * posScale; \ + ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)(*(pData+1))) * posScale; \ + if (pVtxAttr->PosElements) \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)(*(pData+2))) * posScale; \ + else \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ + LOG_VTX(); \ + VertexManager::s_pCurBufferPointer += 12; \ +} + +#define Pos_ReadIndex_Short(T) { \ + u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ + u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress); \ + ((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) \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)Common::swap16(*(pData+2))) * posScale;\ + else \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ + LOG_VTX(); \ + VertexManager::s_pCurBufferPointer += 12; \ +} + +#define Pos_ReadIndex_Float() { \ u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]); \ - ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); \ - ((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4); \ - if (pVtxAttr->PosElements) \ - ((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8); \ - else \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ - LOG_VTX(); \ - VertexManager::s_pCurBufferPointer += 12; \ + u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress); \ + ((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData)); \ + ((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1)); \ + if (pVtxAttr->PosElements) \ + ((u32*)VertexManager::s_pCurBufferPointer)[2] = Common::swap32(*(pData+2)); \ + else \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ + LOG_VTX(); \ + VertexManager::s_pCurBufferPointer += 12; \ } // ============================================================================== |
