Commit ac94777f authored by cutealien's avatar cutealien

Allow setting D3DCREATE_MULTITHREADED when creating Direct3D drivers.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4167 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 3810ecb4
...@@ -43,6 +43,7 @@ namespace irr ...@@ -43,6 +43,7 @@ namespace irr
LoggingLevel(ELL_INFORMATION), LoggingLevel(ELL_INFORMATION),
#endif #endif
DisplayAdapter(0), DisplayAdapter(0),
DriverMultithreaded(false),
UsePerformanceTimer(true), UsePerformanceTimer(true),
SDK_version_do_not_use(IRRLICHT_SDK_VERSION) SDK_version_do_not_use(IRRLICHT_SDK_VERSION)
{ {
...@@ -72,6 +73,7 @@ namespace irr ...@@ -72,6 +73,7 @@ namespace irr
EventReceiver = other.EventReceiver; EventReceiver = other.EventReceiver;
WindowId = other.WindowId; WindowId = other.WindowId;
LoggingLevel = other.LoggingLevel; LoggingLevel = other.LoggingLevel;
DriverMultithreaded = other.DriverMultithreaded;
DisplayAdapter = other.DisplayAdapter; DisplayAdapter = other.DisplayAdapter;
UsePerformanceTimer = other.UsePerformanceTimer; UsePerformanceTimer = other.UsePerformanceTimer;
return *this; return *this;
...@@ -268,6 +270,12 @@ namespace irr ...@@ -268,6 +270,12 @@ namespace irr
/** So far only supported on D3D */ /** So far only supported on D3D */
u32 DisplayAdapter; u32 DisplayAdapter;
//! Create the driver multithreaded.
/** Default is false. Enabling this can slow down your application.
Note that this does _not_ make Irrlicht threadsafe, but only the underlying driver-API for the graphiccard.
So far only supported on D3D. */
bool DriverMultithreaded;
//! Enables use of high performance timers on Windows platform. //! Enables use of high performance timers on Windows platform.
/** When performance timers are not used, standard GetTickCount() /** When performance timers are not used, standard GetTickCount()
is used instead which usually has worse resolution, but also less is used instead which usually has worse resolution, but also less
......
...@@ -326,11 +326,12 @@ bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize, ...@@ -326,11 +326,12 @@ bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize,
DWORD fpuPrecision = 0; DWORD fpuPrecision = 0;
#else #else
DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0;
DWORD multithreaded = Params.DriverMultithreaded ? D3DCREATE_MULTITHREADED : 0;
#endif #endif
if (pureSoftware) if (pureSoftware)
{ {
hr = pID3D->CreateDevice(DisplayAdapter, D3DDEVTYPE_REF, hwnd, hr = pID3D->CreateDevice(DisplayAdapter, D3DDEVTYPE_REF, hwnd,
fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); fpuPrecision | multithreaded | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice);
if (FAILED(hr)) if (FAILED(hr))
os::Printer::log("Was not able to create Direct3D8 software device.", ELL_ERROR); os::Printer::log("Was not able to create Direct3D8 software device.", ELL_ERROR);
...@@ -338,14 +339,14 @@ bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize, ...@@ -338,14 +339,14 @@ bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize,
else else
{ {
hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd, hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd,
fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); fpuPrecision | multithreaded | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice);
if(FAILED(hr)) if(FAILED(hr))
hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd, hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd,
fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); fpuPrecision | multithreaded | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice);
if(FAILED(hr)) if(FAILED(hr))
hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd, hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd,
fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); fpuPrecision | multithreaded | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice);
if (FAILED(hr)) if (FAILED(hr))
os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR);
} }
......
...@@ -375,6 +375,7 @@ bool CD3D9Driver::initDriver(HWND hwnd, bool pureSoftware) ...@@ -375,6 +375,7 @@ bool CD3D9Driver::initDriver(HWND hwnd, bool pureSoftware)
// create device // create device
DWORD fpuPrecision = Params.HighPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; DWORD fpuPrecision = Params.HighPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0;
DWORD multithreaded = Params.DriverMultithreaded ? D3DCREATE_MULTITHREADED : 0;
if (pureSoftware) if (pureSoftware)
{ {
if (FAILED(pID3D->CreateDevice(Params.DisplayAdapter, D3DDEVTYPE_REF, hwnd, if (FAILED(pID3D->CreateDevice(Params.DisplayAdapter, D3DDEVTYPE_REF, hwnd,
...@@ -384,15 +385,15 @@ bool CD3D9Driver::initDriver(HWND hwnd, bool pureSoftware) ...@@ -384,15 +385,15 @@ bool CD3D9Driver::initDriver(HWND hwnd, bool pureSoftware)
else else
{ {
HRESULT hr = pID3D->CreateDevice(adapter, devtype, hwnd, HRESULT hr = pID3D->CreateDevice(adapter, devtype, hwnd,
fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); fpuPrecision | multithreaded | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice);
if(FAILED(hr)) if(FAILED(hr))
hr = pID3D->CreateDevice(adapter, devtype, hwnd, hr = pID3D->CreateDevice(adapter, devtype, hwnd,
fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); fpuPrecision | multithreaded | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice);
if(FAILED(hr)) if(FAILED(hr))
hr = pID3D->CreateDevice(adapter, devtype, hwnd, hr = pID3D->CreateDevice(adapter, devtype, hwnd,
fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); fpuPrecision | multithreaded | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice);
if (FAILED(hr)) if (FAILED(hr))
os::Printer::log("Was not able to create Direct3D9 device.", ELL_ERROR); os::Printer::log("Was not able to create Direct3D9 device.", ELL_ERROR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment