Eliminated the plugin interface. Merged DX9/DX11/OGL video plugins into Dolphin. It could still use a lot of cleanup. Lots of things are still named "plugin". Software renderer is temporarily disabled until it gets some namespaces. I only updated vs08/10, Linux/OSX builds are broken.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6996 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Jordan Woyak
2011-01-31 01:28:32 +00:00
parent ae7c64ec13
commit fbaf965995
136 changed files with 1537 additions and 3412 deletions

View File

@ -22,6 +22,8 @@
#include "VertexManagerBase.h"
#include "VertexShaderManager.h"
#include "VideoConfig.h"
#include "HW/Memmap.h"
#include "ConfigManager.h"
bool textureChanged[8];
const bool renderFog = false;
@ -202,7 +204,7 @@ bool GetConfig(const int &type)
switch (type)
{
case CONFIG_ISWII:
return g_VideoInitialize.bWii;
return SConfig::GetInstance().m_LocalCoreStartupParameter.bWii;
case CONFIG_DISABLEFOG:
return g_ActiveConfig.bDisableFog;
case CONFIG_SHOWEFBREGIONS:
@ -215,7 +217,7 @@ bool GetConfig(const int &type)
u8 *GetPointer(const u32 &address)
{
return g_VideoInitialize.pGetMemoryPointer(address);
return Memory::GetPointer(address);
}
void SetTextureMode(const BPCmd &bp)

View File

@ -78,10 +78,20 @@
#include "ChunkFile.h"
#include "CommandProcessor.h"
#include "PixelEngine.h"
#include "CoreTiming.h"
#include "ConfigManager.h"
#include "HW/ProcessorInterface.h"
#include "HW/GPFifo.h"
#include "HW/Memmap.h"
namespace CommandProcessor
{
bool IsOnThread()
{
return SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread;
}
int et_UpdateInterrupts;
@ -185,7 +195,7 @@ void Init()
s_fifoIdleEvent.Init();
et_UpdateInterrupts = g_VideoInitialize.pRegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper);
et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper);
}
void Shutdown()
@ -204,7 +214,7 @@ void Read16(u16& _rReturnValue, const u32 _Address)
// Here always there is one fifo attached to the GPU
if (g_VideoInitialize.bOnThread)
if (IsOnThread())
{
m_CPStatusReg.Breakpoint = fifo.bFF_Breakpoint;
m_CPStatusReg.ReadIdle = (fifo.CPReadPointer == fifo.CPWritePointer) || (fifo.CPReadPointer == fifo.CPBreakpoint);
@ -406,7 +416,7 @@ void Write16(const u16 _Value, const u32 _Address)
// (mb2) We don't sleep here since it could be a perf issue for super monkey ball (yup only this game IIRC)
// Touching that game is a no-go so I don't want to take the risk :p
if (g_VideoInitialize.bOnThread)
if (IsOnThread())
{
//ProcessFifoAllDistance();
@ -437,7 +447,7 @@ void Write16(const u16 _Value, const u32 _Address)
// seems invalid or has a bug and hang the game.
// Single Core MODE
if (!g_VideoInitialize.bOnThread)
if (!IsOnThread())
{
Common::AtomicStore(fifo.bFF_Breakpoint, false);
@ -463,9 +473,9 @@ void Write16(const u16 _Value, const u32 _Address)
if(tmpCtrl.GPReadEnable && tmpCtrl.GPLinkEnable)
{
*(g_VideoInitialize.Fifo_CPUWritePointer) = fifo.CPWritePointer;
*(g_VideoInitialize.Fifo_CPUBase) = fifo.CPBase;
*(g_VideoInitialize.Fifo_CPUEnd) = fifo.CPEnd;
ProcessorInterface::Fifo_CPUWritePointer = fifo.CPWritePointer;
ProcessorInterface::Fifo_CPUBase = fifo.CPBase;
ProcessorInterface::Fifo_CPUEnd = fifo.CPEnd;
}
// If overflown happens process the fifo to LoWatemark
if (bProcessFifoToLoWatemark)
@ -488,7 +498,7 @@ void Write16(const u16 _Value, const u32 _Address)
{
UCPClearReg tmpCtrl(_Value);
if (g_VideoInitialize.bOnThread)
if (IsOnThread())
{
if (!tmpCtrl.ClearFifoUnderflow && tmpCtrl.ClearFifoOverflow)
bProcessFifoToLoWatemark = true;
@ -607,7 +617,7 @@ void Write16(const u16 _Value, const u32 _Address)
WARN_LOG(COMMANDPROCESSOR, "(w16) unknown CP reg write %04x @ %08x", _Value, _Address);
}
if (!g_VideoInitialize.bOnThread)
if (!IsOnThread())
CatchUpGPU();
ProcessFifoEvents();
}
@ -648,12 +658,12 @@ void STACKALIGN GatherPipeBursted()
// if we aren't linked, we don't care about gather pipe data
if (!m_CPCtrlReg.GPLinkEnable)
{
if (!g_VideoInitialize.bOnThread)
if (!IsOnThread())
CatchUpGPU();
return;
}
if (g_VideoInitialize.bOnThread)
if (IsOnThread())
SetOverflowStatusFromGatherPipe();
@ -667,7 +677,7 @@ void STACKALIGN GatherPipeBursted()
if (!g_VideoInitialize.bOnThread)
if (!IsOnThread())
{
CatchUpGPU();
if (!m_CPStatusReg.OverflowHiWatermark && fifo.CPReadWriteDistance >= fifo.CPHiWatermark)
@ -703,17 +713,17 @@ void STACKALIGN GatherPipeBursted()
"FIFO is overflown by GatherPipe !\nCPU thread is too fast!");
// check if we are in sync
_assert_msg_(COMMANDPROCESSOR, fifo.CPWritePointer == *(g_VideoInitialize.Fifo_CPUWritePointer), "FIFOs linked but out of sync");
_assert_msg_(COMMANDPROCESSOR, fifo.CPBase == *(g_VideoInitialize.Fifo_CPUBase), "FIFOs linked but out of sync");
_assert_msg_(COMMANDPROCESSOR, fifo.CPEnd == *(g_VideoInitialize.Fifo_CPUEnd), "FIFOs linked but out of sync");
_assert_msg_(COMMANDPROCESSOR, fifo.CPWritePointer == ProcessorInterface::Fifo_CPUWritePointer, "FIFOs linked but out of sync");
_assert_msg_(COMMANDPROCESSOR, fifo.CPBase == ProcessorInterface::Fifo_CPUBase, "FIFOs linked but out of sync");
_assert_msg_(COMMANDPROCESSOR, fifo.CPEnd == ProcessorInterface::Fifo_CPUEnd, "FIFOs linked but out of sync");
}
// This is only used in single core mode
void CatchUpGPU()
{
// HyperIris: Memory_GetPtr is an expensive call, call it less, run faster
u8 *ptr = Memory_GetPtr(fifo.CPReadPointer);
// HyperIris: Memory::GetPointer is an expensive call, call it less, run faster
u8 *ptr = Memory::GetPointer(fifo.CPReadPointer);
// check if we are able to run this buffer
while (fifo.bFF_GPReadEnable && (fifo.CPReadWriteDistance ||
@ -767,31 +777,29 @@ void UpdateInterruptsScMode()
|| (m_CPCtrlReg.FifoUnderflowIntEnable && fifo.bFF_LoWatermark)
|| (m_CPCtrlReg.FifoOverflowIntEnable && m_CPStatusReg.OverflowHiWatermark);
INFO_LOG(COMMANDPROCESSOR, "Fifo Interrupt: %s", (active)? "Asserted" : "Deasserted");
g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, active);
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, active);
}
void UpdateInterrupts(u64 userdata)
{
if (userdata)
{
interruptSet = true;
INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, true);
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true);
}
else
{
interruptSet = false;
INFO_LOG(COMMANDPROCESSOR,"Interrupt cleared");
g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, false);
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, false);
}
interruptWaiting = false;
}
void UpdateInterruptsFromVideoPlugin(u64 userdata)
{
g_VideoInitialize.pScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata);
CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata);
}
void SetFifoIdleFromVideoPlugin()
@ -807,8 +815,8 @@ void AbortFrame()
{
fifo.bFF_GPReadEnable = false;
while (CommandProcessor::isFifoBusy)
Common::YieldCPU();
g_VideoInitialize.pResetGatherPipe();
Common::YieldCPU();
GPFifo::ResetGatherPipe();
ResetVideoBuffer();
fifo.CPReadPointer = fifo.CPWritePointer;
fifo.CPReadWriteDistance = 0;
@ -876,7 +884,7 @@ void SetStatus()
if (interrupt != interruptSet && !interruptWaiting)
{
u64 userdata = interrupt?1:0;
if (g_VideoInitialize.bOnThread)
if (IsOnThread())
{
interruptWaiting = true;
CommandProcessor::UpdateInterruptsFromVideoPlugin(userdata);
@ -890,7 +898,7 @@ void SetStatus()
void ProcessFifoToLoWatemark()
{
if (g_VideoInitialize.bOnThread)
if (IsOnThread())
{
while (!CommandProcessor::interruptWaiting && fifo.bFF_GPReadEnable &&
fifo.CPReadWriteDistance > fifo.CPLoWatermark && !AtBreakpoint())
@ -901,7 +909,7 @@ void ProcessFifoToLoWatemark()
void ProcessFifoAllDistance()
{
if (g_VideoInitialize.bOnThread)
if (IsOnThread())
{
while (!CommandProcessor::interruptWaiting && fifo.bFF_GPReadEnable &&
fifo.CPReadWriteDistance && !AtBreakpoint())
@ -912,8 +920,8 @@ void ProcessFifoAllDistance()
void ProcessFifoEvents()
{
if (g_VideoInitialize.bOnThread && (interruptWaiting || interruptFinishWaiting || interruptTokenWaiting))
g_VideoInitialize.pProcessFifoEvents();
if (IsOnThread() && (interruptWaiting || interruptFinishWaiting || interruptTokenWaiting))
CoreTiming::ProcessFifoWaitEvents();
}

View File

@ -19,7 +19,7 @@
#define _COMMANDPROCESSOR_H
#include "Common.h"
#include "pluginspecs_video.h"
#include "VideoBackendBase.h"
class PointerWrap;

View File

@ -26,6 +26,7 @@
#include "DataReader.h"
#include "Statistics.h"
#include "OpcodeDecoding.h" // For the GX_ constants.
#include "HW/Memmap.h"
#include "XFMemory.h"
#include "CPMemory.h"
@ -281,9 +282,9 @@ u8 AnalyzeAndRunDisplayList(u32 address, int size, CachedDisplayList *dl)
int num_draw_call = 0;
u8 result = 0;
u8* old_pVideoData = g_pVideoData;
u8* startAddress = Memory_GetPtr(address);
u8* startAddress = Memory::GetPointer(address);
// Avoid the crash if Memory_GetPtr failed ..
// Avoid the crash if Memory::GetPointer failed ..
if (startAddress != 0)
{
g_pVideoData = startAddress;
@ -417,9 +418,9 @@ u8 AnalyzeAndRunDisplayList(u32 address, int size, CachedDisplayList *dl)
bool CompileAndRunDisplayList(u32 address, int size, CachedDisplayList *dl)
{
u8* old_pVideoData = g_pVideoData;
u8* startAddress = Memory_GetPtr(address);
u8* startAddress = Memory::GetPointer(address);
// Avoid the crash if Memory_GetPtr failed ..
// Avoid the crash if Memory::GetPointer failed ..
if (startAddress != 0)
{
g_pVideoData = startAddress;
@ -707,7 +708,7 @@ bool HandleDisplayList(u32 address, u32 size)
{
case DLCache::DLPASS_COMPILE:
// First, check that the hash is the same as the last time.
if (dl.dl_hash != GetHash64(Memory_GetPtr(address), size, 0))
if (dl.dl_hash != GetHash64(Memory::GetPointer(address), size, 0))
{
// PanicAlert("uncachable %08x", address);
dl.uncachable = true;
@ -722,7 +723,7 @@ bool HandleDisplayList(u32 address, u32 size)
dl.check--;
if (dl.check <= 0)
{
if (dl.dl_hash != GetHash64(Memory_GetPtr(address), size, 0) || !dl.CheckRegions())
if (dl.dl_hash != GetHash64(Memory::GetPointer(address), size, 0) || !dl.CheckRegions())
{
dl.uncachable = true;
dl.check = 60;
@ -760,7 +761,7 @@ bool HandleDisplayList(u32 address, u32 size)
DLCache::CachedDisplayList dl;
u8 dlvatused = DLCache::AnalyzeAndRunDisplayList(address, size, &dl);
dl.dl_hash = GetHash64(Memory_GetPtr(address), size,0);
dl.dl_hash = GetHash64(Memory::GetPointer(address), size,0);
dl.pass = DLCache::DLPASS_COMPILE;
dl.check = 1;
dl.next_check = 1;

View File

@ -31,7 +31,7 @@ volatile bool GFXDebuggerPauseFlag = false;
volatile PauseEvent GFXDebuggerToPauseAtNext = NOT_PAUSE;
volatile int GFXDebuggerEventToPauseCount = 0;
void UpdateFPSDisplay(const char *text);
//void UpdateFPSDisplay(const char *text);
extern NativeVertexFormat *g_nativeVertexFmt;
void GFXDebuggerUpdateScreen()
@ -69,7 +69,7 @@ void GFXDebuggerCheckAndPause(bool update)
g_pdebugger->OnPause();
while( GFXDebuggerPauseFlag )
{
UpdateFPSDisplay("Paused by Video Debugger");
g_video_backend->UpdateFPSDisplay("Paused by Video Debugger");
if (update) GFXDebuggerUpdateScreen();
SLEEP(5);

View File

@ -22,7 +22,8 @@
#include "Fifo.h"
#include "VertexShaderManager.h"
#include "RenderBase.h"
#include "VideoBackendBase.h"
#include "Core.h"
int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
@ -223,7 +224,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
return true;
case WM_DESTROY:
Shutdown();
g_video_backend->Shutdown();
break;
default:
return DefWindowProc(hWnd, iMsg, wParam, lParam);
@ -323,7 +324,7 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title)
// 3. Request window sizes which actually make the client area map to a common resolution
HWND Ret;
int x=0, y=0, width=640, height=480;
g_VideoInitialize.pGetWindowSize(x, y, width, height);
Core::Callback_VideoGetWindowSize(x, y, width, height);
// TODO: Don't show if fullscreen
Ret = OpenWindow(hParent, hInstance, width, height, title);

View File

@ -24,6 +24,7 @@
#include "CommandProcessor.h"
#include "ChunkFile.h"
#include "Fifo.h"
#include "HW/Memmap.h"
volatile bool g_bSkipCurrentFrame = false;
volatile bool g_EFBAccessRequested = false;
@ -134,16 +135,15 @@ void ResetVideoBuffer()
// Description: Main FIFO update loop
// Purpose: Keep the Core HW updated about the CPU-GPU distance
void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
void Fifo_EnterLoop()
{
fifoStateRun = true;
SCPFifoStruct &_fifo = CommandProcessor::fifo;
s32 distToSend;
while (fifoStateRun)
{
video_initialize.pPeekMessages();
g_video_backend->PeekMessages();
VideoFifo_CheckAsyncRequest();
@ -164,7 +164,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
// Create pointer to video data and send it to the VideoPlugin
u32 readPtr = _fifo.CPReadPointer;
u8 *uData = video_initialize.pGetMemoryPointer(readPtr);
u8 *uData = Memory::GetPointer(readPtr);
distToSend = 32;
@ -204,7 +204,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
// While the emu is paused, we still handle async request such as Savestates then sleep.
while (!EmuRunning)
{
video_initialize.pPeekMessages();
g_video_backend->PeekMessages();
VideoFifo_CheckAsyncRequest();
Common::SleepCurrentThread(10);
}

View File

@ -18,8 +18,8 @@
#ifndef _FIFO_H
#define _FIFO_H
#include "pluginspecs_video.h"
#include "Common.h"
#include "VideoBackendBase.h"
class PointerWrap;
@ -34,7 +34,7 @@ void Fifo_Shutdown();
void Fifo_SendFifoData(u8* _uData, u32 len);
// These two are for dual core mode only.
void Fifo_EnterLoop(const SVideoInitialize &video_initialize);
void Fifo_EnterLoop();
void Fifo_ExitLoop();
void Fifo_ExitLoopNonBlocking();
void Fifo_RunLoop(bool run);

View File

@ -12,6 +12,8 @@
#include "Fifo.h"
#include "BPStructs.h"
#include "OnScreenDisplay.h"
#include "VideoBackendBase.h"
#include "ConfigManager.h"
bool s_PluginInitialized = false;
@ -37,25 +39,24 @@ static struct
static u32 s_AccessEFBResult = 0;
void EmuStateChange(PLUGIN_EMUSTATE newState)
void VideoBackendHLE::EmuStateChange(PLUGIN_EMUSTATE newState)
{
Fifo_RunLoop((newState == PLUGIN_EMUSTATE_PLAY) ? true : false);
}
// Enter and exit the video loop
void Video_EnterLoop()
void VideoBackendHLE::Video_EnterLoop()
{
Fifo_EnterLoop(g_VideoInitialize);
Fifo_EnterLoop();
}
void Video_ExitLoop()
void VideoBackendHLE::Video_ExitLoop()
{
Fifo_ExitLoop();
s_FifoShuttingDown = true;
}
void Video_SetRendering(bool bEnabled)
void VideoBackendHLE::Video_SetRendering(bool bEnabled)
{
Fifo_SetRendering(bEnabled);
}
@ -93,11 +94,11 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
}
// Run from the CPU thread (from VideoInterface.cpp)
void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
void VideoBackendHLE::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
{
if (s_PluginInitialized && g_ActiveConfig.bUseXFB)
{
if (!g_VideoInitialize.bOnThread)
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread)
VideoFifo_CheckSwapRequest();
s_beginFieldArgs.xfbAddr = xfbAddr;
s_beginFieldArgs.field = field;
@ -107,7 +108,7 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
}
// Run from the CPU thread (from VideoInterface.cpp)
void Video_EndField()
void VideoBackendHLE::Video_EndField()
{
if (s_PluginInitialized)
{
@ -115,15 +116,16 @@ void Video_EndField()
}
}
void Video_AddMessage(const char* pstr, u32 milliseconds)
void VideoBackendHLE::Video_AddMessage(const char* pstr, u32 milliseconds)
{
OSD::AddMessage(pstr, milliseconds);
}
// Screenshot
void Video_Screenshot(const char *_szFilename)
bool VideoBackendHLE::Video_Screenshot(const char *_szFilename)
{
Renderer::SetScreenshot(_szFilename);
return true;
}
void VideoFifo_CheckEFBAccess()
@ -136,7 +138,7 @@ void VideoFifo_CheckEFBAccess()
}
}
u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
u32 VideoBackendHLE::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
{
if (s_PluginInitialized)
{
@ -147,7 +149,7 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
Common::AtomicStoreRelease(s_efbAccessRequested, TRUE);
if (g_VideoInitialize.bOnThread)
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread)
{
while (Common::AtomicLoadAcquire(s_efbAccessRequested) && !s_FifoShuttingDown)
//Common::SleepCurrentThread(1);
@ -196,12 +198,12 @@ static void check_DoState() {
}
// Run from the CPU thread
void DoState(unsigned char **ptr, int mode)
void VideoBackendHLE::DoState(PointerWrap& p)
{
s_doStateArgs.ptr = ptr;
s_doStateArgs.mode = mode;
s_doStateArgs.ptr = p.ptr;
s_doStateArgs.mode = p.mode;
Common::AtomicStoreRelease(s_doStateRequested, TRUE);
if (g_VideoInitialize.bOnThread)
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread)
{
while (Common::AtomicLoadAcquire(s_doStateRequested) && !s_FifoShuttingDown)
//Common::SleepCurrentThread(1);
@ -218,47 +220,22 @@ void VideoFifo_CheckAsyncRequest()
check_DoState();
}
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
{
CommandProcessor::Read16(_rReturnValue, _Address);
}
void Video_CommandProcessorWrite16(const u16 _Data, const u32 _Address)
{
CommandProcessor::Write16(_Data, _Address);
}
void Video_PixelEngineRead16(u16& _rReturnValue, const u32 _Address)
{
PixelEngine::Read16(_rReturnValue, _Address);
}
void Video_PixelEngineWrite16(const u16 _Data, const u32 _Address)
{
PixelEngine::Write16(_Data, _Address);
}
void Video_PixelEngineWrite32(const u32 _Data, const u32 _Address)
{
PixelEngine::Write32(_Data, _Address);
}
void Video_GatherPipeBursted(void)
void VideoBackend::Video_GatherPipeBursted()
{
CommandProcessor::GatherPipeBursted();
}
void Video_WaitForFrameFinish(void)
void VideoBackendHLE::Video_WaitForFrameFinish()
{
CommandProcessor::WaitForFrameFinish();
}
bool Video_IsFifoBusy(void)
bool VideoBackendHLE::Video_IsFifoBusy()
{
return CommandProcessor::isFifoBusy;
}
void Video_AbortFrame(void)
void VideoBackendHLE::Video_AbortFrame()
{
CommandProcessor::AbortFrame();
}

View File

@ -30,6 +30,9 @@
#include "OpcodeDecoding.h"
#include "CommandProcessor.h"
#include "CPUDetect.h"
#include "Core.h"
#include "Host.h"
#include "HW/Memmap.h"
#include "VertexLoaderManager.h"
@ -95,9 +98,9 @@ static void Decode();
void InterpretDisplayList(u32 address, u32 size)
{
u8* old_pVideoData = g_pVideoData;
u8* startAddress = Memory_GetPtr(address);
u8* startAddress = Memory::GetPointer(address);
// Avoid the crash if Memory_GetPtr failed ..
// Avoid the crash if Memory::GetPointer failed ..
if (startAddress != 0)
{
g_pVideoData = startAddress;
@ -201,16 +204,16 @@ bool FifoCommandRunnable()
else
{
// TODO(Omega): Maybe dump FIFO to file on this error
char szTemp[1024];
sprintf(szTemp, "GFX FIFO: Unknown Opcode (0x%x).\n"
char szTemp[1024];
sprintf(szTemp, "GFX FIFO: Unknown Opcode (0x%x).\n"
"This means one of the following:\n"
"* The emulated GPU got desynced, disabling dual core can help\n"
"* Command stream corrupted by some spurious memory bug\n"
"* This really is an unknown opcode (unlikely)\n"
"* Some other sort of bug\n\n"
"Dolphin will now likely crash or hang. Enjoy." , cmd_byte);
g_VideoInitialize.pSysMessage(szTemp);
g_VideoInitialize.pLog(szTemp, TRUE);
Host_SysMessage(szTemp);
Core::Callback_VideoLog(szTemp, TRUE);
{
SCPFifoStruct &fifo = CommandProcessor::fifo;
@ -234,8 +237,8 @@ bool FifoCommandRunnable()
,fifo.bFF_BPEnable ? "true" : "false" ,fifo.bFF_BPInt ? "true" : "false"
,fifo.bFF_Breakpoint ? "true" : "false");
g_VideoInitialize.pSysMessage(szTmp);
g_VideoInitialize.pLog(szTmp, TRUE);
Host_SysMessage(szTmp);
Core::Callback_VideoLog(szTmp, TRUE);
}
}
break;

View File

@ -24,9 +24,12 @@
#include "VideoCommon.h"
#include "ChunkFile.h"
#include "Atomic.h"
#include "CoreTiming.h"
#include "ConfigManager.h"
#include "PixelEngine.h"
#include "CommandProcessor.h"
#include "HW/ProcessorInterface.h"
namespace PixelEngine
{
@ -151,8 +154,8 @@ void Init()
{
m_Control.Hex = 0;
et_SetTokenOnMainThread = g_VideoInitialize.pRegisterEvent("SetToken", SetToken_OnMainThread);
et_SetFinishOnMainThread = g_VideoInitialize.pRegisterEvent("SetFinish", SetFinish_OnMainThread);
et_SetTokenOnMainThread = CoreTiming::RegisterEvent("SetToken", SetToken_OnMainThread);
et_SetFinishOnMainThread = CoreTiming::RegisterEvent("SetFinish", SetFinish_OnMainThread);
bbox[0] = 0x80;
bbox[1] = 0xA0;
@ -298,7 +301,7 @@ void Write32(const u32 _iValue, const u32 _iAddress)
bool AllowIdleSkipping()
{
return !g_VideoInitialize.bOnThread || (!m_Control.PETokenEnable && !m_Control.PEFinishEnable);
return !SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread || (!m_Control.PETokenEnable && !m_Control.PEFinishEnable);
}
void UpdateInterrupts()
@ -314,7 +317,7 @@ void UpdateTokenInterrupt(bool active)
{
if(interruptSetToken != active)
{
g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_TOKEN, active);
ProcessorInterface::SetInterrupt(INT_CAUSE_PE_TOKEN, active);
interruptSetToken = active;
}
}
@ -324,7 +327,7 @@ void UpdateFinishInterrupt(bool active)
if(interruptSetFinish != active)
{
g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_FINISH, active);
ProcessorInterface::SetInterrupt(INT_CAUSE_PE_FINISH, active);
interruptSetFinish = active;
}
}
@ -366,8 +369,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge)
CommandProcessor::IncrementGPWDToken(); // for DC watchdog hack since PEToken seems to be a frame-finish too
Common::AtomicStore(*(volatile u32*)&CommandProcessor::fifo.PEToken, _token);
CommandProcessor::interruptTokenWaiting = true;
g_VideoInitialize.pScheduleEvent_Threadsafe(
0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16));
CoreTiming::ScheduleEvent_Threadsafe(0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16));
}
else // set token value
{
@ -386,8 +388,7 @@ void SetFinish()
{
CommandProcessor::IncrementGPWDToken(); // for DC watchdog hack
CommandProcessor::interruptFinishWaiting = true;
g_VideoInitialize.pScheduleEvent_Threadsafe(
0, et_SetFinishOnMainThread, 0);
CoreTiming::ScheduleEvent_Threadsafe(0, et_SetFinishOnMainThread, 0);
INFO_LOG(PIXELENGINE, "VIDEO Set Finish");
}
@ -401,9 +402,10 @@ void ResetSetFinish()
UpdateFinishInterrupt(false);
g_bSignalFinishInterrupt = false;
}else
}
else
{
g_VideoInitialize.pRemoveEvent(et_SetFinishOnMainThread);
CoreTiming::RemoveEvent(et_SetFinishOnMainThread);
}
CommandProcessor::interruptFinishWaiting = false;
}
@ -415,9 +417,10 @@ void ResetSetToken()
UpdateTokenInterrupt(false);
g_bSignalTokenInterrupt = false;
}else
}
else
{
g_VideoInitialize.pRemoveEvent(et_SetTokenOnMainThread);
CoreTiming::RemoveEvent(et_SetTokenOnMainThread);
}
CommandProcessor::interruptTokenWaiting = false;
}

View File

@ -22,7 +22,9 @@
#include "PixelShaderManager.h"
#include "VideoCommon.h"
#include "VideoConfig.h"
#include "RenderBase.h"
static float GC_ALIGNED16(s_fMaterials[16]);
static int s_nColorsChanged[2]; // 0 - regular colors, 1 - k colors
static int s_nIndTexMtxChanged;
@ -43,6 +45,21 @@ static u32 lastTexDims[8]; // width | height << 16 | wrap_s << 28 | wrap_t << 30
static u32 lastZBias;
static int nMaterialsChanged;
inline void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
g_renderer->SetPSConstant4f(const_number, f1, f2, f3, f4);
}
inline void SetPSConstant4fv(unsigned int const_number, const float *f)
{
g_renderer->SetPSConstant4fv(const_number, f);
}
inline void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
g_renderer->SetMultiPSConstant4fv(const_number, count, f);
}
void PixelShaderManager::Init()
{
lastAlpha = 0;
@ -97,7 +114,7 @@ void PixelShaderManager::SetConstants()
if (s_bAlphaChanged)
{
SetPSConstant4f(C_ALPHA, (lastAlpha&0xff)/255.0f, ((lastAlpha>>8)&0xff)/255.0f, 0, ((lastAlpha>>16)&0xff)/255.0f);
SetPSConstant4f(C_ALPHA, (lastAlpha&0xff)/255.0f, ((lastAlpha>>8)&0xff)/255.0f, 0, ((lastAlpha>>16)&0xff)/255.0f);
s_bAlphaChanged = false;
}
@ -126,7 +143,7 @@ void PixelShaderManager::SetConstants()
if (s_bZBiasChanged || s_bDepthRangeChanged)
{
//ERROR_LOG("pixel=%x,%x, bias=%x\n", bpmem.zcontrol.pixel_format, bpmem.ztex2.type, lastZBias);
SetPSConstant4f(C_ZBIAS+1, lastDepthRange[0] / 16777216.0f, lastDepthRange[1] / 16777216.0f, 0, (float)(lastZBias)/16777215.0f);
SetPSConstant4f(C_ZBIAS+1, lastDepthRange[0] / 16777216.0f, lastDepthRange[1] / 16777216.0f, 0, (float)(lastZBias)/16777215.0f);
s_bZBiasChanged = s_bDepthRangeChanged = false;
}
@ -144,7 +161,7 @@ void PixelShaderManager::SetConstants()
f[2 * i + 1] = bpmem.texscale[0].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
SetPSConstant4fv(C_INDTEXSCALE, f);
SetPSConstant4fv(C_INDTEXSCALE, f);
}
if (s_nIndTexScaleChanged & 0x0c) {
@ -153,7 +170,7 @@ void PixelShaderManager::SetConstants()
f[2 * i + 1] = bpmem.texscale[1].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]);
SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]);
}
s_nIndTexScaleChanged = 0;
@ -173,7 +190,7 @@ void PixelShaderManager::SetConstants()
// xyz - static matrix
// TODO w - dynamic matrix scale / 256...... somehow / 4 works better
// rev 2972 - now using / 256.... verify that this works
SetPSConstant4f(C_INDTEXMTX + 2 * i,
SetPSConstant4f(C_INDTEXMTX + 2 * i,
bpmem.indmtx[i].col0.ma * fscale,
bpmem.indmtx[i].col1.mc * fscale,
bpmem.indmtx[i].col2.me * fscale,
@ -195,8 +212,8 @@ void PixelShaderManager::SetConstants()
if (s_bFogColorChanged)
{
SetPSConstant4f(C_FOG, bpmem.fog.color.r / 255.0f, bpmem.fog.color.g / 255.0f, bpmem.fog.color.b / 255.0f, 0);
s_bFogColorChanged = false;
SetPSConstant4f(C_FOG, bpmem.fog.color.r / 255.0f, bpmem.fog.color.g / 255.0f, bpmem.fog.color.b / 255.0f, 0);
s_bFogColorChanged = false;
}
if (s_bFogParamChanged)

View File

@ -22,10 +22,6 @@
#include "XFMemory.h"
#include "PixelShaderGen.h"
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4);
void SetPSConstant4fv(unsigned int const_number, const float *f);
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f);
// The non-API dependent parts.
class PixelShaderManager
{

View File

@ -42,9 +42,6 @@
int frameCount;
//int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
SVideoInitialize g_VideoInitialize;
PLUGIN_GLOBALS* globals;
Renderer *g_renderer;
bool s_bLastFrameDumped = false;

View File

@ -31,7 +31,6 @@
#include "VideoCommon.h"
#include "Thread.h"
#include "MathUtil.h"
#include "pluginspecs_video.h"
#include "NativeVertexFormat.h"
#include "FramebufferManagerBase.h"
#include "BPMemory.h"
@ -43,8 +42,6 @@ extern int frameCount;
extern int OSDChoice, OSDTime;
extern bool s_bLastFrameDumped;
extern SVideoInitialize g_VideoInitialize;
extern PLUGIN_GLOBALS* globals;
// Renderer really isn't a very good name for this class - it's more like "Misc".
// The long term goal is to get rid of this class and replace it with others that make
@ -132,6 +129,17 @@ public:
static unsigned int GetPrevPixelFormat() { return prev_efb_format; }
static void StorePixelFormat(unsigned int new_format) { prev_efb_format = new_format; }
// TODO: doesn't belong here
virtual void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) = 0;
virtual void SetPSConstant4fv(unsigned int const_number, const float *f) = 0;
virtual void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) = 0;
// TODO: doesn't belong here
virtual void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) = 0;
virtual void SetVSConstant4fv(unsigned int const_number, const float *f) = 0;
virtual void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) = 0;
virtual void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) = 0;
protected:
static Common::CriticalSection s_criticalScreenshot;

