VirtualBox

Changeset 15707 in vbox


Ignore:
Timestamp:
Dec 19, 2008 6:16:40 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
41270
Message:

crOpenGL: make host buffer dynamic in size, fix for 3443

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c

    r15532 r15707  
    117117    /* make sure there's host buffer and it's clear */
    118118    CRASSERT(conn->pHostBuffer && !conn->cbHostBuffer);
    119     CRASSERT(conn->cbHostBufferAllocated >= len);
     119
     120    if (conn->cbHostBufferAllocated < len)
     121    {
     122        crDebug("Host buffer too small %d out of requsted %d bytes, reallocating", conn->cbHostBufferAllocated, len);
     123        crFree(conn->pHostBuffer);
     124        conn->pHostBuffer = crAlloc(len);
     125        if (!conn->pHostBuffer)
     126        {
     127            conn->cbHostBufferAllocated = 0;
     128            crError("OUT_OF_MEMORY trying to allocate %d bytes", len);
     129            return FALSE;
     130        }
     131        conn->cbHostBufferAllocated = len;
     132    }
    120133
    121134    crMemcpy(conn->pHostBuffer, buf, len);
     
    314327}
    315328
     329static void crVBoxHGCMReadExact( CRConnection *conn, const void *buf, unsigned int len )
     330{
     331    CRVBOXHGCMREAD parms;
     332    int rc;
     333
     334    parms.hdr.result      = VINF_SUCCESS;
     335    parms.hdr.u32ClientID = conn->u32ClientID;
     336    parms.hdr.u32Function = SHCRGL_GUEST_FN_READ;
     337    parms.hdr.cParms      = SHCRGL_CPARMS_READ;
     338
     339    CRASSERT(!conn->pBuffer); //make sure there's no data to process
     340    parms.pBuffer.type                   = VMMDevHGCMParmType_LinAddr_Out;
     341    parms.pBuffer.u.Pointer.size         = conn->cbHostBufferAllocated;
     342    parms.pBuffer.u.Pointer.u.linearAddr = (VMMDEVHYPPTR) conn->pHostBuffer;
     343
     344    parms.cbBuffer.type      = VMMDevHGCMParmType_32bit;
     345    parms.cbBuffer.u.value32 = 0;
     346
     347    rc = crVBoxHGCMCall(&parms, sizeof(parms));
     348
     349    if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.result))
     350    {
     351        crDebug("SHCRGL_GUEST_FN_WRITE_READ failed with %x %x\n", rc, parms.hdr.result);
     352        return;
     353    }
     354
     355    if (parms.cbBuffer.u.value32)
     356    {
     357        conn->pBuffer  = (uint8_t*) parms.pBuffer.u.Pointer.u.linearAddr;
     358        conn->cbBuffer = parms.cbBuffer.u.value32;
     359    }
     360
     361    if (conn->cbBuffer)
     362        crVBoxHGCMReceiveMessage(conn);
     363
     364}
     365
    316366/* Same as crVBoxHGCMWriteExact, but combined with read of writeback data.
    317367 * This halves the number of HGCM calls we do,
     
    354404    if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.result))
    355405    {
    356         crDebug("SHCRGL_GUEST_FN_WRITE_READ failed with %x %x\n", rc, parms.hdr.result);
    357         return;
     406
     407        if ((VERR_BUFFER_OVERFLOW == parms.hdr.result) && RT_SUCCESS(rc))
     408        {
     409            /* reallocate buffer and retry */
     410
     411            CRASSERT(parms.cbWriteback.u.value32>conn->cbHostBufferAllocated);
     412
     413            crDebug("Reallocating host buffer from %d to %d bytes", conn->cbHostBufferAllocated, parms.cbWriteback.u.value32);
     414
     415            crFree(conn->pHostBuffer);
     416            conn->cbHostBufferAllocated = parms.cbWriteback.u.value32;
     417            conn->pHostBuffer = crAlloc(conn->cbHostBufferAllocated);
     418
     419            crVBoxHGCMReadExact(conn, buf, len);
     420
     421            return;
     422        }
     423        else
     424        {
     425            crDebug("SHCRGL_GUEST_FN_WRITE_READ failed with %x %x\n", rc, parms.hdr.result);
     426            return;
     427        }
    358428    }
    359429
     
    413483     */
    414484    *bufp = NULL;
    415 }
    416 
    417 static void crVBoxHGCMReadExact( CRConnection *conn, void *buf, unsigned int len )
    418 {
    419     CRASSERT(FALSE);
    420485}
    421486
     
    900965
    901966    //@todo remove this crap at all later
    902     conn->cbHostBufferAllocated = 100*1024;
     967    conn->cbHostBufferAllocated = 1*1024;
    903968    conn->pHostBuffer = (uint8_t*) crAlloc(conn->cbHostBufferAllocated);
    904969    CRASSERT(conn->pHostBuffer);
  • trunk/src/VBox/HostServices/SharedOpenGL/crserver/crservice.cpp

    r15532 r15707  
    297297                /* Update parameters.*/
    298298                paParms[0].u.pointer.size = cbBuffer; //@todo guest doesn't see this change somehow?
    299                 paParms[1].u.uint32 = cbBuffer;
    300             }
     299            }
     300
     301            /* Return the required buffer size always */
     302            paParms[1].u.uint32 = cbBuffer;
    301303
    302304            break;
     
    337339                    /* Update parameters.*/
    338340                    paParms[1].u.pointer.size = cbWriteback;
    339                     paParms[2].u.uint32 = cbWriteback;
    340341                }
     342                /* Return the required buffer size always */
     343                paParms[2].u.uint32 = cbWriteback;
    341344            }
    342345            break;
  • trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c

    r15532 r15707  
    460460        crWarning("crServer: [%lx] ClientRead u32ClientID=%d FAIL, host buffer too small %d of %d",
    461461                  crThreadID(), u32ClientID, *pcbBuffer, pClient->conn->cbHostBuffer);
    462         return VERR_INVALID_PARAMETER;
     462
     463        /* Return the size of needed buffer */
     464        *pcbBuffer = pClient->conn->cbHostBuffer;
     465
     466        return VERR_BUFFER_OVERFLOW;
    463467    }
    464468
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette