VBoxDispD3D.cpp revision 21591edad86f2635638801986bc8786661041b56
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * VBoxVideo Display D3D User mode dll
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * Copyright (C) 2011 Oracle Corporation
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * available from http://www.virtualbox.org. This file is free software;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * you can redistribute it and/or modify it under the terms of the GNU
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * General Public License (GPL) as published by the Free Software
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncvolatile uint32_t g_u32VBoxDispProfileFunctionLoggerIndex = 0;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync/* uncomment to enable particular logging */
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync/* allows dumping fps + how much time is spent in ddi functions in comparison with the rest time */
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync//# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_ENABLE
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync/* allows dumping time spent in each function and the number of calls made for any given function */
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncextern volatile uint32_t g_u322VBoxDispProfileFunctionLoggerIndex = 0;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync//static VBoxDispProfileSet g_VBoxDispProfileDDI("D3D_DDI");
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE(_pObj) VBOXDISPPROFILE_FUNCTION_LOGGER_DEFINE((_pObj)->ProfileDdiFunc)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DUMP(_pObj) do {\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj) do {\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_FUNCTION_LOGGER_DISABLE_CURRENT();\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT() VBOXDISPPROFILE_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT()
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pObj) do { \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if (!((_pObj)->ProfileDdiFunc.reportIteration() % 31) && !VBOXVDBG_IS_DWM()) {\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE(_pObj) do {} while(0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DUMP(_pObj) do {} while(0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj) do {} while(0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT() do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pDev) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync//static VBoxDispProfileFpsCounter g_VBoxDispFpsDDI(64);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(_pObj) VBOXDISPPROFILE_STATISTIC_LOGGER_DEFINE(&(_pObj)->ProfileDdiFps)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_STATISTIC_LOGGER_DISABLE_CURRENT();\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DUMP(_pObj) do { \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync double tup = (_pObj)->ProfileDdiFps.GetTimeProcPercent(); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DUMP(("[0x%p]: fps: %f, cps: %.1f, host %.1f%%", (_pObj), fps, cps, tup)); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pObj) do { \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if(!((_pObj)->ProfileDdiFps.GetNumFrames() % 31)) \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DUMP(_pObj); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT() VBOXDISPPROFILE_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT()
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(_pObj) do {} while(0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT() do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DUMP(_pObj) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE(_pObj) \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE(_pObj); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(_pObj);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_LOG_AND_DISABLE_CURRENT() \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT(); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT();
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pDev); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FLUSH(_pDev) do {\
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pDev); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_INIT_CMN(_pObj, _name, _cEntries) do { \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync (_pObj)->ProfileDdiFps = VBoxDispProfileFpsCounter(); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync (_pObj)->ProfileDdiFunc = VBoxDispProfileSet(_name); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj); \
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_PRINT(_m) VBOXDISPPROFILE_DUMP(_m)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_INIT_GLBL() VBOXDISPPROFILE_DDI_INIT_CMN(&g_VBoxDispProfile, "DDI_Adp", 64)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_INIT_ADP(_pAdp) VBOXDISPPROFILE_DDI_INIT_CMN(_pAdp, "DDI_Adp", 64)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_INIT_DEV(_pDev) VBOXDISPPROFILE_DDI_INIT_CMN(_pDev, "DDI_Dev", 64)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE(_pObj) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FLUSH(_pDev) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_INIT_GLBL() do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_INIT_ADP(_pAdp) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_INIT_DEV(_pDev) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_TERM(_pObj) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync# define VBOXDISPPROFILE_DDI_PRINT(_m) do {} while (0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync/* debugging/profiling stuff could go here.
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync * NOP in release */
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE((PVBOXWDDMDISP_DEVICE)(_hDevice));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE((PVBOXWDDMDISP_ADAPTER)(_hAdapter));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE(&g_VBoxDispProfile);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync//#define VBOXWDDMOVERLAY_TEST
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync// D3DDDIQUERYTYPE_OCCLUSION
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync#define VBOX_QUERYTYPE_COUNT() RT_ELEMENTS(gVBoxQueryTypes)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync#define VBOXDISPCRHGSMI_SCOPE_SET_DEV(_pDev) do {} while(0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync#define VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL() do {} while(0)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic HRESULT vboxWddmNSCAddAlloc(PVBOXWDDMDISP_NSCADD pData, PVBOXWDDMDISP_ALLOCATION pAlloc)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if (pData->cAllocationList && pData->cPatchLocationList && pData->cbCommandBuffer > 4)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync memset(pData->pAllocationList, 0, sizeof (D3DDDI_ALLOCATIONLIST));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pData->pAllocationList[0].hAllocation = pAlloc->hAllocation;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync memset(pData->pPatchLocationList, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pData->pPatchLocationList[0].PatchOffset = pData->cAllocations*4;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pData->pPatchLocationList[0].AllocationIndex = pData->cAllocations;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pData->pvCommandBuffer = (VOID*)(((uint8_t*)pData->pvCommandBuffer) + 4);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic BOOLEAN vboxWddmDalCheckRemove(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic HRESULT vboxWddmDalNotifyChange(PVBOXWDDMDISP_DEVICE pDevice)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync NscAdd.pvCommandBuffer = pDevice->DefaultContext.ContextInfo.pCommandBuffer;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync NscAdd.cbCommandBuffer = pDevice->DefaultContext.ContextInfo.CommandBufferSize;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync NscAdd.pAllocationList = pDevice->DefaultContext.ContextInfo.pAllocationList;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync NscAdd.cAllocationList = pDevice->DefaultContext.ContextInfo.AllocationListSize;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync NscAdd.pPatchLocationList = pDevice->DefaultContext.ContextInfo.pPatchLocationList;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync NscAdd.cPatchLocationList = pDevice->DefaultContext.ContextInfo.PatchLocationListSize;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(NscAdd.cbCommandBuffer >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if (NscAdd.cbCommandBuffer < sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR))
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pHdr = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)NscAdd.pvCommandBuffer;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync NscAdd.pvCommandBuffer = (VOID*)(((uint8_t*)NscAdd.pvCommandBuffer) + sizeof (*pHdr));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDMDISP_ALLOCATION pAlloc = RTListGetFirst(&pDevice->DirtyAllocList, VBOXWDDMDISP_ALLOCATION, DirtyAllocListEntry);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync HRESULT tmpHr = vboxWddmNSCAddAlloc(&NscAdd, pAlloc);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync RenderData.CommandLength = pDevice->DefaultContext.ContextInfo.CommandBufferSize - NscAdd.cbCommandBuffer;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync RenderData.NumAllocations = pDevice->DefaultContext.ContextInfo.AllocationListSize - NscAdd.cAllocationList;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(RenderData.NumAllocations == NscAdd.cAllocations);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync RenderData.NumPatchLocations = pDevice->DefaultContext.ContextInfo.PatchLocationListSize - NscAdd.cPatchLocationList;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(RenderData.NumPatchLocations == NscAdd.cAllocations);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync// RenderData.NewCommandBufferSize = sizeof (VBOXVDMACMD) + 4 * (100);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync// RenderData.NewAllocationListSize = 100;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync// RenderData.NewPatchLocationListSize = 100;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync RenderData.hContext = pDevice->DefaultContext.ContextInfo.hContext;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync HRESULT hr = pDevice->RtCallbacks.pfnRenderCb(pDevice->hDevice, &RenderData);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pDevice->DefaultContext.ContextInfo.CommandBufferSize = RenderData.NewCommandBufferSize;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pDevice->DefaultContext.ContextInfo.pCommandBuffer = RenderData.pNewCommandBuffer;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pDevice->DefaultContext.ContextInfo.AllocationListSize = RenderData.NewAllocationListSize;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pDevice->DefaultContext.ContextInfo.pAllocationList = RenderData.pNewAllocationList;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pDevice->DefaultContext.ContextInfo.PatchLocationListSize = RenderData.NewPatchLocationListSize;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pDevice->DefaultContext.ContextInfo.pPatchLocationList = RenderData.pNewPatchLocationList;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync } while (1);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync//#define VBOX_WDDM_SHRC_WO_NOTIFY
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic BOOLEAN vboxWddmDalCheckAdd(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOLEAN fWrite)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if (!pAlloc->hAllocation /* only shared resources matter */
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(!pAlloc->DirtyAllocListEntry.pNext || (!fWrite && pAlloc->hSharedHandle && pAlloc->fDirtyWrite));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync RTListAppend(&pDevice->DirtyAllocList, &pAlloc->DirtyAllocListEntry);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic DECLINLINE(BOOLEAN) vboxWddmDalCheckAddRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, BOOLEAN fWrite)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDMDISP_ALLOCATION pDAlloc = &pRc->aAllocations[i];
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync fChanged |= vboxWddmDalCheckAdd(pDevice, pDAlloc, fWrite);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic VOID vboxWddmDalCheckAddRtsSamplers(PVBOXWDDMDISP_DEVICE pDevice)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync vboxWddmDalCheckAdd(pDevice, pDevice->apRTs[i], TRUE);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync for (UINT i = 0, iSampler = 0; iSampler < pDevice->cSamplerTextures; ++i)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(i < RT_ELEMENTS(pDevice->aSamplerTextures));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync vboxWddmDalCheckAddRc(pDevice, pDevice->aSamplerTextures[i], FALSE);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic bool vboxVhwaIsEnabled(PVBOXWDDMDISP_ADAPTER pAdapter)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if (pAdapter->aHeads[i].Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync return true;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync return false;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic bool vboxVhwaHasCKeying(PVBOXWDDMDISP_ADAPTER pAdapter)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXVHWA_INFO* pSettings = &pAdapter->aHeads[i].Vhwa.Settings;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync return true;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync return false;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic void vboxResourceFree(PVBOXWDDMDISP_RESOURCE pRc)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncvoid vboxWddmResourceInit(PVBOXWDDMDISP_RESOURCE pRc, UINT cAllocs)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync memset(pRc, 0, RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs]));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic PVBOXWDDMDISP_RESOURCE vboxResourceAlloc(UINT cAllocs)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)RTMemAlloc(RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs]));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic void vboxWddmDbgSynchMemCheck(PVBOXWDDMDISP_ALLOCATION pAlloc, D3DLOCKED_RECT *pLockInfo)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync iRc = memcmp(pLockInfo->pBits, pAlloc->pvMem, pAlloc->SurfDesc.cbSize);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(pAlloc->SurfDesc.pitch <= (UINT)pLockInfo->Pitch);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync uint32_t cRows = vboxWddmCalcNumRows(0, pAlloc->SurfDesc.height, pAlloc->SurfDesc.format);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic VOID vboxWddmDbgRcSynchMemCheck(PVBOXWDDMDISP_RESOURCE pRc)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync HRESULT hr = VBoxD3DIfLockRect(pRc, i, &Rect, NULL, D3DLOCK_READONLY);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic HRESULT vboxWddmRenderTargetSet(PVBOXWDDMDISP_DEVICE pDevice, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncDECLINLINE(VOID) vboxWddmSwapchainInit(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync memset(pSwapchain, 0, sizeof (VBOXWDDMDISP_SWAPCHAIN));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic HRESULT vboxWddmSwapchainKmSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync D3DKMT_HANDLE ahAllocs[VBOXWDDMDISP_MAX_SWAPCHAIN_SIZE];
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync memset(&Buf.SwapchainInfo, 0, sizeof (Buf.SwapchainInfo));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Buf.SwapchainInfo.EscapeHdr.escapeCode = VBOXESC_SWAPCHAININFO;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Buf.SwapchainInfo.SwapchainInfo.hSwapchainKm = pSwapchain->hSwapchainKm;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Buf.SwapchainInfo.SwapchainInfo.hSwapchainUm = (VBOXDISP_UMHANDLE)pSwapchain;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync// Buf.SwapchainInfo.SwapchainInfo.Rect;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync// Buf.SwapchainInfo.SwapchainInfo.u32Reserved;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Buf.SwapchainInfo.SwapchainInfo.cAllocs = pSwapchain->cRTs;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync for (UINT i = 0; i < Buf.SwapchainInfo.SwapchainInfo.cAllocs; ++i)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync// Assert(pSwapchain->aRTs[i].pAlloc->hAllocation);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Buf.SwapchainInfo.SwapchainInfo.ahAllocs[i] = pSwapchain->aRTs[i].pAlloc->hAllocation;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(cAllocsKm == Buf.SwapchainInfo.SwapchainInfo.cAllocs || !cAllocsKm);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if (cAllocsKm == Buf.SwapchainInfo.SwapchainInfo.cAllocs)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync DdiEscape.hContext = pDevice->DefaultContext.ContextInfo.hContext;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync // DdiEscape.Flags.Value = 0;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync DdiEscape.PrivateDriverDataSize = RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[Buf.SwapchainInfo.SwapchainInfo.cAllocs]);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pSwapchain->hSwapchainKm = Buf.SwapchainInfo.SwapchainInfo.hSwapchainKm;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic HRESULT vboxWddmSwapchainKmDestroy(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync /* submit empty swapchain to destroy the KM one */
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync hr = vboxWddmSwapchainKmSynch(pDevice, pSwapchain);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic HRESULT vboxWddmSwapchainDestroyIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncDECLINLINE(VOID) vboxWddmSwapchainClear(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync /* first do a Km destroy to ensure all km->um region submissions are completed */
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync vboxDispMpInternalCancel(&pDevice->DefaultContext, pSwapchain);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncVOID vboxWddmSwapchainDestroy(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic VOID vboxWddmSwapchainDestroyAll(PVBOXWDDMDISP_DEVICE pDevice)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDMDISP_SWAPCHAIN pCur = RTListGetFirst(&pDevice->SwapchainList, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync if (!RTListNodeIsLast(&pDevice->SwapchainList, &pCur->ListEntry))
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync pNext = RTListNodeGetNext(&pCur->ListEntry, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncstatic PVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainAlloc(PVBOXWDDMDISP_DEVICE pDevice)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDMDISP_SWAPCHAIN pSwapchain = (PVBOXWDDMDISP_SWAPCHAIN)RTMemAllocZ(sizeof (VBOXWDDMDISP_SWAPCHAIN));
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync RTListAppend(&pDevice->SwapchainList, &pSwapchain->ListEntry);
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncDECLINLINE(VOID) vboxWddmSwapchainRtInit(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRt, PVBOXWDDMDISP_ALLOCATION pAlloc)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsyncDECLINLINE(VOID) vboxWddmSwapchainBbAddTail(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bAssignAsBb)
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync VBOXWDDMDISP_SWAPCHAIN_FLAGS fOldFlags = pSwapchain->fFlags;
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[pSwapchain->cRTs];
d84b6107a8e797f41ac2d55bed97b02c91c742e8vboxsync Assert(pSwapchain->iBB == VBOXWDDMDISP_INDEX_UNDEFINED);
DECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainRtForAlloc(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc)
return NULL;
Assert(0);
return NULL;
DECLINLINE(UINT) vboxWddmSwapchainRtIndex(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
return iRt;
DECLINLINE(VOID) vboxWddmSwapchainRtRemove(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
DECLINLINE(VOID) vboxWddmSwapchainSetBb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
PVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainFindCreate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc, BOOL *pbNeedPresent)
if (pSwapchain)
return pSwapchain;
if (!pSwapchain)
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
&& vboxWddmFmtNoAlphaFormat(pBbAlloc->SurfDesc.format) == vboxWddmFmtNoAlphaFormat(pRt->pAlloc->SurfDesc.format)
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)
return S_OK;
iBb = 0;
return hr;
return hr;
#ifdef DEBUG_misha
VBOXVDBG_CHECK_SWAPCHAIN_SYNC(hr = pDevice->pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9Surf, NULL, D3DTEXF_NONE); Assert(hr == S_OK),
if (pD3D9OldSurf)
VBOXVDBG_CHECK_SWAPCHAIN_SYNC(tmpHr = pDevice->pDevice9If->StretchRect(pD3D9Bb, NULL, (IDirect3DSurface9*)vboxWddmSwapchainGetBb(pSwapchain)->pAlloc->pD3DIf, NULL, D3DTEXF_NONE); Assert(tmpHr == S_OK),
pAlloc, pD3D9Bb, NULL, pAlloc, (IDirect3DSurface9*)vboxWddmSwapchainGetBb(pSwapchain)->pAlloc->pD3DIf, NULL);
return hr;
static HRESULT vboxWddmSwapchainSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
return hr;
static VOID vboxWddmSwapchainFillPresentParams(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*/
static HRESULT vboxWddmSwapchainSwtichOffscreenRt(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, BOOL fForceCreate)
if (pOldIf)
return hr;
if (fHasSurf)
if (pD3D9OldSurf)
if (pD3D9OldSurf)
VBOXVDBG_CHECK_SWAPCHAIN_SYNC(hr = pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9NewSurf, NULL, D3DTEXF_NONE); Assert(hr == S_OK),
if (pD3D9OldSurf)
if (pD3D9OldSurf)
return hr;
static HRESULT vboxWddmSwapchainSwtichRtPresent(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
return S_OK;
return hr;
return hr;
HRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
return S_OK;
if (pOldIf)
if (fNeedRtPresentSwitch)
if (!bReuseSwapchain)
hr = pAdapter->D3D.pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, fFlags, &Params.Base, &pDevice9If);
if (pOldIf)
return hr;
if (fNeedRtPresentSwitch)
#ifndef VBOXWDDM_WITH_VISIBLE_FB
#ifdef DEBUG
if (pOldIf)
return S_OK;
static HRESULT vboxWddmSwapchainCreateIfForRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, PVBOXWDDMDISP_SWAPCHAIN *ppSwapchain)
if (pSwapchain)
return hr;
return E_OUTOFMEMORY;
static HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain);
static HRESULT vboxWddmSwapchainBbUpdate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pBbAlloc)
return S_OK;
return hr;
return E_FAIL;
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 */
return hr;
return S_OK;
static HRESULT vboxWddmSwapchainRtSurfGet(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch, IDirect3DSurface9 **ppSurf)
if (!bOnSwapchainSynch)
if (iRt == 0)
return hr;
return hr;
return hr;
return S_OK;
static HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
return hr;
return hr;
return hr;
return hr;
static HRESULT vboxWddmSwapchainPresent(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc)
/* we currently *assume* that presenting shared resource is only possible when 3d app is rendering with composited desktop on,
HRESULT hr = pDevice->pAdapter->D3D.D3D.pfnVBoxWineExD3DDev9Flush((IDirect3DDevice9Ex*)pDevice->pDevice9If);
return S_OK;
if (!bNeedPresent)
return S_OK;
if (pSwapchain)
return hr;
return E_OUTOFMEMORY;
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
if (iNewRTFB == i)
# define VBOXVDBG_RTGT_STATECHECK(_pDev) (vboxWddmDbgRenderTargetCheck((_pDev), (_pDev)->aScreens[(_pDev)->iPrimaryScreen].pRenderTargetRc, (_pDev)->aScreens[(_pDev)->iPrimaryScreen].iRenderTargetFrontBuf))
static HRESULT vboxWddmRenderTargetSet(PVBOXWDDMDISP_DEVICE pDevice, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch)
if (pSwapchain)
return hr;
return hr;
return hr;
switch (dwReason)
case DLL_PROCESS_ATTACH:
#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
return TRUE;
#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
case DLL_PROCESS_DETACH:
#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
return TRUE;
return TRUE;
return FALSE;
case D3DDDICAPS_DDRAW:
#ifdef VBOX_WITH_VIDEOHWACCEL
#ifdef VBOX_WITH_VIDEOHWACCEL
case D3DDDICAPS_GETFORMATDATA:
memcpy(pData->pData, pAdapter->Formats.paFormstOps, pAdapter->Formats.cFormstOps * sizeof (FORMATOP));
Assert(0);
case D3DDDICAPS_GETD3D3CAPS:
case D3DDDICAPS_GETD3D7CAPS:
case D3DDDICAPS_GETD3D9CAPS:
case D3DDDICAPS_GETD3D8CAPS:
case D3DDDICAPS_GETD3D5CAPS:
case D3DDDICAPS_GETD3D6CAPS:
Assert(0);
Assert(0);
return S_OK;
static HRESULT APIENTRY vboxWddmDDevSetRenderState(HANDLE hDevice, CONST D3DDDIARG_RENDERSTATE* pData)
return hr;
return S_OK;
static HRESULT APIENTRY vboxWddmDDevValidateDevice(HANDLE hDevice, D3DDDIARG_VALIDATETEXTURESTAGESTATE* pData)
#ifdef DEBUG_misha
Assert(0);
return S_OK;
static HRESULT APIENTRY vboxWddmDDevSetTextureStageState(HANDLE hDevice, CONST D3DDDIARG_TEXTURESTAGESTATE* pData)
hr = pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value);
return hr;
if (pRc)
Assert(0);
if (idx >= 0)
#ifdef DEBUG_misha
if (idx >= 0)
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)
#ifdef DEBUG
((uint8_t*)pDevice->aStreamSourceUm[0].pvBuffer) + pData->VStart * pDevice->aStreamSourceUm[0].cbStride,
Assert(0);
#ifdef DEBUG
++cStreams;
return hr;
static HRESULT APIENTRY vboxWddmDDevDrawIndexedPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWINDEXEDPRIMITIVE* pData)
#ifdef DEBUG
++cStreams;
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)
int stream;
IDirect3DVertexBuffer9 *pD3D9VBuf = (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf;
RECT r;
r.top = 0;
VBoxD3DIfLockUnlockMemSynch(pDevice->aStreamSource[stream], &pLock->LockedRect, &r, true /*bool bToLockInfo*/);
hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount);
#ifdef DEBUG
int stream;
#ifdef DEBUG
++cStreams;
(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);
hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);
#ifdef DEBUG
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);
return E_FAIL;
Assert(0);
return E_FAIL;
#ifdef DEBUG
RECT tstRect = {0,0, pDstRc->aAllocations[0].SurfDesc.width, pDstRc->aAllocations[0].SurfDesc.height};
hr = pDevice9If->StretchRect(pSrcSurfIf, &pData->SrcRect, pDstSurfIf, &DstRect, D3DTEXF_NONE); Assert(hr == S_OK),
return hr;
Assert(0);
return E_FAIL;
return S_OK;
static HRESULT APIENTRY vboxWddmDDevClear(HANDLE hDevice, CONST D3DDDIARG_CLEAR* pData, UINT NumRect, CONST RECT* pRect)
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)
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)
switch (DevInfoID)
case D3DDDIDEVINFOID_VCACHE:
Assert(0);
return hr;
return E_INVALIDARG;
// Assert(pRc != pScreen->pRenderTargetRc || pScreen->iRenderTargetFrontBuf != pData->SubResourceIndex);
bool bNeedResynch = false;
Assert(0);
if (pRect)
Assert(0);
Assert(0);
bLocked = true;
if (pRange)
if (pRange)
r.top = 0;
pr = &r;
bLocked = true;
if (pRange)
if (pRange)
r.top = 0;
pr = &r;
Assert(0);
offset = vboxWddmCalcOffXYrd(pData->Area.left, pData->Area.top, pAlloc->SurfDesc.pitch, pAlloc->SurfDesc.format);
Assert(0);
offset = 0;
return hr;
return E_INVALIDARG;
Assert(0);
// Assert(!pAlloc->LockInfo.cLocks);
r.top = 0;
pr = &r;
pr,
// Assert(!pAlloc->LockInfo.cLocks);
r.top = 0;
pr = &r;
pr,
Assert(0);
if (fDoUnlock)
} 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)
return E_OUTOFMEMORY;
bool bIssueCreateResource = false;
bool bCreateKMResource = false;
pAllocation->SurfDesc.cbSize = vboxWddmCalcSize(pAllocation->SurfDesc.pitch, pAllocation->SurfDesc.height, pAllocation->SurfDesc.format);
bIssueCreateResource = true;
bCreateKMResource = true;
bIssueCreateResource = true;
if (pDdiAllocate)
if (bCreateKMResource)
for (UINT j = 0; i < j; ++j)
return hr;
if (pSwapchain)
return hr;
static HRESULT APIENTRY vboxWddmDDevSetDisplayMode(HANDLE hDevice, CONST D3DDDIARG_SETDISPLAYMODE* pData)
return hr;
#ifdef VBOXWDDM_TEST_UHGSMI
#ifdef VBOXWDDM_TEST_UHGSMI
VBoxDispProfileScopeLogger<VBoxDispProfileEntry> profilePresentCbLogger(pDevice->ProfileDdiPresentCb.alloc("pfnPresentCb"));
#ifdef VBOXWDDMDISP_DEBUG_TIMER
#ifdef VBOXWDDMDISP_DEBUG_TIMER
return hr;
hr = pDevice->pAdapter->D3D.D3D.pfnVBoxWineExD3DDev9Flush((IDirect3DDevice9Ex*)pDevice->pDevice9If);
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;
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;
Assert(!pDstSwapchain || vboxWddmSwapchainGetFb(pDstSwapchain)->pAlloc != pDstAlloc || vboxWddmSwapchainNumRTs(pDstSwapchain) == 1);
if (pSrcSwapchain)
Assert((pData->Flags.Value & (~(0x00000100 | 0x00000200 | 0x00000400 | 0x00000001 | 0x00000002))) == 0);
VBOXVDBG_CHECK_BLT(hr = pDevice9If->StretchRect(pSrcSurfIf, &pData->SrcRect, pDstSurfIf, &pData->DstRect, vboxDDI2D3DBltFlags(pData->Flags)); Assert(hr == S_OK),
Assert(0);
return hr;
return hr;
Assert(0);
return E_FAIL;
if (!pQuery)
return E_OUTOFMEMORY;
return hr;
return hr;
return hr;
return hr;
static HRESULT APIENTRY vboxWddmDDevGetQueryData(HANDLE hDevice, CONST D3DDDIARG_GETQUERYDATA* pData)
#ifdef DEBUG
case D3DDDIQUERYTYPE_EVENT:
Assert(0);
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;
#ifdef VBOXWDDMDISP_DEBUG_TIMER
* Release may not work in case of some leaking, which will leave the crOgl context refering the destroyed VBOXUHGSMI */
return hr;
if (pOverlay)
#ifndef VBOXWDDMOVERLAY_TEST
return hr;
static HRESULT APIENTRY vboxWddmDDevUpdateOverlay(HANDLE hDevice, CONST D3DDDIARG_UPDATEOVERLAY* pData)
#ifndef VBOXWDDMOVERLAY_TEST
return hr;
#ifndef VBOXWDDMOVERLAY_TEST
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
return hr;
static HRESULT APIENTRY vboxWddmDDevQueryResourceResidency(HANDLE hDevice, CONST D3DDDIARG_QUERYRESOURCERESIDENCY* pData)
return hr;
if (pRc)
#ifndef VBOXWDDMDISP_DEBUG_NOSHARED
Assert(!pAllocation->hSharedHandle == (pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE));
if (pDdiAllocInfo->pPrivateDriverData && pDdiAllocInfo->PrivateDriverDataSize >= sizeof (VBOXWDDM_ALLOCINFO))
Assert(0);
vboxVDbgPrintR((__FUNCTION__": vboxResourceAlloc failed for hDevice(0x%p), NumAllocations(%d)\n", hDevice, pData->NumAllocations));
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));
PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_DEVICE, apRTs[pAdapter->D3D.cMaxSimRTs]));
if (pDevice)
pCreateData->pDeviceFuncs->pfnSetVideoProcessRenderTarget = vboxWddmDDevSetVideoProcessRenderTarget;
#ifdef VBOX_WDDMDISP_WITH_PROFILE
#ifdef VBOXWDDMDISP_DEBUG_TIMER
#ifdef VBOXDISP_EARLYCREATEDEVICE
if (pRc)
// params.hDeviceWindow = hWnd;
# ifdef VBOXDISP_TEST_SWAPCHAIN
vboxVDbgPrintR((__FUNCTION__": Not implemented: PatchLocationListSize(%d), AllocationListSize(%d)\n",
return hr;
#ifdef VBOX_WITH_VIDEOHWACCEL
return S_OK;
return FALSE;
if (!hDDraw)
return FALSE;
return FALSE;
if (VBOXDISP_IS_MODULE_FUNC(ModuleInfo.lpBaseOfDll, ModuleInfo.SizeOfImage, pOpenData->pAdapterCallbacks->pfnQueryAdapterInfoCb))
return TRUE;
if (VBOXDISP_IS_MODULE_FUNC(ModuleInfo.lpBaseOfDll, ModuleInfo.SizeOfImage, pOpenData->pAdapterCallbacks->pfnGetMultisampleMethodListCb))
return TRUE;
return FALSE;
exit(0);
return E_FAIL;
#ifdef VBOX_WITH_VIDEOHWACCEL
PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)RTMemAllocZ(RT_OFFSETOF(VBOXWDDMDISP_ADAPTER, aHeads[Query.cInfos]));
if (pAdapter)
#ifdef VBOX_WITH_VIDEOHWACCEL
return hr;