VirtualBox

Ignore:
Timestamp:
Jul 6, 2010 11:47:17 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63409
Message:

wddm/3d: swapchain & render target fixes

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp

    r30630 r30657  
    10611061        }
    10621062    }
     1063    return S_OK;
     1064}
     1065
     1066static HRESULT vboxWddmRenderTargetUpdateSurface(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, uint32_t iBBuf)
     1067{
     1068    IDirect3DSurface9 *pD3D9Surf;
     1069    HRESULT hr = pDevice->pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/,
     1070            iBBuf, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);
     1071    Assert(hr == S_OK);
     1072    if (hr == S_OK)
     1073    {
     1074        Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
     1075        if (pAlloc->pD3DIf)
     1076            pAlloc->pD3DIf->Release();
     1077        pAlloc->pD3DIf = pD3D9Surf;
     1078    }
     1079    return hr;
     1080}
     1081static HRESULT vboxWddmRenderTargetUpdate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, uint32_t iNewRTFB)
     1082{
     1083    PVBOXWDDMDISP_ALLOCATION pAlloc;
     1084    UINT iBBuf = 0;
     1085    for (UINT i = iNewRTFB + 1; i < pRc->cAllocations; ++i, ++iBBuf)
     1086    {
     1087        pAlloc = &pRc->aAllocations[i];
     1088        Assert(i != iNewRTFB);
     1089        HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, iBBuf);
     1090        Assert(tmpHr == S_OK);
     1091    }
     1092
     1093    for (UINT i = 0; iBBuf < pRc->cAllocations-1; ++i, ++iBBuf)
     1094    {
     1095        Assert(i != iNewRTFB);
     1096        pAlloc = &pRc->aAllocations[i];
     1097        HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, iBBuf);
     1098        Assert(tmpHr == S_OK);
     1099    }
     1100
     1101    pAlloc = &pRc->aAllocations[iNewRTFB];
     1102    HRESULT tmpHr = vboxWddmRenderTargetUpdateSurface(pDevice, pAlloc, ~0UL /* <- for the frontbuffer */);
     1103    Assert(tmpHr == S_OK);
    10631104    return S_OK;
    10641105}
     
    32623303                            pDevice->pRenderTargetRc = pRc;
    32633304
    3264                             IDirect3DSurface9* pD3D9Surf;
    3265                             hr = pDevice->pDevice9If->GetRenderTarget(0, &pD3D9Surf);
     3305                            for (UINT i = 0; i < pResource->SurfCount; ++i)
     3306                            {
     3307                                PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
     3308                                pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;
     3309                            }
     3310
     3311                            hr = vboxWddmRenderTargetUpdate(pDevice, pRc, 0);
    32663312                            Assert(hr == S_OK);
    32673313                            if (hr == S_OK)
    32683314                            {
    3269                                 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[0];
    3270                                 pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;
    3271                                 pAllocation->pD3DIf = pD3D9Surf;
    3272                                 hr = vboxWddmSurfSynchMem(pRc, pAllocation);
    3273                                 Assert(hr == S_OK);
    3274                                 if (hr == S_OK)
     3315                                for (UINT i = 0; i < pResource->SurfCount; ++i)
    32753316                                {
    3276                                     for (UINT i = 1; i < pResource->SurfCount; ++i)
     3317                                    PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
     3318                                    pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;
     3319                                    hr = vboxWddmSurfSynchMem(pRc, pAllocation);
     3320                                    Assert(hr == S_OK);
     3321                                    if (hr != S_OK)
     3322                                    {
     3323                                        break;
     3324                                    }
     3325                                }
     3326
     3327                                if (hr != S_OK)
     3328                                {
     3329                                    for (UINT i = 0; i < pResource->SurfCount; ++i)
    32773330                                    {
    32783331                                        PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i];
    3279                                         hr = pDevice->pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/,
    3280                                                 i-1, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);
    3281                                         Assert(hr == S_OK);
    3282                                         if (hr == S_OK)
    3283                                         {
    3284                                             Assert(pD3D9Surf);
    3285                                             pAllocation->enmD3DIfType = VBOXDISP_D3DIFTYPE_SURFACE;
    3286                                             pAllocation->pD3DIf = pD3D9Surf;
    3287                                             hr = vboxWddmSurfSynchMem(pRc, pAllocation);
    3288                                             Assert(hr == S_OK);
    3289                                             if (hr == S_OK)
    3290                                             {
    3291                                                 continue;
    3292                                             }
    3293 
    3294                                             /* Failure branch */
    3295                                             pD3D9Surf->Release();
    3296                                         }
    3297 
    3298                                         for (UINT j = 1; j < i; ++j)
    3299                                         {
    3300                                             pRc->aAllocations[j].pD3DIf->Release();
    3301                                         }
     3332                                        pAllocation->pD3DIf->Release();
    33023333                                    }
    33033334                                }
    3304 
    3305                                 if (hr != S_OK)
    3306                                     pRc->aAllocations[0].pD3DIf->Release();
    33073335                            }
    33083336
     
    35513579//    DdiDm.PrivateDriverFormatAttribute = 0;
    35523580    Assert(pDevice->pRenderTargetRc == pRc);
     3581    Assert(pDevice->iRenderTargetFrontBuf == pData->SubResourceIndex);
    35533582
    35543583#if 0
     
    35883617#endif
    35893618    {
     3619        if (pData->Flags.Flip)
     3620        {
     3621            Assert(pData->hSrcResource);
     3622            PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
     3623            Assert(pDevice->pRenderTargetRc == pRc);
     3624            Assert(pRc->cAllocations >= 2);
     3625            Assert(pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
     3626            Assert(pRc->RcDesc.fFlags.RenderTarget);
     3627            uint32_t iNewRTFB = pDevice->iRenderTargetFrontBuf + 1;
     3628            if (iNewRTFB >= pRc->cAllocations)
     3629                iNewRTFB = 0;
     3630
     3631            Assert(pDevice->iRenderTargetFrontBuf != iNewRTFB);
     3632            Assert(pData->SrcSubResourceIndex == iNewRTFB);
     3633
     3634            vboxWddmRenderTargetUpdate(pDevice, pRc, iNewRTFB);
     3635
     3636            /* assign a new frontbuffer index */
     3637            pDevice->iRenderTargetFrontBuf = iNewRTFB;
     3638        }
    35903639        D3DDDICB_PRESENT DdiPresent = {0};
    35913640        if (pData->hSrcResource)
     
    41394188    HRESULT hr = S_OK;
    41404189    IDirect3DSurface9 *pD3D9Surf;
    4141     hr = vboxWddmSurfGet(pRc, pData->SubResourceIndex, &pD3D9Surf);
    4142     Assert(hr == S_OK);
     4190    if (pRc == pDevice->pRenderTargetRc && pRc->cAllocations == 1 && pData->RenderTargetIndex == 0)
     4191    {
     4192        /* work-around wine double-buffering for the case we have no backbuffers */
     4193        hr = pDevice->pDevice9If->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);
     4194        Assert(hr == S_OK);
     4195        Assert(pD3D9Surf);
     4196    }
     4197    else
     4198    {
     4199        hr = vboxWddmSurfGet(pRc, pData->SubResourceIndex, &pD3D9Surf);
     4200        Assert(hr == S_OK);
     4201        Assert(pD3D9Surf);
     4202    }
    41434203    if (hr == S_OK)
    41444204    {
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h

    r30603 r30657  
    103103    HWND hWnd;
    104104    struct VBOXWDDMDISP_RESOURCE *pRenderTargetRc;
     105    uint32_t iRenderTargetFrontBuf;
    105106    /* number of StreamSources set */
    106107    UINT cStreamSources;
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3DCmn.h

    r30554 r30657  
    6363    } while (0)
    6464#define vboxVDbgPrintR vboxVDbgPrint
    65 #define vboxVDbgPrintF vboxVDbgPrint
     65#define vboxVDbgPrintF(_m)  do {} while (0)
    6666#else
    6767#define vboxVDbgBreak() do {} while (0)
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