[Intel-gfx] [PATCH] intel: Keep track of tiling bits on objects in userland.
Eric Anholt
eric at anholt.net
Mon Dec 15 21:49:40 CET 2008
This saves about 15% CPU in resizing emacs due to lots of little rendering that
keeps asking about tiling.
---
libdrm/intel/intel_bufmgr_gem.c | 41 +++++++++++++++++++++++++++++++-------
1 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c
index 6b876d4..832fc28 100644
--- a/libdrm/intel/intel_bufmgr_gem.c
+++ b/libdrm/intel/intel_bufmgr_gem.c
@@ -159,15 +159,20 @@ struct _drm_intel_bo_gem {
* the common case.
*/
int reloc_tree_size;
+
+ uint32_t tiling;
+ uint32_t swizzle;
};
static void drm_intel_gem_bo_reference_locked(drm_intel_bo *bo);
+static void drm_intel_gem_bo_unreference(drm_intel_bo *bo);
static unsigned int
drm_intel_gem_estimate_batch_space(drm_intel_bo **bo_array, int count);
static unsigned int
drm_intel_gem_compute_batch_space(drm_intel_bo **bo_array, int count);
+static int drm_intel_gem_bo_get_tiling_ioctl(drm_intel_bo *bo);
static int
logbase2(int n)
@@ -369,6 +374,8 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
bo_gem->validate_index = -1;
bo_gem->reloc_tree_size = bo_gem->bo.size;
bo_gem->used_as_reloc_target = 0;
+ bo_gem->tiling = I915_TILING_NONE;
+ bo_gem->swizzle = I915_BIT_6_SWIZZLE_NONE;
DBG("bo_create: buf %d (%s) %ldb\n",
bo_gem->gem_handle, bo_gem->name, size);
@@ -414,6 +421,12 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr, const char *name,
bo_gem->gem_handle = open_arg.handle;
bo_gem->global_name = handle;
+ ret = drm_intel_gem_bo_get_tiling_ioctl(&bo_gem->bo);
+ if (ret != 0) {
+ drm_intel_gem_bo_unreference(&bo_gem->bo);
+ return NULL;
+ }
+
DBG("bo_create_from_handle: %d (%s)\n", handle, bo_gem->name);
return &bo_gem->bo;
@@ -930,7 +943,7 @@ drm_intel_gem_bo_exec(drm_intel_bo *bo, int used,
bufmgr_gem->exec_count),
drm_intel_gem_compute_batch_space(bufmgr_gem->exec_bos,
bufmgr_gem->exec_count),
- bufmgr_gem->gtt_size);
+ (unsigned int)bufmgr_gem->gtt_size);
}
drm_intel_update_buffer_offsets (bufmgr_gem);
@@ -1009,14 +1022,14 @@ drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
*tiling_mode = I915_TILING_NONE;
return -errno;
}
+ (void)drm_intel_gem_bo_get_tiling_ioctl(bo);
*tiling_mode = set_tiling.tiling_mode;
return 0;
}
static int
-drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
- uint32_t *swizzle_mode)
+drm_intel_gem_bo_get_tiling_ioctl(drm_intel_bo *bo)
{
drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bo->bufmgr;
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
@@ -1024,16 +1037,28 @@ drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
int ret;
get_tiling.handle = bo_gem->gem_handle;
-
ret = ioctl(bufmgr_gem->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
if (ret != 0) {
- *tiling_mode = I915_TILING_NONE;
- *swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
+ fprintf(stderr, "DRM_IOCTL_I915_GEM_GET_TILING failed: %s\n",
+ strerror(errno));
+ bo_gem->tiling = I915_TILING_NONE;
+ bo_gem->swizzle = I915_BIT_6_SWIZZLE_NONE;
return -errno;
}
+ bo_gem->tiling = get_tiling.tiling_mode;
+ bo_gem->swizzle = get_tiling.swizzle_mode;
+ return 0;
+}
+
+static int
+drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t *tiling_mode,
+ uint32_t *swizzle_mode)
+{
+ drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *)bo;
+
+ *tiling_mode = bo_gem->tiling;
+ *swizzle_mode = bo_gem->swizzle;
- *tiling_mode = get_tiling.tiling_mode;
- *swizzle_mode = get_tiling.swizzle_mode;
return 0;
}
--
1.5.6.5
More information about the Intel-gfx
mailing list