Changeset 30308 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Display
- Timestamp:
- Jun 18, 2010 12:11:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r30216 r30308 1151 1151 DDRAW_CAPS *pCaps = (DDRAW_CAPS*)pData->pData; 1152 1152 pCaps->Caps |= DDRAW_CAPS_COLORKEY; 1153 pCaps->Caps2 |= DDRAW_CAPS2_FLIPNOVSYNC;1153 // pCaps->Caps2 |= DDRAW_CAPS2_FLIPNOVSYNC; 1154 1154 } 1155 1155 #endif … … 2563 2563 } 2564 2564 2565 static D3DDDICB_ALLOCATE* vboxWddmRequestAllocAlloc(D3DDDIARG_CREATERESOURCE* pResource) 2566 { 2567 /* allocate buffer for D3DDDICB_ALLOCATE + D3DDDI_ALLOCATIONINFO * numAllocs + PVBOXWDDM_RCINFO with aAllocInfos[numAllocs] */ 2568 uint32_t cbBuf = sizeof (D3DDDICB_ALLOCATE); 2569 uint32_t offDdiAllocInfos = (cbBuf + 7) & ~3; 2570 uint32_t cbDdiAllocInfos = sizeof (D3DDDI_ALLOCATIONINFO) * pResource->SurfCount; 2571 cbBuf = offDdiAllocInfos + cbDdiAllocInfos; 2572 uint32_t offRcInfo = (cbBuf + 7) & ~3; 2573 uint32_t cbRcInfo = sizeof (VBOXWDDM_RCINFO); 2574 cbBuf = offRcInfo + cbRcInfo; 2575 uint32_t offAllocInfos = (cbBuf + 7) & ~3; 2576 uint32_t cbAllocInfos = sizeof (VBOXWDDM_ALLOCINFO) * pResource->SurfCount; 2577 cbBuf = offAllocInfos + cbAllocInfos; 2578 uint8_t *pvBuf = (uint8_t*)RTMemAllocZ(cbBuf); 2579 Assert(pvBuf); 2580 if (pvBuf) 2581 { 2582 D3DDDICB_ALLOCATE* pAlloc = (D3DDDICB_ALLOCATE*)pvBuf; 2583 pAlloc->NumAllocations = pResource->SurfCount; 2584 pAlloc->pAllocationInfo = (D3DDDI_ALLOCATIONINFO*)(pvBuf + offDdiAllocInfos); 2585 PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)(pvBuf + offRcInfo); 2586 pAlloc->PrivateDriverDataSize = cbRcInfo; 2587 pAlloc->pPrivateDriverData = pRcInfo; 2588 pAlloc->hResource = pResource->hResource; 2589 PVBOXWDDM_ALLOCINFO pAllocInfos = (PVBOXWDDM_ALLOCINFO)(pvBuf + offAllocInfos); 2590 for (UINT i = 0; i < pResource->SurfCount; ++i) 2591 { 2592 D3DDDI_ALLOCATIONINFO* pDdiAllocInfo = &pAlloc->pAllocationInfo[i]; 2593 PVBOXWDDM_ALLOCINFO pAllocInfo = &pAllocInfos[i]; 2594 pDdiAllocInfo->pPrivateDriverData = pAllocInfo; 2595 pDdiAllocInfo->PrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 2596 } 2597 return pAlloc; 2598 } 2599 return NULL; 2600 } 2565 2601 static HRESULT APIENTRY vboxWddmDDevCreateResource(HANDLE hDevice, D3DDDIARG_CREATERESOURCE* pResource) 2566 2602 { … … 2924 2960 else 2925 2961 { 2926 /* allocate buffer for D3DDDICB_ALLOCATE + D3DDDI_ALLOCATIONINFO * numAllocs + PVBOXWDDM_RCINFO with aAllocInfos[numAllocs] */ 2927 uint32_t cbBuf = sizeof (D3DDDICB_ALLOCATE); 2928 uint32_t offDdiAllocInfos = (cbBuf + 7) & ~3; 2929 uint32_t cbDdiAllocInfos = sizeof (D3DDDI_ALLOCATIONINFO) * pResource->SurfCount; 2930 cbBuf = offDdiAllocInfos + cbDdiAllocInfos; 2931 uint32_t offRcInfo = (cbBuf + 7) & ~3; 2932 uint32_t cbRcInfo = sizeof (VBOXWDDM_RCINFO); 2933 cbBuf = offRcInfo + cbRcInfo; 2934 uint32_t offAllocInfos = (cbBuf + 7) & ~3; 2935 uint32_t cbAllocInfos = sizeof (VBOXWDDM_ALLOCINFO) * pResource->SurfCount; 2936 cbBuf = offAllocInfos + cbAllocInfos; 2937 uint8_t *pvBuf = (uint8_t*)RTMemAllocZ(cbBuf); 2938 if (pvBuf) 2939 { 2940 D3DDDICB_ALLOCATE *pAllocate = (D3DDDICB_ALLOCATE*)pvBuf; 2941 D3DDDI_ALLOCATIONINFO* pDdiAllocInfos = (D3DDDI_ALLOCATIONINFO*)(pvBuf + offDdiAllocInfos); 2942 PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)(pvBuf + offRcInfo); 2943 PVBOXWDDM_ALLOCINFO pAllocInfos = (PVBOXWDDM_ALLOCINFO)(pvBuf + offAllocInfos); 2944 pAllocate->pPrivateDriverData = pRcInfo; 2945 pAllocate->PrivateDriverDataSize = cbRcInfo; 2946 pAllocate->hResource = pResource->hResource; 2947 pAllocate->hKMResource = NULL; 2948 pAllocate->NumAllocations = pResource->SurfCount; 2949 pAllocate->pAllocationInfo = pDdiAllocInfos; 2950 2951 pRcInfo->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC; 2952 pRcInfo->RcDesc.fFlags = pResource->Flags; 2953 pRcInfo->RcDesc.enmFormat = pResource->Format; 2954 pRcInfo->RcDesc.enmPool = pResource->Pool; 2955 pRcInfo->RcDesc.enmMultisampleType = pResource->MultisampleType; 2956 pRcInfo->RcDesc.MultisampleQuality = pResource->MultisampleQuality; 2957 pRcInfo->RcDesc.MipLevels = pResource->MipLevels; 2958 pRcInfo->RcDesc.Fvf = pResource->Fvf; 2959 pRcInfo->RcDesc.VidPnSourceId = pResource->VidPnSourceId; 2960 pRcInfo->RcDesc.RefreshRate = pResource->RefreshRate; 2961 pRcInfo->RcDesc.enmRotation = pResource->Rotation; 2962 pRcInfo->cAllocInfos = pResource->SurfCount; 2963 2964 for (UINT i = 0; i < pResource->SurfCount; ++i) 2965 { 2966 PVBOXWDDM_ALLOCINFO pAllocInfo = &pAllocInfos[i]; 2967 D3DDDI_ALLOCATIONINFO* pDdiAllocInfo = &pDdiAllocInfos[i]; 2968 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 2969 pDdiAllocInfo->hAllocation = NULL; 2970 pDdiAllocInfo->pSystemMem = pSurf->pSysMem; 2971 Assert((!!(pSurf->pSysMem)) == (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)); 2972 pDdiAllocInfo->pPrivateDriverData = pAllocInfo; 2973 pDdiAllocInfo->PrivateDriverDataSize = sizeof (VBOXWDDM_ALLOCINFO); 2974 pDdiAllocInfo->VidPnSourceId = pResource->VidPnSourceId; 2975 pDdiAllocInfo->Flags.Value = 0; 2976 if (pResource->Flags.Primary) 2977 pDdiAllocInfo->Flags.Primary = 1; 2978 2979 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; 2980 pAllocInfo->SurfDesc.width = pSurf->Width; 2981 pAllocInfo->SurfDesc.height = pSurf->Height; 2982 pAllocInfo->SurfDesc.format = pResource->Format; 2983 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pResource->Format); 2984 2985 if (pSurf->SysMemPitch) 2986 { 2987 pAllocInfo->SurfDesc.pitch = pSurf->SysMemPitch; 2962 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pResource->SurfCount); 2963 Assert(pRc); 2964 if (pRc) 2965 { 2966 pRc->hResource = pResource->hResource; 2967 pRc->hKMResource = NULL; 2968 pRc->pDevice = pDevice; 2969 pRc->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC; 2970 pRc->RcDesc.fFlags = pResource->Flags; 2971 pRc->RcDesc.enmFormat = pResource->Format; 2972 pRc->RcDesc.enmPool = pResource->Pool; 2973 pRc->RcDesc.enmMultisampleType = pResource->MultisampleType; 2974 pRc->RcDesc.MultisampleQuality = pResource->MultisampleQuality; 2975 pRc->RcDesc.MipLevels = pResource->MipLevels; 2976 pRc->RcDesc.Fvf = pResource->Fvf; 2977 pRc->RcDesc.VidPnSourceId = pResource->VidPnSourceId; 2978 pRc->RcDesc.RefreshRate = pResource->RefreshRate; 2979 pRc->RcDesc.enmRotation = pResource->Rotation; 2980 pRc->cAllocations = pResource->SurfCount; 2981 2982 D3DDDICB_ALLOCATE *pDdiAllocate = vboxWddmRequestAllocAlloc(pResource); 2983 Assert(pDdiAllocate); 2984 if (pDdiAllocate) 2985 { 2986 Assert(pDdiAllocate->pPrivateDriverData); 2987 Assert(pDdiAllocate->PrivateDriverDataSize == sizeof (VBOXWDDM_RCINFO)); 2988 PVBOXWDDM_RCINFO pRcInfo = (PVBOXWDDM_RCINFO)pDdiAllocate->pPrivateDriverData; 2989 pRcInfo->fFlags = VBOXWDDM_RESOURCE_F_TYPE_GENERIC; 2990 pRcInfo->RcDesc = pRc->RcDesc; 2991 pRcInfo->cAllocInfos = pResource->SurfCount; 2992 2993 for (UINT i = 0; i < pResource->SurfCount; ++i) 2994 { 2995 D3DDDI_ALLOCATIONINFO *pDdiAllocI = &pDdiAllocate->pAllocationInfo[i]; 2996 Assert(pDdiAllocI->pPrivateDriverData); 2997 Assert(pDdiAllocI->PrivateDriverDataSize == sizeof (VBOXWDDM_ALLOCINFO)); 2998 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pDdiAllocI->pPrivateDriverData; 2999 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 3000 pDdiAllocI->hAllocation = NULL; 3001 pDdiAllocI->pSystemMem = pSurf->pSysMem; 3002 Assert((!!(pSurf->pSysMem)) == (pResource->Pool == D3DDDIPOOL_SYSTEMMEM)); 3003 pDdiAllocI->VidPnSourceId = pResource->VidPnSourceId; 3004 pDdiAllocI->Flags.Value = 0; 3005 if (pResource->Flags.Primary) 3006 pDdiAllocI->Flags.Primary = 1; 3007 3008 pAllocInfo->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; 3009 pAllocInfo->fFlags = pResource->Flags; 3010 pAllocInfo->SurfDesc.width = pSurf->Width; 3011 pAllocInfo->SurfDesc.height = pSurf->Height; 3012 pAllocInfo->SurfDesc.format = pResource->Format; 3013 pAllocInfo->SurfDesc.bpp = vboxWddmCalcBitsPerPixel(pResource->Format); 3014 3015 if (pSurf->SysMemPitch) 3016 { 3017 pAllocInfo->SurfDesc.pitch = pSurf->SysMemPitch; 2988 3018 #ifdef DEBUG 2989 UINT tst = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp);2990 Assert(tst == pSurf->SysMemPitch);3019 UINT tst = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp); 3020 Assert(tst == pSurf->SysMemPitch); 2991 3021 #endif 3022 } 3023 else 3024 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp); 3025 3026 pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 3027 pAllocInfo->SurfDesc.depth = pSurf->Depth; 3028 pAllocInfo->SurfDesc.slicePitch = pSurf->SysMemSlicePitch; 3029 pAllocInfo->SurfDesc.VidPnSourceId = pResource->VidPnSourceId; 3030 pAllocInfo->SurfDesc.RefreshRate = pResource->RefreshRate; 2992 3031 } 2993 else 2994 pAllocInfo->SurfDesc.pitch = vboxWddmCalcPitch(pSurf->Width, pAllocInfo->SurfDesc.bpp); 2995 2996 pAllocInfo->SurfDesc.cbSize = pAllocInfo->SurfDesc.pitch * pAllocInfo->SurfDesc.height; 2997 pAllocInfo->SurfDesc.depth = pSurf->Depth; 2998 pAllocInfo->SurfDesc.slicePitch = pSurf->SysMemSlicePitch; 2999 pAllocInfo->SurfDesc.VidPnSourceId = pResource->VidPnSourceId; 3000 pAllocInfo->SurfDesc.RefreshRate = pResource->RefreshRate; 3001 } 3002 3003 hr = pDevice->RtCallbacks.pfnAllocateCb(pDevice->hDevice, pAllocate); 3004 Assert(hr == S_OK); 3005 if (hr == S_OK) 3006 { 3007 Assert(pAllocate->hKMResource); 3008 PVBOXWDDMDISP_RESOURCE pRc = vboxResourceAlloc(pResource->SurfCount); 3009 Assert(pRc); 3010 if (pRc) 3011 { 3012 pRc->hResource = pResource->hResource; 3013 pRc->hKMResource = pAllocate->hKMResource; 3014 pRc->pDevice = pDevice; 3015 pRc->fFlags = pRcInfo->fFlags; 3016 pRc->RcDesc = pRcInfo->RcDesc; 3017 pRc->cAllocations = pRcInfo->cAllocInfos; 3018 for (UINT i = 0; i < pRcInfo->cAllocInfos; ++i) 3032 3033 hr = pDevice->RtCallbacks.pfnAllocateCb(pDevice->hDevice, pDdiAllocate); 3034 Assert(hr == S_OK); 3035 Assert(pDdiAllocate->hKMResource); 3036 if (hr == S_OK) 3037 { 3038 for (UINT i = 0; i < pResource->SurfCount; ++i) 3019 3039 { 3020 3040 PVBOXWDDMDISP_ALLOCATION pAllocation = &pRc->aAllocations[i]; 3021 D3DDDI_ALLOCATIONINFO * pDdiAllocInfo = &pDdiAllocInfos[i];3022 PVBOXWDDM_ALLOCINFO pAllocInfo = &pAllocInfos[i];3041 D3DDDI_ALLOCATIONINFO *pDdiAllocI = &pDdiAllocate->pAllocationInfo[i]; 3042 PVBOXWDDM_ALLOCINFO pAllocInfo = (PVBOXWDDM_ALLOCINFO)pDdiAllocI->pPrivateDriverData; 3023 3043 CONST D3DDDI_SURFACEINFO* pSurf = &pResource->pSurfList[i]; 3024 pAllocation->hAllocation = pDdiAllocI nfo->hAllocation;3044 pAllocation->hAllocation = pDdiAllocI->hAllocation; 3025 3045 pAllocation->enmType = VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC; 3026 3046 pAllocation->pvMem = (void*)pSurf->pSysMem; 3027 3047 pAllocation->SurfDesc = pAllocInfo->SurfDesc; 3028 3048 } 3029 3030 pResource->hResource = pRc;3031 // vboxResourceFree(pRc);3032 3049 } 3033 else 3034 { 3035 hr = E_OUTOFMEMORY; 3036 } 3037 } 3038 3039 RTMemFree(pvBuf); 3050 } 3051 else 3052 { 3053 hr = E_OUTOFMEMORY; 3054 } 3055 3056 if (hr == S_OK) 3057 pResource->hResource = pRc; 3058 else 3059 vboxResourceFree(pRc); 3040 3060 } 3041 3061 else … … 3091 3111 hr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc); 3092 3112 Assert(hr == S_OK); 3113 // for (UINT j = 0; j < pRc->cAllocations; ++j) 3114 // { 3115 // D3DDDICB_DEALLOCATE Dealloc; 3116 // Dealloc.hResource = NULL; 3117 // Dealloc.NumAllocations = 1; 3118 // Dealloc.HandleList = &pRc->aAllocations[j].hAllocation; 3119 // HRESULT tmpHr = pDevice->RtCallbacks.pfnDeallocateCb(pDevice->hDevice, &Dealloc); 3120 // Assert(tmpHr = S_OK); 3121 // } 3093 3122 } 3094 3123 } … … 3620 3649 OverInfo.VidPnSourceId = pData->VidPnSourceId; 3621 3650 OverInfo.OverlayInfo.hAllocation = pAlloc->hAllocation; 3651 Assert(pAlloc->hAllocation); 3622 3652 OverInfo.OverlayInfo.DstRect = *(D3DDDIRECT*)((void*)&pData->OverlayInfo.DstRect); 3623 3653 OverInfo.OverlayInfo.SrcRect = *(D3DDDIRECT*)((void*)&pData->OverlayInfo.SrcRect);
Note:
See TracChangeset
for help on using the changeset viewer.