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 | |
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')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_bufmgr.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_simulator.c | 1 |
2 files changed, 9 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; } diff --git a/src/gallium/drivers/vc4/vc4_simulator.c b/src/gallium/drivers/vc4/vc4_simulator.c index 88eda4fe722..8038fee5109 100644 --- a/src/gallium/drivers/vc4/vc4_simulator.c +++ b/src/gallium/drivers/vc4/vc4_simulator.c @@ -75,6 +75,7 @@ vc4_simulator_pin_bos(struct drm_device *dev, struct exec_info *exec) struct vc4_bo *bo = bos[i]; struct drm_gem_cma_object *obj = vc4_wrap_bo_with_cma(dev, bo); + vc4_bo_map(bo); memcpy(obj->vaddr, bo->map, bo->size); exec->bo[i].bo = obj; |