VirtualBox

Ignore:
Timestamp:
Feb 18, 2010 3:47:33 PM (15 years ago)
Author:
vboxsync
Message:

wddm: more impl

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

Legend:

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

    r26556 r26630  
    10321032}
    10331033
     1034/**
     1035 * DxgkDdiQueryAdapterInfo
     1036 */
    10341037NTSTATUS APIENTRY DxgkDdiQueryAdapterInfo(
    10351038    CONST HANDLE  hAdapter,
     
    10691072            pCaps->SchedulingCaps.Value = 0;
    10701073            /* we might need it for Aero.
    1071              * Setting this glag means we support DeviceContext, i.e.
     1074             * Setting this flag means we support DeviceContext, i.e.
    10721075             *  DxgkDdiCreateContext and DxgkDdiDestroyContext
    10731076             */
     
    11311134}
    11321135
     1136/**
     1137 * DxgkDdiCreateDevice
     1138 */
    11331139NTSTATUS APIENTRY DxgkDdiCreateDevice(
    11341140    CONST HANDLE  hAdapter,
     
    11431149
    11441150    PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)vboxWddmMemAllocZero(sizeof (VBOXWDDM_DEVICE));
    1145     pDevice->hDevice = pCreateDevice->hDevice;
     1151    pCreateDevice->hDevice = pDevice;
     1152    if (pCreateDevice->Flags.SystemDevice)
     1153        pDevice->enmType = VBOXWDDM_DEVICE_TYPE_SYSTEM;
     1154    else
     1155    {
     1156        AssertBreakpoint(); /* we do not support custom contexts for now */
     1157        drprintf((__FUNCTION__ ": we do not support custom devices for now, hAdapter (0x%x)\n", hAdapter));
     1158    }
     1159
    11461160    pDevice->pAdapter = pContext;
    1147     pDevice->fCreationFlags = pCreateDevice->Flags;
    1148 
    1149     pDevice->DeviceInfo.AllocationListSize = 1024;
    1150     pDevice->DeviceInfo.DmaBufferSegmentSet = 0;
    1151     pDevice->DeviceInfo.DmaBufferPrivateDataSize = 0;
    1152     pDevice->DeviceInfo.AllocationListSize = 4;
    1153     pDevice->DeviceInfo.PatchLocationListSize = 4;
    1154     pDevice->DeviceInfo.Flags.Value = 0;
    1155     pDevice->DeviceInfo.Flags.GuaranteedDmaBufferContract = 1;
    1156 
    1157     pCreateDevice->pInfo = &pDevice->DeviceInfo;
     1161
    11581162    pCreateDevice->hDevice = pDevice;
     1163    pCreateDevice->pInfo = NULL;
    11591164
    11601165    dfprintf(("<== "__FUNCTION__ ", context(0x%x), Status(0x%x)\n", hAdapter, Status));
     
    11871192                if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE))
    11881193                {
    1189                     PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
    1190                     UINT bpp = vboxWddmCalcBitsPerPixel(pInfo->SurfData.Format);
    1191                     Assert(bpp);
    1192                     if (bpp != 0)
     1194                    if (pAllocInfo->u.SurfInfo.bpp != 0)
    11931195                    {
    11941196                        PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE));
     
    11961198                        if (pAllocation)
    11971199                        {
    1198                             UINT Pitch = vboxWddmCalcPitch(pInfo->SurfData.Width, bpp);
    11991200                            pAllocation->enmType = VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE;
     1201                            pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo;
    12001202                            PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocInfo, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
    1201                             memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo));
     1203                            PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pAllocI = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
     1204//                            memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo));
     1205                            pAlloc->RefreshRate = pAllocI->RefreshRate;
     1206                            pAlloc->VidPnSourceId = pAllocI->VidPnSourceId;
     1207                            pAlloc->offAddress = VBOXVIDEOOFFSET_VOID;
     1208                            pAlloc->bVisible = FALSE;
    12021209
    12031210                            pAllocationInfo->pPrivateDriverData = NULL;
    12041211                            pAllocationInfo->PrivateDriverDataSize = 0;
    12051212                            pAllocationInfo->Alignment = 0;
    1206                             pAllocationInfo->Size = Pitch * pInfo->SurfData.Height;
     1213                            pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height;
    12071214                            pAllocationInfo->PitchAlignedSize = 0;
    12081215                            pAllocationInfo->HintedBank.Value = 0;
     
    12121219                            pAllocationInfo->EvictionSegmentSet = 0;
    12131220                            pAllocationInfo->MaximumRenamingListLength = 0;
    1214                             pAllocationInfo->hAllocation = pAlloc;
     1221                            pAllocationInfo->hAllocation = pAllocation;
    12151222                            pAllocationInfo->Flags.Value = 0;
    12161223                            pAllocationInfo->Flags.CpuVisible = 1;
     
    12261233                    else
    12271234                    {
    1228                         drprintf((__FUNCTION__ ": Invalid format (%d)\n", pInfo->SurfData.Format));
     1235                        drprintf((__FUNCTION__ ": Invalid format (%d)\n", pAllocInfo->u.SurfInfo.format));
    12291236                        Status = STATUS_INVALID_PARAMETER;
    12301237                    }
     
    12321239                else
    12331240                {
    1234                     drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE)));
     1241                    drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE)));
    12351242                    Status = STATUS_INVALID_PARAMETER;
    12361243                }
     
    12381245            }
    12391246            case VBOXWDDM_ALLOC_STD_SHADOWSURFACE:
    1240             {
    1241                 Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE));
    1242                 if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE))
     1247            case VBOXWDDM_ALLOC_STD_STAGINGSURFACE:
     1248            {
     1249                Assert(pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE());
     1250                if (pAllocationInfo->PrivateDriverDataSize >= VBOXWDDM_ALLOCINFO_HEADSIZE())
    12431251                {
    1244                     PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCATION_SIZE(VBOXWDDM_ALLOCATION_SHADOWSURFACE));
     1252                    PVBOXWDDM_ALLOCATION pAllocation = (PVBOXWDDM_ALLOCATION)vboxWddmMemAllocZero(VBOXWDDM_ALLOCINFO_HEADSIZE());
    12451253                    Assert(pAllocation);
    12461254                    if (pAllocation)
    12471255                    {
    1248                         pAllocation->enmType = VBOXWDDM_ALLOC_STD_SHADOWSURFACE;
    1249                         PVBOXWDDM_ALLOCATION_SHADOWSURFACE pAlloc = VBOXWDDM_ALLOCATION_BODY(pAllocInfo, VBOXWDDM_ALLOCATION_SHADOWSURFACE);
    1250                         PVBOXWDDM_ALLOCINFO_SHADOWSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHADOWSURFACE);
    1251                         memcpy(&pAlloc->AllocInfo, pInfo, sizeof (pAlloc->AllocInfo));
     1256                        pAllocation->enmType = pAllocInfo->enmType;
     1257                        pAllocation->u.SurfInfo = pAllocInfo->u.SurfInfo;
    12521258
    12531259                        pAllocationInfo->pPrivateDriverData = NULL;
    12541260                        pAllocationInfo->PrivateDriverDataSize = 0;
    12551261                        pAllocationInfo->Alignment = 0;
    1256                         pAllocationInfo->Size = pInfo->SurfData.Pitch * pInfo->SurfData.Height;
     1262                        pAllocationInfo->Size = pAllocInfo->u.SurfInfo.pitch * pAllocInfo->u.SurfInfo.height;
    12571263                        pAllocationInfo->PitchAlignedSize = 0;
    12581264                        pAllocationInfo->HintedBank.Value = 0;
     
    12621268                        pAllocationInfo->EvictionSegmentSet = 0;
    12631269                        pAllocationInfo->MaximumRenamingListLength = 0;
    1264                         pAllocationInfo->hAllocation = pAlloc;
     1270                        pAllocationInfo->hAllocation = pAllocation;
    12651271                        pAllocationInfo->Flags.Value = 0;
    12661272                        pAllocationInfo->Flags.CpuVisible = 1;
     
    12761282                else
    12771283                {
    1278                     drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHADOWSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE)));
     1284                    drprintf((__FUNCTION__ ": ERROR: PrivateDriverDataSize(%d) less than VBOXWDDM_ALLOC_STD_SHADOWSURFACE cmd size(%d)\n", pAllocationInfo->PrivateDriverDataSize, VBOXWDDM_ALLOCINFO_HEADSIZE()));
    12791285                    Status = STATUS_INVALID_PARAMETER;
    12801286                }
    1281                 break;
    1282             }
    1283             case VBOXWDDM_ALLOC_STD_STAGINGSURFACE:
    1284             {
    1285                 /* @todo: impl */
    1286                 AssertBreakpoint();
    12871287                break;
    12881288            }
     
    13661366
    13671367/**
    1368  *
     1368 * DxgkDdiGetStandardAllocationDriverData
    13691369 */
    13701370NTSTATUS
     
    13911391                pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
    13921392                pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE;
     1393                pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width;
     1394                pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Height;
     1395                pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Format;
     1396                pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
     1397                pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
    13931398                PVBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
    1394                 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData, sizeof (pInfo->SurfData));
     1399                pInfo->RefreshRate = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->RefreshRate;
     1400                pInfo->VidPnSourceId = pGetStandardAllocationDriverData->pCreateSharedPrimarySurfaceData->VidPnSourceId;
    13951401            }
    13961402            pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHAREDPRIMARYSURFACE);
     
    14151421                    pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
    14161422                    pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_SHADOWSURFACE;
    1417                     PVBOXWDDM_ALLOCINFO_SHADOWSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_SHADOWSURFACE);
    1418                     memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateShadowSurfaceData, sizeof (pInfo->SurfData));
     1423                    pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width;
     1424                    pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Height;
     1425                    pAllocInfo->u.SurfInfo.format = pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Format;
     1426                    pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
     1427                    pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
     1428
     1429                    pGetStandardAllocationDriverData->pCreateShadowSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch;
    14191430                }
    1420                 pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_SHADOWSURFACE);
     1431                pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();
    14211432
    14221433                pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
     
    14361447                pAllocInfo = (PVBOXWDDM_ALLOCINFO)pGetStandardAllocationDriverData->pAllocationPrivateDriverData;
    14371448                pAllocInfo->enmType = VBOXWDDM_ALLOC_STD_STAGINGSURFACE;
    1438                 PVBOXWDDM_ALLOCINFO_STAGINGSURFACE pInfo = VBOXWDDM_ALLOCINFO_BODY(pAllocInfo, VBOXWDDM_ALLOCINFO_STAGINGSURFACE);
    1439                 memcpy(&pInfo->SurfData, pGetStandardAllocationDriverData->pCreateStagingSurfaceData, sizeof (pInfo->SurfData));
    1440             }
    1441             pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_SIZE(VBOXWDDM_ALLOCINFO_STAGINGSURFACE);
     1449                pAllocInfo->u.SurfInfo.width = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width;
     1450                pAllocInfo->u.SurfInfo.height = pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Height;
     1451                pAllocInfo->u.SurfInfo.format = D3DDDIFMT_X8R8G8B8; /* staging has always always D3DDDIFMT_X8R8G8B8 */
     1452                pAllocInfo->u.SurfInfo.bpp = vboxWddmCalcBitsPerPixel(pAllocInfo->u.SurfInfo.format);
     1453                pAllocInfo->u.SurfInfo.pitch = vboxWddmCalcPitch(pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Width, pAllocInfo->u.SurfInfo.bpp);
     1454
     1455                pGetStandardAllocationDriverData->pCreateStagingSurfaceData->Pitch = pAllocInfo->u.SurfInfo.pitch;
     1456            }
     1457            pGetStandardAllocationDriverData->AllocationPrivateDriverDataSize = VBOXWDDM_ALLOCINFO_HEADSIZE();
    14421458
    14431459            pGetStandardAllocationDriverData->ResourcePrivateDriverDataSize = 0;
     
    14461462//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
    14471463//        case D3DKMDT_STANDARDALLOCATION_GDISURFACE:
     1464//# error port to Win7 DDI
    14481465//              break;
    14491466//#endif
     
    20542071    CONST DXGKARG_OPENALLOCATION  *pOpenAllocation)
    20552072{
    2056     return STATUS_NOT_IMPLEMENTED;
     2073    /* DxgkDdiOpenAllocation should be made pageable. */
     2074    PAGED_CODE();
     2075
     2076    NTSTATUS Status = STATUS_SUCCESS;
     2077
     2078    for (UINT i = 0; i < pOpenAllocation->NumAllocations; ++i)
     2079    {
     2080        DXGK_OPENALLOCATIONINFO* pInfo = &pOpenAllocation->pOpenAllocation[i];
     2081        PVBOXWDDM_OPENALLOCATION pOa = (PVBOXWDDM_OPENALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_OPENALLOCATION));
     2082        pOa->hAllocation = pInfo->hAllocation;
     2083        pInfo->hDeviceSpecificAllocation = pOa;
     2084    }
     2085
     2086    return Status;
    20572087}
    20582088
     
    20722102    DXGKARG_RENDER  *pRender)
    20732103{
    2074     return STATUS_NOT_IMPLEMENTED;
    2075 }
    2076 
     2104    drprintf(("==> "__FUNCTION__ ", !!NOT_IMPLEMENTED!! hContext(0x%x)\n", hContext));
     2105
     2106    AssertBreakpoint();
     2107
     2108    drprintf(("<== "__FUNCTION__ ", !!NOT_IMPLEMENTED!! hContext(0x%x)\n", hContext));
     2109
     2110    return STATUS_NOT_IMPLEMENTED;
     2111}
     2112
     2113#define VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE() (VBOXVDMACMD_SIZE(VBOXVDMACMD_DMA_PRESENT_BLT))
     2114#define VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(_c) (VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects[_c]))
     2115
     2116DECLINLINE(PVBOXWDDM_ALLOCATION) vboxWddmGetAllocationFromOpenData(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_OPENALLOCATION pOa)
     2117{
     2118    DXGKARGCB_GETHANDLEDATA GhData;
     2119    GhData.hObject = pOa->hAllocation;
     2120    GhData.Type = DXGK_HANDLE_ALLOCATION;
     2121    GhData.Flags.Value = 0;
     2122    return (PVBOXWDDM_ALLOCATION)pDevExt->u.primary.DxgkInterface.DxgkCbGetHandleData(&GhData);
     2123}
     2124
     2125DECLINLINE(PVBOXWDDM_ALLOCATION) vboxWddmGetAllocationFromAllocList(PDEVICE_EXTENSION pDevExt, DXGK_ALLOCATIONLIST *pAllocList)
     2126{
     2127    return vboxWddmGetAllocationFromOpenData(pDevExt, (PVBOXWDDM_OPENALLOCATION)pAllocList->hDeviceSpecificAllocation);
     2128}
     2129
     2130DECLINLINE(VBOXVIDEOOFFSET) vboxWddmOffsetFromPhAddress(PHYSICAL_ADDRESS phAddr)
     2131{
     2132    return (VBOXVIDEOOFFSET)(phAddr.QuadPart ? phAddr.QuadPart - VBE_DISPI_LFB_PHYSICAL_ADDRESS : VBOXVIDEOOFFSET_VOID);
     2133}
     2134
     2135DECLINLINE(VOID) vboxWddmRectlFromRect(const RECT *pRect, PVBOXVDMA_RECTL pRectl)
     2136{
     2137    pRectl->left = (int16_t)pRect->left;
     2138    pRectl->width = (uint16_t)(pRect->right - pRect->left);
     2139    pRectl->top = (int16_t)pRect->top;
     2140    pRectl->height = (uint16_t)(pRect->bottom - pRect->top);
     2141}
     2142
     2143DECLINLINE(VBOXVDMA_PIXEL_FORMAT) vboxWddmFromPixFormat(D3DDDIFORMAT format)
     2144{
     2145    return (VBOXVDMA_PIXEL_FORMAT)format;
     2146}
     2147
     2148DECLINLINE(VOID) vboxWddmSurfDescFromAllocation(PVBOXWDDM_ALLOCATION pAllocation, PVBOXVDMA_SURF_DESC pDesc)
     2149{
     2150    pDesc->width = pAllocation->u.SurfInfo.width;
     2151    pDesc->height = pAllocation->u.SurfInfo.height;
     2152    pDesc->format = vboxWddmFromPixFormat(pAllocation->u.SurfInfo.format);
     2153    pDesc->bpp = pAllocation->u.SurfInfo.bpp;
     2154    pDesc->pitch = pAllocation->u.SurfInfo.pitch;
     2155    pDesc->fFlags = 0;
     2156}
     2157
     2158DECLINLINE(BOOLEAN) vboxWddmPixFormatConversionSupported(D3DDDIFORMAT From, D3DDDIFORMAT To)
     2159{
     2160    Assert(From != D3DDDIFMT_UNKNOWN);
     2161    Assert(To != D3DDDIFMT_UNKNOWN);
     2162    Assert(From == To);
     2163    return From == To;
     2164}
     2165
     2166DECLINLINE(PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE) vboxWddmCheckForVisiblePrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_ALLOCATION pAllocation)
     2167{
     2168    if (pAllocation->enmType != VBOXWDDM_ALLOC_STD_SHAREDPRIMARYSURFACE)
     2169        return NULL;
     2170
     2171    PVBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE pPrimary = VBOXWDDM_ALLOCATION_BODY(pAllocation, VBOXWDDM_ALLOCATION_SHAREDPRIMARYSURFACE);
     2172    if (!pPrimary->bVisible)
     2173        return NULL;
     2174
     2175    D3DDDI_VIDEO_PRESENT_SOURCE_ID id = pPrimary->VidPnSourceId;
     2176    if (id >=  pDevExt->cSources)
     2177        return NULL;
     2178
     2179    PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[id];
     2180    if (pSource->pAllocation != pAllocation)
     2181        return NULL;
     2182
     2183    return pPrimary;
     2184}
     2185
     2186/**
     2187 * DxgkDdiPresent
     2188 */
    20772189NTSTATUS
    20782190APIENTRY
     
    20812193    DXGKARG_PRESENT  *pPresent)
    20822194{
    2083     return STATUS_NOT_IMPLEMENTED;
     2195    PAGED_CODE();
     2196
     2197    dfprintf(("==> "__FUNCTION__ ", hContext(0x%x)\n", hContext));
     2198
     2199    NTSTATUS Status = STATUS_SUCCESS;
     2200    PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)hContext;
     2201    PVBOXWDDM_DEVICE pDevice = pContext->pDevice;
     2202    PDEVICE_EXTENSION pDevExt = pDevice->pAdapter;
     2203
     2204    if (pPresent->Flags.Blt)
     2205    {
     2206        Assert(pPresent->Flags.Value == 1); /* only Blt is set, we do not support anything else for now */
     2207        UINT cbCmd = pPresent->DmaSize;
     2208
     2209        UINT cmdSize = VBOXVDMACMD_DMA_PRESENT_BLT_SIZE(pPresent->SubRectCnt - pPresent->MultipassOffset);
     2210        PVBOXVDMACMD pCmd = (PVBOXVDMACMD)pPresent->pDmaBuffer;
     2211        pPresent->pDmaBuffer = ((uint8_t*)pPresent->pDmaBuffer) + cmdSize;
     2212        Assert(cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE());
     2213        if (cbCmd >= VBOXVDMACMD_DMA_PRESENT_BLT_MINSIZE())
     2214        {
     2215            DXGK_ALLOCATIONLIST *pSrc =  &pPresent->pAllocationList[DXGK_PRESENT_SOURCE_INDEX];
     2216            DXGK_ALLOCATIONLIST *pDst =  &pPresent->pAllocationList[DXGK_PRESENT_DESTINATION_INDEX];
     2217            PVBOXWDDM_ALLOCATION pSrcAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pSrc);
     2218            Assert(pSrcAlloc);
     2219            if (pSrcAlloc)
     2220            {
     2221                PVBOXWDDM_ALLOCATION pDstAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pDst);
     2222                Assert(pDstAlloc);
     2223                if (pDstAlloc)
     2224                {
     2225                    if (vboxWddmPixFormatConversionSupported(pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format))
     2226                    {
     2227                        memset(pPresent->pPatchLocationListOut, 0, 2*sizeof (D3DDDI_PATCHLOCATIONLIST));
     2228                        pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offSrc);
     2229                        ++pPresent->pPatchLocationListOut;
     2230                        pPresent->pPatchLocationListOut->PatchOffset = VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, offDst);
     2231                        pPresent->pPatchLocationListOut->AllocationIndex = 1;
     2232                        ++pPresent->pPatchLocationListOut;
     2233
     2234                        pCmd->enmType = VBOXVDMACMD_TYPE_DMA_PRESENT_BLT;
     2235                        pCmd->u32CmdSpecific = 0;
     2236                        PVBOXVDMACMD_DMA_PRESENT_BLT pTransfer = VBOXVDMACMD_BODY(pCmd, VBOXVDMACMD_DMA_PRESENT_BLT);
     2237                        pTransfer->offSrc = vboxWddmOffsetFromPhAddress(pSrc->PhysicalAddress);
     2238                        pTransfer->offDst = vboxWddmOffsetFromPhAddress(pDst->PhysicalAddress);
     2239                        vboxWddmSurfDescFromAllocation(pSrcAlloc, &pTransfer->srcDesc);
     2240                        vboxWddmSurfDescFromAllocation(pDstAlloc, &pTransfer->dstDesc);
     2241                        vboxWddmRectlFromRect(&pPresent->SrcRect, &pTransfer->srcRectl);
     2242                        vboxWddmRectlFromRect(&pPresent->DstRect, &pTransfer->dstRectl);
     2243                        UINT i = 0;
     2244                        cbCmd -= VBOXVDMACMD_BODY_FIELD_OFFSET(UINT, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects);
     2245                        Assert(cbCmd >= sizeof (VBOXVDMA_RECTL));
     2246                        Assert(cbCmd < pPresent->DmaSize);
     2247                        for (; i < pPresent->SubRectCnt; ++i)
     2248                        {
     2249                            if (cbCmd < sizeof (VBOXVDMA_RECTL))
     2250                            {
     2251                                Assert(i);
     2252                                pPresent->MultipassOffset += i;
     2253                                Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
     2254                                break;
     2255                            }
     2256                            vboxWddmRectlFromRect(&pPresent->pDstSubRects[i + pPresent->MultipassOffset], &pTransfer->aDstSubRects[i]);
     2257                            cbCmd -= sizeof (VBOXVDMA_RECTL);
     2258                        }
     2259                        Assert(i);
     2260                        pTransfer->cDstSubRects = i;
     2261                    }
     2262                    else
     2263                    {
     2264                        AssertBreakpoint();
     2265                        drprintf((__FUNCTION__": unsupported format conversion from(%d) to (%d)\n",pSrcAlloc->u.SurfInfo.format, pDstAlloc->u.SurfInfo.format));
     2266                        Status = STATUS_GRAPHICS_CANNOTCOLORCONVERT;
     2267                    }
     2268                }
     2269                else
     2270                {
     2271                    /* this should not happen actually */
     2272                    drprintf((__FUNCTION__": failed to get Dst Allocation info for hDeviceSpecificAllocation(0x%x)\n",pDst->hDeviceSpecificAllocation));
     2273                    Status = STATUS_INVALID_HANDLE;
     2274                }
     2275            }
     2276            else
     2277            {
     2278                /* this should not happen actually */
     2279                drprintf((__FUNCTION__": failed to get Src Allocation info for hDeviceSpecificAllocation(0x%x)\n",pSrc->hDeviceSpecificAllocation));
     2280                Status = STATUS_INVALID_HANDLE;
     2281            }
     2282        }
     2283        else
     2284        {
     2285            /* this should not happen actually */
     2286            drprintf((__FUNCTION__": cbCmd too small!! (%d)\n", cbCmd));
     2287            Status = STATUS_GRAPHICS_INSUFFICIENT_DMA_BUFFER;
     2288        }
     2289
     2290    }
     2291    else
     2292    {
     2293        drprintf((__FUNCTION__": cmd NOT IMPLEMENTED!! Flags(0x%x)\n", pPresent->Flags.Value));
     2294        AssertBreakpoint();
     2295    }
     2296
     2297    dfprintf(("<== "__FUNCTION__ ", hContext(0x%x), Status(0x%x)\n", hContext, Status));
     2298
     2299    return Status;
    20842300}
    20852301
     
    21102326}
    21112327
     2328/**
     2329 * DxgkDdiCreateContext
     2330 */
    21122331NTSTATUS
    21132332APIENTRY
     
    21162335    DXGKARG_CREATECONTEXT  *pCreateContext)
    21172336{
    2118     return STATUS_NOT_IMPLEMENTED;
     2337    /* DxgkDdiCreateContext should be made pageable */
     2338    PAGED_CODE();
     2339
     2340    dfprintf(("==> "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
     2341
     2342    NTSTATUS Status = STATUS_SUCCESS;
     2343    PVBOXWDDM_DEVICE pDevice = (PVBOXWDDM_DEVICE)hDevice;
     2344    PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)vboxWddmMemAllocZero(sizeof (VBOXWDDM_CONTEXT));
     2345
     2346    pContext->pDevice = pDevice;
     2347    pContext->EngineAffinity = pCreateContext->EngineAffinity;
     2348    pContext->NodeOrdinal = pCreateContext->NodeOrdinal;
     2349    if (pCreateContext->Flags.SystemContext)
     2350        pContext->enmType = VBOXWDDM_CONTEXT_TYPE_SYSTEM;
     2351    else
     2352    {
     2353        AssertBreakpoint(); /* we do not support custom contexts for now */
     2354        drprintf((__FUNCTION__ ", we do not support custom contexts for now, hDevice (0x%x)\n", hDevice));
     2355    }
     2356
     2357    pCreateContext->hContext = pContext;
     2358    pCreateContext->ContextInfo.DmaBufferSize = VBOXWDDM_C_DMA_BUFFER_SIZE;
     2359    pCreateContext->ContextInfo.DmaBufferSegmentSet = 0;
     2360    pCreateContext->ContextInfo.DmaBufferPrivateDataSize = sizeof (VBOXWDDM_DMA_PRIVATE_DATA);
     2361    pCreateContext->ContextInfo.AllocationListSize = VBOXWDDM_C_ALLOC_LIST_SIZE;
     2362    pCreateContext->ContextInfo.PatchLocationListSize = VBOXWDDM_C_PATH_LOCATION_LIST_SIZE;
     2363//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
     2364//# error port to Win7 DDI
     2365//    //pCreateContext->ContextInfo.DmaBufferAllocationGroup = ???;
     2366//#endif // DXGKDDI_INTERFACE_VERSION
     2367
     2368    dfprintf(("<== "__FUNCTION__ ", hDevice(0x%x)\n", hDevice));
     2369
     2370    return Status;
    21192371}
    21202372
     
    21542406    )
    21552407{
     2408    PAGED_CODE();
     2409
    21562410    dprintf(("VBoxVideoWddm::DriverEntry. Built %s %s\n", __DATE__, __TIME__));
    21572411
    21582412    DRIVER_INITIALIZATION_DATA DriverInitializationData = {'\0'};
    2159 
    2160     PAGED_CODE();
    21612413
    21622414    if (! ARGUMENT_PRESENT(DriverObject) ||
     
    22532505
    22542506//#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
    2255 //    DriverInitializationData.DxgkDdiRenderKm  = D3DDDIRenderKm;
    2256 //    DriverInitializationData.DxgkDdiRestartFromTimeout  = D3DDDIRestartFromTimeout;
     2507//# error port to Win7 DDI
     2508//    DriverInitializationData.DxgkDdiRenderKm  = DxgkDdiRenderKm;
     2509//    DriverInitializationData.DxgkDdiRestartFromTimeout  = DxgkDdiRestartFromTimeout;
    22572510//    DriverInitializationData.DxgkDdiSetVidPnSourceVisibility  = DxgkDdiSetVidPnSourceVisibility;
    2258 //    DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath  = D3DDDIUpdateActiveVidPnPresentPath;
    2259 //    DriverInitializationData.DxgkDdiQueryVidPnHWCapability  = D3DDDI DxgkDdiQueryVidPnHWCapability;
     2511//    DriverInitializationData.DxgkDdiUpdateActiveVidPnPresentPath  = DxgkDdiUpdateActiveVidPnPresentPath;
     2512//    DriverInitializationData.DxgkDdiQueryVidPnHWCapability  = DxgkDdiQueryVidPnHWCapability;
    22602513//#endif
    22612514
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