VBoxDispD3D.cpp revision 727fa5661ba0158f74b72e445a8544259b034ab0
/* $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.
*/
#define INITGUID
#include <iprt/initterm.h>
#include <VBox/VBoxGuestLib.h>
#include "VBoxDispD3DCmn.h"
#include "VBoxDispD3D.h"
#include "VBoxScreen.h"
#include <VBox/VBoxCrHgsmi.h>
#ifdef VBOX_WDDMDISP_WITH_PROFILE
#include "VBoxDispProfile.h"
/* uncomment to enable particular logging */
//#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_ENABLE
#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE() VBOXDISPPROFILE_FUNCTION_LOGGER_DEFINE(g_VBoxDispProfileDDI)
#define VBOXDDIROFILE_FUNCTION_LOGGER_DUMP() do {\
} while (0)
#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET() do {\
} while (0)
#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {\
} while (0)
#else
#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE() do {} while(0)
#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DUMP() do {} while(0)
#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET() do {} while(0)
#define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {} while (0)
#endif
#define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE() VBOXDISPPROFILE_STATISTIC_LOGGER_DEFINE(&g_VBoxDispFpsDDI)
#define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {\
} while (0)
#define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev) do { \
{ \
} \
} while (0)
#else
#define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE() do {} while(0)
#define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {} while (0)
#define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev) do {} while (0)
#endif
#define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE() \
#define VBOXDISPPROFILE_DDI_DUMPRESET(_pDev) do {\
} while (0)
#define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {\
} while (0)
#else
#define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE() do {} while (0)
#define VBOXDISPPROFILE_DDI_DUMPRESET(_pDev) do {} while (0)
#define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {} while (0)
#endif
#ifdef VBOXDISPMP_TEST
#endif
#define VBOXDISP_WITH_WINE_BB_WORKAROUND
//#define VBOXWDDMOVERLAY_TEST
static FORMATOP gVBoxFormatOps3D[] = {
FORMATOP_SRGBWRITE|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_SRGBWRITE|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
{D3DDDIFMT_D16, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_D24S8, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_D24X8, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_X8D24, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_D32F_LOCKABLE, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_S8D24, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_NOTEXCOORDWRAPNORMIP, 0, 0, 0},
0|
0|
0|
FORMATOP_NOTEXCOORDWRAPNORMIP, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_OVERLAY, 0, 0, 0},
{D3DDDIFMT_BINARYBUFFER, FORMATOP_OFFSCREENPLAIN, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_AUTOGENMIPMAP|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
};
static FORMATOP gVBoxFormatOpsBase[] = {
{D3DDDIFMT_X8R8G8B8, FORMATOP_DISPLAYMODE, 0, 0, 0},
{D3DDDIFMT_R8G8B8, FORMATOP_DISPLAYMODE, 0, 0, 0},
{D3DDDIFMT_R5G6B5, FORMATOP_DISPLAYMODE, 0, 0, 0},
{D3DDDIFMT_P8, FORMATOP_DISPLAYMODE, 0, 0, 0},
};
static DDSURFACEDESC gVBoxSurfDescsBase[] = {
{
sizeof (DDSURFACEDESC), /* DWORD dwSize; */
0, /* DWORD dwHeight; */
0, /* DWORD dwWidth; */
{
0, /* Union */
/* LONG lPitch; */
/* DWORD dwLinearSize; */
},
0, /* DWORD dwBackBufferCount; */
{
0, /* Union */
/* DWORD dwMipMapCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwRefreshRate; */
},
0, /* DWORD dwAlphaBitDepth; */
0, /* DWORD dwReserved; */
NULL, /* LPVOID lpSurface; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestBlt; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcBlt; */
{
sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
DDPF_RGB, /* DWORD dwFlags; */
0, /* DWORD dwFourCC; */
{
32, /* union */
/* DWORD dwRGBBitCount; */
/* DWORD dwYUVBitCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwAlphaBitDepth; */
/* DWORD dwLuminanceBitCount; */
/* DWORD dwBumpBitCount; */
},
{
0xff0000, /* union */
/* DWORD dwRBitMask; */
/* DWORD dwYBitMask; */
/* DWORD dwStencilBitDepth; */
/* DWORD dwLuminanceBitMask; */
/* DWORD dwBumpDuBitMask; */
},
{
0xff00,
/* DWORD dwGBitMask; */
/* DWORD dwUBitMask; */
/* DWORD dwZBitMask; */
/* DWORD dwBumpDvBitMask; */
},
{
0xff,
/* DWORD dwBBitMask; */
/* DWORD dwVBitMask; */
/* DWORD dwStencilBitMask; */
/* DWORD dwBumpLuminanceBitMask; */
},
{
0,
/* DWORD dwRGBAlphaBitMask; */
/* DWORD dwYUVAlphaBitMask; */
/* DWORD dwLuminanceAlphaBitMask; */
/* DWORD dwRGBZBitMask; */
/* DWORD dwYUVZBitMask; */
},
}, /* DDPIXELFORMAT ddpfPixelFormat; */
{
| DDSCAPS_VISIBLE /* DWORD dwCaps; */
} /* DDSCAPS ddsCaps; */
},
{
sizeof (DDSURFACEDESC), /* DWORD dwSize; */
0, /* DWORD dwHeight; */
0, /* DWORD dwWidth; */
{
0, /* Union */
/* LONG lPitch; */
/* DWORD dwLinearSize; */
},
0, /* DWORD dwBackBufferCount; */
{
0, /* Union */
/* DWORD dwMipMapCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwRefreshRate; */
},
0, /* DWORD dwAlphaBitDepth; */
0, /* DWORD dwReserved; */
NULL, /* LPVOID lpSurface; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestBlt; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcBlt; */
{
sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
DDPF_RGB, /* DWORD dwFlags; */
0, /* DWORD dwFourCC; */
{
24, /* union */
/* DWORD dwRGBBitCount; */
/* DWORD dwYUVBitCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwAlphaBitDepth; */
/* DWORD dwLuminanceBitCount; */
/* DWORD dwBumpBitCount; */
},
{
0xff0000, /* union */
/* DWORD dwRBitMask; */
/* DWORD dwYBitMask; */
/* DWORD dwStencilBitDepth; */
/* DWORD dwLuminanceBitMask; */
/* DWORD dwBumpDuBitMask; */
},
{
0xff00,
/* DWORD dwGBitMask; */
/* DWORD dwUBitMask; */
/* DWORD dwZBitMask; */
/* DWORD dwBumpDvBitMask; */
},
{
0xff,
/* DWORD dwBBitMask; */
/* DWORD dwVBitMask; */
/* DWORD dwStencilBitMask; */
/* DWORD dwBumpLuminanceBitMask; */
},
{
0,
/* DWORD dwRGBAlphaBitMask; */
/* DWORD dwYUVAlphaBitMask; */
/* DWORD dwLuminanceAlphaBitMask; */
/* DWORD dwRGBZBitMask; */
/* DWORD dwYUVZBitMask; */
},
}, /* DDPIXELFORMAT ddpfPixelFormat; */
{
| DDSCAPS_VISIBLE /* DWORD dwCaps; */
} /* DDSCAPS ddsCaps; */
},
{
sizeof (DDSURFACEDESC), /* DWORD dwSize; */
0, /* DWORD dwHeight; */
0, /* DWORD dwWidth; */
{
0, /* Union */
/* LONG lPitch; */
/* DWORD dwLinearSize; */
},
0, /* DWORD dwBackBufferCount; */
{
0, /* Union */
/* DWORD dwMipMapCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwRefreshRate; */
},
0, /* DWORD dwAlphaBitDepth; */
0, /* DWORD dwReserved; */
NULL, /* LPVOID lpSurface; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestBlt; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcBlt; */
{
sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
DDPF_RGB, /* DWORD dwFlags; */
0, /* DWORD dwFourCC; */
{
16, /* union */
/* DWORD dwRGBBitCount; */
/* DWORD dwYUVBitCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwAlphaBitDepth; */
/* DWORD dwLuminanceBitCount; */
/* DWORD dwBumpBitCount; */
},
{
0xf800, /* union */
/* DWORD dwRBitMask; */
/* DWORD dwYBitMask; */
/* DWORD dwStencilBitDepth; */
/* DWORD dwLuminanceBitMask; */
/* DWORD dwBumpDuBitMask; */
},
{
0x7e0,
/* DWORD dwGBitMask; */
/* DWORD dwUBitMask; */
/* DWORD dwZBitMask; */
/* DWORD dwBumpDvBitMask; */
},
{
0x1f,
/* DWORD dwBBitMask; */
/* DWORD dwVBitMask; */
/* DWORD dwStencilBitMask; */
/* DWORD dwBumpLuminanceBitMask; */
},
{
0,
/* DWORD dwRGBAlphaBitMask; */
/* DWORD dwYUVAlphaBitMask; */
/* DWORD dwLuminanceAlphaBitMask; */
/* DWORD dwRGBZBitMask; */
/* DWORD dwYUVZBitMask; */
},
}, /* DDPIXELFORMAT ddpfPixelFormat; */
{
| DDSCAPS_VISIBLE /* DWORD dwCaps; */
} /* DDSCAPS ddsCaps; */
},
};
static D3DDDIQUERYTYPE gVBoxQueryTypes[] = {
// D3DDDIQUERYTYPE_OCCLUSION
};
static CRITICAL_SECTION g_VBoxCritSect;
void vboxDispLock()
{
}
void vboxDispUnlock()
{
}
void vboxDispLockInit()
{
}
#ifdef VBOX_WITH_CRHGSMI
/* cr hgsmi */
static VBOXCRHGSMI_CALLBACKS g_VBoxCrHgsmiCallbacks = {0};
#define VBOXUHGSMIKMT_PERTHREAD
#ifdef VBOXUHGSMIKMT_PERTHREAD
#else
#endif
#endif
#ifdef VBOX_WITH_CRHGSMI
{
#ifdef VBOX_WITH_CRHGSMI
vboxDispLock(); /* the lock is needed here only to ensure callbacks are not initialized & used concurrently
* @todo: make a separate call used to init the per-thread info and make the VBoxDispCrHgsmiInit be called only once */
#ifdef DEBUG_misha
#endif
if (pHgsmi)
{
{
}
}
#endif
return VINF_SUCCESS;
}
{
return VINF_SUCCESS;
}
{
#ifdef VBOX_WITH_CRHGSMI
#ifdef DEBUG_misha
#endif
if (pHgsmi)
{
}
#endif
return NULL;
}
static HRESULT vboxUhgsmiGlobalRetain()
{
vboxDispLock();
if (!g_cVBoxUhgsmiKmtRefs)
{
/* can not do it here because callbacks may not be set yet
* @todo: need to call the cr lib from here to get the callbacks
* rather than making the cr lib call us */
// if (hr == S_OK)
// {
// g_VBoxUhgsmiKmt.BasePrivate.hClient = g_VBoxCrHgsmiCallbacks.pfnClientCreate(&g_VBoxUhgsmiKmt.BasePrivate.Base);
// Assert(g_VBoxUhgsmiKmt.BasePrivate.hClient);
// }
}
{
}
return hr;
}
static HRESULT vboxUhgsmiGlobalRelease()
{
vboxDispLock();
if (!g_cVBoxUhgsmiKmtRefs)
{
}
return hr;
}
{
}
DECLINLINE(void) vboxDispCrHgsmiClientClear()
{
}
{
return hr;
}
{
return S_OK;
}
class VBoxDispCrHgsmiScope
{
public:
{
}
{
}
private:
};
#define VBOXDISPCRHGSMI_SCOPE_SET_DEV(_pDev) VBoxDispCrHgsmiScope __vboxCrHgsmiScope(&(_pDev)->Uhgsmi.BasePrivate)
#define VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL() VBoxDispCrHgsmiScope __vboxCrHgsmiScope(&g_VBoxUhgsmiKmt.BasePrivate)
#else
#define VBOXDISPCRHGSMI_SCOPE_SET_DEV(_pDev) do {} while(0)
#define VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL() do {} while(0)
VBOXWDDMDISP_DECL(int) VBoxDispCrHgsmiInit(void*)
{
return VERR_NOT_IMPLEMENTED;
}
{
return VERR_NOT_IMPLEMENTED;
}
{
return NULL;
}
#endif
typedef struct VBOXWDDMDISP_NSCADD
{
{
{
if (pAlloc->fDirtyWrite)
--pData->cAllocationList;
++pData->cAllocations;
++pData->pAllocationList;
}
else
return hr;
}
static BOOLEAN vboxWddmDalCheckRemove(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc)
{
{
}
return fRemoved;
}
{
do
{
if (bReinitRenderData)
{
NscAdd.cAllocations = 0;
return E_FAIL;
}
PVBOXWDDMDISP_ALLOCATION pAlloc = RTListGetFirst(&pDevice->DirtyAllocList, VBOXWDDMDISP_ALLOCATION, DirtyAllocListEntry);
if (pAlloc)
{
{
continue;
}
}
else
{
if (!NscAdd.cAllocations)
break;
}
D3DDDICB_RENDER RenderData = {0};
RenderData.CommandLength = pDevice->DefaultContext.ContextInfo.CommandBufferSize - NscAdd.cbCommandBuffer;
RenderData.CommandOffset = 0;
RenderData.NumAllocations = pDevice->DefaultContext.ContextInfo.AllocationListSize - NscAdd.cAllocationList;
RenderData.NumPatchLocations = pDevice->DefaultContext.ContextInfo.PatchLocationListSize - NscAdd.cPatchLocationList;
// RenderData.NewCommandBufferSize = sizeof (VBOXVDMACMD) + 4 * (100);
// RenderData.NewAllocationListSize = 100;
// RenderData.NewPatchLocationListSize = 100;
{
}
else
break;
} while (1);
return S_OK;
}
#define VBOX_WDDM_SHRC_WO_NOTIFY
static BOOLEAN vboxWddmDalCheckAdd(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOLEAN fWrite)
{
#ifdef VBOX_WDDM_SHRC_WO_NOTIFY
|| !fWrite /* only write op matter */
#endif
)
{
#ifdef VBOX_WDDM_SHRC_WO_NOTIFY
Assert(!pAlloc->DirtyAllocListEntry.pNext || (!fWrite && pAlloc->hSharedHandle && pAlloc->fDirtyWrite));
#else
#endif
return FALSE;
}
{
}
return TRUE;
}
{
{
{
}
}
}
#ifdef VBOX_WITH_VIDEOHWACCEL
{
{
return true;
}
return false;
}
{
{
)
return true;
}
return false;
}
{
}
#endif
{
}
int vboxSurfDescMerge(DDSURFACEDESC *paDescs, uint32_t *pcDescs, uint32_t cMaxDescs, DDSURFACEDESC *pDesc)
{
return VERR_INVALID_PARAMETER;
{
{
{
}
return VINF_SUCCESS;
}
}
{
++cDescs;
return VINF_SUCCESS;
}
return VERR_BUFFER_OVERFLOW;
}
{
{
{
return VINF_SUCCESS;
}
}
{
++cOps;
return VINF_SUCCESS;
}
return VERR_BUFFER_OVERFLOW;
}
{
pAdapter->cFormstOps = 0;
pAdapter->cSurfDescs = 0;
{
{
if (pAdapter->paFormstOps)
{
}
else
return VERR_OUT_OF_RESOURCES;
/* @todo: do we need surface caps here ? */
}
}
#ifdef VBOX_WITH_VIDEOHWACCEL
else
{
/* just calc the max number of formats */
uint32_t cOverlayFormats = 0;
{
{
}
}
/* ensure the surf descs are 8 byte aligned */
if (pvBuf)
{
{
{
{
}
}
}
{
{
{
if (fourcc)
{
}
}
}
}
}
else
return VERR_OUT_OF_RESOURCES;
}
#endif
return VINF_SUCCESS;
}
{
if (pAdapter->paFormstOps)
}
{
}
{
PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs]));
if (pRc)
{
{
}
return pRc;
}
return NULL;
}
static void vboxWddmLockUnlockMemSynch(PVBOXWDDMDISP_ALLOCATION pAlloc, D3DLOCKED_RECT *pLockInfo, RECT *pRect, bool bToLockInfo)
{
if (!pRect)
{
{
if (bToLockInfo)
else
}
else
{
if (bToLockInfo)
{
}
else
{
}
{
}
}
}
else
{
/* @todo: this is not entirely correct */
if (bToLockInfo)
{
}
else
{
}
{
}
else
{
{
}
}
}
}
#if 0
{
/* we do not support stretching */
if (DstCopyWidth != SrcCopyWidth)
return E_FAIL;
if (DstCopyHeight != SrcCopyWidth)
return E_FAIL;
if (DstWidth == DstCopyWidth
&& SrcWidth == SrcCopyWidth
{
}
else
{
uint32_t offDstLineEnd = ((pDstCopyRect->left * dstBpp + 7) >> 3) + ((dstBpp * DstCopyWidth + 7) >> 3);
uint32_t offSrcLineEnd = ((pSrcCopyRect->left * srcBpp + 7) >> 3) + ((srcBpp * SrcCopyWidth + 7) >> 3);
for (uint32_t i = 0; ; ++i)
{
if (i == DstCopyHeight)
break;
pvDstStart += cbDstSkip;
pvSrcStart += cbSrcSkip;
}
}
return S_OK;
}
#endif
{
/* we do not support stretching */
return E_FAIL;
return E_FAIL;
{
}
else
{
for (uint32_t i = 0; ; ++i)
{
if (i == DstHeight)
break;
}
}
return S_OK;
}
static HRESULT vboxWddmSurfSynchMem(PVBOXWDDMDISP_RESOURCE pRc, PVBOXWDDMDISP_ALLOCATION pAllocation)
{
{
{
}
}
else
{
}
return hr;
}
{
/* @todo: check they are all equal */
}
{
/* @todo: check they are all equal */
return (D3DMULTISAMPLE_TYPE)enmType;
}
{
/* @todo: check they are all equal */
switch (enmPool)
{
case D3DDDIPOOL_SYSTEMMEM:
return D3DPOOL_SYSTEMMEM;
case D3DDDIPOOL_VIDEOMEMORY:
case D3DDDIPOOL_LOCALVIDMEM:
/* @todo: what would be proper here? */
return D3DPOOL_DEFAULT;
default:
Assert(0);
}
return D3DPOOL_DEFAULT;
}
{
/* @todo: @fixme: not entirely correct, need to check */
return (D3DRENDERSTATETYPE)enmType;
}
{
static const VBOXWDDMDISP_TSS_LOOKUP lookup[] =
{
};
}
{
if (fFlags.AutogenMipmap)
fUsage |= D3DUSAGE_DMAP;
if (fFlags.RenderTarget)
//below are wddm 1.1-specific
// if (fFlags.RestrictedContent)
// fUsage |= D3DUSAGE_RESTRICTED_CONTENT;
// if (fFlags.RestrictSharedAccess)
// fUsage |= D3DUSAGE_RESTRICT_SHARED_RESOURCE;
return fUsage;
}
{
if (fLockFlags.Discard)
if (fLockFlags.NoOverwrite)
if (fLockFlags.ReadOnly)
if (fLockFlags.DoNotWait)
return fFlags;
}
{
{
/* no flags other than [Begin|Continue|End]PresentToDwm are set */
return D3DTEXF_POINT;
}
{
/* no flags other than [Begin|Continue|End]PresentToDwm are set */
return D3DTEXF_LINEAR;
}
/* no flags other than [Begin|Continue|End]PresentToDwm are set */
return D3DTEXF_NONE;
}
/******/
static HRESULT vboxWddmRenderTargetSet(PVBOXWDDMDISP_DEVICE pDevice, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch);
{
}
static HRESULT vboxWddmSwapchainKmSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
struct
{
} Buf;
// Buf.SwapchainInfo.SwapchainInfo.Rect;
// Buf.SwapchainInfo.SwapchainInfo.u32Reserved;
{
// Assert(pSwapchain->aRTs[i].pAlloc->hAllocation);
++cAllocsKm;
}
{
D3DDDICB_ESCAPE DdiEscape = {0};
// DdiEscape.Flags.Value = 0;
DdiEscape.PrivateDriverDataSize = RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[Buf.SwapchainInfo.SwapchainInfo.cAllocs]);
#ifdef DEBUG_misha
#endif
{
}
}
return S_OK;
}
static HRESULT vboxWddmSwapchainKmDestroy(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
if (pSwapchain->hSwapchainKm)
{
/* submit empty swapchain to destroy the KM one */
pSwapchain->cRTs = 0;
}
return hr;
}
static HRESULT vboxWddmSwapchainDestroyIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
if (pSwapchain->pSwapChainIf)
{
#ifndef VBOXWDDM_WITH_VISIBLE_FB
{
}
#endif
return S_OK;
}
return S_OK;
}
DECLINLINE(VOID) vboxWddmSwapchainClear(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
{
}
/* first do a Km destroy to ensure all km->um region submissions are completed */
}
static VOID vboxWddmSwapchainDestroy(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
}
{
PVBOXWDDMDISP_SWAPCHAIN pCur = RTListGetFirst(&pDevice->SwapchainList, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
while (pCur)
{
{
}
}
}
{
PVBOXWDDMDISP_SWAPCHAIN pSwapchain = (PVBOXWDDMDISP_SWAPCHAIN)RTMemAllocZ(sizeof (VBOXWDDMDISP_SWAPCHAIN));
if (pSwapchain)
{
return pSwapchain;
}
return NULL;
}
DECLINLINE(VOID) vboxWddmSwapchainRtInit(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRt, PVBOXWDDMDISP_ALLOCATION pAlloc)
{
}
DECLINLINE(VOID) vboxWddmSwapchainBbAddTail(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bAssignAsBb)
{
++pSwapchain->cRTs;
{
pSwapchain->iBB = 0;
}
else if (bAssignAsBb)
{
}
{
}
}
{
}
{
return pSwapchain->cRTs;
}
DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainRtForAlloc(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc)
{
return NULL;
{
return &pSwapchain->aRTs[i];
}
/* should never happen */
Assert(0);
return NULL;
}
DECLINLINE(UINT) vboxWddmSwapchainRtIndex(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
{
return iRt;
}
DECLINLINE(VOID) vboxWddmSwapchainRtRemove(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
{
{
}
--pSwapchain->cRTs;
if (pSwapchain->cRTs)
{
{
--pSwapchain->iBB;
}
{
pSwapchain->iBB = 0;
}
}
else
{
}
}
#if 0
DECLINLINE(VOID) vboxWddmSwapchainSetBb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
{
}
/* the paRemoved buffer should at least contain VBOXWDDMDISP_MAX_SWAPCHAIN_SIZE elements,
* the function does not validate its size in any way */
static BOOL vboxWddmSwapchainAdjust(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pBbAlloc, PUINT pcRemoved, PVBOXWDDMDISP_ALLOCATION paRemoved)
{
if (pCurBb)
{
{
/* determine whether we need to add the current BB
* or remove part or all of the current RTs in the swapchain */
if (pCorrectRt)
{
++cRemoved;
}
else
{
/* check if the pCurBbRt stored in the swapchain match those of the pBbAlloc */
{
{
{
++cRemoved;
}
else
{
++i;
}
}
}
else
{
/* remove all */
{
++cRemoved;
}
}
}
}
}
else
{
}
if (!bChanged)
{
}
return bChanged;
}
#endif
static PVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainFindCreate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc, BOOL *pbNeedPresent)
{
if (pSwapchain)
{
/* check if this is what we expect */
{
{
/* the current front-buffer present is requested, don't do anything */
*pbNeedPresent = FALSE;
return pSwapchain;
}
/* bad, @todo: correct the swapchain by either removing the Rt and adding it to another swapchain
* or by removing the pBbAlloc out of it */
Assert(0);
}
}
*pbNeedPresent = TRUE;
if (!pSwapchain)
{
/* first search for the swapchain the alloc might be added to */
PVBOXWDDMDISP_SWAPCHAIN pCur = RTListGetFirst(&pDevice->SwapchainList, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
while (pCur)
{
&& vboxWddmSwapchainRtIndex(pCur, pRt) == 0) /* <- in case we add a rt to the swapchain on present this would mean
* that the last RT in the swapchain array is now a frontbuffer and
* thus the aRTs[0] is a backbuffer */
{
// && pBbRc->RcDesc.fFlags.Value == pRtRc->RcDesc.fFlags.Value
)
))
{
pSwapchain = pCur;
break;
}
}
break;
}
// if (!pSwapchain) need to create a new one (see below)
}
if (!pSwapchain)
{
if (pSwapchain)
{
}
}
return pSwapchain;
}
static PVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainCreateForRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc)
{
if (pSwapchain)
{
{
}
return pSwapchain;
}
return NULL;
}
{
return iBb != (~0) ? (iBb + pSwapchain->iBB) % pSwapchain->cRTs : vboxWddmSwapchainIdxFb(pSwapchain);
}
static HRESULT vboxWddmSwapchainRtSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, uint32_t iBb)
{
{
iBb = 0;
}
#endif
{
return hr;
}
{
{
{
/* since this can be texture, need to do the vboxWddmSurfGet magic */
{
return hr;
}
}
{
/* get the old surface's swapchain */
{
}
else
{
}
{
/* the swapchain has changed, copy data to the new surface */
#ifdef DEBUG_misha
/* @todo: we can not generally update the render target directly, implement */
#endif
}
}
if (pD3D9OldSurf)
{
pD3D9OldSurf->Release();
}
}
else
{
}
}
{
{
{
}
}
}
{
/* only use direct bb if wine is able to handle quick blits bewteen surfaces in one swapchain,
* this is FALSE by now :( */
/* here we sync the front-buffer with a backbuffer data*/
/* we use backbuffer as a rt frontbuffer copy, so release the old one and assign the current bb */
{
}
# else
# endif
{
tmpHr = pDevice->pDevice9If->StretchRect(pD3D9Bb, NULL, (IDirect3DSurface9*)vboxWddmSwapchainGetBb(pSwapchain)->pAlloc->pD3DIf, NULL, D3DTEXF_NONE);
{
}
# endif
}
else
{
}
}
#endif
return hr;
}
static HRESULT vboxWddmSwapchainSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
{
}
{
{
}
}
return hr;
}
static VOID vboxWddmSwapchainFillParams(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, D3DPRESENT_PARAMETERS *pParams)
{
#ifdef DEBUG_misha
/* not supported by wine properly, need to use offscreen render targets and blit their data to swapchain RTs*/
#endif
#if 0 //def VBOXDISP_WITH_WINE_BB_WORKAROUND /* this does not work so far any way :( */
else
#endif
}
static HRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
return S_OK;
/* preserve the old one */
/* check if we need to re-create the swapchain */
if (pOldIf)
{
{
// && OldParams.SwapEffect == Params.SwapEffect
)
{
}
}
}
/* first create the new one */
///
if (!bReuseSwapchain)
{
//#define VBOXDISP_NEWWND_ON_SWAPCHAINUPDATE
{
// if (pDevice->fFlags.AllowMultithreading)
// fFlags |= D3DCREATE_MULTITHREADED;
/* @todo: it seems there should be a way to detect this correctly since
* our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */
// params.EnableAutoDepthStencil = FALSE;
// params.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
// params.Flags;
// params.FullScreen_RefreshRateInHz;
// params.FullScreen_PresentationInterval;
if (!pDevice->pDevice9If)
{
hr = pAdapter->pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, fFlags, &Params, &pDevice9If);
{
{
}
else
{
pDevice9If->Release();
}
}
}
else
{
if (pOldIf)
{
/* copy current rt data to offscreen render targets */
{
/* just need a pointer to match */
pD3D9OldFb->Release();
}
{
continue;
/* since this can be texture, need to do the vboxWddmSurfGet magic */
{
}
else
{
}
if (pvSwapchain != pOldIf)
continue;
TRUE, /*bLockable*/
);
continue;
{
}
else
{
}
continue;
pD3D9OldSurf->Release();
}
}
/* re-use swapchain window
* this will invalidate the previusly used swapchain */
{
}
}
}
}
else
{
/* to ensure the swapchain is not deleted once we release the pOldIf */
}
{
#ifndef VBOXWDDM_WITH_VISIBLE_FB
# if defined(VBOXDISP_WITH_WINE_BB_WORKAROUND) && defined(VBOX_WINE_WITH_FAST_INTERSWAPCHAIN_BLT)
/* if wine is able to do fast fb->bb blits, we will use backbuffer directly,
* this is NOT possible currently */
{
/* we will assign it to wine backbuffer on a swapchain synch */
{
}
}
else
# endif
if (!pSwapchain->pRenderTargetFbCopy)
{
TRUE, /*bLockable*/
NULL /* HANDLE* pSharedHandle */
);
{
}
}
#endif
{
#ifdef DEBUG
{
}
#endif
{
{
{
break;
}
}
{
if (pOldIf)
{
}
else
{
}
return S_OK;
}
}
}
}
return hr;
}
static HRESULT vboxWddmSwapchainCreateIfForRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, PVBOXWDDMDISP_SWAPCHAIN *ppSwapchain)
{
*ppSwapchain = NULL;
if (pSwapchain)
{
{
}
return hr;
}
return E_OUTOFMEMORY;
}
static HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
{
}
return hr;
}
static HRESULT vboxWddmSwapchainBbUpdate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pBbAlloc)
{
{
return S_OK;
{
return hr;
}
}
AssertMsgFailed(("the given allocation not par of the swapchain\n"));
return E_FAIL;
}
/* get the surface for the specified allocation in the swapchain */
static HRESULT vboxWddmSwapchainSurfGet(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DSurface9 **ppSurf)
{
#ifndef VBOXWDDM_WITH_VISIBLE_FB
# ifdef VBOXDISP_WITH_WINE_BB_WORKAROUND
&& vboxWddmSwapchainNumRTs(pSwapchain) != 1 /* for swapchains w/o a backbuffer the alloc will contain the back-buffer actually */
)
{
/* this is a front-buffer */
if (!pSwapchain->bRTFbCopyUpToDate)
{
{
return hr;
}
}
return S_OK;
}
# endif
#endif
/* if this is not a front-buffer - just return the surface associated with the allocation */
}
static HRESULT vboxWddmSwapchainRtSurfGet(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch, IDirect3DSurface9 **ppSurf)
{
/* do the necessary swapchain synchronization first,
* not needed on swapchain synch since it is done already and we're called here just to set RTs */
if (!bOnSwapchainSynch)
{
/* iRt != 0 is untested here !! */
if (iRt == 0)
{
{
return hr;
}
}
{
return hr;
}
}
{
return hr;
}
return S_OK;
}
static HRESULT vboxWddmSwapchainPresent(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc)
{
if (!bNeedPresent)
return S_OK;
if (pSwapchain)
{
{
}
return hr;
}
return E_OUTOFMEMORY;
}
#if 0 //def DEBUG
static void vboxWddmDbgRenderTargetUpdateCheckSurface(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, uint32_t iBBuf)
{
{
}
}
static void vboxWddmDbgRenderTargetCheck(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, uint32_t iNewRTFB)
{
{
}
#ifdef VBOXWDDM_WITH_VISIBLE_FB
#else
#endif
{
if (iNewRTFB == i)
{
}
{
}
}
}
# define VBOXVDBG_RTGT_STATECHECK(_pDev) (vboxWddmDbgRenderTargetCheck((_pDev), (_pDev)->aScreens[(_pDev)->iPrimaryScreen].pRenderTargetRc, (_pDev)->aScreens[(_pDev)->iPrimaryScreen].iRenderTargetFrontBuf))
#else
# define VBOXVDBG_RTGT_STATECHECK(_pDev) do{}while(0)
#endif
{
if (pRc)
{
{
}
}
else
{
hr = E_OUTOFMEMORY;
}
return hr;
}
{
if (pDevice->pDevice9If)
return pDevice->pDevice9If;
return pDevice->pDevice9If;
}
/******/
static HRESULT vboxWddmRenderTargetSet(PVBOXWDDMDISP_DEVICE pDevice, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch)
{
if (pSwapchain)
{
{
return hr;
}
}
else
{
{
return hr;
}
}
{
}
return hr;
}
/**
* DLL entry point.
*/
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
vboxVDbgPrint(("VBoxDispD3D: DLL loaded.\n"));
#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
#endif
int rc = RTR3InitDll(0);
if (RT_SUCCESS(rc))
{
rc = VbglR3Init();
if (RT_SUCCESS(rc))
{
{
hr = vboxDispMpInternalInit();
{
vboxVDbgPrint(("VBoxDispD3D: DLL loaded OK\n"));
return TRUE;
}
}
VbglR3Term();
}
}
break;
}
case DLL_PROCESS_DETACH:
{
#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
#endif
{
hr = vboxDispCmTerm();
{
VbglR3Term();
/// @todo RTR3Term();
return TRUE;
}
}
break;
}
default:
return TRUE;
}
return FALSE;
}
{
{
/*| D3DDEVCAPS_HWVERTEXBUFFER | D3DDEVCAPS_HWINDEXBUFFER | D3DDEVCAPS_SUBVOLUMELOCK */;
pCaps->RasterCaps |= D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ZBIAS | D3DPRASTERCAPS_COLORPERSPECTIVE /* keep */;
#if 1 /* workaround for wine not returning InstructionSlots correctly for shaders v3.0 */
{
}
#endif
#ifdef DEBUG
{
}
{
}
else
{
Assert(0);
}
#endif
}
return hr;
}
{
{
case D3DDDICAPS_DDRAW:
{
{
#ifdef VBOX_WITH_VIDEOHWACCEL
if (vboxVhwaHasCKeying(pAdapter))
{
// pCaps->Caps2 |= DDRAW_CAPS2_FLIPNOVSYNC;
}
#endif
}
else
hr = E_INVALIDARG;
break;
}
{
{
zero starting with the one following "Head", i.e. Caps */,
#ifdef VBOX_WITH_VIDEOHWACCEL
{
{
| MODE_CKEYCAPS_DESTOVERLAYYUV /* ?? */
;
}
{
| MODE_CKEYCAPS_SRCOVERLAYCLRSPACE /* ?? */
| MODE_CKEYCAPS_SRCOVERLAYCLRSPACEYUV /* ?? */
| MODE_CKEYCAPS_SRCOVERLAYYUV /* ?? */
;
}
}
#endif
}
else
hr = E_INVALIDARG;
break;
}
break;
case D3DDDICAPS_GETFORMATDATA:
break;
#if 1
#else
#endif
break;
#if 1
#else
Assert(0);
#endif
break;
case D3DDDICAPS_GETD3D3CAPS:
{
// | D3DDEVCAPS_DRAWPRIMTLVERTEX
// | D3DDEVCAPS_FLOATTLVERTEX
// | D3DDEVCAPS_HWTRANSFORMANDLIGHT
// | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
// | D3DDEVCAPS_TEXTUREVIDEOMEMORY
;
pCaps->dwNumVertices = 0;
pCaps->dwNumClipVertices = 0;
}
else
hr = E_INVALIDARG;
break;
case D3DDDICAPS_GETD3D7CAPS:
{
}
else
hr = E_INVALIDARG;
break;
case D3DDDICAPS_GETD3D9CAPS:
{
// Assert(0);
{
if (VBOXDISPMODE_IS_3D(pAdapter))
{
break;
/* let's fall back to the 3D disabled case */
}
}
else
hr = E_INVALIDARG;
break;
}
case D3DDDICAPS_GETD3D8CAPS:
{
{
if (VBOXDISPMODE_IS_3D(pAdapter))
{
{
break;
}
/* let's fall back to the 3D disabled case */
}
}
else
hr = E_INVALIDARG;
break;
}
break;
break;
case D3DDDICAPS_GETD3D5CAPS:
case D3DDDICAPS_GETD3D6CAPS:
Assert(0);
break;
default:
Assert(0);
}
return S_OK;
}
static HRESULT APIENTRY vboxWddmDDevSetRenderState(HANDLE hDevice, CONST D3DDDIARG_RENDERSTATE* pData)
{
return hr;
}
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
return S_OK;
}
static HRESULT APIENTRY vboxWddmDDevValidateDevice(HANDLE hDevice, D3DDDIARG_VALIDATETEXTURESTAGESTATE* pData)
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
#ifdef DEBUG_misha
/* @todo: check if it's ok to always return success */
Assert(0);
#endif
return S_OK;
}
static HRESULT APIENTRY vboxWddmDDevSetTextureStageState(HANDLE hDevice, CONST D3DDDIARG_TEXTURESTAGESTATE* pData)
{
if (!lookup.bSamplerState)
{
hr = pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value);
}
else
{
}
return hr;
}
{
// Assert(pRc);
if (pRc)
{
{
}
{
}
else
{
Assert(0);
}
}
else
return hr;
}
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetPixelShaderConst(HANDLE hDevice, CONST D3DDDIARG_SETPIXELSHADERCONST* pData, CONST FLOAT* pRegisters)
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetStreamSourceUm(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCEUM* pData, CONST VOID* pUMBuffer )
{
{
}
return hr;
}
{
if (pRc)
{
}
{
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetIndicesUm(HANDLE hDevice, UINT IndexSize, CONST VOID* pUMBuffer)
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevDrawPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWPRIMITIVE* pData, CONST UINT* pFlagBuffer)
{
if (!pDevice->cStreamSources)
{
{
#ifdef DEBUG
{
}
#endif
((uint8_t*)pDevice->aStreamSourceUm[0].pvBuffer) + pData->VStart * pDevice->aStreamSourceUm[0].cbStride,
// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
}
else
{
/* todo: impl */
Assert(0);
}
}
else
{
#ifdef DEBUG
{
}
{
if (pDevice->aStreamSource[i])
{
++cStreams;
}
}
#endif
// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitive\n"));
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevDrawIndexedPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWINDEXEDPRIMITIVE* pData)
{
#ifdef DEBUG
{
}
{
if (pDevice->aStreamSource[i])
{
++cStreams;
}
}
#endif
return hr;
}
static HRESULT APIENTRY vboxWddmDDevDrawRectPatch(HANDLE hDevice, CONST D3DDDIARG_DRAWRECTPATCH* pData, CONST D3DDDIRECTPATCH_INFO* pInfo, CONST FLOAT* pPatch)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDrawTriPatch(HANDLE hDevice, CONST D3DDDIARG_DRAWTRIPATCH* pData, CONST D3DDDITRIPATCH_INFO* pInfo, CONST FLOAT* pPatch)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDrawPrimitive2(HANDLE hDevice, CONST D3DDDIARG_DRAWPRIMITIVE2* pData)
{
#if 0
int stream;
{
{
{
IDirect3DVertexBuffer9 *pD3D9VBuf = (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf;
RECT r;
r.top = 0;
r.bottom = 1;
vboxWddmLockUnlockMemSynch(pDevice->aStreamSource[stream], &pLock->LockedRect, &r, true /*bool bToLockInfo*/);
}
}
}
hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount);
#else
#ifdef DEBUG
#endif
int stream;
{
{
#ifdef DEBUG
++cStreams;
#endif
{
// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
(void*)((uintptr_t)pDevice->aStreamSource[stream]->pvMem+pDevice->StreamSourceInfo[stream].uiOffset+pData->FirstVertexOffset),
hr = pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride);
}
else
{
// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitive\n"));
hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);
}
}
}
#ifdef DEBUG
#endif
#endif
return hr;
}
static HRESULT APIENTRY vboxWddmDDevDrawIndexedPrimitive2(HANDLE hDevice, CONST D3DDDIARG_DRAWINDEXEDPRIMITIVE2* pData, UINT dwIndicesSize, CONST VOID* pIndexBuffer, CONST UINT* pFlagBuffer)
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
// @todo: vboxWddmDalCheckAdd(pDevice);
return E_FAIL;
}
{
Assert(0);
// @todo: vboxWddmDalCheckAdd(pDevice);
return E_FAIL;
}
{
/* requirements for D3DDevice9::UpdateTexture */
{
}
else
{
{
{
#ifdef DEBUG
RECT tstRect = {0,0, pDstRc->aAllocations[0].SurfDesc.width, pDstRc->aAllocations[0].SurfDesc.height};
#endif
pSrcSurfIf->Release();
}
pDstSurfIf->Release();
}
}
{
}
{
}
return hr;
}
{
Assert(0);
return E_FAIL;
}
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// Assert(pDevice);
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
return S_OK;
}
static HRESULT APIENTRY vboxWddmDDevClear(HANDLE hDevice, CONST D3DDDIARG_CLEAR* pData, UINT NumRect, CONST RECT* pRect)
{
pData->FillStencil);
return hr;
}
static HRESULT APIENTRY vboxWddmDDevUpdatePalette(HANDLE hDevice, CONST D3DDDIARG_UPDATEPALETTE* pData, CONST PALETTEENTRY* pPaletteData)
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetVertexShaderConst(HANDLE hDevice, CONST D3DDDIARG_SETVERTEXSHADERCONST* pData , CONST VOID* pRegisters)
{
(CONST float*)pRegisters,
return hr;
}
static HRESULT APIENTRY vboxWddmDDevMultiplyTransform(HANDLE hDevice, CONST D3DDDIARG_MULTIPLYTRANSFORM* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetTransform(HANDLE hDevice, CONST D3DDDIARG_SETTRANSFORM* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetViewport(HANDLE hDevice, CONST D3DDDIARG_VIEWPORTINFO* pData)
{
return hr;
}
{
return hr;
}
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetLight(HANDLE hDevice, CONST D3DDDIARG_SETLIGHT* pData, CONST D3DDDI_LIGHT* pLightProperties)
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDestroyLight(HANDLE hDevice, CONST D3DDDIARG_DESTROYLIGHT* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetClipPlane(HANDLE hDevice, CONST D3DDDIARG_SETCLIPPLANE* pData)
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevGetInfo(HANDLE hDevice, UINT DevInfoID, VOID* pDevInfoStruct, UINT DevInfoSize)
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// Assert(pDevice);
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
switch (DevInfoID)
{
case D3DDDIDEVINFOID_VCACHE:
{
if (DevInfoSize == sizeof (D3DDDIDEVINFO_VCACHE))
{
pVCache->MagicNumber = 0;
}
else
hr = E_INVALIDARG;
break;
}
default:
Assert(0);
}
return hr;
}
{
return E_INVALIDARG;
{
// Assert(pRc != pScreen->pRenderTargetRc || pScreen->iRenderTargetFrontBuf != pData->SubResourceIndex);
{
bool bNeedResynch = false;
{
}
/* else - we lock the entire texture, pRect == NULL */
{
switch (pTexAlloc->enmD3DIfType)
{
break;
break;
break;
default:
Assert(0);
break;
}
{
if (pRect)
{
}
else
{
}
}
}
else
{
{
}
{
switch (pTexAlloc->enmD3DIfType)
{
break;
break;
break;
default:
Assert(0);
break;
}
{
switch (pTexAlloc->enmD3DIfType)
{
break;
break;
break;
default:
Assert(0);
break;
}
}
}
}
{
{
pData->SlicePitch = 0;
}
else
{
}
}
}
{
{
}
/* else - we lock the entire vertex buffer, pRect == NULL */
{
{
bLocked = true;
}
{
// Assert(pLockAlloc->LockInfo.fFlags.Value == 0);
if (pRange)
{
// pAlloc->LockInfo.fFlags.RangeValid = 1;
}
else
{
// pAlloc->LockInfo.fFlags.RangeValid = 0;
}
}
}
else
{
{
}
}
{
{
pData->SlicePitch = 0;
}
else
{
{
if (pRange)
{
r.top = 0;
r.bottom = 1;
pr = &r;
}
else
}
}
}
}
{
{
}
/* else - we lock the entire vertex buffer, pRect == NULL */
{
{
bLocked = true;
}
{
// Assert(pLockAlloc->LockInfo.fFlags.Value == 0);
if (pRange)
{
// pAlloc->LockInfo.fFlags.RangeValid = 1;
}
else
{
// pAlloc->LockInfo.fFlags.RangeValid = 0;
}
}
}
else
{
{
}
}
{
{
pData->SlicePitch = 0;
}
else
{
{
if (pRange)
{
r.top = 0;
r.bottom = 1;
pr = &r;
}
else
}
}
}
}
else
{
Assert(0);
}
}
else
{
{
{
}
{
}
{
Assert(0);
}
else
{
offset = 0;
}
{
else
{
}
}
{
/* check if the surface was renamed */
if (LockData.hAllocation)
}
}
}
return hr;
}
{
return E_INVALIDARG;
{
{
{
{
{
break;
}
{
break;
}
{
break;
}
default:
Assert(0);
break;
}
}
else
{
}
}
{
{
// Assert(!pAlloc->LockInfo.cLocks);
/* this is a sysmem texture, update */
{
{
r.top = 0;
r.bottom = 1;
pr = &r;
}
else
pr,
true /*bool bToLockInfo*/);
}
}
else
{
}
}
{
{
// Assert(!pAlloc->LockInfo.cLocks);
/* this is a sysmem texture, update */
{
{
r.top = 0;
r.bottom = 1;
pr = &r;
}
else
pr,
true /*bool bToLockInfo*/);
}
}
else
{
}
}
else
{
Assert(0);
}
}
else
{
struct
{
} UnlockData;
{
}
}
return hr;
}
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
{
}
{
/* allocate buffer for D3DDDICB_ALLOCATE + D3DDDI_ALLOCATIONINFO * numAllocs + PVBOXWDDM_RCINFO with aAllocInfos[numAllocs] */
if (pvBuf)
{
{
}
return pAlloc;
}
return NULL;
}
static HRESULT APIENTRY vboxWddmDDevCreateResource(HANDLE hDevice, D3DDDIARG_CREATERESOURCE* pResource)
{
if (pRc)
{
bool bIssueCreateResource = false;
bool bCreateSwapchain = false;
bool bCreateKMResource = false;
{
/*@fixme: Those formats are actually blocks of 4x4 pixels,
* for some reason we're getting pSurf->SysMemPitch as if took 4x1 column from this block,
* which leads us to having 4x times bigger pitch than actual line takes.
* Simply trying to read here provided pointer
* at (byte*)pSurf->pSysMem + pSurf->pSurf->SysMemPitch*pSurf->Height - 1 causes access violation.
*/
{
}
pAllocation->iAlloc = i;
}
if (VBOXDISPMODE_IS_3D(pAdapter))
{
{
bIssueCreateResource = true;
bCreateKMResource = true;
}
{
{
TRUE /* @todo: BOOL Discard */,
NULL /*HANDLE* pSharedHandle*/);
{
}
else
{
for (UINT j = 0; j < i; ++j)
{
}
break;
}
}
}
{
{
NULL /*HANDLE* pSharedHandle*/);
{
{
{
}
}
else
{
}
}
else
{
for (UINT j = 0; j < i; ++j)
{
}
break;
}
}
}
{
{
NULL /*HANDLE* pSharedHandle*/
);
{
{
{
}
}
else
{
}
}
else
{
for (UINT j = 0; j < i; ++j)
{
}
break;
}
}
}
{
{
bIssueCreateResource = true;
}
{
#ifdef DEBUG
{
{
tstW /= 2;
tstH /= 2;
}
}
#endif
void **pavClientMem = NULL;
{
if (bpp)
{
{
Assert(0);
++pAllocation->D3DWidth;
}
}
}
{
if (pavClientMem)
{
{
}
}
else
}
{
{
#ifdef DEBUG_misha
{
vboxVDbgPrint(("\n\n********\nShared Texture pAlloc(0x%p) Handle(0x%x), (0n%d) CREATED, pid (0x%x), (0n%d)\n***********\n\n",
}
#endif
}
if (pavClientMem)
}
}
else /*pResource->Flags.CubeMap*/
{
void **pavClientMem = NULL;
{
Assert(0);
hr = E_INVALIDARG;
}
else
{
{
if (pavClientMem)
{
{
}
}
else
}
{
{
}
if (pavClientMem)
}
}
}
}
{
bIssueCreateResource = true;
{
bCreateSwapchain = true;
{
}
}
else
{
{
);
{
{
continue;
}
/* fail branch */
}
for (UINT j = 0; j < i; ++j)
{
}
break;
}
}
}
else
{
Assert(0);
}
}
else
{
bIssueCreateResource = true;
bCreateKMResource = true;
}
{
if (pDdiAllocate)
{
{
{
}
else
if (pSurf->SysMemPitch)
{
#ifdef DEBUG
#endif
}
else
}
if (bCreateKMResource)
{
}
else
{
{
{
}
else
{
for (UINT j = 0; i < j; ++j)
{
}
break;
}
}
}
{
{
}
if(bCreateSwapchain)
{
}
}
}
else
{
hr = E_OUTOFMEMORY;
}
}
else
}
else
{
hr = E_OUTOFMEMORY;
}
return hr;
}
{
if (VBOXDISPMODE_IS_3D(pAdapter))
{
{
#ifdef DEBUG_misha
if (pAlloc->hSharedHandle)
{
vboxVDbgPrint(("\n\n********\nShared Texture pAlloc(0x%p) Handle(0x%x), (0n%d) DESTROYED, pid (0x%x), (0n%d)\n***********\n\n",
pAlloc, pAlloc->hSharedHandle, pAlloc->hSharedHandle, GetCurrentProcessId(), GetCurrentProcessId()));
}
#endif
if (pAlloc->pSecondaryOpenedD3DIf)
if (pSwapchain)
{
}
}
}
if (pRc->hKMResource)
{
{
/* according to the docs the below two are ignored in case we set the hResource */
Dealloc.NumAllocations = 0;
}
}
else
{
{
{
}
}
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetDisplayMode(HANDLE hDevice, CONST D3DDDIARG_SETDISPLAYMODE* pData)
{
// PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pRc->RcDesc.VidPnSourceId];
// Assert(pScreen->hWnd);
// Assert(pScreen->pDevice9If);
D3DDDICB_SETDISPLAYMODE DdiDm = {0};
// DdiDm.PrivateDriverFormatAttribute = 0;
// Assert(pScreen->pRenderTargetRc == pRc);
// Assert(pScreen->iRenderTargetFrontBuf == pData->SubResourceIndex);
#if 0
#endif
{
#if 0
{
D3DDDICB_LOCK DdiLock = {0};
{
{
/** @todo: take pitch into account */
}
D3DDDICB_UNLOCK DdiUnlock = {0};
}
}
#endif
}
return hr;
}
#ifdef VBOXWDDM_TEST_UHGSMI
#endif
{
// VBOXDISPPROFILE_DDI_CHKDUMPRESET(pDevice);
{
#ifdef VBOXWDDM_TEST_UHGSMI
{
}
#endif
}
{
D3DDDICB_PRESENT DdiPresent = {0};
if (pData->hSrcResource)
{
}
if (pData->hDstResource)
{
}
}
return hr;
}
{
{
}
return hr;
}
AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Stream) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Stream));
AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Offset) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Offset));
AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Method) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Method));
AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, Usage) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, Usage));
AssertCompile(RT_SIZEOFMEMB(D3DDDIVERTEXELEMENT, UsageIndex) == RT_SIZEOFMEMB(D3DVERTEXELEMENT9, UsageIndex));
AssertCompile(RT_OFFSETOF(D3DDDIVERTEXELEMENT, UsageIndex) == RT_OFFSETOF(D3DVERTEXELEMENT9, UsageIndex));
static HRESULT APIENTRY vboxWddmDDevCreateVertexShaderDecl(HANDLE hDevice, D3DDDIARG_CREATEVERTEXSHADERDECL* pData, CONST D3DDDIVERTEXELEMENT* pVertexElements)
{
bool bFreeVe = false;
{
if (pVe)
{
bFreeVe = true;
}
else
hr = E_OUTOFMEMORY;
}
else
{
pVe,
);
{
}
}
if (bFreeVe)
return hr;
}
{
return hr;
}
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevCreateVertexShaderFunc(HANDLE hDevice, D3DDDIARG_CREATEVERTEXSHADERFUNC* pData, CONST UINT* pCode)
{
{
}
return hr;
}
{
return hr;
}
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetVertexShaderConstI(HANDLE hDevice, CONST D3DDDIARG_SETVERTEXSHADERCONSTI* pData, CONST INT* pRegisters)
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetVertexShaderConstB(HANDLE hDevice, CONST D3DDDIARG_SETVERTEXSHADERCONSTB* pData, CONST BOOL* pRegisters)
{
return hr;
}
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetStreamSource(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCE* pData)
{
if (pRc)
{
}
{
{
}
{
}
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetStreamSourceFreq(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCEFREQ* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetConvolutionKernelMono(HANDLE hDevice, CONST D3DDDIARG_SETCONVOLUTIONKERNELMONO* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevComposeRects(HANDLE hDevice, CONST D3DDDIARG_COMPOSERECTS* pData)
{
Assert(0);
return E_FAIL;
}
{
{
{
break;
}
{
break;
}
{
break;
}
default:
Assert(0);
break;
}
return hr;
}
{
{
{
break;
}
{
break;
}
{
break;
}
default:
Assert(0);
break;
}
return hr;
}
{
// PVBOXWDDMDISP_SCREEN pScreen = &pDevice->aScreens[pDevice->iPrimaryScreen];
/* try StretchRect */
Assert(!pDstSwapchain || vboxWddmSwapchainGetFb(pDstSwapchain)->pAlloc != pDstAlloc || vboxWddmSwapchainNumRTs(pDstSwapchain) == 1);
{
do
{
if (pSrcSwapchain)
{
}
else
{
}
{
VBOXVDBG_DUMP_BLT_ENTER(pSrcAlloc, pSrcSurfIf, &pData->SrcRect, pDstAlloc, pDstSurfIf, &pData->DstRect);
/* we support only Point & Linear, we ignore [Begin|Continue|End]PresentToDwm */
Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001 | 0x00000002))) == 0);
VBOXVDBG_DUMP_BLT_LEAVE(pSrcAlloc, pSrcSurfIf, &pData->SrcRect, pDstAlloc, pDstSurfIf, &pData->DstRect);
pSrcSurfIf->Release();
}
} while (0);
pDstSurfIf->Release();
}
{
/* todo: fallback to memcpy or whatever ? */
Assert(0);
}
return hr;
}
{
{
/* @todo: check what need to do when PresentToDwm flag is set */
}
return hr;
}
{
Assert(0);
//@todo: vboxWddmDalCheckAdd(pDevice, pDAlloc, TRUE);
return E_FAIL;
}
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// Assert(pDevice);
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
{
if (pQuery)
{
}
else
{
hr = E_OUTOFMEMORY;
}
}
else
{
Assert(0);
}
return hr;
}
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// Assert(pDevice);
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
return hr;
}
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// Assert(pDevice);
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
return hr;
}
static HRESULT APIENTRY vboxWddmDDevGetQueryData(HANDLE hDevice, CONST D3DDDIARG_GETQUERYDATA* pData)
{
// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
// Assert(pDevice);
// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
{
case D3DDDIQUERYTYPE_EVENT:
break;
default:
Assert(0);
break;
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetRenderTarget(HANDLE hDevice, CONST D3DDDIARG_SETRENDERTARGET* pData)
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetDepthStencil(HANDLE hDevice, CONST D3DDDIARG_SETDEPTHSTENCIL* pData)
{
if (pRc)
{
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevGenerateMipSubLevels(HANDLE hDevice, CONST D3DDDIARG_GENERATEMIPSUBLEVELS* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetPixelShaderConstI(HANDLE hDevice, CONST D3DDDIARG_SETPIXELSHADERCONSTI* pData, CONST INT* pRegisters)
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevSetPixelShaderConstB(HANDLE hDevice, CONST D3DDDIARG_SETPIXELSHADERCONSTB* pData, CONST BOOL* pRegisters)
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevCreatePixelShader(HANDLE hDevice, D3DDDIARG_CREATEPIXELSHADER* pData, CONST UINT* pCode)
{
{
}
return hr;
}
{
return hr;
}
static HRESULT APIENTRY vboxWddmDDevCreateDecodeDevice(HANDLE hDevice, D3DDDIARG_CREATEDECODEDEVICE* pData)
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetDecodeRenderTarget(HANDLE hDevice, CONST D3DDDIARG_SETDECODERENDERTARGET* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDecodeBeginFrame(HANDLE hDevice, D3DDDIARG_DECODEBEGINFRAME* pData)
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDecodeExecute(HANDLE hDevice, CONST D3DDDIARG_DECODEEXECUTE* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDecodeExtensionExecute(HANDLE hDevice, CONST D3DDDIARG_DECODEEXTENSIONEXECUTE* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevCreateVideoProcessDevice(HANDLE hDevice, D3DDDIARG_CREATEVIDEOPROCESSDEVICE* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDestroyVideoProcessDevice(HANDLE hDevice, HANDLE hVideoProcessor)
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevVideoProcessEndFrame(HANDLE hDevice, D3DDDIARG_VIDEOPROCESSENDFRAME* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetVideoProcessRenderTarget(HANDLE hDevice, CONST D3DDDIARG_SETVIDEOPROCESSRENDERTARGET* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevVideoProcessBlt(HANDLE hDevice, CONST D3DDDIARG_VIDEOPROCESSBLT* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevCreateExtensionDevice(HANDLE hDevice, D3DDDIARG_CREATEEXTENSIONDEVICE* pData)
{
Assert(0);
return E_FAIL;
}
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevExtensionExecute(HANDLE hDevice, CONST D3DDDIARG_EXTENSIONEXECUTE* pData)
{
Assert(0);
return E_FAIL;
}
{
if (VBOXDISPMODE_IS_3D(pAdapter))
{
// Assert(!pDevice->cScreens);
/* destroy the device first, since destroying PVBOXWDDMDISP_SWAPCHAIN would result in a device window termination */
if (pDevice->pDevice9If)
{
}
}
#ifdef VBOX_WITH_CRHGSMI
vboxDispLock();
#endif
return hr;
}
{
if (pOverlay)
{
#ifndef VBOXWDDMOVERLAY_TEST
{
{
/* we have reported the dirty rect, may clear it if no locks are pending currently */
}
}
else
{
}
#else
#endif
}
else
hr = E_OUTOFMEMORY;
return hr;
}
static HRESULT APIENTRY vboxWddmDDevUpdateOverlay(HANDLE hDevice, CONST D3DDDIARG_UPDATEOVERLAY* pData)
{
#ifndef VBOXWDDMOVERLAY_TEST
#endif
{
{
/* we have reported the dirty rect, may clear it if no locks are pending currently */
}
}
return hr;
}
{
#ifndef VBOXWDDMOVERLAY_TEST
#endif
{
{
/* we have reported the dirty rect, may clear it if no locks are pending currently */
}
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevGetOverlayColorControls(HANDLE hDevice, D3DDDIARG_GETOVERLAYCOLORCONTROLS* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevSetOverlayColorControls(HANDLE hDevice, CONST D3DDDIARG_SETOVERLAYCOLORCONTROLS* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevDestroyOverlay(HANDLE hDevice, CONST D3DDDIARG_DESTROYOVERLAY* pData)
{
#ifndef VBOXWDDMOVERLAY_TEST
#else
#endif
{
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevQueryResourceResidency(HANDLE hDevice, CONST D3DDDIARG_QUERYRESOURCERESIDENCY* pData)
{
/* @todo check residency for the "real" allocations */
#if 0
{
if (pRc->hKMResource)
{
}
}
#endif
return hr;
}
static HRESULT vboxAllocationInit(PVBOXWDDMDISP_ALLOCATION pAlloc, D3DDDI_OPENALLOCATIONINFO *pInfo)
{
{
}
else
{
vboxVDbgPrintR((__FUNCTION__": ERROR: PrivateDriverDataSize(%d) < (%d)\n", pInfo->PrivateDriverDataSize, sizeof (VBOXWDDM_ALLOCINFO)));
hr = E_INVALIDARG;
}
return hr;
}
{
if (pRc)
{
{
/* this is a "standard" allocation resource */
/* both should be actually zero */
if (pDdiAllocInfo->pPrivateDriverData && pDdiAllocInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO))
{
switch(pAllocInfo->enmType)
{
break;
default:
Assert(0);
hr = E_INVALIDARG;
}
}
else
hr = E_INVALIDARG;
}
else
{
/* this is a "generic" resource whose creation is initiated by the UMD */
{
{
{
hr = E_INVALIDARG;
break;
}
}
{
#ifdef DEBUG_misha
vboxVDbgPrint(("\n\n********\nShared Texture pAlloc(0x%p) Handle(0x%x), (0n%d) OPENED, pid (0x%x), (0n%d)\n***********\n\n",
#endif
{
NULL);
{
}
}
else
{
{
Assert(0);
hr = E_INVALIDARG;
}
NULL);
{
}
}
}
else
{
/* impl */
Assert(0);
}
}
else
hr = E_INVALIDARG;
}
{
{
break;
}
}
else
}
else
{
vboxVDbgPrintR((__FUNCTION__": vboxResourceAlloc failed for hDevice(0x%p), NumAllocations(%d)\n", hDevice, pData->NumAllocations));
hr = E_OUTOFMEMORY;
}
return hr;
}
static HRESULT APIENTRY vboxWddmDDevGetCaptureAllocationHandle(HANDLE hDevice, D3DDDIARG_GETCAPTUREALLOCATIONHANDLE* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDDevCaptureToSysMem(HANDLE hDevice, CONST D3DDDIARG_CAPTURETOSYSMEM* pData)
{
Assert(0);
return E_FAIL;
}
static HRESULT APIENTRY vboxWddmDispCreateDevice (IN HANDLE hAdapter, IN D3DDDIARG_CREATEDEVICE* pCreateData)
{
vboxVDbgPrint(("==> "__FUNCTION__", hAdapter(0x%p), Interface(%d), Version(%d)\n", hAdapter, pCreateData->Interface, pCreateData->Version));
// Assert(0);
PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_DEVICE, apRTs[pAdapter->cMaxSimRTs]));
if (pDevice)
{
/* Set Viewport to some default values */
pCreateData->pDeviceFuncs->pfnSetVideoProcessRenderTarget = vboxWddmDDevSetVideoProcessRenderTarget;
do
{
&& !pCreateData->PatchLocationListSize);
{
#ifdef VBOX_WITH_CRHGSMI
#endif
{
{
#ifdef VBOXDISP_EARLYCREATEDEVICE
if (pRc)
{
// params.BackBufferWidth = 640;
// params.BackBufferHeight = 480;
// params.BackBufferCount = 0;
// params.hDeviceWindow = hWnd;
/* @todo: it seems there should be a way to detect this correctly since
* our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */
// params.EnableAutoDepthStencil = FALSE;
// params.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
// params.Flags;
// params.FullScreen_RefreshRateInHz;
// params.FullScreen_PresentationInterval;
break;
}
else
{
hr = E_OUTOFMEMORY;
}
#else
//# define VBOXDISP_TEST_SWAPCHAIN
# ifdef VBOXDISP_TEST_SWAPCHAIN
# endif
break;
#endif
}
}
}
else
{
vboxVDbgPrintR((__FUNCTION__": Not implemented: PatchLocationListSize(%d), AllocationListSize(%d)\n",
//pCreateData->pAllocationList = ??
}
} while (0);
}
else
{
hr = E_OUTOFMEMORY;
}
return hr;
}
{
if (VBOXDISPMODE_IS_3D(pAdapter))
{
#ifdef VBOX_WITH_CRHGSMI
#endif
}
return S_OK;
}
{
// vboxDispLock();
do
{
{
break;
}
/* check the miniport version match display version */
{
Query.u32Version));
break;
}
#ifdef VBOX_WITH_VIDEOHWACCEL
PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_ADAPTER, aHeads[Query.cInfos]));
#else
#endif
if (pAdapter)
{
/*
* here we detect whether we are called by the d3d or ddraw.
* in the d3d case we init our d3d environment
* in the ddraw case we init 2D acceleration
* if interface version is > 7, this is D3D, treat it as so
* otherwise treat it as ddraw
* @todo: need a more clean way of doing this */
{
do
{
#ifdef VBOX_WITH_CRHGSMI
hr = vboxUhgsmiGlobalRetain();
#endif
{
/* try enable the 3D */
{
// Assert(0);
{
{
break;
}
}
else
}
else
#ifdef VBOX_WITH_CRHGSMI
#endif
}
} while (0);
}
#ifdef VBOX_WITH_VIDEOHWACCEL
else
{
{
}
}
#endif
// RTMemFree(pAdapter);
}
else
{
hr = E_OUTOFMEMORY;
}
} while (0);
// vboxDispUnlock();
return hr;
}