[Spice-devel] [PATCH qxl-wddm-dod 05/20] qxl-wddm-dod: Use rendering offload thread

Frediano Ziglio fziglio at redhat.com
Tue Mar 28 13:27:00 UTC 2017


From: "yuri.benditovich at daynix.com" <yuri.benditovich at daynix.com>

Instead of sending drawable commands down from presentation
callback, collect drawables objects and pass them to dedicated
thread for processing. This reduce peak load of presentation
callback.

Signed-off-by: Javier Celaya <javier.celaya at flexvdi.com>
Signed-off-by: Yuri Benditovich <yuri.benditovich at daynix.com>
---
 qxldod/QxlDod.cpp | 43 +++++++++++++++++++++++++++++++++----------
 qxldod/QxlDod.h   |  4 ++--
 2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 7392399..8b384a7 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -3790,11 +3790,20 @@ QxlDevice::ExecutePresentDisplayOnly(
     SIZE_T sizeRects = NumDirtyRects*sizeof(RECT);
     SIZE_T size = sizeof(DoPresentMemory) + sizeMoves + sizeRects;
 
+    QXLDrawable **pDrawables = reinterpret_cast<QXLDrawable **>(new (NonPagedPoolNx) BYTE[sizeof(QXLDrawable *)*(NumDirtyRects + NumMoves + 1)]);
+    UINT nIndex = 0;
+
+    if (!pDrawables)
+    {
+        return STATUS_NO_MEMORY;
+    }
+
     DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>
                                 (new (NonPagedPoolNx) BYTE[size]);
 
     if (!ctx)
     {
+        delete[] reinterpret_cast<BYTE*>(pDrawables);
         return STATUS_NO_MEMORY;
     }
 
@@ -3824,6 +3833,8 @@ QxlDevice::ExecutePresentDisplayOnly(
         PMDL mdl = IoAllocateMdl((PVOID)SrcAddr, sizeToMap,  FALSE, FALSE, NULL);
         if(!mdl)
         {
+            delete[] reinterpret_cast<BYTE*>(ctx);
+            delete[] reinterpret_cast<BYTE*>(pDrawables);
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
@@ -3840,6 +3851,8 @@ QxlDevice::ExecutePresentDisplayOnly(
         {
             Status = GetExceptionCode();
             IoFreeMdl(mdl);
+            delete[] reinterpret_cast<BYTE*>(ctx);
+            delete[] reinterpret_cast<BYTE*>(pDrawables);
             return Status;
         }
 
@@ -3853,6 +3866,8 @@ QxlDevice::ExecutePresentDisplayOnly(
             Status = STATUS_INSUFFICIENT_RESOURCES;
             MmUnlockPages(mdl);
             IoFreeMdl(mdl);
+            delete[] reinterpret_cast<BYTE*>(ctx);
+            delete[] reinterpret_cast<BYTE*>(pDrawables);
             return Status;
         }
 
@@ -3918,7 +3933,9 @@ QxlDevice::ExecutePresentDisplayOnly(
         DbgPrint(TRACE_LEVEL_INFORMATION, ("--- %d SourcePoint.x = %ld, SourcePoint.y = %ld, DestRect.bottom = %ld, DestRect.left = %ld, DestRect.right = %ld, DestRect.top = %ld\n", 
             i , pSourcePoint->x, pSourcePoint->y, pDestRect->bottom, pDestRect->left, pDestRect->right, pDestRect->top));
 
-        CopyBits(*pDestRect, *pSourcePoint);
+        pDrawables[nIndex] = CopyBits(*pDestRect, *pSourcePoint);
+
+        if (pDrawables[nIndex]) nIndex++;
     }
 
     // Copy all the dirty rects from source image to video frame buffer.
@@ -3932,11 +3949,13 @@ QxlDevice::ExecutePresentDisplayOnly(
         DbgPrint(TRACE_LEVEL_INFORMATION, ("--- %d pDirtyRect->bottom = %ld, pDirtyRect->left = %ld, pDirtyRect->right = %ld, pDirtyRect->top = %ld\n",
             i, pDirtyRect->bottom, pDirtyRect->left, pDirtyRect->right, pDirtyRect->top));
 
-        BltBits(&DstBltInfo,
+        pDrawables[nIndex] = BltBits(&DstBltInfo,
         &SrcBltInfo,
         1,
         pDirtyRect,
         &sourcePoint);
+
+        if (pDrawables[nIndex]) nIndex++;
     }
 
     // Unmap unmap and unlock the pages.
@@ -3947,6 +3966,10 @@ QxlDevice::ExecutePresentDisplayOnly(
     }
     delete [] reinterpret_cast<BYTE*>(ctx);
 
+    pDrawables[nIndex] = NULL;
+
+    PostToWorkerThread(pDrawables);
+
     return STATUS_SUCCESS;
 }
 
@@ -4360,7 +4383,7 @@ VOID QxlDevice::SetImageId(InternalImage *internal,
     }
 }
 
-void QxlDevice::CopyBits(const RECT& rect, const POINT& sourcePoint)
+QXLDrawable *QxlDevice::CopyBits(const RECT& rect, const POINT& sourcePoint)
 {
     PAGED_CODE();
     QXLDrawable *drawable;
@@ -4369,18 +4392,18 @@ void QxlDevice::CopyBits(const RECT& rect, const POINT& sourcePoint)
 
     if (!(drawable = Drawable(QXL_COPY_BITS, &rect, NULL, 0))) {
         DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n"));
-        return;
+        return NULL;
     }
 
     drawable->u.copy_bits.src_pos.x = sourcePoint.x;
     drawable->u.copy_bits.src_pos.y = sourcePoint.y;
 
-    PushDrawable(drawable);
-
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
+
+    return drawable;
 }
 
-VOID QxlDevice::BltBits (
+QXLDrawable *QxlDevice::BltBits (
     BLT_INFO* pDst,
     CONST BLT_INFO* pSrc,
     UINT  NumRects,
@@ -4403,7 +4426,7 @@ VOID QxlDevice::BltBits (
 
     if (!(drawable = Drawable(QXL_DRAW_COPY, pRects, NULL, 0))) {
         DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n"));
-        return;
+        return NULL;
     }
 
     CONST RECT* pRect = &pRects[0];
@@ -4476,9 +4499,9 @@ VOID QxlDevice::BltBits (
          drawable->surfaces_rects[0].top, drawable->surfaces_rects[0].bottom,
          drawable->u.copy.src_bitmap));
 
-    PushDrawable(drawable);
-
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
+
+    return drawable;
 }
 
 VOID QxlDevice::PutBytesAlign(QXLDataChunk **chunk_ptr, UINT8 **now_ptr,
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index 4a62680..f441f4b 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -495,12 +495,12 @@ public:
     BOOLEAN IsBIOSCompatible() { return FALSE; }
 protected:
     NTSTATUS GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo);
-    VOID BltBits (BLT_INFO* pDst,
+    QXLDrawable *BltBits (BLT_INFO* pDst,
                     CONST BLT_INFO* pSrc,
                     UINT  NumRects,
                     _In_reads_(NumRects) CONST RECT *pRects,
                     POINT*   pSourcePoint);
-    void CopyBits(const RECT& rect, const POINT& sourcePoint);
+    QXLDrawable *CopyBits(const RECT& rect, const POINT& sourcePoint);
     QXLDrawable *Drawable(UINT8 type,
                     CONST RECT *area,
                     CONST RECT *clip,
-- 
2.9.3



More information about the Spice-devel mailing list