From 3938d3713b23d264e78a19b5bc1cb751630ee9ba Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Thu, 21 Feb 2013 00:40:22 -0600 Subject: [PATCH] Fix what I broke. --- .../Src/VertexLoader_TextCoord.cpp | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp index 8bbd1197d5..b5e7d890ff 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader_TextCoord.cpp @@ -28,8 +28,20 @@ #include #endif -#define LOG_TEX1() // PRIM_LOG("tex: %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0]); -#define LOG_TEX2() // PRIM_LOG("tex: %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0], ((float*)VertexManager::s_pCurBufferPointer)[1]); +template +void LOG_TEX(); + +template <> +__forceinline void LOG_TEX<1>() +{ + // PRIM_LOG("tex: %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0]); +} + +template <> +__forceinline void LOG_TEX<2>() +{ + // PRIM_LOG("tex: %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0], ((float*)VertexManager::s_pCurBufferPointer)[1]); +} extern int tcIndex; extern float tcScale[8]; @@ -39,14 +51,26 @@ void LOADERDECL TexCoord_Read_Dummy() tcIndex++; } +template +float TCScale(T val) +{ + return val * tcScale[tcIndex]; +} + +template <> +float TCScale(float val) +{ return val; } + template void LOADERDECL TexCoord_ReadDirect() { - reinterpret_cast(VertexManager::s_pCurBufferPointer)[0] = DataRead() * tcScale[tcIndex]; - if (N >= 1) - reinterpret_cast(VertexManager::s_pCurBufferPointer)[1] = DataRead() * tcScale[tcIndex]; - //LOG_TEX1(); - //LOG_TEX2(); + auto const dest = reinterpret_cast(VertexManager::s_pCurBufferPointer); + + for (int i = 0; i != N; ++i) + dest[i] = TCScale(DataRead()); + + LOG_TEX(); + VertexManager::s_pCurBufferPointer += sizeof(float) * N; ++tcIndex; } @@ -57,12 +81,16 @@ void LOADERDECL TexCoord_ReadIndex() static_assert(!std::numeric_limits::is_signed, "Only unsigned I is sane!"); auto const index = DataRead(); - auto const data = reinterpret_cast(cached_arraybases[ARRAY_TEXCOORD0 + tcIndex] + (index * arraystrides[ARRAY_TEXCOORD0 + tcIndex])); - reinterpret_cast(VertexManager::s_pCurBufferPointer)[0] = Common::FromBigEndian(data[0]) * tcScale[tcIndex]; - if (N >= 1) - reinterpret_cast(VertexManager::s_pCurBufferPointer)[1] = Common::FromBigEndian(data[1]) * tcScale[tcIndex]; - //LOG_TEX1(); - //LOG_TEX2(); + auto const data = reinterpret_cast(cached_arraybases[ARRAY_TEXCOORD0 + tcIndex] + + (index * arraystrides[ARRAY_TEXCOORD0 + tcIndex])); + + auto const dest = reinterpret_cast(VertexManager::s_pCurBufferPointer); + + for (int i = 0; i != N; ++i) + dest[i] = TCScale(Common::FromBigEndian(data[i])); + + LOG_TEX(); + VertexManager::s_pCurBufferPointer += sizeof(float) * N; ++tcIndex; }