xf86-video-intel: Branch 'intel-batchbuffer' - src/i830_dri.c src/i830_video.c src/i830_video.h src/i915_video.c src/i965_video.c src/intel_batchbuffer.c
Kristian Høgsberg
krh at kemper.freedesktop.org
Tue Mar 4 16:00:29 PST 2008
src/i830_dri.c | 2 +
src/i830_video.c | 49 +++++++++++++++------------
src/i830_video.h | 2 -
src/i915_video.c | 18 +++++++---
src/i965_video.c | 85 +++++++++++++++++++++++++++++++++++++++---------
src/intel_batchbuffer.c | 2 -
6 files changed, 114 insertions(+), 44 deletions(-)
New commits:
commit 2b6fad726fbbd18a9d435f87f9404dfa8695d053
Author: Kristian Høgsberg <krh at redhat.com>
Date: Tue Mar 4 18:59:01 2008 -0500
Convert the textured video code to use the dri_bo API.
Now that we have the exa dri_bo implementation, this will continue to
work for non-ttm cases. It doesn't work for i965 TTM due to strange
relocations, where the offset is shifted 5, 6 or 10 bits.
diff --git a/src/i830_dri.c b/src/i830_dri.c
index d95ecb2..3c439b8 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1931,7 +1931,9 @@ I830DRI2Prepare(ScreenPtr pScreen)
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[DRI2] Opened DRM device successfully\n");
+#if 0
I830InitBufMgr(pScreen);
+#endif
if (!pI830->use_ttm_batch)
return;
diff --git a/src/i830_video.c b/src/i830_video.c
index 8f0ac30..ccde947 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1018,7 +1018,7 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
/* Sync before freeing the buffer, because the pages will be unbound.
*/
I830Sync(pScrn);
- i830_free_memory(pScrn, pPriv->buf);
+ dri_bo_unreference(pPriv->buf);
pPriv->buf = NULL;
pPriv->videoStatus = 0;
} else {
@@ -1209,10 +1209,11 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
src = buf + (top * srcPitch) + (left << 1);
+ dri_bo_map(pPriv->buf, TRUE);
if (pPriv->currentBuf == 0)
- dst = pI830->FbBase + pPriv->YBuf0offset;
+ dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
else
- dst = pI830->FbBase + pPriv->YBuf1offset;
+ dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
switch (pPriv->rotation) {
case RR_Rotate_0:
@@ -1285,6 +1286,7 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
}
break;
}
+ dri_bo_unmap(pPriv->buf);
}
/* Copies planar data in *buf to UYVY-packed data in the screen atYBufXOffset.
@@ -1299,10 +1301,11 @@ I830CopyPlanarToPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
CARD8 *dst1, *srcy, *srcu, *srcv;
int y;
+ dri_bo_map(pPriv->buf, TRUE);
if (pPriv->currentBuf == 0)
- dst1 = pI830->FbBase + pPriv->YBuf0offset;
+ dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
else
- dst1 = pI830->FbBase + pPriv->YBuf1offset;
+ dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
srcy = buf + (top * srcPitch) + left;
if (id == FOURCC_YV12) {
@@ -1344,6 +1347,7 @@ I830CopyPlanarToPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
srcv += srcPitch2;
}
}
+ dri_bo_unmap(pPriv->buf);
}
static void
@@ -1371,10 +1375,11 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
ErrorF("src1 is %p, offset is %ld\n", src1,
(unsigned long)src1 - (unsigned long)buf);
#endif
+ dri_bo_map(pPriv->buf, TRUE);
if (pPriv->currentBuf == 0)
- dst1 = pI830->FbBase + pPriv->YBuf0offset;
+ dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
else
- dst1 = pI830->FbBase + pPriv->YBuf1offset;
+ dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
switch (pPriv->rotation) {
case RR_Rotate_0:
@@ -1421,14 +1426,14 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
#endif
if (pPriv->currentBuf == 0) {
if (id == FOURCC_I420)
- dst2 = pI830->FbBase + pPriv->UBuf0offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf0offset;
else
- dst2 = pI830->FbBase + pPriv->VBuf0offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf0offset;
} else {
if (id == FOURCC_I420)
- dst2 = pI830->FbBase + pPriv->UBuf1offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf1offset;
else
- dst2 = pI830->FbBase + pPriv->VBuf1offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf1offset;
}
switch (pPriv->rotation) {
@@ -1523,6 +1528,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
}
break;
}
+ dri_bo_unmap(pPriv->buf);
}
typedef struct {
@@ -2341,23 +2347,22 @@ I830PutImage(ScrnInfoPtr pScrn,
/* Free the current buffer if we're going to have to reallocate */
if (pPriv->buf && pPriv->buf->size < alloc_size) {
- i830_free_memory(pScrn, pPriv->buf);
+ dri_bo_unreference(pPriv->buf);
pPriv->buf = NULL;
}
if (pPriv->buf == NULL) {
- pPriv->buf = i830_allocate_memory(pScrn, "xv buffer", alloc_size, 16,
- 0);
+ pPriv->buf = dri_bo_alloc(pI830->bufmgr,
+ "xv buffer", alloc_size, 16, 0);
}
if (pPriv->buf == NULL)
return BadAlloc;
- pPriv->extra_offset = pPriv->buf->offset +
- (pPriv->doubleBuffer ? size * 2 : size);
+ pPriv->extra_offset = (pPriv->doubleBuffer ? size * 2 : size);
/* fixup pointers */
- pPriv->YBuf0offset = pPriv->buf->offset;
+ pPriv->YBuf0offset = 0;
if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * width);
pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * width / 2);
@@ -2596,7 +2601,7 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
* unbound.
*/
I830Sync(pScrn);
- i830_free_memory(pScrn, pPriv->buf);
+ dri_bo_unreference(pPriv->buf);
pPriv->buf = NULL;
pPriv->videoStatus = 0;
}
@@ -2609,7 +2614,7 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
***************************************************************************/
typedef struct {
- i830_memory *buf;
+ dri_bo *buf;
Bool isOn;
} OffscreenPrivRec, *OffscreenPrivPtr;
@@ -2654,7 +2659,7 @@ I830AllocateSurface(ScrnInfoPtr pScrn,
fbpitch = pI830->cpp * pScrn->displayWidth;
size = pitch * h;
- pPriv->buf = i830_allocate_memory(pScrn, "xv surface buffer", size, 16, 0);
+ pPriv->buf = dri_bo_alloc(pI830->bufmgr, "xv surface buffer", size, 16, 0);
if (pPriv->buf == NULL) {
xfree(surface->pitches);
xfree(surface->offsets);
@@ -2670,7 +2675,7 @@ I830AllocateSurface(ScrnInfoPtr pScrn,
surface->pScrn = pScrn;
surface->id = id;
surface->pitches[0] = pitch;
- surface->offsets[0] = pPriv->buf->offset;
+ surface->offsets[0] = 0;
surface->devPrivate.ptr = (pointer) pPriv;
memset(pI830->FbBase + surface->offsets[0], 0, size);
@@ -2709,7 +2714,7 @@ I830FreeSurface(XF86SurfacePtr surface)
I830StopSurface(surface);
/* Sync before freeing the buffer, because the pages will be unbound. */
I830Sync(pScrn);
- i830_free_memory(surface->pScrn, pPriv->buf);
+ dri_bo_unreference(pPriv->buf);
pPriv->buf = NULL;
xfree(surface->pitches);
xfree(surface->offsets);
diff --git a/src/i830_video.h b/src/i830_video.h
index 1768913..c21e5fa 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -58,7 +58,7 @@ typedef struct {
CARD32 videoStatus;
Time offTime;
Time freeTime;
- i830_memory *buf; /** YUV data buffer */
+ dri_bo *buf; /** YUV data buffer */
unsigned int extra_offset;
Bool overlayOK;
diff --git a/src/i915_video.c b/src/i915_video.c
index 6b20ad2..6b3b15e 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -128,7 +128,7 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
OUT_BATCH(BUF_3D_ID_COLOR_BACK | BUF_3D_USE_FENCE |
BUF_3D_PITCH(intel_get_pixmap_pitch(pPixmap)));
- OUT_BATCH(BUF_3D_ADDR(intel_get_pixmap_offset(pPixmap)));
+ OUT_PIXMAP_RELOC(pPixmap, 0, 0);
ADVANCE_BATCH();
if (!planar) {
@@ -148,7 +148,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(_3DSTATE_MAP_STATE | 3);
OUT_BATCH(0x00000001); /* texture map #1 */
- OUT_BATCH(pPriv->YBuf0offset);
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ pPriv->YBuf0offset);
ms3 = MAPSURF_422 | MS3_USE_FENCE_REGS;
switch (id) {
case FOURCC_YUY2:
@@ -245,21 +247,27 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(_3DSTATE_MAP_STATE | 9);
OUT_BATCH(0x00000007);
- OUT_BATCH(pPriv->YBuf0offset);
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ pPriv->YBuf0offset);
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width - 1) << MS3_WIDTH_SHIFT;
OUT_BATCH(ms3);
OUT_BATCH(((video_pitch * 2 / 4) - 1) << MS4_PITCH_SHIFT);
- OUT_BATCH(pPriv->UBuf0offset);
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ pPriv->UBuf0offset);
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;
OUT_BATCH(ms3);
OUT_BATCH(((video_pitch / 4) - 1) << MS4_PITCH_SHIFT);
- OUT_BATCH(pPriv->VBuf0offset);
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ pPriv->VBuf0offset);
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;
diff --git a/src/i965_video.c b/src/i965_video.c
index 6d04613..fc8b42c 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -251,7 +251,9 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
state_base_offset = pPriv->extra_offset;
state_base_offset = ALIGN(state_base_offset, 64);
- state_base = (char *)(pI830->FbBase + state_base_offset);
+ dri_bo_map(pPriv->buf, TRUE);
+
+ state_base = (char *) pPriv->buf->virtual + state_base_offset;
/* Set up our pointers to state structures in framebuffer. It would
* probably be a good idea to fill these structures out in system memory
* and then dump them there, instead.
@@ -340,7 +342,10 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
cc_state->cc3.ia_blend_enable = 1; /* blend alpha just like colors */
cc_state->cc3.blend_enable = 0; /* disable color blend */
cc_state->cc3.alpha_test = 0; /* disable alpha test */
- cc_state->cc4.cc_viewport_state_offset = (state_base_offset +
+
+ /* FIXME: Eek! No relocation to match this... */
+ cc_state->cc4.cc_viewport_state_offset = (pPriv->buf->offset +
+ state_base_offset +
cc_viewport_offset) >> 5;
cc_state->cc5.dither_enable = 0; /* disable dither */
cc_state->cc5.logicop_func = 0xc; /* WHITE */
@@ -371,7 +376,19 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
dest_surf_state->ss0.mipmap_layout_mode = 0;
dest_surf_state->ss0.render_cache_read_mode = 0;
- dest_surf_state->ss1.base_addr = intel_get_pixmap_offset(pPixmap);
+ if (pI830->use_ttm_batch)
+ dest_surf_state->ss1.base_addr =
+ intelddx_batchbuffer_emit_pixmap(pPixmap,
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_WRITE |
+ DRM_BO_FLAG_READ,
+ pPriv->buf,
+ (char *) &dest_surf_state->ss1.base_addr -
+ (char *) pPriv->buf->virtual,
+ 0);
+ else
+ dest_surf_state->ss1.base_addr = intel_get_pixmap_offset(pPixmap);
+
dest_surf_state->ss2.height = pScrn->virtualY - 1;
dest_surf_state->ss2.width = pScrn->virtualX - 1;
dest_surf_state->ss2.mip_count = 0;
@@ -403,7 +420,20 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
src_surf_state->ss0.mipmap_layout_mode = 0;
src_surf_state->ss0.render_cache_read_mode = 0;
- src_surf_state->ss1.base_addr = pPriv->YBuf0offset;
+
+ if (pI830->use_ttm_batch)
+ src_surf_state->ss1.base_addr =
+ intelddx_batchbuffer_emit_pixmap(pPixmap,
+ DRM_BO_FLAG_MEM_TT |
+ DRM_BO_FLAG_READ,
+ pPriv->buf,
+ (char *) &src_surf_state->ss1.base_addr -
+ (char *) pPriv->buf->virtual,
+ pPriv->YBuf0offset);
+ else
+ src_surf_state->ss1.base_addr =
+ pPriv->buf->offset + pPriv->YBuf0offset;
+
src_surf_state->ss2.width = width - 1;
src_surf_state->ss2.height = height - 1;
src_surf_state->ss2.mip_count = 0;
@@ -439,8 +469,11 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
memcpy (sf_kernel, sf_kernel_static, sizeof (sf_kernel_static));
memset(sf_state, 0, sizeof(*sf_state));
+
+ /* FIXME: Eek! No relocation to match this... */
sf_state->thread0.kernel_start_pointer =
- (state_base_offset + sf_kernel_offset) >> 6;
+ (pPriv->buf->offset + state_base_offset + sf_kernel_offset) >> 6;
+
sf_state->thread0.grf_reg_count = BRW_GRF_BLOCKS(SF_KERNEL_NUM_GRF);
sf_state->sf1.single_program_flow = 1; /* XXX */
sf_state->sf1.binding_table_entry_count = 0;
@@ -470,16 +503,22 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
memcpy (ps_kernel, ps_kernel_static, sizeof (ps_kernel_static));
memset (wm_state, 0, sizeof (*wm_state));
+
+ /* FIXME: Eek! No relocation to match this... */
wm_state->thread0.kernel_start_pointer =
- (state_base_offset + ps_kernel_offset) >> 6;
+ (pPriv->buf->offset + state_base_offset + ps_kernel_offset) >> 6;
+
wm_state->thread0.grf_reg_count = BRW_GRF_BLOCKS(PS_KERNEL_NUM_GRF);
wm_state->thread1.single_program_flow = 1; /* XXX */
wm_state->thread1.binding_table_entry_count = 2;
/* Though we never use the scratch space in our WM kernel, it has to be
* set, and the minimum allocation is 1024 bytes.
*/
- wm_state->thread2.scratch_space_base_pointer = (state_base_offset +
+ /* FIXME: Eek! No relocation to match this... */
+ wm_state->thread2.scratch_space_base_pointer = (pPriv->buf->offset +
+ state_base_offset +
wm_scratch_offset) >> 10;
+
wm_state->thread2.per_thread_scratch_space = 0; /* 1024 bytes */
wm_state->thread3.dispatch_grf_start_reg = 3; /* XXX */
wm_state->thread3.const_urb_entry_read_length = 0;
@@ -487,8 +526,12 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
wm_state->thread3.urb_entry_read_length = 1; /* XXX */
wm_state->thread3.urb_entry_read_offset = 0; /* XXX */
wm_state->wm4.stats_enable = 1;
- wm_state->wm4.sampler_state_pointer = (state_base_offset +
+
+ /* FIXME: Eek! No relocation to match this... */
+ wm_state->wm4.sampler_state_pointer = (pPriv->buf->offset +
+ state_base_offset +
src_sampler_offset) >> 5;
+
wm_state->wm4.sampler_count = 1; /* 1-4 samplers used */
wm_state->wm5.max_threads = PS_MAX_THREADS - 1;
wm_state->wm5.thread_dispatch_enable = 1;
@@ -535,8 +578,9 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
/* Set system instruction pointer */
OUT_BATCH(BRW_STATE_SIP | 0);
/* system instruction pointer */
- OUT_BATCH(state_base_offset + sip_kernel_offset);
-
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ state_base_offset + sip_kernel_offset);
OUT_BATCH(MI_NOOP);
ADVANCE_BATCH();
}
@@ -564,7 +608,9 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(0); /* clip */
OUT_BATCH(0); /* sf */
/* Only the PS uses the binding table */
- OUT_BATCH(state_base_offset + binding_table_offset); /* ps */
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ state_base_offset + binding_table_offset); /* ps */
/* Blend constant color (magenta is fun) */
OUT_BATCH(BRW_3DSTATE_CONSTANT_COLOR | 3);
@@ -594,9 +640,16 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(BRW_GS_DISABLE);
/* disable CLIP, resulting in passthrough */
OUT_BATCH(BRW_CLIP_DISABLE);
- OUT_BATCH(state_base_offset + sf_offset); /* 32 byte aligned */
- OUT_BATCH(state_base_offset + wm_offset); /* 32 byte aligned */
- OUT_BATCH(state_base_offset + cc_offset); /* 64 byte aligned */
+
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ state_base_offset + sf_offset); /* 32 byte aligned */
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ state_base_offset + wm_offset); /* 32 byte aligned */
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ state_base_offset + cc_offset); /* 64 byte aligned */
/* URB fence */
OUT_BATCH(BRW_URB_FENCE |
@@ -623,7 +676,9 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH((0 << VB0_BUFFER_INDEX_SHIFT) |
VB0_VERTEXDATA |
((4 * 4) << VB0_BUFFER_PITCH_SHIFT));
- OUT_BATCH(state_base_offset + vb_offset);
+ OUT_RELOC(pPriv->buf,
+ DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
+ state_base_offset + vb_offset);
OUT_BATCH(3); /* four corners to our rectangle */
/* Set up our vertex elements, sourced from the single vertex buffer. */
diff --git a/src/intel_batchbuffer.c b/src/intel_batchbuffer.c
index 460a886..3362a46 100644
--- a/src/intel_batchbuffer.c
+++ b/src/intel_batchbuffer.c
@@ -276,5 +276,5 @@ uint32_t intelddx_batchbuffer_emit_pixmap(PixmapPtr pPixmap,
driver_priv = exaGetPixmapDriverPrivate(pPixmap);
dri_emit_reloc(reloc_buf, flags, delta, offset, driver_priv->bo);
- return driver_priv->bo->offset;
+ return driver_priv->bo->offset + delta;
}
More information about the xorg-commit
mailing list