ADDED option to disable multi-threaded pixel filtering

REDUCED maximum number of cores to use to 8

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@473 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2008-04-05 00:13:31 +00:00
parent c6f5298e6a
commit c3641f314d
8 changed files with 94 additions and 65 deletions

View File

@ -173,7 +173,7 @@ Direct3DDisplay::Direct3DDisplay()
pfthread_data = NULL;
hThreads = NULL;
nThreads = theApp.maxCpuCores;
if( nThreads > 16 ) nThreads = 16;
if( nThreads > 8 ) nThreads = 8;
}
@ -444,7 +444,9 @@ void Direct3DDisplay::render()
return;
} else {
u32 pitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
if( theApp.filterFunction ) {
if( theApp.filterMT ) {
u8 *start = pix + pitch;
int src_height_per_thread = theApp.sizeY / nThreads;
int src_height_remaining = theApp.sizeY - ( ( theApp.sizeY / nThreads ) * nThreads );
@ -499,10 +501,8 @@ void Direct3DDisplay::render()
for( i = 0 ; i < nThreads ; i++ ) {
CloseHandle( hThreads[i] );
}
/* without threads
// pixel filter enabled
} else {
// multi-threading disabled
theApp.filterFunction(
pix + pitch,
pitch,
@ -512,7 +512,7 @@ void Direct3DDisplay::render()
theApp.sizeX,
theApp.sizeY
);
*/
}
} else {
// pixel filter disabled
switch( systemColorDepth )

View File

@ -437,6 +437,8 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_WM_NCRBUTTONDOWN()
ON_COMMAND(ID_OUTPUTAPI_XAUDIO2, &MainWnd::OnOutputapiXaudio2)
ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_XAUDIO2, &MainWnd::OnUpdateOutputapiXaudio2)
ON_COMMAND(ID_PIXELFILTER_MULTI, &MainWnd::OnPixelfilterMultiThreading)
ON_UPDATE_COMMAND_UI(ID_PIXELFILTER_MULTI, &MainWnd::OnUpdatePixelfilterMultiThreading)
END_MESSAGE_MAP()

View File

@ -425,6 +425,8 @@ public:
afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnOutputapiXaudio2();
afx_msg void OnUpdateOutputapiXaudio2(CCmdUI *pCmdUI);
afx_msg void OnPixelfilterMultiThreading();
afx_msg void OnUpdatePixelfilterMultiThreading(CCmdUI *pCmdUI);
};
/////////////////////////////////////////////////////////////////////////////

View File

@ -1854,3 +1854,13 @@ void MainWnd::OnEmulatorBiosfiles()
theApp.biosFileNameGB = dlg.m_pathGB;
}
}
void MainWnd::OnPixelfilterMultiThreading()
{
theApp.filterMT = !theApp.filterMT;
}
void MainWnd::OnUpdatePixelfilterMultiThreading(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck( theApp.filterMT ? 1 : 0 );
}

View File

@ -215,6 +215,8 @@ VBA::VBA()
if( S_OK != CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ) ) {
systemMessage( IDS_COM_FAILURE, NULL );
}
// ! keep in mind that many of the following values will be really initialized in loadSettings()
mode320Available = false;
mode640Available = false;
mode800Available = false;
@ -229,6 +231,7 @@ VBA::VBA()
filterType = FILTER_NONE;
filterWidth = 0;
filterHeight = 0;
filterMT = false;
fsAdapter = 0;
fsWidth = 0;
fsHeight = 0;
@ -1543,6 +1546,8 @@ void VBA::loadSettings()
if(filterType < 0 || filterType > 17)
filterType = 0;
filterMT = ( 1 == regQueryDwordValue("filterEnableMultiThreading", 0) );
disableMMX = regQueryDwordValue("disableMMX", false) ? true: false;
disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false;
@ -1704,6 +1709,11 @@ void VBA::loadSettings()
oalBufferCount = regQueryDwordValue( "oalBufferCount", 5 );
#endif
if( ( maxCpuCores == 1 ) && filterMT ) {
// multi-threading use useless for just one core
filterMT = false;
}
}
void VBA::updateFrameSkip()
@ -2511,6 +2521,8 @@ void VBA::saveSettings()
regSetDwordValue("filter", filterType);
regSetDwordValue("filterEnableMultiThreading", filterMT ? 1 : 0);
regSetDwordValue("LCDFilter", filterLCD);
regSetDwordValue("disableMMX", disableMMX);

View File

@ -91,6 +91,7 @@ class VBA : public CWinApp
int filterHeight;
int filterMagnification;
int filterLCD;
bool filterMT; // enable multi-threading for pixel filters
int fsWidth;
int fsHeight;
int fsColorDepth;

View File

@ -1661,6 +1661,7 @@ BEGIN
MENUITEM "&Smart", ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART
END
MENUITEM SEPARATOR
MENUITEM "Multi-Threading (D3D)", ID_PIXELFILTER_MULTI
MENUITEM "Disable &MMX", ID_OPTIONS_FILTER_DISABLEMMX
END
POPUP "&Audio"

View File

@ -850,13 +850,14 @@
#define ID_FILE_OPENGBC 40357
#define ID_FILE_OPEN_GBC 40358
#define ID_OUTPUTAPI_XAUDIO2 40359
#define ID_PIXELFILTER_MULTI 40360
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 163
#define _APS_NEXT_COMMAND_VALUE 40360
#define _APS_NEXT_COMMAND_VALUE 40361
#define _APS_NEXT_CONTROL_VALUE 1284
#define _APS_NEXT_SYMED_VALUE 103
#endif