From ac94777f6d89e481dbaa087b7d009efb339ddb65 Mon Sep 17 00:00:00 2001 From: cutealien Date: Tue, 22 May 2012 13:10:25 +0000 Subject: [PATCH] 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 --- include/SIrrCreationParameters.h | 8 ++++++++ source/Irrlicht/CD3D8Driver.cpp | 9 +++++---- source/Irrlicht/CD3D9Driver.cpp | 7 ++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/SIrrCreationParameters.h b/include/SIrrCreationParameters.h index 5afe6def..64deb27a 100644 --- a/include/SIrrCreationParameters.h +++ b/include/SIrrCreationParameters.h @@ -43,6 +43,7 @@ namespace irr LoggingLevel(ELL_INFORMATION), #endif DisplayAdapter(0), + DriverMultithreaded(false), UsePerformanceTimer(true), SDK_version_do_not_use(IRRLICHT_SDK_VERSION) { @@ -72,6 +73,7 @@ namespace irr EventReceiver = other.EventReceiver; WindowId = other.WindowId; LoggingLevel = other.LoggingLevel; + DriverMultithreaded = other.DriverMultithreaded; DisplayAdapter = other.DisplayAdapter; UsePerformanceTimer = other.UsePerformanceTimer; return *this; @@ -268,6 +270,12 @@ namespace irr /** So far only supported on D3D */ 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. /** When performance timers are not used, standard GetTickCount() is used instead which usually has worse resolution, but also less diff --git a/source/Irrlicht/CD3D8Driver.cpp b/source/Irrlicht/CD3D8Driver.cpp index 01b02016..47125cb9 100644 --- a/source/Irrlicht/CD3D8Driver.cpp +++ b/source/Irrlicht/CD3D8Driver.cpp @@ -326,11 +326,12 @@ bool CD3D8Driver::initDriver(const core::dimension2d& screenSize, DWORD fpuPrecision = 0; #else DWORD fpuPrecision = highPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; + DWORD multithreaded = Params.DriverMultithreaded ? D3DCREATE_MULTITHREADED : 0; #endif if (pureSoftware) { hr = pID3D->CreateDevice(DisplayAdapter, D3DDEVTYPE_REF, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); + fpuPrecision | multithreaded | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); if (FAILED(hr)) os::Printer::log("Was not able to create Direct3D8 software device.", ELL_ERROR); @@ -338,14 +339,14 @@ bool CD3D8Driver::initDriver(const core::dimension2d& screenSize, else { hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd, - fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); + fpuPrecision | multithreaded | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); if(FAILED(hr)) hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd, - fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); + fpuPrecision | multithreaded | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); if(FAILED(hr)) hr = pID3D->CreateDevice(DisplayAdapter, devtype, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); + fpuPrecision | multithreaded | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); if (FAILED(hr)) os::Printer::log("Was not able to create Direct3D8 device.", ELL_ERROR); } diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index f7f29e81..74bee5e2 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -375,6 +375,7 @@ bool CD3D9Driver::initDriver(HWND hwnd, bool pureSoftware) // create device DWORD fpuPrecision = Params.HighPrecisionFPU ? D3DCREATE_FPU_PRESERVE : 0; + DWORD multithreaded = Params.DriverMultithreaded ? D3DCREATE_MULTITHREADED : 0; if (pureSoftware) { if (FAILED(pID3D->CreateDevice(Params.DisplayAdapter, D3DDEVTYPE_REF, hwnd, @@ -384,15 +385,15 @@ bool CD3D9Driver::initDriver(HWND hwnd, bool pureSoftware) else { HRESULT hr = pID3D->CreateDevice(adapter, devtype, hwnd, - fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); + fpuPrecision | multithreaded | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice); if(FAILED(hr)) hr = pID3D->CreateDevice(adapter, devtype, hwnd, - fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); + fpuPrecision | multithreaded | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice); if(FAILED(hr)) hr = pID3D->CreateDevice(adapter, devtype, hwnd, - fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); + fpuPrecision | multithreaded | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice); if (FAILED(hr)) os::Printer::log("Was not able to create Direct3D9 device.", ELL_ERROR);