diff options
author | Eric Anholt <[email protected]> | 2014-08-04 13:01:29 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-11 14:45:32 -0700 |
commit | 8ebfa8fdb27bb5efaeda4fe567622d5de4779342 (patch) | |
tree | 47548c9f35b1a1b6126246eae23cdf0960c2564a /src/gallium/drivers/vc4/vc4_bufmgr.c | |
parent | cdc208bdaf90017c2e1aaa54d2318b956e801ca0 (diff) |
vc4: Use GEM under simulation even for non-winsys BOs.
In addition to reducing sim-specific code, it also avoids our local handle
allocation conflicting with the host GEM's handle numbering, which was
causing vc4_gem_hindex() to not distinguish between winsys BOs and the
same-numbered non-winsys bo.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_bufmgr.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_bufmgr.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c index 581ba89fd07..faec853ec8d 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.c +++ b/src/gallium/drivers/vc4/vc4_bufmgr.c @@ -45,7 +45,6 @@ vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name) bo->size = size; bo->name = name; -#ifndef USE_VC4_SIMULATOR struct drm_mode_create_dumb create; memset(&create, 0, sizeof(create)); @@ -59,12 +58,6 @@ vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name) bo->handle = create.handle; assert(create.size >= size); -#else /* USE_VC4_SIMULATOR */ - static int next_handle = 0; - bo->handle = next_handle++; - - bo->map = malloc(size); -#endif /* USE_VC4_SIMULATOR */ return bo; } @@ -72,20 +65,23 @@ vc4_bo_alloc(struct vc4_screen *screen, uint32_t size, const char *name) void vc4_bo_free(struct vc4_bo *bo) { -#ifndef USE_VC4_SIMULATOR struct vc4_screen *screen = bo->screen; - if (bo->map) + if (bo->map) { +#ifdef USE_VC4_SIMULATOR + if (bo->simulator_winsys_map) { + free(bo->map); + bo->map = bo->simulator_winsys_map; + } +#endif munmap(bo->map, bo->size); + } struct drm_gem_close c; c.handle = bo->handle; int ret = drmIoctl(screen->fd, DRM_IOCTL_GEM_CLOSE, &c); if (ret != 0) fprintf(stderr, "close object %d: %s\n", bo->handle, strerror(errno)); -#else - free(bo->map); -#endif free(bo); } @@ -137,7 +133,6 @@ vc4_bo_alloc_mem(struct vc4_screen *screen, const void *data, uint32_t size, bool vc4_bo_flink(struct vc4_bo *bo, uint32_t *name) { -#ifndef USE_VC4_SIMULATOR struct drm_gem_flink flink = { .handle = bo->handle, }; @@ -150,7 +145,6 @@ vc4_bo_flink(struct vc4_bo *bo, uint32_t *name) } *name = flink.name; -#endif /* USE_VC4_SIMULATOR */ return true; } |