summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoader_Position.cpp
diff options
context:
space:
mode:
authorFiora <fioraaeterna@gmail.com>2014-11-11 01:48:38 -0800
committerFiora <fioraaeterna@gmail.com>2014-11-20 02:13:19 -0800
commit3ddf82a318eef8091d58255c712965e3271bb296 (patch)
tree14372858775fe3449ecba35f2acb0bebc0eba6a7 /Source/Core/VideoCommon/VertexLoader_Position.cpp
parentda962a3d2b035875518df079fd286337e85de371 (diff)
Vertex Loader: SSE implementations of more position/texcoord/normal formats
~35-45% faster NFS:HP2, possibly other vertex-bound games.
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoader_Position.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoader_Position.cpp66
1 files changed, 47 insertions, 19 deletions
diff --git a/Source/Core/VideoCommon/VertexLoader_Position.cpp b/Source/Core/VideoCommon/VertexLoader_Position.cpp
index a38d429d58..6c50dd1560 100644
--- a/Source/Core/VideoCommon/VertexLoader_Position.cpp
+++ b/Source/Core/VideoCommon/VertexLoader_Position.cpp
@@ -2,7 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include <limits>
+#include <type_traits>
#include "Common/CommonTypes.h"
#include "Common/CPUDetect.h"
@@ -74,7 +74,7 @@ template <typename T, int N>
void LOADERDECL Pos_ReadDirect()
{
static_assert(N <= 3, "N > 3 is not sane!");
- auto const scale = posScale;
+ auto const scale = posScale[0];
DataWriter dst;
DataReader src;
@@ -87,12 +87,12 @@ void LOADERDECL Pos_ReadDirect()
template <typename I, typename T, int N>
void LOADERDECL Pos_ReadIndex()
{
- static_assert(!std::numeric_limits<I>::is_signed, "Only unsigned I is sane!");
+ static_assert(std::is_unsigned<I>::value, "Only unsigned I is sane!");
static_assert(N <= 3, "N > 3 is not sane!");
auto const index = DataRead<I>();
auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_POSITION] + (index * g_main_cp_state.array_strides[ARRAY_POSITION]));
- auto const scale = posScale;
+ auto const scale = posScale[0];
DataWriter dst;
for (int i = 0; i < 3; ++i)
@@ -102,18 +102,22 @@ void LOADERDECL Pos_ReadIndex()
}
#if _M_SSE >= 0x301
-static const __m128i kMaskSwap32_3 = _mm_set_epi32(0xFFFFFFFFL, 0x08090A0BL, 0x04050607L, 0x00010203L);
-static const __m128i kMaskSwap32_2 = _mm_set_epi32(0xFFFFFFFFL, 0xFFFFFFFFL, 0x04050607L, 0x00010203L);
+template <typename T, bool three>
+void LOADERDECL Pos_ReadDirect_SSSE3()
+{
+ const T* pData = reinterpret_cast<const T*>(DataGetPosition());
+ Vertex_Read_SSSE3<T, three, true>(pData, *(__m128*)posScale);
+ DataSkip<(2 + three) * sizeof(T)>();
+ LOG_VTX();
+}
-template <typename I, bool three>
-void LOADERDECL Pos_ReadIndex_Float_SSSE3()
+template <typename I, typename T, bool three>
+void LOADERDECL Pos_ReadIndex_SSSE3()
{
+ static_assert(std::is_unsigned<I>::value, "Only unsigned I is sane!");
auto const index = DataRead<I>();
- const u32* pData = (const u32 *)(cached_arraybases[ARRAY_POSITION] + (index * g_main_cp_state.array_strides[ARRAY_POSITION]));
- GC_ALIGNED128(const __m128i a = _mm_loadu_si128((__m128i*)pData));
- GC_ALIGNED128(__m128i b = _mm_shuffle_epi8(a, three ? kMaskSwap32_3 : kMaskSwap32_2));
- _mm_storeu_si128((__m128i*)VertexManager::s_pCurBufferPointer, b);
- VertexManager::s_pCurBufferPointer += sizeof(float) * 3;
+ const T* pData = (const T*)(cached_arraybases[ARRAY_POSITION] + (index * g_main_cp_state.array_strides[ARRAY_POSITION]));
+ Vertex_Read_SSSE3<T, three, true>(pData, *(__m128*)posScale);
LOG_VTX();
}
#endif
@@ -169,15 +173,39 @@ void VertexLoader_Position::Init()
{
#if _M_SSE >= 0x301
-
if (cpu_info.bSSSE3)
{
- tableReadPosition[2][4][0] = Pos_ReadIndex_Float_SSSE3<u8, false>;
- tableReadPosition[2][4][1] = Pos_ReadIndex_Float_SSSE3<u8, true>;
- tableReadPosition[3][4][0] = Pos_ReadIndex_Float_SSSE3<u16, false>;
- tableReadPosition[3][4][1] = Pos_ReadIndex_Float_SSSE3<u16, true>;
+ tableReadPosition[1][0][0] = Pos_ReadDirect_SSSE3<u8, false>;
+ tableReadPosition[1][0][1] = Pos_ReadDirect_SSSE3<u8, true>;
+ tableReadPosition[1][1][0] = Pos_ReadDirect_SSSE3<s8, false>;
+ tableReadPosition[1][1][1] = Pos_ReadDirect_SSSE3<s8, true>;
+ tableReadPosition[1][2][0] = Pos_ReadDirect_SSSE3<u16, false>;
+ tableReadPosition[1][2][1] = Pos_ReadDirect_SSSE3<u16, true>;
+ tableReadPosition[1][3][0] = Pos_ReadDirect_SSSE3<s16, false>;
+ tableReadPosition[1][3][1] = Pos_ReadDirect_SSSE3<s16, true>;
+ tableReadPosition[1][4][0] = Pos_ReadDirect_SSSE3<float, false>;
+ tableReadPosition[1][4][1] = Pos_ReadDirect_SSSE3<float, true>;
+ tableReadPosition[2][0][0] = Pos_ReadIndex_SSSE3<u8, u8, false>;
+ tableReadPosition[2][0][1] = Pos_ReadIndex_SSSE3<u8, u8, true>;
+ tableReadPosition[3][0][0] = Pos_ReadIndex_SSSE3<u16, u8, false>;
+ tableReadPosition[3][0][1] = Pos_ReadIndex_SSSE3<u16, u8, true>;
+ tableReadPosition[2][1][0] = Pos_ReadIndex_SSSE3<u8, s8, false>;
+ tableReadPosition[2][1][1] = Pos_ReadIndex_SSSE3<u8, s8, true>;
+ tableReadPosition[3][1][0] = Pos_ReadIndex_SSSE3<u16, s8, false>;
+ tableReadPosition[3][1][1] = Pos_ReadIndex_SSSE3<u16, s8, true>;
+ tableReadPosition[2][2][0] = Pos_ReadIndex_SSSE3<u8, u16, false>;
+ tableReadPosition[2][2][1] = Pos_ReadIndex_SSSE3<u8, u16, true>;
+ tableReadPosition[3][2][0] = Pos_ReadIndex_SSSE3<u16, u16, false>;
+ tableReadPosition[3][2][1] = Pos_ReadIndex_SSSE3<u16, u16, true>;
+ tableReadPosition[2][3][0] = Pos_ReadIndex_SSSE3<u8, s16, false>;
+ tableReadPosition[2][3][1] = Pos_ReadIndex_SSSE3<u8, s16, true>;
+ tableReadPosition[3][3][0] = Pos_ReadIndex_SSSE3<u16, s16, false>;
+ tableReadPosition[3][3][1] = Pos_ReadIndex_SSSE3<u16, s16, true>;
+ tableReadPosition[2][4][0] = Pos_ReadIndex_SSSE3<u8, float, false>;
+ tableReadPosition[2][4][1] = Pos_ReadIndex_SSSE3<u8, float, true>;
+ tableReadPosition[3][4][0] = Pos_ReadIndex_SSSE3<u16, float, false>;
+ tableReadPosition[3][4][1] = Pos_ReadIndex_SSSE3<u16, float, true>;
}
-
#endif
}