wined3d: Simply pass an IWineD3DSurfaceImpl pointer to surface_internal_preload().

This commit is contained in:
Henri Verbeet 2010-04-26 11:02:34 +02:00 committed by Alexandre Julliard
parent c56d3c199c
commit d1ea48b971
5 changed files with 32 additions and 28 deletions

View File

@ -6906,7 +6906,7 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
RECT dst_rect = *dst_rect_in; RECT dst_rect = *dst_rect_in;
/* Now load the surface */ /* Now load the surface */
surface_internal_preload((IWineD3DSurface *)src_surface, SRGB_RGB); surface_internal_preload(src_surface, SRGB_RGB);
/* Activate the destination context, set it up for blitting */ /* Activate the destination context, set it up for blitting */
context = context_acquire(device, dst_surface, CTXUSAGE_BLIT); context = context_acquire(device, dst_surface, CTXUSAGE_BLIT);

View File

@ -2003,7 +2003,7 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI
if (context->render_offscreen) if (context->render_offscreen)
{ {
FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n"); FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n");
surface_internal_preload((IWineD3DSurface *)context->current_rt, SRGB_RGB); surface_internal_preload(context->current_rt, SRGB_RGB);
ENTER_GL(); ENTER_GL();
context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo); context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
@ -2149,11 +2149,11 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
/* Read the back buffer of the old drawable into the destination texture. */ /* Read the back buffer of the old drawable into the destination texture. */
if (context->current_rt->texture_name_srgb) if (context->current_rt->texture_name_srgb)
{ {
surface_internal_preload((IWineD3DSurface *)context->current_rt, SRGB_BOTH); surface_internal_preload(context->current_rt, SRGB_BOTH);
} }
else else
{ {
surface_internal_preload((IWineD3DSurface *)context->current_rt, SRGB_RGB); surface_internal_preload(context->current_rt, SRGB_RGB);
} }
IWineD3DSurface_ModifyLocation((IWineD3DSurface *)context->current_rt, SFLAG_INDRAWABLE, FALSE); IWineD3DSurface_ModifyLocation((IWineD3DSurface *)context->current_rt, SFLAG_INDRAWABLE, FALSE);

View File

@ -5247,7 +5247,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
LEAVE_GL(); LEAVE_GL();
/* Make sure the surface is loaded and up to date */ /* Make sure the surface is loaded and up to date */
surface_internal_preload(dst_surface, SRGB_RGB); surface_internal_preload(dst_impl, SRGB_RGB);
IWineD3DSurface_BindTexture(dst_surface, FALSE); IWineD3DSurface_BindTexture(dst_surface, FALSE);
src_w = src_impl->currentDesc.Width; src_w = src_impl->currentDesc.Width;

View File

