space changes, merge #defines, language fix, and code reorder/cleanup :P

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5614 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004
2010-06-05 01:38:22 +00:00
parent c98f8a96d2
commit 2e783d9769
42 changed files with 1870 additions and 1793 deletions
+5 -5
View File
@@ -22,12 +22,12 @@
struct CConfig
{
bool m_EnableHLEAudio;
bool m_EnableHLEAudio;
CConfig();
void Load();
void Save();
CConfig();
void Load();
void Save();
};
extern CConfig g_Config;
@@ -95,7 +95,7 @@ DSPConfigDialogHLE::DSPConfigDialogHLE(wxWindow *parent, wxWindowID id, const wx
void DSPConfigDialogHLE::AddBackend(const char* backend)
{
// Update values
m_BackendSelection->Append(wxString::FromAscii(backend));
m_BackendSelection->Append(wxString::FromAscii(backend));
#ifdef __APPLE__
int num = m_BackendSelection->FindString(wxString::FromAscii(ac_Config.sBackend));
#else
@@ -145,7 +145,7 @@ bool DSPConfigDialogHLE::SupportsVolumeChanges(std::string backend)
// but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider...
return (backend == BACKEND_DIRECTSOUND ||
backend == BACKEND_OPENAL);
backend == BACKEND_OPENAL);
}
void DSPConfigDialogHLE::BackendChanged(wxCommandEvent& event)
+25 -25
View File
@@ -28,38 +28,38 @@ class DSPConfigDialogHLE : public wxDialog
{
public:
DSPConfigDialogHLE(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxString &title = wxT("Dolphin DSP-HLE Plugin Settings"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE);
virtual ~DSPConfigDialogHLE();
void AddBackend(const char *backend);
wxWindowID id = wxID_ANY,
const wxString &title = wxT("Dolphin DSP-HLE Plugin Settings"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE);
virtual ~DSPConfigDialogHLE();
void AddBackend(const char *backend);
void ClearBackends();
private:
DECLARE_EVENT_TABLE();
wxSlider *m_volumeSlider;
wxStaticText *m_volumeText;
wxButton *m_OK;
wxCheckBox *m_buttonEnableHLEAudio;
wxCheckBox *m_buttonEnableDTKMusic;
wxCheckBox *m_buttonEnableThrottle;
DECLARE_EVENT_TABLE();
wxSlider* m_volumeSlider;
wxStaticText* m_volumeText;
wxButton* m_OK;
wxCheckBox* m_buttonEnableHLEAudio;
wxCheckBox* m_buttonEnableDTKMusic;
wxCheckBox* m_buttonEnableThrottle;
wxArrayString wxArrayBackends;
wxChoice *m_BackendSelection;
wxChoice* m_BackendSelection;
enum
enum
{
ID_ENABLE_HLE_AUDIO,
ID_ENABLE_DTK_MUSIC,
ID_ENABLE_THROTTLE,
ID_BACKEND,
ID_ENABLE_HLE_AUDIO,
ID_ENABLE_DTK_MUSIC,
ID_ENABLE_THROTTLE,
ID_BACKEND,
ID_VOLUME
};
void OnOK(wxCommandEvent& event);
void SettingsChanged(wxCommandEvent& event);
void OnOK(wxCommandEvent& event);
void SettingsChanged(wxCommandEvent& event);
void VolumeChanged(wxScrollEvent& event);
bool SupportsVolumeChanges(std::string backend);
void BackendChanged(wxCommandEvent& event);
+8 -14
View File
@@ -72,7 +72,7 @@ class wxDLLApp : public wxApp
return true;
}
};
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
#endif
@@ -89,7 +89,7 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
wxInitialize();
#endif
}
break;
break;
case DLL_PROCESS_DETACH:
#if defined(HAVE_WX) && HAVE_WX
@@ -129,13 +129,11 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo)
_PluginInfo->Version = 0x0100;
_PluginInfo->Type = PLUGIN_TYPE_DSP;
#ifdef DEBUGFAST
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (DebugFast) ");
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (DebugFast)");
#elif defined _DEBUG
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (Debug)");
#else
#ifndef _DEBUG
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin ");
#else
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin (Debug) ");
#endif
sprintf(_PluginInfo->Name, "Dolphin DSP-HLE Plugin");
#endif
}
@@ -143,7 +141,7 @@ void GetDllInfo(PLUGIN_INFO* _PluginInfo)
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
{
globals = _pPluginGlobals;
LogManager::SetInstance((LogManager *)globals->logManager);
LogManager::SetInstance((LogManager*)globals->logManager);
}
void DllConfig(HWND _hParent)
@@ -198,10 +196,6 @@ void Initialize(void *init)
CDSPHandler::CreateInstance();
}
void DSP_StopSoundStream()
{
}
void Shutdown()
{
AudioCommon::ShutdownSoundStream();
@@ -285,7 +279,7 @@ unsigned short DSP_WriteControlRegister(unsigned short _Value)
{
unsigned int AISampleRate, DACSampleRate;
g_dspInitialize.pGetSampleRate(AISampleRate, DACSampleRate);
soundStream = AudioCommon::InitSoundStream(new HLEMixer(AISampleRate, DACSampleRate));
soundStream = AudioCommon::InitSoundStream(new HLEMixer(AISampleRate, DACSampleRate));
if(!soundStream) PanicAlert("Error starting up sound stream");
// Mixer is initialized
g_InitMixer = true;
+29 -20
View File
@@ -102,7 +102,7 @@ void EnableAlphaToCoverage()
if (GetCurAdapter().ident.VendorId == VENDOR_ATI)
D3D::SetRenderState(D3DRS_POINTSIZE, (D3DFORMAT)MAKEFOURCC('A', '2', 'M', '1'));
else
D3D::SetRenderState(D3DRS_ADAPTIVETESS_Y, (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C'));
D3D::SetRenderState(D3DRS_ADAPTIVETESS_Y, (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C'));
}
void InitPP(int adapter, int f, int aa_mode, D3DPRESENT_PARAMETERS *pp)
@@ -191,7 +191,7 @@ void Enumerate()
}
}
if (D3DERR_NOTAVAILABLE != D3D::D3D->CheckDeviceMultiSampleType(
i, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_8_SAMPLES, &qlevels))
i, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, TRUE, D3DMULTISAMPLE_8_SAMPLES, &qlevels))
{
if (qlevels > 2)
{
@@ -211,14 +211,14 @@ void Enumerate()
// Also check for RAWZ (nvidia only, but the only option to get Z24 textures on sub GF8800
a.supports_rawz = D3D_OK == D3D->CheckDeviceFormat(
i, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, FOURCC_RAWZ);
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, FOURCC_RAWZ);
// Might as well check for RESZ and NULL too.
a.supports_resz = D3D_OK == D3D->CheckDeviceFormat(
i, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, FOURCC_RESZ);
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, FOURCC_RESZ);
a.supports_null = D3D_OK == D3D->CheckDeviceFormat(
i, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, FOURCC_NULL);
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, FOURCC_NULL);
if (a.aa_levels.size() == 1)
{
@@ -291,7 +291,7 @@ HRESULT Create(int adapter, HWND wnd, int _resolution, int aa_mode, bool auto_de
dev->GetRenderTarget(0, &back_buffer);
if (dev->GetDepthStencilSurface(&back_buffer_z) == D3DERR_NOTFOUND)
back_buffer_z = NULL;
D3D::SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE );
D3D::SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE );
D3D::SetRenderState(D3DRS_FILLMODE, g_Config.bWireFrame ? D3DFILL_WIREFRAME : D3DFILL_SOLID);
memset(m_Textures, 0, sizeof(m_Textures));
memset(m_TextureStageStatesSet, 0, sizeof(m_TextureStageStatesSet));
@@ -312,14 +312,15 @@ void Close()
if (back_buffer_z)
back_buffer_z->Release();
back_buffer_z = NULL;
back_buffer->Release();
if( back_buffer )
back_buffer->Release();
back_buffer = NULL;
ULONG references = dev->Release();
if (references)
ERROR_LOG(VIDEO, "Unreleased references: %i.", references);
dev = 0;
dev = NULL;
}
const D3DCAPS9 &GetCaps()
@@ -353,14 +354,22 @@ LPDIRECT3DSURFACE9 GetBackBufferDepthSurface()
void ShowD3DError(HRESULT err)
{
switch (err)
switch (err)
{
case D3DERR_DEVICELOST: PanicAlert("Device Lost"); break;
case D3DERR_INVALIDCALL: PanicAlert("Invalid Call"); break;
case D3DERR_DRIVERINTERNALERROR: PanicAlert("Driver Internal Error"); break;
case D3DERR_OUTOFVIDEOMEMORY: PanicAlert("Out of vid mem"); break;
case D3DERR_DEVICELOST:
PanicAlert("Device Lost");
break;
case D3DERR_INVALIDCALL:
PanicAlert("Invalid Call");
break;
case D3DERR_DRIVERINTERNALERROR:
PanicAlert("Driver Internal Error");
break;
case D3DERR_OUTOFVIDEOMEMORY:
PanicAlert("Out of vid mem");
break;
default:
// MessageBoxA(0,"Other error or success","ERROR",0);
// MessageBox(0,_T("Other error or success"),_T("ERROR"),0);
break;
}
}
@@ -378,7 +387,7 @@ void Reset()
back_buffer->Release();
back_buffer = NULL;
D3DPRESENT_PARAMETERS d3dpp;
D3DPRESENT_PARAMETERS d3dpp;
InitPP(cur_adapter, resolution, multisample, &d3dpp);
HRESULT hr = dev->Reset(&d3dpp);
ShowD3DError(hr);
@@ -457,7 +466,7 @@ void ApplyCachedState()
// so no stale state is around.
memset(m_Textures, 0, sizeof(m_Textures));
memset(m_TextureStageStatesSet, 0, sizeof(m_TextureStageStatesSet));
memset(m_TextureStageStatesChanged, 0, sizeof(m_TextureStageStatesChanged));
memset(m_TextureStageStatesChanged, 0, sizeof(m_TextureStageStatesChanged));
m_VtxDecl = NULL;
m_PixelShader = NULL;
m_VertexShader = NULL;
@@ -553,7 +562,7 @@ void RefreshSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type)
{
if(m_SamplerStatesSet[Sampler][Type] && m_SamplerStatesChanged[Sampler][Type])
{
D3D::dev->SetSamplerState(Sampler, Type, m_SamplerStates[Sampler][Type]);
D3D::dev->SetSamplerState(Sampler, Type, m_SamplerStates[Sampler][Type]);
m_SamplerStatesChanged[Sampler][Type] = false;
}
}
@@ -575,7 +584,7 @@ void RefreshVertexDeclaration()
{
if (m_VtxDecl)
{
D3D::dev->SetVertexDeclaration(m_VtxDecl);
D3D::dev->SetVertexDeclaration(m_VtxDecl);
}
}
@@ -596,7 +605,7 @@ void RefreshVertexShader()
{
if (m_VertexShader)
{
D3D::dev->SetVertexShader(m_VertexShader);
D3D::dev->SetVertexShader(m_VertexShader);
}
}
@@ -617,7 +626,7 @@ void RefreshPixelShader()
{
if (m_PixelShader)
{
D3D::dev->SetPixelShader(m_PixelShader);
D3D::dev->SetPixelShader(m_PixelShader);
}
}
+20 -20
View File
@@ -45,8 +45,8 @@ inline FONT2DVERTEX InitFont2DVertex(float x, float y, u32 color, float tu, floa
CD3DFont::CD3DFont()
{
m_pTexture = NULL;
m_pVB = NULL;
m_pTexture = NULL;
m_pVB = NULL;
}
enum {m_dwTexWidth = 512, m_dwTexHeight = 512};
@@ -74,7 +74,7 @@ int CD3DFont::Init()
bmi.bmiHeader.biBitCount = 32;
// Create a DC and a bitmap for the font
HDC hDC = CreateCompatibleDC(NULL);
HDC hDC = CreateCompatibleDC(NULL);
HBITMAP hbmBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (VOID**)&pBitmapBits, NULL, 0);
SetMapMode(hDC, MM_TEXT);
@@ -125,7 +125,7 @@ int CD3DFont::Init()
// Create a new texture for the font
hr = dev->CreateTexture(m_dwTexWidth, m_dwTexHeight, 1, D3DUSAGE_DYNAMIC,
D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &m_pTexture, NULL);
D3DFMT_A4R4G4B4, D3DPOOL_DEFAULT, &m_pTexture, NULL);
if (FAILED(hr))
{
PanicAlert("Failed to create font texture");
@@ -172,11 +172,11 @@ int CD3DFont::Shutdown()
const int RS[6][2] =
{
{D3DRS_ALPHABLENDENABLE, TRUE},
{D3DRS_SRCBLEND, D3DBLEND_SRCALPHA},
{D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA},
{D3DRS_CULLMODE, D3DCULL_NONE},
{D3DRS_ZENABLE, FALSE},
{D3DRS_FOGENABLE, FALSE},
{D3DRS_SRCBLEND, D3DBLEND_SRCALPHA},
{D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA},
{D3DRS_CULLMODE, D3DCULL_NONE},
{D3DRS_ZENABLE, FALSE},
{D3DRS_FOGENABLE, FALSE},
};
const int TS[6][2] =
{
@@ -193,10 +193,10 @@ bool DXCheck( std::wstring& msg )
HINSTANCE hDll = LoadLibrary(StringFromFormat( _T("d3dx9_%d.dll"), D3DX_SDK_VERSION).c_str());
if( !hDll )
{
msg = _T("Please make sure that you have the latest version of DirectX 9.0c correctly installed.");
msg = _T("Please make sure that you have the latest version of DirectX correctly installed.");
return false;
} else
msg = _T("DirectX9 is up to date and ready to be used!");
msg = _T("DirectX is up to date and ready to be used!");
FreeLibrary( hDll );
return true;
}
@@ -209,7 +209,7 @@ void RestoreShaders()
D3D::SetTexture(0, 0);
D3D::RefreshVertexDeclaration();
D3D::RefreshPixelShader();
D3D::RefreshVertexShader();
D3D::RefreshVertexShader();
}
void RestoreRenderStates()
@@ -250,7 +250,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, flo
float vpWidth = 1;
float vpHeight = 1;
float sx = x*vpWidth-0.5f;
float sx = x*vpWidth-0.5f;
float sy = y*vpHeight-0.5f;
float fStartX = sx;
@@ -329,7 +329,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, flo
v[4] = v[2];
v[5] = v[1];
memcpy(pVertices, v, 6*sizeof(FONT2DVERTEX));
memcpy(pVertices, v, 6*sizeof(FONT2DVERTEX));
pVertices+=6;
dwNumTriangles += 2;
@@ -395,10 +395,10 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture,
{ 1.0f - dw, 1.0f + dh, 0.0f,1.0f, u2, v1, sw, sh,u1,v1,u2,v2}
};
dev->SetVertexShader(Vshader);
dev->SetPixelShader(PShader);
dev->SetPixelShader(PShader);
D3D::SetTexture(0, texture);
dev->SetFVF(D3DFVF_XYZW | D3DFVF_TEX3 | D3DFVF_TEXCOORDSIZE4(2));
dev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, coords, sizeof(Q2DVertex));
dev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, coords, sizeof(Q2DVertex));
RestoreShaders();
}
@@ -428,10 +428,10 @@ void drawShadedTexSubQuad(IDirect3DTexture9 *texture,
{ rDest->right - dw , rDest->bottom + dh, 1.0f,1.0f, u2, v1, sw, sh,u1,v1,u2,v2}
};
dev->SetVertexShader(Vshader);
dev->SetPixelShader(PShader);
dev->SetPixelShader(PShader);
D3D::SetTexture(0, texture);
dev->SetFVF(D3DFVF_XYZW | D3DFVF_TEX3 | D3DFVF_TEXCOORDSIZE4(2));
dev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, coords, sizeof(Q2DVertex));
dev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, coords, sizeof(Q2DVertex));
RestoreShaders();
}
@@ -444,9 +444,9 @@ void drawClearQuad(u32 Color,float z,IDirect3DPixelShader9 *PShader,IDirect3DVer
{-1.0f, -1.0f, z, 1.0f, Color}
};
dev->SetVertexShader(Vshader);
dev->SetPixelShader(PShader);
dev->SetPixelShader(PShader);
dev->SetFVF(D3DFVF_XYZW | D3DFVF_DIFFUSE);
dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex));
dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex));
RestoreShaders();
}
@@ -60,7 +60,7 @@ struct TabDirect3D : public W32Util::Tab
}
ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_ANTIALIASMODE), g_Config.iMultisampleMode);
if (adapter.aa_levels.size() == 1)
if (adapter.aa_levels.size() == 1)
{
ComboBox_Enable(GetDlgItem(hDlg, IDC_ANTIALIASMODE), FALSE);
}
@@ -153,7 +153,7 @@ struct TabDirect3D : public W32Util::Tab
g_Config.bVSync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false;
if(Button_GetCheck(GetDlgItem(hDlg, IDC_SAFE_TEXTURE_CACHE_SAFE)))
{
g_Config.iSafeTextureCache_ColorSamples = 0;
g_Config.iSafeTextureCache_ColorSamples = 0;
}
else
{
@@ -162,14 +162,14 @@ struct TabDirect3D : public W32Util::Tab
if(g_Config.iSafeTextureCache_ColorSamples < 512)
{
g_Config.iSafeTextureCache_ColorSamples = 512;
}
}
}
else
{
if(g_Config.iSafeTextureCache_ColorSamples > 128 || g_Config.iSafeTextureCache_ColorSamples == 0)
{
g_Config.iSafeTextureCache_ColorSamples = 128;
}
}
}
}
g_Config.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
@@ -274,10 +274,10 @@ struct TabEnhancements : public W32Util::Tab
{
void Init(HWND hDlg)
{
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEFILTERING),g_Config.bForceFiltering);
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEANISOTROPY),g_Config.iMaxAnisotropy > 1);
Button_SetCheck(GetDlgItem(hDlg, IDC_FORCEFILTERING),g_Config.bForceFiltering);
Button_SetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY),g_Config.iMaxAnisotropy > 1);
Button_SetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE), g_Config.bHiresTextures);
Button_SetCheck(GetDlgItem(hDlg,IDC_EFBSCALEDCOPY), g_Config.bCopyEFBScaled);
Button_SetCheck(GetDlgItem(hDlg, IDC_EFBSCALEDCOPY), g_Config.bCopyEFBScaled);
/*
Temporarily disabled the old postprocessing code since it wasn't working anyway.
@@ -299,7 +299,7 @@ struct TabEnhancements : public W32Util::Tab
ComboBox_SetCurSel(pp, g_Config.iPostprocessEffect);
*/
}
void Command(HWND hDlg,WPARAM wParam)
void Command(HWND hDlg, WPARAM wParam)
{
/*
switch (LOWORD(wParam))
@@ -314,7 +314,7 @@ struct TabEnhancements : public W32Util::Tab
g_Config.iMaxAnisotropy = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY)) ? 8 : 1;
g_Config.bForceFiltering = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEFILTERING)) ? true : false;
g_Config.bHiresTextures = Button_GetCheck(GetDlgItem(hDlg, IDC_LOADHIRESTEXTURE)) ? true : false;
g_Config.bCopyEFBScaled = Button_GetCheck(GetDlgItem(hDlg,IDC_EFBSCALEDCOPY)) ? true : false;
g_Config.bCopyEFBScaled = Button_GetCheck(GetDlgItem(hDlg, IDC_EFBSCALEDCOPY)) ? true : false;
g_Config.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
}
};
@@ -333,12 +333,10 @@ void DlgSettings_Show(HINSTANCE hInstance, HWND _hParent)
#ifdef DEBUGFAST
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin (DEBUGFAST)"));
#else
#ifndef _DEBUG
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin"));
#else
#elif defined _DEBUG
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin (DEBUG)"));
#endif
#else
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin"));
#endif
if ((tfoe != g_Config.bTexFmtOverlayEnable) ||
@@ -181,7 +181,7 @@ void OSDMenu(WPARAM wParam)
case '7':
OSDChoice = 5;
g_Config.bDisableLighting = !g_Config.bDisableLighting;
break;
break;
}
}
@@ -24,187 +24,197 @@
#include "TextureConverter.h"
#undef CHECK
#define CHECK(hr,Message) if (FAILED(hr)) { PanicAlert(__FUNCTION__ " FAIL: %s" ,Message); }
#define CHECK(hr, Message) if (FAILED(hr)) { PanicAlert(__FUNCTION__ " FAIL: %s" , Message); }
FramebufferManager FBManager;
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorRTSurface()
{
return s_efb_color_surface;
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorRTSurface()
{
return s_efb_color_surface;
}
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthRTSurface()
{
return s_efb_depth_surface;
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthRTSurface()
{
return s_efb_depth_surface;
}
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorOffScreenRTSurface()
{
return s_efb_color_OffScreenReadBuffer;
}
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthOffScreenRTSurface()
{
return s_efb_depth_OffScreenReadBuffer;
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorOffScreenRTSurface()
{
return s_efb_color_OffScreenReadBuffer;
}
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorReadSurface()
{
return s_efb_color_ReadBuffer;
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthOffScreenRTSurface()
{
return s_efb_depth_OffScreenReadBuffer;
}
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthReadSurface()
{
return s_efb_depth_ReadBuffer;
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBColorReadSurface()
{
return s_efb_color_ReadBuffer;
}
D3DFORMAT FramebufferManager::GetEFBDepthRTSurfaceFormat(){return s_efb_depth_surface_Format;}
D3DFORMAT FramebufferManager::GetEFBDepthReadSurfaceFormat(){return s_efb_depth_ReadBuffer_Format;}
D3DFORMAT FramebufferManager::GetEFBColorRTSurfaceFormat(){return s_efb_color_surface_Format;}
LPDIRECT3DSURFACE9 FramebufferManager::GetEFBDepthReadSurface()
{
return s_efb_depth_ReadBuffer;
}
D3DFORMAT FramebufferManager::GetEFBDepthRTSurfaceFormat()
{
return s_efb_depth_surface_Format;
}
D3DFORMAT FramebufferManager::GetEFBDepthReadSurfaceFormat()
{
return s_efb_depth_ReadBuffer_Format;
}
D3DFORMAT FramebufferManager::GetEFBColorRTSurfaceFormat()
{
return s_efb_color_surface_Format;
}
LPDIRECT3DTEXTURE9 FramebufferManager::GetEFBColorTexture(const EFBRectangle& sourceRc)
{
return s_efb_color_texture;
}
LPDIRECT3DTEXTURE9 FramebufferManager::GetEFBDepthTexture(const EFBRectangle &sourceRc)
{
return s_efb_depth_texture;
}
void FramebufferManager::Create()
{
{
// Simplest possible setup to start with.
int target_width = Renderer::GetFullTargetWidth();
int target_height = Renderer::GetFullTargetHeight();
s_efb_color_surface_Format = D3DFMT_A8R8G8B8;
//get the framebuffer texture
HRESULT hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &s_efb_color_texture, NULL);
HRESULT hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &s_efb_color_texture, NULL);
if(s_efb_color_texture)
{
hr = s_efb_color_texture->GetSurfaceLevel(0,&s_efb_color_surface);
}
CHECK(hr,"Create Color Texture");
hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &s_efb_colorRead_texture, NULL);
CHECK(hr,"Create Color Read Texture");
hr = s_efb_color_texture->GetSurfaceLevel(0, &s_efb_color_surface);
}
CHECK(hr, "Create Color Texture");
hr = D3D::dev->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &s_efb_colorRead_texture, NULL);
CHECK(hr, "Create Color Read Texture");
if(s_efb_colorRead_texture)
{
s_efb_colorRead_texture->GetSurfaceLevel(0,&s_efb_color_ReadBuffer);
s_efb_colorRead_texture->GetSurfaceLevel(0, &s_efb_color_ReadBuffer);
}
//create an offscreen surface that we can lock to retrieve the data
hr = D3D::dev->CreateOffscreenPlainSurface(1, 1, s_efb_color_surface_Format, D3DPOOL_SYSTEMMEM, &s_efb_color_OffScreenReadBuffer, NULL );
CHECK(hr,"Create Color offScreen Surface");
hr = D3D::dev->CreateOffscreenPlainSurface(1, 1, s_efb_color_surface_Format, D3DPOOL_SYSTEMMEM, &s_efb_color_OffScreenReadBuffer, NULL);
CHECK(hr, "Create Color offScreen Surface");
//Select Zbuffer format supported by hadware.
if (g_ActiveConfig.bEFBAccessEnable)
{
{
D3DFORMAT *DepthTexFormats = new D3DFORMAT[5];
DepthTexFormats[0] = FOURCC_INTZ;
DepthTexFormats[0] = FOURCC_INTZ;
DepthTexFormats[1] = FOURCC_DF24;
DepthTexFormats[2] = FOURCC_RAWZ;
DepthTexFormats[3] = FOURCC_DF16;
DepthTexFormats[4] = D3DFMT_D24X8;
for(int i = 0;i<5;i++)
for(int i = 0; i < 5; i++)
{
s_efb_depth_surface_Format = DepthTexFormats[i];
//get the framebuffer Depth texture
hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_DEPTHSTENCIL, s_efb_depth_surface_Format,
hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_DEPTHSTENCIL, s_efb_depth_surface_Format,
D3DPOOL_DEFAULT, &s_efb_depth_texture, NULL);
if (!FAILED(hr)) break;
}
if (!FAILED(hr))
break;
}
CHECK(hr,"Depth Color Texture");
//get the Surface
if(s_efb_depth_texture)
{
s_efb_depth_texture->GetSurfaceLevel(0,&s_efb_depth_surface);
s_efb_depth_texture->GetSurfaceLevel(0, &s_efb_depth_surface);
}
//create a 4x4 pixel texture to work as a buffer for peeking
if(s_efb_depth_surface_Format == FOURCC_RAWZ || s_efb_depth_surface_Format == D3DFMT_D24X8)
{
DepthTexFormats[0] = D3DFMT_A8R8G8B8;
DepthTexFormats[0] = D3DFMT_A8R8G8B8;
}
else
{
DepthTexFormats[0] = D3DFMT_R32F;
}
DepthTexFormats[1] = D3DFMT_A8R8G8B8;
DepthTexFormats[1] = D3DFMT_A8R8G8B8;
for(int i = 0;i<2;i++)
for(int i = 0; i < 2; i++)
{
s_efb_depth_ReadBuffer_Format = DepthTexFormats[i];
//get the framebuffer Depth texture
hr = D3D::dev->CreateTexture(4, 4, 1, D3DUSAGE_RENDERTARGET, s_efb_depth_ReadBuffer_Format,
hr = D3D::dev->CreateTexture(4, 4, 1, D3DUSAGE_RENDERTARGET, s_efb_depth_ReadBuffer_Format,
D3DPOOL_DEFAULT, &s_efb_depthRead_texture, NULL);
if (!FAILED(hr)) break;
if (!FAILED(hr))
break;
}
CHECK(hr,"Create Depth Read texture");
CHECK(hr, "Create Depth Read texture");
if(s_efb_depthRead_texture)
{
s_efb_depthRead_texture->GetSurfaceLevel(0,&s_efb_depth_ReadBuffer);
s_efb_depthRead_texture->GetSurfaceLevel(0, &s_efb_depth_ReadBuffer);
}
//create an offscreen surface that we can lock to retrieve the data
hr = D3D::dev->CreateOffscreenPlainSurface(4, 4, s_efb_depth_ReadBuffer_Format, D3DPOOL_SYSTEMMEM, &s_efb_depth_OffScreenReadBuffer, NULL );
CHECK(hr,"Create Depth offScreen Surface");
delete [] DepthTexFormats;
hr = D3D::dev->CreateOffscreenPlainSurface(4, 4, s_efb_depth_ReadBuffer_Format, D3DPOOL_SYSTEMMEM, &s_efb_depth_OffScreenReadBuffer, NULL);
CHECK(hr, "Create Depth offScreen Surface");
delete [] DepthTexFormats;
}
else
{
s_efb_depth_surface_Format = D3DFMT_D24X8;
hr = D3D::dev->CreateDepthStencilSurface(target_width, target_height, s_efb_depth_surface_Format,
hr = D3D::dev->CreateDepthStencilSurface(target_width, target_height, s_efb_depth_surface_Format,
D3DMULTISAMPLE_NONE, 0, FALSE, &s_efb_depth_surface, NULL);
CHECK(hr,"CreateDepthStencilSurface");
}
CHECK(hr, "CreateDepthStencilSurface");
}
}
void FramebufferManager::Destroy()
{
{
if (s_efb_depth_surface)
s_efb_depth_surface->Release();
s_efb_depth_surface=NULL;
s_efb_depth_surface = NULL;
if (s_efb_color_surface)
s_efb_color_surface->Release();
s_efb_color_surface=NULL;
s_efb_color_surface = NULL;
if (s_efb_color_ReadBuffer)
s_efb_color_ReadBuffer->Release();
s_efb_color_ReadBuffer=NULL;
s_efb_color_ReadBuffer = NULL;
if (s_efb_depth_ReadBuffer)
s_efb_depth_ReadBuffer->Release();
s_efb_depth_ReadBuffer=NULL;
s_efb_depth_ReadBuffer = NULL;
if (s_efb_color_OffScreenReadBuffer)
s_efb_color_OffScreenReadBuffer->Release();
s_efb_color_OffScreenReadBuffer=NULL;
s_efb_color_OffScreenReadBuffer = NULL;
if (s_efb_depth_OffScreenReadBuffer)
s_efb_depth_OffScreenReadBuffer->Release();
s_efb_depth_OffScreenReadBuffer=NULL;
s_efb_depth_OffScreenReadBuffer = NULL;
if (s_efb_color_texture)
s_efb_color_texture->Release();
s_efb_color_texture=NULL;
s_efb_color_texture = NULL;
if (s_efb_colorRead_texture)
s_efb_colorRead_texture->Release();
s_efb_colorRead_texture=NULL;
s_efb_colorRead_texture = NULL;
if (s_efb_depth_texture)
s_efb_depth_texture->Release();
s_efb_depth_texture=NULL;
s_efb_depth_texture = NULL;
if (s_efb_depthRead_texture)
s_efb_depthRead_texture->Release();
s_efb_depthRead_texture=NULL;
s_efb_depthRead_texture = NULL;
for (VirtualXFBListType::iterator it = m_virtualXFBList.begin(); it != m_virtualXFBList.end(); ++it)
{
@@ -213,7 +223,7 @@ void FramebufferManager::Destroy()
}
m_virtualXFBList.clear();
if(m_realXFBSource.texture)
m_realXFBSource.texture->Release();
m_realXFBSource.texture->Release();
m_realXFBSource.texture = NULL;
}
@@ -255,7 +265,7 @@ FramebufferManager::VirtualXFBListType::iterator FramebufferManager::findVirtual
void FramebufferManager::replaceVirtualXFB()
{
VirtualXFBListType::iterator it = m_virtualXFBList.begin();
VirtualXFBListType::iterator it = m_virtualXFBList.begin();
s32 srcLower = it->xfbAddr;
s32 srcUpper = it->xfbAddr + 2 * it->xfbWidth * it->xfbHeight;
@@ -276,7 +286,7 @@ void FramebufferManager::replaceVirtualXFB()
it->xfbWidth = 0;
}
else if (addrRangesOverlap(srcLower, srcUpper, dstLower, dstUpper))
{
{
s32 upperOverlap = (srcUpper - dstLower) / lineSize;
s32 lowerOverlap = (dstUpper - srcLower) / lineSize;
@@ -343,15 +353,15 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
it->xfbSource.srcAddr = xfbAddr;
it->xfbSource.srcWidth = fbWidth;
it->xfbSource.srcHeight = fbHeight;
it->xfbSource.srcHeight = fbHeight;
if(it->xfbSource.texWidth != target_width || it->xfbSource.texHeight != target_height || !(it->xfbSource.texture))
{
if(it->xfbSource.texture)
it->xfbSource.texture->Release();
it->xfbSource.texture = NULL;
hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &(it->xfbSource.texture), NULL);
hr = D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &(it->xfbSource.texture), NULL);
}
@@ -370,8 +380,8 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
{
// Create a new Virtual XFB and place it at the front of the list.
D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &xfbTexture, NULL);
D3D::dev->CreateTexture(target_width, target_height, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &xfbTexture, NULL);
VirtualXFB newVirt;
newVirt.xfbAddr = xfbAddr;
@@ -380,7 +390,7 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
newVirt.xfbSource.texture = xfbTexture;
newVirt.xfbSource.texWidth = target_width;
newVirt.xfbSource.texHeight = target_height;
newVirt.xfbSource.texHeight = target_height;
// Add the new Virtual XFB to the list
@@ -399,14 +409,14 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
if(!xfbTexture)
return;
LPDIRECT3DTEXTURE9 read_texture = GetEFBColorTexture(sourceRc);
Renderer::ResetAPIState(); // reset any game specific settings
LPDIRECT3DSURFACE9 Rendersurf = NULL;
xfbTexture->GetSurfaceLevel(0,&Rendersurf);
xfbTexture->GetSurfaceLevel(0, &Rendersurf);
D3D::dev->SetDepthStencilSurface(NULL);
D3D::dev->SetRenderTarget(0, Rendersurf);
D3D::dev->SetRenderTarget(0, Rendersurf);
D3DVIEWPORT9 vp;
vp.X = 0;
@@ -424,27 +434,25 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
D3D::drawShadedTexQuad(
read_texture,
read_texture,
&sourcerect,
Renderer::GetFullTargetWidth() ,
Renderer::GetFullTargetHeight(),
target_width,
target_height,
PixelShaderCache::GetColorCopyProgram( g_ActiveConfig.iMultisampleMode),
VertexShaderCache::GetSimpleVertexShader( g_ActiveConfig.iMultisampleMode));
Renderer::GetFullTargetWidth(),
Renderer::GetFullTargetHeight(),
target_width,
target_height,
PixelShaderCache::GetColorCopyProgram( g_ActiveConfig.iMultisampleMode),
VertexShaderCache::GetSimpleVertexShader( g_ActiveConfig.iMultisampleMode));
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
D3D::SetTexture(0,NULL);
D3D::SetTexture(0, NULL);
D3D::dev->SetRenderTarget(0, GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(GetEFBDepthRTSurface());
D3D::dev->SetDepthStencilSurface(GetEFBDepthRTSurface());
Renderer::RestoreAPIState();
Rendersurf->Release();
Rendersurf->Release();
}
const XFBSource** FramebufferManager::getRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount)
@@ -456,12 +464,12 @@ const XFBSource** FramebufferManager::getRealXFBSource(u32 xfbAddr, u32 fbWidth,
m_realXFBSource.srcAddr = xfbAddr;
m_realXFBSource.srcWidth = fbWidth;
m_realXFBSource.srcHeight = fbHeight;
m_realXFBSource.srcHeight = fbHeight;
if (!m_realXFBSource.texture)
{
D3D::dev->CreateTexture(fbWidth, fbHeight, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &m_realXFBSource.texture, NULL);
D3D::dev->CreateTexture(fbWidth, fbHeight, 1, D3DUSAGE_RENDERTARGET, s_efb_color_surface_Format,
D3DPOOL_DEFAULT, &m_realXFBSource.texture, NULL);
}
// Decode YUYV data from GameCube RAM
@@ -121,7 +121,7 @@ public:
D3DFORMAT GetEFBColorRTSurfaceFormat();
D3DFORMAT GetEFBDepthReadSurfaceFormat();
LPDIRECT3DSURFACE9 GetEFBColorReadSurface();
LPDIRECT3DSURFACE9 GetEFBDepthReadSurface();
LPDIRECT3DSURFACE9 GetEFBDepthReadSurface();
private:
@@ -163,7 +163,6 @@ private:
LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
D3DFORMAT s_efb_color_surface_Format;//Format of the color Surface
D3DFORMAT s_efb_depth_surface_Format;//Format of the Depth Surface
D3DFORMAT s_efb_depth_ReadBuffer_Format;//Format of the Depth color Read Surface
@@ -116,7 +116,7 @@ static const D3DBLEND d3dDestFactors[8] =
D3DBLEND_INVDESTALPHA
};
static const D3DBLENDOP d3dLogincOPop[16] =
static const D3DBLENDOP d3dLogicOpop[16] =
{
D3DBLENDOP_ADD,
D3DBLENDOP_ADD,
@@ -239,7 +239,6 @@ void TeardownDeviceObjects()
FBManager.Destroy();
D3D::font.Shutdown();
TextureCache::Invalidate(false);
VertexManager::DestroyDeviceObjects();
VertexLoaderManager::Shutdown();
VertexShaderCache::Clear();
PixelShaderCache::Clear();
@@ -1248,10 +1247,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
void Renderer::ResetAPIState()
{
D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
D3D::SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
D3D::SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA| D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask);
}
@@ -1294,7 +1293,7 @@ void Renderer::SetLogicOpMode()
{
s_blendMode = 0;
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
D3D::SetRenderState(D3DRS_BLENDOP, d3dLogincOPop[bpmem.blendmode.logicmode]);
D3D::SetRenderState(D3DRS_BLENDOP, d3dLogicOpop[bpmem.blendmode.logicmode]);
D3D::SetRenderState(D3DRS_SRCBLEND, d3dLogicOpSrcFactors[bpmem.blendmode.logicmode]);
D3D::SetRenderState(D3DRS_DESTBLEND, d3dLogicOpDestFactors[bpmem.blendmode.logicmode]);
}
@@ -106,7 +106,7 @@ bool TextureCache::TCacheEntry::IntersectsMemoryRange(u32 range_address, u32 ran
void TextureCache::Shutdown()
{
Invalidate(true);
FreeMemoryPages(temp, TEMP_SIZE);
FreeMemoryPages(temp, TEMP_SIZE);
temp = NULL;
}
@@ -131,8 +131,8 @@ void TextureCache::Cleanup()
}
else
{
++iter;
}
++iter;
}
}
}
@@ -196,7 +196,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
}
else
{
// Let's reload the new texture data into the same texture,
// Let's reload the new texture data into the same texture,
// instead of destroying it and having to create a new one.
// Might speed up movie playback very, very slightly.
@@ -274,7 +274,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
else
{
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
((u32 *)ptr)[0] = entry.hash;
((u32 *)ptr)[0] = entry.hash;
}
entry.addr = address;
@@ -287,11 +287,11 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
if(TexLevels > maxlevel && maxlevel > 0)
TexLevels = maxlevel;
entry.MipLevels = maxlevel;
if (!skip_texture_create)
{
if (!skip_texture_create)
{
entry.texture = D3D::CreateTexture2D((BYTE*)temp, width, height, expandedWidth, d3d_fmt, swap_r_b, TexLevels);
}
else
}
else
{
D3D::ReplaceTexture2D(entry.texture, (BYTE*)temp, width, height, expandedWidth, d3d_fmt, swap_r_b, 0);
}
@@ -366,7 +366,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
SuperSampleCompensation = 1.0f / SuperSampleCompensation;
float xScale = Renderer::GetTargetScaleX();
float yScale = Renderer::GetTargetScaleY();
int Scaledtex_w = (g_ActiveConfig.bCopyEFBScaled)?((int)(xScale * SuperSampleCompensation * tex_w)):tex_w;
int Scaledtex_h = (g_ActiveConfig.bCopyEFBScaled)?((int)(yScale * SuperSampleCompensation * tex_h)):tex_h;
@@ -376,7 +376,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
if (iter != textures.end())
{
if (iter->second.isRenderTarget && iter->second.Scaledw == Scaledtex_w && iter->second.Scaledh == Scaledtex_h)
{
{
tex = iter->second.texture;
iter->second.frameCount = frameCount;
}
@@ -409,122 +409,122 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
float colmat[16]= {0.0f};
float fConstAdd[4] = {0.0f};
float fConstAdd[4] = {0.0f};
if (bFromZBuffer)
if (bFromZBuffer)
{
switch(copyfmt)
switch(copyfmt)
{
case 0: // Z4
case 1: // Z8
colmat[0] = colmat[4] = colmat[8] = colmat[12] =1.0f;
break;
case 3: // Z16 //?
colmat[1] = colmat[5] = colmat[9] = colmat[12] = 1.0f;
case 11: // Z16 (reverse order)
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1.0f;
break;
case 6: // Z24X8
colmat[0] = colmat[5] = colmat[10] = 1.0f;
break;
case 9: // Z8M
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1.0f;
break;
case 10: // Z8L
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1.0f;
break;
case 12: // Z16L
colmat[2] = colmat[6] = colmat[10] = colmat[13] = 1.0f;
break;
default:
ERROR_LOG(VIDEO, "Unknown copy zbuf format: 0x%x", copyfmt);
colmat[2] = colmat[5] = colmat[8] = 1.0f;
break;
}
}
else if (bIsIntensityFmt)
case 0: // Z4
case 1: // Z8
colmat[0] = colmat[4] = colmat[8] = colmat[12] =1.0f;
break;
case 3: // Z16 //?
colmat[1] = colmat[5] = colmat[9] = colmat[12] = 1.0f;
case 11: // Z16 (reverse order)
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1.0f;
break;
case 6: // Z24X8
colmat[0] = colmat[5] = colmat[10] = 1.0f;
break;
case 9: // Z8M
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1.0f;
break;
case 10: // Z8L
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1.0f;
break;
case 12: // Z16L
colmat[2] = colmat[6] = colmat[10] = colmat[13] = 1.0f;
break;
default:
ERROR_LOG(VIDEO, "Unknown copy zbuf format: 0x%x", copyfmt);
colmat[2] = colmat[5] = colmat[8] = 1.0f;
break;
}
}
else if (bIsIntensityFmt)
{
fConstAdd[0] = fConstAdd[1] = fConstAdd[2] = 16.0f/255.0f;
switch (copyfmt)
fConstAdd[0] = fConstAdd[1] = fConstAdd[2] = 16.0f/255.0f;
switch (copyfmt)
{
case 0: // I4
case 1: // I8
case 2: // IA4
case 3: // IA8
case 0: // I4
case 1: // I8
case 2: // IA4
case 3: // IA8
// TODO - verify these coefficients
colmat[0] = 0.257f; colmat[1] = 0.504f; colmat[2] = 0.098f;
colmat[4] = 0.257f; colmat[5] = 0.504f; colmat[6] = 0.098f;
colmat[8] = 0.257f; colmat[9] = 0.504f; colmat[10] = 0.098f;
colmat[0] = 0.257f; colmat[1] = 0.504f; colmat[2] = 0.098f;
colmat[4] = 0.257f; colmat[5] = 0.504f; colmat[6] = 0.098f;
colmat[8] = 0.257f; colmat[9] = 0.504f; colmat[10] = 0.098f;
if (copyfmt < 2)
if (copyfmt < 2)
{
fConstAdd[3] = 16.0f / 255.0f;
colmat[12] = 0.257f; colmat[13] = 0.504f; colmat[14] = 0.098f;
}
else// alpha
colmat[15] = 1;
fConstAdd[3] = 16.0f / 255.0f;
colmat[12] = 0.257f; colmat[13] = 0.504f; colmat[14] = 0.098f;
}
else// alpha
colmat[15] = 1;
break;
default:
ERROR_LOG(VIDEO, "Unknown copy intensity format: 0x%x", copyfmt);
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
}
}
else
break;
default:
ERROR_LOG(VIDEO, "Unknown copy intensity format: 0x%x", copyfmt);
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
}
}
else
{
switch (copyfmt)
switch (copyfmt)
{
case 0: // R4
case 8: // R8
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
break;
case 2: // RA4
case 3: // RA8
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
break;
case 0: // R4
case 8: // R8
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
break;
case 2: // RA4
case 3: // RA8
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
break;
case 7: // A8
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
break;
case 9: // G8
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
break;
case 10: // B8
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
break;
case 11: // RG8
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
break;
case 12: // GB8
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
break;
case 7: // A8
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
break;
case 9: // G8
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
break;
case 10: // B8
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
break;
case 11: // RG8
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
break;
case 12: // GB8
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
break;
case 4: // RGB565
colmat[0] = colmat[5] = colmat[10] = 1;
fConstAdd[3] = 1; // set alpha to 1
break;
case 5: // RGB5A3
case 6: // RGBA8
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
case 4: // RGB565
colmat[0] = colmat[5] = colmat[10] = 1;
fConstAdd[3] = 1; // set alpha to 1
break;
case 5: // RGB5A3
case 6: // RGBA8
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
default:
ERROR_LOG(VIDEO, "Unknown copy color format: 0x%x", copyfmt);
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
}
}
default:
ERROR_LOG(VIDEO, "Unknown copy color format: 0x%x", copyfmt);
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
}
}
// Make sure to resolve anything we need to read from.
LPDIRECT3DTEXTURE9 read_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source_rect) : FBManager.GetEFBColorTexture(source_rect);
// We have to run a pixel shader, for color conversion.
Renderer::ResetAPIState(); // reset any game specific settings
// We have to run a pixel shader, for color conversion.
Renderer::ResetAPIState(); // reset any game specific settings
LPDIRECT3DSURFACE9 Rendersurf = NULL;
tex->GetSurfaceLevel(0,&Rendersurf);
D3D::dev->SetDepthStencilSurface(NULL);
D3D::dev->SetRenderTarget(0, Rendersurf);
D3D::dev->SetRenderTarget(0, Rendersurf);
D3DVIEWPORT9 vp;
// Stretch picture with increased internal resolution
@@ -553,14 +553,14 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
if(bScaleByHalf)
{
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
}
else
else
{
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
}
D3DFORMAT bformat = FBManager.GetEFBDepthRTSurfaceFormat();
int SSAAMode = ( g_ActiveConfig.iMultisampleMode > 3 )? 0 : g_ActiveConfig.iMultisampleMode;
@@ -572,14 +572,15 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
Scaledtex_w,
Scaledtex_h,
((bformat != FOURCC_RAWZ && bformat != D3DFMT_D24X8) && bFromZBuffer)? PixelShaderCache::GetDepthMatrixProgram(SSAAMode): PixelShaderCache::GetColorMatrixProgram(SSAAMode),
VertexShaderCache::GetSimpleVertexShader(SSAAMode));
VertexShaderCache::GetSimpleVertexShader(SSAAMode));
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
D3D::SetTexture(0,NULL);
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
Renderer::RestoreAPIState();
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
Renderer::RestoreAPIState();
Rendersurf->Release();
}
@@ -50,17 +50,14 @@ namespace VertexManager
static int lastPrimitive;
static u8 *LocalVBuffer;
static u8 *LocalVBuffer;
static u16 *TIBuffer;
static u16 *LIBuffer;
static u16 *LIBuffer;
static u16 *PIBuffer;
#define MAXVBUFFERSIZE 0x50000
#define MAXIBUFFERSIZE 0xFFFF
static bool Flushed=false;
void CreateDeviceObjects();
void DestroyDeviceObjects();
bool Init()
{
LocalVBuffer = new u8[MAXVBUFFERSIZE];
@@ -69,18 +66,17 @@ bool Init()
PIBuffer = new u16[MAXIBUFFERSIZE];
s_pCurBufferPointer = LocalVBuffer;
Flushed=false;
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
return true;
}
void ResetBuffer()
{
s_pCurBufferPointer = LocalVBuffer;
s_pCurBufferPointer = LocalVBuffer;
}
void Shutdown()
{
DestroyDeviceObjects();
delete [] LocalVBuffer;
delete [] TIBuffer;
delete [] LIBuffer;
@@ -88,25 +84,16 @@ void Shutdown()
ResetBuffer();
}
void CreateDeviceObjects()
{
}
void DestroyDeviceObjects()
{
}
void AddIndices(int _primitive, int _numVertices)
{
switch (_primitive)
{
case GX_DRAW_QUADS: IndexGenerator::AddQuads(_numVertices); break;
case GX_DRAW_QUADS: IndexGenerator::AddQuads(_numVertices); break;
case GX_DRAW_TRIANGLES: IndexGenerator::AddList(_numVertices); break;
case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(_numVertices); break;
case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(_numVertices); break;
case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(_numVertices); break;
case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break;
case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break;
case GX_DRAW_POINTS: IndexGenerator::AddPoints(_numVertices); break;
}
}
@@ -122,10 +109,10 @@ int GetRemainingVertices(int primitive)
{
switch (primitive)
{
case GX_DRAW_QUADS:
case GX_DRAW_TRIANGLES:
case GX_DRAW_TRIANGLE_STRIP:
case GX_DRAW_TRIANGLE_FAN:
case GX_DRAW_QUADS:
case GX_DRAW_TRIANGLES:
case GX_DRAW_TRIANGLE_STRIP:
case GX_DRAW_TRIANGLE_FAN:
return (MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen())/3;
case GX_DRAW_LINE_STRIP:
case GX_DRAW_LINES:
@@ -142,10 +129,10 @@ void AddVertices(int _primitive, int _numVertices)
return;
switch (_primitive)
{
case GX_DRAW_QUADS:
case GX_DRAW_TRIANGLES:
case GX_DRAW_TRIANGLE_STRIP:
case GX_DRAW_TRIANGLE_FAN:
case GX_DRAW_QUADS:
case GX_DRAW_TRIANGLES:
case GX_DRAW_TRIANGLE_STRIP:
case GX_DRAW_TRIANGLE_FAN:
if(MAXIBUFFERSIZE - IndexGenerator::GetTriangleindexLen() < 3 * _numVertices)
Flush();
break;
@@ -165,7 +152,7 @@ void AddVertices(int _primitive, int _numVertices)
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
Flushed=false;
}
lastPrimitive = _primitive;
lastPrimitive = _primitive;
ADDSTAT(stats.thisFrame.numPrims, _numVertices);
INCSTAT(stats.thisFrame.numPrimitiveJoins);
AddIndices(_primitive, _numVertices);
@@ -195,11 +182,11 @@ inline void Draw(int stride)
{
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
D3DPT_TRIANGLELIST,
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumTriangles(),
TIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
stride)))
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumTriangles(),
TIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
stride)))
{
DumpBadShaders();
}
@@ -209,11 +196,11 @@ inline void Draw(int stride)
{
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
D3DPT_LINELIST,
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumLines(),
LIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
stride)))
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumLines(),
LIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
stride)))
{
DumpBadShaders();
}
@@ -223,11 +210,11 @@ inline void Draw(int stride)
{
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
D3DPT_POINTLIST,
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumPoints(),
PIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
stride)))
0, IndexGenerator::GetNumVerts(), IndexGenerator::GetNumPoints(),
PIBuffer,
D3DFMT_INDEX16,
LocalVBuffer,
stride)))
{
DumpBadShaders();
}
@@ -237,7 +224,7 @@ inline void Draw(int stride)
void Flush()
{
if (LocalVBuffer == s_pCurBufferPointer) return;
if (LocalVBuffer == s_pCurBufferPointer) return;
if(Flushed) return;
Flushed=true;
@@ -264,11 +251,11 @@ void Flush()
Renderer::SetSamplerState(i & 3, i >> 2);
FourTexUnits &tex = bpmem.tex[i >> 2];
TextureCache::TCacheEntry* tentry = TextureCache::Load(i,
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
tex.texTlut[i&3].tlut_format,
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
(tex.texMode1[i&3].max_lod >> 5));
if (tentry) {
@@ -307,7 +294,7 @@ void Flush()
Draw(stride);
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
{
DWORD write = 0;
if (!PixelShaderCache::SetShader(true))
@@ -323,7 +310,7 @@ void Flush()
Draw(stride);
D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
}
DEBUGGER_PAUSE_AT(NEXT_FLUSH,true);
@@ -30,9 +30,6 @@ void Shutdown();
void AddVertices(int _primitive, int _numVertices);
void Flush();
void CreateDeviceObjects();
void DestroyDeviceObjects();
} // namespace
#endif
+242 -243
View File
@@ -145,22 +145,22 @@ typedef struct
static const GLenum glSrcFactors[8] =
{
GL_ZERO,
GL_ONE,
GL_DST_COLOR,
GL_ONE_MINUS_DST_COLOR,
GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA,
GL_ONE_MINUS_DST_ALPHA
GL_ZERO,
GL_ONE,
GL_DST_COLOR,
GL_ONE_MINUS_DST_COLOR,
GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA,
GL_ONE_MINUS_DST_ALPHA
};
static const GLenum glDestFactors[8] = {
GL_ZERO,
GL_ZERO,
GL_ONE,
GL_SRC_COLOR,
GL_ONE_MINUS_SRC_COLOR,
GL_SRC_ALPHA,
GL_SRC_ALPHA,
GL_ONE_MINUS_SRC_ALPHA,
GL_DST_ALPHA,
GL_ONE_MINUS_DST_ALPHA
@@ -178,7 +178,7 @@ static const GLenum glCmpFuncs[8] = {
};
static const GLenum glLogicOpCodes[16] = {
GL_CLEAR,
GL_CLEAR,
GL_AND,
GL_AND_REVERSE,
GL_COPY,
@@ -199,15 +199,15 @@ static const GLenum glLogicOpCodes[16] = {
void SetDefaultRectTexParams()
{
// Set some standard texture filter modes.
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (glGetError() != GL_NO_ERROR) {
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
GL_REPORT_ERRORD();
}
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (glGetError() != GL_NO_ERROR) {
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
GL_REPORT_ERRORD();
}
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
@@ -230,7 +230,7 @@ void VideoConfig::UpdateProjectionHack()
bool Renderer::Init()
{
UpdateActiveConfig();
bool bSuccess = true;
bool bSuccess = true;
s_blendMode = 0;
s_MSAACoverageSamples = 0;
switch (g_ActiveConfig.iMultisampleMode)
@@ -247,49 +247,49 @@ bool Renderer::Init()
s_MSAASamples = 1;
}
GLint numvertexattribs = 0;
g_cgcontext = cgCreateContext();
g_cgcontext = cgCreateContext();
cgGetError();
cgGetError();
cgSetErrorHandler(HandleCgError, NULL);
// Look for required extensions.
const char *ptoken = (const char*)glGetString(GL_EXTENSIONS);
// Look for required extensions.
const char *ptoken = (const char*)glGetString(GL_EXTENSIONS);
if (!ptoken)
{
PanicAlert("Your OpenGL Driver seems to be not working.\n"
"Please make sure your drivers are up-to-date and\n"
"Please make sure your drivers are up-to-date and\n"
"that your video hardware is OpenGL 2.x compatible "
);
return false;
}
INFO_LOG(VIDEO, "Supported OpenGL Extensions:");
INFO_LOG(VIDEO, ptoken); // write to the log file
INFO_LOG(VIDEO, "");
INFO_LOG(VIDEO, "Supported OpenGL Extensions:");
INFO_LOG(VIDEO, ptoken); // write to the log file
INFO_LOG(VIDEO, "");
OSD::AddMessage(StringFromFormat("Video Info: %s, %s, %s", (const char*)glGetString(GL_VENDOR),
(const char*)glGetString(GL_RENDERER),
(const char*)glGetString(GL_VERSION)).c_str(), 5000);
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
if (numvertexattribs < 11) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********Does your video card support OpenGL 2.x?", numvertexattribs);
bSuccess = false;
}
if (numvertexattribs < 11) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Number of attributes %d not enough\nGPU: *********Does your video card support OpenGL 2.x?", numvertexattribs);
bSuccess = false;
}
// Init extension support.
if (glewInit() != GLEW_OK) {
ERROR_LOG(VIDEO, "glewInit() failed!Does your video card support OpenGL 2.x?");
return false;
}
if (!GLEW_EXT_framebuffer_object) {
ERROR_LOG(VIDEO, "*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********Does your video card support OpenGL 2.x?");
bSuccess = false;
}
if (!GLEW_EXT_secondary_color) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********Does your video card support OpenGL 2.x?");
bSuccess = false;
}
ERROR_LOG(VIDEO, "glewInit() failed!Does your video card support OpenGL 2.x?");
return false;
}
if (!GLEW_EXT_framebuffer_object) {
ERROR_LOG(VIDEO, "*********\nGPU: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nGPU: *********Does your video card support OpenGL 2.x?");
bSuccess = false;
}
if (!GLEW_EXT_secondary_color) {
ERROR_LOG(VIDEO, "*********\nGPU: OGL ERROR: Need GL_EXT_secondary_color\nGPU: *********Does your video card support OpenGL 2.x?");
bSuccess = false;
}
s_bHaveFramebufferBlit = strstr(ptoken, "GL_EXT_framebuffer_blit") != NULL;
if (!s_bHaveFramebufferBlit)
{
@@ -302,8 +302,8 @@ bool Renderer::Init()
s_MSAACoverageSamples = 0;
}
if (!bSuccess)
return false;
if (!bSuccess)
return false;
// Handle VSync on/off
#if defined USE_WX && USE_WX
@@ -320,7 +320,7 @@ bool Renderer::Init()
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)");
#endif
// check the max texture width and height
// check the max texture width and height
GLint max_texture_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&max_texture_size);
if (max_texture_size < 1024) {
@@ -330,8 +330,8 @@ bool Renderer::Init()
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
if (glDrawBuffers == NULL && !GLEW_ARB_draw_buffers)
glDrawBuffers = glDrawBuffersARB;
if (glDrawBuffers == NULL && !GLEW_ARB_draw_buffers)
glDrawBuffers = glDrawBuffersARB;
if (!GLEW_ARB_texture_non_power_of_two) {
WARN_LOG(VIDEO, "ARB_texture_non_power_of_two not supported.");
@@ -377,7 +377,7 @@ bool Renderer::Init()
// Because of the fixed framebuffer size we need to disable the resolution options while running
g_Config.bRunning = true;
if (GL_REPORT_ERROR() != GL_NO_ERROR)
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
// Initialize the FramebufferManager
@@ -385,93 +385,93 @@ bool Renderer::Init()
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
if (GL_REPORT_ERROR() != GL_NO_ERROR)
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
s_pfont = new RasterFont();
s_pfont = new RasterFont();
// load the effect, find the best profiles (if any)
if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) {
ERROR_LOG(VIDEO, "arbvp1 not supported");
return false;
}
// load the effect, find the best profiles (if any)
if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1) != CG_TRUE) {
ERROR_LOG(VIDEO, "arbvp1 not supported");
return false;
}
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) {
ERROR_LOG(VIDEO, "arbfp1 not supported");
return false;
}
if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1) != CG_TRUE) {
ERROR_LOG(VIDEO, "arbfp1 not supported");
return false;
}
g_cgvProf = cgGLGetLatestProfile(CG_GL_VERTEX);
g_cgfProf = cgGLGetLatestProfile(CG_GL_FRAGMENT);
cgGLSetOptimalOptions(g_cgvProf);
cgGLSetOptimalOptions(g_cgfProf);
g_cgvProf = cgGLGetLatestProfile(CG_GL_VERTEX);
g_cgfProf = cgGLGetLatestProfile(CG_GL_FRAGMENT);
cgGLSetOptimalOptions(g_cgvProf);
cgGLSetOptimalOptions(g_cgfProf);
INFO_LOG(VIDEO, "Max buffer sizes: %d %d", cgGetProgramBufferMaxSize(g_cgvProf), cgGetProgramBufferMaxSize(g_cgfProf));
int nenvvertparams, nenvfragparams, naddrregisters[2];
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvvertparams);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvfragparams);
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[0]);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[1]);
DEBUG_LOG(VIDEO, "Max program env parameters: vert=%d, frag=%d", nenvvertparams, nenvfragparams);
DEBUG_LOG(VIDEO, "Max program address register parameters: vert=%d, frag=%d", naddrregisters[0], naddrregisters[1]);
INFO_LOG(VIDEO, "Max buffer sizes: %d %d", cgGetProgramBufferMaxSize(g_cgvProf), cgGetProgramBufferMaxSize(g_cgfProf));
int nenvvertparams, nenvfragparams, naddrregisters[2];
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvvertparams);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, (GLint *)&nenvfragparams);
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[0]);
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, (GLint *)&naddrregisters[1]);
DEBUG_LOG(VIDEO, "Max program env parameters: vert=%d, frag=%d", nenvvertparams, nenvfragparams);
DEBUG_LOG(VIDEO, "Max program address register parameters: vert=%d, frag=%d", naddrregisters[0], naddrregisters[1]);
if (nenvvertparams < 238)
ERROR_LOG(VIDEO, "Not enough vertex shader environment constants!!");
ERROR_LOG(VIDEO, "Not enough vertex shader environment constants!!");
#ifndef _DEBUG
cgGLSetDebugMode(GL_FALSE);
cgGLSetDebugMode(GL_FALSE);
#endif
glStencilFunc(GL_ALWAYS, 0, 0);
glBlendFunc(GL_ONE, GL_ONE);
glStencilFunc(GL_ALWAYS, 0, 0);
glBlendFunc(GL_ONE, GL_ONE);
glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport
glViewport(0, 0, GetTargetWidth(), GetTargetHeight()); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDepthFunc(GL_LEQUAL);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
glDisable(GL_STENCIL_TEST);
glEnable(GL_SCISSOR_TEST);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDepthFunc(GL_LEQUAL);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
glDisable(GL_STENCIL_TEST);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, GetTargetWidth(), GetTargetHeight());
glBlendColorEXT(0, 0, 0, 0.5f);
glClearDepth(1.0f);
glScissor(0, 0, GetTargetWidth(), GetTargetHeight());
glBlendColorEXT(0, 0, 0, 0.5f);
glClearDepth(1.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// legacy multitexturing: select texture channel only.
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
// legacy multitexturing: select texture channel only.
glActiveTexture(GL_TEXTURE0);
glClientActiveTexture(GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
UpdateActiveConfig();
return glGetError() == GL_NO_ERROR && bSuccess;
return glGetError() == GL_NO_ERROR && bSuccess;
}
void Renderer::Shutdown(void)
{
{
g_Config.bRunning = false;
UpdateActiveConfig();
delete s_pfont;
delete s_pfont;
s_pfont = 0;
if (g_cgcontext) {
cgDestroyContext(g_cgcontext);
g_cgcontext = 0;
if (g_cgcontext) {
cgDestroyContext(g_cgcontext);
g_cgcontext = 0;
}
if(s_tempScreenshotFramebuffer)
glDeleteFramebuffersEXT(1, &s_tempScreenshotFramebuffer);
@@ -535,12 +535,12 @@ int Renderer::GetTargetHeight()
}
float Renderer::GetTargetScaleX()
{
return EFBxScale;
return EFBxScale;
}
float Renderer::GetTargetScaleY()
{
return EFByScale;
return EFByScale;
}
@@ -553,20 +553,19 @@ TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
}
void Renderer::ResetAPIState()
{
// Gets us to a reasonably sane state where it's possible to do things like
// image copies with textured quads, etc.
VertexShaderCache::DisableShader();
PixelShaderCache::DisableShader();
PixelShaderCache::DisableShader();
glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDepthMask(GL_FALSE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDepthMask(GL_FALSE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
void UpdateViewport();
@@ -582,17 +581,17 @@ void Renderer::RestoreAPIState()
UpdateViewport();
if (bpmem.genMode.cullmode > 0) glEnable(GL_CULL_FACE);
if (bpmem.zmode.testenable) glEnable(GL_DEPTH_TEST);
if (bpmem.zmode.updateenable) glDepthMask(GL_TRUE);
if (bpmem.genMode.cullmode > 0) glEnable(GL_CULL_FACE);
if (bpmem.zmode.testenable) glEnable(GL_DEPTH_TEST);
if (bpmem.zmode.updateenable) glDepthMask(GL_TRUE);
glEnable(GL_SCISSOR_TEST);
glEnable(GL_SCISSOR_TEST);
SetScissorRect();
SetColorMask();
SetColorMask();
SetBlendMode(true);
VertexShaderCache::SetCurrentShader(0);
PixelShaderCache::SetCurrentShader(0);
PixelShaderCache::SetCurrentShader(0);
}
void Renderer::SetColorMask()
@@ -612,9 +611,9 @@ void Renderer::SetBlendMode(bool forceUpdate)
u32 newval = bpmem.blendmode.subtract << 2;
if (bpmem.blendmode.subtract) {
newval |= 0x0049; // enable blending src 1 dst 1
} else if (bpmem.blendmode.blendenable) {
if (bpmem.blendmode.subtract) {
newval |= 0x0049; // enable blending src 1 dst 1
} else if (bpmem.blendmode.blendenable) {
newval |= 1; // enable blending
newval |= bpmem.blendmode.srcfactor << 3;
newval |= bpmem.blendmode.dstfactor << 6;
@@ -623,11 +622,11 @@ void Renderer::SetBlendMode(bool forceUpdate)
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
if (changes & 1) {
// blend enable change
// blend enable change
(newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
}
if (changes & 4) {
if (changes & 4) {
// subtract enable change
glBlendEquation(newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD);
}
@@ -690,7 +689,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
// Although it may sound strange, this really is A8R8G8B8 and not RGBA or 24-bit...
// Tested in Killer 7, the first 8bits represent the alpha value which is used to
// determine if we're aiming at an enemy (0x80 / 0x88) or not (0x70)
// determine if we're aiming at an enemy (0x80 / 0x88) or not (0x70)
// Wind Waker is also using it for the pictograph to determine the color of each pixel
if (s_MSAASamples > 1)
@@ -736,20 +735,20 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
// therefore the width and height are (scissorBR + 1) - scissorTL
bool Renderer::SetScissorRect()
{
int xoff = bpmem.scissorOffset.x * 2 - 342;
int yoff = bpmem.scissorOffset.y * 2 - 342;
float rc_left = (float)bpmem.scissorTL.x - xoff - 342; // left = 0
if (rc_left < 0) rc_left = 0;
int xoff = bpmem.scissorOffset.x * 2 - 342;
int yoff = bpmem.scissorOffset.y * 2 - 342;
float rc_left = (float)bpmem.scissorTL.x - xoff - 342; // left = 0
if (rc_left < 0) rc_left = 0;
float rc_top = (float)bpmem.scissorTL.y - yoff - 342; // right = 0
if (rc_top < 0) rc_top = 0;
if (rc_top < 0) rc_top = 0;
float rc_right = (float)bpmem.scissorBR.x - xoff - 341; // right = 640
if (rc_right > EFB_WIDTH) rc_right = EFB_WIDTH;
float rc_bottom = (float)bpmem.scissorBR.y - yoff - 341; // bottom = 480
if (rc_bottom > EFB_HEIGHT) rc_bottom = EFB_HEIGHT;
if (rc_bottom > EFB_HEIGHT) rc_bottom = EFB_HEIGHT;
if(rc_left > rc_right)
{
@@ -766,7 +765,7 @@ bool Renderer::SetScissorRect()
// Check that the coordinates are good
if (rc_right >= rc_left && rc_bottom >= rc_top)
if (rc_right >= rc_left && rc_bottom >= rc_top)
{
glScissor(
(int)(rc_left * EFBxScale), // x = 0 for example
@@ -774,18 +773,18 @@ bool Renderer::SetScissorRect()
(int)((rc_right - rc_left)* EFBxScale), // width = 640 for example
(int)((rc_bottom - rc_top) * EFByScale) // height = 480 for example
);
return true;
}
return true;
}
else
{
glScissor(
0,
0,
Renderer::GetTargetWidth(),
Renderer::GetTargetHeight()
);
Renderer::GetTargetHeight()
);
}
return false;
return false;
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
@@ -795,10 +794,10 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
// Always set the scissor in case it was set by the game and has not been reset
// Always set the scissor in case it was set by the game and has not been reset
glScissor(targetRc.left, targetRc.bottom, targetRc.GetWidth(), targetRc.GetHeight());
VertexShaderManager::SetViewportChanged();
VertexShaderManager::SetViewportChanged();
GLbitfield bits = 0;
if (colorEnable)
@@ -847,7 +846,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
{
g_VideoInitialize.pCopiedToXFB(false);
return;
}
}
if (field == FIELD_LOWER) xfbAddr -= fbWidth * 2;
u32 xfbCount = 0;
const XFBSource** xfbSourceList = g_framebufferManager.GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
@@ -858,9 +857,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
return;
}
DVSTARTPROFILE();
DVSTARTPROFILE();
ResetAPIState();
ResetAPIState();
TargetRectangle back_rc;
ComputeDrawRectangle(m_CustomWidth, m_CustomHeight, true, &back_rc);
@@ -891,7 +890,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// We must call ApplyShader here even if no post proc is selected - it takes
// We must call ApplyShader here even if no post proc is selected - it takes
// care of disabling it in that case. It returns false in case of no post processing.
bool applyShader = PostProcessing::ApplyShader();
@@ -900,7 +899,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// draw each xfb source
for (u32 i = 0; i < xfbCount; ++i)
{
xfbSource = xfbSourceList[i];
xfbSource = xfbSourceList[i];
TargetRectangle sourceRc;
@@ -956,7 +955,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Texture map xfbSource->texture onto the main buffer
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfbSource->texture);
// We must call ApplyShader here even if no post proc is selected - it takes
// We must call ApplyShader here even if no post proc is selected - it takes
// care of disabling it in that case. It returns false in case of no post processing.
if (applyShader)
{
@@ -966,14 +965,14 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
glTexCoord2f(sourceRc.right, sourceRc.top); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 1); glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom); glMultiTexCoord2fARB(GL_TEXTURE1, 1, 0); glVertex2f(drawRc.right, drawRc.bottom);
glEnd();
PixelShaderCache::DisableShader();;
PixelShaderCache::DisableShader();
}
else
{
glBegin(GL_QUADS);
glTexCoord2f(sourceRc.left, sourceRc.bottom); glVertex2f(drawRc.left, drawRc.bottom);
glTexCoord2f(sourceRc.left, sourceRc.top); glVertex2f(drawRc.left, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.top); glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.left, sourceRc.top); glVertex2f(drawRc.left, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.top); glVertex2f(drawRc.right, drawRc.top);
glTexCoord2f(sourceRc.right, sourceRc.bottom); glVertex2f(drawRc.right, drawRc.bottom);
glEnd();
}
@@ -1026,20 +1025,20 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
u8 *data = (u8 *) malloc(3 * w * h);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, Renderer::GetTargetHeight() - h, w, h, GL_BGR, GL_UNSIGNED_BYTE, data);
if (glGetError() == GL_NO_ERROR && w > 0 && h > 0)
if (glGetError() == GL_NO_ERROR && w > 0 && h > 0)
{
if (!s_bLastFrameDumped)
if (!s_bLastFrameDumped)
{
s_bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), w, h);
if (!s_bAVIDumping)
OSD::AddMessage("AVIDump Start failed", 2000);
else
else
{
OSD::AddMessage(StringFromFormat(
"Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)", File::GetUserPath(D_DUMPFRAMES_IDX), w, h).c_str(), 2000);
}
}
if (s_bAVIDumping)
if (s_bAVIDumping)
AVIDump::AddFrame((char *) data);
s_bLastFrameDumped = true;
@@ -1053,10 +1052,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, 0, 0);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, g_framebufferManager.GetEFBFramebuffer());
}
else
}
else
{
if(s_bLastFrameDumped && s_bAVIDumping)
if(s_bLastFrameDumped && s_bAVIDumping)
{
AVIDump::Stop();
s_bAVIDumping = false;
@@ -1128,7 +1127,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
if( xfbchanged || WindowResized)
{
{
TargetRectangle dst_rect;
ComputeDrawRectangle(m_CustomWidth, m_CustomHeight, false, &dst_rect);
@@ -1172,20 +1171,20 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Count FPS.
// -------------
static int fpscount = 0;
static unsigned long lasttime;
++fpscount;
if (Common::Timer::GetTimeMs() - lasttime > 1000)
{
lasttime = Common::Timer::GetTimeMs();
s_fps = fpscount - 1;
fpscount = 0;
}
static unsigned long lasttime;
++fpscount;
if (Common::Timer::GetTimeMs() - lasttime > 1000)
{
lasttime = Common::Timer::GetTimeMs();
s_fps = fpscount - 1;
fpscount = 0;
}
// ---------------------------------------------------------------------
GL_REPORT_ERRORD();
GL_REPORT_ERRORD();
DrawDebugText();
GL_REPORT_ERRORD();
GL_REPORT_ERRORD();
// Get the status of the Blend mode
GLboolean blend_enabled = glIsEnabled(GL_BLEND);
@@ -1193,22 +1192,22 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
OSD::DrawMessages();
if (blend_enabled)
glEnable(GL_BLEND);
GL_REPORT_ERRORD();
GL_REPORT_ERRORD();
#if defined(DVPROFILE)
if (g_bWriteProfile) {
//g_bWriteProfile = 0;
static int framenum = 0;
const int UPDATE_FRAMES = 8;
if (++framenum >= UPDATE_FRAMES) {
DVProfWrite("prof.txt", UPDATE_FRAMES);
DVProfClear();
framenum = 0;
}
}
if (g_bWriteProfile) {
//g_bWriteProfile = 0;
static int framenum = 0;
const int UPDATE_FRAMES = 8;
if (++framenum >= UPDATE_FRAMES) {
DVProfWrite("prof.txt", UPDATE_FRAMES);
DVProfClear();
framenum = 0;
}
}
#endif
// Copy the rendered frame to the real window
// Copy the rendered frame to the real window
OpenGL_SwapBuffers();
GL_REPORT_ERRORD();
// Clear framebuffer
@@ -1219,22 +1218,22 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Clean out old stuff from caches. It's not worth it to clean out the shader caches.
DLCache::ProgressiveCleanup();
TextureMngr::ProgressiveCleanup();
TextureMngr::ProgressiveCleanup();
frameCount++;
frameCount++;
// New frame
stats.ResetFrame();
// New frame
stats.ResetFrame();
// Render to the framebuffer.
g_framebufferManager.SetFramebuffer(0);
GL_REPORT_ERRORD();
RestoreAPIState();
RestoreAPIState();
GL_REPORT_ERRORD();
g_Config.iSaveTargetId = 0;
g_Config.iSaveTargetId = 0;
bool last_copy_efb_to_Texture = g_ActiveConfig.bCopyEFBToTexture;
UpdateActiveConfig();
@@ -1242,8 +1241,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
TextureMngr::ClearRenderTargets();
// For testing zbuffer targets.
// Renderer::SetZBufferRender();
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
// Renderer::SetZBufferRender();
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
XFBWrited = false;
g_VideoInitialize.pCopiedToXFB(true);
@@ -1265,11 +1264,11 @@ void Renderer::DrawDebugText()
if (g_ActiveConfig.bShowEFBCopyRegions)
{
// Store Line Size
GLfloat lSize;
GLfloat lSize;
glGetFloatv(GL_LINE_WIDTH, &lSize);
// Set Line Size
glLineWidth(3.0f);
glLineWidth(3.0f);
glBegin(GL_LINES);
@@ -1277,8 +1276,8 @@ void Renderer::DrawDebugText()
for (std::vector<EFBRectangle>::const_iterator it = stats.efb_regions.begin(); it != stats.efb_regions.end(); ++it)
{
GLfloat halfWidth = EFB_WIDTH / 2.0f;
GLfloat halfHeight = EFB_HEIGHT / 2.0f;
GLfloat x = (GLfloat) -1.0f + ((GLfloat)it->left / halfWidth);
GLfloat halfHeight = EFB_HEIGHT / 2.0f;
GLfloat x = (GLfloat) -1.0f + ((GLfloat)it->left / halfWidth);
GLfloat y = (GLfloat) 1.0f - ((GLfloat)it->top / halfHeight);
GLfloat x2 = (GLfloat) -1.0f + ((GLfloat)it->right / halfWidth);
GLfloat y2 = (GLfloat) 1.0f - ((GLfloat)it->bottom / halfHeight);
@@ -1307,10 +1306,10 @@ void Renderer::DrawDebugText()
stats.efb_regions.clear();
}
if (g_ActiveConfig.bOverlayStats)
if (g_ActiveConfig.bOverlayStats)
{
p = Statistics::ToString(p);
}
}
if (g_ActiveConfig.bOverlayProjStats)
{
@@ -1342,7 +1341,7 @@ void Renderer::DrawDebugText()
H = OpenGL_GetBackbufferHeight();
std::string OSDM1 =
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?
(g_ActiveConfig.bNativeResolution ?
StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH)
: StringFromFormat("%i x %i (2x)", OSDInternalW, OSDInternalH))
@@ -1364,7 +1363,7 @@ void Renderer::DrawDebugText()
break;
}
std::string OSDM22 =
g_ActiveConfig.bCrop ? " (crop)" : "";
g_ActiveConfig.bCrop ? " (crop)" : "";
std::string OSDM3 = g_ActiveConfig.bEFBCopyDisable ? "Disabled" :
g_ActiveConfig.bCopyEFBToTexture ? "To Texture" : "To RAM";
@@ -1377,21 +1376,21 @@ void Renderer::DrawDebugText()
T0.push_back(StringFromFormat("4: Aspect Ratio: %s%s\n", OSDM21.c_str(), OSDM22.c_str()));
T0.push_back(StringFromFormat("5: Copy EFB: %s\n", OSDM3.c_str()));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
// The latest changed setting in yellow
T1 += (OSDChoice == -1) ? T0.at(0) : "\n";
T1 += (OSDChoice == -2) ? T0.at(1) : "\n";
T1 += (OSDChoice == -3) ? T0.at(2) : "\n";
T1 += (OSDChoice == -4) ? T0.at(3) : "\n";
T1 += (OSDChoice == -5) ? T0.at(4) : "\n";
T1 += (OSDChoice == -5) ? T0.at(4) : "\n";
// The other settings in cyan
T2 += (OSDChoice != -1) ? T0.at(0) : "\n";
T2 += (OSDChoice != -2) ? T0.at(1) : "\n";
T2 += (OSDChoice != -3) ? T0.at(2) : "\n";
T2 += (OSDChoice != -4) ? T0.at(3) : "\n";
T2 += (OSDChoice != -5) ? T0.at(4) : "\n";
T2 += (OSDChoice != -5) ? T0.at(4) : "\n";
// Render a shadow, and then the text
Renderer::RenderText(T1.c_str(), 21, 21, 0xDD000000);
@@ -1405,11 +1404,11 @@ void Renderer::RenderText(const char* pstr, int left, int top, u32 color)
{
int nBackbufferWidth = (int)OpenGL_GetBackbufferWidth();
int nBackbufferHeight = (int)OpenGL_GetBackbufferHeight();
glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f,
((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f);
s_pfont->printMultilineText(pstr,
left * 2.0f / (float)nBackbufferWidth - 1,
1 - top * 2.0f / (float)nBackbufferHeight,
glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f,
((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f);
s_pfont->printMultilineText(pstr,
left * 2.0f / (float)nBackbufferWidth - 1,
1 - top * 2.0f / (float)nBackbufferHeight,
0, nBackbufferWidth, nBackbufferHeight);
GL_REPORT_ERRORD();
}
@@ -1442,7 +1441,7 @@ THREAD_RETURN TakeScreenshot(void *pArgs)
use16_9 = true;
else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3)
use16_9 = false;
float Ratio = (FloatW / FloatH) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// If ratio > 1 the picture is too wide and we have to limit the width.
@@ -1451,7 +1450,7 @@ THREAD_RETURN TakeScreenshot(void *pArgs)
// ratio == 1 or the image is too high, we have to limit the height.
else
FloatH *= Ratio;
// This is a bit expensive on high resolutions
threadStruct->img->Rescale((int)FloatW, (int)FloatH, wxIMAGE_QUALITY_HIGH);
}
@@ -1473,47 +1472,47 @@ bool Renderer::SaveRenderTarget(const char *filename, int W, int H, int YOffset)
{
u8 *data = (u8 *)malloc(3 * W * H);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, Renderer::GetTargetHeight() - H + YOffset, W, H, GL_RGB, GL_UNSIGNED_BYTE, data);
// Show failure message
if (glGetError() != GL_NO_ERROR)
{
OSD::AddMessage("Error capturing or saving screenshot.", 2000);
return false;
}
// Turn image upside down
FlipImageData(data, W, H);
#if defined(HAVE_WX) && HAVE_WX
// Create wxImage
wxImage *a = new wxImage(W, H, data);
if (scrshotThread)
{
delete scrshotThread;
scrshotThread = NULL;
}
ScrStrct *threadStruct = new ScrStrct;
threadStruct->filename = std::string(filename);
threadStruct->img = a;
threadStruct->H = H; threadStruct->W = W;
scrshotThread = new Common::Thread(TakeScreenshot, threadStruct);
#ifdef _WIN32
scrshotThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL);
#endif
bool result = true;
OSD::AddMessage("Saving Screenshot... ", 2000);
#else
bool result = SaveTGA(filename, W, H, data);
free(data);
#endif
return result;
}
@@ -1536,12 +1535,12 @@ void Renderer::FlipImageData(u8 *data, int w, int h)
void UpdateViewport()
{
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// [0] = width/2
// [1] = height/2
// [2] = 16777215 * (farz - nearz)
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
// [0] = width/2
// [1] = height/2
// [2] = 16777215 * (farz - nearz)
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
int scissorXOff = bpmem.scissorOffset.x * 2; // 342
int scissorYOff = bpmem.scissorOffset.y * 2; // 342
@@ -1555,7 +1554,7 @@ void UpdateViewport()
if(GLWidth < 0)
{
GLx += GLWidth;
GLWidth*=-1;
GLWidth*=-1;
}
if(GLHeight < 0)
{
@@ -1570,47 +1569,47 @@ void UpdateViewport()
void Renderer::SetGenerationMode()
{
// none, ccw, cw, ccw
if (bpmem.genMode.cullmode > 0)
if (bpmem.genMode.cullmode > 0)
{
glEnable(GL_CULL_FACE);
glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
}
else
glEnable(GL_CULL_FACE);
glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
}
else
glDisable(GL_CULL_FACE);
}
void Renderer::SetDepthMode()
{
if (bpmem.zmode.testenable)
if (bpmem.zmode.testenable)
{
glEnable(GL_DEPTH_TEST);
glDepthMask(bpmem.zmode.updateenable ? GL_TRUE : GL_FALSE);
glDepthFunc(glCmpFuncs[bpmem.zmode.func]);
}
else
else
{
// if the test is disabled write is disabled too
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
}
}
}
void Renderer::SetLogicOpMode()
{
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
{
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(glLogicOpCodes[bpmem.blendmode.logicmode]);
}
else
else
glDisable(GL_COLOR_LOGIC_OP);
}
void Renderer::SetDitherMode()
{
if (bpmem.blendmode.dither)
if (bpmem.blendmode.dither)
glEnable(GL_DITHER);
else
else
glDisable(GL_DITHER);
}
@@ -62,7 +62,7 @@ class CWiiMote;
wiimote_t** g_WiiMotesFromWiiUse = NULL;
Common::Thread* g_pReadThread = NULL;
int g_NumberOfWiiMotes;
CWiiMote* g_WiiMotes[MAX_WIIMOTES];
CWiiMote* g_WiiMotes[MAX_WIIMOTES];
volatile bool g_Shutdown = false;
Common::Event g_StartThread;
Common::Event g_StopThreadTemporary;
@@ -101,16 +101,16 @@ class CWiiMote
{
public:
CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
: m_WiimoteNumber(_WiimoteNumber)
, m_channelID(0)
, m_pWiiMote(_pWiimote)
, m_pCriticalSection(NULL)
, m_LastReportValid(false)
CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
: m_WiimoteNumber(_WiimoteNumber)
, m_channelID(0)
, m_pWiiMote(_pWiimote)
, m_pCriticalSection(NULL)
, m_LastReportValid(false)
{
m_pCriticalSection = new Common::CriticalSection();
m_pCriticalSection = new Common::CriticalSection();
//wiiuse_set_leds(m_pWiiMote, WIIMOTE_LED_4);
//wiiuse_set_leds(m_pWiiMote, WIIMOTE_LED_4);
#ifdef _WIN32
// F|RES: i dunno if we really need this
@@ -118,34 +118,34 @@ CWiiMote(u8 _WiimoteNumber, wiimote_t* _pWiimote)
#endif
}
virtual ~CWiiMote()
virtual ~CWiiMote()
{
delete m_pCriticalSection;
delete m_pCriticalSection;
};
// Queue raw HID data from the core to the wiimote
void SendData(u16 _channelID, const u8* _pData, u32 _Size)
{
m_channelID = _channelID;
m_channelID = _channelID;
m_pCriticalSection->Enter();
{
SEvent WriteEvent;
m_pCriticalSection->Enter();
{
SEvent WriteEvent;
memcpy(WriteEvent.m_PayLoad, _pData, _Size);
WriteEvent._Size = _Size;
m_EventWriteQueue.push(WriteEvent);
m_EventWriteQueue.push(WriteEvent);
// Debugging
//std::string Temp = ArrayToString(WriteEvent.m_PayLoad, 28, 0, 30);
//DEBUG_LOG(WIIMOTE, "Wiimote Write:\n%s", Temp.c_str());
}
m_pCriticalSection->Leave();
}
m_pCriticalSection->Leave();
}
/* Read and write data to the Wiimote */
void ReadData()
void ReadData()
{
m_pCriticalSection->Enter();
@@ -179,7 +179,7 @@ void ReadData()
m_pCriticalSection->Enter();
// Filter out data reports
if (pBuffer[1] >= 0x30)
if (pBuffer[1] >= 0x30)
{
// Copy Buffer to LastReport
memcpy(m_LastReport.m_PayLoad, pBuffer + 1, MAX_PAYLOAD - 1);
@@ -207,25 +207,25 @@ void ReadData()
// Send queued data to the core
void Update()
void Update()
{
// Thread function
m_pCriticalSection->Enter();
m_pCriticalSection->Enter();
if (m_EventReadQueue.empty())
{
if (m_EventReadQueue.empty())
{
// Send the data report
if (m_LastReportValid)
if (m_LastReportValid)
SendEvent(m_LastReport);
}
else
{
}
else
{
// Send a 0x20, 0x21 or 0x22 report
SendEvent(m_EventReadQueue.front());
m_EventReadQueue.pop();
}
SendEvent(m_EventReadQueue.front());
m_EventReadQueue.pop();
}
m_pCriticalSection->Leave();
m_pCriticalSection->Leave();
};
@@ -235,62 +235,62 @@ void ClearEvents()
while (!m_EventReadQueue.empty())
m_EventReadQueue.pop();
while (!m_EventWriteQueue.empty())
m_EventWriteQueue.pop();
m_EventWriteQueue.pop();
}
private:
struct SEvent
{
SEvent()
{
memset(m_PayLoad, 0, MAX_PAYLOAD);
}
byte m_PayLoad[MAX_PAYLOAD];
struct SEvent
{
SEvent()
{
memset(m_PayLoad, 0, MAX_PAYLOAD);
}
byte m_PayLoad[MAX_PAYLOAD];
u32 _Size;
};
typedef std::queue<SEvent> CEventQueue;
};
typedef std::queue<SEvent> CEventQueue;
u8 m_WiimoteNumber; // Just for debugging
u16 m_channelID;
CEventQueue m_EventReadQueue; // Read from Wiimote
CEventQueue m_EventWriteQueue; // Write to Wiimote
SEvent m_LastReport;
u8 m_WiimoteNumber; // Just for debugging
u16 m_channelID;
CEventQueue m_EventReadQueue; // Read from Wiimote
CEventQueue m_EventWriteQueue; // Write to Wiimote
SEvent m_LastReport;
wiimote_t* m_pWiiMote; // This is g_WiiMotesFromWiiUse[]
Common::CriticalSection* m_pCriticalSection;
Common::CriticalSection* m_pCriticalSection;
bool m_LastReportValid;
// Send queued data to the core
void SendEvent(SEvent& _rEvent)
{
// We don't have an answer channel
if (m_channelID == 0)
// We don't have an answer channel
if (m_channelID == 0)
return;
// Check event buffer
u8 Buffer[1024];
u32 Offset = 0;
hid_packet* pHidHeader = (hid_packet*)(Buffer + Offset);
pHidHeader->type = HID_TYPE_DATA;
pHidHeader->param = HID_PARAM_INPUT;
// Check event buffer
u8 Buffer[1024];
u32 Offset = 0;
hid_packet* pHidHeader = (hid_packet*)(Buffer + Offset);
pHidHeader->type = HID_TYPE_DATA;
pHidHeader->param = HID_PARAM_INPUT;
// Create the buffer
memcpy(&Buffer[Offset], pHidHeader, sizeof(hid_packet));
Offset += sizeof(hid_packet);
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, sizeof(_rEvent.m_PayLoad));
Offset += sizeof(_rEvent.m_PayLoad);
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, sizeof(_rEvent.m_PayLoad));
Offset += sizeof(_rEvent.m_PayLoad);
// Send it
g_WiimoteInitialize.pWiimoteInput(m_WiimoteNumber, m_channelID, Buffer, Offset);
// Debugging
// ReadDebugging(false, Buffer, Offset);
// ReadDebugging(false, Buffer, Offset);
}
};
// Function Definitions
// Function Definitions
void SendAcc(u8 _ReportID)
{
@@ -348,7 +348,7 @@ int Initialize()
Connected.Init();
// Clear the wiimote classes
memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES);
memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES);
for (int i = 0; i < MAX_WIIMOTES; i++)
g_WiimoteInUse[i] = false;
@@ -399,7 +399,7 @@ int Initialize()
// If we are connecting from the config window without a game running we set the LEDs
if (g_EmulatorState != PLUGIN_EMUSTATE_PLAY && g_RealWiiMotePresent)
FlashLights(true);
/* Allocate memory and copy the Wiimote eeprom accelerometer neutral values
to g_Eeprom. Unlike with and extension we have to do this here, because
@@ -429,7 +429,7 @@ void Allocate()
Initialize();
// Clear the wiimote classes
memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES);
memset(g_WiiMotes, 0, sizeof(CWiiMote*) * MAX_WIIMOTES);
for (int i = 0; i < MAX_WIIMOTES; i++)
g_WiimoteInUse[i] = false;
@@ -500,7 +500,7 @@ void Allocate()
}
void DoState(PointerWrap &p)
void DoState(PointerWrap &p)
{
//TODO: Implement
}
@@ -575,7 +575,7 @@ THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
DEBUG_LOG(WIIMOTE, "Connected: %i", Connect);
#endif
Connected.Set();
while (!g_Shutdown)
{
// There is at least one Real Wiimote in use
@@ -587,8 +587,8 @@ THREAD_RETURN ReadWiimote_ThreadFunc(void* arg)
g_WiiMotes[i]->ReadData();
}
else {
if (!g_StopThreadTemporary.Wait(0))
if (!g_StopThreadTemporary.Wait(0))
{
// Event object was signaled, exiting thread to close ConfigRecordingDlg
new Common::Thread(SafeCloseReadWiimote_ThreadFunc, NULL);
@@ -616,7 +616,7 @@ bool SafeClose()
return true;
}
// Thread to avoid racing conditions by directly closing of ReadWiimote_ThreadFunc() resp. ReadWiimote()
// Thread to avoid racing conditions by directly closing of ReadWiimote_ThreadFunc() resp. ReadWiimote()
// shutting down the Dlg while still beeing @ReadWiimote will result in a crash;
THREAD_RETURN SafeCloseReadWiimote_ThreadFunc(void* arg)
{
@@ -693,7 +693,7 @@ int WiimotePairUp(bool unpair)
if (hFind == NULL)
{
ERROR_LOG(WIIMOTE, "Pair-Up: Error enumerating devices: %08x", GetLastError());
ERROR_LOG(WIIMOTE, "Pair-Up: Error enumerating devices: %08x", GetLastError());
return -1;
}
@@ -702,10 +702,10 @@ int WiimotePairUp(bool unpair)
//btdi.szName is sometimes missings it's content - it's a bt feature..
if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && !btdi.fConnected && !unpair)
{
//TODO: improve the readd of the BT driver, esp. when batteries of the wiimote are removed while beeing fConnected
if (btdi.fRemembered)
//TODO: improve the read of the BT driver, esp. when batteries of the wiimote are removed while being fConnected
if (btdi.fRemembered)
{
// Make Windows forget old expired pairing
// Make Windows forget old expired pairing
// we can pretty much ignore the return value here.
// it either worked (ERROR_SUCCESS), or the device did not exist (ERROR_NOT_FOUND)
// in both cases, there is nothing left.
@@ -714,21 +714,21 @@ int WiimotePairUp(bool unpair)
// Activate service
DWORD hr = BluetoothSetServiceState(hRadios[radio], &btdi, &HumanInterfaceDeviceServiceClass_UUID, BLUETOOTH_SERVICE_ENABLE);
if (!hr == ERROR_SUCCESS)
if (!hr == ERROR_SUCCESS)
{
nPaired++;
}
else
else
{
ERROR_LOG(WIIMOTE, "Pair-Up: BluetoothSetServiceState() returned %08x", hr);
}
}
else if ((!wcscmp(btdi.szName, L"Nintendo RVL-WBC-01") || !wcscmp(btdi.szName, L"Nintendo RVL-CNT-01")) && unpair)
{
BluetoothRemoveDevice(&btdi.Address);
NOTICE_LOG(WIIMOTE, "Pair-Up: Automatically removed BT Device on shutdown: %08x", GetLastError());
nPaired++;
BluetoothRemoveDevice(&btdi.Address);
NOTICE_LOG(WIIMOTE, "Pair-Up: Automatically removed BT Device on shutdown: %08x", GetLastError());
nPaired++;
}
} while (BluetoothFindNextDevice(hFind, &btdi));
@@ -750,13 +750,13 @@ int WiimotePairUp(bool unpair)
#ifdef HAVE_WIIUSE
LRESULT CALLBACK CallBackDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
switch(uMsg)
{
case WM_DEVICECHANGE:
// DBT_DEVNODES_CHANGED 0x007 (devnodes are atm not received); DBT_DEVICEARRIVAL 0x8000 DBT_DEVICEREMOVECOMPLETE 0x8004 // avoiding header file^^
if ( ( wParam == 0x8000 || wParam == 0x8004 || wParam == 0x0007 ) )
if ( ( wParam == 0x8000 || wParam == 0x8004 || wParam == 0x0007 ) )
{
if (wiiuse_check_system_notification(uMsg, wParam, lParam)) //extern wiiuse function: returns 1 if the event came from a wiimote
{
@@ -767,7 +767,7 @@ LRESULT CALLBACK CallBackDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{
stoprefresh = 0;
PaiUpRefreshWiimote();
PaiUpRefreshWiimote();
break;
}
else stoprefresh = 1; //fake arrival wait for second go
@@ -786,7 +786,7 @@ LRESULT CALLBACK CallBackDeviceChange(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}
return 0;
}
@@ -797,14 +797,14 @@ THREAD_RETURN RunInvisibleMessageWindow_ThreadFunc(void* arg)
HWND hwnd;
WNDCLASSEX WCEx;
ZeroMemory(&WCEx, sizeof(WCEx));
WCEx.cbSize = sizeof(WCEx);
WCEx.lpfnWndProc = CallBackDeviceChange;
WCEx.hInstance = g_hInstance;
WCEx.lpszClassName = L"MSGWND";
ZeroMemory(&WCEx, sizeof(WCEx));
WCEx.cbSize = sizeof(WCEx);
WCEx.lpfnWndProc = CallBackDeviceChange;
WCEx.hInstance = g_hInstance;
WCEx.lpszClassName = L"MSGWND";
if (RegisterClassEx(&WCEx) != 0)
{
{
hwnd = CreateWindowEx(0, WCEx.lpszClassName, NULL,0,
0, 0, 0, 0, HWND_MESSAGE, NULL, g_hInstance, NULL);
@@ -815,19 +815,19 @@ THREAD_RETURN RunInvisibleMessageWindow_ThreadFunc(void* arg)
}
wiiuse_register_system_notification(hwnd); //function moved into wiiuse to avoid ddk/wdk dependicies
while(GetMessage(&Msg, 0, 0, 0) > 0)
{
while(GetMessage(&Msg, 0, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
DispatchMessage(&Msg);
}
UnregisterClass(WCEx.lpszClassName, g_hInstance);
if (g_Config.bUnpairRealWiimote)
WiiMoteReal::WiimotePairUp(true);
return (int)Msg.wParam;
return (int)Msg.wParam;
}