xf86-video-intel: 4 commits - configure.ac src/i830_dri.c src/i830_driver.c src/i830_exa.c src/i830.h src/i830_render.c src/i915_reg.h src/i915_render.c src/i915_video.c src/i965_render.c src/i965_video.c

Eric Anholt anholt at kemper.freedesktop.org
Tue Jun 12 10:03:03 PDT 2007


 configure.ac      |    8 --------
 src/i830.h        |    3 +--
 src/i830_dri.c    |    8 +++-----
 src/i830_driver.c |   42 ++++++++++++++++++++++++------------------
 src/i830_exa.c    |   16 ----------------
 src/i830_render.c |    3 ++-
 src/i915_reg.h    |    4 ++--
 src/i915_render.c |    3 ++-
 src/i915_video.c  |   20 +++++---------------
 src/i965_render.c |    3 ++-
 src/i965_video.c  |   16 ++--------------
 11 files changed, 43 insertions(+), 83 deletions(-)

New commits:
diff-tree ceb6dd72443c094212b0281c42cbe92e9a29f682 (from c2b130354aecffbeb2a2d23c7371461feaf5766a)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jun 4 16:37:53 2007 -0700

    Fix context switching between DRI and X.
    
    Now, all 3D pipeline consumers in the driver just call
    IntelEmitInvariantState(), which handles basic state setup, the caching of that
    state setup, and notifying DRI clients.  This also removes a mistaken idle
    wait in the Render code which was papering over the brokenness in the context
    switching.

