xf86-video-intel: Branch 'intel-batchbuffer' - src/i830_video.c src/i830_video.h src/i965_video.c

Kristian Høgsberg krh at kemper.freedesktop.org
Thu Mar 27 16:25:45 PDT 2008


 src/i830_video.c |   22 ----------------------
 src/i830_video.h |    1 -
 src/i965_video.c |   31 +++++++++++++++++++++----------
 3 files changed, 21 insertions(+), 33 deletions(-)

New commits:
commit 1c541d7d1f2f8d54ec6f9c4309d44e069b17514e
Author: Kristian Høgsberg <krh at jiraiya.boston.redhat.com>
Date:   Thu Mar 27 19:18:01 2008 -0400

    textured xv: Allocate state buffer per frame instead of reusing it.
    
    Relocations are never cleared since batch/state buffers aren't supposed
    to be reused.  This leads to a crash after approximately 30 seconds of
    video when we run out of relocs.
    
    This fixes the textured video to just allocated the state buffer on the fly,
    which is also a nice cleanup and avoid unnecessary syncing.

diff --git a/src/i830_video.c b/src/i830_video.c
index 645e25c..dc7c773 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -842,7 +842,6 @@ I830SetupImageVideoOverlay(ScreenPtr pScreen)
     pPriv->current_crtc = NULL;
     pPriv->desired_crtc = NULL;
     pPriv->buf = NULL;
-    pPriv->state = NULL;
     pPriv->currentBuf = 0;
     pPriv->gamma5 = 0xc0c0c0;
     pPriv->gamma4 = 0x808080;
@@ -956,7 +955,6 @@ I830SetupImageVideoTextured(ScreenPtr pScreen)
 	pPriv->textured = TRUE;
 	pPriv->videoStatus = 0;
 	pPriv->buf = NULL;
-	pPriv->state = NULL;
 	pPriv->currentBuf = 0;
 	pPriv->doubleBuffer = 0;
 
@@ -1023,10 +1021,6 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
 	I830Sync(pScrn);
 	dri_bo_unreference(pPriv->buf);
 	pPriv->buf = NULL;
-	if (pPriv->state) {
-	    dri_bo_unreference(pPriv->state);
-	    pPriv->state = NULL;
-	}
 	pPriv->videoStatus = 0;
     } else {
 	if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
@@ -2360,18 +2354,6 @@ I830PutImage(ScrnInfoPtr pScrn,
     if (pPriv->buf == NULL)
 	return BadAlloc;
 
-    if (pPriv->state == NULL && IS_I965G(pI830)) {
-	pPriv->state = dri_bo_alloc(pI830->bufmgr,
-				    "xv buffer", BRW_LINEAR_EXTRA, 4096,
-				    DRM_BO_FLAG_MEM_LOCAL |
-				    DRM_BO_FLAG_CACHED |
-				    DRM_BO_FLAG_CACHED_MAPPED);
-	if (pPriv->state == NULL) {
-	    dri_bo_unreference(pPriv->buf);
-	    return BadAlloc;
-	}
-    }
-
     /* fixup pointers */
     pPriv->YBuf0offset = 0;
     if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
@@ -2614,10 +2596,6 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
 		I830Sync(pScrn);
 		dri_bo_unreference(pPriv->buf);
 		pPriv->buf = NULL;
-		if (pPriv->state) {
-		    dri_bo_unreference(pPriv->state);
-		    pPriv->state = NULL;
-		}
 		pPriv->videoStatus = 0;
 	    }
 	}
