VirtualBox

Ignore:
Timestamp:
May 31, 2010 10:52:52 AM (15 years ago)
Author:
vboxsync
Message:

wddm/2d: overlay creation

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

Legend:

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

    r29883 r29895  
    5050    UINT depth;
    5151    UINT slicePitch;
     52    UINT cbSize;
    5253    D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
    5354    D3DDDI_RATIONAL RefreshRate;
     
    159160}
    160161
     162DECLINLINE(uint32_t) vboxWddmFormatToFourcc(D3DDDIFORMAT format)
     163{
     164    uint32_t uFormat = (uint32_t)format;
     165    /* assume that in case both four bytes are non-zero, this is a fourcc */
     166    if ((format & 0xff000000)
     167            && (format & 0x00ff0000)
     168            && (format & 0x0000ff00)
     169            && (format & 0x000000ff)
     170            )
     171        return uFormat;
     172    return 0;
     173}
     174
    161175#define VBOXWDDM_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1))
    162176
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.cpp

    r29798 r29895  
    413413    }
    414414}
     415
     416int vboxVhwaHlpTranslateFormat(VBOXVHWA_PIXELFORMAT *pFormat, D3DDDIFORMAT enmFormat)
     417{
     418    pFormat->Reserved = 0;
     419    switch (enmFormat)
     420    {
     421        case D3DDDIFMT_A8R8G8B8:
     422        case D3DDDIFMT_X8R8G8B8:
     423            pFormat->flags = VBOXVHWA_PF_RGB;
     424            pFormat->c.rgbBitCount = 32;
     425            pFormat->m1.rgbRBitMask = 0xff0000;
     426            pFormat->m2.rgbGBitMask = 0xff00;
     427            pFormat->m3.rgbBBitMask = 0xff;
     428            /* always zero for now */
     429            pFormat->m4.rgbABitMask = 0;
     430            return VINF_SUCCESS;
     431        case D3DDDIFMT_R8G8B8:
     432            pFormat->flags = VBOXVHWA_PF_RGB;
     433            pFormat->c.rgbBitCount = 24;
     434            pFormat->m1.rgbRBitMask = 0xff0000;
     435            pFormat->m2.rgbGBitMask = 0xff00;
     436            pFormat->m3.rgbBBitMask = 0xff;
     437            /* always zero for now */
     438            pFormat->m4.rgbABitMask = 0;
     439            return VINF_SUCCESS;
     440        case D3DDDIFMT_R5G6B5:
     441            pFormat->flags = VBOXVHWA_PF_RGB;
     442            pFormat->c.rgbBitCount = 16;
     443            pFormat->m1.rgbRBitMask = 0xf800;
     444            pFormat->m2.rgbGBitMask = 0x7e0;
     445            pFormat->m3.rgbBBitMask = 0x1f;
     446            /* always zero for now */
     447            pFormat->m4.rgbABitMask = 0;
     448            return VINF_SUCCESS;
     449        case D3DDDIFMT_P8:
     450        case D3DDDIFMT_A8:
     451        case D3DDDIFMT_X1R5G5B5:
     452        case D3DDDIFMT_A1R5G5B5:
     453        case D3DDDIFMT_A4R4G4B4:
     454        case D3DDDIFMT_R3G3B2:
     455        case D3DDDIFMT_A8R3G3B2:
     456        case D3DDDIFMT_X4R4G4B4:
     457        case D3DDDIFMT_A2B10G10R10:
     458        case D3DDDIFMT_A8B8G8R8:
     459        case D3DDDIFMT_X8B8G8R8:
     460        case D3DDDIFMT_G16R16:
     461        case D3DDDIFMT_A2R10G10B10:
     462        case D3DDDIFMT_A16B16G16R16:
     463        case D3DDDIFMT_A8P8:
     464        default:
     465        {
     466            uint32_t fourcc = vboxWddmFormatToFourcc(enmFormat);
     467            Assert(fourcc);
     468            if (fourcc)
     469            {
     470                pFormat->flags = VBOXVHWA_PF_FOURCC;
     471                pFormat->fourCC = fourcc;
     472                return VINF_SUCCESS;
     473            }
     474            return VERR_NOT_SUPPORTED;
     475        }
     476    }
     477}
     478
     479int vboxVhwaHlpCreateSurface(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf,
     480        uint32_t fFlags, uint32_t cBackBuffers, uint32_t fSCaps,
     481        D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     482{
     483    /* the first thing we need is to post create primary */
     484    VBOXVHWACMD* pCmd = vboxVhwaCommandCreate(pDevExt, VidPnSourceId,
     485                VBOXVHWACMD_TYPE_SURF_CREATE, sizeof(VBOXVHWACMD_SURF_CREATE));
     486    Assert(pCmd);
     487    if(pCmd)
     488    {
     489        VBOXVHWACMD_SURF_CREATE * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_CREATE);
     490        int rc = VINF_SUCCESS;
     491
     492        memset(pBody, 0, sizeof(VBOXVHWACMD_SURF_CREATE));
     493
     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);
     518        AssertRC(rc);
     519        if (RT_SUCCESS(rc))
     520        {
     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
     526            vboxVhwaCommandSubmit(pDevExt, pCmd);
     527            Assert(pCmd->rc == VINF_SUCCESS);
     528            if(pCmd->rc == VINF_SUCCESS)
     529            {
     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                }
     556            }
     557            else
     558                rc = pCmd->rc;
     559        }
     560        vboxVhwaCommandFree(pDevExt, pCmd);
     561        return rc;
     562    }
     563
     564    return VERR_OUT_OF_RESOURCES;
     565}
     566
     567int 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
     573#ifdef VBOXWDDM_RENDER_FROM_SHADOW
     574    PVBOXWDDM_ALLOCATION pFbSurf = pSource->pShadowAllocation;
     575#else
     576    PVBOXWDDM_ALLOCATION pFbSurf = pSource->pPrimaryAllocation;
     577#endif
     578
     579    Assert(!pSource->Vhwa.cOverlaysCreated);
     580    if (pSource->Vhwa.cOverlaysCreated)
     581    {
     582        Assert(pFbSurf->hHostHandle);
     583        if (pFbSurf->hHostHandle)
     584            return VINF_ALREADY_INITIALIZED;
     585        return VERR_INVALID_STATE;
     586    }
     587
     588    int rc = vboxVhwaHlpCreateSurface(pDevExt, pFbSurf,
     589            VBOXVHWA_SD_PITCH, 0, VBOXVHWA_SCAPS_PRIMARYSURFACE | VBOXVHWA_SCAPS_VIDEOMEMORY | VBOXVHWA_SCAPS_LOCALVIDMEM,
     590            VidPnSourceId);
     591    AssertRC(rc);
     592    return rc;
     593}
     594
     595int vboxVhwaHlpCreateOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, uint32_t cBackBuffers, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     596{
     597    Assert(VidPnSourceId < pDevExt->cSources);
     598    if (VidPnSourceId >= pDevExt->cSources)
     599        return VERR_INVALID_PARAMETER;
     600
     601    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
     602
     603    int rc = vboxVhwaHlpCreatePriary(pDevExt, pSource, VidPnSourceId);
     604    AssertRC(rc);
     605    if (RT_SUCCESS(rc))
     606    {
     607        rc = vboxVhwaHlpCreateSurface(pDevExt, pSurf,
     608                    0, cBackBuffers, VBOXVHWA_SCAPS_OVERLAY | VBOXVHWA_SCAPS_VIDEOMEMORY | VBOXVHWA_SCAPS_LOCALVIDMEM | VBOXVHWA_SCAPS_COMPLEX,
     609                    VidPnSourceId);
     610        AssertRC(rc);
     611        if (RT_SUCCESS(rc))
     612            ++pSource->Vhwa.cOverlaysCreated;
     613    }
     614
     615    return rc;
     616}
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVhwa.h

    r29798 r29895  
    5454void vboxVHWAFree(PDEVICE_EXTENSION pDevExt);
    5555
     56int vboxVhwaHlpCreateOverlay(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pSurf, uint32_t cBackBuffers, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId);
     57
    5658#endif /* #ifndef ___VBoxVideoVhwa_h___ */
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r29883 r29895  
    14061406}
    14071407
    1408 NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, DXGK_ALLOCATIONINFO* pAllocationInfo)
     1408NTSTATUS vboxWddmCreateAllocation(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_RCINFO pRcInfo, DXGK_ALLOCATIONINFO* pAllocationInfo)
    14091409{
    14101410    PAGED_CODE();
     
    14291429            pAllocationInfo->PrivateDriverDataSize = 0;
    14301430            pAllocationInfo->Alignment = 0;
    1431             pAllocationInfo->Size = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height;
     1431            pAllocationInfo->Size = pAllocInfo->SurfDesc.cbSize;
    14321432            pAllocationInfo->PitchAlignedSize = 0;
    14331433            pAllocationInfo->HintedBank.Value = 0;
     
    14531453#endif
    14541454                    break;
     1455                case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC:
     1456#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)
     1464                            {
     1465                                int rc = vboxVhwaHlpCreateOverlay(pDevExt, pAllocation, pRcInfo->cAllocInfos - 1, pRcInfo->RcDesc.VidPnSourceId);
     1466                                AssertRC(rc);
     1467                                if (RT_FAILURE(rc))
     1468                                    Status = STATUS_UNSUCCESSFUL;
     1469                            }
     1470                        }
     1471                        else
     1472                            Status = STATUS_INVALID_PARAMETER;
     1473                    }
     1474#endif
     1475                    /* do not break to set CPU visibility flag */
    14551476                case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE:
    14561477                case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE:
    1457                 case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC:
    14581478                    pAllocationInfo->Flags.Value = 0;
    14591479                    pAllocationInfo->Flags.CpuVisible = 1;
     
    14961516    vboxVDbgBreakFv();
    14971517
     1518    PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)hAdapter;
    14981519    NTSTATUS Status = STATUS_SUCCESS;
     1520    PVBOXWDDM_RCINFO pRcInfo = NULL;
    14991521
    15001522    if (pCreateAllocation->PrivateDriverDataSize)
    15011523    {
     1524        Assert(pCreateAllocation->PrivateDriverDataSize == sizeof (VBOXWDDM_RCINFO));
     1525        Assert(pCreateAllocation->pPrivateDriverData);
     1526        if (pCreateAllocation->PrivateDriverDataSize >= sizeof (VBOXWDDM_RCINFO))
     1527        {
     1528            pRcInfo = (PVBOXWDDM_RCINFO)pCreateAllocation->pPrivateDriverData;
     1529            Assert(pRcInfo->RcDesc.VidPnSourceId < pDevExt->cSources);
     1530            Assert(pRcInfo->cAllocInfos == pCreateAllocation->NumAllocations);
     1531        }
     1532        else
     1533            Status = STATUS_INVALID_PARAMETER;
    15021534        /* @todo: Implement Resource Data Handling */
    15031535        drprintf((__FUNCTION__ ": WARNING: Implement Resource Data Handling\n"));
    15041536    }
    15051537
    1506     for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
    1507     {
    1508         Status = vboxWddmCreateAllocation((PDEVICE_EXTENSION)hAdapter, &pCreateAllocation->pAllocationInfo[i]);
    1509         Assert(Status == STATUS_SUCCESS);
    1510         if (Status != STATUS_SUCCESS)
    1511         {
    1512             drprintf((__FUNCTION__ ": ERROR: vboxWddmCreateAllocation error (0x%x)\n", Status));
    1513             /* note: i-th allocation is expected to be cleared in a fail handling code above */
    1514             for (UINT j = 0; j < i; ++j)
    1515             {
    1516                 vboxWddmDestroyAllocation((PDEVICE_EXTENSION)hAdapter, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
    1517             }
    1518         }
    1519     }
    1520 
     1538    if (Status == STATUS_SUCCESS)
     1539    {
     1540        for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
     1541        {
     1542            Status = vboxWddmCreateAllocation(pDevExt, pRcInfo, &pCreateAllocation->pAllocationInfo[i]);
     1543            Assert(Status == STATUS_SUCCESS);
     1544            if (Status != STATUS_SUCCESS)
     1545            {
     1546                drprintf((__FUNCTION__ ": ERROR: vboxWddmCreateAllocation error (0x%x)\n", Status));
     1547                /* note: i-th allocation is expected to be cleared in a fail handling code above */
     1548                for (UINT j = 0; j < i; ++j)
     1549                {
     1550                    vboxWddmDestroyAllocation(pDevExt, (PVBOXWDDM_ALLOCATION)pCreateAllocation->pAllocationInfo[j].hAllocation);
     1551                }
     1552            }
     1553        }
     1554    }
    15211555    dfprintf(("<== "__FUNCTION__ ", status(0x%x), context(0x%x)\n", Status, hAdapter));
    15221556
     
    16101644                pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format);
    16111645                pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->SurfDesc.bpp);
     1646                pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height;
    16121647                pAllocInfo->SurfDesc.depth = 0;
    16131648                pAllocInfo->SurfDesc.slicePitch = 0;
     
    16411676                    pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format);
    16421677                    pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->SurfDesc.bpp);
     1678                    pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height;
    16431679                    pAllocInfo->SurfDesc.depth = 0;
    16441680                    pAllocInfo->SurfDesc.slicePitch = 0;
     
    16721708                pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format);
    16731709                pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->SurfDesc.bpp);
     1710                pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height;
    16741711                pAllocInfo->SurfDesc.depth = 0;
    16751712                pAllocInfo->SurfDesc.slicePitch = 0;
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.h

    r29883 r29895  
    5454    UINT SegmentId;
    5555    VBOXVIDEOOFFSET offVram;
     56#ifdef VBOX_WITH_VIDEOHWACCEL
     57    VBOXVHWA_SURFHANDLE hHostHandle;
     58#endif
    5659    BOOLEAN bVisible;
    5760    BOOLEAN bAssigned;
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