diff options
-rw-r--r-- | src/i830.h | 9 | ||||
-rw-r--r-- | src/i830_dri.c | 2 | ||||
-rw-r--r-- | src/i830_driver.c | 13 | ||||
-rw-r--r-- | src/i830_exa_render.c | 2 | ||||
-rw-r--r-- | src/i830_rotate.c | 106 | ||||
-rw-r--r-- | src/i915_3d.c | 34 | ||||
-rw-r--r-- | src/i915_exa_render.c | 18 | ||||
-rw-r--r-- | src/i915_video.c | 53 |
8 files changed, 66 insertions, 171 deletions
@@ -192,6 +192,13 @@ typedef struct _region { int x0,x1,y0,y1; } region; +/** enumeration of 3d consumers so some can maintain invariant state. */ +enum last_3d { + LAST_3D_OTHER, + LAST_3D_VIDEO, + LAST_3D_RENDER, + LAST_3D_ROTATION +}; typedef struct _I830Rec { unsigned char *MMIOBase; @@ -453,6 +460,8 @@ typedef struct _I830Rec { CARD32 savedAsurf; CARD32 savedBsurf; + + enum last_3d last_3d; } I830Rec; #define I830PTR(p) ((I830Ptr)((p)->driverPrivate)) diff --git a/src/i830_dri.c b/src/i830_dri.c index 8a52750f..b844d334 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -1000,6 +1000,8 @@ I830DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, if (I810_DEBUG & DEBUG_VERBOSE_DRI) ErrorF("i830DRISwapContext (in)\n"); + pI830->last_3d = LAST_3D_OTHER; + if (!pScrn->vtSema) return; pI830->LockHeld = 1; diff --git a/src/i830_driver.c b/src/i830_driver.c index f9ca77cf..12fc5241 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -7041,10 +7041,23 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); CARD32 ctx_addr; +#ifdef XF86DRI + drmI830Sarea *sarea; +#endif if (pI830->noAccel) return; +#ifdef XF86DRI + if (pI830->directRenderingEnabled) { + sarea = DRIGetSAREAPrivate(pScrn->pScreen); + + /* Mark that the X Server was the last holder of the context */ + if (sarea) + sarea->ctxOwner = DRIGetContext(pScrn->pScreen); + } +#endif + ctx_addr = pI830->ContextMem.Start; /* Align to a 2k boundry */ ctx_addr = ((ctx_addr + 2048 - 1) / 2048) * 2048; diff --git a/src/i830_exa_render.c b/src/i830_exa_render.c index 86e11d21..f63313f3 100644 --- a/src/i830_exa_render.c +++ b/src/i830_exa_render.c @@ -404,6 +404,8 @@ I830EXAPrepareComposite(int op, PicturePtr pSrcPicture, dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); + pI830->last_3d = LAST_3D_RENDER; + if (!I830TextureSetup(pSrcPicture, pSrc, 0)) I830FALLBACK("fail to setup src texture\n"); if (pMask != NULL) { diff --git a/src/i830_rotate.c b/src/i830_rotate.c index 76effa29..3cdb3aef 100644 --- a/src/i830_rotate.c +++ b/src/i830_rotate.c @@ -211,11 +211,6 @@ I915UpdateRotate (ScreenPtr pScreen, struct matrix23 rotMatrix; int j; int use_fence; - Bool updateInvarient = FALSE; -#ifdef XF86DRI - drmI830Sarea *sarea = NULL; - drm_context_t myContext = 0; -#endif Bool didLock = FALSE; if (I830IsPrimary(pScrn)) { @@ -246,58 +241,20 @@ I915UpdateRotate (ScreenPtr pScreen, } #ifdef XF86DRI - if (pI8301->directRenderingEnabled) { - sarea = DRIGetSAREAPrivate(pScrn1->pScreen); - myContext = DRIGetContext(pScrn1->pScreen); + if (pI8301->directRenderingEnabled) didLock = I830DRILock(pScrn1); - } #endif + /* If another screen was active, we don't know the current state. */ if (pScrn->scrnIndex != *pI830->used3D) - updateInvarient = TRUE; - -#ifdef XF86DRI - if (sarea && sarea->ctxOwner != myContext) - updateInvarient = TRUE; -#endif + pI830->last_3d = LAST_3D_OTHER; - if (updateInvarient) { + if (pI830->last_3d != LAST_3D_ROTATION) { FS_LOCALS(3); *pI830->used3D = pScrn->scrnIndex; -#ifdef XF86DRI - if (sarea) - sarea->ctxOwner = myContext; -#endif - BEGIN_LP_RING(54); - /* invarient state */ - OUT_RING(MI_NOOP); - OUT_RING(_3DSTATE_AA_CMD | - AA_LINE_ECAAR_WIDTH_ENABLE | AA_LINE_ECAAR_WIDTH_1_0 | - AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); - - OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_COORD_SET_BINDINGS | - CSB_TCB(0, 0) | CSB_TCB(1, 1) | - CSB_TCB(2, 2) | CSB_TCB(3, 3) | - CSB_TCB(4, 4) | CSB_TCB(5, 5) | - CSB_TCB(6, 6) | CSB_TCB(7, 7)); - - OUT_RING(_3DSTATE_RASTER_RULES_CMD | - ENABLE_TRI_FAN_PROVOKE_VRTX | TRI_FAN_PROVOKE_VRTX(2) | - ENABLE_LINE_STRIP_PROVOKE_VRTX | LINE_STRIP_PROVOKE_VRTX(1) | - ENABLE_TEXKILL_3D_4D | TEXKILL_4D | - ENABLE_POINT_RASTER_RULE | OGL_POINT_RASTER_RULE); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 1); - OUT_RING(0x00000000); + BEGIN_LP_RING(34); + /* invarient state */ /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); @@ -313,24 +270,13 @@ I915UpdateRotate (ScreenPtr pScreen, OUT_RING(MI_NOOP); - OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); - OUT_RING(_3DSTATE_SCISSOR_RECT_0_CMD); - OUT_RING(0x00000000); /* ymin, xmin */ - OUT_RING(0x00000000); /* ymax, xmax */ - OUT_RING(0x7c000003); /* XXX: magic numbers */ OUT_RING(0x7d070000); OUT_RING(0x00000000); OUT_RING(0x68000002); - /* context setup */ - OUT_RING(_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) | - MODE4_ENABLE_STENCIL_WRITE_MASK | - MODE4_ENABLE_STENCIL_TEST_MASK); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(2) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); + I1_LOAD_S(2) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 3); OUT_RING(S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) | S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | @@ -349,14 +295,6 @@ I915UpdateRotate (ScreenPtr pScreen, (1 << S6_CBUF_DST_BLEND_FACT_SHIFT) | S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT)); - OUT_RING(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | - IAB_MODIFY_ENABLE | - IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) | - IAB_MODIFY_SRC_FACTOR | - (BLENDFACT_ONE << IAB_SRC_FACTOR_SHIFT) | - IAB_MODIFY_DST_FACTOR | - (BLENDFACT_ZERO << IAB_DST_FACTOR_SHIFT)); - OUT_RING(_3DSTATE_CONST_BLEND_COLOR_CMD); OUT_RING(0x00000000); @@ -373,9 +311,6 @@ I915UpdateRotate (ScreenPtr pScreen, DEPTH_FRMT_24_FIXED_8_OTHER); } - OUT_RING(_3DSTATE_STIPPLE); - OUT_RING(0x00000000); - /* texture sampler state */ OUT_RING(_3DSTATE_SAMPLER_STATE | 3); OUT_RING(0x00000001); @@ -493,13 +428,8 @@ I830UpdateRotate (ScreenPtr pScreen, CARD32 vb[32]; /* 32 dword vertex buffer */ float verts[4][2], tex[4][2]; struct matrix23 rotMatrix; - Bool updateInvarient = FALSE; int use_fence; int j; -#ifdef XF86DRI - drmI830Sarea *sarea = NULL; - drm_context_t myContext = 0; -#endif Bool didLock = FALSE; if (I830IsPrimary(pScrn)) { @@ -530,28 +460,18 @@ I830UpdateRotate (ScreenPtr pScreen, } #ifdef XF86DRI - if (pI8301->directRenderingEnabled) { - sarea = DRIGetSAREAPrivate(pScrn1->pScreen); - myContext = DRIGetContext(pScrn1->pScreen); + if (pI8301->directRenderingEnabled) didLock = I830DRILock(pScrn1); - } #endif if (pScrn->scrnIndex != *pI830->used3D) - updateInvarient = TRUE; - -#ifdef XF86DRI - if (sarea && sarea->ctxOwner != myContext) - updateInvarient = TRUE; -#endif + pI830->last_3d = LAST_3D_OTHER; - if (updateInvarient) { + if (pI830->last_3d != LAST_3D_ROTATION) { *pI830->used3D = pScrn->scrnIndex; -#ifdef XF86DRI - if (sarea) - sarea->ctxOwner = myContext; -#endif - + + pI830->last_3d = LAST_3D_ROTATION; + BEGIN_LP_RING(48); OUT_RING(0x682008a1); OUT_RING(0x6f402100); diff --git a/src/i915_3d.c b/src/i915_3d.c index e70bb24a..ff591716 100644 --- a/src/i915_3d.c +++ b/src/i915_3d.c @@ -38,7 +38,7 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) { I830Ptr pI830 = I830PTR(pScrn); - BEGIN_LP_RING(20); + BEGIN_LP_RING(24); OUT_RING(_3DSTATE_AA_CMD | AA_LINE_ECAAR_WIDTH_ENABLE | @@ -46,6 +46,13 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); + /* Disable independent alpha blend */ + OUT_RING(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | + IAB_MODIFY_ENABLE | + IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) | + IAB_MODIFY_SRC_FACTOR | (BLENDFACT_ONE << IAB_SRC_FACTOR_SHIFT) | + IAB_MODIFY_DST_FACTOR | (BLENDFACT_ZERO << IAB_DST_FACTOR_SHIFT)); + OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); OUT_RING(0); @@ -76,15 +83,15 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) ENABLE_TEXKILL_3D_4D | TEXKILL_4D); - /* Need to initialize this to zero. - */ + OUT_RING(_3DSTATE_MODES_4_CMD | + ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) | + ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff) | + ENABLE_STENCIL_TEST_MASK | STENCIL_TEST_MASK(0xff)); + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 0); - OUT_RING(0); - - /* XXX: Use this */ - OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | - DISABLE_SCISSOR_RECT); + OUT_RING(0x00000000); /* Disable texture coordinate wrap-shortest */ + OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); OUT_RING(_3DSTATE_SCISSOR_RECT_0_CMD); OUT_RING(0); OUT_RING(0); @@ -94,12 +101,11 @@ void I915EmitInvarientState( ScrnInfoPtr pScrn ) OUT_RING(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */ OUT_RING(0); - /* Don't support twosided stencil yet */ - OUT_RING(_3DSTATE_BACKFACE_STENCIL_OPS | - BFO_ENABLE_STENCIL_TWO_SIDE | - 0 ); + OUT_RING(_3DSTATE_STIPPLE); + OUT_RING(0x00000000); + + OUT_RING(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0 ); + OUT_RING(MI_NOOP); - OUT_RING(0); - ADVANCE_LP_RING(); } diff --git a/src/i915_exa_render.c b/src/i915_exa_render.c index 13fe3ee6..eae8171e 100644 --- a/src/i915_exa_render.c +++ b/src/i915_exa_render.c @@ -329,6 +329,8 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, ErrorF("Enter i915 prepareComposite\n"); #endif + pI830->last_3d = LAST_3D_RENDER; + I915GetDestFormat(pDstPicture, &dst_format); dst_offset = exaGetPixmapOffset(pDst); dst_pitch = exaGetPixmapPitch(pDst); @@ -383,7 +385,7 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, { CARD32 ss2; - BEGIN_LP_RING(26); + BEGIN_LP_RING(18); /* color buffer * XXX: Need to add USE_FENCE if we ever tile the X Server's pixmaps or * visible screen. @@ -391,23 +393,12 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, OUT_RING(_3DSTATE_BUF_INFO_CMD); OUT_RING(BUF_3D_ID_COLOR_BACK| BUF_3D_PITCH(dst_pitch)); OUT_RING(BUF_3D_ADDR(dst_offset)); - OUT_RING(MI_NOOP); OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); OUT_RING(dst_format); - /* XXX: defaults */ - OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(0x00000000); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | - I1_LOAD_S(3) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); + I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 3); ss2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); if (pMask) ss2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_2D); @@ -420,7 +411,6 @@ I915EXAPrepareComposite(int op, PicturePtr pSrcPicture, ss2 |= S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT); ss2 |= S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT); OUT_RING(ss2); - OUT_RING(0x00000000); /* Disable texture coordinate wrap-shortest */ OUT_RING((1 << S4_POINT_WIDTH_SHIFT) | S4_LINE_WIDTH_ONE | S4_CULLMODE_NONE| S4_VFMT_XY); blendctl = I915GetBlendCntl(op, pMaskPicture, pDstPicture->format); diff --git a/src/i915_video.c b/src/i915_video.c index 0833d508..aa192aff 100644 --- a/src/i915_video.c +++ b/src/i915_video.c @@ -89,35 +89,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, */ *pI830->used3D |= 1 << 30; - BEGIN_LP_RING(44); + pI830->last_3d = LAST_3D_VIDEO; - /* invarient state */ - OUT_RING(MI_NOOP); - OUT_RING(_3DSTATE_AA_CMD | - AA_LINE_ECAAR_WIDTH_ENABLE | AA_LINE_ECAAR_WIDTH_1_0 | - AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); - - OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_SPEC_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_DFLT_Z_CMD); - OUT_RING(0x00000000); - - OUT_RING(_3DSTATE_COORD_SET_BINDINGS | CSB_TCB(0, 0) | CSB_TCB(1, 1) | - CSB_TCB(2,2) | CSB_TCB(3,3) | CSB_TCB(4,4) | CSB_TCB(5,5) | - CSB_TCB(6,6) | CSB_TCB(7,7)); - - OUT_RING(_3DSTATE_RASTER_RULES_CMD | - ENABLE_TRI_FAN_PROVOKE_VRTX | TRI_FAN_PROVOKE_VRTX(2) | - ENABLE_LINE_STRIP_PROVOKE_VRTX | LINE_STRIP_PROVOKE_VRTX(1) | - ENABLE_TEXKILL_3D_4D | TEXKILL_4D | - ENABLE_POINT_RASTER_RULE | OGL_POINT_RASTER_RULE); - - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 1); - OUT_RING(0x00000000); /* texture coordinate wrap */ + BEGIN_LP_RING(24); /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); @@ -132,25 +106,13 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, OUT_RING(0x00000000); /* yorigin, xorigin */ OUT_RING(MI_NOOP); - /* scissor */ - OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); - OUT_RING(_3DSTATE_SCISSOR_RECT_0_CMD); - OUT_RING(0x00000000); /* ymin, xmin */ - OUT_RING(0x00000000); /* ymax, xmax */ - OUT_RING(0x7c000003); /* unknown command */ OUT_RING(0x7d070000); OUT_RING(0x00000000); OUT_RING(0x68000002); - /* context setup */ - OUT_RING(_3DSTATE_MODES_4_CMD | - ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) | - ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff) | - ENABLE_STENCIL_TEST_MASK | STENCIL_TEST_MASK(0xff)); - OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(2) | - I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); + I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 3); s2 = S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D); if (planar) s2 |= S2_TEXCOORD_FMT(1, TEXCOORDFMT_2D); @@ -171,12 +133,6 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, (1 << S6_CBUF_DST_BLEND_FACT_SHIFT) | S6_COLOR_WRITE_ENABLE | (2 << S6_TRISTRIP_PV_SHIFT)); - OUT_RING(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | - IAB_MODIFY_ENABLE | - IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) | - IAB_MODIFY_SRC_FACTOR | (BLENDFACT_ONE << IAB_SRC_FACTOR_SHIFT) | - IAB_MODIFY_DST_FACTOR | (BLENDFACT_ZERO << IAB_DST_FACTOR_SHIFT)); - OUT_RING(_3DSTATE_CONST_BLEND_COLOR_CMD); OUT_RING(0x00000000); @@ -189,9 +145,6 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, OUT_RING(LOD_PRECLAMP_OGL | DSTORG_HORT_BIAS(0x80) | DSTORG_VERT_BIAS(0x80) | format); - OUT_RING(_3DSTATE_STIPPLE); - OUT_RING(0x00000000); - /* front buffer, pitch, offset */ OUT_RING(_3DSTATE_BUF_INFO_CMD); OUT_RING(BUF_3D_ID_COLOR_BACK | BUF_3D_USE_FENCE | |