Commit fb752928 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Don't store user memory in allocatedMemory.

parent a1762ba8
......@@ -88,9 +88,6 @@ static void surface_cleanup(struct wined3d_surface *surface)
surface->resource.allocatedMemory = NULL;
}
if (surface->flags & SFLAG_USERPTR)
surface->resource.allocatedMemory = NULL;
if (surface->overlay_dest)
list_remove(&surface->overlay_entry);
......@@ -497,7 +494,7 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
memcpy(surface->dib.bitmap_data, surface->resource.allocatedMemory,
surface->resource.height * wined3d_surface_get_pitch(surface));
}
else
else if (!surface->user_memory)
{
/* This is to make maps read the GL texture although memory is allocated. */
surface->flags &= ~SFLAG_INSYSMEM;
......@@ -519,16 +516,20 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
static void surface_get_memory(const struct wined3d_surface *surface, struct wined3d_bo_address *data)
{
if (surface->user_memory)
{
data->addr = surface->user_memory;
data->buffer_object = 0;
return;
}
if (surface->flags & SFLAG_PBO)
{
data->addr = NULL;
data->buffer_object = surface->pbo;
return;
}
else
{
data->addr = surface->resource.allocatedMemory;
data->buffer_object = 0;
}
data->addr = surface->resource.allocatedMemory;
data->buffer_object = 0;
}
static BOOL surface_need_pbo(const struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
......@@ -587,7 +588,8 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
if (!(surface->flags & SFLAG_PBO) && surface_need_pbo(surface, gl_info))
surface_create_pbo(surface, gl_info);
else if (!(surface->resource.allocatedMemory || surface->flags & SFLAG_PBO))
else if (!(surface->resource.allocatedMemory || surface->flags & SFLAG_PBO
|| surface->user_memory))
{
/* Whatever surface we have, make sure that there is memory allocated
* for the downloaded copy, or a PBO to map. */
......@@ -831,6 +833,9 @@ static BYTE *surface_map(struct wined3d_surface *surface, const RECT *rect, DWOR
return ret;
}
if (surface->user_memory)
return surface->user_memory;
return surface->resource.allocatedMemory;
}
......@@ -1296,7 +1301,11 @@ static void surface_remove_pbo(struct wined3d_surface *surface, const struct win
static BOOL surface_init_sysmem(struct wined3d_surface *surface)
{
if (!surface->resource.allocatedMemory)
if (surface->resource.allocatedMemory)
{
memset(surface->resource.allocatedMemory, 0, surface->resource.size);
}
else if (!surface->user_memory)
{
if (!surface->resource.heap_memory)
{
......@@ -1314,10 +1323,6 @@ static BOOL surface_init_sysmem(struct wined3d_surface *surface)
surface->resource.allocatedMemory = surface->resource.heap_memory;
}
else
{
memset(surface->resource.allocatedMemory, 0, surface->resource.size);
}
surface_validate_location(surface, SFLAG_INSYSMEM);
surface_invalidate_location(surface, ~SFLAG_INSYSMEM);
......@@ -1491,6 +1496,9 @@ static BYTE *gdi_surface_map(struct wined3d_surface *surface, const RECT *rect,
TRACE("surface %p, rect %s, flags %#x.\n",
surface, wine_dbgstr_rect(rect), flags);
if (surface->user_memory)
return surface->user_memory;
return surface->resource.allocatedMemory;
}
......@@ -2611,7 +2619,7 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
return WINED3DERR_INVALIDCALL;
}
if (mem && mem != surface->resource.allocatedMemory)
if (mem && mem != surface->user_memory)
{
/* Do I have to copy the old surface content? */
if (surface->flags & SFLAG_DIBSECTION)
......@@ -2626,8 +2634,9 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
else if (!(surface->flags & SFLAG_USERPTR))
{
wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = NULL;
}
surface->resource.allocatedMemory = mem;
surface->user_memory = mem;
surface->flags |= SFLAG_USERPTR;
/* Now the surface memory is most up do date. Invalidate drawable and texture. */
......@@ -2646,7 +2655,7 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
if (!mem)
{
surface->resource.allocatedMemory = NULL;
surface->user_memory = NULL;
surface->flags &= ~(SFLAG_USERPTR | SFLAG_INSYSMEM);
if (surface->flags & SFLAG_CLIENT)
......
......@@ -2186,6 +2186,7 @@ struct wined3d_surface
struct wined3d_swapchain *swapchain;
struct wined3d_palette *palette; /* D3D7 style palette handling */
DWORD draw_binding;
void *user_memory;
DWORD flags;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment