VirtualBox

Ignore:
Timestamp:
May 31, 2010 5:38:48 PM (15 years ago)
Author:
vboxsync
Message:

wddm/2d: overlay surface creation fixes

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Miniport
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h

    r29895 r29922  
    157157{
    158158    VBOXVHWA_INFO Settings;
    159     bool cOverlaysCreated;
     159    volatile uint32_t cOverlaysCreated;
    160160} VBOXWDDM_VHWA;
    161161#endif
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp

    r29895 r29922  
    477477}
    478478
     479int vboxVhwaHlpDestroySurface(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf,
     480        D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     481{
     482    Assert(pSurf->hHostHandle);
     483    if (!pSurf->hHostHandle)
     484        return VERR_INVALID_STATE;
     485
     486    VBOXVHWACMD* pCmd = vboxVhwaCommandCreate(pDevExt, VidPnSourceId,
     487            VBOXVHWACMD_TYPE_SURF_DESTROY, sizeof(VBOXVHWACMD_SURF_DESTROY));
     488    Assert(pCmd);
     489    if(pCmd)
     490    {
     491        VBOXVHWACMD_SURF_DESTROY * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_DESTROY);
     492
     493        memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_DESTROY));
     494
     495        pBody->u.in.hSurf = pSurf->hHostHandle;
     496
     497        /* we're not interested in completion, just send the command */
     498        vboxVhwaCommandSubmitAsynchAndComplete(pDevExt, pCmd);
     499
     500        pSurf->hHostHandle = VBOXVHWA_SURFHANDLE_INVALID;
     501
     502        return VINF_SUCCESS;
     503    }
     504
     505    return VERR_OUT_OF_RESOURCES;
     506}
     507
     508int vboxVhwaHlpPopulateSurInfo(VBOXVHWA_SURFACEDESC *pInfo, PVBOXWDDM_ALLOCATION pSurf,
     509        uint32_t fFlags, uint32_t cBackBuffers, uint32_t fSCaps,
     510        D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     511{
     512    memset(pInfo, 0, sizeof(VBOXVHWA_SURFACEDESC));
     513
     514    pInfo->height = pSurf->SurfDesc.height;
     515    pInfo->width = pSurf->SurfDesc.width;
     516    pInfo->flags |= VBOXVHWA_SD_HEIGHT | VBOXVHWA_SD_WIDTH;
     517    if (fFlags & VBOXVHWA_SD_PITCH)
     518    {
     519        pInfo->pitch = pSurf->SurfDesc.pitch;
     520        pInfo->flags |= VBOXVHWA_SD_PITCH;
     521        pInfo->sizeX = pSurf->SurfDesc.cbSize;
     522        pInfo->sizeY = 1;
     523    }
     524
     525    if (cBackBuffers)
     526    {
     527        pInfo->cBackBuffers = cBackBuffers;
     528        pInfo->flags |= VBOXVHWA_SD_BACKBUFFERCOUNT;
     529    }
     530    else
     531        pInfo->cBackBuffers = 0;
     532    pInfo->Reserved = 0;
     533        /* @todo: color keys */
     534//                        pInfo->DstOverlayCK;
     535//                        pInfo->DstBltCK;
     536//                        pInfo->SrcOverlayCK;
     537//                        pInfo->SrcBltCK;
     538    int rc = vboxVhwaHlpTranslateFormat(&pInfo->PixelFormat, pSurf->SurfDesc.format);
     539    AssertRC(rc);
     540    if (RT_SUCCESS(rc))
     541    {
     542        pInfo->flags |= VBOXVHWA_SD_PIXELFORMAT;
     543        pInfo->surfCaps = fSCaps;
     544        pInfo->flags |= VBOXVHWA_SD_CAPS;
     545        pInfo->offSurface = pSurf->offVram;
     546    }
     547
     548    return rc;
     549}
     550
     551int vboxVhwaHlpCheckApplySurfInfo(PVBOXWDDM_ALLOCATION pSurf, VBOXVHWA_SURFACEDESC *pInfo,
     552        uint32_t fFlags, bool bApplyHostHandle)
     553{
     554    int rc = VINF_SUCCESS;
     555    if (!(fFlags & VBOXVHWA_SD_PITCH))
     556    {
     557        /* should be set by host */
     558        Assert(pInfo->flags & VBOXVHWA_SD_PITCH);
     559        pSurf->SurfDesc.cbSize = pInfo->sizeX * pInfo->sizeY;
     560        Assert(pSurf->SurfDesc.cbSize);
     561        pSurf->SurfDesc.pitch = pInfo->pitch;
     562        Assert(pSurf->SurfDesc.pitch);
     563    }
     564    else
     565    {
     566        Assert(pSurf->SurfDesc.cbSize ==  pInfo->sizeX);
     567        Assert(pInfo->sizeY == 1);
     568        Assert(pInfo->pitch == pSurf->SurfDesc.pitch);
     569        if (pSurf->SurfDesc.cbSize !=  pInfo->sizeX
     570                || pInfo->sizeY != 1
     571                || pInfo->pitch != pSurf->SurfDesc.pitch)
     572        {
     573            rc = VERR_INVALID_PARAMETER;
     574        }
     575    }
     576
     577    if (bApplyHostHandle && RT_SUCCESS(rc))
     578    {
     579        pSurf->hHostHandle = pInfo->hSurf;
     580    }
     581
     582    return rc;
     583}
     584
    479585int vboxVhwaHlpCreateSurface(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf,
    480586        uint32_t fFlags, uint32_t cBackBuffers, uint32_t fSCaps,
     
    485591                VBOXVHWACMD_TYPE_SURF_CREATE, sizeof(VBOXVHWACMD_SURF_CREATE));
    486592    Assert(pCmd);
    487     if(pCmd)
     593    if (pCmd)
    488594    {
    489595        VBOXVHWACMD_SURF_CREATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_CREATE);
     
    492598        memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_CREATE));
    493599
    494         pBody->SurfInfo.height = pSurf->SurfDesc.height;
    495         pBody->SurfInfo.width = pSurf->SurfDesc.width;
    496         pBody->SurfInfo.flags |= VBOXVHWA_SD_HEIGHT | VBOXVHWA_SD_WIDTH;
    497         if (fFlags & VBOXVHWA_SD_PITCH)
    498         {
    499             pBody->SurfInfo.pitch = pSurf->SurfDesc.pitch;
    500             pBody->SurfInfo.flags |= VBOXVHWA_SD_PITCH;
    501             pBody->SurfInfo.sizeX = pSurf->SurfDesc.cbSize;
    502             pBody->SurfInfo.sizeY = 1;
    503         }
    504         if (cBackBuffers)
    505         {
    506             pBody->SurfInfo.cBackBuffers = cBackBuffers;
    507             pBody->SurfInfo.flags |= VBOXVHWA_SD_BACKBUFFERCOUNT;
    508         }
    509         else
    510             pBody->SurfInfo.cBackBuffers = 0;
    511         pBody->SurfInfo.Reserved = 0;
    512         /* @todo: color keys */
    513 //                        pBody->SurfInfo.DstOverlayCK;
    514 //                        pBody->SurfInfo.DstBltCK;
    515 //                        pBody->SurfInfo.SrcOverlayCK;
    516 //                        pBody->SurfInfo.SrcBltCK;
    517         rc = vboxVhwaHlpTranslateFormat(&pBody->SurfInfo.PixelFormat, pSurf->SurfDesc.format);
     600        rc = vboxVhwaHlpPopulateSurInfo(&pBody->SurfInfo, pSurf,
     601                fFlags, cBackBuffers, fSCaps,
     602                VidPnSourceId);
    518603        AssertRC(rc);
    519604        if (RT_SUCCESS(rc))
    520605        {
    521             pBody->SurfInfo.flags |= VBOXVHWA_SD_PIXELFORMAT;
    522             pBody->SurfInfo.surfCaps = fSCaps;
    523             pBody->SurfInfo.flags |= VBOXVHWA_SD_CAPS;
    524             pBody->SurfInfo.offSurface = pSurf->offVram;
    525 
    526606            vboxVhwaCommandSubmit(pDevExt, pCmd);
    527607            Assert(pCmd->rc == VINF_SUCCESS);
    528608            if(pCmd->rc == VINF_SUCCESS)
    529609            {
    530                 if (!(fFlags & VBOXVHWA_SD_PITCH))
    531                 {
    532                     /* should be set by host */
    533                     Assert(pBody->SurfInfo.flags & VBOXVHWA_SD_PITCH);
    534                     pSurf->SurfDesc.cbSize = pBody->SurfInfo.sizeX * pBody->SurfInfo.sizeY;
    535                     Assert(pSurf->SurfDesc.cbSize);
    536                     pSurf->SurfDesc.pitch = pBody->SurfInfo.pitch;
    537                     Assert(pSurf->SurfDesc.pitch);
    538                 }
    539                 else
    540                 {
    541                     Assert(pSurf->SurfDesc.cbSize ==  pBody->SurfInfo.sizeX);
    542                     Assert(pBody->SurfInfo.sizeY == 1);
    543                     Assert(pBody->SurfInfo.pitch == pSurf->SurfDesc.pitch);
    544                     if (pSurf->SurfDesc.cbSize !=  pBody->SurfInfo.sizeX
    545                             || pBody->SurfInfo.sizeY != 1
    546                             || pBody->SurfInfo.pitch != pSurf->SurfDesc.pitch)
    547                     {
    548                         rc = VERR_INVALID_PARAMETER;
    549                     }
    550                 }
    551 
    552                 if (RT_SUCCESS(rc))
    553                 {
    554                         pSurf->hHostHandle = pBody->SurfInfo.hSurf;
    555                 }
     610                rc = vboxVhwaHlpCheckApplySurfInfo(pSurf, &pBody->SurfInfo, fFlags, true);
    556611            }
    557612            else
     
    565620}
    566621
    567 int vboxVhwaHlpCreatePriary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
    568 {
    569     Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED));
    570     if (!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED))
    571         return VERR_NOT_SUPPORTED;
    572 
     622int vboxVhwaHlpGetSurfInfoForSource(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     623{
     624    /* the first thing we need is to post create primary */
     625    VBOXVHWACMD* pCmd = vboxVhwaCommandCreate(pDevExt, VidPnSourceId,
     626            VBOXVHWACMD_TYPE_SURF_GETINFO, sizeof(VBOXVHWACMD_SURF_GETINFO));
     627    Assert(pCmd);
     628    if (pCmd)
     629    {
     630        VBOXVHWACMD_SURF_GETINFO * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_GETINFO);
     631        int rc = VINF_SUCCESS;
     632
     633        memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_GETINFO));
     634
     635        rc = vboxVhwaHlpPopulateSurInfo(&pBody->SurfInfo, pSurf,
     636                0, 0, VBOXVHWA_SCAPS_OVERLAY | VBOXVHWA_SCAPS_VIDEOMEMORY | VBOXVHWA_SCAPS_LOCALVIDMEM | VBOXVHWA_SCAPS_COMPLEX,
     637                VidPnSourceId);
     638        AssertRC(rc);
     639        if (RT_SUCCESS(rc))
     640        {
     641            vboxVhwaCommandSubmit(pDevExt, pCmd);
     642            Assert(pCmd->rc == VINF_SUCCESS);
     643            if(pCmd->rc == VINF_SUCCESS)
     644            {
     645                rc = vboxVhwaHlpCheckApplySurfInfo(pSurf, &pBody->SurfInfo, 0, true);
     646            }
     647            else
     648                rc = pCmd->rc;
     649        }
     650        vboxVhwaCommandFree(pDevExt, pCmd);
     651        return rc;
     652    }
     653
     654    return VERR_OUT_OF_RESOURCES;
     655}
     656
     657int vboxVhwaHlpGetSurfInfo(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf)
     658{
     659    for (uint32_t i = 0; i < pDevExt->cSources; ++i)
     660    {
     661        PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[i];
     662        if (pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)
     663        {
     664            int rc = vboxVhwaHlpGetSurfInfoForSource(pDevExt, pSurf, i);
     665            AssertRC(rc);
     666            return rc;
     667        }
     668    }
     669    AssertBreakpoint();
     670    return VERR_NOT_SUPPORTED;
     671}
     672
     673int vboxVhwaHlpDestroyPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     674{
    573675#ifdef VBOXWDDM_RENDER_FROM_SHADOW
    574676    PVBOXWDDM_ALLOCATION pFbSurf = pSource->pShadowAllocation;
     
    577679#endif
    578680
    579     Assert(!pSource->Vhwa.cOverlaysCreated);
    580     if (pSource->Vhwa.cOverlaysCreated)
    581     {
    582         Assert(pFbSurf->hHostHandle);
    583         if (pFbSurf->hHostHandle)
    584             return VINF_ALREADY_INITIALIZED;
     681    int rc = vboxVhwaHlpDestroySurface(pDevExt, pFbSurf, VidPnSourceId);
     682    AssertRC(rc);
     683    return rc;
     684}
     685
     686int vboxVhwaHlpCreatePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     687{
     688#ifdef VBOXWDDM_RENDER_FROM_SHADOW
     689    PVBOXWDDM_ALLOCATION pFbSurf = pSource->pShadowAllocation;
     690#else
     691    PVBOXWDDM_ALLOCATION pFbSurf = pSource->pPrimaryAllocation;
     692#endif
     693    Assert(pSource->Vhwa.cOverlaysCreated == 1);
     694    Assert(pFbSurf->hHostHandle == VBOXVHWA_SURFHANDLE_INVALID);
     695    if (pFbSurf->hHostHandle != VBOXVHWA_SURFHANDLE_INVALID)
    585696        return VERR_INVALID_STATE;
    586     }
    587697
    588698    int rc = vboxVhwaHlpCreateSurface(pDevExt, pFbSurf,
     
    593703}
    594704
    595 int vboxVhwaHlpCreateOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, uint32_t cBackBuffers, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     705int vboxVhwaHlpCheckInit(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
    596706{
    597707    Assert(VidPnSourceId < pDevExt->cSources);
     
    601711    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
    602712
    603     int rc = vboxVhwaHlpCreatePriary(pDevExt, pSource, VidPnSourceId);
     713    Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED));
     714    if (!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED))
     715        return VERR_NOT_SUPPORTED;
     716
     717    int rc = VINF_SUCCESS;
     718    /* @todo: need a better synch */
     719    uint32_t cNew = ASMAtomicIncU32(&pSource->Vhwa.cOverlaysCreated);
     720    if (cNew == 1)
     721    {
     722        rc = vboxVhwaHlpCreatePrimary(pDevExt, pSource, VidPnSourceId);
     723        AssertRC(rc);
     724    }
     725    else
     726    {
     727#ifdef VBOXWDDM_RENDER_FROM_SHADOW
     728        PVBOXWDDM_ALLOCATION pFbSurf = pSource->pShadowAllocation;
     729#else
     730        PVBOXWDDM_ALLOCATION pFbSurf = pSource->pPrimaryAllocation;
     731#endif
     732        Assert(pFbSurf->hHostHandle);
     733        if (pFbSurf->hHostHandle)
     734            rc = VINF_ALREADY_INITIALIZED;
     735        else
     736            rc = VERR_INVALID_STATE;
     737    }
     738
     739    if (RT_FAILURE(rc))
     740        ASMAtomicDecU32(&pSource->Vhwa.cOverlaysCreated);
     741
     742    return rc;
     743}
     744
     745int vboxVhwaHlpCheckTerm(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     746{
     747    Assert(VidPnSourceId < pDevExt->cSources);
     748    if (VidPnSourceId >= pDevExt->cSources)
     749        return VERR_INVALID_PARAMETER;
     750
     751    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
     752
     753    Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED));
     754
     755    /* @todo: need a better synch */
     756    uint32_t cNew = ASMAtomicDecU32(&pSource->Vhwa.cOverlaysCreated);
     757    int rc = VINF_SUCCESS;
     758    if (!cNew)
     759    {
     760        rc = vboxVhwaHlpDestroyPrimary(pDevExt, pSource, VidPnSourceId);
     761        AssertRC(rc);
     762    }
     763    else
     764    {
     765        Assert(cNew < UINT32_MAX / 2);
     766    }
     767
     768    return rc;
     769}
     770
     771int vboxVhwaHlpCreateOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, uint32_t cBackBuffers, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     772{
     773    int rc = vboxVhwaHlpCheckInit(pDevExt, VidPnSourceId);
    604774    AssertRC(rc);
    605775    if (RT_SUCCESS(rc))
     
    609779                    VidPnSourceId);
    610780        AssertRC(rc);
    611         if (RT_SUCCESS(rc))
    612             ++pSource->Vhwa.cOverlaysCreated;
    613     }
    614 
    615     return rc;
    616 }
     781    }
     782
     783    return rc;
     784}
     785
     786int vboxVhwaHlpDestroyOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     787{
     788    int rc = vboxVhwaHlpDestroySurface(pDevExt, pSurf, VidPnSourceId);
     789    AssertRC(rc);
     790    if (RT_SUCCESS(rc))
     791    {
     792        rc = vboxVhwaHlpCheckTerm(pDevExt, VidPnSourceId);
     793        AssertRC(rc);
     794    }
     795
     796    return rc;
     797}
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.h

    r29895 r29922  
    5555
    5656int vboxVhwaHlpCreateOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, uint32_t cBackBuffers, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId);
     57int vboxVhwaHlpDestroyOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId);
     58int vboxVhwaHlpGetSurfInfo(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf);
    5759
    5860#endif /* #ifndef ___VBoxVideoVhwa_h___ */
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r29895 r29922  
    13721372    return Status;
    13731373}
     1374
     1375PVBOXWDDM_ALLOCATION vboxWddmAllocationCreateFromResource(PVBOXWDDM_RESOURCE pResource, uint32_t iIndex)
     1376{
     1377    PVBOXWDDM_ALLOCATION pAllocation = NULL;
     1378    if (pResource)
     1379    {
     1380        Assert(iIndex < pResource->cAllocations);
     1381        if (iIndex < pResource->cAllocations)
     1382        {
     1383            pAllocation = &pResource->aAllocations[iIndex];
     1384            memset(pAllocation, 0, sizeof (VBOXWDDM_ALLOCATION));
     1385        }
     1386    }
     1387    else
     1388        pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_ALLOCATION));
     1389
     1390    if (pAllocation)
     1391    {
     1392        if (pResource)
     1393        {
     1394            pAllocation->pResource = pResource;
     1395            pAllocation->iIndex = iIndex;
     1396        }
     1397    }
     1398
     1399    return pAllocation;
     1400}
     1401
     1402void vboxWddmAllocationDeleteFromResource(PVBOXWDDM_RESOURCE pResource, PVBOXWDDM_ALLOCATION pAllocation)
     1403{
     1404    Assert(pAllocation->pResource == pResource);
     1405    if (pResource)
     1406    {
     1407        Assert(&pResource->aAllocations[pAllocation->iIndex] == pAllocation);
     1408    }
     1409    else
     1410    {
     1411        vboxWddmMemFree(pAllocation);
     1412    }
     1413}
     1414
    13741415NTSTATUS vboxWddmDestroyAllocation(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
    13751416{
     
    13991440        }
    14001441#endif
     1442//#ifdef VBOX_WITH_VIDEOHWACCEL
     1443//        case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC:
     1444//        {
     1445//            if (pAllocation->fRcFlags.Overlay)
     1446//            {
     1447//                vboxVhwaHlpDestroyOverlay(pDevExt, pAllocation);
     1448//            }
     1449//            break;
     1450//        }
     1451//#endif
    14011452        default:
    14021453            break;
    14031454    }
    1404     vboxWddmMemFree(pAllocation);
     1455
     1456    vboxWddmAllocationDeleteFromResource(pAllocation->pResource, pAllocation);
     1457
    14051458    return STATUS_SUCCESS;
    14061459}
    14071460
    1408 NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_RCINFO pRcInfo, DXGK_ALLOCATIONINFO* pAllocationInfo)
     1461NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_RESOURCE pResource, uint32_t iIndex, DXGK_ALLOCATIONINFO* pAllocationInfo)
    14091462{
    14101463    PAGED_CODE();
     
    14161469    {
    14171470        PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pAllocationInfo->pPrivateDriverData;
    1418         PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_ALLOCATION));
     1471        PVBOXWDDM_ALLOCATION pAllocation = vboxWddmAllocationCreateFromResource(pResource, iIndex);
    14191472        Assert(pAllocation);
    14201473        if (pAllocation)
     
    14541507                    break;
    14551508                case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC:
     1509                    Assert(pResource);
     1510                    if (pResource)
     1511                    {
     1512                        Assert(pResource->cAllocations);
     1513                        if (pResource->cAllocations)
     1514                        {
    14561515#ifdef VBOX_WITH_VIDEOHWACCEL
    1457                     Assert(pRcInfo);
    1458                     if (pRcInfo)
    1459                     {
    1460                         Assert(pRcInfo->cAllocInfos);
    1461                         if (pRcInfo->cAllocInfos)
    1462                         {
    1463                             if (pRcInfo->RcDesc.fFlags.Overlay)
     1516                            if (pResource->RcDesc.fFlags.Overlay)
    14641517                            {
    1465                                 int rc = vboxVhwaHlpCreateOverlay(pDevExt, pAllocation, pRcInfo->cAllocInfos - 1, pRcInfo->RcDesc.VidPnSourceId);
     1518                                /* actually we can not "properly" issue create overlay commands to the host here
     1519                                 * because we do not know source VidPn id here, i.e.
     1520                                 * the primary which is supposed to be overlayed,
     1521                                 * however we need to get some info like pitch & size from the host here */
     1522                                int rc = vboxVhwaHlpGetSurfInfo(pDevExt, pAllocation);
    14661523                                AssertRC(rc);
    1467                                 if (RT_FAILURE(rc))
     1524                                if (RT_SUCCESS(rc))
     1525                                {
     1526                                    pAllocInfo->SurfDesc = pAllocation->SurfDesc;
     1527                                }
     1528                                else
    14681529                                    Status = STATUS_UNSUCCESSFUL;
    14691530                            }
     1531#endif
    14701532                        }
    14711533                        else
    14721534                            Status = STATUS_INVALID_PARAMETER;
    14731535                    }
    1474 #endif
    14751536                    /* do not break to set CPU visibility flag */
    14761537                case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE:
     
    14871548
    14881549            if (Status != STATUS_SUCCESS)
    1489                 vboxWddmMemFree(pAllocation);
     1550                vboxWddmAllocationDeleteFromResource(pResource, pAllocation);
    14901551        }
    14911552        else
     
    15181579    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
    15191580    NTSTATUS Status = STATUS_SUCCESS;
    1520     PVBOXWDDM_RCINFO pRcInfo = NULL;
     1581    PVBOXWDDM_RESOURCE pResource = NULL;
    15211582
    15221583    if (pCreateAllocation->PrivateDriverDataSize)
     
    15261587        if (pCreateAllocation->PrivateDriverDataSize >= sizeof (VBOXWDDM_RCINFO))
    15271588        {
    1528             pRcInfo = (PVBOXWDDM_RCINFO)pCreateAllocation->pPrivateDriverData;
    1529             Assert(pRcInfo->RcDesc.VidPnSourceId < pDevExt->cSources);
     1589            PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)pCreateAllocation->pPrivateDriverData;
     1590//            Assert(pRcInfo->RcDesc.VidPnSourceId < pDevExt->cSources);
    15301591            Assert(pRcInfo->cAllocInfos == pCreateAllocation->NumAllocations);
     1592            pResource = (PVBOXWDDM_RESOURCE)vboxWddmMemAllocZero(RT_OFFSETOF(VBOXWDDM_RESOURCE, aAllocations[pRcInfo->cAllocInfos]));
     1593            Assert(pResource);
     1594            if (pResource)
     1595            {
     1596                pResource->cAllocations = pRcInfo->cAllocInfos;
     1597                pResource->fFlags = pRcInfo->fFlags;
     1598                pResource->RcDesc = pRcInfo->RcDesc;
     1599            }
     1600            else
     1601                Status = STATUS_NO_MEMORY;
    15311602        }
    15321603        else
     
    15401611        for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
    15411612        {
    1542             Status = vboxWddmCreateAllocation(pDevExt, pRcInfo, &pCreateAllocation->pAllocationInfo[i]);
     1613            Status = vboxWddmCreateAllocation(pDevExt, pResource, i, &pCreateAllocation->pAllocationInfo[i]);
    15431614            Assert(Status == STATUS_SUCCESS);
    15441615            if (Status != STATUS_SUCCESS)
     
    15521623            }
    15531624        }
     1625
     1626        pCreateAllocation->hResource = pResource;
     1627        if (pResource && Status != STATUS_SUCCESS)
     1628            vboxWddmMemFree(pResource);
    15541629    }
    15551630    dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
     
    15731648    NTSTATUS Status = STATUS_SUCCESS;
    15741649
     1650    PVBOXWDDM_RESOURCE pRc = (PVBOXWDDM_RESOURCE)pDestroyAllocation->hResource;
     1651
     1652    if (pRc)
     1653    {
     1654        Assert(pRc->cAllocations == pDestroyAllocation->NumAllocations);
     1655    }
     1656
    15751657    for (UINT i = 0; i < pDestroyAllocation->NumAllocations; ++i)
    15761658    {
    1577         vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pDestroyAllocation->pAllocationList[i]);
     1659        PVBOXWDDM_ALLOCATION pAlloc = (PVBOXWDDM_ALLOCATION)pDestroyAllocation->pAllocationList[i];
     1660        Assert(pAlloc->pResource == pRc);
     1661        vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, pAlloc);
     1662    }
     1663
     1664    if (pRc)
     1665    {
     1666        vboxWddmMemFree(pRc);
    15781667    }
    15791668
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h

    r29895 r29922  
    5252{
    5353    VBOXWDDM_ALLOC_TYPE enmType;
     54//    D3DDDI_RESOURCEFLAGS fRcFlags;
    5455    UINT SegmentId;
    5556    VBOXVIDEOOFFSET offVram;
     
    6061    BOOLEAN bAssigned;
    6162    VBOXWDDM_SURFACE_DESC SurfDesc;
     63    struct VBOXWDDM_RESOURCE *pResource;
     64    uint32_t iIndex;
    6265} VBOXWDDM_ALLOCATION, *PVBOXWDDM_ALLOCATION;
    6366
    6467typedef struct VBOXWDDM_RESOURCE
    6568{
    66     VBOXWDDM_ALLOC_TYPE enmType;
    67     UINT SegmentId;
    68     VBOXVIDEOOFFSET offVram;
    69     D3DDDI_RATIONAL RefreshRate;
    70     D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
    71     BOOLEAN bVisible;
    72     BOOLEAN bAssigned;
    73     VBOXWDDM_SURFACE_DESC SurfDesc;
     69    uint32_t fFlags;
     70    VBOXWDDM_RC_DESC RcDesc;
    7471    uint32_t cAllocations;
     72    VBOXWDDM_ALLOCATION aAllocations[1];
    7573} VBOXWDDM_RESOURCE, *PVBOXWDDM_RESOURCE;
    7674
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