Added NVIDIA 3D Vision support. Patch by Uhyve.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6347 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
skidau 2010-11-05 11:24:46 +00:00
parent eb167e3ca8
commit 5436bef30b
9 changed files with 150 additions and 15 deletions

View File

@ -710,6 +710,14 @@
RelativePath=".\Src\Render.cpp"
>
</File>
<File
RelativePath=".\Src\Render3dVision.cpp"
>
</File>
<File
RelativePath=".\Src\Render3dVision.h"
>
</File>
<File
RelativePath=".\Src\TextureCache.cpp"
>

View File

@ -20,6 +20,7 @@
#include "Render.h"
#include "XFStructs.h"
#include "StringUtil.h"
#include "Render3dVision.h"
// D3DX
HINSTANCE hD3DXDll = NULL;
@ -139,7 +140,7 @@ void InitPP(int adapter, int f, int aa_mode, D3DPRESENT_PARAMETERS *pp)
yres = pp->BackBufferHeight = client.bottom - client.top;
pp->SwapEffect = D3DSWAPEFFECT_DISCARD;
pp->PresentationInterval = g_Config.bVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
pp->Windowed = TRUE;
pp->Windowed = !Render3dVision::isEnable3dVision();
}
void Enumerate()

View File

@ -31,6 +31,7 @@
#include "VideoConfig.h"
#include "TextureCache.h"
#include "Render3dVision.h"
BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog)
@ -56,11 +57,11 @@ BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog)
EVT_CHECKBOX(ID_LOADHIRESTEXTURES, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_CHECKBOX(ID_EFBSCALEDCOPY, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_CHECKBOX(ID_PIXELLIGHTING, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_CHECKBOX(ID_ENABLE_3DVISION, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_ANAGLYPH, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_SLIDER(ID_ANAGLYPHSEPARATION, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_SLIDER(ID_ANAGLYPHFOCALANGLE, GFXConfigDialogDX::EnhancementsSettingsChanged)
//Advanced Tab
EVT_CHECKBOX(ID_DISABLEFOG, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_OVERLAYFPS, GFXConfigDialogDX::AdvancedSettingsChanged)
@ -153,6 +154,7 @@ void GFXConfigDialogDX::InitializeGUIValues()
m_EnableXFB->SetValue(g_Config.bUseXFB);
m_EnableRealXFB->SetValue(g_Config.bUseRealXFB);
m_UseNativeMips->SetValue(g_Config.bUseNativeMips);
m_Enable3dVision->SetValue(Render3dVision::isEnable3dVision());
m_DumpTextures->SetValue(g_Config.bDumpTextures);
m_DumpFrames->SetValue(g_Config.bDumpFrames);
@ -269,14 +271,15 @@ void GFXConfigDialogDX::CreateGUIControls()
wxStaticBoxSizer* sbTextureFilter;
sbTextureFilter = new wxStaticBoxSizer( new wxStaticBox( m_PageEnhancements, wxID_ANY, wxT("Texture filtering") ), wxVERTICAL );
m_ForceFiltering = new wxCheckBox( m_PageEnhancements, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering (breaks video in several Wii games)"), wxDefaultPosition, wxDefaultSize, 0 );
m_MaxAnisotropy = new wxCheckBox( m_PageEnhancements, ID_FORCEANISOTROPY, wxT("Enable 16x anisotropic filtering"), wxDefaultPosition, wxDefaultSize, 0 );
m_HiresTextures = new wxCheckBox( m_PageEnhancements, ID_LOADHIRESTEXTURES, wxT("Enable hires texture loading"), wxDefaultPosition, wxDefaultSize, 0 );
m_MaxAnisotropy = new wxCheckBox( m_PageEnhancements, ID_FORCEANISOTROPY, wxT("16x anisotropic filtering"), wxDefaultPosition, wxDefaultSize, 0 );
m_HiresTextures = new wxCheckBox( m_PageEnhancements, ID_LOADHIRESTEXTURES, wxT("Hires texture loading"), wxDefaultPosition, wxDefaultSize, 0 );
wxStaticBoxSizer* sbEFBHacks;
sbEFBHacks = new wxStaticBoxSizer( new wxStaticBox( m_PageEnhancements, wxID_ANY, wxT("EFB hacks") ), wxVERTICAL );
m_EFBScaledCopy = new wxCheckBox( m_PageEnhancements, ID_EFBSCALEDCOPY, wxT("EFB scaled copy"), wxDefaultPosition, wxDefaultSize, 0 );
m_Anaglyph = new wxCheckBox( m_PageEnhancements, ID_ANAGLYPH, wxT("Enable Anaglyph Stereo"), wxDefaultPosition, wxDefaultSize, 0 );
m_PixelLighting = new wxCheckBox( m_PageEnhancements, ID_PIXELLIGHTING, wxT("Enable Pixel Lighting"), wxDefaultPosition, wxDefaultSize, 0 );
m_Enable3dVision = new wxCheckBox( m_PageEnhancements, ID_ENABLE_3DVISION, wxT("NVIDIA 3D Vision support (Note: fullscreen must be enabled)"), wxDefaultPosition, wxDefaultSize, 0 );
m_PixelLighting = new wxCheckBox( m_PageEnhancements, ID_PIXELLIGHTING, wxT("Pixel Lighting"), wxDefaultPosition, wxDefaultSize, 0 );
m_Anaglyph = new wxCheckBox( m_PageEnhancements, ID_ANAGLYPH, wxT("Anaglyph Stereo"), wxDefaultPosition, wxDefaultSize, 0 );
m_AnaglyphSeparation = new wxSlider( m_PageEnhancements, ID_ANAGLYPHSEPARATION,2000,1,10000, wxDefaultPosition, wxDefaultSize, wxHORIZONTAL,wxDefaultValidator, wxT("Stereo separation") );
m_AnaglyphFocalAngle = new wxSlider( m_PageEnhancements, ID_ANAGLYPHFOCALANGLE,0,-1000,1000, wxDefaultPosition, wxDefaultSize, wxHORIZONTAL,wxDefaultValidator, wxT("Stereo Focal Angle") );
m_AnaglyphSeparationText = new wxStaticText( m_PageEnhancements, wxID_ANY, wxT("Stereo Separation:"), wxDefaultPosition, wxDefaultSize, 0 );
@ -309,12 +312,13 @@ void GFXConfigDialogDX::CreateGUIControls()
sImprovements = new wxGridBagSizer( 0, 0 );
sImprovements->SetFlexibleDirection( wxBOTH );
sImprovements->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
sImprovements->Add( m_Anaglyph, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphSeparationText, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphFocalAngleText, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphSeparation, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphFocalAngle, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_PixelLighting, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_Enable3dVision, wxGBPosition( 0, 0 ), wxGBSpan( 1, 2 ), wxALL, 5 );
sImprovements->Add( m_Anaglyph, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphSeparationText, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphFocalAngleText, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphSeparation, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_AnaglyphFocalAngle, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sImprovements->Add( m_PixelLighting, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sbImprovements->Add( sImprovements, 1, wxEXPAND, 5 );
sEnhancements->Add( sbImprovements, 0, wxEXPAND|wxALL, 5 );
@ -549,6 +553,9 @@ void GFXConfigDialogDX::AdvancedSettingsChanged(wxCommandEvent& event)
case ID_TEXFMT_CENTER:
g_Config.bTexFmtOverlayCenter = m_TexfmtCenter->IsChecked();
break;
case ID_ENABLE_3DVISION:
Render3dVision::setEnable3dVision(m_Enable3dVision->IsChecked());
break;
}
UpdateGUI();
}
@ -557,6 +564,7 @@ void GFXConfigDialogDX::CloseWindow()
{
// Save the config to INI
g_Config.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
Render3dVision::saveConfig((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
EndModal(1);
}

View File

@ -130,6 +130,7 @@ class GFXConfigDialogDX : public wxDialog
wxCheckBox *m_ShaderErrors;
wxCheckBox *m_TexfmtOverlay;
wxCheckBox *m_TexfmtCenter;
wxCheckBox *m_Enable3dVision;
enum
{
@ -183,6 +184,7 @@ class GFXConfigDialogDX : public wxDialog
ID_ANAGLYPH,
ID_ANAGLYPHSEPARATION,
ID_ANAGLYPHFOCALANGLE,
ID_ENABLE_3DVISION,
};
void InitializeAdapters();
void OnClose(wxCloseEvent& event);

View File

@ -22,6 +22,7 @@
#include "EmuWindow.h"
#include "D3DBase.h"
#include "Fifo.h"
#include "Render3dVision.h"
int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
@ -197,7 +198,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
m_hParent = parent;
m_hWnd = CreateWindow(m_szClassName, title, WS_CHILD,
m_hWnd = CreateWindow(m_szClassName, title, Render3dVision::isEnable3dVision() ? WS_EX_TOPMOST | WS_POPUP : WS_CHILD,
0, 0, width, height, m_hParent, NULL, hInstance, NULL);
return m_hWnd;

View File

@ -52,6 +52,8 @@
#include "debugger/debugger.h"
#include "Render3dVision.h"
static int s_fps = 0;
static bool WindowResized;
@ -1318,10 +1320,19 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
yScale = 1.0f;
}
else
{
if(Render3dVision::isEnable3dVision())
{
// This works, yet the version in the else doesn't. No idea why.
xScale = (float)s_backbuffer_width / (float)s_XFB_width;
yScale = (float)s_backbuffer_height / (float)s_XFB_height;
}
else
{
xScale = (float)(dst_rect.right - dst_rect.left) / (float)s_XFB_width;
yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height;
}
}
float SupersampleCoeficient = s_LastAA + 1;
s_LastEFBScale = g_ActiveConfig.iEFBScale;

View File

@ -0,0 +1,49 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Render3dVision.h"
#include "IniFile.h"
bool Render3dVision::enable3dVision = false;
bool Render3dVision::isEnable3dVision()
{
return enable3dVision;
}
void Render3dVision::setEnable3dVision(bool value)
{
enable3dVision = value;
}
void Render3dVision::loadConfig(const char* filename)
{
IniFile iniFile;
iniFile.Load(filename);
iniFile.Get("Settings", "Enable3dVision", &enable3dVision, false);
}
void Render3dVision::saveConfig(const char* filename)
{
IniFile iniFile;
iniFile.Load(filename);
iniFile.Set("Settings", "Enable3dVision", enable3dVision);
iniFile.Save(filename);
}

View File

@ -0,0 +1,51 @@
// Copyright (C) 2003 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _RENDER3DVISION_H
#define _RENDER3DVISION_H
#include "CommonTypes.h"
#include "VideoCommon.h"
//3d vision pipline functions and variables.
//This class provides services needed to run 3d vision.
//It could be replaced by putting the config settings in the
//VideoSettings class, but this way the dx9 plugin can stay portable
//with no reliance on Core being updated. This can be modified if
//these changes are added to the trunk.
class Render3dVision
{
private:
static bool enable3dVision;
public:
//Check to see if 3d vision compatable rendering should be used.
static bool isEnable3dVision();
//Set 3d vision enabled or disabled, used by the config dialog.
static void setEnable3dVision(bool value);
//Lod the specified config file and get enable3dVision out of it.
static void loadConfig(const char* filename);
//Save the enable3dVision variable to the specified config file.
static void saveConfig(const char* filename);
static void Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,const EFBRectangle& rc);
};
#endif

View File

@ -53,6 +53,7 @@ GFXConfigDialogDX *m_ConfigFrame = NULL;
#include "XFBConvert.h"
#include "render.h"
#include "DLCache.h"
#include "Render3dVision.h"
HINSTANCE g_hInstance = NULL;
SVideoInitialize g_VideoInitialize;
@ -180,6 +181,7 @@ void DllConfig(void *_hParent)
g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
g_Config.GameIniLoad(globals->game_ini);
UpdateActiveConfig();
Render3dVision::loadConfig((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
#if defined(HAVE_WX) && HAVE_WX
m_ConfigFrame = new GFXConfigDialogDX((wxWindow *)_hParent);
@ -204,6 +206,8 @@ void Initialize(void *init)
UpdateProjectionHack(g_Config.iPhackvalue); // DX9 projection hack could be disabled by commenting out this line
UpdateActiveConfig();
Render3dVision::loadConfig((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str());
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Loading - Please wait."));
if (g_VideoInitialize.pWindowHandle == NULL)
{