diff --git a/src/i830.h b/src/i830.h
index e4d5070..8947524 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -307,7 +307,6 @@ typedef struct _I830Rec {
    Rotation rotation;
    void (*PointerMoved)(int, int, int);
    CreateScreenResourcesProcPtr    CreateScreenResources;
-   int *used3D;
 
    i830_memory *logical_context;
 
@@ -527,7 +526,7 @@ typedef struct _I830Rec {
    CARD32 saveSWF[17];
    CARD32 saveBLC_PWM_CTL;
 
-   enum last_3d last_3d;
+   enum last_3d *last_3d;
 
    /** Enables logging of debug output related to mode switching. */
    Bool debug_modes;
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 4746be0..6ec56cf 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1196,7 +1196,7 @@ I830DRISwapContext(ScreenPtr pScreen, DR
       if (I810_DEBUG & DEBUG_VERBOSE_DRI)
 	 ErrorF("i830DRISwapContext (in)\n");
 
-      pI830->last_3d = LAST_3D_OTHER;
+      *pI830->last_3d = LAST_3D_OTHER;
 
       if (!pScrn->vtSema)
      	 return;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 3133d77..7f1fe2c 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2045,22 +2045,25 @@ I830InitFBManager(
    return ret;
 }
 
-/* Initialize the first context */
+/**
+ * Intialiazes the hardware for the 3D pipeline use in the 2D driver.
+ *
+ * Some state caching is performed to avoid redundant state emits.  This
+ * function is also responsible for marking the state as clobbered for DRI
+ * clients.
+ */
 void
 IntelEmitInvarientState(ScrnInfoPtr pScrn)
 {
    I830Ptr pI830 = I830PTR(pScrn);
    CARD32 ctx_addr;
-#ifdef XF86DRI
-   drmI830Sarea *sarea;
-#endif
 
-   if (pI830->noAccel || !I830IsPrimary(pScrn))
+   if (pI830->noAccel)
       return;
 
 #ifdef XF86DRI
    if (pI830->directRenderingEnabled) {
-      sarea = DRIGetSAREAPrivate(pScrn->pScreen);
+      drmI830Sarea *sarea = DRIGetSAREAPrivate(pScrn->pScreen);
 
       /* Mark that the X Server was the last holder of the context */
       if (sarea)
@@ -2068,6 +2071,12 @@ IntelEmitInvarientState(ScrnInfoPtr pScr
    }
 #endif
 
+   /* If we've emitted our state since the last clobber by another client,
+    * skip it.
+    */
+   if (*pI830->last_3d != LAST_3D_OTHER)
+      return;
+
    ctx_addr = pI830->logical_context->offset;
    assert((pI830->logical_context->offset & 2047) == 0);
    {
@@ -2304,13 +2313,14 @@ I830ScreenInit(int scrnIndex, ScreenPtr 
          pI830->LpRing = xcalloc(1, sizeof(I830RingBuffer));
       if (!pI830->overlayOn)
          pI830->overlayOn = xalloc(sizeof(Bool));
-      if (!pI830->used3D)
-         pI830->used3D = xalloc(sizeof(int));
-      if (!pI830->LpRing || !pI830->overlayOn || !pI830->used3D) {
+      if (!pI830->last_3d)
+         pI830->last_3d = xalloc(sizeof(enum last_3d));
+      if (!pI830->LpRing || !pI830->overlayOn || !pI830->last_3d) {
          xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		 "Could not allocate primary data structures.\n");
          return FALSE;
       }
+      *pI830->last_3d = LAST_3D_OTHER;
       *pI830->overlayOn = FALSE;
       if (pI830->entityPrivate)
          pI830->entityPrivate->XvInUse = -1;
@@ -2320,7 +2330,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr 
       pI830->LpRing = pI8301->LpRing;
       pI830->overlay_regs = pI8301->overlay_regs;
       pI830->overlayOn = pI8301->overlayOn;
-      pI830->used3D = pI8301->used3D;
+      pI830->last_3d = pI8301->last_3d;
    }
 
    /* Need MMIO mapped to do GTT lookups during memory allocation. */
@@ -3012,15 +3022,11 @@ I830EnterVT(int scrnIndex, int flags)
     */
    i830SetHotkeyControl(pScrn, HOTKEY_DRIVER_NOTIFY);
 
-   /* Needed for rotation */
-   IntelEmitInvarientState(pScrn);
-
    if (pI830->checkDevices)
       pI830->devicesTimer = TimerSet(NULL, 0, 1000, I830CheckDevicesTimer, pScrn);
 
-   /* Force invarient 3D state to be emitted */
-   *pI830->used3D = 1<<31;
-   pI830->last_3d = LAST_3D_OTHER;
+   /* Mark 3D state as being clobbered */
+   *pI830->last_3d = LAST_3D_OTHER;
 
    return TRUE;
 }
@@ -3111,8 +3117,8 @@ I830CloseScreen(int scrnIndex, ScreenPtr
       pI830->LpRing = NULL;
       xfree(pI830->overlayOn);
       pI830->overlayOn = NULL;
-      xfree(pI830->used3D);
-      pI830->used3D = NULL;
+      xfree(pI830->last_3d);
+      pI830->last_3d = NULL;
    }
 
    pScrn->PointerMoved = pI830->PointerMoved;
diff --git a/src/i830_exa.c b/src/i830_exa.c
index bb60c0a..22618dc 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -270,22 +270,6 @@ I830EXADoneCopy(PixmapPtr pDstPixmap)
 #endif
 }
 
-void
-i830_enter_render(ScrnInfoPtr pScrn)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-#ifdef XF86DRI
-    if (pI830->directRenderingEnabled) {
-        drmI830Sarea *pSAREAPriv = DRIGetSAREAPrivate(pScrn->pScreen);
-	pSAREAPriv->ctxOwner = DRIGetContext(pScrn->pScreen);
-    }
-#endif
-    if (pI830->last_3d != LAST_3D_RENDER) {
-	i830WaitSync(pScrn);
-	pI830->last_3d = LAST_3D_RENDER;
-    }
-}
-
 #define xFixedToFloat(val) \
 	((float)xFixedToInt(val) + ((float)xFixedFrac(val) / 65536.0))
 
diff --git a/src/i830_render.c b/src/i830_render.c
index 957953e..90b884f 100644
--- a/src/i830_render.c
+++ b/src/i830_render.c
@@ -400,7 +400,8 @@ i830_prepare_composite(int op, PicturePt
     I830Ptr pI830 = I830PTR(pScrn);
     CARD32 dst_format, dst_offset, dst_pitch;
 
-    i830_enter_render(pScrn);
+    IntelEmitInvarientState(pScrn);
+    *pI830->last_3d = LAST_3D_RENDER;
 
     i830_get_dest_format(pDstPicture, &dst_format);
     dst_offset = intel_get_pixmap_offset(pDst);
diff --git a/src/i915_render.c b/src/i915_render.c
index d5a8579..b2dacfe 100644
--- a/src/i915_render.c
+++ b/src/i915_render.c
@@ -315,7 +315,8 @@ i915_prepare_composite(int op, PicturePt
     CARD32 dst_format, dst_offset, dst_pitch;
     CARD32 blendctl;
 
-    i830_enter_render(pScrn);
+    IntelEmitInvarientState(pScrn);
+    *pI830->last_3d = LAST_3D_RENDER;
 
     i915_get_dest_format(pDstPicture, &dst_format);
     dst_offset = intel_get_pixmap_offset(pDst);
diff --git a/src/i915_video.c b/src/i915_video.c
index e4e0f1a..d02f770 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -75,13 +75,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
       break;
    }
 
-   /* Tell the rotation code that we have stomped its invariant state by
-    * setting a high bit.  We don't use any invariant 3D state for video, so we
-    * don't have to worry about it ourselves.
-    */
-   *pI830->used3D |= 1 << 30;
-
-   pI830->last_3d = LAST_3D_VIDEO;
+   IntelEmitInvarientState(pScrn);
+   *pI830->last_3d = LAST_3D_VIDEO;
 
    BEGIN_LP_RING(20);
 
diff --git a/src/i965_render.c b/src/i965_render.c
index 956baf3..e69a939 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -404,7 +404,8 @@ i965_prepare_composite(int op, PicturePt
     CARD32 dst_format, dst_offset, dst_pitch;
     Bool rotation_program = FALSE;
 
-    i830_enter_render(pScrn);
+    IntelEmitInvarientState(pScrn);
+    *pI830->last_3d = LAST_3D_RENDER;
 
     src_offset = intel_get_pixmap_offset(pSrc);
     src_pitch = intel_get_pixmap_pitch(pSrc);
diff --git a/src/i965_video.c b/src/i965_video.c
index 17d2006..3084233 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -200,20 +200,8 @@ I965DisplayVideoTextured(ScrnInfoPtr pSc
 
     assert((id == FOURCC_UYVY) || (id == FOURCC_YUY2));
 
-    /* Tell the rotation code that we have stomped its invariant state by
-     * setting a high bit.  We don't use any invariant 3D state for video, so
-     * we don't have to worry about it ourselves.
-     */
-    *pI830->used3D |= 1 << 30;
-
-#ifdef XF86DRI
-    /* Tell the DRI that we're smashing its state. */
-    if (pI830->directRenderingEnabled) {
-	drmI830Sarea *pSAREAPriv = DRIGetSAREAPrivate(pScrn->pScreen);
-
-	pSAREAPriv->ctxOwner = DRIGetContext(pScrn->pScreen);
-    }
-#endif /* XF86DRI */
+    IntelEmitInvarientState(pScrn);
+    *pI830->last_3d = LAST_3D_VIDEO;
 
     next_offset = 0;
 
diff-tree c2b130354aecffbeb2a2d23c7371461feaf5766a (from 0e1deb607f94e4aa3ec4b9df8ff7a07a1c95e31d)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Jun 12 08:49:21 2007 -0700

    Replace failure-prone configure test for fresh libdrm with a simple ifndef.

diff --git a/configure.ac b/configure.ac
index da9fd3f..53d23ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -189,14 +189,6 @@ if test "$DRI" = yes; then
 	if test "$have_damage_h" = yes; then
 		AC_DEFINE(DAMAGE,1,[Use Damage extension])
 	fi
-
-	save_CFLAGS="$CFLAGS"
-	CFLAGS="$DRI_CFLAGS"
-	AC_CHECK_TYPE(drm_i915_flip_t,
-		      [AC_DEFINE(HAVE_I915_FLIP, 1,
-			         [Have drm_i915_flip_t and related definitions])],
-		      [], [#include <i915_drm.h>])
-	CFLAGS="$save_CFLAGS"
 fi
 
 AM_CONDITIONAL(VIDEO_DEBUG, test x$VIDEO_DEBUG = xyes)
diff --git a/src/i830_dri.c b/src/i830_dri.c
index a17770b..4746be0 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -83,10 +83,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "i915_drm.h"
 
-/* This block and the corresponding configure test can be removed when
- * libdrm >= 2.3.1 is required.
- */
-#ifndef HAVE_I915_FLIP
+/* This block can be removed when libdrm >= 2.3.1 is required. */
+#ifndef DRM_IOCTL_I915_FLIP
 
 #define DRM_VBLANK_FLIP 0x8000000
 
diff-tree 0e1deb607f94e4aa3ec4b9df8ff7a07a1c95e31d (from 8d7a0ccd4f674659eb781def2cfdc3a6e5a219ce)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jun 11 17:33:33 2007 -0700

    Fix a typo in _3DSTATE_DEPTH_SUBRECT_DISABLE definition.
    
    This is already fixed in the definition in the 3d driver.

diff --git a/src/i915_reg.h b/src/i915_reg.h
index 6751de6..6b40d70 100644
--- a/src/i915_reg.h
+++ b/src/i915_reg.h
@@ -133,9 +133,9 @@
 #define _3DSTATE_DEPTH_OFFSET_SCALE       (CMD_3D | (0x1d<<24) | (0x97<<16))
 /* scale in dword 1 */
 
-
+/* The depth subrectangle is not supported, but must be disabled. */
 /* 3DSTATE_DEPTH_SUBRECT_DISABLE, p160 */
-#define _3DSTATE_DEPTH_SUBRECT_DISABLE    (CMD_3D | (0x1c<<24) | (0x11<19) | 0x2)
+#define _3DSTATE_DEPTH_SUBRECT_DISABLE	(CMD_3D | (0x1c<<24) | (0x11<<19) | (1 << 1) | (0 << 0))
 
 /* p161 */
 #define _3DSTATE_DST_BUF_VARS_CMD	(CMD_3D | (0x1d<<24) | (0x85<<16))
diff-tree 8d7a0ccd4f674659eb781def2cfdc3a6e5a219ce (from 15caa64a497dcc0eacb0f91166d9b70206a8db35)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jun 11 17:33:07 2007 -0700

    Clean up some nits in i915_video.c setup.
    
    - The screen dimensions were used for the clipping despite drawing being done
      to any pixmap, not necessarily the screen.
    - One piece of state setup was not documented anywhere, and isn't used in other
      3d hardware paths that also work.
    - A 3DSTATE_MODES_1 command (830-class only) was issued even though it no
      longer exists.

diff --git a/src/i915_video.c b/src/i915_video.c
index e837097..e4e0f1a 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -83,7 +83,7 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
 
    pI830->last_3d = LAST_3D_VIDEO;
 
-   BEGIN_LP_RING(24);
+   BEGIN_LP_RING(20);
 
    /* flush map & render cache */
    OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE);
@@ -94,16 +94,11 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
    OUT_RING(DRAW_DITHER_OFS_X(pPixmap->drawable.x & 3) |
 	    DRAW_DITHER_OFS_Y(pPixmap->drawable.y & 3));
    OUT_RING(0x00000000);	/* ymin, xmin */
-   OUT_RING((pScrn->virtualX - 1) |
-	    (pScrn->virtualY - 1) << 16); /* ymax, xmax */
+   OUT_RING((pPixmap->drawable.width - 1) |
+	    (pPixmap->drawable.height - 1) << 16); /* ymax, xmax */
    OUT_RING(0x00000000);	/* yorigin, xorigin */
    OUT_RING(MI_NOOP);
 
-   OUT_RING(0x7c000003);	/* unknown command */
-   OUT_RING(0x7d070000);
-   OUT_RING(0x00000000);
-   OUT_RING(0x68000002);
-
    OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) |
 	    I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 3);
    s2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D);


More information about the xorg-commit mailing list