diff -upNr xf86-video-intel.orig//src/i965_render.c xf86-video-intel.patched//src/i965_render.c --- xf86-video-intel.orig//src/i965_render.c 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/i965_render.c 2011-04-14 14:10:59.000000000 +0200 @@ -1867,7 +1867,7 @@ i965_prepare_composite(int op, PicturePt 2 + (mask ? 2 : 1) * (composite_op->is_affine ? 2: 3); if (!i965_composite_check_aperture(intel)) { - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); if (!i965_composite_check_aperture(intel)) { intel_debug_fallback(scrn, "Couldn't fit render operation " diff -upNr xf86-video-intel.orig//src/i965_video.c xf86-video-intel.patched//src/i965_video.c --- xf86-video-intel.orig//src/i965_video.c 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/i965_video.c 2011-04-14 14:10:59.000000000 +0200 @@ -1207,7 +1207,7 @@ I965DisplayVideoTextured(ScrnInfoPtr scr if (drm_intel_bufmgr_check_aperture_space(bo_table, ARRAY_SIZE(bo_table)) < 0) { - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); } intel_batch_start_atomic(scrn, 100); @@ -1850,7 +1850,7 @@ void Gen6DisplayVideoTextured(ScrnInfoPt * Assume that it does after being flushed. */ if (drm_intel_bufmgr_check_aperture_space(bo_table, ARRAY_SIZE(bo_table)) < 0) - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); intel_batch_start_atomic(scrn, 200); gen6_emit_video_setup(scrn, surface_state_binding_table_bo, n_src_surf, pixmap); diff -upNr xf86-video-intel.orig//src/intel_batchbuffer.c xf86-video-intel.patched//src/intel_batchbuffer.c --- xf86-video-intel.orig//src/intel_batchbuffer.c 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/intel_batchbuffer.c 2011-04-14 14:10:59.000000000 +0200 @@ -135,6 +135,8 @@ void intel_batch_do_flush(ScrnInfoPtr sc while (!list_is_empty(&intel->flush_pixmaps)) list_del(intel->flush_pixmaps.next); + + intel->need_mi_flush = FALSE; } void intel_batch_emit_flush(ScrnInfoPtr scrn) @@ -175,14 +177,7 @@ void intel_batch_emit_flush(ScrnInfoPtr intel_batch_do_flush(scrn); } -static Bool intel_batch_needs_flush(intel_screen_private *intel) -{ - ScreenPtr screen = intel->scrn->pScreen; - PixmapPtr pixmap = screen->GetScreenPixmap(screen); - return intel_get_pixmap_private(pixmap)->batch_write; -} - -void intel_batch_submit(ScrnInfoPtr scrn) +void intel_batch_submit(ScrnInfoPtr scrn, int flush) { intel_screen_private *intel = intel_get_screen_private(scrn); int ret; @@ -196,6 +191,9 @@ void intel_batch_submit(ScrnInfoPtr scrn if (intel->batch_flush) intel->batch_flush(intel); + if (flush) + intel_batch_emit_flush(scrn); + if (intel->batch_used == 0) return; @@ -241,8 +239,6 @@ void intel_batch_submit(ScrnInfoPtr scrn } } - intel->needs_flush |= intel_batch_needs_flush(intel); - while (!list_is_empty(&intel->batch_pixmaps)) { struct intel_pixmap *entry; @@ -255,6 +251,7 @@ void intel_batch_submit(ScrnInfoPtr scrn list_del(&entry->batch); } + intel->need_mi_flush |= !list_is_empty(&intel->flush_pixmaps); while (!list_is_empty(&intel->flush_pixmaps)) list_del(intel->flush_pixmaps.next); @@ -290,5 +287,5 @@ void intel_debug_flush(ScrnInfoPtr scrn) intel_batch_emit_flush(scrn); if (intel->debug_flush & DEBUG_FLUSH_BATCHES) - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); } diff -upNr xf86-video-intel.orig//src/intel_batchbuffer.h xf86-video-intel.patched//src/intel_batchbuffer.h --- xf86-video-intel.orig//src/intel_batchbuffer.h 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/intel_batchbuffer.h 2011-04-14 14:10:59.000000000 +0200 @@ -37,7 +37,7 @@ void intel_batch_init(ScrnInfoPtr scrn); void intel_batch_teardown(ScrnInfoPtr scrn); void intel_batch_emit_flush(ScrnInfoPtr scrn); void intel_batch_do_flush(ScrnInfoPtr scrn); -void intel_batch_submit(ScrnInfoPtr scrn); +void intel_batch_submit(ScrnInfoPtr scrn, int flush); static inline int intel_batch_space(intel_screen_private *intel) { @@ -54,7 +54,7 @@ intel_batch_require_space(ScrnInfoPtr sc { assert(sz < intel->batch_bo->size - 8); if (intel_batch_space(intel) < sz) - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); } static inline void intel_batch_start_atomic(ScrnInfoPtr scrn, unsigned int sz) diff -upNr xf86-video-intel.orig//src/intel_display.c xf86-video-intel.patched//src/intel_display.c --- xf86-video-intel.orig//src/intel_display.c 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/intel_display.c 2011-04-14 14:10:59.000000000 +0200 @@ -451,7 +451,7 @@ intel_crtc_set_mode_major(xf86CrtcPtr cr crtc->y = y; crtc->rotation = rotation; - intel_batch_submit(crtc->scrn); + intel_batch_submit(crtc->scrn, TRUE); mode_to_kmode(crtc->scrn, &intel_crtc->kmode, mode); ret = intel_crtc_apply(crtc); @@ -1363,7 +1363,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, if (scrn->virtualX == width && scrn->virtualY == height) return TRUE; - intel_batch_submit(scrn); + intel_batch_submit(scrn, TRUE); old_width = scrn->virtualX; old_height = scrn->virtualY; diff -upNr xf86-video-intel.orig//src/intel_driver.c xf86-video-intel.patched//src/intel_driver.c --- xf86-video-intel.orig//src/intel_driver.c 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/intel_driver.c 2011-04-14 14:25:05.107093700 +0200 @@ -626,7 +626,6 @@ static Bool I830PreInit(ScrnInfoPtr scrn intel->tiling &= ~INTEL_TILING_FB; intel->can_blt = can_accelerate_blt(intel); - intel->has_kernel_flush = has_kernel_flush(intel); intel->use_shadow = !intel->can_blt; if (xf86IsOptionSet(intel->Options, OPTION_SHADOW)) { @@ -800,7 +799,7 @@ intel_flush_callback(CallbackListPtr *li { ScrnInfoPtr scrn = user_data; if (scrn->vtSema) - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); } #if HAVE_UDEV diff -upNr xf86-video-intel.orig//src/intel.h xf86-video-intel.patched//src/intel.h --- xf86-video-intel.orig//src/intel.h 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/intel.h 2011-04-14 14:10:59.000000000 +0200 @@ -295,6 +295,8 @@ typedef struct intel_screen_private { Bool shadow_present; + Bool need_mi_flush; + unsigned int tiling; #define INTEL_TILING_FB 0x1 #define INTEL_TILING_2D 0x2 @@ -425,8 +427,6 @@ typedef struct intel_screen_private { Bool use_pageflipping; Bool force_fallback; Bool can_blt; - Bool has_kernel_flush; - Bool needs_flush; Bool use_shadow; /* Broken-out options. */ diff -upNr xf86-video-intel.orig//src/intel_uxa.c xf86-video-intel.patched//src/intel_uxa.c --- xf86-video-intel.orig//src/intel_uxa.c 2011-04-14 11:25:21.000000000 +0200 +++ xf86-video-intel.patched//src/intel_uxa.c 2011-04-14 14:10:59.000000000 +0200 @@ -88,7 +88,7 @@ static void gen6_context_switch(intel_screen_private *intel, int new_mode) { - intel_batch_submit(intel->scrn); + intel_batch_submit(intel->scrn, FALSE); } static void @@ -136,7 +136,7 @@ intel_get_aperture_space(ScrnInfoPtr scr bo_table[0] = intel->batch_bo; if (drm_intel_bufmgr_check_aperture_space(bo_table, num_bos) != 0) { - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); bo_table[0] = intel->batch_bo; if (drm_intel_bufmgr_check_aperture_space(bo_table, num_bos) != 0) { @@ -703,7 +703,7 @@ static Bool intel_uxa_prepare_access(Pix if (!list_is_empty(&priv->batch) && (access == UXA_ACCESS_RW || priv->batch_write)) - intel_batch_submit(scrn); + intel_batch_submit(scrn, FALSE); if (priv->tiling || bo->size <= intel->max_gtt_map_size) ret = drm_intel_gem_bo_map_gtt(bo); @@ -921,7 +921,7 @@ static Bool intel_uxa_get_image(PixmapPt FreeScratchGC(gc); - intel_batch_submit(xf86Screens[screen->myNum]); + intel_batch_submit(xf86Screens[screen->myNum], FALSE); x = y = 0; pixmap = scratch; @@ -935,35 +935,20 @@ static Bool intel_uxa_get_image(PixmapPt return ret; } -static void intel_flush_rendering(intel_screen_private *intel) -{ - if (intel->needs_flush == 0) - return; - - if (intel->has_kernel_flush) { - intel_batch_submit(intel->scrn); - drm_intel_bo_busy(intel->front_buffer); - } else { - intel_batch_emit_flush(intel->scrn); - intel_batch_submit(intel->scrn); - } - - intel->needs_flush = 0; -} - void intel_uxa_block_handler(intel_screen_private *intel) { if (intel->shadow_damage && pixman_region_not_empty(DamageRegion(intel->shadow_damage))) { intel_shadow_blt(intel); - DamageEmpty(intel->shadow_damage); - } + /* Emit a flush of the rendering cache, or on the 965 + * and beyond rendering results may not hit the + * framebuffer until significantly later. + */ + intel_batch_submit(intel->scrn, TRUE); - /* Emit a flush of the rendering cache, or on the 965 - * and beyond rendering results may not hit the - * framebuffer until significantly later. - */ - intel_flush_rendering(intel); + DamageEmpty(intel->shadow_damage); + } else + intel_batch_submit(intel->scrn, TRUE); } static PixmapPtr