VirtualBox

Ignore:
Timestamp:
Jul 18, 2018 7:14:24 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123797
Message:

DevVGA-SVGA: added new parameters for vmsvgaGMRTransfer in order to reduce code duplication, adjusted callers accordingly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp

    r71686 r73194  
    23492349 * @param   cbGuestPitch        The guest pitch.
    23502350 * @param   transfer            The transfer direction.
    2351  * @param   pBox                The box to copy.
     2351 * @param   pBox                The box to copy (clipped, valid, except for guest's srcx, srcy, srcz).
    23522352 * @param   pContext            The context (for OpenGL).
    23532353 * @param   rc                  The current rc for all boxes.
     
    23692369    {
    23702370        uint32_t cbSurfacePitch;
    2371         uint8_t *pDoubleBuffer, *pBufferStart;
    2372         unsigned uDestOffset = 0;
     2371        uint8_t *pDoubleBuffer;
     2372        uint32_t offHst;
    23732373
    23742374        pDoubleBuffer = (uint8_t *)RTMemAlloc(pMipLevel->cbSurface);
     
    24032403            VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext);
    24042404
    2405             uDestOffset = pBox->x * pSurface->cbBlock + pBox->y * pMipLevel->cbSurfacePitch;
    2406             AssertReturnStmt(   uDestOffset + pBox->w * pSurface->cbBlock + (pBox->h - 1) * pMipLevel->cbSurfacePitch
    2407                              <= pMipLevel->cbSurface,
    2408                              RTMemFree(pDoubleBuffer),
    2409                              VERR_INTERNAL_ERROR);
    2410 
     2405            offHst = pBox->x * pSurface->cbBlock + pBox->y * pMipLevel->cbSurfacePitch;
    24112406            cbSurfacePitch = pMipLevel->cbSurfacePitch;
    24122407
     
    24172412                           - cbSurfacePitch;      /* flip image during copy */
    24182413#else
    2419             pBufferStart = pDoubleBuffer + uDestOffset;
    24202414#endif
    24212415        }
    24222416        else
    24232417        {
     2418            /* The buffer will contain only the copied rectangle. */
     2419            offHst = 0;
    24242420            cbSurfacePitch = pBox->w * pSurface->cbBlock;
    24252421#ifdef MANUAL_FLIP_SURFACE_DATA
    24262422            pBufferStart = pDoubleBuffer + cbSurfacePitch * pBox->h - cbSurfacePitch;      /* flip image during copy */
    24272423#else
    2428             pBufferStart = pDoubleBuffer;
    2429 #endif
    2430         }
     2424#endif
     2425        }
     2426
     2427        uint32_t const offGst = pBox->srcx * pSurface->cbBlock + pBox->srcy * cbGuestPitch; /// @todo compressed fmts
    24312428
    24322429        rc = vmsvgaGMRTransfer(pThis,
    24332430                               transfer,
    2434                                pBufferStart,
     2431                               pDoubleBuffer,
     2432                               pMipLevel->cbSurface,
     2433                               offHst,
    24352434#ifdef MANUAL_FLIP_SURFACE_DATA
    24362435                               -(int32_t)cbSurfacePitch,
    24372436#else
    2438                                (int32_t)cbSurfacePitch,
     2437                               cbSurfacePitch,
    24392438#endif
    24402439                               GuestPtr,
    2441                                pBox->srcx * pSurface->cbBlock + pBox->srcy * cbGuestPitch, /// @todo compressed fmts
     2440                               offGst,
    24422441                               cbGuestPitch,
    24432442                               pBox->w * pSurface->cbBlock,
     
    24982497    case SVGA3D_SURFACE_HINT_INDEXBUFFER:
    24992498    {
    2500         Assert(pBox->h == 1);
     2499        /* Caller already clipped pBox and buffers are 1-dimensional. */
     2500        Assert(pBox->y == 0 && pBox->h == 1 && pBox->z == 0 && pBox->d == 1);
    25012501
    25022502        VMSVGA3D_CLEAR_GL_ERRORS();
     
    25152515                          ("cbStrictBufSize=%#x cbSurface=%#x pContext->id=%#x\n", (uint32_t)cbStrictBufSize, pMipLevel->cbSurface, pContext->id));
    25162516#endif
    2517 
    2518                 unsigned offDst = pBox->x * pSurface->cbBlock + pBox->y * pMipLevel->cbSurfacePitch;
    2519                 if (RT_LIKELY(   offDst + pBox->w * pSurface->cbBlock  + (pBox->h - 1) * pMipLevel->cbSurfacePitch
    2520                               <= pMipLevel->cbSurface))
    2521                 {
    2522                     Log(("Lock %s memory for rectangle (%d,%d)(%d,%d)\n",
    2523                          (pSurface->surfaceFlags & VMSVGA3D_SURFACE_HINT_SWITCH_MASK) == SVGA3D_SURFACE_HINT_VERTEXBUFFER ? "vertex" :
    2524                            (pSurface->surfaceFlags & VMSVGA3D_SURFACE_HINT_SWITCH_MASK) == SVGA3D_SURFACE_HINT_INDEXBUFFER ? "index" : "buffer",
    2525                          pBox->x, pBox->y, pBox->x + pBox->w, pBox->y + pBox->h));
    2526 
    2527                     rc = vmsvgaGMRTransfer(pThis,
    2528                                            transfer,
    2529                                            pbData + offDst,
    2530                                            pMipLevel->cbSurfacePitch,
    2531                                            GuestPtr,
    2532                                            pBox->srcx * pSurface->cbBlock + pBox->srcy * cbGuestPitch,
    2533                                            cbGuestPitch,
    2534                                            pBox->w * pSurface->cbBlock,
    2535                                            pBox->h);
    2536                     AssertRC(rc);
    2537 
    2538                     Log4(("first line:\n%.*Rhxd\n", cbGuestPitch, pbData + offDst));
    2539                 }
    2540                 else
    2541                 {
    2542                     AssertFailed();
    2543                     rc = VERR_INTERNAL_ERROR;
    2544                 }
     2517                Log(("Lock %s memory for rectangle (%d,%d)(%d,%d)\n",
     2518                     (pSurface->surfaceFlags & VMSVGA3D_SURFACE_HINT_SWITCH_MASK) == SVGA3D_SURFACE_HINT_VERTEXBUFFER ? "vertex" :
     2519                       (pSurface->surfaceFlags & VMSVGA3D_SURFACE_HINT_SWITCH_MASK) == SVGA3D_SURFACE_HINT_INDEXBUFFER ? "index" : "buffer",
     2520                     pBox->x, pBox->y, pBox->x + pBox->w, pBox->y + pBox->h));
     2521
     2522                uint32_t const offHst = pBox->x * pSurface->cbBlock;
     2523
     2524                rc = vmsvgaGMRTransfer(pThis,
     2525                                       transfer,
     2526                                       pbData,
     2527                                       pMipLevel->cbSurface,
     2528                                       offHst,
     2529                                       pMipLevel->cbSurfacePitch,
     2530                                       GuestPtr,
     2531                                       pBox->srcx * pSurface->cbBlock,
     2532                                       cbGuestPitch,
     2533                                       pBox->w * pSurface->cbBlock,
     2534                                       pBox->h);
     2535                AssertRC(rc);
     2536
     2537                Log4(("first line:\n%.*Rhxd\n", cbGuestPitch, pbData + offHst));
    25452538
    25462539                pState->ext.glUnmapBuffer(GL_ARRAY_BUFFER);
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