From: Axel Davy Date: Mon, 24 Oct 2016 19:48:13 +0000 (+0200) Subject: st/nine: Handle when cursor stride is not what is expected X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c0f65e08a197d153801f0ea3ee0fb9e85884f44;p=mesa.git st/nine: Handle when cursor stride is not what is expected SetCursor assumes for now a 32x32 argb cursor with pitch 128. 32x32 argb doesn't have pitch 128 on all hw, thus use a temporary surface with the correct pitch when needed. Signed-off-by: Axel Davy --- diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index ddac548418f..a78d18e5267 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -315,6 +315,11 @@ NineDevice9_ctor( struct NineDevice9 *This, This->cursor.image = pScreen->resource_create(pScreen, &tmpl); if (!This->cursor.image) return D3DERR_OUTOFVIDEOMEMORY; + + /* For uploading 32x32 (argb) cursor */ + This->cursor.hw_upload_temp = MALLOC(32 * 4 * 32); + if (!This->cursor.hw_upload_temp) + return D3DERR_OUTOFVIDEOMEMORY; } /* Create constant buffers. */ @@ -506,6 +511,8 @@ NineDevice9_dtor( struct NineDevice9 *This ) FREE(This->state.vs_const_b); FREE(This->state.vs_const_f_swvp); + FREE(This->cursor.hw_upload_temp); + if (This->swapchains) { for (i = 0; i < This->nswapchains; ++i) if (This->swapchains[i]) @@ -709,11 +716,20 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This, lock.pBits, lock.Pitch, This->cursor.w, This->cursor.h); - if (hw_cursor) + if (hw_cursor) { + void *data = lock.pBits; + /* SetCursor assumes 32x32 argb with pitch 128 */ + if (lock.Pitch != 128) { + sfmt->unpack_rgba_8unorm(This->cursor.hw_upload_temp, 128, + lock.pBits, lock.Pitch, + 32, 32); + data = This->cursor.hw_upload_temp; + } hw_cursor = ID3DPresent_SetCursor(This->swapchains[0]->present, - lock.pBits, + data, &This->cursor.hotspot, This->cursor.visible) == D3D_OK; + } NineSurface9_UnlockRect(surf); } diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h index 12be643dc2c..d698cee619c 100644 --- a/src/gallium/state_trackers/nine/device9.h +++ b/src/gallium/state_trackers/nine/device9.h @@ -112,6 +112,7 @@ struct NineDevice9 POINT pos; BOOL visible; boolean software; + void *hw_upload_temp; } cursor; struct {