Henri Verbeet : wined3d: Pass a resource to wined3d_resource_free_sysmem().
Alexandre Julliard
julliard at winehq.org
Mon Sep 16 16:57:22 CDT 2013
Module: wine
Branch: master
Commit: d1e44ff77595a0d60c409b22fdaf76771b1e6841
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d1e44ff77595a0d60c409b22fdaf76771b1e6841
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Mon Sep 16 10:57:25 2013 +0200
wined3d: Pass a resource to wined3d_resource_free_sysmem().
---
dlls/wined3d/buffer.c | 3 +--
dlls/wined3d/resource.c | 12 ++++++------
dlls/wined3d/surface.c | 34 +++++++++-------------------------
dlls/wined3d/volume.c | 6 ++----
dlls/wined3d/wined3d_private.h | 3 +--
5 files changed, 19 insertions(+), 39 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index b61c3ce..de06ae8 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -198,9 +198,8 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wine
}
else
{
- wined3d_resource_free_sysmem(This->resource.heap_memory);
+ wined3d_resource_free_sysmem(&This->resource);
This->resource.allocatedMemory = NULL;
- This->resource.heap_memory = NULL;
}
return;
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 78f35e9..a24db3c 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -138,7 +138,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
if (size > wined3d_device_get_available_texture_mem(device))
{
ERR("Out of adapter memory\n");
- wined3d_resource_free_sysmem(resource->heap_memory);
+ wined3d_resource_free_sysmem(resource);
return WINED3DERR_OUTOFVIDEOMEMORY;
}
adapter_adjust_memory(device->adapter, size);
@@ -172,9 +172,8 @@ void resource_cleanup(struct wined3d_resource *resource)
ERR("Failed to free private data when destroying resource %p, hr = %#x.\n", resource, hr);
}
- wined3d_resource_free_sysmem(resource->heap_memory);
+ wined3d_resource_free_sysmem(resource);
resource->allocatedMemory = NULL;
- resource->heap_memory = NULL;
device_resource_released(resource->device, resource);
}
@@ -360,14 +359,15 @@ BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
return TRUE;
}
-void wined3d_resource_free_sysmem(void *mem)
+void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
{
- void **p = mem;
+ void **p = resource->heap_memory;
- if (!mem)
+ if (!p)
return;
HeapFree(GetProcessHeap(), 0, *(--p));
+ resource->heap_memory = NULL;
}
DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource, DWORD flags)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index e40a65a..a48d0bf 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -566,10 +566,7 @@ static void surface_load_pbo(struct wined3d_surface *surface, const struct wined
/* We don't need the system memory anymore and we can't even use it for PBOs. */
if (!(surface->flags & SFLAG_CLIENT))
- {
- wined3d_resource_free_sysmem(surface->resource.heap_memory);
- surface->resource.heap_memory = NULL;
- }
+ wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = NULL;
surface->flags |= SFLAG_PBO;
context_release(context);
@@ -601,9 +598,8 @@ static void surface_evict_sysmem(struct wined3d_surface *surface)
if (surface->resource.map_count || (surface->flags & SFLAG_DONOTFREE))
return;
- wined3d_resource_free_sysmem(surface->resource.heap_memory);
+ wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = NULL;
- surface->resource.heap_memory = NULL;
surface_invalidate_location(surface, SFLAG_INSYSMEM);
}
@@ -1611,8 +1607,7 @@ static HRESULT gdi_surface_private_setup(struct wined3d_surface *surface)
hr = surface_create_dib_section(surface);
if (SUCCEEDED(hr))
{
- wined3d_resource_free_sysmem(surface->resource.heap_memory);
- surface->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
@@ -1671,8 +1666,7 @@ static void gdi_surface_map(struct wined3d_surface *surface, const RECT *rect, D
ERR("Failed to create dib section, hr %#x.\n", hr);
return;
}
- wined3d_resource_free_sysmem(surface->resource.heap_memory);
- surface->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
}
@@ -2867,8 +2861,6 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
if (mem && mem != surface->resource.allocatedMemory)
{
- void *release = NULL;
-
/* Do I have to copy the old surface content? */
if (surface->flags & SFLAG_DIBSECTION)
{
@@ -2881,8 +2873,7 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
}
else if (!(surface->flags & SFLAG_USERPTR))
{
- release = surface->resource.heap_memory;
- surface->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&surface->resource);
}
surface->resource.allocatedMemory = mem;
surface->flags |= SFLAG_USERPTR;
@@ -2894,9 +2885,6 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem
/* For client textures OpenGL has to be notified. */
if (surface->flags & SFLAG_CLIENT)
surface_release_client_storage(surface);
-
- /* Now free the old memory if any. */
- wined3d_resource_free_sysmem(release);
}
else if (surface->flags & SFLAG_USERPTR)
{
@@ -3086,8 +3074,7 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
surface->flags &= ~(SFLAG_LOCATIONS | SFLAG_USERPTR);
surface->resource.allocatedMemory = NULL;
- wined3d_resource_free_sysmem(surface->resource.heap_memory);
- surface->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&surface->resource);
surface->resource.width = width;
surface->resource.height = height;
@@ -3583,8 +3570,7 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
/* Use the DIB section from now on if we are not using a PBO. */
if (!(surface->flags & (SFLAG_PBO | SFLAG_PIN_SYSMEM)))
{
- wined3d_resource_free_sysmem(surface->resource.heap_memory);
- surface->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
}
@@ -5004,9 +4990,8 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE
if (!dst_surface->resource.map_count && !(dst_surface->flags & SFLAG_DONOTFREE))
{
- wined3d_resource_free_sysmem(dst_surface->resource.heap_memory);
+ wined3d_resource_free_sysmem(&dst_surface->resource);
dst_surface->resource.allocatedMemory = NULL;
- dst_surface->resource.heap_memory = NULL;
}
else
{
@@ -6933,8 +6918,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, UINT alignment, UIN
if ((usage & WINED3DUSAGE_OWNDC) && !surface->hDC
&& SUCCEEDED(surface_create_dib_section(surface)))
{
- wined3d_resource_free_sysmem(surface->resource.heap_memory);
- surface->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 62c6ab9..4865c59 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -142,8 +142,7 @@ static void wined3d_volume_download_data(struct wined3d_volume *volume,
static void wined3d_volume_evict_sysmem(struct wined3d_volume *volume)
{
- wined3d_resource_free_sysmem(volume->resource.heap_memory);
- volume->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&volume->resource);
volume->resource.allocatedMemory = NULL;
wined3d_volume_invalidate_location(volume, WINED3D_LOCATION_SYSMEM);
}
@@ -702,8 +701,7 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device
if (pool == WINED3D_POOL_DEFAULT && usage & WINED3DUSAGE_DYNAMIC
&& gl_info->supported[ARB_PIXEL_BUFFER_OBJECT])
{
- wined3d_resource_free_sysmem(volume->resource.heap_memory);
- volume->resource.heap_memory = NULL;
+ wined3d_resource_free_sysmem(&volume->resource);
volume->resource.allocatedMemory = NULL;
volume->flags |= WINED3D_VFLAG_PBO;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cbf6e78..07e8c9b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1984,8 +1984,6 @@ struct wined3d_resource_ops
void (*resource_unload)(struct wined3d_resource *resource);
};
-void wined3d_resource_free_sysmem(void *mem) DECLSPEC_HIDDEN;
-
struct wined3d_resource
{
LONG ref;
@@ -2025,6 +2023,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
DWORD resource_set_priority(struct wined3d_resource *resource, DWORD priority) DECLSPEC_HIDDEN;
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource,
DWORD flags) DECLSPEC_HIDDEN;
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list