@ -1071,15 +1071,16 @@ static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
IWineD3DSurface IWineD3DResource parts follow IWineD3DSurface IWineD3DResource parts follow
**************************************************** */ **************************************************** */
void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srgb)
{ {
/* TODO: check for locks */ /* TODO: check for locks */
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DDeviceImpl *device = surface->resource.device;
IWineD3DDeviceImpl *device = This->resource.device;
IWineD3DBaseTexture *baseTexture = NULL; IWineD3DBaseTexture *baseTexture = NULL;
TRACE("(%p)Checking to see if the container is a base texture\n", This); TRACE("(%p)Checking to see if the container is a base texture\n", surface);
if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == WINED3D_OK) { if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)surface,
&IID_IWineD3DBaseTexture, (void **)&baseTexture)))
{
IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *)baseTexture; IWineD3DBaseTextureImpl *tex_impl = (IWineD3DBaseTextureImpl *)baseTexture;
TRACE("Passing to container\n"); TRACE("Passing to container\n");
tex_impl->baseTexture.internal_preload(baseTexture, srgb); tex_impl->baseTexture.internal_preload(baseTexture, srgb);
@ -1087,30 +1088,32 @@ void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb)
} else { } else {
struct wined3d_context *context = NULL; struct wined3d_context *context = NULL;
TRACE("(%p) : About to load surface\n", This); TRACE("(%p) : About to load surface\n", surface);
if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
if (This->resource.format_desc->format == WINED3DFMT_P8_UINT if (surface->resource.format_desc->format == WINED3DFMT_P8_UINT
|| This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM) || surface->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
{
if (palette9_changed(surface))
{ {
if(palette9_changed(This)) {
TRACE("Reloading surface because the d3d8/9 palette was changed\n"); TRACE("Reloading surface because the d3d8/9 palette was changed\n");
/* TODO: This is not necessarily needed with hw palettized texture support */ /* TODO: This is not necessarily needed with hw palettized texture support */
IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL); IWineD3DSurface_LoadLocation((IWineD3DSurface *)surface, SFLAG_INSYSMEM, NULL);
/* Make sure the texture is reloaded because of the palette change, this kills performance though :( */ /* Make sure the texture is reloaded because of the palette change, this kills performance though :( */
IWineD3DSurface_ModifyLocation(iface, SFLAG_INTEXTURE, FALSE); IWineD3DSurface_ModifyLocation((IWineD3DSurface *)surface, SFLAG_INTEXTURE, FALSE);
} }
} }
IWineD3DSurface_LoadTexture(iface, srgb == SRGB_SRGB ? TRUE : FALSE); IWineD3DSurface_LoadTexture((IWineD3DSurface *)surface, srgb == SRGB_SRGB ? TRUE : FALSE);
if (This->resource.pool == WINED3DPOOL_DEFAULT) { if (surface->resource.pool == WINED3DPOOL_DEFAULT)
{
/* Tell opengl to try and keep this texture in video ram (well mostly) */ /* Tell opengl to try and keep this texture in video ram (well mostly) */
GLclampf tmp; GLclampf tmp;
tmp = 0.9f; tmp = 0.9f;
ENTER_GL(); ENTER_GL();
glPrioritizeTextures(1, &This->texture_name, &tmp); glPrioritizeTextures(1, &surface->texture_name, &tmp);
LEAVE_GL(); LEAVE_GL();
} }
@ -1118,8 +1121,9 @@ void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb)
} }
} }
static void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) { static void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface)
surface_internal_preload(iface, SRGB_ANY); {
surface_internal_preload((IWineD3DSurfaceImpl *)iface, SRGB_ANY);
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
@ -2707,7 +2711,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, c
LEAVE_GL(); LEAVE_GL();
} else { /* bind the real texture, and make sure it up to date */ } else { /* bind the real texture, and make sure it up to date */
surface_internal_preload(iface, SRGB_RGB); surface_internal_preload(This, SRGB_RGB);
surface_bind_and_dirtify(This, FALSE); surface_bind_and_dirtify(This, FALSE);
} }
allocatedMemory = HeapAlloc(GetProcessHeap(), 0, width * height * 4); allocatedMemory = HeapAlloc(GetProcessHeap(), 0, width * height * 4);
@ -3009,7 +3013,7 @@ static void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *dst_surface, IWineD3D
} }
context = context_acquire(device, src_surface, CTXUSAGE_BLIT); context = context_acquire(device, src_surface, CTXUSAGE_BLIT);
surface_internal_preload((IWineD3DSurface *)dst_surface, SRGB_RGB); surface_internal_preload(dst_surface, SRGB_RGB);
ENTER_GL(); ENTER_GL();
/* Bind the target texture */ /* Bind the target texture */
@ -3117,14 +3121,14 @@ static void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *dst_surface, IWine
TRACE("Using hwstretch blit\n"); TRACE("Using hwstretch blit\n");
/* Activate the Proper context for reading from the source surface, set it up for blitting */ /* Activate the Proper context for reading from the source surface, set it up for blitting */
context = context_acquire(device, src_surface, CTXUSAGE_BLIT); context = context_acquire(device, src_surface, CTXUSAGE_BLIT);
surface_internal_preload((IWineD3DSurface *)dst_surface, SRGB_RGB); surface_internal_preload(dst_surface, SRGB_RGB);
src_offscreen = surface_is_offscreen(src_surface); src_offscreen = surface_is_offscreen(src_surface);
noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO; noBackBufferBackup = src_offscreen && wined3d_settings.offscreen_rendering_mode == ORM_FBO;
if (!noBackBufferBackup && !src_surface->texture_name) if (!noBackBufferBackup && !src_surface->texture_name)
{ {
/* Get it a description */ /* Get it a description */
surface_internal_preload((IWineD3DSurface *)src_surface, SRGB_RGB); surface_internal_preload(src_surface, SRGB_RGB);
} }
ENTER_GL(); ENTER_GL();
@ -3657,7 +3661,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
} }
/* Now load the surface */ /* Now load the surface */
surface_internal_preload((IWineD3DSurface *) Src, SRGB_RGB); surface_internal_preload(Src, SRGB_RGB);
/* Activate the destination context, set it up for blitting */ /* Activate the destination context, set it up for blitting */
context = context_acquire(device, This, CTXUSAGE_BLIT); context = context_acquire(device, This, CTXUSAGE_BLIT);

View File

@ -1872,7 +1872,7 @@ typedef struct IWineD3DBaseTextureClass
void (*internal_preload)(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb); void (*internal_preload)(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb);
} IWineD3DBaseTextureClass; } IWineD3DBaseTextureClass;
void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN; void surface_internal_preload(IWineD3DSurfaceImpl *surface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN; BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
BOOL surface_is_offscreen(IWineD3DSurfaceImpl *iface) DECLSPEC_HIDDEN; BOOL surface_is_offscreen(IWineD3DSurfaceImpl *iface) DECLSPEC_HIDDEN;
void surface_prepare_texture(IWineD3DSurfaceImpl *surface, void surface_prepare_texture(IWineD3DSurfaceImpl *surface,