From 1b0a7d05575bccaf73f0e558c0ea4cf5aae0a76a Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Wed, 10 Apr 2019 23:03:06 +0200 Subject: [PATCH] st/nine: Support internal compressed format for surfaces Reuse the generic path to support compressed formats. Signed-off-by: Axel Davy --- src/gallium/state_trackers/nine/surface9.c | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index 853e5a66f4c..d57d13ef7c6 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -481,25 +481,28 @@ NineSurface9_LockRect( struct NineSurface9 *This, if (p_atomic_read(&This->pending_uploads_counter)) nine_csmt_process(This->base.base.device); - if (This->data_internal) { - /* For now we only have uncompressed formats here */ - pLockedRect->Pitch = This->stride_internal; - pLockedRect->pBits = This->data_internal + box.y * This->stride_internal + - util_format_get_stride(This->format_internal, box.x); - } else if (This->data) { + if (This->data_internal || This->data) { + enum pipe_format format = This->base.info.format; + unsigned stride = This->stride; + uint8_t *data = This->data; + if (This->data_internal) { + format = This->format_internal; + stride = This->stride_internal; + data = This->data_internal; + } DBG("returning system memory\n"); /* ATI1 and ATI2 need special handling, because of d3d9 bug. * We must advertise to the application as if it is uncompressed * and bpp 8, and the app has a workaround to work with the fact * that it is actually compressed. */ - if (is_ATI1_ATI2(This->base.info.format)) { + if (is_ATI1_ATI2(format)) { pLockedRect->Pitch = This->desc.Width; - pLockedRect->pBits = This->data + box.y * This->desc.Width + box.x; + pLockedRect->pBits = data + box.y * This->desc.Width + box.x; } else { - pLockedRect->Pitch = This->stride; - pLockedRect->pBits = This->data + - NineSurface9_GetSystemMemOffset(This->base.info.format, - This->stride, + pLockedRect->Pitch = stride; + pLockedRect->pBits = data + + NineSurface9_GetSystemMemOffset(format, + stride, box.x, box.y); } -- 2.30.2