diff options
author | Eric Anholt <eric@anholt.net> | 2008-06-07 13:57:59 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2008-06-10 11:37:04 -0700 |
commit | e930c0dc5b5f98d256a4167ed70ba813c88924d2 (patch) | |
tree | 7ee30a1ae76580f4e843c6e2e5b660bf0813bdaa | |
parent | ecf19e1cda60a938d41413075ae6e00f24e0ec1a (diff) |
Use bufmgr_gem when available instead of the fake bufmgr.
This is a bit unstable still sometimes.
-rw-r--r-- | src/i830_batchbuffer.c | 69 | ||||
-rw-r--r-- | src/i830_driver.c | 32 | ||||
-rw-r--r-- | src/i830_memory.c | 14 |
3 files changed, 78 insertions, 37 deletions
diff --git a/src/i830_batchbuffer.c b/src/i830_batchbuffer.c index 976a405c..416f4d05 100644 --- a/src/i830_batchbuffer.c +++ b/src/i830_batchbuffer.c @@ -98,36 +98,59 @@ intel_batch_flush(ScrnInfoPtr pScrn) dri_bo_unmap(pI830->batch_bo); pI830->batch_ptr = NULL; - dri_process_relocs(pI830->batch_bo); - - if (pI830->directRenderingEnabled) { - struct drm_i915_batchbuffer batch; + if (pI830->memory_manager) { + struct drm_i915_gem_execbuffer *exec; int ret; - batch.start = pI830->batch_bo->offset; - batch.used = pI830->batch_used; - batch.cliprects = NULL; - batch.num_cliprects = 0; - batch.DR1 = 0; - batch.DR4 = 0xffffffff; + exec = dri_process_relocs(pI830->batch_bo); + + exec->batch_start_offset = 0; + exec->batch_len = pI830->batch_used; + exec->cliprects_ptr = 0; + exec->num_cliprects = 0; + exec->DR1 = 0; + exec->DR4 = 0xffffffff; - ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_BATCHBUFFER, - &batch, sizeof(batch)); + ret = drmCommandWriteRead(pI830->drmSubFD, DRM_I915_GEM_EXECBUFFER, + exec, sizeof(*exec)); if (ret != 0) FatalError("Failed to submit batchbuffer: %s\n", strerror(errno)); + + i830_refresh_ring(pScrn); } else { - if (!IS_I830(pI830) && !IS_845G(pI830)) { - BEGIN_LP_RING(2); - OUT_RING(MI_BATCH_BUFFER_START | (2 << 6)); - OUT_RING(pI830->batch_bo->offset); - ADVANCE_LP_RING(); + dri_process_relocs(pI830->batch_bo); + + if (pI830->directRenderingEnabled) { + struct drm_i915_batchbuffer batch; + int ret; + + batch.start = pI830->batch_bo->offset; + batch.used = pI830->batch_used; + batch.cliprects = NULL; + batch.num_cliprects = 0; + batch.DR1 = 0; + batch.DR4 = 0xffffffff; + + ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_BATCHBUFFER, + &batch, sizeof(batch)); + if (ret != 0) + FatalError("Failed to submit batchbuffer: %s\n", strerror(errno)); + + i830_refresh_ring(pScrn); } else { - BEGIN_LP_RING(4); - OUT_RING(MI_BATCH_BUFFER); - OUT_RING(pI830->batch_bo->offset); - OUT_RING(pI830->batch_bo->offset + pI830->batch_used - 4); - OUT_RING(MI_NOOP); - ADVANCE_LP_RING(); + if (!IS_I830(pI830) && !IS_845G(pI830)) { + BEGIN_LP_RING(2); + OUT_RING(MI_BATCH_BUFFER_START | (2 << 6)); + OUT_RING(pI830->batch_bo->offset); + ADVANCE_LP_RING(); + } else { + BEGIN_LP_RING(4); + OUT_RING(MI_BATCH_BUFFER); + OUT_RING(pI830->batch_bo->offset); + OUT_RING(pI830->batch_bo->offset + pI830->batch_used - 4); + OUT_RING(MI_NOOP); + ADVANCE_LP_RING(); + } } } diff --git a/src/i830_driver.c b/src/i830_driver.c index cb9644ee..bce00af1 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -2750,13 +2750,25 @@ i830_init_bufmgr(ScrnInfoPtr pScrn) I830Ptr pI830 = I830PTR(pScrn); assert(pI830->FbBase != NULL); - pI830->bufmgr = intel_bufmgr_fake_init(pI830->fake_bufmgr_mem->offset, - pI830->FbBase + - pI830->fake_bufmgr_mem->offset, - pI830->fake_bufmgr_mem->size, - i830_fake_fence_emit, - i830_fake_fence_wait, - pScrn); + if (pI830->memory_manager) { + int batch_size; + + batch_size = 4096 * 4; + + /* The 865 has issues with larger-than-page-sized batch buffers. */ + if (IS_I865G(pI830)) + batch_size = 4096; + + pI830->bufmgr = intel_bufmgr_gem_init(pI830->drmSubFD, batch_size); + } else { + pI830->bufmgr = intel_bufmgr_fake_init(pI830->fake_bufmgr_mem->offset, + pI830->FbBase + + pI830->fake_bufmgr_mem->offset, + pI830->fake_bufmgr_mem->size, + i830_fake_fence_emit, + i830_fake_fence_wait, + pScrn); + } } @@ -3338,7 +3350,11 @@ I830LeaveVT(int scrnIndex, int flags) RestoreHWState(pScrn); - intel_bufmgr_fake_evict_all(pI830->bufmgr); + /* Evict everything from the bufmgr, as we're about to lose ownership of + * the graphics memory. + */ + if (!pI830->memory_manager) + intel_bufmgr_fake_evict_all(pI830->bufmgr); intel_batch_teardown(pScrn); i830_stop_ring(pScrn, TRUE); diff --git a/src/i830_memory.c b/src/i830_memory.c index 57e4f2e2..db99d97e 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -1375,12 +1375,14 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn) return FALSE; } - pI830->fake_bufmgr_mem = i830_allocate_memory(pScrn, "fake bufmgr", - MB(1), GTT_PAGE_SIZE, 0); - if (pI830->fake_bufmgr_mem == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Failed to allocate fake bufmgr space.\n"); - return FALSE; + if (pI830->memory_manager == NULL) { + pI830->fake_bufmgr_mem = i830_allocate_memory(pScrn, "fake bufmgr", + MB(1), GTT_PAGE_SIZE, 0); + if (pI830->fake_bufmgr_mem == NULL) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Failed to allocate fake bufmgr space.\n"); + return FALSE; + } } /* even in XAA, 965G needs state mem buffer for rendering */ |