[1/4] D3D9: Implement IDirect3DDevice9::StretchRect

Mirek thunder.m at czela.net
Wed Jan 17 10:33:39 CST 2007


Hi, this patch caused big performance regression in some D3D games 
(Flatout 2, Tomb Raider: Legend, HalfLife 2: Episode One).

Mirek Slugen

Stefan Dösinger napsal(a):
> This time with a FIXME for unsupported filtering options. If we implement 
> them, it should be done in Blt and private blitting flags used.
> 
> 
> ------------------------------------------------------------------------
> 
> From 95f4217d366770b9b05214ae68274ce4ab4b9fb6 Mon Sep 17 00:00:00 2001
> From: Stefan Doesinger <stefan at codeweavers.com>
> Date: Thu, 11 Jan 2007 22:39:03 +0100
> Subject: [PATCH] D3D9: Implement IDirect3DDevice9::StretchRect
> 
> ---
>  dlls/d3d9/device.c               |   10 +++++++---
>  dlls/d3d9/directx.c              |    3 +++
>  dlls/wined3d/device.c            |    9 ---------
>  include/wine/wined3d_interface.h |    2 --
>  4 files changed, 10 insertions(+), 14 deletions(-)
> 
> diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
> index aa788af..4c27853 100644
> --- a/dlls/d3d9/device.c
> +++ b/dlls/d3d9/device.c
> @@ -356,9 +356,13 @@ static HRESULT  WINAPI  IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE
>  }
>  
>  static HRESULT  WINAPI  IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter) {
> -    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;    
> -    TRACE("(%p) Relay\n" , This);
> -    return IWineD3DDevice_StretchRect(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface, pDestRect, (WINED3DTEXTUREFILTERTYPE) Filter);            
> +    IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
> +    IDirect3DSurface9Impl *src = (IDirect3DSurface9Impl *) pSourceSurface;
> +    IDirect3DSurface9Impl *dst = (IDirect3DSurface9Impl *) pDestSurface;
> +
> +    TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This, src, pSourceRect, dst, pDestRect, Filter);
> +    if(Filter != D3DTEXF_NONE) ERR("Texture filters not supported yet\n");
> +    return IWineD3DSurface_Blt(dst->wineD3DSurface, (RECT *) pDestRect, src->wineD3DSurface, (RECT *) pSourceRect, 0, NULL);
>  }
>  
>  static HRESULT  WINAPI  IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color) {
> diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
> index f360b4e..57062b2 100644
> --- a/dlls/d3d9/directx.c
> +++ b/dlls/d3d9/directx.c
> @@ -170,6 +170,9 @@ static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapt
>      D3D9CAPSTOWINECAPS(pCaps, pWineCaps)
>      hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
>      HeapFree(GetProcessHeap(), 0, pWineCaps);
> +
> +    /* Some functionality is implemented in d3d9.dll, not wined3d.dll. Add the needed caps */
> +    pCaps->Caps2 |= D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES;
>      TRACE("(%p) returning %p\n", This, pCaps);
>      return hrc;
>  }
> diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
> index 7b81f0e..5f964fb 100644
> --- a/dlls/wined3d/device.c
> +++ b/dlls/wined3d/device.c
> @@ -4930,14 +4930,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateTexture (IWineD3DDevice *iface, I
>      return hr;
>  }
>  
> -static HRESULT  WINAPI  IWineD3DDeviceImpl_StretchRect(IWineD3DDevice *iface, IWineD3DSurface *pSourceSurface,
> -                                                CONST RECT* pSourceRect, IWineD3DSurface *pDestinationSurface,
> -                                                CONST RECT* pDestRect, WINED3DTEXTUREFILTERTYPE Filter) {
> -    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
> -
> -    TRACE("(%p) : stub\n", This);
> -    return WINED3D_OK;
> -}
>  static HRESULT  WINAPI  IWineD3DDeviceImpl_GetRenderTargetData(IWineD3DDevice *iface, IWineD3DSurface *pRenderTarget, IWineD3DSurface *pSurface) {
>      IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
>      /** TODO: remove remove casts to IWineD3DSurfaceImpl *
> @@ -6776,7 +6768,6 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
>      IWineD3DDeviceImpl_ColorFill,
>      IWineD3DDeviceImpl_UpdateTexture,
>      IWineD3DDeviceImpl_UpdateSurface,
> -    IWineD3DDeviceImpl_StretchRect,
>      IWineD3DDeviceImpl_GetRenderTargetData,
>      IWineD3DDeviceImpl_GetFrontBufferData,
>      /*** object tracking ***/
> diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h
> index 8a685f0..4a24636 100644
> --- a/include/wine/wined3d_interface.h
> +++ b/include/wine/wined3d_interface.h
> @@ -469,7 +469,6 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
>      STDMETHOD(ColorFill)(THIS_ struct IWineD3DSurface* pSurface, CONST WINED3DRECT* pRect, WINED3DCOLOR color) PURE;
>      STDMETHOD(UpdateTexture)(THIS_ struct IWineD3DBaseTexture *pSourceTexture, struct IWineD3DBaseTexture *pDestinationTexture) PURE;
>      STDMETHOD(UpdateSurface)(THIS_ struct IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRect, struct IWineD3DSurface* pDestinationSurface, CONST POINT* pDestPoint) PURE;
> -    STDMETHOD(StretchRect)(THIS_ struct IWineD3DSurface* pSourceSurface, CONST RECT* pSourceRect, struct IWineD3DSurface* pDestinationSurface, CONST RECT* pDestRect, WINED3DTEXTUREFILTERTYPE Filter) PURE;
>      STDMETHOD(GetRenderTargetData)(THIS_ struct IWineD3DSurface* pRenderTarget, struct IWineD3DSurface* pSurface) PURE;
>      STDMETHOD(GetFrontBufferData)(THIS_ UINT iSwapChain,struct IWineD3DSurface* pSurface) PURE;
>      /*** object tracking ***/
> @@ -608,7 +607,6 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
>  #define IWineD3DDevice_ColorFill(p,a,b,c)                       (p)->lpVtbl->ColorFill(p,a,b,c)
>  #define IWineD3DDevice_UpdateTexture(p,a,b)                     (p)->lpVtbl->UpdateTexture(p,a,b)
>  #define IWineD3DDevice_UpdateSurface(p,a,b,c,d)                 (p)->lpVtbl->UpdateSurface(p,a,b,c,d)
> -#define IWineD3DDevice_StretchRect(p,a,b,c,d,e)                 (p)->lpVtbl->StretchRect(p,a,b,c,d,e)
>  #define IWineD3DDevice_GetRenderTargetData(p,a,b)               (p)->lpVtbl->GetRenderTargetData(p,a,b)
>  #define IWineD3DDevice_GetFrontBufferData(p,a,b)                (p)->lpVtbl->GetFrontBufferData(p,a,b)
>  #define IWineD3DDevice_ResourceReleased(p,a)                    (p)->lpVtbl->ResourceReleased(p,a)
> 
> 
> ------------------------------------------------------------------------
> 
> 



More information about the wine-devel mailing list