diff options
author | Jason Ekstrand <[email protected]> | 2018-01-18 20:39:50 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-01-21 23:07:18 -0800 |
commit | b9e7b29705cb17ef7f88d346db823c9b99810249 (patch) | |
tree | 9c4766b628812002d5a218fb18dc0f6cc111425f /src/mesa/drivers/dri | |
parent | ad424b2243023b0299de700fb2d220c2f7849ce6 (diff) |
i965/bufmgr: Add a create_from_prime_tiled function
This new function is an import and a set tiling in one go.
Reviewed-by: Kenneth Graunke <[email protected]>
Cc: [email protected]
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_bufmgr.c | 39 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_bufmgr.h | 4 |
2 files changed, 35 insertions, 8 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c index 52b5bf97a16..fb180289a0c 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c @@ -1107,8 +1107,9 @@ brw_bo_get_tiling(struct brw_bo *bo, uint32_t *tiling_mode, return 0; } -struct brw_bo * -brw_bo_gem_create_from_prime(struct brw_bufmgr *bufmgr, int prime_fd) +static struct brw_bo * +brw_bo_gem_create_from_prime_internal(struct brw_bufmgr *bufmgr, int prime_fd, + int tiling_mode, uint32_t stride) { uint32_t handle; struct brw_bo *bo; @@ -1157,13 +1158,17 @@ brw_bo_gem_create_from_prime(struct brw_bufmgr *bufmgr, int prime_fd) bo->reusable = false; bo->external = true; - struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle }; - if (drmIoctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling)) - goto err; + if (tiling_mode < 0) { + struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle }; + if (drmIoctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling)) + goto err; - bo->tiling_mode = get_tiling.tiling_mode; - bo->swizzle_mode = get_tiling.swizzle_mode; - /* XXX stride is unknown */ + bo->tiling_mode = get_tiling.tiling_mode; + bo->swizzle_mode = get_tiling.swizzle_mode; + /* XXX stride is unknown */ + } else { + bo_set_tiling_internal(bo, tiling_mode, stride); + } out: mtx_unlock(&bufmgr->lock); @@ -1175,6 +1180,24 @@ err: return NULL; } +struct brw_bo * +brw_bo_gem_create_from_prime(struct brw_bufmgr *bufmgr, int prime_fd) +{ + return brw_bo_gem_create_from_prime_internal(bufmgr, prime_fd, -1, 0); +} + +struct brw_bo * +brw_bo_gem_create_from_prime_tiled(struct brw_bufmgr *bufmgr, int prime_fd, + uint32_t tiling_mode, uint32_t stride) +{ + assert(tiling_mode == I915_TILING_NONE || + tiling_mode == I915_TILING_X || + tiling_mode == I915_TILING_Y); + + return brw_bo_gem_create_from_prime_internal(bufmgr, prime_fd, + tiling_mode, stride); +} + static void brw_bo_make_external(struct brw_bo *bo) { diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h index 0ae541cda0d..a3745d6667a 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.h +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h @@ -336,6 +336,10 @@ void brw_destroy_hw_context(struct brw_bufmgr *bufmgr, uint32_t ctx_id); int brw_bo_gem_export_to_prime(struct brw_bo *bo, int *prime_fd); struct brw_bo *brw_bo_gem_create_from_prime(struct brw_bufmgr *bufmgr, int prime_fd); +struct brw_bo *brw_bo_gem_create_from_prime_tiled(struct brw_bufmgr *bufmgr, + int prime_fd, + uint32_t tiling_mode, + uint32_t stride); uint32_t brw_bo_export_gem_handle(struct brw_bo *bo); |