Commit 7994a0f3 authored by Siarhei Siamashka's avatar Siarhei Siamashka
Browse files

DRI2: only pay attention to back buffers requests



Bail out earlier for the uninteresting types of DRI2 buffer
requests (by just returning a dummy null UMP buffer). Makes
the code a bit more simple on the common path.
Signed-off-by: default avatarSiarhei Siamashka <siarhei.siamashka@gmail.com>
parent 1f89628c
...@@ -248,22 +248,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -248,22 +248,7 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
free(buffer); free(buffer);
return NULL; return NULL;
} }
privates->refcount = 1;
/* The drawable must be a window for using hardware overlays */
if (pDraw->type != DRAWABLE_WINDOW)
can_use_overlay = FALSE;
/* We could not allocate disp layer or get framebuffer secure id */
if (!disp || private->ump_fb_secure_id == UMP_INVALID_SECURE_ID)
can_use_overlay = FALSE;
/* Overlay is already used by a different window */
if (private->pOverlayWin && private->pOverlayWin != (void *)pDraw)
can_use_overlay = FALSE;
/* TODO: try to support other color depths later */
if (pDraw->bitsPerPixel != 32)
can_use_overlay = FALSE;
/* The default common values */ /* The default common values */
buffer->attachment = attachment; buffer->attachment = attachment;
...@@ -279,6 +264,27 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -279,6 +264,27 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
privates->height = pDraw->height; privates->height = pDraw->height;
privates->depth = pDraw->depth; privates->depth = pDraw->depth;
/* We are not interested in anything other than back buffer requests ... */
if (attachment != DRI2BufferBackLeft || pDraw->type != DRAWABLE_WINDOW) {
/* ... and just return some dummy UMP buffer */
privates->handle = UMP_INVALID_MEMORY_HANDLE;
privates->addr = NULL;
buffer->name = private->ump_null_secure_id;
return buffer;
}
/* We could not allocate disp layer or get framebuffer secure id */
if (!disp || private->ump_fb_secure_id == UMP_INVALID_SECURE_ID)
can_use_overlay = FALSE;
/* Overlay is already used by a different window */
if (private->pOverlayWin && private->pOverlayWin != (void *)pDraw)
can_use_overlay = FALSE;
/* TODO: try to support other color depths later */
if (pDraw->bitsPerPixel != 32)
can_use_overlay = FALSE;
if (disp && disp->framebuffer_size - disp->gfx_layer_size < privates->size) { if (disp && disp->framebuffer_size - disp->gfx_layer_size < privates->size) {
DebugMsg("Not enough space in the offscreen framebuffer (wanted %d for DRI2)\n", DebugMsg("Not enough space in the offscreen framebuffer (wanted %d for DRI2)\n",
privates->size); privates->size);
...@@ -286,7 +292,6 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -286,7 +292,6 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
} }
/* Allocate the DRI2-related window bookkeeping information */ /* Allocate the DRI2-related window bookkeeping information */
if (attachment == DRI2BufferBackLeft && pDraw->type == DRAWABLE_WINDOW) {
HASH_FIND_PTR(private->HashWindowState, &pDraw, window_state); HASH_FIND_PTR(private->HashWindowState, &pDraw, window_state);
if (!window_state) { if (!window_state) {
window_state = calloc(1, sizeof(*window_state)); window_state = calloc(1, sizeof(*window_state));
...@@ -295,26 +300,23 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw, ...@@ -295,26 +300,23 @@ static DRI2Buffer2Ptr MaliDRI2CreateBuffer(DrawablePtr pDraw,
DebugMsg("Allocate DRI2 bookkeeping for window %p\n", pDraw); DebugMsg("Allocate DRI2 bookkeeping for window %p\n", pDraw);
} }
window_state->buf_request_cnt++; window_state->buf_request_cnt++;
}
/* For odd buffer requests save the window size */ /* For odd buffer requests save the window size */
if (window_state && (window_state->buf_request_cnt & 1)) { if (window_state->buf_request_cnt & 1) {
/* remember window size for one buffer */ /* remember window size for one buffer */
window_state->width = pDraw->width; window_state->width = pDraw->width;
window_state->height = pDraw->height; window_state->height = pDraw->height;
} }
/* For even buffer requests check if the window size is still the same */ /* For even buffer requests check if the window size is still the same */
if (window_state && !(window_state->buf_request_cnt & 1) && if (!(window_state->buf_request_cnt & 1) &&
(pDraw->width != window_state->width || (pDraw->width != window_state->width ||
pDraw->height != window_state->height) && pDraw->height != window_state->height) &&
private->ump_null_secure_id) { private->ump_null_secure_id <= 2) {
DebugMsg("DRI2 buffers size mismatch detected, trying to recover\n"); DebugMsg("DRI2 buffers size mismatch detected, trying to recover\n");
privates->handle = UMP_INVALID_MEMORY_HANDLE; privates->handle = UMP_INVALID_MEMORY_HANDLE;
privates->addr = NULL; privates->addr = NULL;
buffer->name = private->ump_null_secure_id; buffer->name = private->ump_null_secure_id;
buffer->cpp = 0;
buffer->pitch = 0;
return buffer; return buffer;
} }
...@@ -767,7 +769,6 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay) ...@@ -767,7 +769,6 @@ SunxiMaliDRI2 *SunxiMaliDRI2_Init(ScreenPtr pScreen, Bool bUseOverlay)
if (private->ump_null_secure_id > 2) { if (private->ump_null_secure_id > 2) {
xf86DrvMsg(pScreen->myNum, X_INFO, xf86DrvMsg(pScreen->myNum, X_INFO,
"warning, can't workaround Mali r3p0 window resize bug\n"); "warning, can't workaround Mali r3p0 window resize bug\n");
private->ump_null_secure_id = 0;
} }
if (disp && private->ump_fb_secure_id != UMP_INVALID_SECURE_ID) if (disp && private->ump_fb_secure_id != UMP_INVALID_SECURE_ID)
......
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