Stefan Dösinger : wined3d: Free shader private data on reset.

Alexandre Julliard julliard at winehq.org
Tue Mar 25 14:19:56 CDT 2008


Module: wine
Branch: master
Commit: ac57b4e2f57b4130702de0264508551e2b1f528e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ac57b4e2f57b4130702de0264508551e2b1f528e

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Tue Mar 18 19:31:24 2008 +0100

wined3d: Free shader private data on reset.

Since the shader backend implementations might track opengl resources in
their private data inform them about reset calls. For example, the atifs
backend keeps track of the replacement shaders, which are lost during an
opengl context recreation.

---

 dlls/wined3d/device.c      |   11 +++++++++--
 dlls/wined3d/glsl_shader.c |    1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index dea417c..12f91af 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -7029,6 +7029,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE
         This->depth_blt_texture = 0;
     }
     This->shader_backend->shader_destroy_depth_blt(iface);
+    This->shader_backend->shader_free_private(iface);
 
     for (i = 0; i < GL_LIMITS(textures); i++) {
         /* Textures are recreated below */
@@ -7123,6 +7124,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE
                                           &swapchain->presentParms);
     swapchain->num_contexts = 1;
     This->activeContext = swapchain->context[0];
+    IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
 
     hr = IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *) This->stateBlock);
     if(FAILED(hr)) {
@@ -7130,11 +7132,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE
     }
     create_dummy_textures(This);
 
+
+    hr = This->shader_backend->shader_alloc_private(iface);
+    if(FAILED(hr)) {
+        ERR("Failed to recreate shader private data\n");
+        return hr;
+    }
+
     /* All done. There is no need to reload resources or shaders, this will happen automatically on the
      * first use
      */
-
-    IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
     return WINED3D_OK;
 }
 
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 4f7b527..908f5bd 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -3378,6 +3378,7 @@ static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) {
 static void shader_glsl_free(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     HeapFree(GetProcessHeap(), 0, This->shader_priv);
+    This->shader_priv = NULL;
 }
 
 static BOOL shader_glsl_dirty_const(IWineD3DDevice *iface) {




More information about the wine-cvs mailing list