mirror of https://github.com/PCSX2/pcsx2.git
GSdx:
Avih renovated the configuration dialog a bit. It makes lots more sense now, thanks :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4173 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
ed0f6852c0
commit
74ee0835fd
|
@ -50,6 +50,31 @@ GSDevice9::~GSDevice9()
|
|||
if(m_state.ps_cb) _aligned_free(m_state.ps_cb);
|
||||
}
|
||||
|
||||
|
||||
//if supported and null!=msaa_desc, msaa_desc will contain requested Count and Quality
|
||||
static bool IsMsaaSupported(CComPtr<IDirect3D9>& d3d, D3DFORMAT depth_format, uint msaaCount, OUT DXGI_SAMPLE_DESC* msaa_desc=NULL){
|
||||
D3DCAPS9 d3dcaps;
|
||||
|
||||
if (msaaCount>16) return false;
|
||||
|
||||
memset(&d3dcaps, 0, sizeof(d3dcaps));
|
||||
d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dcaps);
|
||||
|
||||
DWORD quality[2] = {0, 0};
|
||||
|
||||
if(SUCCEEDED(d3d->CheckDeviceMultiSampleType(d3dcaps.AdapterOrdinal, d3dcaps.DeviceType, D3DFMT_A8R8G8B8, TRUE, (D3DMULTISAMPLE_TYPE)msaaCount, &quality[0])) && quality[0] >0
|
||||
&& SUCCEEDED(d3d->CheckDeviceMultiSampleType(d3dcaps.AdapterOrdinal, d3dcaps.DeviceType, depth_format, TRUE, (D3DMULTISAMPLE_TYPE)msaaCount, &quality[1])) && quality[1] >0
|
||||
){
|
||||
if (msaa_desc){
|
||||
msaa_desc->Count = msaaCount;
|
||||
msaa_desc->Quality = std::min<DWORD>(quality[0] - 1, quality[1] - 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool TestDepthFormat(CComPtr<IDirect3D9> &d3d, D3DFORMAT format)
|
||||
{
|
||||
if (FAILED(d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, format)))
|
||||
|
@ -59,6 +84,39 @@ static bool TestDepthFormat(CComPtr<IDirect3D9> &d3d, D3DFORMAT format)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
//In descending order of preference
|
||||
static D3DFORMAT s_DX9formatsToSearch[]={D3DFMT_D32, D3DFMT_D32F_LOCKABLE, D3DFMT_D24S8};
|
||||
|
||||
static D3DFORMAT BestD3dFormat(CComPtr<IDirect3D9>& d3d, int msaaCount=0, OUT DXGI_SAMPLE_DESC* msaa_desc=NULL){
|
||||
if(!d3d) return D3DFMT_UNKNOWN;
|
||||
if (1==msaaCount) msaaCount=0;
|
||||
|
||||
for (int i=0; i<sizeof(s_DX9formatsToSearch); i++)
|
||||
if (TestDepthFormat(d3d, s_DX9formatsToSearch[i]) && (!msaaCount || IsMsaaSupported(d3d, s_DX9formatsToSearch[i], msaaCount, msaa_desc)))
|
||||
return s_DX9formatsToSearch[i];
|
||||
|
||||
return D3DFMT_UNKNOWN;
|
||||
}
|
||||
|
||||
//return: 32, 24, or 0 if not supported. if 1==msaa, considered as msaa=0
|
||||
uint GSDevice9::GetMaxDepth(uint msaa=0){
|
||||
CComPtr<IDirect3D9> d3d;
|
||||
d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));
|
||||
|
||||
D3DFORMAT f=BestD3dFormat(d3d, msaa);
|
||||
switch (f){
|
||||
case D3DFMT_D32: case D3DFMT_D32F_LOCKABLE: return 32;
|
||||
case D3DFMT_D24S8: return 24;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GSDevice9::ForceValidMsaaConfig(){
|
||||
if (0==GetMaxDepth(theApp.GetConfig("msaa", 0)))
|
||||
theApp.SetConfig("msaa", 0);//replace invalid msaa value in ini file with 0.
|
||||
};
|
||||
|
||||
bool GSDevice9::Create(GSWnd* wnd)
|
||||
{
|
||||
if(!__super::Create(wnd))
|
||||
|
@ -90,15 +148,18 @@ bool GSDevice9::Create(GSWnd* wnd)
|
|||
m_d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));
|
||||
|
||||
if(!m_d3d) return false;
|
||||
|
||||
if (TestDepthFormat(m_d3d, D3DFMT_D32))
|
||||
m_depth_format = D3DFMT_D32;
|
||||
else if (TestDepthFormat(m_d3d, D3DFMT_D32F_LOCKABLE))
|
||||
m_depth_format = D3DFMT_D32F_LOCKABLE;
|
||||
else if (TestDepthFormat(m_d3d, D3DFMT_D24S8))
|
||||
m_depth_format = D3DFMT_D24S8;
|
||||
else
|
||||
return false;
|
||||
ForceValidMsaaConfig();
|
||||
//Get best format/depth for msaa. Assumption is that if the resulting depth is 24 instead of possible 32,
|
||||
// the user was already warned when she selected it. (Lower res z buffer without warning is unacceptable).
|
||||
m_depth_format=BestD3dFormat(m_d3d, m_msaa, &m_msaa_desc);
|
||||
if (D3DFMT_UNKNOWN == m_depth_format){
|
||||
//can't find a format with requested msaa, try without.
|
||||
m_depth_format = BestD3dFormat(m_d3d, 0);
|
||||
if (D3DFMT_UNKNOWN == m_depth_format)
|
||||
return false;
|
||||
|
||||
m_msaa=0;
|
||||
}
|
||||
|
||||
memset(&m_d3dcaps, 0, sizeof(m_d3dcaps));
|
||||
|
||||
|
@ -139,26 +200,6 @@ bool GSDevice9::Create(GSWnd* wnd)
|
|||
return false;
|
||||
}
|
||||
|
||||
// msaa
|
||||
|
||||
for(uint32 i = 2; i <= 16; i++)
|
||||
{
|
||||
DWORD quality[2] = {0, 0};
|
||||
|
||||
if(SUCCEEDED(m_d3d->CheckDeviceMultiSampleType(m_d3dcaps.AdapterOrdinal, m_d3dcaps.DeviceType, D3DFMT_A8R8G8B8, TRUE, (D3DMULTISAMPLE_TYPE)i, &quality[0])) && quality[0] > 0
|
||||
&& SUCCEEDED(m_d3d->CheckDeviceMultiSampleType(m_d3dcaps.AdapterOrdinal, m_d3dcaps.DeviceType, m_depth_format, TRUE, (D3DMULTISAMPLE_TYPE)i, &quality[1])) && quality[1] > 0)
|
||||
{
|
||||
m_msaa_desc.Count = i;
|
||||
m_msaa_desc.Quality = std::min<DWORD>(quality[0] - 1, quality[1] - 1);
|
||||
|
||||
if(i >= m_msaa) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_msaa_desc.Count == 1)
|
||||
m_msaa = 0;
|
||||
|
||||
//
|
||||
|
||||
if(!Reset(1, 1))
|
||||
{
|
||||
|
|
|
@ -213,4 +213,8 @@ public:
|
|||
|
||||
bool HasStencil() { return m_depth_format == D3DFMT_D24S8; }
|
||||
bool HasDepth32() { return m_depth_format != D3DFMT_D24S8; }
|
||||
|
||||
static uint GetMaxDepth(uint msaaCount);
|
||||
static void ForceValidMsaaConfig();
|
||||
|
||||
};
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "GSUtil.h"
|
||||
#include "resource.h"
|
||||
|
||||
#include "GSDevice9.h"
|
||||
|
||||
GSSetting GSSettingsDlg::g_renderers[] =
|
||||
{
|
||||
{0, "Direct3D9 (Hardware)", ""},
|
||||
|
@ -57,12 +59,12 @@ GSSetting GSSettingsDlg::g_aspectratio[] =
|
|||
|
||||
GSSetting GSSettingsDlg::g_upscale_multiplier[] =
|
||||
{
|
||||
{1, "1x", "Use D3D internal Res"},
|
||||
{2, "2x", ""},
|
||||
{3, "3x", ""},
|
||||
{4, "4x", ""},
|
||||
{5, "5x", ""},
|
||||
{6, "6x", ""},
|
||||
{1, "Custom", ""},
|
||||
{2, "2x Native", ""},
|
||||
{3, "3x Native", ""},
|
||||
{4, "4x Native", ""},
|
||||
{5, "5x Native", ""},
|
||||
{6, "6x Native", ""},
|
||||
};
|
||||
|
||||
GSSettingsDlg::GSSettingsDlg( bool isOpen2 )
|
||||
|
@ -149,6 +151,12 @@ void GSSettingsDlg::OnInit()
|
|||
SendMessage(GetDlgItem(m_hWnd, IDC_RESY), UDM_SETRANGE, 0, MAKELPARAM(8192, 256));
|
||||
SendMessage(GetDlgItem(m_hWnd, IDC_RESY), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("resy", 1024), 0));
|
||||
|
||||
int r=theApp.GetConfig("Renderer", 0);
|
||||
if (r>=0 && r<=2){//DX9
|
||||
GSDevice9::ForceValidMsaaConfig();
|
||||
m_lastValidMsaa=theApp.GetConfig("msaa", 0);
|
||||
}
|
||||
|
||||
SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_SETRANGE, 0, MAKELPARAM(16, 0));
|
||||
SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_SETPOS, 0, MAKELPARAM(theApp.GetConfig("msaa", 0), 0));
|
||||
|
||||
|
@ -160,6 +168,57 @@ void GSSettingsDlg::OnInit()
|
|||
|
||||
bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code)
|
||||
{
|
||||
if(id == IDC_MSAAEDIT && code == EN_CHANGE)//validate and possibly warn user when changing msaa
|
||||
{//post change
|
||||
bool dx9 = false;
|
||||
INT_PTR i;
|
||||
if(ComboBoxGetSelData(IDC_RENDERER, i))
|
||||
dx9 = i >= 0 && i <= 2;
|
||||
|
||||
if (dx9){
|
||||
|
||||
uint requestedMsaa= (int)SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_GETPOS, 0, 0);//valid from OnCommand?
|
||||
uint derivedDepth=GSDevice9::GetMaxDepth(requestedMsaa);
|
||||
|
||||
if (derivedDepth==0){
|
||||
//FIXME: Ugly UI: HW AA is currently a uint spinbox but usually only some values are supported (e.g. only 2/4/8 or a similar set).
|
||||
// Better solution would be to use a drop-down with only valid msaa values such that we don't need this. Maybe some day.
|
||||
// Known bad behavior: When manually deleting a HW AA value to put another instead (e.g. 2 -> delete -> 4)
|
||||
// it's registered as 0 after the deletion (with possible higher derived z bits), and might issue
|
||||
// a warning when the new value is registered (i.e. 4 in our example) since it might result in fewer
|
||||
// z bits than 0, even if it's not different than the previous value (i.e. 2 in our example) z bits.
|
||||
|
||||
//Find valid msaa values, regardless of derived z buffer bits
|
||||
string supportedAa="";
|
||||
for (int i=2; i<=16; i++)
|
||||
if (GSDevice9::GetMaxDepth(i)){
|
||||
if (supportedAa.length()) supportedAa+="/";
|
||||
supportedAa += format("%d", i);
|
||||
}
|
||||
|
||||
if (!supportedAa.length())
|
||||
supportedAa="None";
|
||||
|
||||
string s=format("AA=%d is not supported.\nSupported AA values: %s.", (int)requestedMsaa, supportedAa.c_str());
|
||||
MessageBox(hWnd, s.c_str(),"Warning", MB_OK|MB_ICONWARNING);
|
||||
SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_SETPOS, 0, requestedMsaa=m_lastValidMsaa);//revert value from inside OnCommand? is this OK?
|
||||
|
||||
} else if (derivedDepth < GSDevice9::GetMaxDepth(m_lastValidMsaa)){
|
||||
string s=format("AA=%d will force GSdx to degrade Z buffer\nfrom 32 to 24 bit, which will probably cause glitches\n(changing 'Logarithmic Z' might help some).\n\nContinue?", (int)requestedMsaa);
|
||||
//s+= format("\nlastMsaa=%d, lastDepth=%d, newMsaa=%d, newDepth=%d", (int)m_lastValidMsaa, (int)GSDevice9::GetMaxDepth(m_lastValidMsaa), (int)requestedMsaa, (int)GSDevice9::GetMaxDepth(requestedMsaa));
|
||||
if (IDOK!=MessageBox(hWnd, s.c_str(), "Warning", MB_OKCANCEL|MB_ICONWARNING))
|
||||
SendMessage(GetDlgItem(m_hWnd, IDC_MSAA), UDM_SETPOS, 0, requestedMsaa=m_lastValidMsaa);//revert value from inside OnCommand? is this OK?
|
||||
|
||||
}
|
||||
m_lastValidMsaa=requestedMsaa;
|
||||
|
||||
UpdateControls();
|
||||
}
|
||||
}
|
||||
else if(id == IDC_UPSCALE_MULTIPLIER && code == CBN_SELCHANGE)
|
||||
{
|
||||
UpdateControls();
|
||||
}
|
||||
if(id == IDC_RENDERER && code == CBN_SELCHANGE)
|
||||
{
|
||||
UpdateControls();
|
||||
|
@ -229,12 +288,18 @@ bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code)
|
|||
return __super::OnCommand(hWnd, id, code);
|
||||
}
|
||||
|
||||
|
||||
void GSSettingsDlg::UpdateControls()
|
||||
{
|
||||
INT_PTR i;
|
||||
|
||||
bool allowHacks = !!theApp.GetConfig("allowHacks", 0);
|
||||
|
||||
int scaling=1;//in case reading the combo doesn't work, enable the custom res control anyway
|
||||
if (ComboBoxGetSelData(IDC_UPSCALE_MULTIPLIER, i)){
|
||||
scaling=(int)i;
|
||||
}
|
||||
|
||||
if(ComboBoxGetSelData(IDC_RENDERER, i))
|
||||
{
|
||||
bool dx9 = i >= 0 && i <= 2;
|
||||
|
@ -251,15 +316,15 @@ void GSSettingsDlg::UpdateControls()
|
|||
// TODO: ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO_OGL), ogl ? SW_SHOW : SW_HIDE);
|
||||
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_WINDOWED), dx9);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESX), hw && !native);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESX_EDIT), hw && !native);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESY), hw && !native);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESY_EDIT), hw && !native);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESX), hw && !native && scaling==1);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESX_EDIT), hw && !native && scaling==1);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESY), hw && !native && scaling==1);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESY_EDIT), hw && !native && scaling==1);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_UPSCALE_MULTIPLIER), hw && !native);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_NATIVERES), hw);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_FILTER), hw && !native);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_PALTEX), hw);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_LOGZ), dx9 && hw);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_LOGZ), dx9 && hw && GSDevice9::GetMaxDepth(m_lastValidMsaa)<32);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_FBA), dx9 && hw);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_AA1), sw);
|
||||
EnableWindow(GetDlgItem(m_hWnd, IDC_SWTHREADS_EDIT), sw);
|
||||
|
|
|
@ -35,6 +35,8 @@ protected:
|
|||
void OnInit();
|
||||
bool OnCommand(HWND hWnd, UINT id, UINT code);
|
||||
|
||||
uint m_lastValidMsaa; //used to revert to previous dialog value if the user changed to invalid one, or lesser one and canceled
|
||||
|
||||
public:
|
||||
GSSettingsDlg( bool isOpen2 );
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
|
@ -171,18 +172,18 @@ BEGIN
|
|||
COMBOBOX IDC_RENDERER,70,55,111,118,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Interlacing (F5):",IDC_STATIC,6,73,81,8
|
||||
COMBOBOX IDC_INTERLACE,70,70,111,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "D3D internal res:",IDC_STATIC,27,105,55,8
|
||||
EDITTEXT IDC_RESX_EDIT,87,102,35,13,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_RESX,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,115,105,11,14
|
||||
EDITTEXT IDC_RESY_EDIT,125,102,35,13,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_RESY,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,149,105,11,14
|
||||
CONTROL "Native",IDC_NATIVERES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,122,135,33,10
|
||||
LTEXT "Custom resolution:",IDC_STATIC,26,135,65,8
|
||||
EDITTEXT IDC_RESX_EDIT,92,132,35,13,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_RESX,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,120,135,11,14
|
||||
EDITTEXT IDC_RESY_EDIT,130,132,35,13,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_RESY,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,154,130,11,14
|
||||
CONTROL "Native",IDC_NATIVERES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,92,105,33,10
|
||||
LTEXT "Rendering threads:",IDC_STATIC,19,214,63,8
|
||||
EDITTEXT IDC_SWTHREADS_EDIT,87,212,35,13,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_SWTHREADS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,115,215,11,14
|
||||
COMBOBOX IDC_UPSCALE_MULTIPLIER,87,117,74,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Or use Scaling:",IDC_STATIC,33,120,49,8
|
||||
LTEXT "Or use original PS2 resolution :",IDC_STATIC,17,135,99,8
|
||||
COMBOBOX IDC_UPSCALE_MULTIPLIER,92,117,74,98,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Or use Scaling:",IDC_STATIC,38,120,49,8
|
||||
LTEXT "Original PS2 resolution :",IDC_STATIC,10,105,80,8
|
||||
CONTROL "Edge anti-aliasing (AA1)",IDC_AA1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,230,93,10
|
||||
PUSHBUTTON "Cancel",IDCANCEL,95,312,50,14
|
||||
CONTROL 2021,IDC_LOGO9,"Static",SS_BITMAP,6,6,175,44
|
||||
|
@ -194,7 +195,7 @@ BEGIN
|
|||
LTEXT "Skipdraw Hack:",IDC_STATIC_TEXT_SKIPDRAW,11,289,50,8
|
||||
EDITTEXT IDC_MSAAEDIT,69,260,35,13,ES_AUTOHSCROLL | ES_NUMBER
|
||||
CONTROL "",IDC_MSAA,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,103,263,11,14
|
||||
GROUPBOX "D3D Upscaling (can cause glitches)",IDC_STATIC,6,87,175,64,BS_CENTER
|
||||
GROUPBOX "D3D Internal resolution (can cause glitches)",IDC_STATIC,6,87,175,64,BS_CENTER
|
||||
GROUPBOX "Software Mode Settings",IDC_STATIC,6,198,175,50,BS_CENTER
|
||||
GROUPBOX "Hardware Mode Settings",IDC_STATIC,6,152,175,45,BS_CENTER
|
||||
CONTROL "Logarithmic Z",IDC_LOGZ,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,88,166,58,10
|
||||
|
@ -307,7 +308,8 @@ END
|
|||
#include "res/tfx.fx"
|
||||
#include "res/convert.fx"
|
||||
#include "res/interlace.fx"
|
||||
#include "res/merge.fx"
|
||||
#include "res/merge.fx"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
|
|
Loading…
Reference in New Issue