[PATCH 5/5] ddraw: Destroy the ddraw surface after the wined3d texture is destroyed.

Stefan Dösinger stefandoesinger at gmx.at
Thu Apr 21 14:47:57 CDT 2011


Hi,
I guess the obvious next step is to let wined3d manage the surface creation by 
getting rid of the CreateAdditionalSurface mess and let 
IWineD3DDeviceParent::CreateSurface handle this.

I guess we should also get rid of the complex_array attachment list and handle 
those attachment by querying the wined3d container for the backbuffer or mipmap 
sublevel list. And while AddAttachedSurface mostly serves the function of 
SetDepthStencilSurface I'm afraid we won't be able to get rid of the manual 
attachment list - but we should probably replace it with a wine list(*)

Anyway, thanks for cleaning up this mess. I feel guilty because I should have 
done this long ago :-/

Cheers,
Stefan

(*) I think I did that at some point, maybe is was another case of written but 
never finished patches. Or maybe I did this with some other surface list...

On Wednesday 20 April 2011 22:09:27 Henri Verbeet wrote:
> ---
>  dlls/ddraw/surface.c |   34 ++++++++++++++++++++++++++--------
>  1 files changed, 26 insertions(+), 8 deletions(-)
> 
> diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
> index 16b831a..84082c5 100644
> --- a/dlls/ddraw/surface.c
> +++ b/dlls/ddraw/surface.c
> @@ -180,10 +180,13 @@ static ULONG WINAPI
> ddraw_surface7_AddRef(IDirectDrawSurface7 *iface)
> 
>      TRACE("%p increasing refcount to %u.\n", This, refCount);
> 
> -    if (refCount == 1 && This->WineD3DSurface)
> +    if (refCount == 1)
>      {
>          EnterCriticalSection(&ddraw_cs);
> -        IWineD3DSurface_AddRef(This->WineD3DSurface);
> +        if (This->WineD3DSurface)
> +            IWineD3DSurface_AddRef(This->WineD3DSurface);
> +        if (This->wined3d_texture)
> +            wined3d_texture_incref(This->wined3d_texture);
>          LeaveCriticalSection(&ddraw_cs);
>      }
> 
> @@ -256,9 +259,7 @@ static void
> ddraw_surface_cleanup(IDirectDrawSurfaceImpl *surface)
> 
>      TRACE("surface %p.\n", surface);
> 
> -    if (surface->wined3d_texture) /* If it's a texture, destroy the
> wined3d texture. */ -       
> wined3d_texture_decref(surface->wined3d_texture);
> -    else if (surface->wined3d_swapchain)
> +    if (surface->wined3d_swapchain)
>      {
>          IDirectDrawImpl *ddraw = surface->ddraw;
> 
> @@ -388,7 +389,10 @@ static ULONG WINAPI
> ddraw_surface7_Release(IDirectDrawSurface7 *iface)
> LeaveCriticalSection(&ddraw_cs);
>              return ref;
>          }
> -        ddraw_surface_cleanup(This);
> +        if (This->wined3d_texture) /* If it's a texture, destroy the
> wined3d texture. */ +           
> wined3d_texture_decref(This->wined3d_texture);
> +        else
> +            ddraw_surface_cleanup(This);
>          LeaveCriticalSection(&ddraw_cs);
>      }
> 
> @@ -3491,6 +3495,20 @@ const struct wined3d_parent_ops
> ddraw_surface_wined3d_parent_ops = ddraw_surface_wined3d_object_destroyed,
>  };
> 
> +static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void
> *parent) +{
> +    IDirectDrawSurfaceImpl *surface = parent;
> +
> +    TRACE("surface %p.\n", surface);
> +
> +    ddraw_surface_cleanup(surface);
> +}
> +
> +static const struct wined3d_parent_ops ddraw_texture_wined3d_parent_ops =
> +{
> +    ddraw_texture_wined3d_object_destroyed,
> +};
> +
>  HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface)
>  {
>      const DDSURFACEDESC2 *desc = &surface->surface_desc;
> @@ -3513,10 +3531,10 @@ HRESULT
> ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface) format =
> PixelFormat_DD2WineD3D(&surface->surface_desc.u4.ddpfPixelFormat); if
> (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
>          return
> IWineD3DDevice_CreateCubeTexture(surface->ddraw->wineD3DDevice,
> desc->dwWidth, -                levels, 0, format, pool, surface,
> &ddraw_null_wined3d_parent_ops, &surface->wined3d_texture); +             
>   levels, 0, format, pool, surface, &ddraw_texture_wined3d_parent_ops,
> &surface->wined3d_texture); else
>          return IWineD3DDevice_CreateTexture(surface->ddraw->wineD3DDevice,
> desc->dwWidth, desc->dwHeight, -                levels, 0, format, pool,
> surface, &ddraw_null_wined3d_parent_ops, &surface->wined3d_texture); +    
>            levels, 0, format, pool, surface,
> &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture); }
> 
>  HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface,
> IDirectDrawImpl *ddraw,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20110421/df1eaeae/attachment.pgp>


More information about the wine-devel mailing list