[PATCH v3 5/6] qxl-wddm-dod: Implement non-forced bitmap allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Preparation for non-forced allocations.
Update bitmap creation procedure to allocate device memory forced
or non-forced.
In forced case it works as before.
In non-forced case, if allocation fails, the procedure allocates
memory from OS pool for entire bitmap and copies source data to it.
Later, before sending command, memory will be allocated from device
memory and copied from intermediate location to new one.

Signed-off-by: Yuri Benditovich <yuri.benditovich@xxxxxxxxxx>
---
 qxldod/QxlDod.cpp | 29 +++++++++++++++++++++++++----
 qxldod/QxlDod.h   |  2 +-
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 353f3c7..c832c93 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -4416,7 +4416,7 @@ QXLDrawable *QxlDevice::PrepareCopyBits(const RECT& rect, const POINT& sourcePoi
     return drawable;
 }
 
-BOOLEAN QxlDevice::AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src_end, INT pitch)
+BOOLEAN QxlDevice::AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src_end, INT pitch, BOOLEAN bForce)
 {
     PAGED_CODE();
     LONG width, height;
@@ -4434,7 +4434,7 @@ BOOLEAN QxlDevice::AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src
 
     alloc_size = BITMAP_ALLOC_BASE + BITS_BUF_MAX - BITS_BUF_MAX % line_size;
     alloc_size = MIN(BITMAP_ALLOC_BASE + height * line_size, alloc_size);
-    image_res = (Resource*)AllocMem(MSPACE_TYPE_VRAM, alloc_size, TRUE);
+    image_res = (Resource*)AllocMem(MSPACE_TYPE_VRAM, alloc_size, bForce);
 
     if (image_res) {
         image_res->refs = 1;
@@ -4466,6 +4466,27 @@ BOOLEAN QxlDevice::AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src
         DrawableAddRes(drawable, image_res);
         RELEASE_RES(image_res);
         alloc_size = height * line_size;
+    } else if (!bForce) {
+        alloc_size = height * line_size;
+        // allocate delayed chunck for entire bitmap without limitation
+        QXL_DELAYED_CHUNK *pChunk = (QXL_DELAYED_CHUNK *)new (PagedPool)BYTE[alloc_size + sizeof(QXL_DELAYED_CHUNK)];
+        if (pChunk) {
+            // add it to delayed list
+            InsertTailList(pDelayedList, &pChunk->list);
+            // PutBytesAlign do not need to allocate additional memory
+            pDelayedList = NULL;
+            chunk = &pChunk->chunk;
+            chunk->data_size = 0;
+            chunk->prev_chunk = 0;
+            chunk->next_chunk = 0;
+            // set dest and dest_end
+            dest = chunk->data;
+            dest_end = chunk->data + alloc_size;
+        } else {
+            // can't allocate memory
+            DbgPrint(TRACE_LEVEL_ERROR, ("Cannot allocate delayed bitmap for drawable\n"));
+            return FALSE;
+        }
     } else {
         // can't allocate memory (forced), driver abort flow
         DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get bitmap for drawable (stopping)\n"));
@@ -4473,7 +4494,7 @@ BOOLEAN QxlDevice::AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src
     }
 
     for (; src != src_end; src -= pitch, alloc_size -= line_size) {
-        BOOLEAN b = PutBytesAlign(&chunk, &dest, &dest_end, src, line_size, alloc_size, NULL);
+        BOOLEAN b = PutBytesAlign(&chunk, &dest, &dest_end, src, line_size, alloc_size, pDelayedList);
         if (!b) {
             DbgPrint(TRACE_LEVEL_WARNING, ("%s: aborting copy of lines\n", __FUNCTION__));
             return FALSE;
@@ -4530,7 +4551,7 @@ QXLDrawable *QxlDevice::PrepareBltBits (
     UINT8* src_end = src - pSrc->Pitch;
     src += pSrc->Pitch * (height - 1);
 
-    if (!AttachNewBitmap(drawable, src, src_end, (INT)pSrc->Pitch)) {
+    if (!AttachNewBitmap(drawable, src, src_end, (INT)pSrc->Pitch, TRUE)) {
         ReleaseOutput(drawable->release_info.id);
         drawable = NULL;
     } else {
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index f4e632b..28373b8 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -608,7 +608,7 @@ private:
     void PushCmd(void);
     void WaitForCursorRing(void);
     void PushCursor(void);
-    BOOLEAN AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src_end, INT pitch);
+    BOOLEAN AttachNewBitmap(QXLDrawable *drawable, UINT8 *src, UINT8 *src_end, INT pitch, BOOLEAN bForce);
     BOOLEAN PutBytesAlign(QXLDataChunk **chunk_ptr, UINT8 **now_ptr,
                             UINT8 **end_ptr, UINT8 *src, int size,
                             size_t alloc_size, PLIST_ENTRY pDelayed);
-- 
2.7.0.windows.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]