VirtualBox

Ignore:
Timestamp:
May 30, 2010 7:27:02 PM (15 years ago)
Author:
vboxsync
Message:

wddm: open,create,destroy,lock,unlock resource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp

    r29798 r29883  
    7676}
    7777
    78 NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     78NTSTATUS vboxWddmGhDisplayPostInfoScreen (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
    7979{
    8080    VBOXVIDEOOFFSET offVram = pAllocation->offVram;
     
    8383//        return STATUS_INVALID_PARAMETER;
    8484
    85 //    PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    8685    /* Issue the screen info command. */
    8786    void *p = vboxHGSMIBufferAlloc (pDevExt,
     
    9493        VBVAINFOSCREEN *pScreen = (VBVAINFOSCREEN *)p;
    9594
    96         pScreen->u32ViewIndex    = /*pPrimaryInfo->*/VidPnSourceId;
     95        pScreen->u32ViewIndex    = pAllocation->SurfDesc.VidPnSourceId;
    9796        pScreen->i32OriginX      = 0;
    9897        pScreen->i32OriginY      = 0;
    9998        pScreen->u32StartOffset  = 0; //(uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */
    100         pScreen->u32LineSize     = pAllocation->u.SurfInfo.pitch;
    101         pScreen->u32Width        = pAllocation->u.SurfInfo.width;
    102         pScreen->u32Height       = pAllocation->u.SurfInfo.height;
    103         pScreen->u16BitsPerPixel = (uint16_t)pAllocation->u.SurfInfo.bpp;
     99        pScreen->u32LineSize     = pAllocation->SurfDesc.pitch;
     100        pScreen->u32Width        = pAllocation->SurfDesc.width;
     101        pScreen->u32Height       = pAllocation->SurfDesc.height;
     102        pScreen->u16BitsPerPixel = (uint16_t)pAllocation->SurfDesc.bpp;
    104103        pScreen->u16Flags        = VBVA_SCREEN_F_ACTIVE;
    105104
     
    112111}
    113112
    114 NTSTATUS vboxWddmGhDisplayPostInfoView (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     113NTSTATUS vboxWddmGhDisplayPostInfoView(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
    115114{
    116115    VBOXVIDEOOFFSET offVram = pAllocation->offVram;
     
    119118        return STATUS_INVALID_PARAMETER;
    120119
    121 //    PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    122120    /* Issue the screen info command. */
    123121    void *p = vboxHGSMIBufferAlloc (pDevExt,
     
    130128        VBVAINFOVIEW *pView = (VBVAINFOVIEW *)p;
    131129
    132         pView->u32ViewIndex     = /*pPrimaryInfo->*/VidPnSourceId;
     130        pView->u32ViewIndex     = pAllocation->SurfDesc.VidPnSourceId;
    133131        pView->u32ViewOffset    = (uint32_t)offVram; /* we pretend the view is located at the start of each framebuffer */
    134132        pView->u32ViewSize      = vboxWddmVramCpuVisibleSegmentSize(pDevExt)/pDevExt->cSources;
     
    144142}
    145143
    146 NTSTATUS vboxWddmGhDisplaySetMode (PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
     144NTSTATUS vboxWddmGhDisplaySetMode(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
    147145{
    148146//    PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    149     if (/*pPrimaryInfo->*/VidPnSourceId)
     147    if (/*pPrimaryInfo->*/pAllocation->SurfDesc.VidPnSourceId)
    150148        return STATUS_SUCCESS;
    151149
    152     if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation->u.SurfInfo.width,
    153             pAllocation->u.SurfInfo.height, pAllocation->u.SurfInfo.bpp,
     150    if (VBoxVideoSetCurrentModePerform(pDevExt, pAllocation->SurfDesc.width,
     151            pAllocation->SurfDesc.height, pAllocation->SurfDesc.bpp,
    154152            (ULONG)pAllocation->offVram))
    155153        return STATUS_SUCCESS;
     
    166164#ifndef VBOXWDDM_RENDER_FROM_SHADOW
    167165    PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation;
    168     PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    169166#else
    170167    PVBOXWDDM_ALLOCATION pAllocation = pSource->pShadowAllocation;
    171     PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pSource->pPrimaryAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    172168#endif
    173169    VBOXVIDEOOFFSET offVram = vboxWddmValidatePrimary(pAllocation);
     
    179175     * Set the current mode into the hardware.
    180176     */
    181     NTSTATUS Status = vboxWddmGhDisplaySetMode (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);
     177    NTSTATUS Status = vboxWddmGhDisplaySetMode(pDevExt, pAllocation);
    182178    Assert(Status == STATUS_SUCCESS);
    183179    if (Status == STATUS_SUCCESS)
    184180    {
    185         Status = vboxWddmGhDisplayPostInfoView (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);
     181        Status = vboxWddmGhDisplayPostInfoView(pDevExt, pAllocation);
    186182        Assert(Status == STATUS_SUCCESS);
    187183        if (Status == STATUS_SUCCESS)
    188184        {
    189             Status = vboxWddmGhDisplayPostInfoScreen (pDevExt, pAllocation, pPrimaryInfo->VidPnSourceId);
     185            Status = vboxWddmGhDisplayPostInfoScreen(pDevExt, pAllocation);
    190186            Assert(Status == STATUS_SUCCESS);
    191187            if (Status != STATUS_SUCCESS)
     
    407403}
    408404
    409 UINT vboxWddmCalcBitsPerPixel(D3DDDIFORMAT format)
    410 {
    411     switch (format)
    412     {
    413         case D3DDDIFMT_R8G8B8:
    414             return 24;
    415         case D3DDDIFMT_A8R8G8B8:
    416         case D3DDDIFMT_X8R8G8B8:
    417             return 32;
    418         case D3DDDIFMT_R5G6B5:
    419         case D3DDDIFMT_X1R5G5B5:
    420         case D3DDDIFMT_A1R5G5B5:
    421         case D3DDDIFMT_A4R4G4B4:
    422             return 16;
    423         case D3DDDIFMT_R3G3B2:
    424         case D3DDDIFMT_A8:
    425             return 8;
    426         case D3DDDIFMT_A8R3G3B2:
    427         case D3DDDIFMT_X4R4G4B4:
    428             return 16;
    429         case D3DDDIFMT_A2B10G10R10:
    430         case D3DDDIFMT_A8B8G8R8:
    431         case D3DDDIFMT_X8B8G8R8:
    432         case D3DDDIFMT_G16R16:
    433         case D3DDDIFMT_A2R10G10B10:
    434             return 32;
    435         case D3DDDIFMT_A16B16G16R16:
    436             return 64;
    437         case D3DDDIFMT_A8P8:
    438             return 16;
    439         case D3DDDIFMT_P8:
    440             return 8;
    441         default:
    442             AssertBreakpoint();
    443             return 0;
    444     }
    445 }
    446 
    447405D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo)
    448406{
     
    509467
    510468    return D3DDDIFMT_UNKNOWN;
    511 }
    512 
    513 UINT vboxWddmCalcPitch(UINT w, UINT bitsPerPixel)
    514 {
    515     UINT Pitch = bitsPerPixel * w;
    516     /* pitch is now in bits, translate in bytes */
    517     if(Pitch & 7)
    518         Pitch = (Pitch >> 3) + 1;
    519     else
    520         Pitch = (Pitch >> 3);
    521 
    522     return Pitch;
    523469}
    524470
     
    14341380        case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE:
    14351381        {
    1436             PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    1437             if (pAlloc->bAssigned)
     1382            if (pAllocation->bAssigned)
    14381383            {
    14391384                /* @todo: do we need to notify host? */
    1440                 vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[pAlloc->VidPnSourceId], NULL, pAlloc->VidPnSourceId);
     1385                vboxWddmAssignPrimary(pDevExt, &pDevExt->aSources[pAllocation->SurfDesc.VidPnSourceId], NULL, pAllocation->SurfDesc.VidPnSourceId);
    14411386            }
    14421387            break;
     
    14451390        case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE:
    14461391        {
    1447             PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHADOWSURFACE);
    1448             if (pAlloc->bAssigned)
    1449             {
    1450                 Assert(pAlloc->VidPnSourceId != D3DDDI_ID_UNINITIALIZED);
     1392            if (pAllocation->bAssigned)
     1393            {
     1394                Assert(pAllocation->SurfDesc.VidPnSourceId != D3DDDI_ID_UNINITIALIZED);
    14511395                /* @todo: do we need to notify host? */
    1452                 vboxWddmAssignShadow(pDevExt, &pDevExt->aSources[pAlloc->VidPnSourceId], NULL, pAlloc->VidPnSourceId);
     1396                vboxWddmAssignShadow(pDevExt, &pDevExt->aSources[pAllocation->SurfDesc.VidPnSourceId], NULL, pAllocation->SurfDesc.VidPnSourceId);
    14531397            }
    14541398            break;
     
    14681412    NTSTATUS Status = STATUS_SUCCESS;
    14691413
    1470     Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());
    1471     if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())
     1414    Assert(pAllocationInfo->PrivateDriverDataSize == sizeof (VBOXWDDM_ALLOCINFO));
     1415    if (pAllocationInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO))
    14721416    {
    14731417        PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pAllocationInfo->pPrivateDriverData;
    1474         switch (pAllocInfo->enmType)
    1475         {
    1476             case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE:
    1477             {
    1478                 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE));
    1479                 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE))
    1480                 {
    1481                     if (pAllocInfo->u.SurfInfo.bpp != 0)
    1482                     {
    1483                         PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE));
    1484                         Assert(pAllocation);
    1485                         if (pAllocation)
    1486                         {
    1487                             pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE;
    1488                             pAllocation->offVram = VBOXVIDEOOFFSET_VOID;
    1489                             pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo;
    1490                             PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    1491                             PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pAllocI = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
    1492                             pAlloc->RefreshRate = pAllocI->RefreshRate;
    1493                             pAlloc->VidPnSourceId = pAllocI->VidPnSourceId;
    1494 //                            pAlloc->offAddress = VBOXVIDEOOFFSET_VOID;
    1495                             pAlloc->bVisible = FALSE;
    1496 
    1497                             pAllocationInfo->pPrivateDriverData = NULL;
    1498                             pAllocationInfo->PrivateDriverDataSize = 0;
    1499                             pAllocationInfo->Alignment = 0;
    1500                             pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height;
    1501                             pAllocationInfo->PitchAlignedSize = 0;
    1502                             pAllocationInfo->HintedBank.Value = 0;
    1503                             pAllocationInfo->PreferredSegment.Value = 0;
    1504 #if 1 //defined(VBOXWDDM_RENDER_FROM_SHADOW)
    1505                             pAllocationInfo->SupportedReadSegmentSet = 1;
    1506                             pAllocationInfo->SupportedWriteSegmentSet = 1;
    1507 #else
    1508                             pAllocationInfo->SupportedReadSegmentSet = 2;
    1509                             pAllocationInfo->SupportedWriteSegmentSet = 2;
     1418        PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_ALLOCATION));
     1419        Assert(pAllocation);
     1420        if (pAllocation)
     1421        {
     1422            pAllocation->enmType = pAllocInfo->enmType;
     1423            pAllocation->offVram = VBOXVIDEOOFFSET_VOID;
     1424            pAllocation->SurfDesc = pAllocInfo->SurfDesc;
     1425            pAllocation->bVisible = FALSE;
     1426            pAllocation->bAssigned = FALSE;
     1427
     1428            pAllocationInfo->pPrivateDriverData = NULL;
     1429            pAllocationInfo->PrivateDriverDataSize = 0;
     1430            pAllocationInfo->Alignment = 0;
     1431            pAllocationInfo->Size = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height;
     1432            pAllocationInfo->PitchAlignedSize = 0;
     1433            pAllocationInfo->HintedBank.Value = 0;
     1434            pAllocationInfo->PreferredSegment.Value = 0;
     1435            pAllocationInfo->SupportedReadSegmentSet = 1;
     1436            pAllocationInfo->SupportedWriteSegmentSet = 1;
     1437            pAllocationInfo->EvictionSegmentSet = 0;
     1438            pAllocationInfo->MaximumRenamingListLength = 0;
     1439            pAllocationInfo->hAllocation = pAllocation;
     1440            pAllocationInfo->Flags.Value = 0;
     1441            pAllocationInfo->pAllocationUsageHint = NULL;
     1442            pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
     1443
     1444            switch (pAllocInfo->enmType)
     1445            {
     1446                case VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE:
     1447#if 0 //defined(VBOXWDDM_RENDER_FROM_SHADOW)
     1448                    pAllocationInfo->SupportedReadSegmentSet = 2;
     1449                    pAllocationInfo->SupportedWriteSegmentSet = 2;
    15101450#endif
    1511                             pAllocationInfo->EvictionSegmentSet = 0;
    1512                             pAllocationInfo->MaximumRenamingListLength = 0;
    1513                             pAllocationInfo->hAllocation = pAllocation;
    1514                             pAllocationInfo->Flags.Value = 0;
    15151451#ifndef VBOXWDDM_RENDER_FROM_SHADOW
    1516                             pAllocationInfo->Flags.CpuVisible = 1;
     1452                    pAllocationInfo->Flags.CpuVisible = 1;
    15171453#endif
    1518                             pAllocationInfo->pAllocationUsageHint = NULL;
    1519                             pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
    1520                         }
    1521                         else
    1522                         {
    1523                             drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
    1524                             Status = STATUS_NO_MEMORY;
    1525                         }
    1526                     }
    1527                     else
    1528                     {
    1529                         drprintf((__FUNCTION__ ": Invalid format (%d)\n", pAllocInfo->u.SurfInfo.format));
    1530                         Status = STATUS_INVALID_PARAMETER;
    1531                     }
    1532                 }
    1533                 else
    1534                 {
    1535                     drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)));
     1454                    break;
     1455                case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE:
     1456                case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE:
     1457                case VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC:
     1458                    pAllocationInfo->Flags.Value = 0;
     1459                    pAllocationInfo->Flags.CpuVisible = 1;
     1460                    break;
     1461                default:
     1462                    drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType));
     1463                    AssertBreakpoint();
    15361464                    Status = STATUS_INVALID_PARAMETER;
    1537                 }
    1538                 break;
    1539             }
    1540             case VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE:
    1541 #ifdef VBOXWDDM_RENDER_FROM_SHADOW
    1542             {
    1543                 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());
    1544                 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())
    1545                 {
    1546                     PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHADOWSURFACE));
    1547                     Assert(pAllocation);
    1548                     if (pAllocation)
    1549                     {
    1550                         pAllocation->enmType = pAllocInfo->enmType;
    1551                         pAllocation->offVram = VBOXVIDEOOFFSET_VOID;
    1552                         pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo;
    1553 
    1554                         pAllocationInfo->pPrivateDriverData = NULL;
    1555                         pAllocationInfo->PrivateDriverDataSize = 0;
    1556                         pAllocationInfo->Alignment = 0;
    1557                         pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height;
    1558                         pAllocationInfo->PitchAlignedSize = 0;
    1559                         pAllocationInfo->HintedBank.Value = 0;
    1560                         pAllocationInfo->PreferredSegment.Value = 0;
    1561                         pAllocationInfo->SupportedReadSegmentSet = 1;
    1562                         pAllocationInfo->SupportedWriteSegmentSet = 1;
    1563                         pAllocationInfo->EvictionSegmentSet = 0;
    1564                         pAllocationInfo->MaximumRenamingListLength = 0;
    1565                         pAllocationInfo->hAllocation = pAllocation;
    1566                         pAllocationInfo->Flags.Value = 0;
    1567                         pAllocationInfo->Flags.CpuVisible = 1;
    1568                         pAllocationInfo->pAllocationUsageHint = NULL;
    1569                         pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
    1570                         PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHADOWSURFACE);
    1571                         pAlloc->VidPnSourceId = D3DDDI_ID_UNINITIALIZED;
    1572 //                        pAlloc->bVisible = FALSE;
    1573 //                        pAlloc->bAssigned = FALSE;
    1574                     }
    1575                     else
    1576                     {
    1577                         drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
    1578                         Status = STATUS_NO_MEMORY;
    1579                     }
    1580                 }
    1581                 else
    1582                 {
    1583                     drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));
    1584                     Status = STATUS_INVALID_PARAMETER;
    1585                 }
    1586                 break;
    1587             }
    1588 #endif
    1589             case VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE:
    1590             {
    1591                 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());
    1592                 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())
    1593                 {
    1594                     PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_HEADSIZE());
    1595                     Assert(pAllocation);
    1596                     if (pAllocation)
    1597                     {
    1598                         pAllocation->enmType = pAllocInfo->enmType;
    1599                         pAllocation->offVram = VBOXVIDEOOFFSET_VOID;
    1600                         pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo;
    1601 
    1602                         pAllocationInfo->pPrivateDriverData = NULL;
    1603                         pAllocationInfo->PrivateDriverDataSize = 0;
    1604                         pAllocationInfo->Alignment = 0;
    1605                         pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height;
    1606                         pAllocationInfo->PitchAlignedSize = 0;
    1607                         pAllocationInfo->HintedBank.Value = 0;
    1608                         pAllocationInfo->PreferredSegment.Value = 0;
    1609                         pAllocationInfo->SupportedReadSegmentSet = 1;
    1610                         pAllocationInfo->SupportedWriteSegmentSet = 1;
    1611                         pAllocationInfo->EvictionSegmentSet = 0;
    1612                         pAllocationInfo->MaximumRenamingListLength = 0;
    1613                         pAllocationInfo->hAllocation = pAllocation;
    1614                         pAllocationInfo->Flags.Value = 0;
    1615                         pAllocationInfo->Flags.CpuVisible = 1;
    1616                         pAllocationInfo->pAllocationUsageHint = NULL;
    1617                         pAllocationInfo->AllocationPriority = D3DDDI_ALLOCATIONPRIORITY_NORMAL;
    1618                     }
    1619                     else
    1620                     {
    1621                         drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
    1622                         Status = STATUS_NO_MEMORY;
    1623                     }
    1624                 }
    1625                 else
    1626                 {
    1627                     drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));
    1628                     Status = STATUS_INVALID_PARAMETER;
    1629                 }
    1630                 break;
    1631             }
    1632             default:
    1633                 drprintf((__FUNCTION__ ": ERROR: invalid alloc info type(%d)\n", pAllocInfo->enmType));
    1634                 Status = STATUS_INVALID_PARAMETER;
    1635                 break;
    1636         }
     1465                    break;
     1466            }
     1467
     1468            if (Status != STATUS_SUCCESS)
     1469                vboxWddmMemFree(pAllocation);
     1470        }
     1471        else
     1472        {
     1473            drprintf((__FUNCTION__ ": ERROR: failed to create allocation description\n"));
     1474            Status = STATUS_NO_MEMORY;
     1475        }
     1476
    16371477    }
    16381478    else
    16391479    {
    1640         drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));
     1480        drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than header size(%d)\n", pAllocationInfo->PrivateDriverDataSize, sizeof (VBOXWDDM_ALLOCINFO)));
    16411481        Status = STATUS_INVALID_PARAMETER;
    16421482    }
     
    16581498    NTSTATUS Status = STATUS_SUCCESS;
    16591499
     1500    if (pCreateAllocation->PrivateDriverDataSize)
     1501    {
     1502        /* @todo: Implement Resource Data Handling */
     1503        drprintf((__FUNCTION__ ": WARNING: Implement Resource Data Handling\n"));
     1504    }
     1505
    16601506    for (UINT i = 0; i < pCreateAllocation->NumAllocations; ++i)
    16611507    {
     
    17171563
    17181564    PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)pDescribeAllocation->hAllocation;
    1719     pDescribeAllocation->Width = pAllocation->u.SurfInfo.width;
    1720     pDescribeAllocation->Height = pAllocation->u.SurfInfo.height;
    1721     pDescribeAllocation->Format = pAllocation->u.SurfInfo.format;
     1565    pDescribeAllocation->Width = pAllocation->SurfDesc.width;
     1566    pDescribeAllocation->Height = pAllocation->SurfDesc.height;
     1567    pDescribeAllocation->Format = pAllocation->SurfDesc.format;
    17221568    memset (&pDescribeAllocation->MultisampleMethod, 0, sizeof (pDescribeAllocation->MultisampleMethod));
    17231569    pDescribeAllocation->RefreshRate.Numerator = 60000;
     
    17571603            {
    17581604                pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
     1605                memset (pAllocInfo, 0, sizeof (VBOXWDDM_ALLOCINFO));
    17591606                pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE;
    1760                 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width;
    1761                 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height;
    1762                 pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format;
    1763                 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
    1764                 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
    1765                 PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
    1766                 pInfo->RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate;
    1767                 pInfo->VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId;
    1768             }
    1769             pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
     1607                pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width;
     1608                pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height;
     1609                pAllocInfo->SurfDesc.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format;
     1610                pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format);
     1611                pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->SurfDesc.bpp);
     1612                pAllocInfo->SurfDesc.depth = 0;
     1613                pAllocInfo->SurfDesc.slicePitch = 0;
     1614                pAllocInfo->SurfDesc.RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate;
     1615                pAllocInfo->SurfDesc.VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId;
     1616            }
     1617            pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO);
    17701618
    17711619            pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
     
    17881636                    pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
    17891637                    pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE;
    1790                     pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width;
    1791                     pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height;
    1792                     pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format;
    1793                     pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
    1794                     pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
    1795 
    1796                     pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch;
     1638                    pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width;
     1639                    pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height;
     1640                    pAllocInfo->SurfDesc.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format;
     1641                    pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format);
     1642                    pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->SurfDesc.bpp);
     1643                    pAllocInfo->SurfDesc.depth = 0;
     1644                    pAllocInfo->SurfDesc.slicePitch = 0;
     1645                    pAllocInfo->SurfDesc.RefreshRate.Numerator = 0;
     1646                    pAllocInfo->SurfDesc.RefreshRate.Denominator = 1000;
     1647                    pAllocInfo->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED;
     1648
     1649                    pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->SurfDesc.pitch;
    17971650                }
    1798                 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();
     1651                pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO);
    17991652
    18001653                pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
     
    18141667                pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
    18151668                pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_STD_STAGINGSURFACE;
    1816                 pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width;
    1817                 pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height;
    1818                 pAllocInfo->u.SurfInfo.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */
    1819                 pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
    1820                 pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
    1821 
    1822                 pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch;
    1823             }
    1824             pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();
     1669                pAllocInfo->SurfDesc.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width;
     1670                pAllocInfo->SurfDesc.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height;
     1671                pAllocInfo->SurfDesc.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */
     1672                pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->SurfDesc.format);
     1673                pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->SurfDesc.bpp);
     1674                pAllocInfo->SurfDesc.depth = 0;
     1675                pAllocInfo->SurfDesc.slicePitch = 0;
     1676                pAllocInfo->SurfDesc.RefreshRate.Numerator = 0;
     1677                pAllocInfo->SurfDesc.RefreshRate.Denominator = 1000;
     1678                pAllocInfo->SurfDesc.VidPnSourceId = D3DDDI_ID_UNINITIALIZED;
     1679
     1680                pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->SurfDesc.pitch;
     1681            }
     1682            pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO);
    18251683
    18261684            pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
     
    29292787        {
    29302788            Assert(pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE);
    2931             PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    29322789            pAllocation->offVram = (VBOXVIDEOOFFSET)pSetVidPnSourceAddress->PrimaryAddress.QuadPart;
    29332790            pAllocation->SegmentId = pSetVidPnSourceAddress->PrimarySegment;
    29342791            Assert (pAllocation->SegmentId);
    2935             Assert (!pPrimary->bVisible);
     2792            Assert (!pAllocation->bVisible);
    29362793#ifndef VBOXWDDM_RENDER_FROM_SHADOW
    2937             if (pPrimary->bVisible)
     2794            if (pAllocation->bVisible)
    29382795            {
    29392796                /* should not generally happen, but still inform host*/
     
    29832840        PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pSetVidPnSourceVisibility->VidPnSourceId];
    29842841        PVBOXWDDM_ALLOCATION pAllocation = pSource->pPrimaryAllocation;
    2985         PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    2986 
    2987         Assert(pPrimary->bVisible != pSetVidPnSourceVisibility->Visible);
    2988         if (pPrimary->bVisible != pSetVidPnSourceVisibility->Visible)
    2989         {
    2990             pPrimary->bVisible = pSetVidPnSourceVisibility->Visible;
     2842
     2843        Assert(pAllocation->bVisible != pSetVidPnSourceVisibility->Visible);
     2844        if (pAllocation->bVisible != pSetVidPnSourceVisibility->Visible)
     2845        {
     2846            pAllocation->bVisible = pSetVidPnSourceVisibility->Visible;
    29912847#ifndef VBOXWDDM_RENDER_FROM_SHADOW
    2992             if (pPrimary->bVisible)
     2848            if (pAllocation->bVisible)
    29932849            {
    29942850                Status = vboxWddmGhDisplaySetInfo(pDevExt, pSource);
     
    33683224DECLINLINE(VOID) vboxWddmSurfDescFromAllocation(PVBOXWDDM_ALLOCATION pAllocation, PVBOXVDMA_SURF_DESC pDesc)
    33693225{
    3370     pDesc->width = pAllocation->u.SurfInfo.width;
    3371     pDesc->height = pAllocation->u.SurfInfo.height;
    3372     pDesc->format = vboxWddmFromPixFormat(pAllocation->u.SurfInfo.format);
    3373     pDesc->bpp = pAllocation->u.SurfInfo.bpp;
    3374     pDesc->pitch = pAllocation->u.SurfInfo.pitch;
     3226    pDesc->width = pAllocation->SurfDesc.width;
     3227    pDesc->height = pAllocation->SurfDesc.height;
     3228    pDesc->format = vboxWddmFromPixFormat(pAllocation->SurfDesc.format);
     3229    pDesc->bpp = pAllocation->SurfDesc.bpp;
     3230    pDesc->pitch = pAllocation->SurfDesc.pitch;
    33753231    pDesc->fFlags = 0;
    33763232}
     
    33843240}
    33853241
    3386 DECLINLINE(PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
     3242DECLINLINE(bool) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
    33873243{
    33883244    if (pAllocation->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE)
    3389         return NULL;
    3390 
    3391     PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    3392     if (!pPrimary->bVisible)
    3393         return NULL;
    3394 
    3395     D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pPrimary->VidPnSourceId;
     3245        return false;
     3246
     3247    if (!pAllocation->bVisible)
     3248        return false;
     3249
     3250    D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pAllocation->SurfDesc.VidPnSourceId;
    33963251    if (id >=  pDevExt->cSources)
    3397         return NULL;
     3252        return false;
    33983253
    33993254    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[id];
    34003255    if (pSource->pPrimaryAllocation != pAllocation)
    3401         return NULL;
    3402 
    3403     return pPrimary;
     3256        return false;
     3257
     3258    return true;
    34043259}
    34053260
     
    34563311                            && pSrcAlloc->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHADOWSURFACE)
    34573312                    {
    3458                         PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimaryInfo = VBOXWDDM_ALLOCATION_BODY(pDstAlloc, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    3459                         Assert(pPrimaryInfo->bAssigned);
    3460                         Assert(pPrimaryInfo->bVisible);
    3461                         if (pPrimaryInfo->bAssigned
    3462                                 && pPrimaryInfo->bVisible)
     3313                        Assert(pDstAlloc->bAssigned);
     3314                        Assert(pDstAlloc->bVisible);
     3315                        if (pDstAlloc->bAssigned
     3316                                && pDstAlloc->bVisible)
    34633317                        {
    3464                             VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pPrimaryInfo->VidPnSourceId];
    3465                             vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pPrimaryInfo->VidPnSourceId);
     3318                            VBOXWDDM_SOURCE *pSource = &pDevExt->aSources[pDstAlloc->SurfDesc.VidPnSourceId];
     3319                            vboxWddmAssignShadow(pDevExt, pSource, pSrcAlloc, pDstAlloc->SurfDesc.VidPnSourceId);
    34663320                            Assert(pPresent->SrcRect.left == pPresent->DstRect.left);
    34673321                            Assert(pPresent->SrcRect.right == pPresent->DstRect.right);
     
    35073361                                    /* we do not know the shadow address yet, perform dummy DMA cycle */
    35083362                                    pPrivateData->rect = rect;
    3509                                     pPrivateData->srcId = pPrimaryInfo->VidPnSourceId;
     3363                                    pPrivateData->srcId = pDstAlloc->SurfDesc.VidPnSourceId;
    35103364                                    pPrivateData->enmCmd = VBOXVDMACMD_TYPE_DMA_PRESENT_SHADOW2PRIMARY;
    35113365                                    if (pSrc->SegmentId)
     
    35373391                    if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE())
    35383392                    {
    3539                         if (vboxWddmPixFormatConversionSupported(pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))
     3393                        if (vboxWddmPixFormatConversionSupported(pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format))
    35403394                        {
    35413395                            memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
     
    35823436                        {
    35833437                            AssertBreakpoint();
    3584                             drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));
     3438                            drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format));
    35853439                            Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT;
    35863440                        }
     
    36263480                if (pDstAlloc)
    36273481                {
    3628                     if (vboxWddmPixFormatConversionSupported(pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))
     3482                    if (vboxWddmPixFormatConversionSupported(pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format))
    36293483                    {
    36303484                        memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
     
    36703524                    {
    36713525                        AssertBreakpoint();
    3672                         drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));
     3526                        drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->SurfDesc.format, pDstAlloc->SurfDesc.format));
    36733527                        Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT;
    36743528                    }
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