2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// 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/
|
|
|
|
|
2009-06-06 13:36:33 +00:00
|
|
|
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2009-06-06 13:36:33 +00:00
|
|
|
// OpenGL Plugin Documentation
|
2009-06-15 06:39:26 +00:00
|
|
|
/*
|
2009-06-06 13:36:33 +00:00
|
|
|
|
|
|
|
1.1 Display settings
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2009-09-09 19:52:45 +00:00
|
|
|
Internal and fullscreen resolution: Since the only internal resolutions allowed
|
|
|
|
are also fullscreen resolution allowed by the system there is only need for one
|
|
|
|
resolution setting that applies to both the internal resolution and the
|
|
|
|
fullscreen resolution. - Apparently no, someone else doesn't agree
|
2009-06-06 13:36:33 +00:00
|
|
|
|
2009-09-09 19:52:45 +00:00
|
|
|
Todo: Make the internal resolution option apply instantly, currently only the
|
|
|
|
native and 2x option applies instantly. To do this we need to be able to change
|
|
|
|
the reinitialize FramebufferManager:Init() while a game is running.
|
2009-06-06 13:36:33 +00:00
|
|
|
|
2009-06-07 11:51:53 +00:00
|
|
|
1.2 Screenshots
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2009-06-07 11:51:53 +00:00
|
|
|
|
2009-09-09 19:52:45 +00:00
|
|
|
The screenshots should be taken from the internal representation of the picture
|
|
|
|
regardless of what the current window size is. Since AA and wireframe is
|
|
|
|
applied together with the picture resizing this rule is not currently applied
|
|
|
|
to AA or wireframe pictures, they are instead taken from whatever the window
|
|
|
|
size is.
|
2009-06-07 11:51:53 +00:00
|
|
|
|
2009-09-09 19:52:45 +00:00
|
|
|
Todo: Render AA and wireframe to a separate picture used for the screenshot in
|
|
|
|
addition to the one for display.
|
2009-06-07 11:51:53 +00:00
|
|
|
|
|
|
|
1.3 AA
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2009-06-07 11:51:53 +00:00
|
|
|
Make AA apply instantly during gameplay if possible
|
|
|
|
|
2009-06-15 06:39:26 +00:00
|
|
|
*/
|
2009-06-06 13:36:33 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "Globals.h"
|
2009-07-12 21:58:32 +00:00
|
|
|
#include "LogManager.h"
|
|
|
|
#include "Thread.h"
|
2009-07-13 05:38:34 +00:00
|
|
|
#include "Atomic.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-01-11 13:37:13 +00:00
|
|
|
#include <cstdarg>
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "OS/Win32.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
#include "GUI/ConfigDlg.h"
|
2009-07-02 17:11:27 +00:00
|
|
|
GFXConfigDialogOGL *m_ConfigFrame = NULL;
|
|
|
|
#include "Debugger/Debugger.h"
|
|
|
|
GFXDebuggerOGL *m_DebuggerFrame = NULL;
|
2009-07-26 09:52:35 +00:00
|
|
|
#endif // HAVE_WX
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-09-13 09:23:30 +00:00
|
|
|
#include "VideoConfig.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "LookUpTables.h"
|
|
|
|
#include "ImageWrite.h"
|
|
|
|
#include "Render.h"
|
|
|
|
#include "GLUtil.h"
|
|
|
|
#include "Fifo.h"
|
|
|
|
#include "OpcodeDecoding.h"
|
|
|
|
#include "TextureMngr.h"
|
2009-06-22 09:31:30 +00:00
|
|
|
#include "BPStructs.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "VertexLoader.h"
|
|
|
|
#include "VertexLoaderManager.h"
|
|
|
|
#include "VertexManager.h"
|
2008-12-26 11:23:59 +00:00
|
|
|
#include "PixelShaderCache.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "PixelShaderManager.h"
|
2008-12-26 11:23:59 +00:00
|
|
|
#include "VertexShaderCache.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "VertexShaderManager.h"
|
|
|
|
#include "XFB.h"
|
|
|
|
#include "XFBConvert.h"
|
2009-10-10 21:19:39 +00:00
|
|
|
#include "CommandProcessor.h"
|
|
|
|
#include "PixelEngine.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
#include "TextureConverter.h"
|
2009-06-08 19:42:25 +00:00
|
|
|
#include "PostProcessing.h"
|
2009-02-21 12:53:10 +00:00
|
|
|
#include "OnScreenDisplay.h"
|
2009-02-22 04:24:53 +00:00
|
|
|
#include "Setup.h"
|
2009-08-09 11:03:58 +00:00
|
|
|
#include "DLCache.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
#include "VideoState.h"
|
2008-12-14 23:52:01 +00:00
|
|
|
|
2010-04-14 04:32:59 +00:00
|
|
|
#if defined(HAVE_COCOA) && HAVE_COCOA
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
#endif
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
SVideoInitialize g_VideoInitialize;
|
2009-03-18 17:17:58 +00:00
|
|
|
PLUGIN_GLOBALS* globals = NULL;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-19 06:52:01 +00:00
|
|
|
// Logging
|
|
|
|
int GLScissorX, GLScissorY, GLScissorW, GLScissorH;
|
|
|
|
|
2009-06-26 08:57:53 +00:00
|
|
|
static bool s_PluginInitialized = false;
|
|
|
|
|
2010-01-26 14:56:51 +00:00
|
|
|
volatile u32 s_swapRequested = FALSE;
|
2009-07-27 22:05:38 +00:00
|
|
|
static u32 s_efbAccessRequested = FALSE;
|
2010-01-03 22:18:50 +00:00
|
|
|
static volatile u32 s_FifoShuttingDown = FALSE;
|
2009-08-08 05:47:08 +00:00
|
|
|
static bool ForceSwap = true;
|
2009-07-02 10:16:06 +00:00
|
|
|
|
2009-09-13 21:18:04 +00:00
|
|
|
bool IsD3D()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
void GetDllInfo (PLUGIN_INFO* _PluginInfo)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
_PluginInfo->Version = 0x0100;
|
|
|
|
_PluginInfo->Type = PLUGIN_TYPE_VIDEO;
|
2009-01-15 06:48:15 +00:00
|
|
|
#ifdef DEBUGFAST
|
2010-02-25 12:35:31 +00:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin OpenGL (DebugFast)");
|
2009-09-09 19:52:45 +00:00
|
|
|
#elif defined _DEBUG
|
2010-02-25 12:35:31 +00:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin OpenGL (Debug)");
|
2008-12-08 05:25:12 +00:00
|
|
|
#else
|
2010-02-25 12:35:31 +00:00
|
|
|
sprintf(_PluginInfo->Name, "Dolphin OpenGL");
|
2008-12-08 05:25:12 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-02-21 12:25:43 +00:00
|
|
|
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
|
|
|
|
{
|
2009-03-18 17:17:58 +00:00
|
|
|
globals = _pPluginGlobals;
|
|
|
|
LogManager::SetInstance((LogManager *)globals->logManager);
|
2009-01-08 12:12:15 +00:00
|
|
|
}
|
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
// This is used for the functions right below here which use wxwidgets
|
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
#ifdef _WIN32
|
2009-02-22 04:24:53 +00:00
|
|
|
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
|
|
|
|
extern HINSTANCE g_hInstance;
|
|
|
|
#endif
|
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
wxWindow* GetParentedWxWindow(HWND Parent)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-22 22:57:56 +00:00
|
|
|
#ifdef _WIN32
|
2009-07-02 17:11:27 +00:00
|
|
|
wxSetInstance((HINSTANCE)g_hInstance);
|
2009-02-22 22:04:31 +00:00
|
|
|
#endif
|
2009-07-02 17:11:27 +00:00
|
|
|
wxWindow *win = new wxWindow();
|
2009-02-23 21:38:06 +00:00
|
|
|
#ifdef _WIN32
|
2009-07-02 17:11:27 +00:00
|
|
|
win->SetHWND((WXHWND)Parent);
|
|
|
|
win->AdoptAttributesFromHWND();
|
|
|
|
#endif
|
|
|
|
return win;
|
|
|
|
}
|
2009-02-22 22:04:31 +00:00
|
|
|
#endif
|
2009-02-23 21:38:06 +00:00
|
|
|
|
2009-07-02 17:11:27 +00:00
|
|
|
void DllDebugger(HWND _hParent, bool Show)
|
|
|
|
{
|
2009-09-09 19:52:45 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
|
|
|
if (Show) {
|
2009-09-07 13:33:40 +00:00
|
|
|
if (!m_DebuggerFrame)
|
|
|
|
m_DebuggerFrame = new GFXDebuggerOGL(NULL);
|
2009-08-26 23:28:30 +00:00
|
|
|
m_DebuggerFrame->Show();
|
2009-09-09 19:52:45 +00:00
|
|
|
} else {
|
2009-09-07 13:33:40 +00:00
|
|
|
if (m_DebuggerFrame) m_DebuggerFrame->Hide();
|
|
|
|
}
|
2009-02-23 21:38:06 +00:00
|
|
|
#endif
|
2009-09-09 19:52:45 +00:00
|
|
|
}
|
2009-02-22 04:24:53 +00:00
|
|
|
|
2010-04-14 04:32:59 +00:00
|
|
|
// Search for avaliable resolutions
|
2010-04-12 01:33:10 +00:00
|
|
|
void AddResolutions()
|
2010-02-25 06:12:35 +00:00
|
|
|
{
|
2010-04-14 04:32:59 +00:00
|
|
|
#ifdef _WIN32
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
DWORD iModeNum = 0;
|
|
|
|
DEVMODE dmi;
|
|
|
|
ZeroMemory(&dmi, sizeof(dmi));
|
|
|
|
dmi.dmSize = sizeof(dmi);
|
2009-02-21 12:25:43 +00:00
|
|
|
std::vector<std::string> resos;
|
2009-01-15 06:48:15 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0)
|
2009-01-15 06:48:15 +00:00
|
|
|
{
|
2010-04-14 04:32:59 +00:00
|
|
|
char res[100];
|
|
|
|
sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight);
|
|
|
|
std::string strRes(res);
|
|
|
|
// Only add unique resolutions
|
|
|
|
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-04-14 04:32:59 +00:00
|
|
|
resos.push_back(strRes);
|
|
|
|
m_ConfigFrame->AddFSReso(res);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2010-02-25 06:12:35 +00:00
|
|
|
ZeroMemory(&dmi, sizeof(dmi));
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2010-04-14 04:32:59 +00:00
|
|
|
|
|
|
|
#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_XRANDR) \
|
|
|
|
&& HAVE_XRANDR && defined(HAVE_WX) && HAVE_WX
|
|
|
|
|
2010-03-10 17:29:19 +00:00
|
|
|
// Don't modify GLWin.dpy here.
|
|
|
|
// If the emulator is running that is bad.
|
|
|
|
Display *dpy;
|
|
|
|
int screen;
|
|
|
|
dpy = XOpenDisplay(0);
|
|
|
|
screen = DefaultScreen(dpy);
|
2008-12-08 05:25:12 +00:00
|
|
|
//Get all full screen resos for the config dialog
|
2010-02-16 04:59:45 +00:00
|
|
|
XRRScreenSize *sizes = NULL;
|
2008-12-08 05:25:12 +00:00
|
|
|
int modeNum = 0;
|
|
|
|
|
2010-03-10 17:29:19 +00:00
|
|
|
sizes = XRRSizes(dpy, screen, &modeNum);
|
|
|
|
XCloseDisplay(dpy);
|
2010-02-16 04:59:45 +00:00
|
|
|
if (modeNum > 0 && sizes != NULL)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-01-15 06:48:15 +00:00
|
|
|
for (int i = 0; i < modeNum; i++)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-02-16 04:59:45 +00:00
|
|
|
char temp[32];
|
|
|
|
sprintf(temp,"%dx%d", sizes[i].width, sizes[i].height);
|
|
|
|
m_ConfigFrame->AddFSReso(temp);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2010-02-25 06:12:35 +00:00
|
|
|
}
|
2009-09-09 19:52:45 +00:00
|
|
|
|
2010-04-14 04:32:59 +00:00
|
|
|
#elif defined(HAVE_COCOA) && HAVE_COCOA && defined(HAVE_WX) && HAVE_WX
|
2009-09-09 19:52:45 +00:00
|
|
|
|
2010-04-14 04:32:59 +00:00
|
|
|
CGDisplayModeRef mode;
|
|
|
|
CFArrayRef array;
|
|
|
|
CFIndex n, i;
|
|
|
|
int w, h;
|
|
|
|
std::vector<std::string> resos;
|
2009-09-09 19:52:45 +00:00
|
|
|
|
2010-04-14 04:32:59 +00:00
|
|
|
array = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), NULL);
|
|
|
|
n = CFArrayGetCount(array);
|
2009-09-09 19:52:45 +00:00
|
|
|
|
2010-04-14 04:32:59 +00:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(array, i);
|
|
|
|
w = CGDisplayModeGetWidth(mode);
|
|
|
|
h = CGDisplayModeGetHeight(mode);
|
2009-09-09 19:52:45 +00:00
|
|
|
|
2010-04-14 04:32:59 +00:00
|
|
|
char res[32];
|
|
|
|
sprintf(res,"%dx%d", w, h);
|
|
|
|
std::string strRes(res);
|
|
|
|
// Only add unique resolutions
|
|
|
|
if (std::find(resos.begin(), resos.end(), strRes) == resos.end())
|
|
|
|
{
|
|
|
|
resos.push_back(strRes);
|
|
|
|
m_ConfigFrame->AddFSReso(res);
|
2009-05-15 08:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-14 04:32:59 +00:00
|
|
|
CFRelease(array);
|
|
|
|
|
2009-09-09 19:52:45 +00:00
|
|
|
#endif
|
2010-04-14 04:32:59 +00:00
|
|
|
}
|
2009-09-09 19:52:45 +00:00
|
|
|
|
|
|
|
void DllConfig(HWND _hParent)
|
|
|
|
{
|
2010-02-02 21:56:29 +00:00
|
|
|
g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_opengl.ini").c_str());
|
2009-09-13 08:54:46 +00:00
|
|
|
g_Config.GameIniLoad(globals->game_ini);
|
2009-09-13 08:21:35 +00:00
|
|
|
g_Config.UpdateProjectionHack();
|
|
|
|
UpdateActiveConfig();
|
2009-09-09 19:52:45 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2010-02-25 06:12:35 +00:00
|
|
|
wxWindow *frame = GetParentedWxWindow(_hParent);
|
|
|
|
m_ConfigFrame = new GFXConfigDialogOGL(frame);
|
2009-09-09 19:52:45 +00:00
|
|
|
|
2010-04-12 01:33:10 +00:00
|
|
|
AddResolutions();
|
2009-07-02 17:11:27 +00:00
|
|
|
|
2010-02-25 06:12:35 +00:00
|
|
|
// Prevent user to show more than 1 config window at same time
|
2010-03-05 07:03:44 +00:00
|
|
|
#ifdef _WIN32
|
2010-02-25 06:12:35 +00:00
|
|
|
frame->Disable();
|
2010-02-25 17:50:08 +00:00
|
|
|
m_ConfigFrame->CreateGUIControls();
|
2010-02-25 06:12:35 +00:00
|
|
|
m_ConfigFrame->ShowModal();
|
|
|
|
frame->Enable();
|
2010-03-05 07:03:44 +00:00
|
|
|
#else
|
|
|
|
m_ConfigFrame->CreateGUIControls();
|
|
|
|
m_ConfigFrame->ShowModal();
|
|
|
|
#endif
|
2010-02-25 06:12:35 +00:00
|
|
|
|
2010-02-14 16:44:16 +00:00
|
|
|
#ifdef _WIN32
|
2010-02-25 17:50:08 +00:00
|
|
|
frame->SetFocus();
|
2010-02-25 06:12:35 +00:00
|
|
|
frame->SetHWND(NULL);
|
2010-02-14 16:44:16 +00:00
|
|
|
#endif
|
2010-02-25 17:50:08 +00:00
|
|
|
|
|
|
|
m_ConfigFrame->Destroy();
|
|
|
|
m_ConfigFrame = NULL;
|
2010-02-25 06:12:35 +00:00
|
|
|
frame->Destroy();
|
2009-07-02 17:11:27 +00:00
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
void Initialize(void *init)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
frameCount = 0;
|
|
|
|
SVideoInitialize *_pVideoInitialize = (SVideoInitialize*)init;
|
2009-09-09 19:52:45 +00:00
|
|
|
// Create a shortcut to _pVideoInitialize that can also update it
|
2010-02-25 06:12:35 +00:00
|
|
|
g_VideoInitialize = *(_pVideoInitialize);
|
2008-12-08 05:25:12 +00:00
|
|
|
InitXFBConvTables();
|
2009-09-09 19:52:45 +00:00
|
|
|
|
2010-02-25 06:12:35 +00:00
|
|
|
g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_opengl.ini").c_str());
|
2009-09-13 08:54:46 +00:00
|
|
|
g_Config.GameIniLoad(globals->game_ini);
|
2009-03-20 11:51:22 +00:00
|
|
|
|
2009-08-01 18:31:25 +00:00
|
|
|
g_Config.UpdateProjectionHack();
|
2009-10-24 00:18:21 +00:00
|
|
|
#if defined(HAVE_WX) && HAVE_WX
|
2009-07-31 01:55:26 +00:00
|
|
|
//Enable support for PNG screenshots.
|
|
|
|
wxImage::AddHandler( new wxPNGHandler );
|
|
|
|
#endif
|
2009-09-13 08:21:35 +00:00
|
|
|
UpdateActiveConfig();
|
2009-07-31 01:55:26 +00:00
|
|
|
|
2010-02-25 06:12:35 +00:00
|
|
|
if (!OpenGL_Create(g_VideoInitialize, 640, 480))
|
2010-01-20 19:51:13 +00:00
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE);
|
|
|
|
return;
|
|
|
|
}
|
2009-02-21 12:25:43 +00:00
|
|
|
|
|
|
|
_pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages;
|
2010-02-25 06:12:35 +00:00
|
|
|
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
|
2009-01-04 21:53:41 +00:00
|
|
|
|
|
|
|
// Now the window handle is written
|
2010-02-25 06:12:35 +00:00
|
|
|
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
|
2010-02-13 20:47:23 +00:00
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
2010-02-25 06:12:35 +00:00
|
|
|
_pVideoInitialize->pXWindow = g_VideoInitialize.pXWindow;
|
2010-02-13 20:47:23 +00:00
|
|
|
#endif
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2009-02-21 12:53:10 +00:00
|
|
|
OSD::AddMessage("Dolphin OpenGL Video Plugin" ,5000);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
void DoState(unsigned char **ptr, int mode) {
|
2010-04-01 23:13:26 +00:00
|
|
|
#if defined(HAVE_X11) && HAVE_X11
|
|
|
|
OpenGL_MakeCurrent();
|
|
|
|
#endif
|
2010-02-25 06:12:35 +00:00
|
|
|
// Clear all caches that touch RAM
|
|
|
|
TextureMngr::Invalidate(false);
|
|
|
|
VertexLoaderManager::MarkAllDirty();
|
|
|
|
|
|
|
|
PointerWrap p(ptr, mode);
|
|
|
|
VideoCommon_DoState(p);
|
|
|
|
|
|
|
|
// Refresh state.
|
2009-02-09 20:35:30 +00:00
|
|
|
if (mode == PointerWrap::MODE_READ)
|
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
BPReload();
|
2009-02-09 20:35:30 +00:00
|
|
|
RecomputeCachedArraybases();
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
|
|
|
void EmuStateChange(PLUGIN_EMUSTATE newState)
|
|
|
|
{
|
2010-01-07 20:01:41 +00:00
|
|
|
Fifo_RunLoop((newState == PLUGIN_EMUSTATE_PLAY) ? true : false);
|
Now you can switch between Emulated and Real WiiMotes, connect more Real Wiimotes and even pair them up (if you have MS BT Stack) during gameplay!
All you gotta do is Pause the emulation! That's useful for when your batteries run out during gameplay, for example...
But if you change the WiiMote source (between Emulated, Real or Inactive) you must disconnect and reconnect (Menu Tools -> Connect WiiMote) the WiiMotes affected by the change...
Thanks to jack.fr0st who did all the emulation state notification work!
Now every plugin has a way to know the current emulation state (paused, stopped or playing)
@ayuanx: I thought about doing a PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, current_number); so that the user gets asked to reconnect that WiiMote, trying to avoid having to disconnect and reconnect, but it didn't work because shooting that message only asks to reconnect, doesn't do a disconnect... Do you have any ideas on how to accomplish that?
Also, if anyone could check if Issue 1916 is finally fixed... Or at least when is the cursor being hidden or not...
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4789 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-06 19:26:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
// This is called after Video_Initialize() from the Core
|
|
|
|
void Video_Prepare(void)
|
|
|
|
{
|
2010-04-01 23:13:26 +00:00
|
|
|
OpenGL_Initialize();
|
2010-02-25 06:12:35 +00:00
|
|
|
if (!Renderer::Init()) {
|
|
|
|
g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE);
|
|
|
|
PanicAlert("Can't create opengl renderer. You might be missing some required opengl extensions, check the logs for more info");
|
|
|
|
exit(1);
|
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-01-01 03:55:39 +00:00
|
|
|
s_swapRequested = FALSE;
|
|
|
|
s_efbAccessRequested = FALSE;
|
|
|
|
s_FifoShuttingDown = FALSE;
|
|
|
|
|
2010-02-25 06:12:35 +00:00
|
|
|
CommandProcessor::Init();
|
|
|
|
PixelEngine::Init();
|
2009-10-10 21:19:39 +00:00
|
|
|
|
2010-02-25 06:12:35 +00:00
|
|
|
TextureMngr::Init();
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-02-25 06:12:35 +00:00
|
|
|
BPInit();
|
|
|
|
VertexManager::Init();
|
|
|
|
Fifo_Init(); // must be done before OpcodeDecoder_Init()
|
|
|
|
OpcodeDecoder_Init();
|
|
|
|
VertexShaderCache::Init();
|
|
|
|
VertexShaderManager::Init();
|
|
|
|
PixelShaderCache::Init();
|
|
|
|
PixelShaderManager::Init();
|
2009-06-08 19:42:25 +00:00
|
|
|
PostProcessing::Init();
|
2010-02-25 06:12:35 +00:00
|
|
|
GL_REPORT_ERRORD();
|
|
|
|
VertexLoaderManager::Init();
|
|
|
|
TextureConverter::Init();
|
2009-08-09 11:03:58 +00:00
|
|
|
DLCache::Init();
|
2009-07-11 16:52:34 +00:00
|
|
|
|
2009-06-26 08:57:53 +00:00
|
|
|
s_PluginInitialized = true;
|
2009-03-10 22:51:17 +00:00
|
|
|
INFO_LOG(VIDEO, "Video plugin initialized.");
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 06:48:15 +00:00
|
|
|
void Shutdown(void)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-06-26 08:57:53 +00:00
|
|
|
s_PluginInitialized = false;
|
2009-12-30 15:08:18 +00:00
|
|
|
ForceSwap = true;
|
2009-06-26 08:57:53 +00:00
|
|
|
|
2009-07-13 05:38:34 +00:00
|
|
|
s_efbAccessRequested = FALSE;
|
|
|
|
s_swapRequested = FALSE;
|
2010-01-01 03:55:39 +00:00
|
|
|
s_FifoShuttingDown = FALSE;
|
2009-07-11 02:34:16 +00:00
|
|
|
|
2009-08-09 11:03:58 +00:00
|
|
|
DLCache::Shutdown();
|
2009-02-22 04:24:53 +00:00
|
|
|
Fifo_Shutdown();
|
2009-06-08 19:42:25 +00:00
|
|
|
PostProcessing::Shutdown();
|
2009-07-15 15:09:20 +00:00
|
|
|
|
|
|
|
// The following calls are NOT Thread Safe
|
|
|
|
// And need to be called from the video thread
|
2009-02-22 22:57:56 +00:00
|
|
|
TextureConverter::Shutdown();
|
2009-02-22 04:24:53 +00:00
|
|
|
VertexLoaderManager::Shutdown();
|
|
|
|
VertexShaderCache::Shutdown();
|
|
|
|
VertexShaderManager::Shutdown();
|
|
|
|
PixelShaderManager::Shutdown();
|
|
|
|
PixelShaderCache::Shutdown();
|
|
|
|
VertexManager::Shutdown();
|
2009-02-22 20:21:56 +00:00
|
|
|
TextureMngr::Shutdown();
|
2009-02-22 04:24:53 +00:00
|
|
|
OpcodeDecoder_Shutdown();
|
2009-02-22 22:57:56 +00:00
|
|
|
Renderer::Shutdown();
|
2009-02-22 04:24:53 +00:00
|
|
|
OpenGL_Shutdown();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-02-22 04:24:53 +00:00
|
|
|
// Enter and exit the video loop
|
2009-02-20 22:04:52 +00:00
|
|
|
void Video_EnterLoop()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-20 22:04:52 +00:00
|
|
|
Fifo_EnterLoop(g_VideoInitialize);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-02-20 22:04:52 +00:00
|
|
|
void Video_ExitLoop()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-20 22:04:52 +00:00
|
|
|
Fifo_ExitLoop();
|
2010-01-01 03:55:39 +00:00
|
|
|
|
|
|
|
s_FifoShuttingDown = TRUE;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
2009-04-03 14:35:49 +00:00
|
|
|
|
2009-06-15 04:30:02 +00:00
|
|
|
// Screenshot and screen message
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2009-02-27 03:56:34 +00:00
|
|
|
void Video_Screenshot(const char *_szFilename)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-02-27 03:56:34 +00:00
|
|
|
Renderer::SetScreenshot(_szFilename);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-06-15 04:30:02 +00:00
|
|
|
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
|
|
|
{
|
|
|
|
OSD::AddMessage(pstr, milliseconds);
|
|
|
|
}
|
|
|
|
|
2009-08-08 01:39:56 +00:00
|
|
|
void Video_SetRendering(bool bEnabled) {
|
|
|
|
Fifo_SetRendering(bEnabled);
|
|
|
|
}
|
|
|
|
|
2009-07-11 02:34:16 +00:00
|
|
|
static volatile struct
|
|
|
|
{
|
2009-06-29 07:30:48 +00:00
|
|
|
u32 xfbAddr;
|
2009-07-11 02:34:16 +00:00
|
|
|
FieldType field;
|
|
|
|
u32 fbWidth;
|
|
|
|
u32 fbHeight;
|
2009-07-11 16:52:34 +00:00
|
|
|
} s_beginFieldArgs;
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2009-07-11 02:34:16 +00:00
|
|
|
// Run from the graphics thread (from Fifo.cpp)
|
|
|
|
void VideoFifo_CheckSwapRequest()
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-07-13 05:38:34 +00:00
|
|
|
if (Common::AtomicLoadAcquire(s_swapRequested))
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2009-09-13 08:21:35 +00:00
|
|
|
if (ForceSwap || g_ActiveConfig.bUseXFB)
|
2009-08-08 05:47:08 +00:00
|
|
|
{
|
|
|
|
Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight);
|
|
|
|
}
|
2010-03-10 06:45:13 +00:00
|
|
|
|
|
|
|
Common::AtomicStoreRelease(s_swapRequested, FALSE);
|
2009-07-11 02:34:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
|
|
|
{
|
2009-07-29 01:06:49 +00:00
|
|
|
return !((aLower >= bUpper) || (bLower >= aUpper));
|
2009-07-11 02:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run from the graphics thread (from Fifo.cpp)
|
|
|
|
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
|
|
|
|
{
|
2009-09-13 08:21:35 +00:00
|
|
|
if (Common::AtomicLoadAcquire(s_swapRequested) && g_ActiveConfig.bUseXFB)
|
2009-07-11 02:34:16 +00:00
|
|
|
{
|
|
|
|
u32 aLower = xfbAddr;
|
|
|
|
u32 aUpper = xfbAddr + 2 * fbWidth * fbHeight;
|
|
|
|
u32 bLower = s_beginFieldArgs.xfbAddr;
|
|
|
|
u32 bUpper = s_beginFieldArgs.xfbAddr + 2 * s_beginFieldArgs.fbWidth * s_beginFieldArgs.fbHeight;
|
|
|
|
|
|
|
|
if (addrRangesOverlap(aLower, aUpper, bLower, bUpper))
|
|
|
|
VideoFifo_CheckSwapRequest();
|
|
|
|
}
|
2009-08-25 18:30:15 +00:00
|
|
|
|
2009-08-08 05:47:08 +00:00
|
|
|
ForceSwap = false;
|
2009-07-11 02:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run from the CPU thread (from VideoInterface.cpp)
|
|
|
|
void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
|
|
|
{
|
2010-03-25 22:01:33 +00:00
|
|
|
if (s_PluginInitialized && g_ActiveConfig.bUseXFB)
|
2009-07-11 02:34:16 +00:00
|
|
|
{
|
2010-04-04 13:19:03 +00:00
|
|
|
s_beginFieldArgs.xfbAddr = xfbAddr;
|
|
|
|
s_beginFieldArgs.field = field;
|
|
|
|
s_beginFieldArgs.fbWidth = fbWidth;
|
|
|
|
s_beginFieldArgs.fbHeight = fbHeight;
|
|
|
|
|
|
|
|
Common::AtomicStoreRelease(s_swapRequested, TRUE);
|
2009-10-23 15:26:35 +00:00
|
|
|
if (g_VideoInitialize.bOnThread)
|
2009-07-15 22:20:59 +00:00
|
|
|
{
|
2010-01-01 03:55:39 +00:00
|
|
|
while (Common::AtomicLoadAcquire(s_swapRequested) && !s_FifoShuttingDown)
|
2010-03-25 22:01:33 +00:00
|
|
|
//Common::SleepCurrentThread(1);
|
|
|
|
Common::YieldCPU();
|
2009-07-15 22:20:59 +00:00
|
|
|
}
|
2009-07-27 22:05:38 +00:00
|
|
|
else
|
2010-04-04 13:19:03 +00:00
|
|
|
VideoFifo_CheckSwapRequest();
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-15 06:39:26 +00:00
|
|
|
|
2009-07-15 22:20:59 +00:00
|
|
|
// Run from the CPU thread (from VideoInterface.cpp)
|
|
|
|
void Video_EndField()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-07-27 22:05:38 +00:00
|
|
|
static struct
|
2009-07-11 16:52:34 +00:00
|
|
|
{
|
|
|
|
EFBAccessType type;
|
|
|
|
u32 x;
|
|
|
|
u32 y;
|
|
|
|
} s_accessEFBArgs;
|
|
|
|
|
2009-07-27 22:05:38 +00:00
|
|
|
static u32 s_AccessEFBResult = 0;
|
2009-07-11 16:52:34 +00:00
|
|
|
|
|
|
|
void VideoFifo_CheckEFBAccess()
|
2009-07-01 13:49:49 +00:00
|
|
|
{
|
2009-07-13 05:38:34 +00:00
|
|
|
if (Common::AtomicLoadAcquire(s_efbAccessRequested))
|
2009-07-12 22:22:48 +00:00
|
|
|
{
|
2009-07-15 00:51:24 +00:00
|
|
|
s_AccessEFBResult = Renderer::AccessEFB(s_accessEFBArgs.type, s_accessEFBArgs.x, s_accessEFBArgs.y);
|
2009-07-03 15:35:31 +00:00
|
|
|
|
2009-07-27 22:05:38 +00:00
|
|
|
Common::AtomicStoreRelease(s_efbAccessRequested, FALSE);
|
2009-07-12 22:22:48 +00:00
|
|
|
}
|
2009-07-02 10:16:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
|
|
|
|
{
|
2009-07-11 20:39:28 +00:00
|
|
|
if (s_PluginInitialized)
|
|
|
|
{
|
|
|
|
s_accessEFBArgs.type = type;
|
|
|
|
s_accessEFBArgs.x = x;
|
|
|
|
s_accessEFBArgs.y = y;
|
2009-07-02 10:16:06 +00:00
|
|
|
|
2009-07-13 05:38:34 +00:00
|
|
|
Common::AtomicStoreRelease(s_efbAccessRequested, TRUE);
|
2009-07-02 10:16:06 +00:00
|
|
|
|
2009-10-23 15:26:35 +00:00
|
|
|
if (g_VideoInitialize.bOnThread)
|
2009-07-27 22:05:38 +00:00
|
|
|
{
|
2010-01-01 03:55:39 +00:00
|
|
|
while (Common::AtomicLoadAcquire(s_efbAccessRequested) && !s_FifoShuttingDown)
|
2010-03-25 22:01:33 +00:00
|
|
|
//Common::SleepCurrentThread(1);
|
|
|
|
Common::YieldCPU();
|
2009-07-27 22:05:38 +00:00
|
|
|
}
|
2009-07-11 20:39:28 +00:00
|
|
|
else
|
|
|
|
VideoFifo_CheckEFBAccess();
|
2009-07-02 10:16:06 +00:00
|
|
|
|
2009-07-11 20:39:28 +00:00
|
|
|
return s_AccessEFBResult;
|
|
|
|
}
|
2009-07-03 10:00:09 +00:00
|
|
|
|
2009-07-11 20:39:28 +00:00
|
|
|
return 0;
|
2009-07-01 13:49:49 +00:00
|
|
|
}
|
|
|
|
|
2009-10-10 21:19:39 +00:00
|
|
|
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
|
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
CommandProcessor::Read16(_rReturnValue, _Address);
|
2009-10-10 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Video_CommandProcessorWrite16(const u16 _Data, const u32 _Address)
|
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
CommandProcessor::Write16(_Data, _Address);
|
2009-10-10 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Video_PixelEngineRead16(u16& _rReturnValue, const u32 _Address)
|
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
PixelEngine::Read16(_rReturnValue, _Address);
|
2009-10-10 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Video_PixelEngineWrite16(const u16 _Data, const u32 _Address)
|
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
PixelEngine::Write16(_Data, _Address);
|
2009-10-10 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Video_PixelEngineWrite32(const u32 _Data, const u32 _Address)
|
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
PixelEngine::Write32(_Data, _Address);
|
2009-10-10 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 00:01:29 +00:00
|
|
|
void Video_GatherPipeBursted(void)
|
2009-10-10 21:19:39 +00:00
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
CommandProcessor::GatherPipeBursted();
|
2009-10-10 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Video_WaitForFrameFinish(void)
|
|
|
|
{
|
2010-02-25 06:12:35 +00:00
|
|
|
CommandProcessor::WaitForFrameFinish();
|
2009-10-10 21:19:39 +00:00
|
|
|
}
|
|
|
|
|