View File

@ -11,6 +11,8 @@
#include "TextureCacheBase.h"
#include "Debugger.h"
#include "ConfigManager.h"
#include "HW/Memmap.h"
// ugly
extern int frameCount;
@ -33,20 +35,17 @@ TextureCache::TCacheEntryBase::~TCacheEntryBase()
if (!isRenderTarget && !g_ActiveConfig.bSafeTextureCache)
{
u32 *const ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr);
u32 *const ptr = (u32*)Memory::GetPointer(addr);
if (ptr && *ptr == hash)
*ptr = oldpixel;
}
}
// TODO: uglyness
extern PLUGIN_GLOBALS *globals;
TextureCache::TextureCache()
{
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
HiresTextures::Init(globals->unique_id);
HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
}
void TextureCache::Invalidate(bool shutdown)
@ -164,7 +163,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
if (0 == address)
return NULL;
u8* ptr = g_VideoInitialize.pGetMemoryPointer(address);
u8* ptr = Memory::GetPointer(address);
// TexelSizeInNibbles(format)*width*height/16;
const unsigned int bsw = TexDecoder_GetBlockWidthInTexels(texformat) - 1;
@ -288,7 +287,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
unsigned int newWidth = width;
unsigned int newHeight = height;
sprintf(texPathTemp, "%s_%08llx_%i", globals->unique_id, texHash, texformat);
sprintf(texPathTemp, "%s_%08llx_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), texHash, texformat);
pcfmt = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, texformat, temp);
if (pcfmt != PC_TEX_FMT_NONE)
@ -385,11 +384,11 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
char szDir[MAX_PATH];
// make sure that the directory exists
sprintf(szDir, "%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), globals->unique_id);
sprintf(szDir, "%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
if (false == File::Exists(szDir) || false == File::IsDirectory(szDir))
File::CreateDir(szDir);
sprintf(szTemp, "%s/%s_%08llx_%i.png", szDir, globals->unique_id, texHash, texformat);
sprintf(szTemp, "%s/%s_%08llx_%i.png", szDir, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), texHash, texformat);
if (false == File::Exists(szTemp))
entry->Save(szTemp);

View File

@ -25,6 +25,7 @@
#include "PixelShaderManager.h"
#include "PixelShaderGen.h"
#include "BPMemory.h"
#include "RenderBase.h"
#define WRITE p+=sprintf
@ -874,8 +875,8 @@ const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
void SetShaderParameters(float width, float height, float offsetX, float offsetY, float widthStride, float heightStride,float buffW,float buffH)
{
SetPSConstant4f(C_COLORMATRIX, widthStride, heightStride, buffW, buffH);
SetPSConstant4f(C_COLORMATRIX + 1, width, (height - 1), offsetX, offsetY);
g_renderer->SetPSConstant4f(C_COLORMATRIX, widthStride, heightStride, buffW, buffH);
g_renderer->SetPSConstant4f(C_COLORMATRIX + 1, width, (height - 1), offsetX, offsetY);
}
} // namespace

