third_party/virtualbox/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
/**
 * Backend worker for implementing SVGA_3D_CMD_SURFACE_STRETCHBLT.
 *
 * @returns VBox status code.
 * @param   pThis               The VGA device instance.
 * @param   pState              The VMSVGA3d state.
 * @param   pDstSurface         The destination host surface.
 * @param   uDstFace            The destination face (valid).
 * @param   uDstMipmap          The destination mipmap level (valid).
 * @param   pDstBox             The destination box.
 * @param   pSrcSurface         The source host surface.
 * @param   uSrcFace            The destination face (valid).
 * @param   uSrcMipmap          The source mimap level (valid).
 * @param   pSrcBox             The source box.
 * @param   enmMode             The strecht blt mode .
 * @param   pContext            The VMSVGA3d context (already current for OGL).
 */
Backend worker for implementing SVGA_3D_CMD_SURFACE_STRETCHBLT.
@returns VBox status code.
@param   pThis               The VGA device instance.
@param   pState              The VMSVGA3d state.
@param   pDstSurface         The destination host surface.
@param   uDstFace            The destination face (valid).
@param   uDstMipmap          The destination mipmap level (valid).
@param   pDstBox             The destination box.
@param   pSrcSurface         The source host surface.
@param   uSrcFace            The destination face (valid).
@param   uSrcMipmap          The source mimap level (valid).
@param   pSrcBox             The source box.
@param   enmMode             The strecht blt mode .
@param   pContext            The VMSVGA3d context (already current for OGL).
Backend worker for implementing SVGA_3D_CMD_SURFACE_STRETCHBLT . @returns VBox status code . @param pThis The VGA device instance . @param pState The VMSVGA3d state . @param pDstSurface The destination host surface . @param uDstFace The destination face ( valid ) . @param uDstMipmap The destination mipmap level ( valid ) . @param pDstBox The destination box . @param pSrcSurface The source host surface . @param uSrcFace The destination face ( valid ) . @param uSrcMipmap The source mimap level ( valid ) . @param pSrcBox The source box . @param enmMode The strecht blt mode . @param pContext The VMSVGA3d context ( already current for OGL ) .
int vmsvga3dBackSurfaceStretchBlt(PVGASTATE pThis, PVMSVGA3DSTATE pState,
                                  PVMSVGA3DSURFACE pDstSurface, uint32_t uDstFace, uint32_t uDstMipmap, SVGA3dBox const *pDstBox,
                                  PVMSVGA3DSURFACE pSrcSurface, uint32_t uSrcFace, uint32_t uSrcMipmap, SVGA3dBox const *pSrcBox,
                                  SVGA3dStretchBltMode enmMode, PVMSVGA3DCONTEXT pContext)
{
    HRESULT hr;
    int rc;
    AssertReturn(pSrcSurface->enmD3DResType != VMSVGA3D_D3DRESTYPE_VOLUME_TEXTURE, VERR_NOT_IMPLEMENTED);
    AssertReturn(pDstSurface->enmD3DResType != VMSVGA3D_D3DRESTYPE_VOLUME_TEXTURE, VERR_NOT_IMPLEMENTED);
    vmsvga3dSurfaceFlush(pThis, pSrcSurface);
    vmsvga3dSurfaceFlush(pThis, pDstSurface);
    RECT RectSrc;
    RectSrc.left    = pSrcBox->x;
    RectSrc.top     = pSrcBox->y;
    RectSrc.right   = pSrcBox->x + pSrcBox->w;  
    RectSrc.bottom  = pSrcBox->y + pSrcBox->h;  
    Assert(!pSrcBox->z);
    RECT RectDst;
    RectDst.left   = pDstBox->x;
    RectDst.top    = pDstBox->y;
    RectDst.right  = pDstBox->x + pDstBox->w;  
    RectDst.bottom = pDstBox->y + pDstBox->h;  
    Assert(!pDstBox->z);
    IDirect3DSurface9 *pSrc;
    rc = vmsvga3dGetD3DSurface(pContext, pSrcSurface, uSrcFace, uSrcMipmap, false, &pSrc);
    AssertRCReturn(rc, rc);
    IDirect3DSurface9 *pDst;
    rc = vmsvga3dGetD3DSurface(pContext, pDstSurface, uDstFace, uDstMipmap, false, &pDst);
    AssertRCReturn(rc, rc);
    D3DTEXTUREFILTERTYPE moded3d;
    switch (enmMode)
    {
    case SVGA3D_STRETCH_BLT_POINT:
        moded3d = D3DTEXF_POINT;
        break;
    case SVGA3D_STRETCH_BLT_LINEAR:
        moded3d = D3DTEXF_LINEAR;
        break;
    default:
        AssertFailed();
        moded3d = D3DTEXF_NONE;
        break;
    }
    hr = pContext->pDevice->StretchRect(pSrc, &RectSrc, pDst, &RectDst, moded3d);
    D3D_RELEASE(pDst);
    D3D_RELEASE(pSrc);
    AssertMsgReturn(hr == D3D_OK, ("StretchRect failed with %x\n", hr), VERR_INTERNAL_ERROR);
    vmsvga3dSurfaceTrackUsage(pState, pContext, pSrcSurface);
    vmsvga3dSurfaceTrackUsage(pState, pContext, pDstSurface);
    return VINF_SUCCESS;
}
int vmsvga3dBackSurfaceStretchBlt ( PVGASTATE pThis , PVMSVGA3DSTATE pState , PVMSVGA3DSURFACE pDstSurface , uint32_t uDstFace , uint32_t uDstMipmap , SVGA3dBox const * pDstBox , PVMSVGA3DSURFACE pSrcSurface , uint32_t uSrcFace , uint32_t uSrcMipmap , SVGA3dBox const * pSrcBox , SVGA3dStretchBltMode enmMode , PVMSVGA3DCONTEXT pContext ) { HRESULT hr ; int rc ; AssertReturn ( pSrcSurface -> enmD3DResType != VMSVGA3D_D3DRESTYPE_VOLUME_TEXTURE , VERR_NOT_IMPLEMENTED ) ; AssertReturn ( pDstSurface -> enmD3DResType != VMSVGA3D_D3DRESTYPE_VOLUME_TEXTURE , VERR_NOT_IMPLEMENTED ) ; vmsvga3dSurfaceFlush ( pThis , pSrcSurface ) ; vmsvga3dSurfaceFlush ( pThis , pDstSurface ) ; RECT RectSrc ; RectSrc . left = pSrcBox -> x ; RectSrc . top = pSrcBox -> y ; RectSrc . right = pSrcBox -> x + pSrcBox -> w ; RectSrc . bottom = pSrcBox -> y + pSrcBox -> h ; Assert ( ! pSrcBox -> z ) ; RECT RectDst ; RectDst . left = pDstBox -> x ; RectDst . top = pDstBox -> y ; RectDst . right = pDstBox -> x + pDstBox -> w ; RectDst . bottom = pDstBox -> y + pDstBox -> h ; Assert ( ! pDstBox -> z ) ; IDirect3DSurface9 * pSrc ; rc = vmsvga3dGetD3DSurface ( pContext , pSrcSurface , uSrcFace , uSrcMipmap , false , & pSrc ) ; AssertRCReturn ( rc , rc ) ; IDirect3DSurface9 * pDst ; rc = vmsvga3dGetD3DSurface ( pContext , pDstSurface , uDstFace , uDstMipmap , false , & pDst ) ; AssertRCReturn ( rc , rc ) ; D3DTEXTUREFILTERTYPE moded3d ; switch ( enmMode ) { case SVGA3D_STRETCH_BLT_POINT : moded3d = D3DTEXF_POINT ; break ; case SVGA3D_STRETCH_BLT_LINEAR : moded3d = D3DTEXF_LINEAR ; break ; default : AssertFailed ( ) ; moded3d = D3DTEXF_NONE ; break ; } hr = pContext -> pDevice -> StretchRect ( pSrc , & RectSrc , pDst , & RectDst , moded3d ) ; D3D_RELEASE ( pDst ) ; D3D_RELEASE ( pSrc ) ; AssertMsgReturn ( hr == D3D_OK , ( " \n " , hr ) , VERR_INTERNAL_ERROR ) ; vmsvga3dSurfaceTrackUsage ( pState , pContext , pSrcSurface ) ; vmsvga3dSurfaceTrackUsage ( pState , pContext , pDstSurface ) ; return VINF_SUCCESS ; }
Backend worker for implementing SVGA_3D_CMD_SURFACE_STRETCHBLT.
Backend worker for implementing SVGA_3D_CMD_SURFACE_STRETCHBLT .
/* Flush the drawing pipeline for this surface as it could be used in a shared context. */ /* exclusive */ /* exclusive */ /* exclusive */ /* exclusive */ /* Track the StretchRect operation. */