This helper should be used carefully as setting tiling is a racy operation since it potentially interacts with other processes. Still, it is a useful thing to be able to do.
Cc: mesa-sta...@lists.freedesktop.org --- src/mesa/drivers/dri/i965/brw_bufmgr.c | 27 +++++++++++++++++++++++++++ src/mesa/drivers/dri/i965/brw_bufmgr.h | 10 ++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c index 469895e..dbd13dd 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.c +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c @@ -1133,6 +1133,33 @@ brw_bo_get_tiling(struct brw_bo *bo, uint32_t *tiling_mode, return 0; } +int +brw_bo_set_tiling(struct brw_bo *bo, uint32_t tiling_mode, + uint32_t stride) +{ + struct brw_bufmgr *bufmgr = bo->bufmgr; + + mtx_lock(&bufmgr->lock); + + if (bo->tiling_mode != tiling_mode || bo->stride != stride) { + /* We can't have any GTT maps active if we're switching tiling modes */ + assert(bo->map_gtt == NULL); + + /* This function should only be called immediately after import. If + * the BO came from something that sets the tiling, they should agree. + * Otherwise, the tiling should be NONE. + */ + assert(bo->tiling_mode == I915_TILING_NONE || + bo->tiling_mode == tiling_mode); + } + + int ret = bo_set_tiling_internal(bo, tiling_mode, stride); + + mtx_unlock(&bufmgr->lock); + + return ret; +} + struct brw_bo * brw_bo_gem_create_from_prime(struct brw_bufmgr *bufmgr, int prime_fd) { diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h b/src/mesa/drivers/dri/i965/brw_bufmgr.h index 8bfb0e4..66cb3e3 100644 --- a/src/mesa/drivers/dri/i965/brw_bufmgr.h +++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h @@ -288,6 +288,16 @@ int brw_bo_get_tiling(struct brw_bo *bo, uint32_t *tiling_mode, uint32_t *swizzle_mode); /** + * Set the tiling mode and stride for the bo. + * + * \param bo Buffer to set tiling mode on + * \param tiling_mode tiling mode + * \param stride tiled buffer stride + */ +int brw_bo_set_tiling(struct brw_bo *bo, uint32_t tiling_mode, + uint32_t stride); + +/** * Create a visible name for a buffer which can be used by other apps * * \param buf Buffer to create a name for -- 2.5.0.400.gff86faf _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev