Skip to content

Commit

Permalink
VertexLoader: load scale factor as const, this will save some assembl…
Browse files Browse the repository at this point in the history
…er instructions
  • Loading branch information
degasus committed Jan 21, 2014
1 parent f90fe90 commit c613868
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 7 additions & 5 deletions Source/Core/VideoCommon/VertexLoader_Position.cpp
Expand Up @@ -61,13 +61,13 @@ MOVUPS(MOffset(EDI, 0), XMM0);
*/

template <typename T>
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;
}
Expand All @@ -76,9 +76,10 @@ template <typename T, int N>
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<N ? PosScale(DataRead<T>()) : 0.f);
DataWrite(i<N ? PosScale(DataRead<T>(), scale) : 0.f);

LOG_VTX();
}
Expand All @@ -91,9 +92,10 @@ void LOADERDECL Pos_ReadIndex()

auto const index = DataRead<I>();
auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_POSITION] + (index * arraystrides[ARRAY_POSITION]));
auto const scale = posScale;

for (int i = 0; i < 3; ++i)
DataWrite(i<N ? PosScale(Common::FromBigEndian(data[i])) : 0.f);
DataWrite(i<N ? PosScale(Common::FromBigEndian(data[i]), scale) : 0.f);

LOG_VTX();
}
Expand Down
13 changes: 8 additions & 5 deletions Source/Core/VideoCommon/VertexLoader_TextCoord.cpp
Expand Up @@ -41,22 +41,24 @@ void LOADERDECL TexCoord_Read_Dummy()
}

template <typename T>
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;
}

template <typename T, int N>
void LOADERDECL TexCoord_ReadDirect()
{
auto const scale = tcScale[tcIndex];

for (int i = 0; i != N; ++i)
DataWrite(TCScale(DataRead<T>()));
DataWrite(TCScale(DataRead<T>(), scale));

LOG_TEX<N>();

Expand All @@ -71,9 +73,10 @@ void LOADERDECL TexCoord_ReadIndex()
auto const index = DataRead<I>();
auto const data = reinterpret_cast<const T*>(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<N>();
++tcIndex;
Expand Down

0 comments on commit c613868

Please sign in to comment.