mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 17:19:44 -06:00
Move some code out of the plugins into VideoCommon. No functional change.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@255 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -542,6 +542,10 @@
|
||||
RelativePath=".\src\RegisterWindow.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\SConscript"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
@ -13,6 +13,7 @@ files = ["LogWindow.cpp",
|
||||
"MemoryWindow.cpp",
|
||||
"RegisterWindow.cpp",
|
||||
"RegisterView.cpp",
|
||||
"JitWindow.cpp",
|
||||
]
|
||||
wxenv = env.Copy(CXXFLAGS = "`wx-config --cppflags` -DUSE_XPM_BITMAPS -DwxNEEDS_CHARPP",
|
||||
LINKFLAGS = "-L/usr/local/lib -pthread `wx-config --libs --debug`")
|
||||
|
167
Source/Core/VideoCommon/Src/Fifo.cpp
Normal file
167
Source/Core/VideoCommon/Src/Fifo.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "MemoryUtil.h"
|
||||
#include "Thread.h"
|
||||
#include "OpcodeDecoding.h"
|
||||
#include "pluginspecs_video.h"
|
||||
|
||||
#include "Fifo.h"
|
||||
|
||||
#define FIFO_SIZE (1024*1024)
|
||||
|
||||
FifoReader fifo;
|
||||
static u8 *videoBuffer;
|
||||
|
||||
static int size = 0;
|
||||
static int readptr = 0;
|
||||
|
||||
void Fifo_Init()
|
||||
{
|
||||
videoBuffer = (u8*)AllocateMemoryPages(FIFO_SIZE);
|
||||
fifo.Init(videoBuffer, videoBuffer); //zero length. there is no data yet.
|
||||
}
|
||||
|
||||
void Fifo_Shutdown()
|
||||
{
|
||||
FreeMemoryPages(videoBuffer, FIFO_SIZE);
|
||||
}
|
||||
|
||||
int FAKE_GetFifoSize()
|
||||
{
|
||||
if (size < readptr)
|
||||
{
|
||||
PanicAlert("GFX Fifo underrun encountered (size = %i, readptr = %i)", size, readptr);
|
||||
}
|
||||
return (size - readptr);
|
||||
}
|
||||
|
||||
u8 FAKE_PeekFifo8(u32 _uOffset)
|
||||
{
|
||||
return videoBuffer[readptr + _uOffset];
|
||||
}
|
||||
|
||||
u16 FAKE_PeekFifo16(u32 _uOffset)
|
||||
{
|
||||
return Common::swap16(*(u16*)&videoBuffer[readptr + _uOffset]);
|
||||
}
|
||||
|
||||
u32 FAKE_PeekFifo32(u32 _uOffset)
|
||||
{
|
||||
return Common::swap32(*(u32*)&videoBuffer[readptr + _uOffset]);
|
||||
}
|
||||
|
||||
u8 FAKE_ReadFifo8()
|
||||
{
|
||||
return videoBuffer[readptr++];
|
||||
}
|
||||
|
||||
u16 FAKE_ReadFifo16()
|
||||
{
|
||||
u16 val = Common::swap16(*(u16*)(videoBuffer+readptr));
|
||||
readptr += 2;
|
||||
return val;
|
||||
}
|
||||
|
||||
u32 FAKE_ReadFifo32()
|
||||
{
|
||||
u32 val = Common::swap32(*(u32*)(videoBuffer+readptr));
|
||||
readptr += 4;
|
||||
return val;
|
||||
}
|
||||
|
||||
void FAKE_SkipFifo(u32 skip)
|
||||
{
|
||||
readptr += skip;
|
||||
}
|
||||
|
||||
void Video_SendFifoData(BYTE *_uData)
|
||||
{
|
||||
memcpy(videoBuffer + size, _uData, 32);
|
||||
size += 32;
|
||||
if (size + 32 >= FIFO_SIZE)
|
||||
{
|
||||
if (FAKE_GetFifoSize() > readptr)
|
||||
{
|
||||
PanicAlert("FIFO out of bounds (sz = %i, at %08x)", FAKE_GetFifoSize(), readptr);
|
||||
}
|
||||
// DebugLog("FAKE BUFFER LOOPS");
|
||||
memmove(&videoBuffer[0], &videoBuffer[readptr], FAKE_GetFifoSize());
|
||||
// memset(&videoBuffer[FAKE_GetFifoSize()], 0, FIFO_SIZE - FAKE_GetFifoSize());
|
||||
size = FAKE_GetFifoSize();
|
||||
readptr = 0;
|
||||
}
|
||||
OpcodeDecoder_Run();
|
||||
}
|
||||
|
||||
|
||||
//TODO - turn inside out, have the "reader" ask for bytes instead
|
||||
// See Core.cpp for threading idea
|
||||
void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
{
|
||||
SCPFifoStruct &fifo = *video_initialize.pCPFifo;
|
||||
|
||||
// TODO(ector): Don't peek so often!
|
||||
while (video_initialize.pPeekMessages())
|
||||
{
|
||||
if (fifo.CPReadWriteDistance < 1) //fifo.CPLoWatermark)
|
||||
Common::SleepCurrentThread(1);
|
||||
//etc...
|
||||
|
||||
// check if we are able to run this buffer
|
||||
if ((fifo.bFF_GPReadEnable) && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint))
|
||||
{
|
||||
int count = 200;
|
||||
while(fifo.CPReadWriteDistance > 0 && count)
|
||||
{
|
||||
// check if we are on a breakpoint
|
||||
if (fifo.bFF_BPEnable)
|
||||
{
|
||||
if (fifo.CPReadPointer == fifo.CPBreakpoint)
|
||||
{
|
||||
fifo.bFF_Breakpoint = 1;
|
||||
video_initialize.pUpdateInterrupts();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// read the data and send it to the VideoPlugin
|
||||
u8 *uData = video_initialize.pGetMemoryPointer(fifo.CPReadPointer);
|
||||
#ifdef _WIN32
|
||||
EnterCriticalSection(&fifo.sync);
|
||||
#endif
|
||||
fifo.CPReadPointer += 32;
|
||||
Video_SendFifoData(uData);
|
||||
#ifdef _WIN32
|
||||
InterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, -32);
|
||||
LeaveCriticalSection(&fifo.sync);
|
||||
#endif
|
||||
// increase the ReadPtr
|
||||
if (fifo.CPReadPointer >= fifo.CPEnd)
|
||||
{
|
||||
fifo.CPReadPointer = fifo.CPBase;
|
||||
//LOG(COMMANDPROCESSOR, "BUFFER LOOP");
|
||||
}
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
58
Source/Core/VideoCommon/Src/Fifo.h
Normal file
58
Source/Core/VideoCommon/Src/Fifo.h
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _FIFO_H
|
||||
#define _FIFO_H
|
||||
|
||||
#include "Common.h"
|
||||
// inline for speed!
|
||||
class FifoReader
|
||||
{
|
||||
u8 *ptr;
|
||||
u8 *end;
|
||||
u8 *tempPtr; //single element stack :P
|
||||
u8 *tempEnd;
|
||||
bool pushed;
|
||||
public:
|
||||
void Init(u8 *_ptr, u8 *_end)
|
||||
{
|
||||
ptr = _ptr; end = _end; pushed = false;
|
||||
}
|
||||
bool IsPushed() {return pushed;}
|
||||
void Push(u8 *_ptr, u8 *_end) {pushed = true; tempPtr = ptr; tempEnd = end; ptr = _ptr; end = _end;}
|
||||
void Pop() {pushed = false; ptr = tempPtr; end = tempEnd;}
|
||||
u8 Peek8 (int offset) const { return ptr[offset]; }
|
||||
u16 Peek16(int offset) const { return Common::swap16(*(u16*)(ptr+offset)); }
|
||||
u32 Peek32(int offset) const { return Common::swap32(*(u32*)(ptr+offset)); }
|
||||
u8 Read8 () {return *ptr++;}
|
||||
u16 Read16() {const u16 value = Common::swap16(*((u16*)ptr)); ptr+=2; return value;}
|
||||
u32 Read32() {const u32 value = Common::swap32(*((u32*)ptr)); ptr+=4; return value;}
|
||||
float Read32F() {const u32 value = Common::swap32(*((u32*)ptr)); ptr+=4; return *(float*)&value;}
|
||||
int GetRemainSize() const { return (int)(end - ptr); }
|
||||
u8 *GetPtr() const { return ptr; }
|
||||
void MoveEndForward() { end += 32; }
|
||||
u8 *GetEnd() const { return end; }
|
||||
};
|
||||
|
||||
extern FifoReader fifo;
|
||||
|
||||
void Fifo_Init();
|
||||
void Fifo_Shutdown();
|
||||
void Fifo_EnterLoop(const SVideoInitialize &video_initialize);
|
||||
|
||||
#endif
|
||||
|
42
Source/Core/VideoCommon/Src/OpcodeDecoding.h
Normal file
42
Source/Core/VideoCommon/Src/OpcodeDecoding.h
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifndef _OPCODE_DECODING_H
|
||||
#define _OPCODE_DECODING_H
|
||||
|
||||
#define GX_NOP 0x00
|
||||
|
||||
#define GX_LOAD_BP_REG 0x61
|
||||
#define GX_LOAD_CP_REG 0x08
|
||||
#define GX_LOAD_XF_REG 0x10
|
||||
#define GX_LOAD_INDX_A 0x20
|
||||
#define GX_LOAD_INDX_B 0x28
|
||||
#define GX_LOAD_INDX_C 0x30
|
||||
#define GX_LOAD_INDX_D 0x38
|
||||
|
||||
#define GX_CMD_CALL_DL 0x40
|
||||
#define GX_CMD_INVL_VC 0x48
|
||||
|
||||
#define GX_PRIMITIVE_MASK 0x78
|
||||
#define GX_PRIMITIVE_SHIFT 3
|
||||
#define GX_VAT_MASK 0x07
|
||||
|
||||
void OpcodeDecoder_Init();
|
||||
void OpcodeDecoder_Shutdown();
|
||||
void OpcodeDecoder_Run();
|
||||
|
||||
#endif
|
@ -6,6 +6,7 @@ files = ["BPMemory.cpp",
|
||||
"TextureDecoder.cpp",
|
||||
"XFMemory.cpp",
|
||||
"XFBConvert.cpp",
|
||||
"Fifo.cpp",
|
||||
]
|
||||
|
||||
env_common = env.Copy(CXXFLAGS = " -fPIC ")
|
||||
|
@ -43,7 +43,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -106,7 +106,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -168,7 +168,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
@ -229,7 +229,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
@ -289,7 +289,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
@ -350,7 +350,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
@ -405,6 +405,14 @@
|
||||
RelativePath=".\Src\CPMemory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Fifo.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Fifo.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\LookUpTables.cpp"
|
||||
>
|
||||
@ -413,6 +421,10 @@
|
||||
RelativePath=".\Src\LookUpTables.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\OpcodeDecoding.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\SConscript"
|
||||
>
|
||||
|
Reference in New Issue
Block a user