From: Marek Olšák Date: Wed, 5 May 2021 17:39:20 +0000 (-0400) Subject: nouveau: stop using u_resource_vtbl::resource_destroy X-Git-Tag: upstream/21.2.3~3091 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6d843c284d6281e13f2cf07c06a7096f16a066d7;p=platform%2Fupstream%2Fmesa.git nouveau: stop using u_resource_vtbl::resource_destroy Acked-By: Mike Blumenkrantz Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c index 92d3765..df99d0f 100644 --- a/src/gallium/drivers/nouveau/nouveau_buffer.c +++ b/src/gallium/drivers/nouveau/nouveau_buffer.c @@ -112,12 +112,17 @@ nouveau_buffer_reallocate(struct nouveau_screen *screen, return nouveau_buffer_allocate(screen, buf, domain); } -static void +void nouveau_buffer_destroy(struct pipe_screen *pscreen, struct pipe_resource *presource) { struct nv04_resource *res = nv04_resource(presource); + if (res->status & NOUVEAU_BUFFER_STATUS_USER_PTR) { + FREE(res); + return; + } + nouveau_buffer_release_gpu_storage(res); if (res->data && !(res->status & NOUVEAU_BUFFER_STATUS_USER_MEMORY)) @@ -630,19 +635,11 @@ nouveau_resource_map_offset(struct nouveau_context *nv, const struct u_resource_vtbl nouveau_buffer_vtbl = { - nouveau_buffer_destroy, /* resource_destroy */ + NULL, /* resource_destroy */ nouveau_buffer_transfer_map, /* transfer_map */ nouveau_buffer_transfer_unmap, /* transfer_unmap */ }; -static void -nouveau_user_ptr_destroy(struct pipe_screen *pscreen, - struct pipe_resource *presource) -{ - struct nv04_resource *res = nv04_resource(presource); - FREE(res); -} - static void * nouveau_user_ptr_transfer_map(struct pipe_context *pipe, struct pipe_resource *resource, @@ -668,7 +665,7 @@ nouveau_user_ptr_transfer_unmap(struct pipe_context *pipe, const struct u_resource_vtbl nouveau_user_ptr_buffer_vtbl = { - nouveau_user_ptr_destroy, /* resource_destroy */ + NULL, /* resource_destroy */ nouveau_user_ptr_transfer_map, /* transfer_map */ nouveau_user_ptr_transfer_unmap, /* transfer_unmap */ }; diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.h b/src/gallium/drivers/nouveau/nouveau_buffer.h index 4157c69..509e654 100644 --- a/src/gallium/drivers/nouveau/nouveau_buffer.h +++ b/src/gallium/drivers/nouveau/nouveau_buffer.h @@ -72,6 +72,10 @@ nouveau_resource_map_offset(struct nouveau_context *, struct nv04_resource *, uint32_t offset, uint32_t flags); void +nouveau_buffer_destroy(struct pipe_screen *pscreen, + struct pipe_resource *presource); + +void nouveau_buffer_transfer_flush_region(struct pipe_context *pipe, struct pipe_transfer *transfer, const struct pipe_box *box); diff --git a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c index ae93241..587d4b3 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c @@ -67,7 +67,7 @@ nv30_miptree_get_handle(struct pipe_screen *pscreen, return nouveau_screen_bo_get_handle(pscreen, mt->base.bo, stride, handle); } -static void +void nv30_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt) { struct nv30_miptree *mt = nv30_miptree(pt); @@ -403,7 +403,7 @@ nv30_miptree_transfer_unmap(struct pipe_context *pipe, } const struct u_resource_vtbl nv30_miptree_vtbl = { - nv30_miptree_destroy, + NULL, nv30_miptree_transfer_map, nv30_miptree_transfer_unmap, }; diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.c b/src/gallium/drivers/nouveau/nv30/nv30_resource.c index ff18596..53bd879 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c @@ -59,6 +59,15 @@ nv30_resource_create(struct pipe_screen *pscreen, } } +static void +nv30_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *res) +{ + if (res->target == PIPE_BUFFER) + nouveau_buffer_destroy(pscreen, res); + else + nv30_miptree_destroy(pscreen, res); +} + static struct pipe_resource * nv30_resource_from_handle(struct pipe_screen *pscreen, const struct pipe_resource *tmpl, @@ -77,7 +86,7 @@ nv30_resource_screen_init(struct pipe_screen *pscreen) pscreen->resource_create = nv30_resource_create; pscreen->resource_from_handle = nv30_resource_from_handle; pscreen->resource_get_handle = nv30_miptree_get_handle; - pscreen->resource_destroy = u_resource_destroy_vtbl; + pscreen->resource_destroy = nv30_resource_destroy; } void diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.h b/src/gallium/drivers/nouveau/nv30/nv30_resource.h index c04e999..1a541e3 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.h +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.h @@ -66,6 +66,9 @@ nv30_miptree_get_handle(struct pipe_screen *pscreen, unsigned usage); void +nv30_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt); + +void nv30_resource_copy_region(struct pipe_context *pipe, struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c index 9155849..fba6718 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c @@ -204,7 +204,7 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen, const struct u_resource_vtbl nv50_miptree_vtbl = { - nv50_miptree_destroy, /* resource_destroy */ + NULL, /* resource_destroy */ nv50_miptree_transfer_map, /* transfer_map */ nv50_miptree_transfer_unmap, /* transfer_unmap */ }; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_resource.c b/src/gallium/drivers/nouveau/nv50/nv50_resource.c index 79d48ae..bb68227 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_resource.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_resource.c @@ -19,6 +19,15 @@ nv50_resource_create(struct pipe_screen *screen, } } +static void +nv50_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *res) +{ + if (res->target == PIPE_BUFFER) + nouveau_buffer_destroy(pscreen, res); + else + nv50_miptree_destroy(pscreen, res); +} + static struct pipe_resource * nv50_resource_from_handle(struct pipe_screen * screen, const struct pipe_resource *templ, @@ -110,5 +119,5 @@ nv50_screen_init_resource_functions(struct pipe_screen *pscreen) pscreen->resource_create = nv50_resource_create; pscreen->resource_from_handle = nv50_resource_from_handle; pscreen->resource_get_handle = nv50_miptree_get_handle; - pscreen->resource_destroy = u_resource_destroy_vtbl; + pscreen->resource_destroy = nv50_resource_destroy; } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c index cf6290e..8dc912d 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c @@ -438,7 +438,7 @@ nvc0_miptree_select_best_modifier(struct pipe_screen *pscreen, const struct u_resource_vtbl nvc0_miptree_vtbl = { - nv50_miptree_destroy, /* resource_destroy */ + NULL, /* resource_destroy */ nvc0_miptree_transfer_map, /* transfer_map */ nvc0_miptree_transfer_unmap, /* transfer_unmap */ }; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c index 27c7ee2..fbda9f8 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c @@ -31,6 +31,15 @@ nvc0_resource_create_with_modifiers(struct pipe_screen *screen, } static void +nvc0_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *res) +{ + if (res->target == PIPE_BUFFER) + nouveau_buffer_destroy(pscreen, res); + else + nv50_miptree_destroy(pscreen, res); +} + +static void nvc0_query_dmabuf_modifiers(struct pipe_screen *screen, enum pipe_format format, int max, uint64_t *modifiers, unsigned int *external_only, @@ -164,6 +173,6 @@ nvc0_screen_init_resource_functions(struct pipe_screen *pscreen) pscreen->is_dmabuf_modifier_supported = nvc0_is_dmabuf_modifier_supported; pscreen->resource_from_handle = nvc0_resource_from_handle; pscreen->resource_get_handle = nvc0_miptree_get_handle; - pscreen->resource_destroy = u_resource_destroy_vtbl; + pscreen->resource_destroy = nvc0_resource_destroy; pscreen->resource_from_user_memory = nvc0_resource_from_user_memory; }