From 88f705532312a3d346b1b8023d2d050f8fb91f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Wed, 2 Dec 2009 11:21:13 +0100 Subject: [PATCH 03/19] WineD3D: A function for checking if a surface is offscreen --- dlls/wined3d/device.c | 6 +++--- dlls/wined3d/surface.c | 30 +++++++++++++++++++++--------- dlls/wined3d/wined3d_private.h | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 58775e1..fe4bb4d 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -5674,7 +5674,7 @@ static void color_fill_fbo(IWineD3DDevice *iface, IWineD3DSurface *surface, IWineD3DSwapChain *swapchain; swapchain = get_swapchain(surface); - if (swapchain) { + if (!surface_is_offscreen(surface)) { GLenum buffer; TRACE("Surface %p is onscreen\n", surface); @@ -6086,7 +6086,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED gl_info = context->gl_info; - if (src_swapchain) { + if (!surface_is_offscreen(src_surface)) { GLenum buffer = surface_get_gl_buffer(src_surface, src_swapchain); TRACE("Source surface %p is onscreen\n", src_surface); @@ -6124,7 +6124,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED LEAVE_GL(); /* Attach dst surface to dst fbo */ - if (dst_swapchain) { + if (!surface_is_offscreen(dst_surface)) { GLenum buffer = surface_get_gl_buffer(dst_surface, dst_swapchain); TRACE("Destination surface %p is onscreen\n", dst_surface); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index a98cf49..cdc3286 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1770,7 +1770,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ *internal = glDesc->glGammaInternal; } else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET - && !(This->Flags & SFLAG_SWAPCHAIN)) + && surface_is_offscreen((IWineD3DSurface *) This)) { *internal = glDesc->rtInternal; } else { @@ -4562,13 +4562,15 @@ static void WINAPI IWineD3DSurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DW persistent ? "TRUE" : "FALSE"); if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { - if (This->Flags & SFLAG_SWAPCHAIN) + if (surface_is_offscreen(iface)) { - TRACE("Surface %p is an onscreen surface\n", iface); - } else { /* 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); } + else + { + TRACE("Surface %p is an onscreen surface\n", iface); + } } if(persistent) { @@ -4829,16 +4831,20 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D int width, pitch, outpitch; BYTE *mem; BOOL drawable_read_ok = TRUE; + BOOL in_fbo = FALSE; if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) { - if (This->Flags & SFLAG_SWAPCHAIN) + if (surface_is_offscreen(iface)) { - TRACE("Surface %p is an onscreen surface\n", iface); - } else { /* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. * Prefer SFLAG_INTEXTURE. */ if (flag == SFLAG_INDRAWABLE) flag = SFLAG_INTEXTURE; drawable_read_ok = FALSE; + in_fbo = TRUE; + } + else + { + TRACE("Surface %p is an onscreen surface\n", iface); } } @@ -5063,8 +5069,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D This->Flags |= flag; } - if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && !(This->Flags & SFLAG_SWAPCHAIN) - && (This->Flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE))) { + if (in_fbo && (This->Flags & (SFLAG_INTEXTURE | SFLAG_INDRAWABLE))) { /* With ORM_FBO, SFLAG_INTEXTURE and SFLAG_INDRAWABLE are the same for offscreen targets. */ This->Flags |= (SFLAG_INTEXTURE | SFLAG_INDRAWABLE); } @@ -5121,6 +5126,13 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_DrawOverlay(IWineD3DSurface *iface) { return hr; } +BOOL surface_is_offscreen(IWineD3DSurface *iface) +{ + IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; + + return !(This->Flags & SFLAG_SWAPCHAIN); +} + const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl = { /* IUnknown */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 4744c2e..a64691c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1726,6 +1726,7 @@ typedef struct IWineD3DBaseTextureClass void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN; BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN; +BOOL surface_is_offscreen(IWineD3DSurface *iface) DECLSPEC_HIDDEN; typedef struct IWineD3DBaseTextureImpl { -- 1.6.4.4