From c613868f5788b59855ff564440a12839717aa3d2 Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 21 Jan 2014 18:54:16 +0100 Subject: [PATCH] VertexLoader: load scale factor as const, this will save some assembler instructions --- Source/Core/VideoCommon/VertexLoader_Position.cpp | 12 +++++++----- Source/Core/VideoCommon/VertexLoader_TextCoord.cpp | 13 ++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Source/Core/VideoCommon/VertexLoader_Position.cpp b/Source/Core/VideoCommon/VertexLoader_Position.cpp index 3206c002a9..e6836ddf6a 100644 --- a/Source/Core/VideoCommon/VertexLoader_Position.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Position.cpp @@ -61,13 +61,13 @@ MOVUPS(MOffset(EDI, 0), XMM0); */ template -float PosScale(T val) +float PosScale(T val, float scale) { - return val * posScale; + return val * scale; } template <> -float PosScale(float val) +float PosScale(float val, float scale) { return val; } @@ -76,9 +76,10 @@ template void LOADERDECL Pos_ReadDirect() { static_assert(N <= 3, "N > 3 is not sane!"); + auto const scale = posScale; for (int i = 0; i < 3; ++i) - DataWrite(i()) : 0.f); + DataWrite(i(), scale) : 0.f); LOG_VTX(); } @@ -91,9 +92,10 @@ void LOADERDECL Pos_ReadIndex() auto const index = DataRead(); auto const data = reinterpret_cast(cached_arraybases[ARRAY_POSITION] + (index * arraystrides[ARRAY_POSITION])); + auto const scale = posScale; for (int i = 0; i < 3; ++i) - DataWrite(i -float TCScale(T val) +float TCScale(T val, float scale) { - return val * tcScale[tcIndex]; + return val * scale; } template <> -float TCScale(float val) +float TCScale(float val, float scale) { return val; } @@ -55,8 +55,10 @@ float TCScale(float val) template void LOADERDECL TexCoord_ReadDirect() { + auto const scale = tcScale[tcIndex]; + for (int i = 0; i != N; ++i) - DataWrite(TCScale(DataRead())); + DataWrite(TCScale(DataRead(), scale)); LOG_TEX(); @@ -71,9 +73,10 @@ void LOADERDECL TexCoord_ReadIndex() auto const index = DataRead(); auto const data = reinterpret_cast(cached_arraybases[ARRAY_TEXCOORD0 + tcIndex] + (index * arraystrides[ARRAY_TEXCOORD0 + tcIndex])); + auto const scale = tcScale[tcIndex]; for (int i = 0; i != N; ++i) - DataWrite(TCScale(Common::FromBigEndian(data[i]))); + DataWrite(TCScale(Common::FromBigEndian(data[i]), scale)); LOG_TEX(); ++tcIndex;