View File

@ -25,6 +25,7 @@
#include "x64Emitter.h"
#include "ABI.h"
#include "PixelEngine.h"
#include "Host.h"
#include "LookUpTables.h"
#include "Statistics.h"
@ -302,7 +303,7 @@ void VertexLoader::CompileVertexTranslator()
{
char temp[256];
sprintf(temp,"%i %i %i %i", m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3);
g_VideoInitialize.pSysMessage("VertexLoader_Normal::GetFunction returned zero!");
Host_SysMessage("VertexLoader_Normal::GetFunction returned zero!");
}
WriteCall(pFunc);

View File

@ -32,6 +32,7 @@ using __gnu_cxx::hash_map;
#include "VertexShaderManager.h"
#include "VertexLoader.h"
#include "VertexLoaderManager.h"
#include "HW/Memmap.h"
static int s_attr_dirty; // bitfield
@ -204,7 +205,7 @@ void LoadCPReg(u32 sub_cmd, u32 value)
// Pointers to vertex arrays in GC RAM
case 0xA0:
arraybases[sub_cmd & 0xF] = value;
cached_arraybases[sub_cmd & 0xF] = Memory_GetPtr(value);
cached_arraybases[sub_cmd & 0xF] = Memory::GetPointer(value);
break;
case 0xB0:
@ -217,6 +218,6 @@ void RecomputeCachedArraybases()
{
for (int i = 0; i < 16; i++)
{
cached_arraybases[i] = Memory_GetPtr(arraybases[i]);
cached_arraybases[i] = Memory::GetPointer(arraybases[i]);
}
}

