changeset 5728:e7bb12b9597a

RT-32226: 3D: Window can't restore after screen lock Reviewed-by: kcr, ckyang
author vadim
date Mon, 18 Nov 2013 15:05:02 +0400
parents 858ac97de356
children 8eb44bb11764
files modules/graphics/src/main/native-prism-d3d/D3DContext.cc modules/graphics/src/main/native-prism-d3d/D3DMesh.cc modules/graphics/src/main/native-prism-d3d/D3DResourceManager.cc
diffstat 3 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-prism-d3d/D3DContext.cc	Mon Nov 18 15:03:55 2013 +0400
+++ b/modules/graphics/src/main/native-prism-d3d/D3DContext.cc	Mon Nov 18 15:05:02 2013 +0400
@@ -761,6 +761,7 @@
         IDirect3DSurface9 *pCurrentDepth = NULL;
         pd3dDevice->GetDepthStencilSurface(&pCurrentDepth);
         clearDepth = pCurrentDepth == NULL ? FALSE : clearDepth;
+        SAFE_RELEASE(pCurrentDepth);
     }
     if (clearDepth) {
         flags |= D3DCLEAR_ZBUFFER;
@@ -919,7 +920,6 @@
         }
         if (pCurrentDepth != (*ppTargetDepthSurface)) {
             res = pd3dDevice->SetDepthStencilSurface(*ppTargetDepthSurface);
-            SAFE_RELEASE(pCurrentDepth);
             if ((*ppTargetDepthSurface) != NULL && depthIsNew) {
                 // Depth buffer must be cleared after it is created, also
                 // if depth buffer was not attached when render target was
@@ -932,8 +932,10 @@
                 }
             }
         } else if (!renderTargetChanged) {
+            SAFE_RELEASE(pCurrentDepth);
             return res; // Render target has not changed
         }
+        SAFE_RELEASE(pCurrentDepth);
         pd3dDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, msaa);
     }
     // NOTE PRISM: changed to only recalculate the matrix if current target is
--- a/modules/graphics/src/main/native-prism-d3d/D3DMesh.cc	Mon Nov 18 15:03:55 2013 +0400
+++ b/modules/graphics/src/main/native-prism-d3d/D3DMesh.cc	Mon Nov 18 15:05:02 2013 +0400
@@ -105,6 +105,7 @@
 //            << ", indexBufferSize = " << ibSize << endl;
 
     IDirect3DDevice9 *device = context->Get3DDevice();
+    D3DPOOL pool = context->getResourcePool();
     UINT size = vbSize * sizeof (float); // in bytes
     UINT vbCount = size / PRIMITIVE_VERTEX_SIZE; // in vertices
     HRESULT result = D3D_OK;
@@ -112,7 +113,7 @@
     if (numVertices != vbCount) {
         releaseVertexBuffer();
         result = device->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, fvf,
-                D3DPOOL_DEFAULT, &vertexBuffer, NULL);
+                pool, &vertexBuffer, NULL);
         numVertices = vbCount;
     }
 
@@ -130,7 +131,7 @@
     if (SUCCEEDED(result) && (numIndices != ibSize)) {
         releaseIndexBuffer();
         result = device->CreateIndexBuffer(size, D3DUSAGE_WRITEONLY,
-                D3DFMT_INDEX16, D3DPOOL_DEFAULT, &indexBuffer, NULL);
+                D3DFMT_INDEX16, pool, &indexBuffer, NULL);
         numIndices = ibSize;
     }
 
@@ -152,6 +153,7 @@
 //            << ", indexBufferSize = " << ibSize << endl;
 
     IDirect3DDevice9 *device = context->Get3DDevice();
+    D3DPOOL pool = context->getResourcePool();
     UINT size = vbSize * sizeof (float); // in bytes
     UINT vbCount = size / PRIMITIVE_VERTEX_SIZE; // in vertices
     HRESULT result = D3D_OK;
@@ -159,7 +161,7 @@
     if (numVertices != vbCount) {
         releaseVertexBuffer();
         result = device->CreateVertexBuffer(size, D3DUSAGE_WRITEONLY, fvf,
-                D3DPOOL_DEFAULT, &vertexBuffer, NULL);
+                pool, &vertexBuffer, NULL);
         numVertices = vbCount;
     }
 
@@ -177,7 +179,7 @@
     if (SUCCEEDED(result) && (numIndices != ibSize)) {
         releaseIndexBuffer();
         result = device->CreateIndexBuffer(size, D3DUSAGE_WRITEONLY,
-                D3DFMT_INDEX32, D3DPOOL_DEFAULT, &indexBuffer, NULL);
+                D3DFMT_INDEX32, pool, &indexBuffer, NULL);
         numIndices = ibSize;
     }
 
--- a/modules/graphics/src/main/native-prism-d3d/D3DResourceManager.cc	Mon Nov 18 15:03:55 2013 +0400
+++ b/modules/graphics/src/main/native-prism-d3d/D3DResourceManager.cc	Mon Nov 18 15:05:02 2013 +0400
@@ -106,6 +106,7 @@
     SAFE_PRINTLN(pSurface);
     SAFE_PRINTLN(pTexture);
     SAFE_PRINTLN(pSwapChain);
+    SAFE_PRINTLN(pDepthSurface);
 
     // note that it is normal for the SAFE_RELEASE here to complain about
     // remaining references (with debug build and tracing enabled) as long as
@@ -117,6 +118,7 @@
     SAFE_RELEASE(pTexture);
     SAFE_RELEASE(pResource);
     SAFE_RELEASE(pSwapChain);
+    SAFE_RELEASE(pDepthSurface);
 }
 
 D3DPixelShaderResource::D3DPixelShaderResource(IDirect3DPixelShader9 *pShader)