summaryrefslogtreecommitdiff
path: root/src/intel_driver.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-08-25 12:56:43 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-08 13:33:37 +0100
commit2b96c18165d713cd6781dbf217ec33e11cc961bc (patch)
tree92b4c9b3b0fa31e0ec20b6ac348011de9ea59df2 /src/intel_driver.c
parent0fa4321a765126228170ecb9536f32c134886d51 (diff)
Enable a shadow buffer and disable GPU acceleration.
An attempt to workaround the incoherency in gen2 chipsets, we avoid using dynamic reallocation as much as possible. The first step is to disable allocation of pixmaps using GEM and simply create them in system memory without a backing buffer object. This forces all rendering to use S/W fallbacks. The second step is to allocate a shadow front buffer and assign that to the Screen pixmap. This ensure that the front buffer remains in the GTT and pinned for scanout. The shadow buffer will be rendered to in the normal fashion via the Screen pixmap, and be marked dirty. In the block handler, the dirty shadow buffer is then blitted (using the GPU) over the front buffer. This should completely avoid having to move pages around in the GTT and avoid incurring the wrath of those early chipsets. Secondly, performance should be reasonable as we avoid the ping-pong caused by the small aperture and weak GPU forcing software fallbacks. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/intel_driver.c')
-rw-r--r--src/intel_driver.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/intel_driver.c b/src/intel_driver.c
index 9b2fdaf1..eab5c2c7 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -98,6 +98,7 @@ typedef enum {
OPTION_COLOR_KEY,
OPTION_FALLBACKDEBUG,
OPTION_TILING,
+ OPTION_SHADOW,
OPTION_SWAPBUFFERS_WAIT,
#ifdef INTEL_XVMC
OPTION_XVMC,
@@ -115,6 +116,7 @@ static OptionInfoRec I830Options[] = {
{OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE},
{OPTION_FALLBACKDEBUG, "FallbackDebug", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_TILING, "Tiling", OPTV_BOOLEAN, {0}, TRUE},
+ {OPTION_SHADOW, "Shadow", OPTV_BOOLEAN, {0}, FALSE},
{OPTION_SWAPBUFFERS_WAIT, "SwapbuffersWait", OPTV_BOOLEAN, {0}, TRUE},
#ifdef INTEL_XVMC
{OPTION_XVMC, "XvMC", OPTV_BOOLEAN, {0}, TRUE},
@@ -536,6 +538,7 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
scrn->driverPrivate = intel;
}
+ intel->scrn = scrn;
intel->pEnt = pEnt;
scrn->displayWidth = 640; /* default it */
@@ -726,13 +729,16 @@ static Bool
intel_init_initial_framebuffer(ScrnInfoPtr scrn)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
+ int width = scrn->virtualX;
+ int height = scrn->virtualY;
unsigned long pitch;
+ uint32_t tiling;
intel->front_buffer = intel_allocate_framebuffer(scrn,
- scrn->virtualX,
- scrn->virtualY,
+ width, height,
intel->cpp,
- &pitch);
+ &pitch,
+ &tiling);
if (!intel->front_buffer) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -740,6 +746,8 @@ intel_init_initial_framebuffer(ScrnInfoPtr scrn)
return FALSE;
}
+ intel->front_pitch = pitch;
+ intel->front_tiling = tiling;
scrn->displayWidth = pitch / intel->cpp;
return TRUE;
@@ -828,6 +836,9 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv)
intel->directRenderingType = DRI_DRI2;
#endif
+ intel->force_fallback = FALSE;
+ intel->use_shadow = FALSE;
+
/* Enable tiling by default */
intel->tiling = TRUE;
@@ -839,6 +850,17 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv)
intel->tiling = FALSE;
}
+ if (xf86IsOptionSet(intel->Options, OPTION_SHADOW)) {
+ if (xf86ReturnOptValBool(intel->Options, OPTION_SHADOW, FALSE))
+ intel->force_fallback = intel->use_shadow = TRUE;
+ }
+
+ if (intel->use_shadow) {
+ xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
+ "Shadow buffer enabled,"
+ " GPU acceleration disabled.\n");
+ }
+
/* SwapBuffers delays to avoid tearing */
intel->swapbuffers_wait = TRUE;
@@ -1101,6 +1123,8 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen)
I830LeaveVT(scrnIndex, 0);
}
+ DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
+
if (intel->uxa_driver) {
uxa_driver_fini(screen);
free(intel->uxa_driver);
@@ -1108,13 +1132,31 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen)
}
if (intel->front_buffer) {
- intel_set_pixmap_bo(screen->GetScreenPixmap(screen), NULL);
+ if (!intel->use_shadow)
+ intel_set_pixmap_bo(screen->GetScreenPixmap(screen),
+ NULL);
intel_mode_remove_fb(intel);
drm_intel_bo_unreference(intel->front_buffer);
intel->front_buffer = NULL;
}
- DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
+ if (intel->shadow_pixmap) {
+ PixmapPtr pixmap = intel->shadow_pixmap;
+
+ if (intel->shadow_damage) {
+ DamageUnregister(&pixmap->drawable,
+ intel->shadow_damage);
+ DamageDestroy(intel->shadow_damage);
+ intel->shadow_damage = NULL;
+ }
+
+ if (intel->shadow_buffer) {
+ drm_intel_bo_unreference(intel->shadow_buffer);
+ intel->shadow_buffer = NULL;
+ }
+
+ intel->shadow_pixmap = NULL;
+ }
intel_batch_teardown(scrn);