View File

@ -32,6 +32,8 @@
#include "VideoCommon.h"
#include "VertexManagerBase.h"
#include "RenderBase.h"
static float GC_ALIGNED16(s_fMaterials[16]);
float GC_ALIGNED16(g_fProjectionMatrix[16]);
@ -50,6 +52,26 @@ static float s_fViewRotation[2];
void UpdateViewport();
inline void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{
g_renderer->SetVSConstant4f(const_number, f1, f2, f3, f4);
}
inline void SetVSConstant4fv(unsigned int const_number, const float *f)
{
g_renderer->SetVSConstant4fv(const_number, f);
}
inline void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f)
{
g_renderer->SetMultiVSConstant3fv(const_number, count, f);
}
inline void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f)
{
g_renderer->SetMultiVSConstant4fv(const_number, count, f);
}
namespace
{
// Control Variables

View File

@ -55,10 +55,4 @@ public:
static void ResetView();
};
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4);
void SetVSConstant4fv(unsigned int const_number, const float *f);
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f);
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f);
#endif // _VERTEXSHADERMANAGER_H

View File

@ -20,7 +20,7 @@
#include "Common.h"
#include "MathUtil.h"
#include "pluginspecs_video.h"
#include "VideoBackendBase.h"
#if defined(_MSC_VER) && !defined(__x86_64__) && !defined(_M_X64)
void * memcpy_amd(void *dest, const void *src, size_t n);
@ -57,44 +57,6 @@ enum
// Do testing to figure out if the speed hit is bad?
// #define BBOX_SUPPORT
extern SVideoInitialize g_VideoInitialize;
inline u8 *Memory_GetPtr(u32 _uAddress)
{
return g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u8 Memory_Read_U8(u32 _uAddress)
{
return *(u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u16 Memory_Read_U16(u32 _uAddress)
{
return Common::swap16(*(u16*)g_VideoInitialize.pGetMemoryPointer(_uAddress));
}
inline u32 Memory_Read_U32(u32 _uAddress)
{
return Common::swap32(*(u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress));
}
inline u8* Memory_Read_U8_Ptr(u32 _uAddress)
{
return (u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u16* Memory_Read_U16_Unswapped_Ptr(u32 _uAddress)
{
return (u16*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u32* Memory_Read_U32_Unswapped_Ptr(u32 _uAddress)
{
return (u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
// Logging
// ----------
void HandleGLError();

View File

@ -243,6 +243,9 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Save(ini_file);
}
// TODO: remove
extern bool g_aspect_wide;
// TODO: Figure out a better place for this function.
void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc)
{
@ -257,7 +260,7 @@ void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip
// Handle aspect ratio.
// Default to auto.
bool use16_9 = g_VideoInitialize.bAutoAspectIs16_9;
bool use16_9 = g_aspect_wide;
// Update aspect ratio hack values
// Won't take effect until next frame

View File

@ -22,6 +22,7 @@
#include "VertexManagerBase.h"
#include "VertexShaderManager.h"
#include "PixelShaderManager.h"
#include "HW/Memmap.h"
// LoadXFReg 0x10
void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
@ -224,5 +225,5 @@ void LoadIndexedXF(u32 val, int array)
//PRIM_LOG("xfmem iwrite: 0x%x-0x%x\n", address, address+size);
for (int i = 0; i < size; i++)
xfmem[address + i] = Memory_Read_U32(arraybases[array] + arraystrides[array] * index + i * 4);
xfmem[address + i] = Memory::Read_U32(arraybases[array] + arraystrides[array] * index + i * 4);
}