summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authormemberTwo.mb2 <memberTwo.mb2@gmail.com>2008-09-29 17:29:25 +0000
committermemberTwo.mb2 <memberTwo.mb2@gmail.com>2008-09-29 17:29:25 +0000
commitdf9eba79b2f9efd451bee3fdfb683b3b2976bb1b (patch)
treed46276e4cc4008fea6cca21c9226273d3a1a0671 /Source/Core
parentd80178bd89294b64ec961e81e909c7b5e03d01e8 (diff)
DataReader migration to faster one: first step.
TODO: doing it for DX9, move DataReader to VideoCommon, remove dirty debug #def if ok git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@729 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/Src/Fifo.cpp32
-rw-r--r--Source/Core/VideoCommon/Src/Fifo.h13
2 files changed, 43 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp
index d6e6cef4b0..7f96ea1789 100644
--- a/Source/Core/VideoCommon/Src/Fifo.cpp
+++ b/Source/Core/VideoCommon/Src/Fifo.cpp
@@ -23,9 +23,11 @@
#include "Fifo.h"
-#define FIFO_SIZE (1024*1024)
-
+#if defined(DATAREADER_INLINE)
+extern u32 g_pVideoData;
+#else
FifoReader fifo;
+#endif
// STATE_TO_SAVE
static u8 *videoBuffer;
@@ -41,7 +43,9 @@ void Fifo_DoState(PointerWrap &p) {
void Fifo_Init()
{
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
+#ifndef DATAREADER_INLINE
fifo.Init(videoBuffer, videoBuffer); //zero length. there is no data yet.
+#endif
}
void Fifo_Shutdown()
@@ -49,6 +53,11 @@ void Fifo_Shutdown()
FreeMemoryPages(videoBuffer, FIFO_SIZE);
}
+u32 FAKE_GetFifoStartPtr()
+{
+ return (int)videoBuffer;
+}
+
int FAKE_GetFifoSize()
{
if (size < readptr)
@@ -57,6 +66,10 @@ int FAKE_GetFifoSize()
}
return (size - readptr);
}
+int FAKE_GetFifoEndAddr()
+{
+ return (int)(videoBuffer+size);
+}
u8 FAKE_PeekFifo8(u32 _uOffset)
{
@@ -83,6 +96,11 @@ int FAKE_GetPosition()
return readptr;
}
+int FAKE_GetRealPtr()
+{
+ return (int)(videoBuffer+readptr);
+}
+
u16 FAKE_ReadFifo16()
{
u16 val = Common::swap16(*(u16*)(videoBuffer+readptr));
@@ -104,10 +122,16 @@ void FAKE_SkipFifo(u32 skip)
void Video_SendFifoData(u8* _uData)
{
+ // TODO (mb2): unrolled loop faster than memcpy here?
memcpy(videoBuffer + size, _uData, 32);
size += 32;
if (size + 32 >= FIFO_SIZE)
{
+ // TODO (mb2): Better and DataReader inline for DX9
+#ifdef DATAREADER_INLINE
+ if (g_pVideoData) // for DX9 plugin "compatibility"
+ readptr = g_pVideoData-(u32)videoBuffer;
+#endif
if (FAKE_GetFifoSize() > readptr)
{
PanicAlert("FIFO out of bounds (sz = %i, at %08x)", FAKE_GetFifoSize(), readptr);
@@ -117,6 +141,10 @@ void Video_SendFifoData(u8* _uData)
// memset(&videoBuffer[FAKE_GetFifoSize()], 0, FIFO_SIZE - FAKE_GetFifoSize());
size = FAKE_GetFifoSize();
readptr = 0;
+#ifdef DATAREADER_INLINE
+ if (g_pVideoData) // for DX9 plugin "compatibility"
+ g_pVideoData = FAKE_GetFifoStartPtr();
+#endif
}
OpcodeDecoder_Run();
}
diff --git a/Source/Core/VideoCommon/Src/Fifo.h b/Source/Core/VideoCommon/Src/Fifo.h
index ec1610c4ff..68bc0eed96 100644
--- a/Source/Core/VideoCommon/Src/Fifo.h
+++ b/Source/Core/VideoCommon/Src/Fifo.h
@@ -23,6 +23,18 @@
#include "Common.h"
#include "ChunkFile.h"
+// TODO (mb2) clean this if ok
+#define DATAREADER_INLINE // uncomment to use the previous IDataReader way
+//#define DATAREADER_DEBUG // simple compare with the previous IDataReader way
+
+#if defined(DATAREADER_DEBUG) && !defined(DATAREADER_INLINE)
+#define DATAREADER_INLINE
+#endif
+
+
+#define FIFO_SIZE (1024*1024)
+
+#ifndef DATAREADER_INLINE
// inline for speed!
class FifoReader
{
@@ -54,6 +66,7 @@ public:
extern FifoReader fifo;
+#endif
void Fifo_Init();
void Fifo_Shutdown();
void Fifo_EnterLoop(const SVideoInitialize &video_initialize);