diff --git a/src/i830_video.h b/src/i830_video.h
index b5f6a47..9921847 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -59,7 +59,6 @@ typedef struct {
    Time offTime;
    Time freeTime;
    dri_bo *buf; /** YUV data buffer */
-   dri_bo *state; /** State buffer */
 
    Bool overlayOK;
    int oneLineMode;
diff --git a/src/i965_video.c b/src/i965_video.c
index 91b9f39..70b7b53 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -183,6 +183,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     int next_offset, total_state_size;
     int vb_size = (4 * 4) * 4; /* 4 DWORDS per vertex */
     char *state_base;
+    dri_bo *state; /** State buffer */
 
 #if 0
     ErrorF("BroadwaterDisplayVideoTextured: %dx%d (pitch %d)\n", width, height,
@@ -199,6 +200,14 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 
     assert((id == FOURCC_UYVY) || (id == FOURCC_YUY2));
 
+    state = dri_bo_alloc(pI830->bufmgr,
+			 "xv buffer", BRW_LINEAR_EXTRA, 4096,
+			 DRM_BO_FLAG_MEM_LOCAL |
+			 DRM_BO_FLAG_CACHED |
+			 DRM_BO_FLAG_CACHED_MAPPED);
+    if (state == NULL)
+      return 
+
     IntelEmitInvarientState(pScrn);
     *pI830->last_3d = LAST_3D_VIDEO;
 
@@ -241,11 +250,11 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     next_offset = binding_table_offset + (WM_BINDING_TABLE_ENTRIES * 4);
 
     total_state_size = next_offset;
-    assert (total_state_size < pPriv->state->size);
+    assert (total_state_size < state->size);
 
-    dri_bo_map(pPriv->state, TRUE);
+    dri_bo_map(state, TRUE);
     
-    state_base = (char *) pPriv->state->virtual;
+    state_base = (char *) state->virtual;
     /* 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.
@@ -370,7 +379,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 					     DRM_BO_FLAG_MEM_TT |
 					     DRM_BO_FLAG_WRITE |
 					     DRM_BO_FLAG_READ,
-					     pPriv->state,
+					     state,
 					     (char *) &dest_surf_state->ss1.base_addr -
 					     state_base,
 					     0);
@@ -409,7 +418,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     src_surf_state->ss0.render_cache_read_mode = 0;
 
     if (pI830->use_ttm_batch) {
-	dri_emit_reloc(pPriv->state,
+	dri_emit_reloc(state,
 		       DRM_BO_FLAG_MEM_TT |
 		       DRM_BO_FLAG_WRITE | 
 		       DRM_BO_FLAG_READ,
@@ -513,7 +522,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     wm_state->wm5.enable_8_pix = 0;
     wm_state->wm5.early_depth_test = 1;
 
-    dri_bo_unmap(pPriv->state);
+    dri_bo_unmap(state);
 
     {
 	BEGIN_BATCH(2);
@@ -543,10 +552,10 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 	 * to our buffer.
 	 */
 	OUT_BATCH(BRW_STATE_BASE_ADDRESS | 4);
-	OUT_RELOC(pPriv->state,	/* General state base address */
+	OUT_RELOC(state,	/* General state base address */
 		  DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		  BASE_ADDRESS_MODIFY);
-	OUT_RELOC(pPriv->state,	/* Surface state base address */
+	OUT_RELOC(state,	/* Surface state base address */
 		  DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		  BASE_ADDRESS_MODIFY);
 	OUT_BATCH(0 | BASE_ADDRESS_MODIFY);  /* media base addr, don't care */
@@ -558,7 +567,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 	/* Set system instruction pointer */
 	OUT_BATCH(BRW_STATE_SIP | 0);
 	/* system instruction pointer */
-	OUT_RELOC(pPriv->state,
+	OUT_RELOC(state,
 		  DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		  sip_kernel_offset);
 	OUT_BATCH(MI_NOOP);
@@ -650,7 +659,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
        OUT_BATCH((0 << VB0_BUFFER_INDEX_SHIFT) |
 		VB0_VERTEXDATA |
 		((4 * 4) << VB0_BUFFER_PITCH_SHIFT));
-       OUT_RELOC(pPriv->state,
+       OUT_RELOC(state,
 		 DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
 		 vb_offset);
        OUT_BATCH(3); /* four corners to our rectangle */
@@ -682,6 +691,8 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
        ADVANCE_BATCH();
     }
 
+    dri_bo_unreference(state);
+
    /* Set up the offset for translating from the given region (in screen
     * coordinates) to the backing pixmap.
     */


More information about the xorg-commit mailing list