VirtualBox

Changeset 104874 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 10, 2024 10:09:38 AM (7 months ago)
Author:
vboxsync
Message:

3D: Quick fix implementing all kinds of memory transfers using host GPU hardware resources and DX API

File:
1 edited

Legend:

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

    r104813 r104874  
    45804580                               uint32_t cCopyBoxes, SVGA3dCopyBox *pBox)
    45814581{
    4582     RT_NOREF(cCopyBoxes, pBox);
     4582    RT_NOREF(cCopyBoxes);
     4583    AssertReturn(pBox, VERR_INVALID_PARAMETER);
    45834584
    45844585    LogFunc(("src sid %d -> dst sid %d\n", src.sid, dest.sid));
     
    45974598    AssertRCReturn(rc, rc);
    45984599
     4600/** @todo Implement a separate code paths for memory->texture, texture->memory and memory->memory transfers */
    45994601    LogFunc(("src%s sid = %u -> dst%s sid = %u\n",
    46004602             pSrcSurface->pBackendSurface ? "" : " sysmem", pSrcSurface->id,
     
    46044606    //AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    46054607
    4606     if (pSrcSurface->pBackendSurface)
    4607     {
    4608         if (pDstSurface->pBackendSurface == NULL)
    4609         {
    4610             rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, pDstSurface);
    4611             AssertRCReturn(rc, rc);
    4612         }
    4613 
    4614         if (pDstSurface->pBackendSurface)
    4615         {
    4616             /* Surface -> Surface. */
    4617             DXDEVICE *pDXDevice = &pBackend->dxDevice;
    4618 
    4619             /* Clip the box. */
    4620             PVMSVGA3DMIPMAPLEVEL pSrcMipLevel;
    4621             rc = vmsvga3dMipmapLevel(pSrcSurface, src.face, src.mipmap, &pSrcMipLevel);
    4622             ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
    4623 
    4624             PVMSVGA3DMIPMAPLEVEL pDstMipLevel;
    4625             rc = vmsvga3dMipmapLevel(pDstSurface, dest.face, dest.mipmap, &pDstMipLevel);
    4626             ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
    4627 
    4628             SVGA3dCopyBox clipBox = *pBox;
    4629             vmsvgaR3ClipCopyBox(&pSrcMipLevel->mipmapSize, &pDstMipLevel->mipmapSize, &clipBox);
    4630 
    4631             UINT DstSubresource = vmsvga3dCalcSubresource(dest.mipmap, dest.face, pDstSurface->cLevels);
    4632             UINT DstX = clipBox.x;
    4633             UINT DstY = clipBox.y;
    4634             UINT DstZ = clipBox.z;
    4635 
    4636             UINT SrcSubresource = vmsvga3dCalcSubresource(src.mipmap, src.face, pSrcSurface->cLevels);
    4637             D3D11_BOX SrcBox;
    4638             SrcBox.left   = clipBox.srcx;
    4639             SrcBox.top    = clipBox.srcy;
    4640             SrcBox.front  = clipBox.srcz;
    4641             SrcBox.right  = clipBox.srcx + clipBox.w;
    4642             SrcBox.bottom = clipBox.srcy + clipBox.h;
    4643             SrcBox.back   = clipBox.srcz + clipBox.d;
    4644 
    4645             Assert(cCopyBoxes == 1); /** @todo */
    4646 
    4647             ID3D11Resource *pDstResource;
    4648             ID3D11Resource *pSrcResource;
    4649             pDstResource = dxResource(pDstSurface);
    4650             pSrcResource = dxResource( pSrcSurface);
    4651 
    4652             pDXDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ,
    4653                                                                 pSrcResource, SrcSubresource, &SrcBox);
    4654         }
    4655         else
    4656         {
    4657             /* Surface -> Memory. */
    4658             AssertFailed(); /** @todo implement */
    4659         }
    4660     }
    4661     else
    4662     {
    4663         /* Memory -> Surface. */
    4664         AssertFailed(); /** @todo implement */
    4665     }
     4608    if (pSrcSurface->pBackendSurface == NULL)
     4609    {
     4610        rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, pSrcSurface);
     4611        AssertRCReturn(rc, rc);
     4612    }
     4613
     4614    if (pDstSurface->pBackendSurface == NULL)
     4615    {
     4616        rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, pDstSurface);
     4617        AssertRCReturn(rc, rc);
     4618    }
     4619
     4620    DXDEVICE *pDXDevice = &pBackend->dxDevice;
     4621
     4622    /* Clip the box. */
     4623    PVMSVGA3DMIPMAPLEVEL pSrcMipLevel;
     4624    rc = vmsvga3dMipmapLevel(pSrcSurface, src.face, src.mipmap, &pSrcMipLevel);
     4625    ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
     4626
     4627    PVMSVGA3DMIPMAPLEVEL pDstMipLevel;
     4628    rc = vmsvga3dMipmapLevel(pDstSurface, dest.face, dest.mipmap, &pDstMipLevel);
     4629    ASSERT_GUEST_RETURN(RT_SUCCESS(rc), rc);
     4630
     4631    SVGA3dCopyBox clipBox = *pBox;
     4632    vmsvgaR3ClipCopyBox(&pSrcMipLevel->mipmapSize, &pDstMipLevel->mipmapSize, &clipBox);
     4633
     4634    UINT DstSubresource = vmsvga3dCalcSubresource(dest.mipmap, dest.face, pDstSurface->cLevels);
     4635    UINT DstX = clipBox.x;
     4636    UINT DstY = clipBox.y;
     4637    UINT DstZ = clipBox.z;
     4638
     4639    UINT SrcSubresource = vmsvga3dCalcSubresource(src.mipmap, src.face, pSrcSurface->cLevels);
     4640    D3D11_BOX SrcBox;
     4641    SrcBox.left   = clipBox.srcx;
     4642    SrcBox.top    = clipBox.srcy;
     4643    SrcBox.front  = clipBox.srcz;
     4644    SrcBox.right  = clipBox.srcx + clipBox.w;
     4645    SrcBox.bottom = clipBox.srcy + clipBox.h;
     4646    SrcBox.back   = clipBox.srcz + clipBox.d;
     4647
     4648    Assert(cCopyBoxes == 1); /** @todo */
     4649
     4650    ID3D11Resource *pDstResource;
     4651    ID3D11Resource *pSrcResource;
     4652    pDstResource = dxResource(pDstSurface);
     4653    pSrcResource = dxResource(pSrcSurface);
     4654
     4655    pDXDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ,
     4656                                                        pSrcResource, SrcSubresource, &SrcBox);
    46664657
    46674658    return rc;
Note: See TracChangeset for help on using the changeset viewer.

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