diff options
author | Rob Herring <[email protected]> | 2016-07-22 15:28:30 -0500 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-07-26 13:47:50 -0700 |
commit | 9ace2c13550609dfe78164f104500d438821f383 (patch) | |
tree | 1b556d0fe722c7bb2603786ebdd1bf49a0ba8068 /src/gallium/drivers/vc4/vc4_screen.c | |
parent | ce8504d196291452b42ed755ed3830ecb16febcd (diff) |
vc4: add hash table look-up for exported dmabufs
It is necessary to reuse existing BOs when dmabufs are imported. There
are 2 cases that need to be handled. dmabufs can be created/exported and
imported by the same process and can be imported multiple times.
Copying other drivers, add a hash table to track exported BOs so the
BOs get reused.
v2: Whitespace fixup (by anholt)
Signed-off-by: Rob Herring <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_screen.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_screen.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c index 5882f070340..aeb6c9a784e 100644 --- a/src/gallium/drivers/vc4/vc4_screen.c +++ b/src/gallium/drivers/vc4/vc4_screen.c @@ -30,6 +30,7 @@ #include "util/u_debug.h" #include "util/u_memory.h" #include "util/u_format.h" +#include "util/u_hash_table.h" #include "util/ralloc.h" #include <xf86drm.h> @@ -508,6 +509,18 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen, return retval == usage; } +#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) + +static unsigned handle_hash(void *key) +{ + return PTR_TO_UINT(key); +} + +static int handle_compare(void *key1, void *key2) +{ + return PTR_TO_UINT(key1) != PTR_TO_UINT(key2); +} + static bool vc4_supports_branches(struct vc4_screen *screen) { @@ -595,6 +608,8 @@ vc4_screen_create(int fd) screen->fd = fd; list_inithead(&screen->bo_cache.time_list); + pipe_mutex_init(screen->bo_handles_mutex); + screen->bo_handles = util_hash_table_create(handle_hash, handle_compare); if (vc4_supports_branches(screen)) screen->has_control_flow = true; |