Commit eb24c957 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Keep a reference to the resource in rendertarget views.

parent 3a160432
......@@ -1113,8 +1113,20 @@ void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer)
}
}
static ULONG buffer_resource_incref(struct wined3d_resource *resource)
{
return wined3d_buffer_incref(buffer_from_resource(resource));
}
static ULONG buffer_resource_decref(struct wined3d_resource *resource)
{
return wined3d_buffer_decref(buffer_from_resource(resource));
}
static const struct wined3d_resource_ops buffer_resource_ops =
{
buffer_resource_incref,
buffer_resource_decref,
buffer_unload,
};
......
......@@ -1158,6 +1158,16 @@ static void surface_remove_pbo(struct wined3d_surface *surface, const struct win
surface_invalidate_location(surface, WINED3D_LOCATION_BUFFER);
}
static ULONG surface_resource_incref(struct wined3d_resource *resource)
{
return wined3d_surface_incref(surface_from_resource(resource));
}
static ULONG surface_resource_decref(struct wined3d_resource *resource)
{
return wined3d_surface_decref(surface_from_resource(resource));
}
static void surface_unload(struct wined3d_resource *resource)
{
struct wined3d_surface *surface = surface_from_resource(resource);
......@@ -1236,6 +1246,8 @@ static void surface_unload(struct wined3d_resource *resource)
static const struct wined3d_resource_ops surface_resource_ops =
{
surface_resource_incref,
surface_resource_decref,
surface_unload,
};
......
......@@ -771,6 +771,16 @@ static const struct wined3d_texture_ops texture2d_ops =
texture2d_sub_resource_cleanup,
};
static ULONG texture_resource_incref(struct wined3d_resource *resource)
{
return wined3d_texture_incref(wined3d_texture_from_resource(resource));
}
static ULONG texture_resource_decref(struct wined3d_resource *resource)
{
return wined3d_texture_decref(wined3d_texture_from_resource(resource));
}
static void wined3d_texture_unload(struct wined3d_resource *resource)
{
struct wined3d_texture *texture = wined3d_texture_from_resource(resource);
......@@ -791,6 +801,8 @@ static void wined3d_texture_unload(struct wined3d_resource *resource)
static const struct wined3d_resource_ops texture_resource_ops =
{
texture_resource_incref,
texture_resource_decref,
wined3d_texture_unload,
};
......
......@@ -40,7 +40,10 @@ ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *v
TRACE("%p decreasing refcount to %u.\n", view, refcount);
if (!refcount)
{
wined3d_resource_decref(view->resource);
HeapFree(GetProcessHeap(), 0, view);
}
return refcount;
}
......@@ -64,6 +67,7 @@ static void wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *vie
{
view->refcount = 1;
view->resource = resource;
wined3d_resource_incref(resource);
view->parent = parent;
}
......
......@@ -772,8 +772,20 @@ HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume)
return WINED3D_OK;
}
static ULONG volume_resource_incref(struct wined3d_resource *resource)
{
return wined3d_volume_incref(volume_from_resource(resource));
}
static ULONG volume_resource_decref(struct wined3d_resource *resource)
{
return wined3d_volume_decref(volume_from_resource(resource));
}
static const struct wined3d_resource_ops volume_resource_ops =
{
volume_resource_incref,
volume_resource_decref,
volume_unload,
};
......
......@@ -2020,6 +2020,8 @@ static inline void context_invalidate_active_texture(struct wined3d_context *con
struct wined3d_resource_ops
{
ULONG (*resource_incref)(struct wined3d_resource *resource);
ULONG (*resource_decref)(struct wined3d_resource *resource);
void (*resource_unload)(struct wined3d_resource *resource);
};
......@@ -2051,6 +2053,16 @@ struct wined3d_resource
const struct wined3d_resource_ops *resource_ops;
};
static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
{
return resource->resource_ops->resource_incref(resource);
}
static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
{
return resource->resource_ops->resource_decref(resource);
}
void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
enum wined3d_resource_type type, const struct wined3d_format *format,
......
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