<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 20, 2017 at 2:08 PM, Frediano Ziglio <span dir="ltr"><<a href="mailto:fziglio@redhat.com" target="_blank">fziglio@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">><br>
> Instead of sending drawable commands down from presentation<br>
> callback, collect drawables objects and pass them to dedicated<br>
> thread for processing. This reduce peak load of presentation<br>
> callback.<br>
><br>
> Signed-off-by: Javier Celaya <<a href="mailto:javier.celaya@flexvdi.com">javier.celaya@flexvdi.com</a>><br>
> Signed-off-by: Yuri Benditovich <<a href="mailto:yuri.benditovich@daynix.com">yuri.benditovich@daynix.com</a>><br>
> ---<br>
>  qxldod/QxlDod.cpp | 43 ++++++++++++++++++++++++++++++<wbr>+++----------<br>
>  qxldod/QxlDod.h   |  4 ++--<br>
>  2 files changed, 35 insertions(+), 12 deletions(-)<br>
><br>
> diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp<br>
> index b952bf9..01de9b3 100755<br>
> --- a/qxldod/QxlDod.cpp<br>
> +++ b/qxldod/QxlDod.cpp<br>
> @@ -3794,11 +3794,20 @@ QxlDevice::<wbr>ExecutePresentDisplayOnly(<br>
>      SIZE_T sizeRects = NumDirtyRects*sizeof(RECT);<br>
>      SIZE_T size = sizeof(DoPresentMemory) + sizeMoves + sizeRects;<br>
><br>
> +    QXLDrawable **pDrawables = reinterpret_cast<QXLDrawable **>(new<br>
> (NonPagedPoolNx) BYTE[sizeof(QXLDrawable *)*(NumDirtyRects + NumMoves +<br>
> 1)]);<br>
<br>
</span>here would be<br>
<br>
  QXLDrawable **pDrawables = new (NonPagedPoolNx) QXLDrawable *[NumDirtyRects + NumMoves + 1];<br>
<br>
is non paged memory needed? Both functions (producer and consumer) are in paged areas.<br>
<span class=""><br>
> +    UINT nIndex = 0;<br>
> +<br>
> +    if (!pDrawables)<br>
> +    {<br>
> +        return STATUS_NO_MEMORY;<br>
> +    }<br>
> +<br>
>      DoPresentMemory* ctx = reinterpret_cast<<wbr>DoPresentMemory*><br>
>                                  (new (NonPagedPoolNx) BYTE[size]);<br>
><br>
<br>
</span>   DoPresentMemory* ctx = new (NonPagedPoolNx) DoPresentMemory;<br></blockquote><div><br></div><div>Current commit intentionally does not change this, to make clear what is changed.</div><div>Without changes in the code we can't just allocate less memory, as trailing RECT structures are used for</div><div>unneeded copy from parameters.</div><div>Removal of this completely unneeded 'ctx' is planned for further commits after all the HCK-related work is done.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
same comments as above<br>
<span class=""><br>
>      if (!ctx)<br>
>      {<br>
> +        delete[] reinterpret_cast<BYTE*>(<wbr>pDrawables);<br>
<br>
</span>delete[] pDrawables;<br>
<span class=""><br>
>          return STATUS_NO_MEMORY;<br>
>      }<br>
><br>
> @@ -3828,6 +3837,8 @@ QxlDevice::<wbr>ExecutePresentDisplayOnly(<br>
>          PMDL mdl = IoAllocateMdl((PVOID)SrcAddr, sizeToMap,  FALSE, FALSE,<br>
>          NULL);<br>
>          if(!mdl)<br>
>          {<br>
> +            delete[] reinterpret_cast<BYTE*>(ctx);<br>
> +            delete[] reinterpret_cast<BYTE*>(<wbr>pDrawables);<br>
<br>
</span>similar to above, in this case "delete ctx;"<br>
<span class=""><br>
>              return STATUS_INSUFFICIENT_RESOURCES;<br>
>          }<br>
><br>
> @@ -3844,6 +3855,8 @@ QxlDevice::<wbr>ExecutePresentDisplayOnly(<br>
>          {<br>
>              Status = GetExceptionCode();<br>
>              IoFreeMdl(mdl);<br>
> +            delete[] reinterpret_cast<BYTE*>(ctx);<br>
> +            delete[] reinterpret_cast<BYTE*>(<wbr>pDrawables);<br>
<br>
</span>ditto<br>
<span class=""><br>
>              return Status;<br>
>          }<br>
><br>
> @@ -3857,6 +3870,8 @@ QxlDevice::<wbr>ExecutePresentDisplayOnly(<br>
>              Status = STATUS_INSUFFICIENT_RESOURCES;<br>
>              MmUnlockPages(mdl);<br>
>              IoFreeMdl(mdl);<br>
> +            delete[] reinterpret_cast<BYTE*>(ctx);<br>
> +            delete[] reinterpret_cast<BYTE*>(<wbr>pDrawables);<br>
<br>
</span>ditto<br>
<div><div class="h5"><br>
>              return Status;<br>
>          }<br>
><br>
> @@ -3922,7 +3937,9 @@ QxlDevice::<wbr>ExecutePresentDisplayOnly(<br>
>          DbgPrint(TRACE_LEVEL_<wbr>INFORMATION, ("--- %d SourcePoint.x = %ld,<br>
>          SourcePoint.y = %ld, DestRect.bottom = %ld, DestRect.left = %ld,<br>
>          DestRect.right = %ld, DestRect.top = %ld\n",<br>
>              i , pSourcePoint->x, pSourcePoint->y, pDestRect->bottom,<br>
>              pDestRect->left, pDestRect->right, pDestRect->top));<br>
><br>
> -        CopyBits(*pDestRect, *pSourcePoint);<br>
> +        pDrawables[nIndex] = CopyBits(*pDestRect, *pSourcePoint);<br>
> +<br>
> +        if (pDrawables[nIndex]) nIndex++;<br>
>      }<br>
><br>
>      // Copy all the dirty rects from source image to video frame buffer.<br>
> @@ -3936,11 +3953,13 @@ QxlDevice::<wbr>ExecutePresentDisplayOnly(<br>
>          DbgPrint(TRACE_LEVEL_<wbr>INFORMATION, ("--- %d pDirtyRect->bottom = %ld,<br>
>          pDirtyRect->left = %ld, pDirtyRect->right = %ld, pDirtyRect->top =<br>
>          %ld\n",<br>
>              i, pDirtyRect->bottom, pDirtyRect->left, pDirtyRect->right,<br>
>              pDirtyRect->top));<br>
><br>
> -        BltBits(&DstBltInfo,<br>
> +        pDrawables[nIndex] = BltBits(&DstBltInfo,<br>
>          &SrcBltInfo,<br>
>          1,<br>
>          pDirtyRect,<br>
>          &sourcePoint);<br>
> +<br>
> +        if (pDrawables[nIndex]) nIndex++;<br>
>      }<br>
><br>
>      // Unmap unmap and unlock the pages.<br>
> @@ -3951,6 +3970,10 @@ QxlDevice::<wbr>ExecutePresentDisplayOnly(<br>
>      }<br>
>      delete [] reinterpret_cast<BYTE*>(ctx);<br>
><br>
> +    pDrawables[nIndex] = NULL;<br>
> +<br>
> +    PostToWorkerThread(pDrawables)<wbr>;<br>
> +<br>
>      return STATUS_SUCCESS;<br>
>  }<br>
><br>
> @@ -4364,7 +4387,7 @@ VOID QxlDevice::SetImageId(<wbr>InternalImage *internal,<br>
>      }<br>
>  }<br>
><br>
> -void QxlDevice::CopyBits(const RECT& rect, const POINT& sourcePoint)<br>
> +QXLDrawable *QxlDevice::CopyBits(const RECT& rect, const POINT& sourcePoint)<br>
>  {<br>
<br>
</div></div>This CopyBits and BltBits are not doing anymore the operation, should<br>
be renamed to something like PrepareCopyBits (better names welcome)<br></blockquote><div><br></div><div>No problem, prefer to do it on later commits.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
>      PAGED_CODE();<br>
>      QXLDrawable *drawable;<br>
> @@ -4373,18 +4396,18 @@ void QxlDevice::CopyBits(const RECT& rect, const<br>
> POINT& sourcePoint)<br>
><br>
>      if (!(drawable = Drawable(QXL_COPY_BITS, &rect, NULL, 0))) {<br>
>          DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n"));<br>
> -        return;<br>
> +        return NULL;<br>
>      }<br>
><br>
>      drawable->u.copy_bits.src_pos.<wbr>x = sourcePoint.x;<br>
>      drawable->u.copy_bits.src_pos.<wbr>y = sourcePoint.y;<br>
><br>
> -    PushDrawable(drawable);<br>
> -<br>
>      DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));<br>
> +<br>
> +    return drawable;<br>
>  }<br>
><br>
> -VOID QxlDevice::BltBits (<br>
> +QXLDrawable *QxlDevice::BltBits (<br>
>      BLT_INFO* pDst,<br>
>      CONST BLT_INFO* pSrc,<br>
>      UINT  NumRects,<br>
> @@ -4407,7 +4430,7 @@ VOID QxlDevice::BltBits (<br>
><br>
>      if (!(drawable = Drawable(QXL_DRAW_COPY, pRects, NULL, 0))) {<br>
>          DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n"));<br>
> -        return;<br>
> +        return NULL;<br>
>      }<br>
><br>
>      CONST RECT* pRect = &pRects[0];<br>
> @@ -4480,9 +4503,9 @@ VOID QxlDevice::BltBits (<br>
>           drawable->surfaces_rects[0].<wbr>top,<br>
>           drawable->surfaces_rects[0].<wbr>bottom,<br>
>           drawable->u.copy.src_bitmap));<br>
><br>
> -    PushDrawable(drawable);<br>
> -<br>
>      DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));<br>
> +<br>
> +    return drawable;<br>
>  }<br>
><br>
>  VOID QxlDevice::PutBytesAlign(<wbr>QXLDataChunk **chunk_ptr, UINT8 **now_ptr,<br>
> diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h<br>
> index 4a62680..f441f4b 100755<br>
> --- a/qxldod/QxlDod.h<br>
> +++ b/qxldod/QxlDod.h<br>
> @@ -495,12 +495,12 @@ public:<br>
>      BOOLEAN IsBIOSCompatible() { return FALSE; }<br>
>  protected:<br>
>      NTSTATUS GetModeList(DXGK_DISPLAY_<wbr>INFORMATION* pDispInfo);<br>
> -    VOID BltBits (BLT_INFO* pDst,<br>
> +    QXLDrawable *BltBits (BLT_INFO* pDst,<br>
>                      CONST BLT_INFO* pSrc,<br>
>                      UINT  NumRects,<br>
>                      _In_reads_(NumRects) CONST RECT *pRects,<br>
>                      POINT*   pSourcePoint);<br>
> -    void CopyBits(const RECT& rect, const POINT& sourcePoint);<br>
> +    QXLDrawable *CopyBits(const RECT& rect, const POINT& sourcePoint);<br>
>      QXLDrawable *Drawable(UINT8 type,<br>
>                      CONST RECT *area,<br>
>                      CONST RECT *clip,<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">Frediano<br>
</font></span></blockquote></div><br></div></div>