summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2014-01-21 19:23:07 +0100
committerdegasus <wickmarkus@web.de>2014-01-21 19:23:07 +0100
commit0b97b33ceb58cd72a9586c438f39866ec032d9a4 (patch)
treee518a492ae97f0dda68acecd3a1d57cff03dd486 /Source/Core
parentc613868f5788b59855ff564440a12839717aa3d2 (diff)
VertexLoader: inline destionation buffer
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/DataReader.h10
-rw-r--r--Source/Core/VideoCommon/VertexLoader_Normal.cpp5
-rw-r--r--Source/Core/VideoCommon/VertexLoader_Position.cpp10
-rw-r--r--Source/Core/VideoCommon/VertexLoader_TextCoord.cpp11
4 files changed, 29 insertions, 7 deletions
diff --git a/Source/Core/VideoCommon/DataReader.h b/Source/Core/VideoCommon/DataReader.h
index 95c992a011..b552ca34e4 100644
--- a/Source/Core/VideoCommon/DataReader.h
+++ b/Source/Core/VideoCommon/DataReader.h
@@ -133,10 +133,16 @@ __forceinline u8* DataGetPosition()
}
template <typename T>
+__forceinline void DataWrite(u8* &dst, T data)
+{
+ *(T*)dst = data;
+ dst += sizeof(T);
+}
+
+template <typename T>
__forceinline void DataWrite(T data)
{
- *(T*)VertexManager::s_pCurBufferPointer = data;
- VertexManager::s_pCurBufferPointer += sizeof(T);
+ DataWrite(VertexManager::s_pCurBufferPointer, data);
}
#endif
diff --git a/Source/Core/VideoCommon/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/VertexLoader_Normal.cpp
index 4a3600addd..fc9cf9e554 100644
--- a/Source/Core/VideoCommon/VertexLoader_Normal.cpp
+++ b/Source/Core/VideoCommon/VertexLoader_Normal.cpp
@@ -48,12 +48,15 @@ template <typename T, int N>
__forceinline void ReadIndirect(const T* data)
{
static_assert(3 == N || 9 == N, "N is only sane as 3 or 9!");
+ auto dst = VertexManager::s_pCurBufferPointer;
for (int i = 0; i != N; ++i)
{
- DataWrite(FracAdjust(Common::FromBigEndian(data[i])));
+ DataWrite(dst, FracAdjust(Common::FromBigEndian(data[i])));
}
+ VertexManager::s_pCurBufferPointer = dst;
+
LOG_NORM();
}
diff --git a/Source/Core/VideoCommon/VertexLoader_Position.cpp b/Source/Core/VideoCommon/VertexLoader_Position.cpp
index e6836ddf6a..6163272fb1 100644
--- a/Source/Core/VideoCommon/VertexLoader_Position.cpp
+++ b/Source/Core/VideoCommon/VertexLoader_Position.cpp
@@ -77,9 +77,12 @@ void LOADERDECL Pos_ReadDirect()
{
static_assert(N <= 3, "N > 3 is not sane!");
auto const scale = posScale;
+ auto dst = VertexManager::s_pCurBufferPointer;
for (int i = 0; i < 3; ++i)
- DataWrite(i<N ? PosScale(DataRead<T>(), scale) : 0.f);
+ DataWrite(dst, i<N ? PosScale(DataRead<T>(), scale) : 0.f);
+
+ VertexManager::s_pCurBufferPointer = dst;
LOG_VTX();
}
@@ -93,9 +96,12 @@ 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;
+ auto dst = VertexManager::s_pCurBufferPointer;
for (int i = 0; i < 3; ++i)
- DataWrite(i<N ? PosScale(Common::FromBigEndian(data[i]), scale) : 0.f);
+ DataWrite(dst, i<N ? PosScale(Common::FromBigEndian(data[i]), scale) : 0.f);
+
+ VertexManager::s_pCurBufferPointer = dst;
LOG_VTX();
}
diff --git a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp
index 37d2407c71..ed97716768 100644
--- a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp
+++ b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp
@@ -56,9 +56,13 @@ template <typename T, int N>
void LOADERDECL TexCoord_ReadDirect()
{
auto const scale = tcScale[tcIndex];
+ auto dst = VertexManager::s_pCurBufferPointer;
+
for (int i = 0; i != N; ++i)
- DataWrite(TCScale(DataRead<T>(), scale));
+ DataWrite(dst, TCScale(DataRead<T>(), scale));
+
+ VertexManager::s_pCurBufferPointer = dst;
LOG_TEX<N>();
@@ -74,9 +78,12 @@ void LOADERDECL TexCoord_ReadIndex()
auto const data = reinterpret_cast<const T*>(cached_arraybases[ARRAY_TEXCOORD0 + tcIndex]
+ (index * arraystrides[ARRAY_TEXCOORD0 + tcIndex]));
auto const scale = tcScale[tcIndex];
+ auto dst = VertexManager::s_pCurBufferPointer;
for (int i = 0; i != N; ++i)
- DataWrite(TCScale(Common::FromBigEndian(data[i]), scale));
+ DataWrite(dst, TCScale(Common::FromBigEndian(data[i]), scale));
+
+ VertexManager::s_pCurBufferPointer = dst;
LOG_TEX<N>();
++tcIndex;