diff options
author | Keith Packard <keithp@keithp.com> | 2008-05-12 12:15:09 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2008-05-12 12:15:09 -0700 |
commit | 10f1d835b8ac7bf3153ac39d295ad2a72c4aa076 (patch) | |
tree | 945602b599119e48234400c8e0c363f7b6da9b5c | |
parent | 417f86d80525d2f5038628afba8f70f8c0fecca3 (diff) |
Record alignment requirements in mem structure for use by GEM.
GEM needs memory alignment requirements sent at pin time, which is a bit
after the allocation itself. Store the required alignment in the memory
object for later use by pin.
-rw-r--r-- | src/i830.h | 2 | ||||
-rw-r--r-- | src/i830_dri.c | 19 | ||||
-rw-r--r-- | src/i830_memory.c | 19 |
3 files changed, 21 insertions, 19 deletions
@@ -196,6 +196,8 @@ struct _i830_memory { #ifdef XF86DRI_MM uint32_t gem_handle; + uint32_t alignment; + uint32_t gem_name; Bool lifetime_fixed_offset; #endif }; diff --git a/src/i830_dri.c b/src/i830_dri.c index 239ed6b0..1cd1732a 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -1519,12 +1519,19 @@ i830_name_buffer (ScrnInfoPtr pScrn, i830_memory *mem) struct drm_gem_name name; int ret; - name.handle = mem->gem_handle; - ret = ioctl(pI830->drmSubFD, DRM_IOCTL_GEM_NAME, &name); - if (ret == 0) - return name.name; - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "[drm] failed to name buffer %d\n", -errno); + if (!mem->gem_name) + { + name.handle = mem->gem_handle; + ret = ioctl(pI830->drmSubFD, DRM_IOCTL_GEM_NAME, &name); + if (ret != 0) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] failed to name buffer %d\n", -errno); + return -1; + } + mem->gem_name = name.name; + } + return mem->gem_name; } #endif return -1; diff --git a/src/i830_memory.c b/src/i830_memory.c index 550b4d85..6f3c06b9 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -171,19 +171,10 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem) int ret; pin.handle = mem->gem_handle; - pin.alignment = 0; - if (mem->tiling) { - if (IS_I965G(pI830)) - pin.alignment = 0; - else { - if (IS_I9XX (pI830)) - pin.alignment = 1024 * 1024; - else - pin.alignment = 512 * 1024; - if (pin.alignment < mem->size) - pin.alignment = mem->size; - } - } + pin.alignment = mem->alignment; + xf86DrvMsg (pScrn->scrnIndex, X_ERROR, + "alignment %d size %d\n", mem->alignment, mem->size); + ret = ioctl(pI830->drmSubFD, DRM_IOCTL_I915_GEM_PIN, &pin); if (ret != 0) return FALSE; @@ -638,6 +629,7 @@ i830_allocate_aperture(ScrnInfoPtr pScrn, const char *name, size = ALIGN(size, GTT_PAGE_SIZE); mem->size = size; mem->allocated_size = size; + mem->alignment = alignment; if (alignment < GTT_PAGE_SIZE) alignment = GTT_PAGE_SIZE; @@ -771,6 +763,7 @@ i830_allocate_memory_bo(ScrnInfoPtr pScrn, const char *name, mem->end = -1; mem->size = size; mem->allocated_size = size; + mem->alignment = align; if (flags & NEED_LIFETIME_FIXED) mem->lifetime_fixed_offset = TRUE; |