VBoxDispKmt.cpp revision 4caf19ef0484a5991eed5210bb56cb1104835fc6
/* $Id$ */
/** @file
* VBoxVideo Display D3D User mode dll
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "VBoxDispD3DCmn.h"
#ifndef NT_SUCCESS
#endif
{
{
bool bSupported = true;
bool bSupportedWin8 = true;
pCallbacks->pfnD3DKMTOpenAdapterFromHdc = (PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress(pCallbacks->hGdi32, "D3DKMTOpenAdapterFromHdc");
pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName = (PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME)GetProcAddress(pCallbacks->hGdi32, "D3DKMTOpenAdapterFromGdiDisplayName");
Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName = %p\n", pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName));
pCallbacks->pfnD3DKMTCloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCloseAdapter");
pCallbacks->pfnD3DKMTCreateDevice = (PFND3DKMT_CREATEDEVICE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateDevice");
pCallbacks->pfnD3DKMTDestroyDevice = (PFND3DKMT_DESTROYDEVICE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyDevice");
pCallbacks->pfnD3DKMTCreateContext = (PFND3DKMT_CREATECONTEXT)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateContext");
pCallbacks->pfnD3DKMTDestroyContext = (PFND3DKMT_DESTROYCONTEXT)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyContext");
pCallbacks->pfnD3DKMTCreateAllocation = (PFND3DKMT_CREATEALLOCATION)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateAllocation");
pCallbacks->pfnD3DKMTDestroyAllocation = (PFND3DKMT_DESTROYALLOCATION)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyAllocation");
pCallbacks->pfnD3DKMTEnumAdapters = (PFND3DKMT_ENUMADAPTERS)GetProcAddress(pCallbacks->hGdi32, "D3DKMTEnumAdapters");
/* this present starting win8 release preview only, so keep going if it is not available,
* i.e. do not clear the bSupported on its absence */
#ifdef DEBUG_misha
/* just a debug assertion to test it on win8 */
#endif
pCallbacks->pfnD3DKMTOpenAdapterFromLuid = (PFND3DKMT_OPENADAPTERFROMLUID)GetProcAddress(pCallbacks->hGdi32, "D3DKMTOpenAdapterFromLuid");
Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromLuid = %p\n", pCallbacks->pfnD3DKMTOpenAdapterFromLuid));
/* this present starting win8 release preview only, so keep going if it is not available,
* i.e. do not clear the bSupported on its absence */
#ifdef DEBUG_misha
/* just a debug assertion to test it on win8 */
#endif
/*Assert(bSupported);*/
if (bSupported)
{
if (bSupportedWin8)
else
return S_OK;
}
else
{
hr = E_NOINTERFACE;
}
}
else
{
Assert(0);
}
return hr;
}
{
return S_OK;
}
{
for (int i = 0; ; ++i)
{
&DDev, 0 /* DWORD dwFlags*/))
{
{
if (hDc)
{
return S_OK;
}
else
{
Assert(0);
break;
}
}
}
else
{
// BP_WARN();
#ifdef DEBUG_misha
#endif
{
}
break;
}
}
return hr;
}
static HRESULT vboxDispKmtOpenAdapterViaHdc(PVBOXDISPKMT_CALLBACKS pCallbacks, PVBOXDISPKMT_ADAPTER pAdapter)
{
return hr;
#ifdef DEBUG_misha
/* may fail with xpdm driver */
#endif
if (NT_SUCCESS(Status))
{
return S_OK;
}
else
{
}
return hr;
}
static HRESULT vboxDispKmtOpenAdapterViaLuid(PVBOXDISPKMT_CALLBACKS pCallbacks, PVBOXDISPKMT_ADAPTER pAdapter)
{
return E_NOTIMPL;
D3DKMT_ENUMADAPTERS EnumAdapters = {0};
#ifdef DEBUG_misha
#endif
if (!NT_SUCCESS(Status))
return E_FAIL;
/* try the same twice: if we fail to open the adapter containing present sources,
* try to open any adapter */
for (ULONG f = 0; f < 2; ++f)
{
{
{
#ifdef DEBUG_misha
#endif
if (NT_SUCCESS(Status))
{
return S_OK;
}
}
}
}
#ifdef DEBUG_misha
Assert(0);
#endif
return E_FAIL;
}
{
return S_OK;
return S_OK;
return hr;
}
{
if (!Status)
{
return S_OK;
}
return E_FAIL;
}
{
if (!Status)
{
return S_OK;
}
return E_FAIL;
}
{
if (!Status)
{
return S_OK;
}
return E_FAIL;
}
{
VBOXWDDM_CREATECONTEXT_INFO Info = {0};
D3DKMT_CREATECONTEXT ContextData = {0};
ContextData.ClientHint = enmType == VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL ? D3DKMT_CLIENTHINT_OPENGL : D3DKMT_CLIENTHINT_DX9;
if (!Status)
{
return S_OK;
}
return E_FAIL;
}
{
NTSTATUS Status = pContext->pDevice->pAdapter->pCallbacks->pfnD3DKMTDestroyContext(&DestroyContextData);
if (!Status)
return S_OK;
return E_FAIL;
}