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
This commit is contained in:
hyperiris 2009-02-08 13:08:58 +00:00
parent 5045119da3
commit c450e44b08
5 changed files with 181 additions and 115 deletions

View File

@ -174,9 +174,12 @@ void LOADERDECL Color_ReadIndex8_24b_6666()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u32 val = Memory_Read_U8(iAddress+2) |
(Memory_Read_U8(iAddress+1)<<8) |
(Memory_Read_U8(iAddress)<<16);
u8* pData = Memory_Read_U8_Ptr(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);
}
@ -219,9 +222,13 @@ void LOADERDECL Color_ReadIndex16_24b_6666()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_COLOR+colIndex] + (Index * arraystrides[ARRAY_COLOR+colIndex]);
u32 val = Memory_Read_U8(iAddress+2) |
(Memory_Read_U8(iAddress+1)<<8) |
(Memory_Read_U8(iAddress)<<16);
u8* pData = Memory_Read_U8_Ptr(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()

View File

@ -184,9 +184,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+2);
u8* pData = Memory_Read_U8_Ptr(iAddress);
*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);
VertexManager::s_pCurBufferPointer++;
// ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(signed char)Memory_Read_U8(iAddress)+0.5f) / 127.5f;
// ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(signed char)Memory_Read_U8(iAddress+1)+0.5f) / 127.5f;
@ -199,9 +200,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Short()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
((u16*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U16(iAddress+4);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
@ -210,9 +212,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Float()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 12;
LOG_NORMF();
}
@ -220,12 +223,15 @@ 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);
for (int i = 0; i < 3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+2);
//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);
VertexManager::s_pCurBufferPointer++;
LOG_NORM8();
}
@ -234,12 +240,15 @@ 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);
for (int i = 0; i < 3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
((u16*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U16(iAddress+4);
//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);
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
@ -248,12 +257,14 @@ 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);
for (int i = 0; i < 3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8);
//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);
VertexManager::s_pCurBufferPointer += 12;
LOG_NORMF();
}
@ -265,9 +276,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices3()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+2);
u8* pData = Memory_Read_U8_Ptr(iAddress);
*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);
*VertexManager::s_pCurBufferPointer++;
LOG_NORM8();
}
@ -279,9 +291,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices3()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
((u16*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U16(iAddress+4);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
@ -293,9 +306,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Float3_Indices3()
{
u8 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 12;
LOG_NORMF();
}
@ -309,9 +323,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+2);
u8* pData = Memory_Read_U8_Ptr(iAddress);
*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);
VertexManager::s_pCurBufferPointer++;
LOG_NORM8();
}
@ -320,9 +335,11 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Short()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
((u16*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U16(iAddress+4);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
@ -331,9 +348,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Float()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 12;
LOG_NORMF();
}
@ -341,12 +359,14 @@ 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);
for (int i = 0; i < 3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+2);
//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);
VertexManager::s_pCurBufferPointer++;
LOG_NORM8();
}
@ -355,12 +375,15 @@ 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);
for (int i = 0; i < 3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
((u16*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U16(iAddress+4);
//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);
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
@ -369,12 +392,15 @@ 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);
for (int i = 0; i < 3; i++)
{
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8);
//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);
VertexManager::s_pCurBufferPointer += 12;
LOG_NORMF();
}
@ -386,9 +412,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices3()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 1*3*i;
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+1);
*VertexManager::s_pCurBufferPointer++ = Memory_Read_U8(iAddress+2);
u8* pData = Memory_Read_U8_Ptr(iAddress);
*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);
VertexManager::s_pCurBufferPointer++;
LOG_NORM8();
}
@ -400,9 +427,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices3()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i;
((u16*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U16(iAddress);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U16(iAddress+2);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U16(iAddress+4);
u16* pData = Memory_Read_U16_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
@ -415,9 +443,10 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Float3_Indices3()
{
u16 Index = DataReadU16();
u32 iAddress = arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 4*3*i;
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4);
((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8);
u32* pData = Memory_Read_U32_Unswapped_Ptr(iAddress);
((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);
VertexManager::s_pCurBufferPointer += 12;
LOG_NORMF();
}

View File

@ -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_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]); \
((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_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() { \
#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; \
}
// ==============================================================================

View File

@ -130,9 +130,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -152,9 +153,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -174,9 +176,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Memory_Read_U16(iAddress+2) * tcScale[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();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -196,9 +199,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Memory_Read_U16(iAddress+2) * tcScale[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();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -217,8 +221,10 @@ void LOADERDECL TexCoord_ReadIndex8_Float2()
{
u16 Index = DataReadU8();
u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4);
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));
LOG_TEX2();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -239,9 +245,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -261,9 +268,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)(*(pData)) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)(*(pData+1)) * tcScale[tcIndex];
LOG_TEX2();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -283,9 +291,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Memory_Read_U16(iAddress+2) * tcScale[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();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -305,9 +314,10 @@ 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);
((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex];
((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Memory_Read_U16(iAddress+2) * tcScale[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();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;
@ -327,9 +337,10 @@ 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);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress);
((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress + 4);
((u32*)VertexManager::s_pCurBufferPointer)[0] = Common::swap32(*(pData));
((u32*)VertexManager::s_pCurBufferPointer)[1] = Common::swap32(*(pData+1));
LOG_TEX2();
VertexManager::s_pCurBufferPointer += 8;
tcIndex++;

View File

@ -48,6 +48,7 @@ extern volatile u32 g_XFBUpdateRequested;
void DebugLog(const char* _fmt, ...);
//////////////////////////////////////////////////////////////////////////
inline u8 *Memory_GetPtr(u32 _uAddress)
{
return g_VideoInitialize.pGetMemoryPointer(_uAddress);//&g_pMemory[_uAddress & RAM_MASK];
@ -67,7 +68,22 @@ inline u32 Memory_Read_U32(u32 _uAddress)
{
return Common::swap32(*(u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress));
}
//////////////////////////////////////////////////////////////////////////
inline u8* Memory_Read_U8_Ptr(u32 _uAddress)
{
return (u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress);//g_pMemory[_uAddress & RAM_MASK];
}
inline u16* Memory_Read_U16_Unswapped_Ptr(u32 _uAddress)
{
return (u16*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u32* Memory_Read_U32_Unswapped_Ptr(u32 _uAddress)
{
return (u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
//////////////////////////////////////////////////////////////////////////
inline u32 Memory_Read_U32_Unswapped(u32 _uAddress)
{
return *(u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress);