changeset 6416:085d0c62f4c8

RT-11175: PrismSettings.isVsyncEnabled is not taken into consideration during prism-d3d initialization Reviewed-by: ckyang
author vadim
date Tue, 04 Mar 2014 14:55:10 +0400
parents ca9b98508292
children 20943f5b3791
files modules/graphics/src/main/native-prism-d3d/D3DContext.cc modules/graphics/src/main/native-prism-d3d/D3DContext.h modules/graphics/src/main/native-prism-d3d/D3DContextInit.cc modules/graphics/src/main/native-prism-d3d/D3DPipelineManager.cc modules/graphics/src/main/native-prism-d3d/D3DPipelineManager.h
diffstat 5 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-prism-d3d/D3DContext.cc	Tue Mar 04 10:12:19 2014 +0100
+++ b/modules/graphics/src/main/native-prism-d3d/D3DContext.cc	Tue Mar 04 14:55:10 2014 +0400
@@ -69,11 +69,11 @@
 
 // static
 HRESULT
-D3DContext::CreateInstance(IDirect3D9 *pd3d9, IDirect3D9Ex *pd3d9Ex, UINT adapter, D3DContext **ppCtx)
+D3DContext::CreateInstance(IDirect3D9 *pd3d9, IDirect3D9Ex *pd3d9Ex, UINT adapter, bool isVsyncEnabled, D3DContext **ppCtx)
 {
     HRESULT res;
     *ppCtx = new D3DContext(pd3d9, pd3d9Ex, adapter);
-    if (FAILED(res = (*ppCtx)->InitContext())) {
+    if (FAILED(res = (*ppCtx)->InitContext(isVsyncEnabled))) {
         delete *ppCtx;
         *ppCtx = NULL;
     }
--- a/modules/graphics/src/main/native-prism-d3d/D3DContext.h	Tue Mar 04 10:12:19 2014 +0100
+++ b/modules/graphics/src/main/native-prism-d3d/D3DContext.h	Tue Mar 04 14:55:10 2014 +0400
@@ -105,14 +105,14 @@
      * to initialize and test the device last time, it doesn't attempt
      * to create/init/test the device.
      */
-    static HRESULT CreateInstance(IDirect3D9 *pd3d9, IDirect3D9Ex *pd3d9Ex, UINT adapter, D3DContext **ppCtx);
+    static HRESULT CreateInstance(IDirect3D9 *pd3d9, IDirect3D9Ex *pd3d9Ex, UINT adapter, bool isVsyncEnabled, D3DContext **ppCtx);
 
     // desrtoys this instance
     /* virtual */ int release();
 
-    // creates a new D3D windowed device with swap copy effect and default
+    // creates a new D3D windowed device with swap copy effect and specified
     // present interval
-    HRESULT InitContext();
+    HRESULT InitContext(bool isVsyncEnabled);
 
     // resets existing D3D device with the current presentation parameters
     HRESULT ResetContext();
--- a/modules/graphics/src/main/native-prism-d3d/D3DContextInit.cc	Tue Mar 04 10:12:19 2014 +0100
+++ b/modules/graphics/src/main/native-prism-d3d/D3DContextInit.cc	Tue Mar 04 14:55:10 2014 +0400
@@ -28,7 +28,7 @@
 #include "D3DContext.h"
 #include "D3DPipelineManager.h"
 
-HRESULT D3DContext::InitContext() {
+HRESULT D3DContext::InitContext(bool isVsyncEnabled) {
 
     D3DDEVTYPE devType = D3DPipelineManager::GetInstance()->GetDeviceType();
 
@@ -39,6 +39,9 @@
     params.Windowed = TRUE;
     params.SwapEffect = D3DSWAPEFFECT_DISCARD;
     params.hDeviceWindow = GetDesktopWindow();
+    params.PresentationInterval = isVsyncEnabled ?
+        D3DPRESENT_INTERVAL_ONE :
+        D3DPRESENT_INTERVAL_IMMEDIATE;
 
     D3DCAPS9 d3dCaps;
 
--- a/modules/graphics/src/main/native-prism-d3d/D3DPipelineManager.cc	Tue Mar 04 10:12:19 2014 +0100
+++ b/modules/graphics/src/main/native-prism-d3d/D3DPipelineManager.cc	Tue Mar 04 14:55:10 2014 +0400
@@ -72,6 +72,7 @@
     pd3d9Ex = NULL;
     pAdapters = NULL;
     adapterCount = 0;
+    isVsyncEnabled = cfg.getBool("isVsyncEnabled");
 
     devType = SelectDeviceType();
 
@@ -609,7 +610,7 @@
                         "  initializing context for adapter %d",adapterOrdinal);
 
             if (SUCCEEDED(res = D3DEnabledOnAdapter(adapterOrdinal))) {
-                res = D3DContext::CreateInstance(pd3d9, pd3d9Ex, adapterOrdinal, &pCtx);
+                res = D3DContext::CreateInstance(pd3d9, pd3d9Ex, adapterOrdinal, isVsyncEnabled, &pCtx);
                 if (FAILED(res)) {
                     RlsTraceLn1(NWT_TRACE_ERROR,
                         "D3DPPLM::GetD3DContext: failed to create context "\
--- a/modules/graphics/src/main/native-prism-d3d/D3DPipelineManager.h	Tue Mar 04 10:12:19 2014 +0100
+++ b/modules/graphics/src/main/native-prism-d3d/D3DPipelineManager.h	Tue Mar 04 14:55:10 2014 +0400
@@ -141,6 +141,9 @@
     D3DDEVTYPE devType;
 
     D3DAdapter *pAdapters;
+
+    bool isVsyncEnabled;
+
     // instance of this object
     static D3DPipelineManager* pMgr;