From 50de4238bb1bbceb4797821d8ec428ab1d075aaa Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 29 Nov 2014 03:39:24 +0100 Subject: [PATCH] VertexLoader: Move the old Datareader function into VertexLoader --- .../VideoBackends/Software/OpcodeDecoder.cpp | 2 +- .../Software/SWCommandProcessor.cpp | 2 +- .../VideoBackends/Software/SWVertexLoader.cpp | 1 - Source/Core/VideoCommon/DataReader.h | 86 ----------------- Source/Core/VideoCommon/VertexLoader.h | 3 +- Source/Core/VideoCommon/VertexLoaderUtils.h | 93 +++++++++++++++++++ Source/Core/VideoCommon/VideoCommon.vcxproj | 3 +- .../VideoCommon/VideoCommon.vcxproj.filters | 5 +- 8 files changed, 103 insertions(+), 92 deletions(-) create mode 100644 Source/Core/VideoCommon/VertexLoaderUtils.h diff --git a/Source/Core/VideoBackends/Software/OpcodeDecoder.cpp b/Source/Core/VideoBackends/Software/OpcodeDecoder.cpp index 66816e6626..6ae76c44b5 100644 --- a/Source/Core/VideoBackends/Software/OpcodeDecoder.cpp +++ b/Source/Core/VideoBackends/Software/OpcodeDecoder.cpp @@ -14,8 +14,8 @@ #include "VideoBackends/Software/SWVertexLoader.h" #include "VideoBackends/Software/SWVideoConfig.h" #include "VideoBackends/Software/XFMemLoader.h" -#include "VideoCommon/DataReader.h" #include "VideoCommon/Fifo.h" +#include "VideoCommon/VertexLoaderUtils.h" typedef void (*DecodingFunction)(u32); diff --git a/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp b/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp index 5b3af7f78a..9c7ff303b7 100644 --- a/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp +++ b/Source/Core/VideoBackends/Software/SWCommandProcessor.cpp @@ -20,8 +20,8 @@ #include "VideoBackends/Software/SWCommandProcessor.h" #include "VideoBackends/Software/VideoBackend.h" -#include "VideoCommon/DataReader.h" #include "VideoCommon/Fifo.h" +#include "VideoCommon/VertexLoaderUtils.h" namespace SWCommandProcessor { diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index 0612a743da..baa1a60164 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -13,7 +13,6 @@ #include "VideoBackends/Software/TransformUnit.h" #include "VideoBackends/Software/XFMemLoader.h" -#include "VideoCommon/DataReader.h" #include "VideoCommon/VertexLoader.h" #include "VideoCommon/VertexLoader_Color.h" #include "VideoCommon/VertexLoader_Normal.h" diff --git a/Source/Core/VideoCommon/DataReader.h b/Source/Core/VideoCommon/DataReader.h index ce862c83b4..f7e030739f 100644 --- a/Source/Core/VideoCommon/DataReader.h +++ b/Source/Core/VideoCommon/DataReader.h @@ -5,9 +5,6 @@ #pragma once #include "Common/Common.h" -#include "VideoCommon/VertexManagerBase.h" - -extern u8* g_video_buffer_read_ptr; class DataReader { @@ -66,86 +63,3 @@ private: u8* __restrict buffer; u8* end; }; - -__forceinline void DataSkip(u32 skip) -{ - g_video_buffer_read_ptr += skip; -} - -// probably unnecessary -template -__forceinline void DataSkip() -{ - g_video_buffer_read_ptr += count; -} - -template -__forceinline T DataPeek(int _uOffset, u8** bufp = &g_video_buffer_read_ptr) -{ - auto const result = Common::FromBigEndian(*reinterpret_cast(*bufp + _uOffset)); - return result; -} - -// TODO: kill these -__forceinline u8 DataPeek8(int _uOffset) -{ - return DataPeek(_uOffset); -} - -__forceinline u16 DataPeek16(int _uOffset) -{ - return DataPeek(_uOffset); -} - -__forceinline u32 DataPeek32(int _uOffset) -{ - return DataPeek(_uOffset); -} - -template -__forceinline T DataRead(u8** bufp = &g_video_buffer_read_ptr) -{ - auto const result = DataPeek(0, bufp); - *bufp += sizeof(T); - return result; -} - -// TODO: kill these -__forceinline u8 DataReadU8() -{ - return DataRead(); -} - -__forceinline s8 DataReadS8() -{ - return DataRead(); -} - -__forceinline u16 DataReadU16() -{ - return DataRead(); -} - -__forceinline u32 DataReadU32() -{ - return DataRead(); -} - -__forceinline u32 DataReadU32Unswapped() -{ - u32 tmp = *(u32*)g_video_buffer_read_ptr; - g_video_buffer_read_ptr += 4; - return tmp; -} - -__forceinline u8* DataGetPosition() -{ - return g_video_buffer_read_ptr; -} - -template -__forceinline void DataWrite(T data) -{ - *(T*)VertexManager::s_pCurBufferPointer = data; - VertexManager::s_pCurBufferPointer += sizeof(T); -} diff --git a/Source/Core/VideoCommon/VertexLoader.h b/Source/Core/VideoCommon/VertexLoader.h index 71159b60d7..1eedd13b25 100644 --- a/Source/Core/VideoCommon/VertexLoader.h +++ b/Source/Core/VideoCommon/VertexLoader.h @@ -18,6 +18,7 @@ #include "VideoCommon/CPMemory.h" #include "VideoCommon/DataReader.h" #include "VideoCommon/NativeVertexFormat.h" +#include "VideoCommon/VertexLoaderUtils.h" #if _M_SSE >= 0x401 #include @@ -219,4 +220,4 @@ __forceinline void Vertex_Read_SSSE3(const T* pData, __m128 scale) VertexManager::s_pCurBufferPointer += sizeof(float) * (2 + threeOut); } -#endif \ No newline at end of file +#endif diff --git a/Source/Core/VideoCommon/VertexLoaderUtils.h b/Source/Core/VideoCommon/VertexLoaderUtils.h new file mode 100644 index 0000000000..0477437876 --- /dev/null +++ b/Source/Core/VideoCommon/VertexLoaderUtils.h @@ -0,0 +1,93 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + + +#include "Common/Common.h" +#include "VideoCommon/VertexManagerBase.h" + +extern u8* g_video_buffer_read_ptr; + + +__forceinline void DataSkip(u32 skip) +{ + g_video_buffer_read_ptr += skip; +} + +// probably unnecessary +template +__forceinline void DataSkip() +{ + g_video_buffer_read_ptr += count; +} + +template +__forceinline T DataPeek(int _uOffset, u8** bufp = &g_video_buffer_read_ptr) +{ + auto const result = Common::FromBigEndian(*reinterpret_cast(*bufp + _uOffset)); + return result; +} + +// TODO: kill these +__forceinline u8 DataPeek8(int _uOffset) +{ + return DataPeek(_uOffset); +} + +__forceinline u16 DataPeek16(int _uOffset) +{ + return DataPeek(_uOffset); +} + +__forceinline u32 DataPeek32(int _uOffset) +{ + return DataPeek(_uOffset); +} + +template +__forceinline T DataRead(u8** bufp = &g_video_buffer_read_ptr) +{ + auto const result = DataPeek(0, bufp); + *bufp += sizeof(T); + return result; +} + +// TODO: kill these +__forceinline u8 DataReadU8() +{ + return DataRead(); +} + +__forceinline s8 DataReadS8() +{ + return DataRead(); +} + +__forceinline u16 DataReadU16() +{ + return DataRead(); +} + +__forceinline u32 DataReadU32() +{ + return DataRead(); +} + +__forceinline u32 DataReadU32Unswapped() +{ + u32 tmp = *(u32*)g_video_buffer_read_ptr; + g_video_buffer_read_ptr += 4; + return tmp; +} + +__forceinline u8* DataGetPosition() +{ + return g_video_buffer_read_ptr; +} + +template +__forceinline void DataWrite(T data) +{ + *(T*)VertexManager::s_pCurBufferPointer = data; + VertexManager::s_pCurBufferPointer += sizeof(T); +} diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj b/Source/Core/VideoCommon/VideoCommon.vcxproj index 31dc089736..237becb45e 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj @@ -117,6 +117,7 @@ + @@ -151,4 +152,4 @@ - \ No newline at end of file + diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters index f285ce35d4..971bf59bbf 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters @@ -275,6 +275,9 @@ Vertex Loading + + Vertex Loading + Util @@ -285,4 +288,4 @@ - \ No newline at end of file +