diff --git a/dlls/d3d9/cubetexture.c b/dlls/d3d9/cubetexture.c index 95ac05ed8f2..04cff3575ae 100644 --- a/dlls/d3d9/cubetexture.c +++ b/dlls/d3d9/cubetexture.c @@ -158,7 +158,7 @@ HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBETEXTURE IWineD3DSurface *mySurface = NULL; hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, FaceType, Level, &mySurface); - if (hrc == D3D_OK) { + if (hrc == D3D_OK && NULL != ppCubeMapSurface) { IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface); IWineD3DCubeTexture_Release(mySurface); } @@ -210,21 +210,35 @@ IDirect3DCubeTexture9Vtbl Direct3DCubeTexture9_Vtbl = /* IDirect3DDevice9 IDirect3DCubeTexture9 Methods follow: */ HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, - UINT EdgeLength, UINT Levels, DWORD Usage, - D3DFORMAT Format, D3DPOOL Pool, - IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) { + UINT EdgeLength, UINT Levels, DWORD Usage, + D3DFORMAT Format, D3DPOOL Pool, + IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle) { IDirect3DCubeTexture9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hr = D3D_OK; /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture9Impl)); + if (NULL == object) { + FIXME("(%p) allocation of CubeTexture failed\n", This); + *ppCubeTexture = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DCubeTexture9_Vtbl; object->ref = 1; - IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage, + hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage, Format, Pool, &(object->wineD3DCubeTexture), pSharedHandle, (IUnknown *)object, D3D9CB_CreateSurface); - *ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object; - return D3D_OK; + if (hr != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppCubeTexture = NULL; + } else { + *ppCubeTexture = (LPDIRECT3DCUBETEXTURE9) object; + } + return hr; } diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index e863bdc72d0..12943fddadf 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -71,7 +71,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVICE9 ifa UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : stub, emulating 32Mb for now\n", This); + FIXME("(%p) : stub, emulating 32Mb for now\n", This); /* * pretend we have 32MB of any type of memory queried. */ @@ -95,27 +95,24 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDire HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub, calling idirect3d for now\n", This); - IDirect3D9Impl_GetDeviceCaps((LPDIRECT3D9) This->direct3d, This->adapterNo, This->devType, pCaps); - return D3D_OK; + return IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pCaps); } HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + return IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, pMode); } HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) copying to %p\n", This, pParameters); + FIXME("(%p) copying to %p\n", This, pParameters); memcpy(pParameters, &This->CreateParms, sizeof(D3DDEVICE_CREATION_PARAMETERS)); return D3D_OK; } HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : Spot Pos(%u,%u)\n", This, XHotSpot, YHotSpot); + FIXME("(%p) : Spot Pos(%u,%u)\n", This, XHotSpot, YHotSpot); /* TODO: IDirect3DSurface9Impl* pSur = (IDirect3DSurface9Impl*) pCursorBitmap; @@ -136,7 +133,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVICE9 ifac void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface, int XScreenSpace, int YScreenSpace, DWORD Flags) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : SetPos to (%u,%u)\n", This, XScreenSpace, YScreenSpace); + FIXME("(%p) : SetPos to (%u,%u)\n", This, XScreenSpace, YScreenSpace); This->xScreenSpace = XScreenSpace; This->yScreenSpace = YScreenSpace; return; @@ -144,7 +141,7 @@ void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9 iface, BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9 iface, BOOL bShow) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : visible(%d)\n", This, bShow); + FIXME("(%p) : visible(%d)\n", This, bShow); This->bCursorVisible = bShow; return D3D_OK; } @@ -162,15 +159,16 @@ HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9 iface, CONST REC HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - *ppBackBuffer = (LPDIRECT3DSURFACE9) This->backBuffer; - TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, BackBuffer, Type, *ppBackBuffer); - if (BackBuffer > This->PresentParms.BackBufferCount - 1) { - FIXME("Only one backBuffer currently supported\n"); - return D3DERR_INVALIDCALL; + + IWineD3DSurface *retSurface = NULL; + HRESULT rc = D3D_OK; + + rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, Type, (IWineD3DSurface **)&retSurface); + if (rc == D3D_OK && NULL != ppBackBuffer) { + IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer); + IWineD3DSurface_Release(retSurface); } - /* Note inc ref on returned surface */ - IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppBackBuffer); - return D3D_OK; + return rc; } HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) { @@ -213,16 +211,29 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(LPDIRECT3DDEVICE9 iface IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) { IDirect3DSurface9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hrc = D3D_OK; /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl)); + if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *ppSurface = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DSurface9_Vtbl; object->ref = 1; - IWineD3DDevice_CreateRenderTarget(This->WineD3DDevice, Width, Height, Format, MultiSample, MultisampleQuality, - Lockable, &object->wineD3DSurface, pSharedHandle, (IUnknown *)object); - *ppSurface = (LPDIRECT3DSURFACE9) object; - - return D3D_OK; + hrc = IWineD3DDevice_CreateRenderTarget(This->WineD3DDevice, Width, Height, Format, MultiSample, MultisampleQuality, + Lockable, &object->wineD3DSurface, pSharedHandle, (IUnknown *)object); + if (hrc != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateRenderTarget failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppSurface = NULL; + } else { + *ppSurface = (LPDIRECT3DSURFACE9) object; + } + return hrc; } HRESULT WINAPI IDirect3DDevice9Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) { @@ -276,16 +287,29 @@ HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) { IDirect3DSurface9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hrc = D3D_OK; /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl)); + if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *ppSurface = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DSurface9_Vtbl; object->ref = 1; - IWineD3DDevice_CreateOffscreenPlainSurface(This->WineD3DDevice, Width, Height, Format, Pool, + hrc = IWineD3DDevice_CreateOffscreenPlainSurface(This->WineD3DDevice, Width, Height, Format, Pool, &(object->wineD3DSurface), pSharedHandle, (IUnknown *)object); - - *ppSurface = (LPDIRECT3DSURFACE9) object; - return D3D_OK; + if (hrc != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateOffscreenPlainSurface failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppSurface = NULL; + } else { + *ppSurface = (LPDIRECT3DSURFACE9) object; + } + return hrc; } HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) { @@ -414,16 +438,21 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9 iface, D3D HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9** ppTexture) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - TRACE("(%p) : returning %p for stage %ld\n", This, This->UpdateStateBlock->textures[Stage], Stage); - *ppTexture = (LPDIRECT3DBASETEXTURE9) This->UpdateStateBlock->textures[Stage]; - IDirect3DBaseTexture9Impl_AddRef(*ppTexture); - return D3D_OK; + IWineD3DBaseTexture *retTexture = NULL; + HRESULT rc = D3D_OK; + + rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, (IWineD3DBaseTexture **)&retTexture); + if (rc == D3D_OK && NULL != ppTexture) { + IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture); + IWineD3DBaseTexture_Release(retTexture); + } + return rc; } HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9 iface, DWORD Stage, IDirect3DBaseTexture9* pTexture) { IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - FIXME("(%p) : stub\n", This); - return D3D_OK; + return IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage, + pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture); } HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) { @@ -570,7 +599,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9 iface, U HRESULT rc = D3D_OK; rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, (IWineD3DVertexBuffer **)&retStream, OffsetInBytes, pStride); - if (rc == D3D_OK && NULL != *pStream) { + if (rc == D3D_OK && NULL != pStream) { IWineD3DVertexBuffer_GetParent(retStream, (IUnknown **)pStream); IWineD3DVertexBuffer_Release(retStream); } @@ -603,7 +632,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9 iface, IDirec UINT tmp; rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData, &tmp); - if (rc == D3D_OK && NULL != *ppIndexData) { + if (rc == D3D_OK && NULL != ppIndexData) { IWineD3DVertexBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData); IWineD3DVertexBuffer_Release(retIndexData); } diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index 9a5302fa844..cc2d8d8ab5a 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -144,7 +144,7 @@ HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, U HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) { IDirect3D9Impl *This = (IDirect3D9Impl *)iface; - return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (void *)pCaps); + return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (WINED3DCAPS *)pCaps); } HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) { @@ -165,6 +165,8 @@ HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, UINT Width, UINT Heig (IDirect3DSurface9 **)&d3dSurface, pSharedHandle); if (res == D3D_OK) { *ppSurface = d3dSurface->wineD3DSurface; + } else { + *ppSurface = NULL; } return res; } @@ -179,14 +181,18 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3 /* Check the validity range of the adapter parameter */ if (Adapter >= IDirect3D9Impl_GetAdapterCount(iface)) { + *ppReturnedDeviceInterface = NULL; return D3DERR_INVALIDCALL; } /* Allocate the storage for the device object */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DDevice9Impl)); if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *ppReturnedDeviceInterface = NULL; return D3DERR_OUTOFVIDEOMEMORY; } + object->lpVtbl = &Direct3DDevice9_Vtbl; object->ref = 1; object->direct3d = This; @@ -208,10 +214,7 @@ HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3 localParameters.Flags = &pPresentationParameters->Flags; localParameters.FullScreen_RefreshRateInHz = &pPresentationParameters->FullScreen_RefreshRateInHz; localParameters.PresentationInterval = &pPresentationParameters->PresentationInterval; - IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D9CB_CreateRenderTarget); - - FIXME("(%p) : incomplete stub\n", This); - return D3D_OK; + return IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &localParameters, &object->WineD3DDevice, (IUnknown *)object, D3D9CB_CreateRenderTarget); } IDirect3D9Vtbl Direct3D9_Vtbl = diff --git a/dlls/d3d9/indexbuffer.c b/dlls/d3d9/indexbuffer.c index fc90cc70bc6..ddeda2850de 100644 --- a/dlls/d3d9/indexbuffer.c +++ b/dlls/d3d9/indexbuffer.c @@ -142,13 +142,26 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DIndexBuffer9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hrc = D3D_OK; /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DIndexBuffer9Impl)); + if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *ppIndexBuffer = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DIndexBuffer9_Vtbl; object->ref = 1; - IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage, Format, Pool, &(object->wineD3DIndexBuffer), pSharedHandle, (IUnknown *)object); - - *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object; - return D3D_OK; + hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage, Format, Pool, &(object->wineD3DIndexBuffer), pSharedHandle, (IUnknown *)object); + if (hrc != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppIndexBuffer = NULL; + } else { + *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object; + } + return hrc; } diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index db7a0c9aff3..80a97c7ab0d 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -204,6 +204,8 @@ HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *pDevice, Format, Pool, (IDirect3DSurface9 **)&d3dSurface, pSharedHandle); if (res == D3D_OK) { *ppSurface = d3dSurface->wineD3DSurface; + } else { + *ppSurface = NULL; } return res; } diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index ccaa62c338b..402918e2d36 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -158,7 +158,7 @@ HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 iface, U IWineD3DSurface *mySurface = NULL; hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface); - if (hrc == D3D_OK) { + if (hrc == D3D_OK && NULL != ppSurfaceLevel) { IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel); IWineD3DSurface_Release(mySurface); } @@ -213,14 +213,28 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9 iface, UIN D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) { IDirect3DTexture9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hrc = D3D_OK; /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture9Impl)); + if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *ppTexture = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DTexture9_Vtbl; object->ref = 1; - IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage, + hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage, Format, Pool, &(object->wineD3DTexture), pSharedHandle, (IUnknown *)object, D3D9CB_CreateSurface); - *ppTexture = (LPDIRECT3DTEXTURE9) object; - return D3D_OK; + if (hrc != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppTexture = NULL; + } else { + *ppTexture = (LPDIRECT3DTEXTURE9) object; + } + return hrc; } diff --git a/dlls/d3d9/vertexbuffer.c b/dlls/d3d9/vertexbuffer.c index 2bc92d84d97..9bfca3ae1d8 100644 --- a/dlls/d3d9/vertexbuffer.c +++ b/dlls/d3d9/vertexbuffer.c @@ -141,13 +141,27 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface, IDirect3DVertexBuffer9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; + HRESULT hrc = D3D_OK; /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl)); + if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *ppVertexBuffer = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DVertexBuffer9_Vtbl; object->ref = 1; - IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage, FVF, Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object); - *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object; - - return D3D_OK; + hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage, FVF, Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object); + + if (hrc != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppVertexBuffer = NULL; + } else { + *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object; + } + return hrc; } diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index ae763866882..e519bc47310 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -90,7 +90,7 @@ HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID res = IWineD3DVolume_GetContainer(This->wineD3DVolume, riid, (void **)&IWineContainer); /* If this works, the only valid container is a child of resource (volumetexture) */ - if (res == D3D_OK) { + if (res == D3D_OK && NULL != ppContainer) { IWineD3DResource_GetParent((IWineD3DResource *)IWineContainer, (IUnknown **)ppContainer); IWineD3DResource_Release((IWineD3DResource *)IWineContainer); } @@ -148,11 +148,27 @@ HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, UINT Width, UINT Height, HANDLE * pSharedHandle) { IDirect3DVolume9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)pDevice; + HRESULT hrc = D3D_OK; /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume9Impl)); + if (NULL == object) { + FIXME("Allocation of memory failed\n"); + *ppVolume = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DVolume9_Vtbl; object->ref = 1; - return IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format, + hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format, Pool, ppVolume, pSharedHandle, (IUnknown *)object); + if (hrc != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppVolume = NULL; + } else { + *ppVolume = (IWineD3DVolume *)object; + } + return hrc; } diff --git a/dlls/d3d9/volumetexture.c b/dlls/d3d9/volumetexture.c index 344e278233b..1f26cd67045 100644 --- a/dlls/d3d9/volumetexture.c +++ b/dlls/d3d9/volumetexture.c @@ -156,7 +156,7 @@ HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUMETEXTUR IWineD3DVolume *myVolume = NULL; hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume); - if (hrc == D3D_OK) { + if (hrc == D3D_OK && NULL != ppVolumeLevel) { IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel); IWineD3DVolumeTexture_Release(myVolume); } @@ -210,19 +210,34 @@ IDirect3DVolumeTexture9Vtbl Direct3DVolumeTexture9_Vtbl = HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, - IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) { + IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle) { IDirect3DVolumeTexture9Impl *object; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; - + HRESULT hrc = D3D_OK; + /* Allocate the storage for the device */ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl)); + if (NULL == object) { + FIXME("(%p) allocation of memory failed\n", This); + *ppVolumeTexture = NULL; + return D3DERR_OUTOFVIDEOMEMORY; + } + object->lpVtbl = &Direct3DVolumeTexture9_Vtbl; object->ref = 1; - IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage, + hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage, Format, Pool, &(object->wineD3DVolumeTexture), pSharedHandle, (IUnknown *)object, D3D9CB_CreateVolume); - *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE9) object; - return D3D_OK; + + if (hrc != D3D_OK) { + /* free up object */ + FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This); + HeapFree(GetProcessHeap(), 0, object); + *ppVolumeTexture = NULL; + } else { + *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE9) object; + } + return hrc; } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 76fac63da06..5305485fd1e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -336,17 +336,17 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateRenderTarget(IWineD3DDevice *iface, UINT object->currentDesc.MultiSampleType = MultiSample; object->bytesPerPixel = D3DFmtGetBpp(This, Format); if (Format == D3DFMT_DXT1) { - object->currentDesc.Size = (Width * object->bytesPerPixel)/2 * Height; /* DXT1 is half byte per pixel */ + object->currentDesc_size = (Width * object->bytesPerPixel)/2 * Height; /* DXT1 is half byte per pixel */ } else { - object->currentDesc.Size = (Width * object->bytesPerPixel) * Height; + object->currentDesc_size = (Width * object->bytesPerPixel) * Height; } - object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->currentDesc.Size); + object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->currentDesc_size); object->lockable = Lockable; object->locked = FALSE; memset(&object->lockedRect, 0, sizeof(RECT)); IWineD3DSurface_CleanDirtyRect(*ppSurface); - TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), Lockable, *ppSurface, object->allocatedMemory, object->currentDesc.Size); + TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), Lockable, *ppSurface, object->allocatedMemory, object->currentDesc_size); return D3D_OK; } @@ -389,18 +389,18 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateOffscreenPlainSurface(IWineD3DDevice *if it is based around 4x4 pixel blocks it requires padding, so allocate enough space! */ if (Format == D3DFMT_DXT1) { - object->currentDesc.Size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)) / 2; /* DXT1 is half byte per pixel */ + object->currentDesc_size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)) / 2; /* DXT1 is half byte per pixel */ } else if (Format == D3DFMT_DXT2 || Format == D3DFMT_DXT3 || Format == D3DFMT_DXT4 || Format == D3DFMT_DXT5) { - object->currentDesc.Size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)); + object->currentDesc_size = ((max(Width,4) * object->bytesPerPixel) * max(Height,4)); } else { - object->currentDesc.Size = (Width * object->bytesPerPixel) * Height; + object->currentDesc_size = (Width * object->bytesPerPixel) * Height; } - object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->currentDesc.Size); + object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object->currentDesc_size); object->lockable = TRUE; object->locked = FALSE; object->Dirty = FALSE; - TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->currentDesc.Size); + TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) surf@%p, surfmem@%p, %d bytes\n", This, Width, Height, Format, debug_d3dformat(Format), *ppSurface, object->allocatedMemory, object->currentDesc_size); memset(&object->lockedRect, 0, sizeof(RECT)); return IWineD3DSurface_CleanDirtyRect(*ppSurface); @@ -465,13 +465,13 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Widt object->surfaces[i]->currentDesc.Usage = Usage; object->surfaces[i]->currentDesc.Pool = Pool; - /** - * As written in msdn in IDirect3DTexture8::LockRect - * Textures created in D3DPOOL_DEFAULT are not lockable. - */ - if (D3DPOOL_DEFAULT == Pool) { - object->surfaces[i]->lockable = FALSE; - } + /** + * As written in msdn in IDirect3DTexture8::LockRect + * Textures created in D3DPOOL_DEFAULT are not lockable. + */ + if (D3DPOOL_DEFAULT == Pool) { + object->surfaces[i]->lockable = FALSE; + } TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[i], object->surfaces[i]->allocatedMemory); tmpW = max(1, tmpW / 2); @@ -619,6 +619,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DCubeTextureImpl)); if (NULL == object) { + FIXME("Allocation of memory failed\n"); *ppCubeTexture = NULL; return D3DERR_OUTOFVIDEOMEMORY; } @@ -663,13 +664,13 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT object->surfaces[j][i]->currentDesc.Usage = Usage; object->surfaces[j][i]->currentDesc.Pool = Pool; - /** - * As written in msdn in IDirect3DCubeTexture8::LockRect - * Textures created in D3DPOOL_DEFAULT are not lockable. - */ - if (D3DPOOL_DEFAULT == Pool) { - object->surfaces[j][i]->lockable = FALSE; - } + /** + * As written in msdn in IDirect3DCubeTexture8::LockRect + * Textures created in D3DPOOL_DEFAULT are not lockable. + */ + if (D3DPOOL_DEFAULT == Pool) { + object->surfaces[j][i]->lockable = FALSE; + } TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[j][i], object->surfaces[j][i]->allocatedMemory); } @@ -2977,6 +2978,219 @@ HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *iface, DW return D3D_OK; } +/***** + * Get / Set Texture + *****/ +HRESULT WINAPI IWineD3DDeviceImpl_SetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture* pTexture) { + + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + IWineD3DBaseTexture *oldTexture; + BOOL reapplyStates = TRUE; + DWORD reapplyFlags = 0; + INT oldTextureDimensions = -1; + D3DRESOURCETYPE textureType; + + oldTexture = This->updateStateBlock->textures[Stage]; + TRACE("(%p) : Stage(%ld), Texture (%p)\n", This, Stage, pTexture); + + /* Reject invalid texture units */ + if (Stage >= GL_LIMITS(textures)) { + TRACE("Attempt to access invalid texture rejected\n"); + return D3DERR_INVALIDCALL; + } + + This->updateStateBlock->set.textures[Stage] = TRUE; + This->updateStateBlock->changed.textures[Stage] = TRUE; + This->updateStateBlock->textures[Stage] = pTexture; + + /* Handle recording of state blocks */ + if (This->isRecordingState) { + TRACE("Recording... not performing anything\n"); + return D3D_OK; + } + + oldTextureDimensions = This->updateStateBlock->textureDimensions[Stage]; + + ENTER_GL(); + + /* Make appropriate texture active */ + if (GL_SUPPORT(ARB_MULTITEXTURE)) { + GLACTIVETEXTURE(Stage); + + } else if (Stage>0) { + FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n"); + } + + /* Decrement the count of the previous texture */ + if (NULL != oldTexture) { + IWineD3DBaseTexture_Release(oldTexture); + } + + if (NULL != pTexture) { + IWineD3DBaseTexture_AddRef((IWineD3DBaseTexture *) This->updateStateBlock->textures[Stage]); + + /* Now setup the texture appropraitly */ + textureType = IWineD3DBaseTexture_GetType(pTexture); + + if (textureType == D3DRTYPE_TEXTURE) { + + if (oldTexture == pTexture && !IWineD3DBaseTexture_GetDirty(pTexture)) { + TRACE("Skipping setting texture as old == new\n"); + reapplyStates = FALSE; + + } else { + + /* Standard 2D texture */ + TRACE("Standard 2d texture\n"); + This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_2D; + + /* Load up the texture now */ + IWineD3DTexture_PreLoad((IWineD3DTexture *) pTexture); + } + + } else if (textureType == D3DRTYPE_VOLUMETEXTURE) { + + if (oldTexture == pTexture && !IWineD3DBaseTexture_GetDirty(pTexture)) { + TRACE("Skipping setting texture as old == new\n"); + reapplyStates = FALSE; + + } else { + + /* Standard 3D (volume) texture */ + TRACE("Standard 3d texture\n"); + This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_3D; + + /* Load up the texture now */ + IWineD3DVolumeTexture_PreLoad((IWineD3DVolumeTexture *) pTexture); + } + + } else if (textureType == D3DRTYPE_CUBETEXTURE) { + + if (oldTexture == pTexture && !IWineD3DBaseTexture_GetDirty(pTexture)) { + TRACE("Skipping setting texture as old == new\n"); + reapplyStates = FALSE; + + } else { + + /* Standard Cube texture */ + TRACE("Standard Cube texture\n"); + This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_CUBE_MAP_ARB; + + /* Load up the texture now */ + IWineD3DCubeTexture_PreLoad((IWineD3DCubeTexture *) pTexture); + } + + } else { + FIXME("(%p) : Incorrect type for a texture : (%d,%s)\n", This, textureType, debug_d3dresourcetype(textureType)); + } + + } else { + + TRACE("Setting to no texture (ie default texture)\n"); + This->updateStateBlock->textureDimensions[Stage] = GL_TEXTURE_1D; + glBindTexture(GL_TEXTURE_1D, This->dummyTextureName[Stage]); + checkGLcall("glBindTexture"); + TRACE("Bound dummy Texture to stage %ld (gl name %d)\n", Stage, This->dummyTextureName[Stage]); + } + + /* Disable the old texture binding and enable the new one (unless operations are disabled) */ + if (oldTextureDimensions != This->updateStateBlock->textureDimensions[Stage]) { + + glDisable(oldTextureDimensions); + checkGLcall("Disable oldTextureDimensions"); + + if (This->stateBlock->textureState[Stage][D3DTSS_COLOROP] != D3DTOP_DISABLE) { + glEnable(This->updateStateBlock->textureDimensions[Stage]); + checkGLcall("glEnable new texture dimensions"); + } + + /* If Alpha arg1 is texture then handle the special case when there changes between a + texture and no texture - See comments in set_tex_op */ + if ((This->stateBlock->textureState[Stage][D3DTSS_ALPHAARG1] == D3DTA_TEXTURE) && + (((oldTexture == NULL) && (pTexture != NULL)) || ((pTexture == NULL) && (oldTexture != NULL)))) + { + reapplyFlags |= REAPPLY_ALPHAOP; + } + } + + + /* Even if the texture has been set to null, reapply the stages as a null texture to directx requires + a dummy texture in opengl, and we always need to ensure the current view of the TextureStates apply */ + if (reapplyStates) { + IWineD3DDeviceImpl_SetupTextureStates(iface, Stage, reapplyFlags); + } + + LEAVE_GL(); + TRACE("Texture now fully setup\n"); + + return D3D_OK; +} + +HRESULT WINAPI IWineD3DDeviceImpl_GetTexture(IWineD3DDevice *iface, DWORD Stage, IWineD3DBaseTexture** ppTexture) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + TRACE("(%p) : returning %p for stage %ld\n", This, This->updateStateBlock->textures[Stage], Stage); + *ppTexture = (IWineD3DBaseTexture *) This->updateStateBlock->textures[Stage]; + if (*ppTexture) + IWineD3DBaseTexture_AddRef(*ppTexture); + return D3D_OK; +} + +/***** + * Get Back Buffer + *****/ +HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UINT iSwapChain, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, + IWineD3DSurface** ppBackBuffer) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + + *ppBackBuffer = (IWineD3DSurface *) This->backBuffer; + TRACE("(%p) : BackBuf %d Type %d SwapChain %d returning %p\n", This, BackBuffer, Type, iSwapChain, *ppBackBuffer); + + if (BackBuffer > This->presentParms.BackBufferCount - 1) { + FIXME("Only one backBuffer currently supported\n"); + return D3DERR_INVALIDCALL; + } + + /* Note inc ref on returned surface */ + IWineD3DSurface_AddRef(*ppBackBuffer); + + return D3D_OK; +} + +HRESULT WINAPI IWineD3DDeviceImpl_GetDeviceCaps(IWineD3DDevice *iface, D3DCAPS9* pCaps) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + WARN("(%p) : stub, calling idirect3d for now\n", This); + IWineD3D_GetDeviceCaps(This->wineD3D, This->adapterNo, This->devType, pCaps); + return D3D_OK; +} + +HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, D3DDISPLAYMODE* pMode) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + HDC hdc; + int bpp = 0; + + pMode->Width = GetSystemMetrics(SM_CXSCREEN); + pMode->Height = GetSystemMetrics(SM_CYSCREEN); + pMode->RefreshRate = 85; /*FIXME: How to identify? */ + + hdc = CreateDCA("DISPLAY", NULL, NULL, NULL); + bpp = GetDeviceCaps(hdc, BITSPIXEL); + DeleteDC(hdc); + + switch (bpp) { + case 8: pMode->Format = D3DFMT_R8G8B8; break; + case 16: pMode->Format = D3DFMT_R5G6B5; break; + case 24: /*pMode->Format = D3DFMT_R8G8B8; break; */ + case 32: pMode->Format = D3DFMT_A8R8G8B8; break; + default: + FIXME("Unrecognized display mode format\n"); + pMode->Format = D3DFMT_UNKNOWN; + } + + FIXME("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate, + pMode->Format, debug_d3dformat(pMode->Format)); + return D3D_OK; +} + /***** * Scene related functions *****/ @@ -3397,6 +3611,12 @@ IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_GetRenderState, IWineD3DDeviceImpl_SetTextureStageState, IWineD3DDeviceImpl_GetTextureStageState, + IWineD3DDeviceImpl_SetTexture, + IWineD3DDeviceImpl_GetTexture, + + IWineD3DDeviceImpl_GetBackBuffer, + IWineD3DDeviceImpl_GetDeviceCaps, + IWineD3DDeviceImpl_GetDisplayMode, IWineD3DDeviceImpl_BeginScene, IWineD3DDeviceImpl_EndScene, diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 5d06ead2e05..2f10b642c0c 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -986,7 +986,7 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true subset of a D3DCAPS9 structure. However, it has to come via a void * as the d3d8 interface cannot import the d3d9 header */ -HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, void* pCapsIn) { +HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS* pCapsIn) { IWineD3DImpl *This = (IWineD3DImpl *)iface; BOOL gotContext = FALSE; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index d53b170a6e8..8381f03e546 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -124,7 +124,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFAC *(pDesc->Type) = This->currentDesc.Type; *(pDesc->Usage) = This->currentDesc.Usage; *(pDesc->Pool) = This->currentDesc.Pool; - *(pDesc->Size) = This->currentDesc.Size; /* dx8 only */ + *(pDesc->Size) = This->currentDesc_size; /* dx8 only */ *(pDesc->MultiSampleType) = This->currentDesc.MultiSampleType; *(pDesc->MultiSampleQuality) = This->currentDesc.MultiSampleQuality; *(pDesc->Width) = This->currentDesc.Width; @@ -569,7 +569,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl This->currentDesc.Width, This->currentDesc.Height, 0, - This->currentDesc.Size, + This->currentDesc_size, This->allocatedMemory); ENTER_GL(); @@ -580,7 +580,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, GLenum gl This->currentDesc.Width, This->currentDesc.Height, 0, - This->currentDesc.Size, + This->currentDesc_size, This->allocatedMemory); checkGLcall("glCommpressedTexTexImage2D"); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index dc8f3622d92..28a6404ec2e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -583,6 +583,7 @@ struct IWineD3DSurfaceImpl /* IWineD3DSurface fields */ IUnknown *container; D3DSURFACE_DESC currentDesc; + UINT currentDesc_size; BYTE *allocatedMemory; UINT textureName; @@ -709,79 +710,9 @@ GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt); /***************************************************************************** * To enable calling of inherited functions, requires prototypes + * + * Note: Only require classes which are subclassed, ie resource, basetexture, */ - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DImpl_QueryInterface(IWineD3D *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DImpl_AddRef(IWineD3D *iface); - extern ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface); - /*** IWineD3D methods ***/ - extern HRESULT WINAPI IWineD3DImpl_GetParent(IWineD3D *iface, IUnknown **pParent); - extern UINT WINAPI IWineD3DImpl_GetAdapterCount(IWineD3D *iface); - extern HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice(IWineD3D *iface, void * pInitializeFunction); - extern HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter); - extern UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Adapter, D3DFORMAT Format); - extern HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapter, UINT Mode, D3DFORMAT Format, D3DDISPLAYMODE * pMode); - extern HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT Adapter, D3DDISPLAYMODE * pMode); - extern HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter, DWORD Flags, WINED3DADAPTER_IDENTIFIER* pIdentifier); - extern HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQuality); - extern HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); - extern HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed); - extern HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); - extern HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); - extern HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, void * pCaps); - extern HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType,HWND hFocusWindow, DWORD BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface, IUnknown *parent, D3DCB_CREATERENDERTARGETFN pFn); - - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DDeviceImpl_QueryInterface(IWineD3DDevice *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DDeviceImpl_AddRef(IWineD3DDevice *iface); - extern ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface); - /*** IWineD3D methods ***/ - extern HRESULT WINAPI IWineD3DDeviceImpl_GetParent(IWineD3DDevice *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IWineD3DVertexBuffer **ppVertexBuffer, HANDLE *sharedHandle, IUnknown *parent); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DIndexBuffer** ppIndexBuffer, HANDLE* pSharedHandle, IUnknown *parent); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice *iface, D3DSTATEBLOCKTYPE Type, IWineD3DStateBlock **ppStateBlock, IUnknown *parent); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateRenderTarget(IWineD3DDevice *iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IWineD3DSurface** ppSurface, HANDLE* pSharedHandle, IUnknown *parent); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateOffscreenPlainSurface(IWineD3DDevice *iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IWineD3DSurface** ppSurface, HANDLE* pSharedHandle, IUnknown *parent); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DTexture** ppTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DVolumeTexture** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATEVOLUMEFN pFn); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface, UINT Width, UINT Height, UINT Depth, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DVolume** ppVolumeTexture, HANDLE* pSharedHandle, IUnknown *parent); - extern HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IWineD3DCubeTexture** ppCubeTexture, HANDLE* pSharedHandle, IUnknown *parent, D3DCB_CREATESURFACEFN pFn); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetFVF(IWineD3DDevice *iface, DWORD fvf); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetFVF(IWineD3DDevice *iface, DWORD * pfvf); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetStreamSource(IWineD3DDevice *iface, UINT StreamNumber,IWineD3DVertexBuffer * pStreamData,UINT Offset,UINT Stride); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetStreamSource(IWineD3DDevice *iface, UINT StreamNumber,IWineD3DVertexBuffer ** ppStreamData,UINT *pOffset, UINT * pStride); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetTransform(IWineD3DDevice *iface, D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX * pMatrix); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetTransform(IWineD3DDevice *iface, D3DTRANSFORMSTATETYPE State,D3DMATRIX * pMatrix); - extern HRESULT WINAPI IWineD3DDeviceImpl_MultiplyTransform(IWineD3DDevice *iface, D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX * pMatrix); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetLight(IWineD3DDevice *iface, DWORD Index,CONST WINED3DLIGHT * pLight); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetLight(IWineD3DDevice *iface, DWORD Index,WINED3DLIGHT * pLight); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetLightEnable(IWineD3DDevice *iface, DWORD Index,BOOL Enable); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetLightEnable(IWineD3DDevice *iface, DWORD Index,BOOL * pEnable); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetClipPlane(IWineD3DDevice *iface, DWORD Index,CONST float * pPlane); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetClipPlane(IWineD3DDevice *iface, DWORD Index,float * pPlane); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetClipStatus(IWineD3DDevice *iface, CONST WINED3DCLIPSTATUS * pClipStatus); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetClipStatus(IWineD3DDevice *iface, WINED3DCLIPSTATUS * pClipStatus); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetMaterial(IWineD3DDevice *iface, CONST WINED3DMATERIAL * pMaterial); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetMaterial(IWineD3DDevice *iface, WINED3DMATERIAL *pMaterial); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DIndexBuffer * pIndexData,UINT BaseVertexIndex); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetIndices(IWineD3DDevice *iface, IWineD3DIndexBuffer ** ppIndexData,UINT * pBaseVertexIndex); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetViewport(IWineD3DDevice *iface, CONST WINED3DVIEWPORT * pViewport); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetViewport(IWineD3DDevice *iface, WINED3DVIEWPORT * pViewport); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, D3DRENDERSTATETYPE State,DWORD Value); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetRenderState(IWineD3DDevice *iface, D3DRENDERSTATETYPE State,DWORD * pValue); - extern HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value); - extern HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD * pValue); - extern HRESULT WINAPI IWineD3DDeviceImpl_BeginScene(IWineD3DDevice *iface); - extern HRESULT WINAPI IWineD3DDeviceImpl_EndScene(IWineD3DDevice *iface); - extern HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface, CONST RECT * pSourceRect,CONST RECT * pDestRect,HWND hDestWindowOverride,CONST RGNDATA * pDirtyRegion); - extern HRESULT WINAPI IWineD3DDeviceImpl_Clear(IWineD3DDevice *iface, DWORD Count,CONST D3DRECT * pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil); - extern HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount); - extern HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType,INT baseVIdx, UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount); - extern HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride); - extern HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface, D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void * pIndexData,D3DFORMAT IndexDataFormat,CONST void * pVertexStreamZeroData,UINT VertexStreamZeroStride); - /*** Internal use IWineD3D methods ***/ - extern void WINAPI IWineD3DDeviceImpl_SetupTextureStates(IWineD3DDevice *iface, DWORD Stage, DWORD Flags); - /*** IUnknown methods ***/ extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject); extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface); @@ -797,43 +728,6 @@ GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt); extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface); extern D3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface); - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DVertexBufferImpl_QueryInterface(IWineD3DVertexBuffer *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DVertexBufferImpl_AddRef(IWineD3DVertexBuffer *iface); - extern ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface); - /*** IWineD3DResource methods ***/ - extern HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DVertexBufferImpl_GetDevice(IWineD3DVertexBuffer *iface, IWineD3DDevice ** ppDevice); - extern HRESULT WINAPI IWineD3DVertexBufferImpl_SetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags); - extern HRESULT WINAPI IWineD3DVertexBufferImpl_GetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData); - extern HRESULT WINAPI IWineD3DVertexBufferImpl_FreePrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid); - extern DWORD WINAPI IWineD3DVertexBufferImpl_SetPriority(IWineD3DVertexBuffer *iface, DWORD PriorityNew); - extern DWORD WINAPI IWineD3DVertexBufferImpl_GetPriority(IWineD3DVertexBuffer *iface); - extern void WINAPI IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer *iface); - extern D3DRESOURCETYPE WINAPI IWineD3DVertexBufferImpl_GetType(IWineD3DVertexBuffer *iface); - /*** IWineD3DVertexBuffer methods ***/ - extern HRESULT WINAPI IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE ** ppbData, DWORD Flags); - extern HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface); - extern HRESULT WINAPI IWineD3DVertexBufferImpl_GetDesc(IWineD3DVertexBuffer *iface, D3DVERTEXBUFFER_DESC * pDesc); - - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DIndexBufferImpl_QueryInterface(IWineD3DIndexBuffer *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DIndexBufferImpl_AddRef(IWineD3DIndexBuffer *iface); - extern ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface); - /*** IWineD3DResource methods ***/ - extern HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DIndexBufferImpl_GetDevice(IWineD3DIndexBuffer *iface, IWineD3DDevice ** ppDevice); - extern HRESULT WINAPI IWineD3DIndexBufferImpl_SetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags); - extern HRESULT WINAPI IWineD3DIndexBufferImpl_GetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData); - extern HRESULT WINAPI IWineD3DIndexBufferImpl_FreePrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid); - extern DWORD WINAPI IWineD3DIndexBufferImpl_SetPriority(IWineD3DIndexBuffer *iface, DWORD PriorityNew); - extern DWORD WINAPI IWineD3DIndexBufferImpl_GetPriority(IWineD3DIndexBuffer *iface); - extern void WINAPI IWineD3DIndexBufferImpl_PreLoad(IWineD3DIndexBuffer *iface); - extern D3DRESOURCETYPE WINAPI IWineD3DIndexBufferImpl_GetType(IWineD3DIndexBuffer *iface); - /*** IWineD3DIndexBuffer methods ***/ - extern HRESULT WINAPI IWineD3DIndexBufferImpl_Lock(IWineD3DIndexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE ** ppbData, DWORD Flags); - extern HRESULT WINAPI IWineD3DIndexBufferImpl_Unlock(IWineD3DIndexBuffer *iface); - extern HRESULT WINAPI IWineD3DIndexBufferImpl_GetDesc(IWineD3DIndexBuffer *iface, D3DINDEXBUFFER_DESC * pDesc); /*** IUnknown methods ***/ extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject); @@ -859,148 +753,6 @@ GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt); extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL); extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface); - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DTextureImpl_QueryInterface(IWineD3DTexture *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DTextureImpl_AddRef(IWineD3DTexture *iface); - extern ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface); - /*** IWineD3DResource methods ***/ - extern HRESULT WINAPI IWineD3DTextureImpl_GetParent(IWineD3DTexture *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DTextureImpl_GetDevice(IWineD3DTexture *iface, IWineD3DDevice ** ppDevice); - extern HRESULT WINAPI IWineD3DTextureImpl_SetPrivateData(IWineD3DTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags); - extern HRESULT WINAPI IWineD3DTextureImpl_GetPrivateData(IWineD3DTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData); - extern HRESULT WINAPI IWineD3DTextureImpl_FreePrivateData(IWineD3DTexture *iface, REFGUID refguid); - extern DWORD WINAPI IWineD3DTextureImpl_SetPriority(IWineD3DTexture *iface, DWORD PriorityNew); - extern DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface); - extern void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface); - extern D3DRESOURCETYPE WINAPI IWineD3DTextureImpl_GetType(IWineD3DTexture *iface); - /*** IWineD3DBaseTexture methods ***/ - extern DWORD WINAPI IWineD3DTextureImpl_SetLOD(IWineD3DTexture *iface, DWORD LODNew); - extern DWORD WINAPI IWineD3DTextureImpl_GetLOD(IWineD3DTexture *iface); - extern DWORD WINAPI IWineD3DTextureImpl_GetLevelCount(IWineD3DTexture *iface); - extern HRESULT WINAPI IWineD3DTextureImpl_SetAutoGenFilterType(IWineD3DTexture *iface, D3DTEXTUREFILTERTYPE FilterType); - extern D3DTEXTUREFILTERTYPE WINAPI IWineD3DTextureImpl_GetAutoGenFilterType(IWineD3DTexture *iface); - extern void WINAPI IWineD3DTextureImpl_GenerateMipSubLevels(IWineD3DTexture *iface); - extern BOOL WINAPI IWineD3DTextureImpl_SetDirty(IWineD3DTexture *iface, BOOL); - extern BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface); - /*** IWineD3DTexture methods ***/ - extern HRESULT WINAPI IWineD3DTextureImpl_GetLevelDesc(IWineD3DTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc); - extern HRESULT WINAPI IWineD3DTextureImpl_GetSurfaceLevel(IWineD3DTexture *iface, UINT Level, IWineD3DSurface** ppSurfaceLevel); - extern HRESULT WINAPI IWineD3DTextureImpl_LockRect(IWineD3DTexture *iface, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags); - extern HRESULT WINAPI IWineD3DTextureImpl_UnlockRect(IWineD3DTexture *iface, UINT Level); - extern HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, CONST RECT* pDirtyRect); - - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DCubeTextureImpl_QueryInterface(IWineD3DCubeTexture *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DCubeTextureImpl_AddRef(IWineD3DCubeTexture *iface); - extern ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface); - /*** IWineD3DResource methods ***/ - extern HRESULT WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_GetDevice(IWineD3DCubeTexture *iface, IWineD3DDevice ** ppDevice); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid); - extern DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew); - extern DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface); - extern void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface); - extern D3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface); - /*** IWineD3DBaseTexture methods ***/ - extern DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew); - extern DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface); - extern DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, D3DTEXTUREFILTERTYPE FilterType); - extern D3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface); - extern void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface); - extern BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL); - extern BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface); - /*** IWineD3DCubeTexture methods ***/ - extern HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level,WINED3DSURFACE_DESC* pDesc); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_GetCubeMapSurface(IWineD3DCubeTexture *iface, D3DCUBEMAP_FACES FaceType, UINT Level, IWineD3DSurface** ppCubeMapSurface); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_LockRect(IWineD3DCubeTexture *iface, D3DCUBEMAP_FACES FaceType, UINT Level, D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_UnlockRect(IWineD3DCubeTexture *iface, D3DCUBEMAP_FACES FaceType, UINT Level); - extern HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture *iface, D3DCUBEMAP_FACES FaceType, CONST RECT* pDirtyRect); - - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_QueryInterface(IWineD3DVolumeTexture *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DVolumeTextureImpl_AddRef(IWineD3DVolumeTexture *iface); - extern ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *iface); - /*** IWineD3DResource methods ***/ - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_GetParent(IWineD3DVolumeTexture *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_GetDevice(IWineD3DVolumeTexture *iface, IWineD3DDevice ** ppDevice); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_SetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_GetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_FreePrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid); - extern DWORD WINAPI IWineD3DVolumeTextureImpl_SetPriority(IWineD3DVolumeTexture *iface, DWORD PriorityNew); - extern DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture *iface); - extern void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface); - extern D3DRESOURCETYPE WINAPI IWineD3DVolumeTextureImpl_GetType(IWineD3DVolumeTexture *iface); - /*** IWineD3DBaseTexture methods ***/ - extern DWORD WINAPI IWineD3DVolumeTextureImpl_SetLOD(IWineD3DVolumeTexture *iface, DWORD LODNew); - extern DWORD WINAPI IWineD3DVolumeTextureImpl_GetLOD(IWineD3DVolumeTexture *iface); - extern DWORD WINAPI IWineD3DVolumeTextureImpl_GetLevelCount(IWineD3DVolumeTexture *iface); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_SetAutoGenFilterType(IWineD3DVolumeTexture *iface, D3DTEXTUREFILTERTYPE FilterType); - extern D3DTEXTUREFILTERTYPE WINAPI IWineD3DVolumeTextureImpl_GetAutoGenFilterType(IWineD3DVolumeTexture *iface); - extern void WINAPI IWineD3DVolumeTextureImpl_GenerateMipSubLevels(IWineD3DVolumeTexture *iface); - extern BOOL WINAPI IWineD3DVolumeTextureImpl_SetDirty(IWineD3DVolumeTexture *iface, BOOL); - extern BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface); - /*** IWineD3DVolumeTexture methods ***/ - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface, UINT Level, WINED3DVOLUME_DESC *pDesc); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTexture *iface, UINT Level, IWineD3DVolume** ppVolumeLevel); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_LockBox(IWineD3DVolumeTexture *iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_UnlockBox(IWineD3DVolumeTexture *iface, UINT Level); - extern HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, CONST D3DBOX* pDirtyBox); - - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DSurfaceImpl_QueryInterface(IWineD3DSurface *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DSurfaceImpl_AddRef(IWineD3DSurface *iface); - extern ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface); - /*** IWineD3DResource methods ***/ - extern HRESULT WINAPI IWineD3DSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice ** ppDevice); - extern HRESULT WINAPI IWineD3DSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags); - extern HRESULT WINAPI IWineD3DSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData); - extern HRESULT WINAPI IWineD3DSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid); - extern DWORD WINAPI IWineD3DSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew); - extern DWORD WINAPI IWineD3DSurfaceImpl_GetPriority(IWineD3DSurface *iface); - extern void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface); - extern D3DRESOURCETYPE WINAPI IWineD3DSurfaceImpl_GetType(IWineD3DSurface *iface); - /*** IWineD3DSurface methods ***/ - extern HRESULT WINAPI IWineD3DSurfaceImpl_GetContainer(IWineD3DSurface *iface, REFIID riid, void ** ppContainer); - extern HRESULT WINAPI IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC * pDesc); - extern HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, D3DLOCKED_RECT * pLockedRect, CONST RECT * pRect,DWORD Flags); - extern HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface); - extern HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHdc); - extern HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hdc); - /* Internally used methods */ - extern HRESULT WINAPI IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface *iface); - extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pRect); - extern HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, UINT gl_target, UINT gl_level); - extern HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char *filename); - - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DVolumeImpl_QueryInterface(IWineD3DVolume *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DVolumeImpl_AddRef(IWineD3DVolume *iface); - extern ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface); - /*** IWineD3DVolume methods ***/ - extern HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DVolumeImpl_GetDevice(IWineD3DVolume *iface, IWineD3DDevice ** ppDevice); - extern HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags); - extern HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData); - extern HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid); - extern HRESULT WINAPI IWineD3DVolumeImpl_GetContainer(IWineD3DVolume *iface, REFIID riid, void ** ppContainer); - extern HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC * pDesc); - extern HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags); - extern HRESULT WINAPI IWineD3DVolumeImpl_UnlockBox(IWineD3DVolume *iface); - extern HRESULT WINAPI IWineD3DVolumeImpl_AddDirtyBox(IWineD3DVolume *iface, CONST D3DBOX* pDirtyBox); - extern HRESULT WINAPI IWineD3DVolumeImpl_CleanDirtyBox(IWineD3DVolume *iface); - - /*** IUnknown methods ***/ - extern HRESULT WINAPI IWineD3DStateBlockImpl_QueryInterface(IWineD3DStateBlock *iface, REFIID riid, void** ppvObject); - extern ULONG WINAPI IWineD3DStateBlockImpl_AddRef(IWineD3DStateBlock *iface); - extern ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface); - /*** IWineD3DStateBlock methods ***/ - extern HRESULT WINAPI IWineD3DStateBlockImpl_GetParent(IWineD3DStateBlock *iface, IUnknown **pParent); - extern HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStateBlock *iface); - #if 0 /* Needs fixing during rework */ /***************************************************************************** diff --git a/include/d3d9types.h b/include/d3d9types.h index a98cb4a9757..4557f10716c 100644 --- a/include/d3d9types.h +++ b/include/d3d9types.h @@ -1304,7 +1304,6 @@ typedef struct _D3DSURFACE_DESC { D3DRESOURCETYPE Type; DWORD Usage; D3DPOOL Pool; - UINT Size; D3DMULTISAMPLE_TYPE MultiSampleType; DWORD MultiSampleQuality; UINT Width; diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h index 4d2b196d3cc..3abc525ead0 100644 --- a/include/wine/wined3d_interface.h +++ b/include/wine/wined3d_interface.h @@ -96,17 +96,27 @@ typedef struct _WINED3DVOLUME_DESC UINT *Depth; } WINED3DVOLUME_DESC; -/* The following have differing names, but actually are the same layout */ +/* The following have differing names, but actually are the same layout. */ +/* Also, D3DCAPS8 is a subset of D3DCAPS9 so can be typecase as long as + none of the 9 fields are accessed when the device is d3d8 */ #if defined( __WINE_D3D8_H ) + /* Identical: */ #define WINED3DLIGHT D3DLIGHT8 #define WINED3DCLIPSTATUS D3DCLIPSTATUS8 #define WINED3DMATERIAL D3DMATERIAL8 #define WINED3DVIEWPORT D3DVIEWPORT8 + + /* Subset: */ + #define WINED3DCAPS D3DCAPS8 #else + /* Identical: */ #define WINED3DLIGHT D3DLIGHT9 #define WINED3DCLIPSTATUS D3DCLIPSTATUS9 #define WINED3DMATERIAL D3DMATERIAL9 #define WINED3DVIEWPORT D3DVIEWPORT9 + + /* Subsets: */ + #define WINED3DCAPS D3DCAPS9 #endif typedef struct IWineD3D IWineD3D; @@ -178,7 +188,7 @@ DECLARE_INTERFACE_(IWineD3D,IUnknown) STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed) PURE; STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) PURE; STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, void * pCaps) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, WINED3DCAPS* pCaps) PURE; STDMETHOD(CreateDevice)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType,HWND hFocusWindow, DWORD BehaviorFlags, WINED3DPRESENT_PARAMETERS * pPresentationParameters, IWineD3DDevice ** ppReturnedDeviceInterface, IUnknown *parent, D3DCB_CREATERENDERTARGETFN pFn) PURE; }; #undef INTERFACE @@ -255,6 +265,11 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown) STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD * pValue) PURE; STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD * pValue) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage, IWineD3DBaseTexture* pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD Stage, IWineD3DBaseTexture** ppTexture) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IWineD3DSurface** ppBackBuffer) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ WINED3DCAPS* pCaps) PURE; + STDMETHOD(GetDisplayMode)(THIS_ UINT iSwapChain, D3DDISPLAYMODE* pMode) PURE; STDMETHOD(BeginScene)(THIS) PURE; STDMETHOD(EndScene)(THIS) PURE; STDMETHOD(Present)(THIS_ CONST RECT * pSourceRect,CONST RECT * pDestRect,HWND hDestWindowOverride,CONST RGNDATA * pDirtyRegion) PURE; @@ -311,6 +326,11 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown) #define IWineD3DDevice_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) #define IWineD3DDevice_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) #define IWineD3DDevice_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IWineD3DDevice_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IWineD3DDevice_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IWineD3DDevice_GetBackBuffer(p,a,b,c,d) (p)->lpVtbl->GetBackBuffer(p,a,b,c,d) +#define IWineD3DDevice_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) +#define IWineD3DDevice_GetDisplayMode(p,a,b) (p)->lpVtbl->GetDisplayMode(p,a,b) #define IWineD3DDevice_BeginScene(p) (p)->lpVtbl->BeginScene(p) #define IWineD3DDevice_EndScene(p) (p)->lpVtbl->EndScene(p) #define IWineD3DDevice_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d)