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

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


Do not copy parameters in an allocate context memory.
This avoid having to free the context on failure paths.
---
 qxldod/QxlDod.cpp | 37 ++-----------------------------------
 1 file changed, 2 insertions(+), 35 deletions(-)

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 6dc50fc..3302a23 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -3786,10 +3786,6 @@ QxlDevice::ExecutePresentDisplayOnly(
 
     NTSTATUS Status = STATUS_SUCCESS;
 
-    SIZE_T sizeMoves = NumMoves*sizeof(D3DKMT_MOVE_RECT);
-    SIZE_T sizeRects = NumDirtyRects*sizeof(RECT);
-    SIZE_T size = sizeof(DoPresentMemory) + sizeMoves + sizeRects;
-
     QXLDrawable **pDrawables = new (NonPagedPoolNx) QXLDrawable *[NumDirtyRects + NumMoves + 1];
     UINT nIndex = 0;
 
@@ -3798,16 +3794,8 @@ QxlDevice::ExecutePresentDisplayOnly(
         return STATUS_NO_MEMORY;
     }
 
-    DoPresentMemory* ctx = reinterpret_cast<DoPresentMemory*>
-                                (new (NonPagedPoolNx) BYTE[size]);
-
-    if (!ctx)
-    {
-        delete[] pDrawables;
-        return STATUS_NO_MEMORY;
-    }
-
-    RtlZeroMemory(ctx,size);
+    DoPresentMemory ctx[1];
+    RtlZeroMemory(ctx, sizeof(ctx));
 
     ctx->DstAddr          = DstAddr;
     ctx->DstBitPerPixel   = DstBitPerPixel;
@@ -3833,7 +3821,6 @@ QxlDevice::ExecutePresentDisplayOnly(
         PMDL mdl = IoAllocateMdl((PVOID)SrcAddr, sizeToMap,  FALSE, FALSE, NULL);
         if(!mdl)
         {
-            delete[] reinterpret_cast<BYTE*>(ctx);
             delete[] pDrawables;
             return STATUS_INSUFFICIENT_RESOURCES;
         }
@@ -3851,7 +3838,6 @@ QxlDevice::ExecutePresentDisplayOnly(
         {
             Status = GetExceptionCode();
             IoFreeMdl(mdl);
-            delete[] reinterpret_cast<BYTE*>(ctx);
             delete[] pDrawables;
             return Status;
         }
@@ -3866,7 +3852,6 @@ QxlDevice::ExecutePresentDisplayOnly(
             Status = STATUS_INSUFFICIENT_RESOURCES;
             MmUnlockPages(mdl);
             IoFreeMdl(mdl);
-            delete[] reinterpret_cast<BYTE*>(ctx);
             delete[] pDrawables;
             return Status;
         }
@@ -3875,23 +3860,6 @@ QxlDevice::ExecutePresentDisplayOnly(
         ctx->Mdl = mdl;
     }
 
-    BYTE* rects = reinterpret_cast<BYTE*>(ctx+1);
-
-    // copy moves and update pointer
-    if (Moves)
-    {
-        memcpy(rects,Moves,sizeMoves);
-        ctx->Moves = reinterpret_cast<D3DKMT_MOVE_RECT*>(rects);
-        rects += sizeMoves;
-    }
-
-    // copy dirty rects and update pointer
-    if (DirtyRect)
-    {
-        memcpy(rects,DirtyRect,sizeRects);
-        ctx->DirtyRect = reinterpret_cast<RECT*>(rects);
-    }
-
     // Set up destination blt info
     BLT_INFO DstBltInfo;
     DstBltInfo.pBits = ctx->DstAddr;
@@ -3964,7 +3932,6 @@ QxlDevice::ExecutePresentDisplayOnly(
         MmUnlockPages(ctx->Mdl);
         IoFreeMdl(ctx->Mdl);
     }
-    delete [] reinterpret_cast<BYTE*>(ctx);
 
     pDrawables[nIndex] = NULL;
 
-- 
2.9.3



More information about the Spice-devel mailing list