From f6d1dd34d76c1930b6f5223ae7e1c6b7f52ec4cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 5 Feb 2020 14:52:38 -0500 Subject: [PATCH] gallium/hash_table: remove some function wrappers Reviewed-by: Kristian H. Kristensen Tested-by: Marge Bot Part-of: --- .../auxiliary/pipebuffer/pb_validate.c | 2 +- src/gallium/auxiliary/util/u_debug_flush.c | 11 ++-- src/gallium/auxiliary/util/u_debug_refcnt.c | 4 +- src/gallium/auxiliary/util/u_debug_stack.c | 2 +- src/gallium/auxiliary/util/u_debug_symbol.c | 2 +- src/gallium/auxiliary/util/u_hash_table.c | 53 +------------------ src/gallium/auxiliary/util/u_hash_table.h | 37 +------------ src/gallium/drivers/lima/lima_bo.c | 20 +++---- src/gallium/drivers/v3d/v3d_bufmgr.c | 4 +- src/gallium/drivers/v3d/v3d_bufmgr.h | 2 +- src/gallium/drivers/v3d/v3d_screen.c | 2 +- src/gallium/drivers/vc4/vc4_bufmgr.c | 4 +- src/gallium/drivers/vc4/vc4_bufmgr.h | 2 +- src/gallium/drivers/vc4/vc4_screen.c | 2 +- src/gallium/state_trackers/nine/device9.c | 4 +- src/gallium/state_trackers/nine/iunknown.c | 19 +++---- src/gallium/state_trackers/nine/nine_ff.c | 32 +++++------ .../state_trackers/omx/tizonia/h264dprc.c | 4 +- src/gallium/state_trackers/va/context.c | 4 +- .../state_trackers/va/picture_h264_enc.c | 2 +- .../state_trackers/va/picture_hevc_enc.c | 2 +- src/gallium/winsys/amdgpu/drm/amdgpu_bo.c | 6 +-- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 10 ++-- .../winsys/etnaviv/drm/etnaviv_drm_winsys.c | 4 +- .../freedreno/drm/freedreno_drm_winsys.c | 4 +- src/gallium/winsys/lima/drm/lima_drm_winsys.c | 4 +- .../winsys/nouveau/drm/nouveau_drm_winsys.c | 4 +- src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 20 +++---- .../winsys/radeon/drm/radeon_drm_winsys.c | 14 ++--- src/gallium/winsys/svga/drm/vmw_context.c | 20 +++---- src/gallium/winsys/svga/drm/vmw_screen.c | 8 ++- .../winsys/virgl/drm/virgl_drm_winsys.c | 20 +++---- 32 files changed, 108 insertions(+), 220 deletions(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c index df334693c01..404bdfcec51 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_validate.c +++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c @@ -118,7 +118,7 @@ pb_validate_add_buffer(struct pb_validate *vl, ++vl->used; if (ht) - util_hash_table_set(ht, buf, (void *) (unsigned long) vl->used); + _mesa_hash_table_insert(ht, buf, (void *) (unsigned long) vl->used); return PIPE_OK; } diff --git a/src/gallium/auxiliary/util/u_debug_flush.c b/src/gallium/auxiliary/util/u_debug_flush.c index f525d6a5d30..b8f6870f0a1 100644 --- a/src/gallium/auxiliary/util/u_debug_flush.c +++ b/src/gallium/auxiliary/util/u_debug_flush.c @@ -323,10 +323,7 @@ debug_flush_cb_reference(struct debug_flush_ctx *fctx, debug_flush_buf_reference(&item->fbuf, fbuf); item->bt_depth = fctx->bt_depth; item->ref_frame = debug_flush_capture_frame(2, item->bt_depth); - if (util_hash_table_set(fctx->ref_hash, fbuf, item) != PIPE_OK) { - debug_flush_item_destroy(item); - goto out_no_item; - } + _mesa_hash_table_insert(fctx->ref_hash, fbuf, item); return; } goto out_no_item; @@ -409,7 +406,7 @@ debug_flush_flush(struct debug_flush_ctx *fctx) util_hash_table_foreach(fctx->ref_hash, debug_flush_flush_cb, NULL); - util_hash_table_clear(fctx->ref_hash); + _mesa_hash_table_clear(fctx->ref_hash, NULL); } void @@ -422,8 +419,8 @@ debug_flush_ctx_destroy(struct debug_flush_ctx *fctx) util_hash_table_foreach(fctx->ref_hash, debug_flush_flush_cb, NULL); - util_hash_table_clear(fctx->ref_hash); - util_hash_table_destroy(fctx->ref_hash); + _mesa_hash_table_clear(fctx->ref_hash, NULL); + _mesa_hash_table_destroy(fctx->ref_hash, NULL); FREE(fctx); } #endif diff --git a/src/gallium/auxiliary/util/u_debug_refcnt.c b/src/gallium/auxiliary/util/u_debug_refcnt.c index a4612a40f66..e0d2385bec7 100644 --- a/src/gallium/auxiliary/util/u_debug_refcnt.c +++ b/src/gallium/auxiliary/util/u_debug_refcnt.c @@ -90,7 +90,7 @@ debug_serial(void *p, unsigned *pserial) os_abort(); } - util_hash_table_set(serials_hash, p, (void *) (uintptr_t) serial); + _mesa_hash_table_insert(serials_hash, p, (void *) (uintptr_t) serial); found = FALSE; } mtx_unlock(&serials_mutex); @@ -108,7 +108,7 @@ static void debug_serial_delete(void *p) { mtx_lock(&serials_mutex); - util_hash_table_remove(serials_hash, p); + _mesa_hash_table_remove_key(serials_hash, p); mtx_unlock(&serials_mutex); } diff --git a/src/gallium/auxiliary/util/u_debug_stack.c b/src/gallium/auxiliary/util/u_debug_stack.c index 34d493b4cee..44581e0a3fb 100644 --- a/src/gallium/auxiliary/util/u_debug_stack.c +++ b/src/gallium/auxiliary/util/u_debug_stack.c @@ -77,7 +77,7 @@ symbol_name_cached(unw_cursor_t *cursor, unw_proc_info_t *pip) if (asprintf(&name, "%s%s", procname, ret == -UNW_ENOMEM ? "..." : "") == -1) name = "??"; - util_hash_table_set(symbols_hash, addr, (void*)name); + _mesa_hash_table_insert(symbols_hash, addr, (void*)name); } mtx_unlock(&symbols_mutex); diff --git a/src/gallium/auxiliary/util/u_debug_symbol.c b/src/gallium/auxiliary/util/u_debug_symbol.c index a1d4a5f23ae..f576a51fe99 100644 --- a/src/gallium/auxiliary/util/u_debug_symbol.c +++ b/src/gallium/auxiliary/util/u_debug_symbol.c @@ -296,7 +296,7 @@ debug_symbol_name_cached(const void *addr) debug_symbol_name(addr, buf, sizeof(buf)); name = strdup(buf); - util_hash_table_set(symbols_hash, (void*)addr, (void*)name); + _mesa_hash_table_insert(symbols_hash, (void*)addr, (void*)name); } mtx_unlock(&symbols_mutex); return name; diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c index 59c8c6cf98d..9182da55800 100644 --- a/src/gallium/auxiliary/util/u_hash_table.c +++ b/src/gallium/auxiliary/util/u_hash_table.c @@ -26,26 +26,14 @@ **************************************************************************/ -#include "pipe/p_compiler.h" -#include "util/u_debug.h" - -#include "util/u_memory.h" +#include "util/u_pointer.h" #include "util/u_hash_table.h" -#include "util/hash_table.h" #if DETECT_OS_UNIX #include #endif -struct hash_table * -util_hash_table_create(uint32_t (*hash)(const void *key), - bool (*equal)(const void *key1, const void *key2)) -{ - return _mesa_hash_table_create(NULL, hash, equal); -} - - static uint32_t pointer_hash(const void *key) { @@ -108,16 +96,6 @@ util_hash_table_create_fd_keys(void) } -enum pipe_error -util_hash_table_set(struct hash_table *ht, - void *key, - void *value) -{ - _mesa_hash_table_insert(ht, key, value); - return PIPE_OK; -} - - void * util_hash_table_get(struct hash_table *ht, void *key) @@ -128,21 +106,6 @@ util_hash_table_get(struct hash_table *ht, } -void -util_hash_table_remove(struct hash_table *ht, - void *key) -{ - _mesa_hash_table_remove_key(ht, key); -} - - -void -util_hash_table_clear(struct hash_table *ht) -{ - _mesa_hash_table_clear(ht, NULL); -} - - enum pipe_error util_hash_table_foreach(struct hash_table *ht, enum pipe_error (*callback) @@ -156,17 +119,3 @@ util_hash_table_foreach(struct hash_table *ht, } return PIPE_OK; } - - -size_t -util_hash_table_count(struct hash_table *ht) -{ - return _mesa_hash_table_num_entries(ht); -} - - -void -util_hash_table_destroy(struct hash_table *ht) -{ - _mesa_hash_table_destroy(ht, NULL); -} diff --git a/src/gallium/auxiliary/util/u_hash_table.h b/src/gallium/auxiliary/util/u_hash_table.h index 46470bf0647..4be4cef3050 100644 --- a/src/gallium/auxiliary/util/u_hash_table.h +++ b/src/gallium/auxiliary/util/u_hash_table.h @@ -34,25 +34,13 @@ #include "pipe/p_defines.h" +#include "util/hash_table.h" #ifdef __cplusplus extern "C" { #endif -struct hash_table; - - -/** - * Create an hash table. - * - * @param hash hash function - * @param equal should return true for two equal keys. - */ -struct hash_table * -util_hash_table_create(uint32_t (*hash)(const void *key), - bool (*equal)(const void *key1, const void *key2)); - /** * Create a hash table where the keys are generic pointers. */ @@ -67,40 +55,17 @@ struct hash_table * util_hash_table_create_fd_keys(void); -enum pipe_error -util_hash_table_set(struct hash_table *ht, - void *key, - void *value); - void * util_hash_table_get(struct hash_table *ht, void *key); -void -util_hash_table_remove(struct hash_table *ht, - void *key); - - -void -util_hash_table_clear(struct hash_table *ht); - - enum pipe_error util_hash_table_foreach(struct hash_table *ht, enum pipe_error (*callback) (void *key, void *value, void *data), void *data); - -size_t -util_hash_table_count(struct hash_table *ht); - - -void -util_hash_table_destroy(struct hash_table *ht); - - #ifdef __cplusplus } #endif diff --git a/src/gallium/drivers/lima/lima_bo.c b/src/gallium/drivers/lima/lima_bo.c index 17197c48279..cccf2f64cac 100644 --- a/src/gallium/drivers/lima/lima_bo.c +++ b/src/gallium/drivers/lima/lima_bo.c @@ -54,7 +54,7 @@ bool lima_bo_table_init(struct lima_screen *screen) return true; err_out0: - util_hash_table_destroy(screen->bo_handles); + _mesa_hash_table_destroy(screen->bo_handles, NULL); return false; } @@ -71,8 +71,8 @@ bool lima_bo_cache_init(struct lima_screen *screen) void lima_bo_table_fini(struct lima_screen *screen) { mtx_destroy(&screen->bo_table_lock); - util_hash_table_destroy(screen->bo_handles); - util_hash_table_destroy(screen->bo_flink_names); + _mesa_hash_table_destroy(screen->bo_handles, NULL); + _mesa_hash_table_destroy(screen->bo_flink_names, NULL); } static void @@ -101,10 +101,10 @@ lima_bo_free(struct lima_bo *bo) bo, bo->size); mtx_lock(&screen->bo_table_lock); - util_hash_table_remove(screen->bo_handles, + _mesa_hash_table_remove_key(screen->bo_handles, (void *)(uintptr_t)bo->handle); if (bo->flink_name) - util_hash_table_remove(screen->bo_flink_names, + _mesa_hash_table_remove_key(screen->bo_flink_names, (void *)(uintptr_t)bo->flink_name); mtx_unlock(&screen->bo_table_lock); @@ -378,7 +378,7 @@ bool lima_bo_export(struct lima_bo *bo, struct winsys_handle *handle) bo->flink_name = flink.name; mtx_lock(&screen->bo_table_lock); - util_hash_table_set(screen->bo_flink_names, + _mesa_hash_table_insert(screen->bo_flink_names, (void *)(uintptr_t)bo->flink_name, bo); mtx_unlock(&screen->bo_table_lock); } @@ -387,7 +387,7 @@ bool lima_bo_export(struct lima_bo *bo, struct winsys_handle *handle) case WINSYS_HANDLE_TYPE_KMS: mtx_lock(&screen->bo_table_lock); - util_hash_table_set(screen->bo_handles, + _mesa_hash_table_insert(screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); mtx_unlock(&screen->bo_table_lock); @@ -400,7 +400,7 @@ bool lima_bo_export(struct lima_bo *bo, struct winsys_handle *handle) return false; mtx_lock(&screen->bo_table_lock); - util_hash_table_set(screen->bo_handles, + _mesa_hash_table_insert(screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); mtx_unlock(&screen->bo_table_lock); return true; @@ -504,9 +504,9 @@ struct lima_bo *lima_bo_import(struct lima_screen *screen, if (lima_bo_get_info(bo)) { if (handle->type == WINSYS_HANDLE_TYPE_SHARED) - util_hash_table_set(screen->bo_flink_names, + _mesa_hash_table_insert(screen->bo_flink_names, (void *)(uintptr_t)bo->flink_name, bo); - util_hash_table_set(screen->bo_handles, + _mesa_hash_table_insert(screen->bo_handles, (void*)(uintptr_t)bo->handle, bo); } else { diff --git a/src/gallium/drivers/v3d/v3d_bufmgr.c b/src/gallium/drivers/v3d/v3d_bufmgr.c index b3e4d053cc0..50e4081dafd 100644 --- a/src/gallium/drivers/v3d/v3d_bufmgr.c +++ b/src/gallium/drivers/v3d/v3d_bufmgr.c @@ -372,7 +372,7 @@ v3d_bo_open_handle(struct v3d_screen *screen, bo->offset = get.offset; assert(bo->offset != 0); - util_hash_table_set(screen->bo_handles, (void *)(uintptr_t)handle, bo); + _mesa_hash_table_insert(screen->bo_handles, (void *)(uintptr_t)handle, bo); screen->bo_count++; screen->bo_size += bo->size; @@ -433,7 +433,7 @@ v3d_bo_get_dmabuf(struct v3d_bo *bo) mtx_lock(&bo->screen->bo_handles_mutex); bo->private = false; - util_hash_table_set(bo->screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); + _mesa_hash_table_insert(bo->screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); mtx_unlock(&bo->screen->bo_handles_mutex); return fd; diff --git a/src/gallium/drivers/v3d/v3d_bufmgr.h b/src/gallium/drivers/v3d/v3d_bufmgr.h index 48629c65356..9aa4d84a001 100644 --- a/src/gallium/drivers/v3d/v3d_bufmgr.h +++ b/src/gallium/drivers/v3d/v3d_bufmgr.h @@ -96,7 +96,7 @@ v3d_bo_unreference(struct v3d_bo **bo) mtx_lock(&screen->bo_handles_mutex); if (pipe_reference(&(*bo)->reference, NULL)) { - util_hash_table_remove(screen->bo_handles, + _mesa_hash_table_remove_key(screen->bo_handles, (void *)(uintptr_t)(*bo)->handle); v3d_bo_last_unreference(*bo); } diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index 8031ea727e0..8e2509a71c4 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -72,7 +72,7 @@ v3d_screen_destroy(struct pipe_screen *pscreen) { struct v3d_screen *screen = v3d_screen(pscreen); - util_hash_table_destroy(screen->bo_handles); + _mesa_hash_table_destroy(screen->bo_handles, NULL); v3d_bufmgr_destroy(pscreen); slab_destroy_parent(&screen->transfer_pool); free(screen->ro); diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c index 5ec360934c0..549c4f8f43d 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.c +++ b/src/gallium/drivers/vc4/vc4_bufmgr.c @@ -413,7 +413,7 @@ vc4_bo_open_handle(struct vc4_screen *screen, bo->map = malloc(bo->size); #endif - util_hash_table_set(screen->bo_handles, (void *)(uintptr_t)handle, bo); + _mesa_hash_table_insert(screen->bo_handles, (void *)(uintptr_t)handle, bo); done: mtx_unlock(&screen->bo_handles_mutex); @@ -471,7 +471,7 @@ vc4_bo_get_dmabuf(struct vc4_bo *bo) mtx_lock(&bo->screen->bo_handles_mutex); bo->private = false; - util_hash_table_set(bo->screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); + _mesa_hash_table_insert(bo->screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); mtx_unlock(&bo->screen->bo_handles_mutex); return fd; diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.h b/src/gallium/drivers/vc4/vc4_bufmgr.h index 30a388ee599..26378cb4840 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.h +++ b/src/gallium/drivers/vc4/vc4_bufmgr.h @@ -102,7 +102,7 @@ vc4_bo_unreference(struct vc4_bo **bo) if (pipe_reference_described(&(*bo)->reference, NULL, (debug_reference_descriptor) vc4_bo_debug_describe)) { - util_hash_table_remove(screen->bo_handles, + _mesa_hash_table_remove_key(screen->bo_handles, (void *)(uintptr_t)(*bo)->handle); vc4_bo_last_unreference(*bo); } diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c index 3b14681c42d..21db4c944ff 100644 --- a/src/gallium/drivers/vc4/vc4_screen.c +++ b/src/gallium/drivers/vc4/vc4_screen.c @@ -102,7 +102,7 @@ vc4_screen_destroy(struct pipe_screen *pscreen) { struct vc4_screen *screen = vc4_screen(pscreen); - util_hash_table_destroy(screen->bo_handles); + _mesa_hash_table_destroy(screen->bo_handles, NULL); vc4_bufmgr_destroy(pscreen); slab_destroy_parent(&screen->transfer_pool); free(screen->ro); diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index bac92c44586..c5b5eff128e 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -3023,7 +3023,7 @@ NineDevice9_ProcessVertices( struct NineDevice9 *This, if (FAILED(hr)) return hr; vdecl->fvf = FVF; - util_hash_table_set(This->ff.ht_fvf, &vdecl->fvf, vdecl); + _mesa_hash_table_insert(This->ff.ht_fvf, &vdecl->fvf, vdecl); NineUnknown_ConvertRefToBind(NineUnknown(vdecl)); } } @@ -3183,7 +3183,7 @@ NineDevice9_SetFVF( struct NineDevice9 *This, if (FAILED(hr)) return hr; vdecl->fvf = FVF; - util_hash_table_set(This->ff.ht_fvf, &vdecl->fvf, vdecl); + _mesa_hash_table_insert(This->ff.ht_fvf, &vdecl->fvf, vdecl); NineUnknown_ConvertRefToBind(NineUnknown(vdecl)); } return NineDevice9_SetVertexDeclaration( diff --git a/src/gallium/state_trackers/nine/iunknown.c b/src/gallium/state_trackers/nine/iunknown.c index 3835651f536..2d69afd5496 100644 --- a/src/gallium/state_trackers/nine/iunknown.c +++ b/src/gallium/state_trackers/nine/iunknown.c @@ -59,7 +59,7 @@ NineUnknown_ctor( struct NineUnknown *This, This->guids = pParams->guids; This->dtor = pParams->dtor; - This->pdata = util_hash_table_create(ht_guid_hash, ht_guid_compare); + This->pdata = _mesa_hash_table_create(NULL, ht_guid_hash, ht_guid_compare); if (!This->pdata) return E_OUTOFMEMORY; @@ -74,7 +74,7 @@ NineUnknown_dtor( struct NineUnknown *This ) if (This->pdata) { util_hash_table_foreach(This->pdata, ht_guid_delete, NULL); - util_hash_table_destroy(This->pdata); + _mesa_hash_table_destroy(This->pdata, NULL); } FREE(This); @@ -224,16 +224,9 @@ NineUnknown_SetPrivateData( struct NineUnknown *This, memcpy(header_data, user_data, header->size); memcpy(&header->guid, refguid, sizeof(header->guid)); - err = util_hash_table_set(This->pdata, &header->guid, header); - if (err == PIPE_OK) { - if (header->unknown) { IUnknown_AddRef(*(IUnknown **)header_data); } - return D3D_OK; - } - - FREE(header); - if (err == PIPE_ERROR_OUT_OF_MEMORY) { return E_OUTOFMEMORY; } - - return D3DERR_DRIVERINTERNALERROR; + _mesa_hash_table_insert(This->pdata, &header->guid, header); + if (header->unknown) { IUnknown_AddRef(*(IUnknown **)header_data); } + return D3D_OK; } HRESULT NINE_WINAPI @@ -289,7 +282,7 @@ NineUnknown_FreePrivateData( struct NineUnknown *This, return D3DERR_NOTFOUND; ht_guid_delete(NULL, header, NULL); - util_hash_table_remove(This->pdata, refguid); + _mesa_hash_table_remove_key(This->pdata, refguid); return D3D_OK; } diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c index 8973dcbbc28..a97a83ff1c3 100644 --- a/src/gallium/state_trackers/nine/nine_ff.c +++ b/src/gallium/state_trackers/nine/nine_ff.c @@ -1563,7 +1563,6 @@ nine_ff_get_vs(struct NineDevice9 *device) { const struct nine_context *context = &device->context; struct NineVertexShader9 *vs; - enum pipe_error err; struct vs_build_ctx bld; struct nine_ff_vs_key key; unsigned s, i; @@ -1695,9 +1694,7 @@ nine_ff_get_vs(struct NineDevice9 *device) memcpy(&vs->ff_key, &key, sizeof(vs->ff_key)); - err = util_hash_table_set(device->ff.ht_vs, &vs->ff_key, vs); - (void)err; - assert(err == PIPE_OK); + _mesa_hash_table_insert(device->ff.ht_vs, &vs->ff_key, vs); device->ff.num_vs++; vs->num_inputs = bld.num_inputs; @@ -1719,7 +1716,6 @@ nine_ff_get_ps(struct NineDevice9 *device) struct nine_context *context = &device->context; D3DMATRIX *projection_matrix = GET_D3DTS(PROJECTION); struct NinePixelShader9 *ps; - enum pipe_error err; struct nine_ff_ps_key key; unsigned s; uint8_t sampler_mask = 0; @@ -1847,9 +1843,7 @@ nine_ff_get_ps(struct NineDevice9 *device) if (ps) { memcpy(&ps->ff_key, &key, sizeof(ps->ff_key)); - err = util_hash_table_set(device->ff.ht_ps, &ps->ff_key, ps); - (void)err; - assert(err == PIPE_OK); + _mesa_hash_table_insert(device->ff.ht_ps, &ps->ff_key, ps); device->ff.num_ps++; ps->rt_mask = 0x1; @@ -2089,13 +2083,13 @@ nine_ff_update(struct NineDevice9 *device) boolean nine_ff_init(struct NineDevice9 *device) { - device->ff.ht_vs = util_hash_table_create(nine_ff_vs_key_hash, - nine_ff_vs_key_comp); - device->ff.ht_ps = util_hash_table_create(nine_ff_ps_key_hash, - nine_ff_ps_key_comp); + device->ff.ht_vs = _mesa_hash_table_create(NULL, nine_ff_vs_key_hash, + nine_ff_vs_key_comp); + device->ff.ht_ps = _mesa_hash_table_create(NULL, nine_ff_ps_key_hash, + nine_ff_ps_key_comp); - device->ff.ht_fvf = util_hash_table_create(nine_ff_fvf_key_hash, - nine_ff_fvf_key_comp); + device->ff.ht_fvf = _mesa_hash_table_create(NULL, nine_ff_fvf_key_hash, + nine_ff_fvf_key_comp); device->ff.vs_const = CALLOC(NINE_FF_NUM_VS_CONST, 4 * sizeof(float)); device->ff.ps_const = CALLOC(NINE_FF_NUM_PS_CONST, 4 * sizeof(float)); @@ -2116,15 +2110,15 @@ nine_ff_fini(struct NineDevice9 *device) { if (device->ff.ht_vs) { util_hash_table_foreach(device->ff.ht_vs, nine_ff_ht_delete_cb, NULL); - util_hash_table_destroy(device->ff.ht_vs); + _mesa_hash_table_destroy(device->ff.ht_vs, NULL); } if (device->ff.ht_ps) { util_hash_table_foreach(device->ff.ht_ps, nine_ff_ht_delete_cb, NULL); - util_hash_table_destroy(device->ff.ht_ps); + _mesa_hash_table_destroy(device->ff.ht_ps, NULL); } if (device->ff.ht_fvf) { util_hash_table_foreach(device->ff.ht_fvf, nine_ff_ht_delete_cb, NULL); - util_hash_table_destroy(device->ff.ht_fvf); + _mesa_hash_table_destroy(device->ff.ht_fvf, NULL); } device->ff.vs = NULL; /* destroyed by unbinding from hash table */ device->ff.ps = NULL; @@ -2142,7 +2136,7 @@ nine_ff_prune_vs(struct NineDevice9 *device) /* could destroy the bound one here, so unbind */ context->pipe->bind_vs_state(context->pipe, NULL); util_hash_table_foreach(device->ff.ht_vs, nine_ff_ht_delete_cb, NULL); - util_hash_table_clear(device->ff.ht_vs); + _mesa_hash_table_clear(device->ff.ht_vs, NULL); device->ff.num_vs = 0; context->changed.group |= NINE_STATE_VS; } @@ -2156,7 +2150,7 @@ nine_ff_prune_ps(struct NineDevice9 *device) /* could destroy the bound one here, so unbind */ context->pipe->bind_fs_state(context->pipe, NULL); util_hash_table_foreach(device->ff.ht_ps, nine_ff_ht_delete_cb, NULL); - util_hash_table_clear(device->ff.ht_ps); + _mesa_hash_table_clear(device->ff.ht_ps, NULL); device->ff.num_ps = 0; context->changed.group |= NINE_STATE_PS; } diff --git a/src/gallium/state_trackers/omx/tizonia/h264dprc.c b/src/gallium/state_trackers/omx/tizonia/h264dprc.c index 5678bd7ac8c..c5df994b8c3 100644 --- a/src/gallium/state_trackers/omx/tizonia/h264dprc.c +++ b/src/gallium/state_trackers/omx/tizonia/h264dprc.c @@ -217,7 +217,7 @@ static void get_eglimage(vid_dec_PrivateType* priv) { assert(video_buffer); assert(video_buffer->buffer_format == p_res->format); - util_hash_table_set(priv->video_buffer_map, priv->p_outhdr_, video_buffer); + _mesa_hash_table_insert(priv->video_buffer_map, priv->p_outhdr_, video_buffer); } } else { (void) tiz_krn_release_buffer(tiz_get_krn (handleOf (priv)), @@ -436,7 +436,7 @@ static OMX_ERRORTYPE h264d_prc_deallocate_resources(void *ap_obj) util_hash_table_foreach(priv->video_buffer_map, &hash_table_clear_item_callback, NULL); - util_hash_table_destroy(priv->video_buffer_map); + _mesa_hash_table_destroy(priv->video_buffer_map, NULL); if (priv->pipe) { vl_compositor_cleanup_state(&priv->cstate); diff --git a/src/gallium/state_trackers/va/context.c b/src/gallium/state_trackers/va/context.c index 70d4bac63a7..0c596f3f811 100644 --- a/src/gallium/state_trackers/va/context.c +++ b/src/gallium/state_trackers/va/context.c @@ -342,12 +342,12 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id) if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_FORMAT_MPEG4_AVC) { if (context->desc.h264enc.frame_idx) - util_hash_table_destroy (context->desc.h264enc.frame_idx); + _mesa_hash_table_destroy(context->desc.h264enc.frame_idx, NULL); } if (u_reduce_video_profile(context->decoder->profile) == PIPE_VIDEO_FORMAT_HEVC) { if (context->desc.h265enc.frame_idx) - util_hash_table_destroy (context->desc.h265enc.frame_idx); + _mesa_hash_table_destroy(context->desc.h265enc.frame_idx, NULL); } } else { if (u_reduce_video_profile(context->decoder->profile) == diff --git a/src/gallium/state_trackers/va/picture_h264_enc.c b/src/gallium/state_trackers/va/picture_h264_enc.c index f46b3425566..8ee27d2cb29 100644 --- a/src/gallium/state_trackers/va/picture_h264_enc.c +++ b/src/gallium/state_trackers/va/picture_h264_enc.c @@ -52,7 +52,7 @@ vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *cont PIPE_USAGE_STREAM, coded_buf->size); context->coded_buf = coded_buf; - util_hash_table_set(context->desc.h264enc.frame_idx, + _mesa_hash_table_insert(context->desc.h264enc.frame_idx, UINT_TO_PTR(h264->CurrPic.picture_id), UINT_TO_PTR(h264->frame_num)); diff --git a/src/gallium/state_trackers/va/picture_hevc_enc.c b/src/gallium/state_trackers/va/picture_hevc_enc.c index 8906901b262..510597753ce 100644 --- a/src/gallium/state_trackers/va/picture_hevc_enc.c +++ b/src/gallium/state_trackers/va/picture_hevc_enc.c @@ -73,7 +73,7 @@ vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *cont context->desc.h265enc.pic.constrained_intra_pred_flag = h265->pic_fields.bits.constrained_intra_pred_flag; - util_hash_table_set(context->desc.h265enc.frame_idx, + _mesa_hash_table_insert(context->desc.h265enc.frame_idx, UINT_TO_PTR(h265->decoded_curr_pic.picture_id), UINT_TO_PTR(context->desc.h265enc.frame_num)); diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index 18ed3aaa596..8a821c8fd4f 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -198,7 +198,7 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf) simple_mtx_unlock(&ws->sws_list_lock); simple_mtx_lock(&ws->bo_export_table_lock); - util_hash_table_remove(ws->bo_export_table, bo->bo); + _mesa_hash_table_remove_key(ws->bo_export_table, bo->bo); simple_mtx_unlock(&ws->bo_export_table_lock); if (bo->initial_domain & RADEON_DOMAIN_VRAM_GTT) { @@ -1519,7 +1519,7 @@ static struct pb_buffer *amdgpu_bo_from_handle(struct radeon_winsys *rws, amdgpu_add_buffer_to_global_list(bo); - util_hash_table_set(ws->bo_export_table, bo->bo, bo); + _mesa_hash_table_insert(ws->bo_export_table, bo->bo, bo); simple_mtx_unlock(&ws->bo_export_table_lock); return &bo->base; @@ -1602,7 +1602,7 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws, hash_table_set: simple_mtx_lock(&ws->bo_export_table_lock); - util_hash_table_set(ws->bo_export_table, bo->bo, bo); + _mesa_hash_table_insert(ws->bo_export_table, bo->bo, bo); simple_mtx_unlock(&ws->bo_export_table_lock); bo->is_shared = true; diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c index f770daafa16..3dff8e46ada 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c @@ -139,7 +139,7 @@ static void do_winsys_deinit(struct amdgpu_winsys *ws) pb_slabs_deinit(&ws->bo_slabs[i]); } pb_cache_deinit(&ws->bo_cache); - util_hash_table_destroy(ws->bo_export_table); + _mesa_hash_table_destroy(ws->bo_export_table, NULL); simple_mtx_destroy(&ws->sws_list_lock); simple_mtx_destroy(&ws->global_bo_list_lock); simple_mtx_destroy(&ws->bo_export_table_lock); @@ -165,9 +165,9 @@ static void amdgpu_winsys_destroy(struct radeon_winsys *rws) destroy = pipe_reference(&ws->reference, NULL); if (destroy && dev_tab) { - util_hash_table_remove(dev_tab, ws->dev); - if (util_hash_table_count(dev_tab) == 0) { - util_hash_table_destroy(dev_tab); + _mesa_hash_table_remove_key(dev_tab, ws->dev); + if (_mesa_hash_table_num_entries(dev_tab) == 0) { + _mesa_hash_table_destroy(dev_tab, NULL); dev_tab = NULL; } } @@ -467,7 +467,7 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, return NULL; } - util_hash_table_set(dev_tab, dev, aws); + _mesa_hash_table_insert(dev_tab, dev, aws); if (aws->reserve_vmid) { r = amdgpu_vm_reserve_vmid(dev, 0); diff --git a/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c b/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c index 1d3f6dc817b..e5e00dd3d64 100644 --- a/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c +++ b/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c @@ -81,7 +81,7 @@ etna_drm_screen_destroy(struct pipe_screen *pscreen) destroy = --screen->refcnt == 0; if (destroy) { int fd = etna_device_fd(screen->dev); - util_hash_table_remove(etna_tab, intptr_to_pointer(fd)); + _mesa_hash_table_remove_key(etna_tab, intptr_to_pointer(fd)); } mtx_unlock(&etna_screen_mutex); @@ -110,7 +110,7 @@ etna_drm_screen_create_renderonly(struct renderonly *ro) pscreen = screen_create(ro); if (pscreen) { int fd = etna_device_fd(etna_screen(pscreen)->dev); - util_hash_table_set(etna_tab, intptr_to_pointer(fd), pscreen); + _mesa_hash_table_insert(etna_tab, intptr_to_pointer(fd), pscreen); /* Bit of a hack, to avoid circular linkage dependency, * ie. pipe driver having to call in to winsys, we diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c index c0da444785f..6bc4853f08a 100644 --- a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c +++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c @@ -52,7 +52,7 @@ fd_drm_screen_destroy(struct pipe_screen *pscreen) destroy = --screen->refcnt == 0; if (destroy) { int fd = fd_device_fd(screen->dev); - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); + _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(fd)); } mtx_unlock(&fd_screen_mutex); @@ -86,7 +86,7 @@ fd_drm_screen_create(int fd, struct renderonly *ro) if (pscreen) { int fd = fd_device_fd(dev); - util_hash_table_set(fd_tab, intptr_to_pointer(fd), pscreen); + _mesa_hash_table_insert(fd_tab, intptr_to_pointer(fd), pscreen); /* Bit of a hack, to avoid circular linkage dependency, * ie. pipe driver having to call in to winsys, we diff --git a/src/gallium/winsys/lima/drm/lima_drm_winsys.c b/src/gallium/winsys/lima/drm/lima_drm_winsys.c index 6dcd21c2e60..046b47b65e7 100644 --- a/src/gallium/winsys/lima/drm/lima_drm_winsys.c +++ b/src/gallium/winsys/lima/drm/lima_drm_winsys.c @@ -47,7 +47,7 @@ lima_drm_screen_destroy(struct pipe_screen *pscreen) mtx_lock(&lima_screen_mutex); destroy = --screen->refcnt == 0; if (destroy) - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); + _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(fd)); mtx_unlock(&lima_screen_mutex); if (destroy) { @@ -77,7 +77,7 @@ lima_drm_screen_create(int fd) pscreen = lima_screen_create(dup_fd, NULL); if (pscreen) { - util_hash_table_set(fd_tab, intptr_to_pointer(dup_fd), pscreen); + _mesa_hash_table_insert(fd_tab, intptr_to_pointer(dup_fd), pscreen); /* Bit of a hack, to avoid circular linkage dependency, * ie. pipe driver having to call in to winsys, we diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c index 8547219b689..313126060ba 100644 --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c @@ -31,7 +31,7 @@ bool nouveau_drm_screen_unref(struct nouveau_screen *screen) ret = --screen->refcount; assert(ret >= 0); if (ret == 0) - util_hash_table_remove(fd_tab, intptr_to_pointer(screen->drm->fd)); + _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(screen->drm->fd)); mtx_unlock(&nouveau_screen_mutex); return ret == 0; } @@ -119,7 +119,7 @@ nouveau_drm_screen_create(int fd) * closed by its owner. The hash key needs to live at least as long as * the screen. */ - util_hash_table_set(fd_tab, intptr_to_pointer(dupfd), screen); + _mesa_hash_table_insert(fd_tab, intptr_to_pointer(dupfd), screen); screen->refcount = 1; mtx_unlock(&nouveau_screen_mutex); return &screen->base; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index 6d3e9c9f752..0f3a8aa67cd 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -361,9 +361,9 @@ void radeon_bo_destroy(struct pb_buffer *_buf) memset(&args, 0, sizeof(args)); mtx_lock(&rws->bo_handles_mutex); - util_hash_table_remove(rws->bo_handles, (void*)(uintptr_t)bo->handle); + _mesa_hash_table_remove_key(rws->bo_handles, (void*)(uintptr_t)bo->handle); if (bo->flink_name) { - util_hash_table_remove(rws->bo_names, + _mesa_hash_table_remove_key(rws->bo_names, (void*)(uintptr_t)bo->flink_name); } mtx_unlock(&rws->bo_handles_mutex); @@ -725,7 +725,7 @@ static struct radeon_bo *radeon_create_bo(struct radeon_drm_winsys *rws, return radeon_bo(b); } - util_hash_table_set(rws->bo_vas, (void*)(uintptr_t)bo->va, bo); + _mesa_hash_table_insert(rws->bo_vas, (void*)(uintptr_t)bo->va, bo); mtx_unlock(&rws->bo_handles_mutex); } @@ -1042,7 +1042,7 @@ no_slab: bo->u.real.use_reusable_pool = use_reusable_pool; mtx_lock(&ws->bo_handles_mutex); - util_hash_table_set(ws->bo_handles, (void*)(uintptr_t)bo->handle, bo); + _mesa_hash_table_insert(ws->bo_handles, (void*)(uintptr_t)bo->handle, bo); mtx_unlock(&ws->bo_handles_mutex); return &bo->base; @@ -1089,7 +1089,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct radeon_winsys *rws, bo->hash = __sync_fetch_and_add(&ws->next_bo_hash, 1); (void) mtx_init(&bo->u.real.map_mutex, mtx_plain); - util_hash_table_set(ws->bo_handles, (void*)(uintptr_t)bo->handle, bo); + _mesa_hash_table_insert(ws->bo_handles, (void*)(uintptr_t)bo->handle, bo); mtx_unlock(&ws->bo_handles_mutex); @@ -1123,7 +1123,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct radeon_winsys *rws, return b; } - util_hash_table_set(ws->bo_vas, (void*)(uintptr_t)bo->va, bo); + _mesa_hash_table_insert(ws->bo_vas, (void*)(uintptr_t)bo->va, bo); mtx_unlock(&ws->bo_handles_mutex); } @@ -1217,9 +1217,9 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws, (void) mtx_init(&bo->u.real.map_mutex, mtx_plain); if (bo->flink_name) - util_hash_table_set(ws->bo_names, (void*)(uintptr_t)bo->flink_name, bo); + _mesa_hash_table_insert(ws->bo_names, (void*)(uintptr_t)bo->flink_name, bo); - util_hash_table_set(ws->bo_handles, (void*)(uintptr_t)bo->handle, bo); + _mesa_hash_table_insert(ws->bo_handles, (void*)(uintptr_t)bo->handle, bo); done: mtx_unlock(&ws->bo_handles_mutex); @@ -1254,7 +1254,7 @@ done: return b; } - util_hash_table_set(ws->bo_vas, (void*)(uintptr_t)bo->va, bo); + _mesa_hash_table_insert(ws->bo_vas, (void*)(uintptr_t)bo->va, bo); mtx_unlock(&ws->bo_handles_mutex); } @@ -1299,7 +1299,7 @@ static bool radeon_winsys_bo_get_handle(struct radeon_winsys *rws, bo->flink_name = flink.name; mtx_lock(&ws->bo_handles_mutex); - util_hash_table_set(ws->bo_names, (void*)(uintptr_t)bo->flink_name, bo); + _mesa_hash_table_insert(ws->bo_names, (void*)(uintptr_t)bo->flink_name, bo); mtx_unlock(&ws->bo_handles_mutex); } whandle->handle = bo->flink_name; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 394ba1f9831..fca5be58751 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -622,9 +622,9 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws) radeon_surface_manager_free(ws->surf_man); } - util_hash_table_destroy(ws->bo_names); - util_hash_table_destroy(ws->bo_handles); - util_hash_table_destroy(ws->bo_vas); + _mesa_hash_table_destroy(ws->bo_names, NULL); + _mesa_hash_table_destroy(ws->bo_handles, NULL); + _mesa_hash_table_destroy(ws->bo_vas, NULL); mtx_destroy(&ws->bo_handles_mutex); mtx_destroy(&ws->vm32.mutex); mtx_destroy(&ws->vm64.mutex); @@ -776,9 +776,9 @@ static bool radeon_winsys_unref(struct radeon_winsys *ws) destroy = pipe_reference(&rws->reference, NULL); if (destroy && fd_tab) { - util_hash_table_remove(fd_tab, intptr_to_pointer(rws->fd)); - if (util_hash_table_count(fd_tab) == 0) { - util_hash_table_destroy(fd_tab); + _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(rws->fd)); + if (_mesa_hash_table_num_entries(fd_tab) == 0) { + _mesa_hash_table_destroy(fd_tab, NULL); fd_tab = NULL; } } @@ -929,7 +929,7 @@ radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config, return NULL; } - util_hash_table_set(fd_tab, intptr_to_pointer(ws->fd), ws); + _mesa_hash_table_insert(fd_tab, intptr_to_pointer(ws->fd), ws); /* We must unlock the mutex once the winsys is fully initialized, so that * other threads attempting to create the winsys from the same fd will diff --git a/src/gallium/winsys/svga/drm/vmw_context.c b/src/gallium/winsys/svga/drm/vmw_context.c index bc6883ee08c..432f9afcd1f 100644 --- a/src/gallium/winsys/svga/drm/vmw_context.c +++ b/src/gallium/winsys/svga/drm/vmw_context.c @@ -260,7 +260,7 @@ vmw_swc_flush(struct svga_winsys_context *swc, vmw_svga_winsys_surface_reference(&isurf->vsurf, NULL); } - util_hash_table_clear(vswc->hash); + _mesa_hash_table_clear(vswc->hash, NULL); vswc->surface.used = 0; vswc->surface.reserved = 0; @@ -504,12 +504,8 @@ vmw_swc_surface_only_relocation(struct svga_winsys_context *swc, isrf = &vswc->surface.items[vswc->surface.used + vswc->surface.staged]; vmw_svga_winsys_surface_reference(&isrf->vsurf, vsurf); isrf->referenced = FALSE; - /* - * Note that a failure here may just fall back to unhashed behavior - * and potentially cause unnecessary flushing, so ignore the - * return code. - */ - (void) util_hash_table_set(vswc->hash, vsurf, isrf); + + _mesa_hash_table_insert(vswc->hash, vsurf, isrf); ++vswc->surface.staged; vswc->seen_surfaces += vsurf->size; @@ -600,12 +596,8 @@ vmw_swc_shader_relocation(struct svga_winsys_context *swc, ishader = &vswc->shader.items[vswc->shader.used + vswc->shader.staged]; vmw_svga_winsys_shader_reference(&ishader->vshader, vshader); ishader->referenced = FALSE; - /* - * Note that a failure here may just fall back to unhashed behavior - * and potentially cause unnecessary flushing, so ignore the - * return code. - */ - (void) util_hash_table_set(vswc->hash, vshader, ishader); + + _mesa_hash_table_insert(vswc->hash, vshader, ishader); ++vswc->shader.staged; } @@ -682,7 +674,7 @@ vmw_swc_destroy(struct svga_winsys_context *swc) vmw_svga_winsys_shader_reference(&ishader->vshader, NULL); } - util_hash_table_destroy(vswc->hash); + _mesa_hash_table_destroy(vswc->hash, NULL); pb_validate_destroy(vswc->validate); vmw_ioctl_context_destroy(vswc->vws, swc->cid); #ifdef DEBUG diff --git a/src/gallium/winsys/svga/drm/vmw_screen.c b/src/gallium/winsys/svga/drm/vmw_screen.c index cecb932c4c7..8b4b89981b2 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen.c +++ b/src/gallium/winsys/svga/drm/vmw_screen.c @@ -69,7 +69,7 @@ vmw_winsys_create( int fd ) struct stat stat_buf; if (dev_hash == NULL) { - dev_hash = util_hash_table_create(vmw_dev_hash, vmw_dev_compare); + dev_hash = _mesa_hash_table_create(NULL, vmw_dev_hash, vmw_dev_compare); if (dev_hash == NULL) return NULL; } @@ -107,14 +107,12 @@ vmw_winsys_create( int fd ) if (!vmw_winsys_screen_init_svga(vws)) goto out_no_svga; - if (util_hash_table_set(dev_hash, &vws->device, vws) != PIPE_OK) - goto out_no_hash_insert; + _mesa_hash_table_insert(dev_hash, &vws->device, vws); cnd_init(&vws->cs_cond); mtx_init(&vws->cs_mutex, mtx_plain); return vws; -out_no_hash_insert: out_no_svga: vmw_pools_cleanup(vws); out_no_pools: @@ -132,7 +130,7 @@ void vmw_winsys_destroy(struct vmw_winsys_screen *vws) { if (--vws->open_count == 0) { - util_hash_table_remove(dev_hash, &vws->device); + _mesa_hash_table_remove_key(dev_hash, &vws->device); vmw_pools_cleanup(vws); vws->fence_ops->destroy(vws->fence_ops); vmw_ioctl_cleanup(vws); diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index 4d9aa0332f8..9d8b2f75891 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -68,10 +68,10 @@ static void virgl_hw_res_destroy(struct virgl_drm_winsys *qdws, struct drm_gem_close args; mtx_lock(&qdws->bo_handles_mutex); - util_hash_table_remove(qdws->bo_handles, + _mesa_hash_table_remove_key(qdws->bo_handles, (void *)(uintptr_t)res->bo_handle); if (res->flink_name) - util_hash_table_remove(qdws->bo_names, + _mesa_hash_table_remove_key(qdws->bo_names, (void *)(uintptr_t)res->flink_name); mtx_unlock(&qdws->bo_handles_mutex); if (res->ptr) @@ -113,8 +113,8 @@ virgl_drm_winsys_destroy(struct virgl_winsys *qws) virgl_resource_cache_flush(&qdws->cache); - util_hash_table_destroy(qdws->bo_handles); - util_hash_table_destroy(qdws->bo_names); + _mesa_hash_table_destroy(qdws->bo_handles, NULL); + _mesa_hash_table_destroy(qdws->bo_names, NULL); mtx_destroy(&qdws->bo_handles_mutex); mtx_destroy(&qdws->mutex); @@ -387,8 +387,8 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, res->num_cs_references = 0; if (res->flink_name) - util_hash_table_set(qdws->bo_names, (void *)(uintptr_t)res->flink_name, res); - util_hash_table_set(qdws->bo_handles, (void *)(uintptr_t)res->bo_handle, res); + _mesa_hash_table_insert(qdws->bo_names, (void *)(uintptr_t)res->flink_name, res); + _mesa_hash_table_insert(qdws->bo_handles, (void *)(uintptr_t)res->bo_handle, res); done: mtx_unlock(&qdws->bo_handles_mutex); @@ -417,7 +417,7 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, res->flink_name = flink.name; mtx_lock(&qdws->bo_handles_mutex); - util_hash_table_set(qdws->bo_names, (void *)(uintptr_t)res->flink_name, res); + _mesa_hash_table_insert(qdws->bo_names, (void *)(uintptr_t)res->flink_name, res); mtx_unlock(&qdws->bo_handles_mutex); } whandle->handle = res->flink_name; @@ -427,7 +427,7 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, if (drmPrimeHandleToFD(qdws->fd, res->bo_handle, DRM_CLOEXEC, (int*)&whandle->handle)) return FALSE; mtx_lock(&qdws->bo_handles_mutex); - util_hash_table_set(qdws->bo_handles, (void *)(uintptr_t)res->bo_handle, res); + _mesa_hash_table_insert(qdws->bo_handles, (void *)(uintptr_t)res->bo_handle, res); mtx_unlock(&qdws->bo_handles_mutex); } @@ -1017,7 +1017,7 @@ virgl_drm_screen_destroy(struct pipe_screen *pscreen) destroy = --screen->refcnt == 0; if (destroy) { int fd = virgl_drm_winsys(screen->vws)->fd; - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); + _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(fd)); close(fd); } mtx_unlock(&virgl_screen_mutex); @@ -1055,7 +1055,7 @@ virgl_drm_screen_create(int fd, const struct pipe_screen_config *config) pscreen = virgl_create_screen(vws, config); if (pscreen) { - util_hash_table_set(fd_tab, intptr_to_pointer(dup_fd), pscreen); + _mesa_hash_table_insert(fd_tab, intptr_to_pointer(dup_fd), pscreen); /* Bit of a hack, to avoid circular linkage dependency, * ie. pipe driver having to call in to winsys, we -- 2.30.2