- Timestamp:
- Apr 20, 2018 11:45:18 AM (7 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/Makefile.kmk
r70802 r71934 91 91 VBoxDispD3D_TEMPLATE = VBoxGuestR3DllMinVista 92 92 VBoxDispD3D_SDKS = ReorderCompilerIncs $(VBOX_WINDDK_GST_WLH) 93 VBoxDispD3D_DEFS = UNICODE _UNICODE VBOX_WITH_WDDM VBOXWDDMDISP LOG_TO_BACKDOOR LOG_TO_BACKDOOR_DRV VBOX_WITH_HGCM D3D_UMD_INTERFACE_VERSION=0x000C93 VBoxDispD3D_DEFS = UNICODE _UNICODE VBOX_WITH_WDDM VBOXWDDMDISP LOG_TO_BACKDOOR LOG_TO_BACKDOOR_DRV VBOX_WITH_HGCM 94 94 ifdef DEBUG_misha 95 95 VBoxDispD3D_DEFS += LOG_ENABLED -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.cpp
r71862 r71934 227 227 228 228 #define VBOX_QUERYTYPE_COUNT() RT_ELEMENTS(gVBoxQueryTypes) 229 230 static CRITICAL_SECTION g_VBoxCritSect;231 232 void vboxDispLock()233 {234 EnterCriticalSection(&g_VBoxCritSect);235 }236 237 void vboxDispUnlock()238 {239 LeaveCriticalSection(&g_VBoxCritSect);240 }241 242 void vboxDispLockInit()243 {244 InitializeCriticalSection(&g_VBoxCritSect);245 }246 229 247 230 … … 1975 1958 1976 1959 return hr; 1977 }1978 1979 /**1980 * DLL entry point.1981 */1982 BOOL WINAPI DllMain(HINSTANCE hInstance,1983 DWORD dwReason,1984 LPVOID lpReserved)1985 {1986 RT_NOREF(hInstance, lpReserved);1987 1988 switch (dwReason)1989 {1990 case DLL_PROCESS_ATTACH:1991 {1992 vboxDispLockInit();1993 1994 vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n"));1995 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER1996 vboxVDbgVEHandlerRegister();1997 #endif1998 int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);1999 AssertRC(rc);2000 if (RT_SUCCESS(rc))2001 {2002 // rc = VbglR3Init();2003 // AssertRC(rc);2004 // if (RT_SUCCESS(rc))2005 {2006 HRESULT hr = vboxDispCmInit();2007 Assert(hr == S_OK);2008 if (hr == S_OK)2009 {2010 VBoxDispD3DGlobalInit();2011 vboxVDbgPrint(("VBoxDispD3D: DLL loaded OK\n"));2012 return TRUE;2013 }2014 // VbglR3Term();2015 }2016 }2017 2018 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER2019 vboxVDbgVEHandlerUnregister();2020 #endif2021 break;2022 }2023 2024 case DLL_PROCESS_DETACH:2025 {2026 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER2027 vboxVDbgVEHandlerUnregister();2028 #endif2029 HRESULT hr = vboxDispCmTerm();2030 Assert(hr == S_OK);2031 if (hr == S_OK)2032 {2033 // VbglR3Term();2034 /// @todo RTR3Term();2035 VBoxDispD3DGlobalTerm();2036 return TRUE;2037 }2038 2039 break;2040 }2041 2042 default:2043 return TRUE;2044 }2045 return FALSE;2046 1960 } 2047 1961 … … 6570 6484 vboxVDbgPrint(("<== "__FUNCTION__", hAdapter(0x%p)\n", hAdapter)); 6571 6485 6572 #ifdef DEBUG6573 VbglR3Term();6574 #endif6575 6486 return S_OK; 6576 6487 } … … 6612 6523 } 6613 6524 6614 HRESULT APIENTRY OpenAdapter(__inout D3DDDIARG_OPENADAPTER* pOpenData) 6615 { 6616 #ifdef DEBUG 6617 VbglR3Init(); 6618 #endif 6619 6525 static HRESULT vboxDispQueryAdapterInfo(D3DDDIARG_OPENADAPTER const *pOpenData, VBOXWDDM_QAI **ppAdapterInfo) 6526 { 6527 VBOXWDDM_QAI *pAdapterInfo = (VBOXWDDM_QAI *)RTMemAllocZ(sizeof(VBOXWDDM_QAI)); 6528 AssertReturn(pAdapterInfo, E_OUTOFMEMORY); 6529 6530 D3DDDICB_QUERYADAPTERINFO DdiQuery; 6531 DdiQuery.PrivateDriverDataSize = sizeof(VBOXWDDM_QAI); 6532 DdiQuery.pPrivateDriverData = pAdapterInfo; 6533 HRESULT hr = pOpenData->pAdapterCallbacks->pfnQueryAdapterInfoCb(pOpenData->hAdapter, &DdiQuery); 6534 AssertReturnStmt(SUCCEEDED(hr), RTMemFree(pAdapterInfo), hr); 6535 6536 /* Check that the miniport version match display version. */ 6537 if (pAdapterInfo->u32Version == VBOXVIDEOIF_VERSION) 6538 { 6539 *ppAdapterInfo = pAdapterInfo; 6540 } 6541 else 6542 { 6543 LOGREL_EXACT((__FUNCTION__": miniport version mismatch, expected (%d), but was (%d)\n", 6544 VBOXVIDEOIF_VERSION, pAdapterInfo->u32Version)); 6545 hr = E_FAIL; 6546 } 6547 6548 return hr; 6549 } 6550 6551 static HRESULT vboxDispAdapterInit(D3DDDIARG_OPENADAPTER const *pOpenData, VBOXWDDM_QAI *pAdapterInfo, 6552 PVBOXWDDMDISP_ADAPTER *ppAdapter) 6553 { 6554 #ifdef VBOX_WITH_VIDEOHWACCEL 6555 Assert(pAdapterInfo->cInfos >= 1); 6556 PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_ADAPTER, 6557 aHeads[pAdapterInfo->cInfos])); 6558 #else 6559 Assert(pAdapterInfo->cInfos == 0); 6560 PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(sizeof(VBOXWDDMDISP_ADAPTER)); 6561 #endif 6562 AssertReturn(pAdapter, E_OUTOFMEMORY); 6563 6564 pAdapter->hAdapter = pOpenData->hAdapter; 6565 pAdapter->uIfVersion = pOpenData->Interface; 6566 pAdapter->uRtVersion = pOpenData->Version; 6567 pAdapter->RtCallbacks = *pOpenData->pAdapterCallbacks; 6568 pAdapter->enmHwType = pAdapterInfo->enmHwType; 6569 if (pAdapter->enmHwType == VBOXVIDEO_HWTYPE_CROGL) 6570 pAdapter->u32VBox3DCaps = pAdapterInfo->u.crogl.u32VBox3DCaps; 6571 pAdapter->AdapterInfo = *pAdapterInfo; 6572 #ifdef VBOX_WITH_VIDEOHWACCEL 6573 pAdapter->cHeads = pAdapterInfo->cInfos; 6574 for (uint32_t i = 0; i < pAdapter->cHeads; ++i) 6575 pAdapter->aHeads[i].Vhwa.Settings = pAdapterInfo->aInfos[i]; 6576 #endif 6577 6578 *ppAdapter = pAdapter; 6579 return S_OK; 6580 } 6581 6582 HRESULT APIENTRY OpenAdapter(__inout D3DDDIARG_OPENADAPTER *pOpenData) 6583 { 6620 6584 VBOXDISP_DDI_PROLOGUE_GLBL(); 6621 6585 6622 vboxVDbgPrint(("==> "__FUNCTION__"\n")); 6623 6624 #if 0 //def DEBUG_misha 6625 DWORD dwVersion = 0; 6626 DWORD dwMajorVersion = 0; 6627 DWORD dwMinorVersion = 0; 6628 dwVersion = GetVersion(); 6629 dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); 6630 dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); 6631 6632 if (dwMajorVersion == 6 && dwMinorVersion <= 1 && VBOXVDBG_IS_DWM()) 6633 { 6634 exit(0); 6635 return E_FAIL; 6636 } 6637 #endif 6638 6639 // vboxDispLock(); 6640 6641 HRESULT hr = E_FAIL; 6642 6643 do 6644 { 6586 LOG_EXACT(("==> "__FUNCTION__"\n")); 6645 6587 6646 6588 LOGREL(("Built %s %s", __DATE__, __TIME__)); 6647 6589 6648 VBOXWDDM_QAI Query; 6649 D3DDDICB_QUERYADAPTERINFO DdiQuery; 6650 DdiQuery.PrivateDriverDataSize = sizeof(Query); 6651 DdiQuery.pPrivateDriverData = &Query; 6652 hr = pOpenData->pAdapterCallbacks->pfnQueryAdapterInfoCb(pOpenData->hAdapter, &DdiQuery); 6653 Assert(hr == S_OK); 6654 if (hr != S_OK) 6655 { 6656 vboxVDbgPrintR((__FUNCTION__": pfnQueryAdapterInfoCb failed, hr (%d)\n", hr)); 6657 hr = E_FAIL; 6658 break; 6659 } 6660 6661 /* check the miniport version match display version */ 6662 if (Query.u32Version != VBOXVIDEOIF_VERSION) 6663 { 6664 vboxVDbgPrintR((__FUNCTION__": miniport version mismatch, expected (%d), but was (%d)\n", 6665 VBOXVIDEOIF_VERSION, 6666 Query.u32Version)); 6667 hr = E_FAIL; 6668 break; 6669 } 6670 6590 VBOXWDDM_QAI *pAdapterInfo = NULL; 6591 PVBOXWDDMDISP_ADAPTER pAdapter = NULL; 6592 6593 /* Query the miniport about virtual hardware capabilities. */ 6594 HRESULT hr = vboxDispQueryAdapterInfo(pOpenData, &pAdapterInfo); 6595 if (SUCCEEDED(hr)) 6596 { 6597 6598 hr = vboxDispAdapterInit(pOpenData, pAdapterInfo, &pAdapter); 6599 if (SUCCEEDED(hr)) 6600 { 6601 if (!vboxDispIsDDraw(pOpenData)) 6602 { 6603 /* 3D adapter. */ 6604 VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL(); 6605 6606 /* Try enable the 3D. */ 6607 hr = VBoxDispD3DGlobalOpen(&pAdapter->D3D, &pAdapter->Formats); 6608 if (hr == S_OK) 6609 { 6610 LOG(("SUCCESS 3D Enabled, pAdapter (0x%p)", pAdapter)); 6611 6612 /* Flag indicating that the adapter instance is running in 3D mode. */ 6613 pAdapter->f3D = (pAdapter->D3D.pD3D9If != NULL); 6614 } 6615 else 6616 WARN(("VBoxDispD3DOpen failed, hr (%d)", hr)); 6617 } 6671 6618 #ifdef VBOX_WITH_VIDEOHWACCEL 6672 Assert(Query.cInfos >= 1); 6673 PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_ADAPTER, aHeads[Query.cInfos])); 6674 #else 6675 Assert(Query.cInfos == 0); 6676 PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(sizeof(VBOXWDDMDISP_ADAPTER)); 6677 #endif 6678 Assert(pAdapter); 6679 if (pAdapter) 6680 { 6681 pAdapter->hAdapter = pOpenData->hAdapter; 6682 pAdapter->uIfVersion = pOpenData->Interface; 6683 pAdapter->uRtVersion= pOpenData->Version; 6684 pAdapter->RtCallbacks = *pOpenData->pAdapterCallbacks; 6685 6686 pAdapter->enmHwType = Query.enmHwType; 6687 6688 if (Query.enmHwType == VBOXVIDEO_HWTYPE_CROGL) 6689 pAdapter->u32VBox3DCaps = Query.u.crogl.u32VBox3DCaps; 6690 6691 #ifdef VBOX_WITH_VIDEOHWACCEL 6692 pAdapter->cHeads = Query.cInfos; 6693 #endif 6694 6619 else 6620 { 6621 /* 2D adapter. */ 6622 hr = VBoxDispD3DGlobal2DFormatsInit(pAdapter); 6623 if (FAILED(hr)) 6624 WARN(("VBoxDispD3DGlobal2DFormatsInit failed hr 0x%x", hr)); 6625 } 6626 #endif 6627 } 6628 } 6629 6630 if (SUCCEEDED(hr)) 6631 { 6632 VBOXDISPPROFILE_DDI_INIT_ADP(pAdapter); 6633 6634 /* Return data to the OS. */ 6695 6635 pOpenData->hAdapter = pAdapter; 6696 6636 pOpenData->pAdapterFuncs->pfnGetCaps = vboxWddmDispGetCaps; 6697 6637 pOpenData->pAdapterFuncs->pfnCreateDevice = vboxWddmDispCreateDevice; 6698 6638 pOpenData->pAdapterFuncs->pfnCloseAdapter = vboxWddmDispCloseAdapter; 6699 pOpenData->DriverVersion = D3D_UMD_INTERFACE_VERSION; 6700 if (!vboxDispIsDDraw(pOpenData)) 6701 { 6702 do 6703 { 6704 { 6705 VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL(); 6706 /* try enable the 3D */ 6707 hr = VBoxDispD3DGlobalOpen(&pAdapter->D3D, &pAdapter->Formats); 6639 pOpenData->DriverVersion = D3D_UMD_INTERFACE_VERSION_VISTA; 6640 } 6641 else 6642 { 6643 WARN(("OpenAdapter failed hr 0x%x", hr)); 6644 RTMemFree(pAdapter); 6645 } 6646 6647 RTMemFree(pAdapterInfo); 6648 6649 LOG_EXACT(("<== "__FUNCTION__", hr (%x)\n", hr)); 6650 return hr; 6651 } 6652 6653 6654 /** 6655 * DLL entry point. 6656 */ 6657 BOOL WINAPI DllMain(HINSTANCE hInstance, 6658 DWORD dwReason, 6659 LPVOID lpReserved) 6660 { 6661 RT_NOREF(hInstance, lpReserved); 6662 6663 switch (dwReason) 6664 { 6665 case DLL_PROCESS_ATTACH: 6666 { 6667 vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n")); 6668 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER 6669 vboxVDbgVEHandlerRegister(); 6670 #endif 6671 int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 6672 AssertRC(rc); 6673 if (RT_SUCCESS(rc)) 6674 { 6675 // rc = VbglR3Init(); 6676 // AssertRC(rc); 6677 // if (RT_SUCCESS(rc)) 6678 { 6679 HRESULT hr = vboxDispCmInit(); 6680 Assert(hr == S_OK); 6708 6681 if (hr == S_OK) 6709 6682 { 6710 LOG(("SUCCESS 3D Enabled, pAdapter (0x%p)", pAdapter)); 6711 break; 6683 VBoxDispD3DGlobalInit(); 6684 vboxVDbgPrint(("VBoxDispD3D: DLL loaded OK\n")); 6685 return TRUE; 6712 6686 } 6713 else 6714 WARN(("VBoxDispD3DOpen failed, hr (%d)", hr)); 6715 6716 } 6717 } while (0); 6718 6719 /* Flag indicating that the adapter instance is running in 3D mode. */ 6720 pAdapter->f3D = (pAdapter->D3D.pD3D9If != NULL); 6721 } 6722 #ifdef VBOX_WITH_VIDEOHWACCEL 6723 if (!VBOXDISPMODE_IS_3D(pAdapter)) 6724 { 6725 for (uint32_t i = 0; i < pAdapter->cHeads; ++i) 6726 { 6727 pAdapter->aHeads[i].Vhwa.Settings = Query.aInfos[i]; 6728 } 6729 hr = VBoxDispD3DGlobal2DFormatsInit(pAdapter); 6730 if (!SUCCEEDED(hr)) 6731 { 6732 WARN(("VBoxDispD3DGlobal2DFormatsInit failed hr 0x%x", hr)); 6733 } 6734 } 6735 #endif 6736 6737 if (SUCCEEDED(hr)) 6738 { 6739 VBOXDISPPROFILE_DDI_INIT_ADP(pAdapter); 6740 hr = S_OK; 6687 // VbglR3Term(); 6688 } 6689 } 6690 6691 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER 6692 vboxVDbgVEHandlerUnregister(); 6693 #endif 6741 6694 break; 6742 6695 } 6743 else 6744 { 6745 WARN(("OpenAdapter failed hr 0x%x", hr)); 6746 } 6747 6748 RTMemFree(pAdapter); 6749 } 6750 else 6751 { 6752 vboxVDbgPrintR((__FUNCTION__": RTMemAllocZ returned NULL\n")); 6753 hr = E_OUTOFMEMORY; 6754 } 6755 6756 } while (0); 6757 6758 // vboxDispUnlock(); 6759 6760 vboxVDbgPrint(("<== "__FUNCTION__", hr (%d)\n", hr)); 6761 6762 return hr; 6763 } 6696 6697 case DLL_PROCESS_DETACH: 6698 { 6699 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER 6700 vboxVDbgVEHandlerUnregister(); 6701 #endif 6702 HRESULT hr = vboxDispCmTerm(); 6703 Assert(hr == S_OK); 6704 if (hr == S_OK) 6705 { 6706 // VbglR3Term(); 6707 /// @todo RTR3Term(); 6708 VBoxDispD3DGlobalTerm(); 6709 return TRUE; 6710 } 6711 6712 break; 6713 } 6714 6715 default: 6716 return TRUE; 6717 } 6718 return FALSE; 6719 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispD3D.h
r71862 r71934 77 77 D3DDDI_ADAPTERCALLBACKS RtCallbacks; 78 78 79 VBOXVIDEO_HWTYPE enmHwType; /* VBOXVIDEO_HWTYPE * */79 VBOXVIDEO_HWTYPE enmHwType; /* VBOXVIDEO_HWTYPE_* */ 80 80 81 81 VBOXWDDMDISP_D3D D3D; … … 83 83 uint32_t u32VBox3DCaps; 84 84 bool f3D; 85 bool fReserved[3]; 86 87 VBOXWDDM_QAI AdapterInfo; 88 85 89 #ifdef VBOX_WDDMDISP_WITH_PROFILE 86 90 VBoxDispProfileFpsCounter ProfileDdiFps;
Note:
See TracChangeset
for help on using the changeset viewer.