wined3d: Add a more convenient way to check if a surface is on a swapchain.

This won't help if we actually need the swapchain, of course.
This commit is contained in:
Henri Verbeet 2009-03-25 10:12:27 +01:00 committed by Alexandre Julliard
parent 42e31a4242
commit 899df56ebe
3 changed files with 20 additions and 20 deletions

View File

@ -1730,6 +1730,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
object->presentParms.MultiSampleQuality, TRUE /* Lockable */, &object->frontBuffer); object->presentParms.MultiSampleQuality, TRUE /* Lockable */, &object->frontBuffer);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
IWineD3DSurface_SetContainer(object->frontBuffer, (IWineD3DBase *)object); IWineD3DSurface_SetContainer(object->frontBuffer, (IWineD3DBase *)object);
((IWineD3DSurfaceImpl *)object->frontBuffer)->Flags |= SFLAG_SWAPCHAIN;
if(surface_type == SURFACE_OPENGL) { if(surface_type == SURFACE_OPENGL) {
IWineD3DSurface_ModifyLocation(object->frontBuffer, SFLAG_INDRAWABLE, TRUE); IWineD3DSurface_ModifyLocation(object->frontBuffer, SFLAG_INDRAWABLE, TRUE);
} }
@ -1812,6 +1813,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
object->presentParms.MultiSampleQuality, TRUE /* Lockable */, &object->backBuffer[i]); object->presentParms.MultiSampleQuality, TRUE /* Lockable */, &object->backBuffer[i]);
if(SUCCEEDED(hr)) { if(SUCCEEDED(hr)) {
IWineD3DSurface_SetContainer(object->backBuffer[i], (IWineD3DBase *)object); IWineD3DSurface_SetContainer(object->backBuffer[i], (IWineD3DBase *)object);
((IWineD3DSurfaceImpl *)object->backBuffer[i])->Flags |= SFLAG_SWAPCHAIN;
} else { } else {
ERR("Cannot create new back buffer\n"); ERR("Cannot create new back buffer\n");
goto error; goto error;
@ -6618,11 +6620,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *ifa
TRACE("Changing the front buffer from %p to %p\n", Swapchain->frontBuffer, Front); TRACE("Changing the front buffer from %p to %p\n", Swapchain->frontBuffer, Front);
if(Swapchain->frontBuffer) if(Swapchain->frontBuffer)
{
IWineD3DSurface_SetContainer(Swapchain->frontBuffer, NULL); IWineD3DSurface_SetContainer(Swapchain->frontBuffer, NULL);
((IWineD3DSurfaceImpl *)Swapchain->frontBuffer)->Flags &= ~SFLAG_SWAPCHAIN;
}
Swapchain->frontBuffer = Front; Swapchain->frontBuffer = Front;
if(Swapchain->frontBuffer) { if(Swapchain->frontBuffer) {
IWineD3DSurface_SetContainer(Swapchain->frontBuffer, (IWineD3DBase *) Swapchain); IWineD3DSurface_SetContainer(Swapchain->frontBuffer, (IWineD3DBase *) Swapchain);
((IWineD3DSurfaceImpl *)Swapchain->frontBuffer)->Flags |= SFLAG_SWAPCHAIN;
} }
} }
@ -6660,11 +6666,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *ifa
LEAVE_GL(); LEAVE_GL();
if(Swapchain->backBuffer[0]) if(Swapchain->backBuffer[0])
{
IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], NULL); IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], NULL);
((IWineD3DSurfaceImpl *)Swapchain->backBuffer[0])->Flags &= ~SFLAG_SWAPCHAIN;
}
Swapchain->backBuffer[0] = Back; Swapchain->backBuffer[0] = Back;
if(Swapchain->backBuffer[0]) { if(Swapchain->backBuffer[0]) {
IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], (IWineD3DBase *) Swapchain); IWineD3DSurface_SetContainer(Swapchain->backBuffer[0], (IWineD3DBase *) Swapchain);
((IWineD3DSurfaceImpl *)Swapchain->backBuffer[0])->Flags |= SFLAG_SWAPCHAIN;
} else { } else {
HeapFree(GetProcessHeap(), 0, Swapchain->backBuffer); HeapFree(GetProcessHeap(), 0, Swapchain->backBuffer);
Swapchain->backBuffer = NULL; Swapchain->backBuffer = NULL;

View File

@ -1120,7 +1120,6 @@ static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This) {
static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) { static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
IWineD3DSwapChain *swapchain = NULL;
TRACE("(%p) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory); TRACE("(%p) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
@ -1157,8 +1156,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
* Use the render target readback if the surface is on a swapchain(=onscreen render target) or the current primary target * Use the render target readback if the surface is on a swapchain(=onscreen render target) or the current primary target
* Offscreen targets which are not active at the moment or are higher targets(FBOs) can be locked with the texture path * Offscreen targets which are not active at the moment or are higher targets(FBOs) can be locked with the texture path
*/ */
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain); if ((This->Flags & SFLAG_SWAPCHAIN) || iface == myDevice->render_targets[0])
if(swapchain || iface == myDevice->render_targets[0]) { {
const RECT *pass_rect = pRect; const RECT *pass_rect = pRect;
/* IWineD3DSurface_LoadLocation does not check if the rectangle specifies the full surfaces /* IWineD3DSurface_LoadLocation does not check if the rectangle specifies the full surfaces
@ -1194,8 +1193,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
case RTL_DISABLE: case RTL_DISABLE:
break; break;
} }
if(swapchain) IWineD3DSwapChain_Release(swapchain);
} else if(iface == myDevice->stencilBufferTarget) { } else if(iface == myDevice->stencilBufferTarget) {
/** the depth stencil in openGL has a format of GL_FLOAT /** the depth stencil in openGL has a format of GL_FLOAT
* which should be good for WINED3DFMT_D16_LOCKABLE * which should be good for WINED3DFMT_D16_LOCKABLE
@ -1376,7 +1373,6 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) { static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
IWineD3DSwapChainImpl *swapchain = NULL;
BOOL fullsurface; BOOL fullsurface;
if (!(This->Flags & SFLAG_LOCKED)) { if (!(This->Flags & SFLAG_LOCKED)) {
@ -1403,10 +1399,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
goto unlock_end; goto unlock_end;
} }
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain); if ((This->Flags & SFLAG_SWAPCHAIN) || (myDevice->render_targets && iface == myDevice->render_targets[0]))
if(swapchain || (myDevice->render_targets && iface == myDevice->render_targets[0])) { {
if(swapchain) IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
if(wined3d_settings.rendertargetlock_mode == RTL_DISABLE) { if(wined3d_settings.rendertargetlock_mode == RTL_DISABLE) {
static BOOL warned = FALSE; static BOOL warned = FALSE;
if(!warned) { if(!warned) {
@ -4220,12 +4214,9 @@ static void WINAPI IWineD3DSurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DW
persistent ? "TRUE" : "FALSE"); persistent ? "TRUE" : "FALSE");
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
IWineD3DSwapChain *swapchain = NULL; if (This->Flags & SFLAG_SWAPCHAIN)
{
if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain))) {
TRACE("Surface %p is an onscreen surface\n", iface); TRACE("Surface %p is an onscreen surface\n", iface);
IWineD3DSwapChain_Release(swapchain);
} else { } else {
/* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. */ /* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. */
if (flag & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)) flag |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE); if (flag & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE)) flag |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE);
@ -4478,7 +4469,6 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) { static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
IWineD3DSwapChain *swapchain = NULL;
GLenum format, internal, type; GLenum format, internal, type;
CONVERT_TYPES convert; CONVERT_TYPES convert;
int bpp; int bpp;
@ -4487,10 +4477,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
BOOL drawable_read_ok = TRUE; BOOL drawable_read_ok = TRUE;
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain))) { if (This->Flags & SFLAG_SWAPCHAIN)
{
TRACE("Surface %p is an onscreen surface\n", iface); TRACE("Surface %p is an onscreen surface\n", iface);
IWineD3DSwapChain_Release(swapchain);
} else { } else {
/* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. /* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets.
* Prefer SFLAG_INTEXTURE. */ * Prefer SFLAG_INTEXTURE. */
@ -4691,7 +4680,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
This->Flags |= flag; This->Flags |= flag;
} }
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && !swapchain if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && !(This->Flags & SFLAG_SWAPCHAIN)
&& (This->Flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE))) { && (This->Flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE))) {
/* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. */ /* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. */
This->Flags |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE); This->Flags |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE);

View File

@ -1643,6 +1643,7 @@ void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back);
#define SFLAG_DS_ONSCREEN 0x00200000 /* Is a depth stencil, last modified onscreen */ #define SFLAG_DS_ONSCREEN 0x00200000 /* Is a depth stencil, last modified onscreen */
#define SFLAG_DS_OFFSCREEN 0x00400000 /* Is a depth stencil, last modified offscreen */ #define SFLAG_DS_OFFSCREEN 0x00400000 /* Is a depth stencil, last modified offscreen */
#define SFLAG_INOVERLAYDRAW 0x00800000 /* Overlay drawing is in progress. Recursion prevention */ #define SFLAG_INOVERLAYDRAW 0x00800000 /* Overlay drawing is in progress. Recursion prevention */
#define SFLAG_SWAPCHAIN 0x01000000 /* The surface is part of a swapchain */
/* In some conditions the surface memory must not be freed: /* In some conditions the surface memory must not be freed:
* SFLAG_OVERSIZE: Not all data can be kept in GL * SFLAG_OVERSIZE: Not all data can be kept in GL