renderer: unref resource when destroying hashtable element

Resources are reference-counted, if another object holds a reference to
a resource, it should not free it. Change the resource hashtable destroy
callback to unref.

Currently, this doesn't happen, since the resource hashtable is kept
until the renderer is reset. However, in the next commit, the destroy
callback will be used if a resource is replaced in the hashtable, and we
want to keep the original resource. Furthermore, even if replace
shouldn't happen, it avoids confusion and future errors if use only
reference-counting mechanism.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
macos/master
Marc-André Lureau 9 years ago committed by Dave Airlie
parent 3ff41ae384
commit dcc83cca07
  1. 2
      src/vrend_renderer.c

@ -4236,6 +4236,8 @@ void vrend_renderer_resource_destroy(struct vrend_resource *res, bool remove)
static void vrend_destroy_resource_object(void *obj_ptr) static void vrend_destroy_resource_object(void *obj_ptr)
{ {
struct vrend_resource *res = obj_ptr; struct vrend_resource *res = obj_ptr;
if (pipe_reference(&res->base.reference, NULL))
vrend_renderer_resource_destroy(res, false); vrend_renderer_resource_destroy(res, false);
} }

Loading…
Cancel
Save