Commit 0732f81a authored by Michel Dänzer's avatar Michel Dänzer Committed by Michel Dänzer

glamor: Make pixmap scanout compatible if its dimensions are

Namely, if its dimensions match those of the screen pixmap (enough that
it could stand in for it). When that's the case, the pixmap may end up
being scanned out directly due to page flipping via the Present
extension, e.g. with xfwm4 --vblank=xpresent .

v2:
* Use AMDGPU_CREATE_PIXMAP_SCANOUT instead of second-guessing in
  amdgpu_alloc_pixmap_bo, fixes corruption when resizing from smaller
  to larger virtual size via RandR.

Closes: #10
parent cb27a5b1
Pipeline #135379 passed with stages
in 1 minute and 20 seconds
......@@ -79,7 +79,7 @@ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width,
}
pixmap_buffer->ref_count = 1;
if ( bitsPerPixel == pScrn->bitsPerPixel)
if (usage_hint & AMDGPU_CREATE_PIXMAP_SCANOUT)
bo_use |= GBM_BO_USE_SCANOUT;
#ifdef HAVE_GBM_BO_USE_LINEAR
......
......@@ -201,11 +201,12 @@ amdgpu_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
unsigned usage)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
PixmapFormatPtr format = xf86GetPixFormat(scrn, depth);
AMDGPUInfoPtr info = AMDGPUPTR(scrn);
struct amdgpu_pixmap *priv;
PixmapPtr pixmap, new_pixmap = NULL;
if (!xf86GetPixFormat(scrn, depth))
if (!format)
return NULL;
if (!AMDGPU_CREATE_PIXMAP_SHARED(usage)) {
......@@ -216,9 +217,15 @@ amdgpu_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
usage |= AMDGPU_CREATE_PIXMAP_LINEAR |
AMDGPU_CREATE_PIXMAP_GTT;
} else if (usage != CREATE_PIXMAP_USAGE_BACKING_PIXMAP) {
pixmap = glamor_create_pixmap(screen, w, h, depth, usage);
if (pixmap)
return pixmap;
if (w < scrn->virtualX || w > scrn->displayWidth ||
h != scrn->virtualY ||
format->bitsPerPixel != scrn->bitsPerPixel) {
pixmap = glamor_create_pixmap(screen, w, h, depth, usage);
if (pixmap)
return pixmap;
} else {
usage |= AMDGPU_CREATE_PIXMAP_SCANOUT;
}
}
}
......
......@@ -2207,6 +2207,7 @@ Bool AMDGPUEnterVT_KMS(ScrnInfoPtr pScrn)
struct amdgpu_buffer *front_buffer =
amdgpu_alloc_pixmap_bo(pScrn, pScrn->virtualX,
pScrn->virtualY, pScrn->depth,
AMDGPU_CREATE_PIXMAP_SCANOUT |
AMDGPU_CREATE_PIXMAP_LINEAR,
pScrn->bitsPerPixel,
&pitch);
......@@ -2413,12 +2414,12 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen)
if (!info->front_buffer) {
int pitch;
int hint = 0;
int hint = AMDGPU_CREATE_PIXMAP_SCANOUT;
if (info->shadow_primary)
hint = AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
hint |= AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
else if (!info->use_glamor)
hint = AMDGPU_CREATE_PIXMAP_LINEAR;
hint |= AMDGPU_CREATE_PIXMAP_LINEAR;
info->front_buffer =
amdgpu_alloc_pixmap_bo(pScrn, pScrn->virtualX,
......
......@@ -557,8 +557,8 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout,
drmmode_crtc_scanout_destroy(drmmode, scanout);
}
scanout->bo = amdgpu_alloc_pixmap_bo(pScrn, width, height,
pScrn->depth, 0,
scanout->bo = amdgpu_alloc_pixmap_bo(pScrn, width, height, pScrn->depth,
AMDGPU_CREATE_PIXMAP_SCANOUT,
pScrn->bitsPerPixel, &pitch);
if (!scanout->bo) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
......@@ -2975,8 +2975,8 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
int i, pitch, old_width, old_height, old_pitch;
int cpp = info->pixel_bytes;
PixmapPtr ppix = screen->GetScreenPixmap(screen);
int hint = AMDGPU_CREATE_PIXMAP_SCANOUT;
void *fb_shadow;
int hint = 0;
if (scrn->virtualX == width && scrn->virtualY == height)
return TRUE;
......@@ -2990,9 +2990,9 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
}
if (info->shadow_primary)
hint = AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
hint |= AMDGPU_CREATE_PIXMAP_LINEAR | AMDGPU_CREATE_PIXMAP_GTT;
else if (!info->use_glamor)
hint = AMDGPU_CREATE_PIXMAP_LINEAR;
hint |= AMDGPU_CREATE_PIXMAP_LINEAR;
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"Allocate new frame buffer %dx%d\n", width, height);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment