VBoxDispD3D.cpp revision 9441dbf0fb711026d58d0c64d61a6dcfc3c6784d
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * VBoxVideo Display D3D User mode dll
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * Copyright (C) 2011 Oracle Corporation
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * available from http://www.virtualbox.org. This file is free software;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * you can redistribute it and/or modify it under the terms of the GNU
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * General Public License (GPL) as published by the Free Software
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncvolatile uint32_t g_u32VBoxDispProfileFunctionLoggerIndex = 0;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync/* uncomment to enable particular logging */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync/* allows dumping fps + how much time is spent in ddi functions in comparison with the rest time */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_ENABLE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync/* allows dumping time spent in each function and the number of calls made for any given function */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBoxDispProfileDevicePostProcess(PVBOXWDDMDISP_DEVICE pDevice) :
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync m_pDevice->pAdapter->D3D.D3D.pfnVBoxWineExD3DDev9Finish((IDirect3DDevice9Ex *)m_pDevice->pDevice9If);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//static VBoxDispProfileSet g_VBoxDispProfileDDI("D3D_DDI");
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE_DEV(_pObj) VBOXDISPPROFILE_FUNCTION_LOGGER_DEFINE((_pObj)->ProfileDdiFunc, VBoxDispProfileDevicePostProcess, VBoxDispProfileDevicePostProcess(_pObj))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE_BASE(_pObj) VBOXDISPPROFILE_FUNCTION_LOGGER_DEFINE((_pObj)->ProfileDdiFunc, VBoxDispProfileDummyPostProcess, VBoxDispProfileDummyPostProcess())
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DUMP(_pObj) do {\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj) do {\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_FUNCTION_LOGGER_DISABLE_CURRENT();\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT() VBOXDISPPROFILE_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT()
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pObj) do { \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (!((_pObj)->ProfileDdiFunc.reportIteration() % 31) /*&& !VBOXVDBG_IS_DWM()*/) {\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE_DEV(_pObj) do {} while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE_BASE(_pObj) do {} while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DUMP(_pObj) do {} while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj) do {} while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_DISABLE_CURRENT() do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT() do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pDev) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//static VBoxDispProfileFpsCounter g_VBoxDispFpsDDI(64);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(_pObj) VBOXDISPPROFILE_STATISTIC_LOGGER_DEFINE(&(_pObj)->ProfileDdiFps, VBoxDispProfileDummyPostProcess, VBoxDispProfileDummyPostProcess())
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_STATISTIC_LOGGER_DISABLE_CURRENT();\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DUMP(_pObj) do { \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync double tup = (_pObj)->ProfileDdiFps.GetTimeProcPercent(); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DUMP(("[0x%p]: fps: %f, cps: %.1f, host %.1f%%", (_pObj), fps, cps, tup)); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pObj) do { \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if(!((_pObj)->ProfileDdiFps.GetNumFrames() % 31)) \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DUMP(_pObj); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT() VBOXDISPPROFILE_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT()
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(_pObj) do {} while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DISABLE_CURRENT() do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT() do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_DUMP(_pObj) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE_DEV(_pObj) \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE_DEV(_pObj); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(_pObj);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE_BASE(_pObj) \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_PROLOGUE_BASE(_pObj); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_PROLOGUE(_pObj);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_LOG_AND_DISABLE_CURRENT() \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_LOG_AND_DISABLE_CURRENT(); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_LOG_AND_DISABLE_CURRENT();
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pDev); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FLUSH(_pDev) do {\
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_STATISTIC_LOGGER_REPORT_FRAME(_pDev); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_REPORT_FRAME(_pDev); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FLUSH(_pDev) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_INIT_CMN(_pObj, _name, _cEntries) do { \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync (_pObj)->ProfileDdiFps = VBoxDispProfileFpsCounter(); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync (_pObj)->ProfileDdiFunc = VBoxDispProfileSet(_name); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_DDI_FUNCTION_LOGGER_RESET(_pObj); \
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_PRINT(_m) VBOXDISPPROFILE_DUMP(_m)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_INIT_GLBL() VBOXDISPPROFILE_DDI_INIT_CMN(&g_VBoxDispProfile, "DDI_Adp", 64)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_INIT_ADP(_pAdp) VBOXDISPPROFILE_DDI_INIT_CMN(_pAdp, "DDI_Adp", 64)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_INIT_DEV(_pDev) VBOXDISPPROFILE_DDI_INIT_CMN(_pDev, "DDI_Dev", 64)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE_DEV(_pObj) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE_BASE(_pObj) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FRAME(_pDev) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_REPORT_FLUSH(_pDev) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_INIT_GLBL() do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_INIT_ADP(_pAdp) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_INIT_DEV(_pDev) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_TERM(_pObj) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXDISPPROFILE_DDI_PRINT(_m) do {} while (0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync/* debugging/profiling stuff could go here.
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * NOP in release */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE_DEV((PVBOXWDDMDISP_DEVICE)(_hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE_BASE((PVBOXWDDMDISP_ADAPTER)(_hAdapter));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXDISPPROFILE_FUNCTION_DDI_PROLOGUE_BASE(&g_VBoxDispProfile);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//#define VBOXWDDMOVERLAY_TEST
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// D3DDDIQUERYTYPE_OCCLUSION
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync#define VBOX_QUERYTYPE_COUNT() RT_ELEMENTS(gVBoxQueryTypes)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync#define VBOXDISPCRHGSMI_SCOPE_SET_DEV(_pDev) do {} while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync#define VBOXDISPCRHGSMI_SCOPE_SET_GLOBAL() do {} while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmNSCAddAlloc(PVBOXWDDMDISP_NSCADD pData, PVBOXWDDMDISP_ALLOCATION pAlloc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pData->cAllocationList && pData->cPatchLocationList && pData->cbCommandBuffer > 4)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset(pData->pAllocationList, 0, sizeof (D3DDDI_ALLOCATIONLIST));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pData->pAllocationList[0].hAllocation = pAlloc->hAllocation;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset(pData->pPatchLocationList, 0, sizeof (D3DDDI_PATCHLOCATIONLIST));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pData->pPatchLocationList[0].PatchOffset = pData->cAllocations*4;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pData->pPatchLocationList[0].AllocationIndex = pData->cAllocations;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pData->pvCommandBuffer = (VOID*)(((uint8_t*)pData->pvCommandBuffer) + 4);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic BOOLEAN vboxWddmDalCheckRemove(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmDalNotifyChange(PVBOXWDDMDISP_DEVICE pDevice)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync NscAdd.pvCommandBuffer = pDevice->DefaultContext.ContextInfo.pCommandBuffer;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync NscAdd.cbCommandBuffer = pDevice->DefaultContext.ContextInfo.CommandBufferSize;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync NscAdd.pAllocationList = pDevice->DefaultContext.ContextInfo.pAllocationList;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync NscAdd.cAllocationList = pDevice->DefaultContext.ContextInfo.AllocationListSize;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync NscAdd.pPatchLocationList = pDevice->DefaultContext.ContextInfo.pPatchLocationList;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync NscAdd.cPatchLocationList = pDevice->DefaultContext.ContextInfo.PatchLocationListSize;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(NscAdd.cbCommandBuffer >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (NscAdd.cbCommandBuffer < sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pHdr = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)NscAdd.pvCommandBuffer;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync NscAdd.pvCommandBuffer = (VOID*)(((uint8_t*)NscAdd.pvCommandBuffer) + sizeof (*pHdr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pAlloc = RTListGetFirst(&pDevice->DirtyAllocList, VBOXWDDMDISP_ALLOCATION, DirtyAllocListEntry);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT tmpHr = vboxWddmNSCAddAlloc(&NscAdd, pAlloc);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync RenderData.CommandLength = pDevice->DefaultContext.ContextInfo.CommandBufferSize - NscAdd.cbCommandBuffer;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync RenderData.NumAllocations = pDevice->DefaultContext.ContextInfo.AllocationListSize - NscAdd.cAllocationList;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(RenderData.NumAllocations == NscAdd.cAllocations);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync RenderData.NumPatchLocations = pDevice->DefaultContext.ContextInfo.PatchLocationListSize - NscAdd.cPatchLocationList;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(RenderData.NumPatchLocations == NscAdd.cAllocations);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// RenderData.NewCommandBufferSize = sizeof (VBOXVDMACMD) + 4 * (100);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// RenderData.NewAllocationListSize = 100;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// RenderData.NewPatchLocationListSize = 100;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync RenderData.hContext = pDevice->DefaultContext.ContextInfo.hContext;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice->RtCallbacks.pfnRenderCb(pDevice->hDevice, &RenderData);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pDevice->DefaultContext.ContextInfo.CommandBufferSize = RenderData.NewCommandBufferSize;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pDevice->DefaultContext.ContextInfo.pCommandBuffer = RenderData.pNewCommandBuffer;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pDevice->DefaultContext.ContextInfo.AllocationListSize = RenderData.NewAllocationListSize;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pDevice->DefaultContext.ContextInfo.pAllocationList = RenderData.pNewAllocationList;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pDevice->DefaultContext.ContextInfo.PatchLocationListSize = RenderData.NewPatchLocationListSize;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pDevice->DefaultContext.ContextInfo.pPatchLocationList = RenderData.pNewPatchLocationList;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync } while (1);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//#define VBOX_WDDM_SHRC_WO_NOTIFY
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic BOOLEAN vboxWddmDalCheckAdd(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOLEAN fWrite)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (!pAlloc->hAllocation /* only shared resources matter */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(!pAlloc->DirtyAllocListEntry.pNext || (!fWrite && pAlloc->hSharedHandle && pAlloc->fDirtyWrite));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync RTListAppend(&pDevice->DirtyAllocList, &pAlloc->DirtyAllocListEntry);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic DECLINLINE(BOOLEAN) vboxWddmDalCheckAddRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, BOOLEAN fWrite)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pDAlloc = &pRc->aAllocations[i];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync fChanged |= vboxWddmDalCheckAdd(pDevice, pDAlloc, fWrite);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic VOID vboxWddmDalCheckAddRtsSamplers(PVBOXWDDMDISP_DEVICE pDevice)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmDalCheckAdd(pDevice, pDevice->apRTs[i], TRUE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 0, iSampler = 0; iSampler < pDevice->cSamplerTextures; ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(i < RT_ELEMENTS(pDevice->aSamplerTextures));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmDalCheckAddRc(pDevice, pDevice->aSamplerTextures[i], FALSE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic bool vboxVhwaIsEnabled(PVBOXWDDMDISP_ADAPTER pAdapter)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pAdapter->aHeads[i].Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync return true;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync return false;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic bool vboxVhwaHasCKeying(PVBOXWDDMDISP_ADAPTER pAdapter)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXVHWA_INFO* pSettings = &pAdapter->aHeads[i].Vhwa.Settings;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync return true;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync return false;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic void vboxResourceFree(PVBOXWDDMDISP_RESOURCE pRc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncvoid vboxWddmResourceInit(PVBOXWDDMDISP_RESOURCE pRc, UINT cAllocs)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset(pRc, 0, RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs]));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic PVBOXWDDMDISP_RESOURCE vboxResourceAlloc(UINT cAllocs)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)RTMemAlloc(RT_OFFSETOF(VBOXWDDMDISP_RESOURCE, aAllocations[cAllocs]));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic void vboxWddmDbgSynchMemCheck(PVBOXWDDMDISP_ALLOCATION pAlloc, D3DLOCKED_RECT *pLockInfo)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync iRc = memcmp(pLockInfo->pBits, pAlloc->pvMem, pAlloc->SurfDesc.cbSize);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pAlloc->SurfDesc.pitch <= (UINT)pLockInfo->Pitch);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync uint32_t cRows = vboxWddmCalcNumRows(0, pAlloc->SurfDesc.height, pAlloc->SurfDesc.format);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic VOID vboxWddmDbgRcSynchMemCheck(PVBOXWDDMDISP_RESOURCE pRc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = VBoxD3DIfLockRect(pRc, i, &Rect, NULL, D3DLOCK_READONLY);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pAlloc = &pRc->aAllocations[i];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmRenderTargetSet(PVBOXWDDMDISP_DEVICE pDevice, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(VOID) vboxWddmSwapchainInit(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset(pSwapchain, 0, sizeof (VBOXWDDMDISP_SWAPCHAIN));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainKmSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync D3DKMT_HANDLE ahAllocs[VBOXWDDMDISP_MAX_SWAPCHAIN_SIZE];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset(&Buf.SwapchainInfo, 0, sizeof (Buf.SwapchainInfo));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Buf.SwapchainInfo.EscapeHdr.escapeCode = VBOXESC_SWAPCHAININFO;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Buf.SwapchainInfo.SwapchainInfo.hSwapchainKm = pSwapchain->hSwapchainKm;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Buf.SwapchainInfo.SwapchainInfo.hSwapchainUm = (VBOXDISP_UMHANDLE)pSwapchain;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// Buf.SwapchainInfo.SwapchainInfo.Rect;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// Buf.SwapchainInfo.SwapchainInfo.u32Reserved;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Buf.SwapchainInfo.SwapchainInfo.cAllocs = pSwapchain->cRTs;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 0; i < Buf.SwapchainInfo.SwapchainInfo.cAllocs; ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// Assert(pSwapchain->aRTs[i].pAlloc->hAllocation);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Buf.SwapchainInfo.SwapchainInfo.ahAllocs[i] = pSwapchain->aRTs[i].pAlloc->hAllocation;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(cAllocsKm == Buf.SwapchainInfo.SwapchainInfo.cAllocs || !cAllocsKm);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (cAllocsKm == Buf.SwapchainInfo.SwapchainInfo.cAllocs)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync DdiEscape.hContext = pDevice->DefaultContext.ContextInfo.hContext;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync // DdiEscape.Flags.Value = 0;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync DdiEscape.PrivateDriverDataSize = RT_OFFSETOF(VBOXDISPIFESCAPE_SWAPCHAININFO, SwapchainInfo.ahAllocs[Buf.SwapchainInfo.SwapchainInfo.cAllocs]);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice->RtCallbacks.pfnEscapeCb(pDevice->pAdapter->hAdapter, &DdiEscape);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pSwapchain->hSwapchainKm = Buf.SwapchainInfo.SwapchainInfo.hSwapchainKm;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainKmDestroy(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* submit empty swapchain to destroy the KM one */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainKmSynch(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainDestroyIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(VOID) vboxWddmSwapchainClear(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* first do a Km destroy to ensure all km->um region submissions are completed */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxDispMpInternalCancel(&pDevice->DefaultContext, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncVOID vboxWddmSwapchainDestroy(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic VOID vboxWddmSwapchainDestroyAll(PVBOXWDDMDISP_DEVICE pDevice)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pCur = RTListGetFirst(&pDevice->SwapchainList, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (!RTListNodeIsLast(&pDevice->SwapchainList, &pCur->ListEntry))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pNext = RTListNodeGetNext(&pCur->ListEntry, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic PVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainAlloc(PVBOXWDDMDISP_DEVICE pDevice)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pSwapchain = (PVBOXWDDMDISP_SWAPCHAIN)RTMemAllocZ(sizeof (VBOXWDDMDISP_SWAPCHAIN));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync RTListAppend(&pDevice->SwapchainList, &pSwapchain->ListEntry);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(VOID) vboxWddmSwapchainRtInit(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRt, PVBOXWDDMDISP_ALLOCATION pAlloc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(VOID) vboxWddmSwapchainBbAddTail(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bAssignAsBb)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXWDDMDISP_SWAPCHAIN_FLAGS fOldFlags = pSwapchain->fFlags;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[pSwapchain->cRTs];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pSwapchain->iBB == VBOXWDDMDISP_INDEX_UNDEFINED);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync else if (pSwapchain->cRTs == 2) /* the first one is a frontbuffer */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(VOID) vboxWddmSwapchainFlip(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pSwapchain->iBB = (pSwapchain->iBB + 1) % pSwapchain->cRTs;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(UINT) vboxWddmSwapchainNumRTs(PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(PVBOXWDDMDISP_RENDERTGT) vboxWddmSwapchainRtForAlloc(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pSwapchain->aRTs[i].pAlloc->pSwapchain = pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* should never happen */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(UINT) vboxWddmSwapchainRtIndex(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync UINT offFirst = RT_OFFSETOF(VBOXWDDMDISP_SWAPCHAIN, aRTs);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync UINT offRT = UINT((uintptr_t)pRT - (uintptr_t)pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(!((offRT - offFirst) % sizeof (VBOXWDDMDISP_RENDERTGT)));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync UINT iRt = (offRT - offFirst) / sizeof (VBOXWDDMDISP_RENDERTGT);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(VOID) vboxWddmSwapchainRtRemove(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync UINT iRt = vboxWddmSwapchainRtIndex(pSwapchain, pRT);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(VOID) vboxWddmSwapchainSetBb(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_RENDERTGT pRT)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync UINT iRt = vboxWddmSwapchainRtIndex(pSwapchain, pRT);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncPVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainFindCreate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc, BOOL *pbNeedPresent)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pSwapchain = pBbAlloc->pSwapchain;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* check if this is what we expect */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRt = vboxWddmSwapchainGetBb(pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pBbAlloc == vboxWddmSwapchainGetFb(pSwapchain)->pAlloc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* the current front-buffer present is requested, don't do anything */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* bad, @todo: correct the swapchain by either removing the Rt and adding it to another swapchain
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * or by removing the pBbAlloc out of it */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//@todo: Assert(0);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRt = vboxWddmSwapchainRtForAlloc(pSwapchain, pBbAlloc);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* first search for the swapchain the alloc might be added to */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pCur = RTListGetFirst(&pDevice->SwapchainList, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRt = vboxWddmSwapchainGetBb(pCur);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && vboxWddmSwapchainRtIndex(pCur, pRt) == 0) /* <- in case we add a rt to the swapchain on present this would mean
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * that the last RT in the swapchain array is now a frontbuffer and
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * thus the aRTs[0] is a backbuffer */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pBbAlloc->SurfDesc.width == pRt->pAlloc->SurfDesc.width
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && pBbAlloc->SurfDesc.height == pRt->pAlloc->SurfDesc.height
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && vboxWddmFmtNoAlphaFormat(pBbAlloc->SurfDesc.format) == vboxWddmFmtNoAlphaFormat(pRt->pAlloc->SurfDesc.format)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && pBbAlloc->SurfDesc.VidPnSourceId == pRt->pAlloc->SurfDesc.VidPnSourceId
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (RTListNodeIsLast(&pDevice->SwapchainList, &pCur->ListEntry))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCur = RTListNodeGetNext(&pCur->ListEntry, VBOXWDDMDISP_SWAPCHAIN, ListEntry);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// if (!pSwapchain) need to create a new one (see below)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmSwapchainBbAddTail(pSwapchain, pBbAlloc, FALSE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic PVBOXWDDMDISP_SWAPCHAIN vboxWddmSwapchainCreateForRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pSwapchain = vboxWddmSwapchainAlloc(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmSwapchainBbAddTail(pSwapchain, &pRc->aAllocations[i], FALSE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncDECLINLINE(UINT) vboxWddmSwapchainIdxBb2Rt(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, uint32_t iBb)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync return iBb != (~0) ? (iBb + pSwapchain->iBB) % pSwapchain->cRTs : vboxWddmSwapchainIdxFb(pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainRtSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, uint32_t iBb)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync UINT iRt = vboxWddmSwapchainIdxBb2Rt(pSwapchain, iBb);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[iRt];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pSwapchain->pSwapChainIf->GetBackBuffer(iBb, D3DBACKBUFFER_TYPE_MONO, &pD3D9Surf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* since this can be texture, need to do the VBoxD3DIfSurfGet magic */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = VBoxD3DIfSurfGet(pAlloc->pRc, pAlloc->iAlloc, &pD3D9OldSurf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* get the old surface's swapchain */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT tmpHr = pD3D9OldSurf->GetContainer(IID_IDirect3DSwapChain9, &pvSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* the swapchain has changed, copy data to the new surface */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* @todo: we can not generally update the render target directly, implement */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXVDBG_CHECK_SWAPCHAIN_SYNC(hr = pDevice->pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9Surf, NULL, D3DTEXF_NONE); Assert(hr == S_OK),
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pAlloc, pD3D9OldSurf, NULL, pAlloc, pD3D9Surf, NULL);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmRenderTargetSet(pDevice, i, pAlloc, TRUE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* only use direct bb if wine is able to handle quick blits bewteen surfaces in one swapchain,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * this is FALSE by now :( */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* here we sync the front-buffer with a backbuffer data*/
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pD3D9Bb = (IDirect3DSurface9*)vboxWddmSwapchainGetBb(pSwapchain)->pAlloc->pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* we use backbuffer as a rt frontbuffer copy, so release the old one and assign the current bb */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT tmpHr = pSwapchain->pSwapChainIf->GetFrontBufferData(pD3D9Bb);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXVDBG_CHECK_SWAPCHAIN_SYNC(tmpHr = pDevice->pDevice9If->StretchRect(pD3D9Bb, NULL, (IDirect3DSurface9*)vboxWddmSwapchainGetBb(pSwapchain)->pAlloc->pD3DIf, NULL, D3DTEXF_NONE); Assert(tmpHr == S_OK),
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pAlloc, pD3D9Bb, NULL, pAlloc, (IDirect3DSurface9*)vboxWddmSwapchainGetBb(pSwapchain)->pAlloc->pD3DIf, NULL);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("GetFrontBufferData failed, hr (0x%x)", tmpHr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainSynch(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (int iBb = -1; iBb < int(pSwapchain->cRTs - 1); ++iBb)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainRtSynch(pDevice, pSwapchain, (UINT)iBb);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainKmSynch(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic VOID vboxWddmSwapchainFillPresentParams(PVBOXWDDMDISP_SWAPCHAIN pSwapchain, D3DPRESENT_PARAMETERS *pParams)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* not supported by wine properly, need to use offscreen render targets and blit their data to swapchain RTs*/
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRt = vboxWddmSwapchainGetBb(pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBoxD3DIfFillPresentParams(pParams, pRc, pSwapchain->cRTs);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync/* copy current rt data to offscreen render targets */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainSwtichOffscreenRt(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, BOOL fForceCreate)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmSwapchainFillPresentParams(pSwapchain, &Params);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DSwapChain9 * pOldIf = pSwapchain->pSwapChainIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pOldIf->GetBackBuffer(~0, D3DBACKBUFFER_TYPE_MONO, &pD3D9OldFb);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* just need a pointer to match */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRT = &pSwapchain->aRTs[i];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pRT->pAlloc->enmD3DIfType != VBOXDISP_D3DIFTYPE_SURFACE)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync BOOL fHasSurf = pRT->pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE ?
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* since this can be texture, need to do the VBoxD3DIfSurfGet magic */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = VBoxD3DIfSurfGet(pRT->pAlloc->pRc, pRT->pAlloc->iAlloc, &pD3D9OldSurf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pD3D9OldSurf->GetContainer(IID_IDirect3DSwapChain9, &pvSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (!pvSwapchain) /* no swapchain, it is already offscreen */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 *pDevice9If = pDevice->pDevice9If;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pRT->pAlloc->hSharedHandle ? &pRT->pAlloc->hSharedHandle : NULL
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXVDBG_CHECK_SWAPCHAIN_SYNC(hr = pDevice9If->StretchRect(pD3D9OldSurf, NULL, pD3D9NewSurf, NULL, D3DTEXF_NONE); Assert(hr == S_OK),
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pRT->pAlloc, pD3D9OldSurf, NULL, pRT->pAlloc, pD3D9NewSurf, NULL);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pRT->pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * @return old RtReportingPresent state
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainSwtichRtPresent(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainSwtichOffscreenRt(pDevice, pSwapchain,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync TRUE /* force offscreen surface creation right away. This way we ensure the swapchain data
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * is always uptodate which allows making the vboxWddmSwapchainRtSynch behave as a nop */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* ensure we update device RTs to offscreen ones we just created */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pRtAlloc = pDevice->apRTs[i];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pAlloc = pSwapchain->aRTs[j].pAlloc;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmRenderTargetSet(pDevice, i, pAlloc, TRUE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncHRESULT vboxWddmSwapchainChkCreateIf(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (!pSwapchain->fFlags.bChanged && pSwapchain->pSwapChainIf)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* preserve the old one */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DSwapChain9 * pOldIf = pSwapchain->pSwapChainIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pSwapchain->fFlags.bSwitchReportingPresent || pSwapchain->cRTs > VBOXWDDMDISP_MAX_DIRECT_RTS)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pSwapchain->fFlags.bSwitchReportingPresent = FALSE;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* indicae switch to Render Target Reporting Present mode is needed */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// vboxWddmSwapchainSwtichRtPresent(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pSwapchain->aRTs[i].pAlloc->enmD3DIfType != VBOXDISP_D3DIFTYPE_SURFACE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && (pSwapchain->aRTs[i].pAlloc->enmD3DIfType != VBOXDISP_D3DIFTYPE_UNDEFINED
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync || pSwapchain->aRTs[i].pAlloc->enmType != VBOXWDDM_ALLOC_TYPE_STD_SHAREDPRIMARYSURFACE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* check if we need to re-create the swapchain */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* the number of swapchain backbuffers does not matter */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (OldParams.BackBufferCount == pSwapchain->cRTs-1)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* first create the new one */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ADAPTER pAdapter = pDevice->pAdapter;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmSwapchainFillPresentParams(pSwapchain, &Params.Base);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync DWORD fFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* @todo: it seems there should be a way to detect this correctly since
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * our vboxWddmDDevSetDisplayMode will be called in case we are using full-screen */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync // params.EnableAutoDepthStencil = FALSE;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync // params.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync // params.Flags;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync // params.FullScreen_RefreshRateInHz;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync // params.FullScreen_PresentationInterval;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pAdapter->D3D.pD3D9If->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, fFlags, &Params.Base, &pDevice9If);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* need to copy data to offscreen rt to ensure the data is preserved
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * since the swapchain data may become invalid once we create a new swapchain
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * and pass the current swapchain's window to it
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * thus vboxWddmSwapchainSynch will not be able to do synchronization */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainSwtichOffscreenRt(pDevice, pSwapchain, FALSE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* re-use swapchain window
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * this will invalidate the previusly used swapchain */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice->pDevice9If->CreateAdditionalSwapChain(&Params.Base, &pNewIf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* to ensure the swapchain is not deleted once we release the pOldIf */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainSwtichRtPresent(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# if defined(VBOXDISP_WITH_WINE_BB_WORKAROUND) && defined(VBOX_WINE_WITH_FAST_INTERSWAPCHAIN_BLT)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* if wine is able to do fast fb->bb blits, we will use backbuffer directly,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * this is NOT possible currently */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* we will assign it to wine backbuffer on a swapchain synch */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmSwapchainFillPresentParams(pSwapchain, &Params);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* ignore any subsequen failures */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RENDERTGT pRt = &pSwapchain->aRTs[i];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pRt->pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync || pRt->pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pRt->pAlloc->pRc->RcDesc.enmPool != D3DDDIPOOL_SYSTEMMEM);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(!pSwapchain->fFlags.bSwitchReportingPresent);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainCreateIfForRc(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, PVBOXWDDMDISP_SWAPCHAIN *ppSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pSwapchain = vboxWddmSwapchainCreateForRc(pDevice, pRc);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = vboxWddmSwapchainChkCreateIf(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainBbUpdate(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pBbAlloc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pCurBb = vboxWddmSwapchainGetBb(pSwapchain)->pAlloc;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = vboxWddmSwapchainPresentPerform(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("vboxWddmSwapchainPresentPerform failed, hr (0x%x)", hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync AssertMsgFailed(("the given allocation not par of the swapchain\n"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync/* get the surface for the specified allocation in the swapchain */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainSurfGet(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DSurface9 **ppSurf)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && vboxWddmSwapchainGetFb(pSwapchain)->pAlloc == pAlloc
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && vboxWddmSwapchainNumRTs(pSwapchain) != 1 /* for swapchains w/o a backbuffer the alloc will contain the back-buffer actually */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* this is a front-buffer */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DSurface9 *pSurf = pSwapchain->pRenderTargetFbCopy;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pSwapchain->pSwapChainIf->GetFrontBufferData(pSurf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("GetFrontBufferData failed, hr (0x%x)", hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* if this is not a front-buffer - just return the surface associated with the allocation */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync return VBoxD3DIfSurfGet(pAlloc->pRc, pAlloc->iAlloc, ppSurf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainRtSurfGet(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch, IDirect3DSurface9 **ppSurf)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* do the necessary swapchain synchronization first,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * not needed on swapchain synch since it is done already and we're called here just to set RTs */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* iRt != 0 is untested here !! */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainBbUpdate(pDevice, pSwapchain, pAlloc);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("vboxWddmSwapchainBbUpdate failed, hr(0x%x)",hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//@todo: Assert(!pSwapchain->fFlags.bChanged);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainChkCreateIf(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("vboxWddmSwapchainChkCreateIf failed, hr(0x%x)",hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync//@todo: Assert(vboxWddmSwapchainGetBb(pSwapchain)->pAlloc == pAlloc || iRt != 0);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainSurfGet(pDevice, pSwapchain, pAlloc, &pSurf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("vboxWddmSwapchainSurfGet failed, hr(0x%x)", hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainPresentPerform(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pSwapchain->pSwapChainIf->Present(NULL, NULL, NULL, NULL, 0);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pCurBb = vboxWddmSwapchainGetBb(pSwapchain)->pAlloc;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainSurfGet(pDevice, pSwapchain, pCurBb, &pSurf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice->pAdapter->D3D.D3D.pfnVBoxWineExD3DSwapchain9Present(pSwapchain->pSwapChainIf, pSurf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(!pSwapchain->fFlags.bSwitchReportingPresent);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmSwapchainPresent(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pBbAlloc)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* we currently *assume* that presenting shared resource is only possible when 3d app is rendering with composited desktop on,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * no need to do anything else since dwm will present everything for us */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice->pAdapter->D3D.D3D.pfnVBoxWineExD3DDev9Flush((IDirect3DDevice9Ex*)pDevice->pDevice9If);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pSwapchain = vboxWddmSwapchainFindCreate(pDevice, pBbAlloc, &bNeedPresent);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = vboxWddmSwapchainChkCreateIf(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainPresentPerform(pDevice, pSwapchain);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync#if 0 //def DEBUG
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic void vboxWddmDbgRenderTargetUpdateCheckSurface(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_ALLOCATION pAlloc, uint32_t iBBuf)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pAlloc->enmD3DIfType == VBOXDISP_D3DIFTYPE_SURFACE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = pDevice->aScreens[pDevice->iPrimaryScreen].pDevice9If;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice9If->GetBackBuffer(0 /*UINT iSwapChain*/,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic void vboxWddmDbgRenderTargetCheck(PVBOXWDDMDISP_DEVICE pDevice, PVBOXWDDMDISP_RESOURCE pRc, uint32_t iNewRTFB)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 1; i < pRc->cAllocations; ++i, ++iBBuf)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmDbgRenderTargetUpdateCheckSurface(pDevice, pAlloc, iBBuf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmDbgRenderTargetUpdateCheckSurface(pDevice, pAlloc, ~0UL /* <- for the frontbuffer */);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert((!pAlloc->pD3DIf) == (pRc->cAllocations > 1));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert((!pAlloc->pD3DIf) == (pRc->cAllocations > 1));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pAllocJ = &pRc->aAllocations[j];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXVDBG_RTGT_STATECHECK(_pDev) (vboxWddmDbgRenderTargetCheck((_pDev), (_pDev)->aScreens[(_pDev)->iPrimaryScreen].pRenderTargetRc, (_pDev)->aScreens[(_pDev)->iPrimaryScreen].iRenderTargetFrontBuf))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync# define VBOXVDBG_RTGT_STATECHECK(_pDev) do{}while(0)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT vboxWddmRenderTargetSet(PVBOXWDDMDISP_DEVICE pDevice, UINT iRt, PVBOXWDDMDISP_ALLOCATION pAlloc, BOOL bOnSwapchainSynch)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_SWAPCHAIN pSwapchain = vboxWddmSwapchainForAlloc(pAlloc);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = vboxWddmSwapchainRtSurfGet(pDevice, pSwapchain, iRt, pAlloc, bOnSwapchainSynch, &pD3D9Surf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("vboxWddmSwapchainRtSurfGet failed, hr(0x%x)",hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = VBoxD3DIfSurfGet(pAlloc->pRc, pAlloc->iAlloc, &pD3D9Surf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync * DLL entry point.
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// rc = VbglR3Init();
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// AssertRC(rc);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// if (RT_SUCCESS(rc))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// VbglR3Term();
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// VbglR3Term();
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /// @todo RTR3Term();
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDispGetCaps (HANDLE hAdapter, CONST D3DDDIARG_GETCAPS* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrint(("==> "__FUNCTION__", hAdapter(0x%p), caps type(%d)\n", hAdapter, pData->Type));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ADAPTER pAdapter = (PVBOXWDDMDISP_ADAPTER)hAdapter;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync // pCaps->Caps2 |= DDRAW_CAPS2_FLIPNOVSYNC;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pData->DataSize == sizeof (DDRAW_MODE_SPECIFIC_CAPS));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pData->DataSize >= sizeof (DDRAW_MODE_SPECIFIC_CAPS))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync DDRAW_MODE_SPECIFIC_CAPS * pCaps = (DDRAW_MODE_SPECIFIC_CAPS*)pData->pData;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset(&pCaps->Caps /* do not cleanup the first "Head" field,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync zero starting with the one following "Head", i.e. Caps */,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync 0, sizeof (DDRAW_MODE_SPECIFIC_CAPS) - RT_OFFSETOF(DDRAW_MODE_SPECIFIC_CAPS, Caps));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXVHWA_INFO *pSettings = &pAdapter->aHeads[pCaps->Head].Vhwa.Settings;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->Caps |= MODE_CAPS_OVERLAY | MODE_CAPS_OVERLAYSTRETCH;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->MaxVisibleOverlays = pSettings->cOverlaysSupported;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("D3DDDICAPS_DDRAW_MODE_SPECIFIC query for D3D mode!"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync *((uint32_t*)pData->pData) = pAdapter->Formats.cFormstOps;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pData->DataSize == pAdapter->Formats.cFormstOps * sizeof (FORMATOP));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memcpy(pData->pData, pAdapter->Formats.paFormstOps, pAdapter->Formats.cFormstOps * sizeof (FORMATOP));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync *((uint32_t*)pData->pData) = VBOX_QUERYTYPE_COUNT();
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pData->DataSize == VBOX_QUERYTYPE_COUNT() * sizeof (D3DDDIQUERYTYPE));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memcpy(pData->pData, gVBoxQueryTypes, VBOX_QUERYTYPE_COUNT() * sizeof (D3DDDIQUERYTYPE));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pData->DataSize == sizeof (D3DHAL_GLOBALDRIVERDATA));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pData->DataSize >= sizeof (D3DHAL_GLOBALDRIVERDATA))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync D3DHAL_GLOBALDRIVERDATA *pCaps = (D3DHAL_GLOBALDRIVERDATA *)pData->pData;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset (pCaps, 0, sizeof (D3DHAL_GLOBALDRIVERDATA));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->hwCaps.dwDevCaps = D3DDEVCAPS_CANRENDERAFTERFLIP
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// | D3DDEVCAPS_DRAWPRIMTLVERTEX
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// | D3DDEVCAPS_FLOATTLVERTEX
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// | D3DDEVCAPS_HWTRANSFORMANDLIGHT
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// | D3DDEVCAPS_TEXTUREVIDEOMEMORY
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->hwCaps.dtcTransformCaps.dwSize = sizeof (D3DTRANSFORMCAPS);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->hwCaps.dlcLightingCaps.dwSize = sizeof (D3DLIGHTINGCAPS);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->hwCaps.dpcLineCaps.dwSize = sizeof (D3DPRIMCAPS);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->hwCaps.dpcLineCaps.dwTextureAddressCaps = 0;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->hwCaps.dpcTriCaps.dwSize = sizeof (D3DPRIMCAPS);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->hwCaps.dwDeviceRenderBitDepth = DDBD_8 | DDBD_16 | DDBD_24 | DDBD_32;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->dwNumTextureFormats = 0;//pAdapter->cSurfDescs;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pCaps->lpTextureFormats = NULL;//pAdapter->paSurfDescs;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pData->DataSize == sizeof (D3DHAL_D3DEXTENDEDCAPS));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pData->DataSize >= sizeof (D3DHAL_D3DEXTENDEDCAPS))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memset(pData->pData, 0, sizeof (D3DHAL_D3DEXTENDEDCAPS));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync D3DHAL_D3DEXTENDEDCAPS *pCaps = (D3DHAL_D3DEXTENDEDCAPS*)pData->pData;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memcpy(pData->pData, &pAdapter->D3D.Caps, sizeof (D3DCAPS9));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pData->DataSize == RT_OFFSETOF(D3DCAPS9, DevCaps2));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pData->DataSize == RT_OFFSETOF(D3DCAPS9, DevCaps2))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync memcpy(pData->pData, &pAdapter->D3D.Caps, RT_OFFSETOF(D3DCAPS9, DevCaps2));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync case D3DDDICAPS_GETDECODECOMPRESSEDBUFFERINFOCOUNT:
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync case D3DDDICAPS_GETVIDEOPROCESSORRTSUBSTREAMFORMATCOUNT:
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync case D3DDDICAPS_GETVIDEOPROCESSORRTSUBSTREAMFORMATS:
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrint((__FUNCTION__": unimplemented caps type(%d)\n", pData->Type));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrint((__FUNCTION__": unknown caps type(%d)\n", pData->Type));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrint(("<== "__FUNCTION__", hAdapter(0x%p), caps type(%d)\n", hAdapter, pData->Type));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetRenderState(HANDLE hDevice, CONST D3DDDIARG_RENDERSTATE* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice9If->SetRenderState(vboxDDI2D3DRenderStateType(pData->State), pData->Value);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevUpdateWInfo(HANDLE hDevice, CONST D3DDDIARG_WINFO* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevValidateDevice(HANDLE hDevice, D3DDDIARG_VALIDATETEXTURESTAGESTATE* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* @todo: check if it's ok to always return success */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrint((__FUNCTION__": @todo: check if it's ok to always return success\n"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetTextureStageState(HANDLE hDevice, CONST D3DDDIARG_TEXTURESTAGESTATE* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXWDDMDISP_TSS_LOOKUP lookup = vboxDDI2D3DTestureStageStateType(pData->State);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->SetTextureStageState(pData->Stage, D3DTEXTURESTAGESTATETYPE(lookup.dType), pData->Value);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->SetSamplerState(pData->Stage, D3DSAMPLERSTATETYPE(lookup.dType), pData->Value);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetTexture(HANDLE hDevice, UINT Stage, HANDLE hTexture)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)hTexture;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// Assert(pRc);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pD3DIfTex = (IDirect3DTexture9*)pRc->aAllocations[0].pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_CUBE_TEXTURE)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pD3DIfTex = (IDirect3DCubeTexture9*)pRc->aAllocations[0].pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync else if (pRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pD3DIfTex = (IDirect3DVolumeTexture9*)pRc->aAllocations[0].pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDevice->cSamplerTextures < RT_ELEMENTS(pDevice->aSamplerTextures));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(idx < RT_ELEMENTS(pDevice->aSamplerTextures));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("non-zero special sampler index not tested!\n"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDevice->cSamplerTextures < RT_ELEMENTS(pDevice->aSamplerTextures));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDevice->cSamplerTextures < RT_ELEMENTS(pDevice->aSamplerTextures));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(idx < RT_ELEMENTS(pDevice->aSamplerTextures));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDevice->cSamplerTextures < RT_ELEMENTS(pDevice->aSamplerTextures));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice9If->SetTexture(Stage, pD3DIfTex);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetPixelShader(HANDLE hDevice, HANDLE hShaderHandle)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DPixelShader9 *pShader = (IDirect3DPixelShader9*)hShaderHandle;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetPixelShaderConst(HANDLE hDevice, CONST D3DDDIARG_SETPIXELSHADERCONST* pData, CONST FLOAT* pRegisters)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice9If->SetPixelShaderConstantF(pData->Register, pRegisters, pData->Count);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetStreamSourceUm(HANDLE hDevice, CONST D3DDDIARG_SETSTREAMSOURCEUM* pData, CONST VOID* pUMBuffer )
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pData->Stream < RT_ELEMENTS(pDevice->aStreamSourceUm));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_STREAMSOURCEUM pStrSrcUm = &pDevice->aStreamSourceUm[pData->Stream];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDevice->cStreamSourcesUm <= RT_ELEMENTS(pDevice->aStreamSourceUm));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice->pDevice9If->SetStreamSource(pData->Stream, NULL, 0, 0);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetIndices(HANDLE hDevice, CONST D3DDDIARG_SETINDICES* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RESOURCE pRc = (PVBOXWDDMDISP_RESOURCE)pData->hIndexBuffer;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pIndexBuffer = (IDirect3DIndexBuffer9*)pAlloc->pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetIndicesUm(HANDLE hDevice, UINT IndexSize, CONST VOID* pUMBuffer)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevDrawPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWPRIMITIVE* pData, CONST UINT* pFlagBuffer)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 1; i < RT_ELEMENTS(pDevice->aStreamSourceUm); ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->DrawPrimitiveUP(pData->PrimitiveType,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync ((uint8_t*)pDevice->aStreamSourceUm[0].pvBuffer) + pData->VStart * pDevice->aStreamSourceUm[0].cbStride,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* todo: impl */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSourceUm); ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSource); ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(!pDevice->aStreamSource[i]->LockInfo.cLocks);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->DrawPrimitive(pData->PrimitiveType,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitive\n"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevDrawIndexedPrimitive(HANDLE hDevice, CONST D3DDDIARG_DRAWINDEXEDPRIMITIVE* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSourceUm); ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSource); ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(!pDevice->aStreamSource[i]->LockInfo.cLocks);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(!pDevice->IndiciesInfo.pIndicesAlloc->LockInfo.cLocks);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("DrawIndexedPrimitive failed hr = 0x%x", hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDevice->IndiciesInfo.uiStride == 2 || pDevice->IndiciesInfo.uiStride == 4);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pvIndexBuffer = (const uint8_t*)pDevice->IndiciesInfo.pIndicesAlloc->pvMem;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pvIndexBuffer = (const uint8_t*)pDevice->IndiciesInfo.pvIndicesUm;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (UINT i = 0; i < RT_ELEMENTS(pDevice->aStreamSourceUm); ++i)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->DrawIndexedPrimitiveUP(pData->PrimitiveType,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pvIndexBuffer + pDevice->IndiciesInfo.uiStride * pData->StartIndex,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pDevice->IndiciesInfo.uiStride == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT tmpHr = pDevice9If->SetIndices((IDirect3DIndexBuffer9*)pDevice->IndiciesInfo.pIndicesAlloc->pD3DIf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("DrawIndexedPrimitiveUP failed hr = 0x%x", hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevDrawRectPatch(HANDLE hDevice, CONST D3DDDIARG_DRAWRECTPATCH* pData, CONST D3DDDIRECTPATCH_INFO* pInfo, CONST FLOAT* pPatch)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevDrawTriPatch(HANDLE hDevice, CONST D3DDDIARG_DRAWTRIPATCH* pData, CONST D3DDDITRIPATCH_INFO* pInfo, CONST FLOAT* pPatch)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevDrawPrimitive2(HANDLE hDevice, CONST D3DDDIARG_DRAWPRIMITIVE2* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (stream=0; stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS; ++stream)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pDevice->aStreamSource[stream] && pDevice->aStreamSource[stream]->LockInfo.cLocks)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXWDDMDISP_LOCKINFO *pLock = &pDevice->aStreamSource[stream]->LockInfo;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite))
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DVertexBuffer9 *pD3D9VBuf = (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pD3D9VBuf->Lock(pLock->Range.Offset, pLock->Range.Size,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBoxD3DIfLockUnlockMemSynch(pDevice->aStreamSource[stream], &pLock->LockedRect, &r, true /*bool bToLockInfo*/);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset, pData->PrimitiveCount);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync for (stream=0; stream<VBOXWDDMDISP_MAX_VERTEX_STREAMS; ++stream)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(stream==0); /*only stream 0 should be accessed here*/
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDevice->StreamSourceInfo[stream].uiStride!=0);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync VBOXWDDMDISP_LOCKINFO *pLock = &pDevice->aStreamSource[stream]->LockInfo;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitiveUP\n"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pLock->fFlags.MightDrawFromLocked && (pLock->fFlags.Discard || pLock->fFlags.NoOverwrite));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->DrawPrimitiveUP(pData->PrimitiveType, pData->PrimitiveCount,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync (void*)((uintptr_t)pDevice->aStreamSource[stream]->pvMem+pDevice->StreamSourceInfo[stream].uiOffset+pData->FirstVertexOffset),
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->SetStreamSource(stream, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[stream]->pD3DIf, pDevice->StreamSourceInfo[stream].uiOffset, pDevice->StreamSourceInfo[stream].uiStride);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// vboxVDbgMpPrintF((pDevice, __FUNCTION__": DrawPrimitive\n"));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->DrawPrimitive(pData->PrimitiveType, pData->FirstVertexOffset/pDevice->StreamSourceInfo[stream].uiStride, pData->PrimitiveCount);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevDrawIndexedPrimitive2(HANDLE hDevice, CONST D3DDDIARG_DRAWINDEXEDPRIMITIVE2* pData, UINT dwIndicesSize, CONST VOID* pIndexBuffer, CONST UINT* pFlagBuffer)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("unsupported dwIndicesSize %d", dwIndicesSize));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pvVertexBuffer = (const uint8_t *)pDevice->aStreamSourceUm[0].pvBuffer;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync cbVertexStride = pDevice->aStreamSourceUm[0].cbStride;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_ALLOCATION pAlloc = pDevice->aStreamSource[0];
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pvVertexBuffer = ((const uint8_t *)pAlloc->pvMem) + pDevice->StreamSourceInfo[0].uiOffset;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync cbVertexStride = pDevice->StreamSourceInfo[0].uiStride;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync pvVertexBuffer = pvVertexBuffer + pData->BaseVertexOffset /* * cbVertexStride */;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->DrawIndexedPrimitiveUP(pData->PrimitiveType,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync ((uint8_t*)pIndexBuffer) + dwIndicesSize * pData->StartIndexOffset,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync dwIndicesSize == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("DrawIndexedPrimitiveUP failed hr = 0x%x", hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT tmpHr = pDevice9If->SetStreamSource(0, (IDirect3DVertexBuffer9*)pDevice->aStreamSource[0]->pD3DIf, pDevice->StreamSourceInfo[0].uiOffset, pDevice->StreamSourceInfo[0].uiStride);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT tmpHr = pDevice9If->SetIndices((IDirect3DIndexBuffer9*)pDevice->IndiciesInfo.pIndicesAlloc->pD3DIf);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(sizeof (D3DDDIBOX) == sizeof (VBOXBOX3D));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(D3DDDIBOX, Left) == RT_SIZEOFMEMB(VBOXBOX3D, Left));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(D3DDDIBOX, Top) == RT_SIZEOFMEMB(VBOXBOX3D, Top));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(D3DDDIBOX, Right) == RT_SIZEOFMEMB(VBOXBOX3D, Right));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(D3DDDIBOX, Bottom) == RT_SIZEOFMEMB(VBOXBOX3D, Bottom));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(D3DDDIBOX, Front) == RT_SIZEOFMEMB(VBOXBOX3D, Front));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(D3DDDIBOX, Back) == RT_SIZEOFMEMB(VBOXBOX3D, Back));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(D3DDDIBOX, Left) == RT_OFFSETOF(VBOXBOX3D, Left));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(D3DDDIBOX, Top) == RT_OFFSETOF(VBOXBOX3D, Top));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(D3DDDIBOX, Right) == RT_OFFSETOF(VBOXBOX3D, Right));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(D3DDDIBOX, Bottom) == RT_OFFSETOF(VBOXBOX3D, Bottom));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(D3DDDIBOX, Front) == RT_OFFSETOF(VBOXBOX3D, Front));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(D3DDDIBOX, Back) == RT_OFFSETOF(VBOXBOX3D, Back));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevVolBlt(HANDLE hDevice, CONST D3DDDIARG_VOLUMEBLT* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* requirements for D3DDevice9::UpdateTexture */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDstRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pSrcRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DVolumeTexture9 * pSrcTex = (IDirect3DVolumeTexture9*)pSrcRc->aAllocations[0].pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DVolumeTexture9 * pDstTex = (IDirect3DVolumeTexture9*)pDstRc->aAllocations[0].pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice->pAdapter->D3D.D3D.pfnVBoxWineExD3DDev9VolTexBlt((IDirect3DDevice9Ex*)pDevice9If, pSrcTex, pDstTex,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync WARN(("pfnVBoxWineExD3DDev9VolTexBlt failed hr 0x%x", hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevBufBlt(HANDLE hDevice, CONST D3DDDIARG_BUFFERBLT* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// @todo: vboxWddmDalCheckAdd(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevTexBlt(HANDLE hDevice, CONST D3DDDIARG_TEXBLT* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RESOURCE pDstRc = (PVBOXWDDMDISP_RESOURCE)pData->hDstResource;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_RESOURCE pSrcRc = (PVBOXWDDMDISP_RESOURCE)pData->hSrcResource;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync /* requirements for D3DDevice9::UpdateTexture */
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDstRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync || pDstRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_CUBE_TEXTURE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync || pDstRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pSrcRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_TEXTURE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync || pSrcRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_CUBE_TEXTURE
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync || pDstRc->aAllocations[0].enmD3DIfType == VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pSrcRc->aAllocations[0].enmD3DIfType == pDstRc->aAllocations[0].enmD3DIfType);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pSrcRc->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDstRc->RcDesc.enmPool != D3DDDIPOOL_SYSTEMMEM);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync if (pSrcRc->aAllocations[0].SurfDesc.d3dWidth == pDstRc->aAllocations[0].SurfDesc.d3dWidth
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && pSrcRc->aAllocations[0].SurfDesc.height == pDstRc->aAllocations[0].SurfDesc.height
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && pSrcRc->RcDesc.enmFormat == pDstRc->RcDesc.enmFormat
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && pData->SrcRect.left == 0 && pData->SrcRect.top == 0
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && pData->SrcRect.right - pData->SrcRect.left == pSrcRc->aAllocations[0].SurfDesc.width
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync && pData->SrcRect.bottom - pData->SrcRect.top == pSrcRc->aAllocations[0].SurfDesc.height)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DBaseTexture9 *pD3DIfSrcTex = (IDirect3DBaseTexture9*)pSrcRc->aAllocations[0].pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DBaseTexture9 *pD3DIfDstTex = (IDirect3DBaseTexture9*)pDstRc->aAllocations[0].pD3DIf;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->UpdateTexture(pD3DIfSrcTex, pD3DIfDstTex); Assert(hr == S_OK),
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pDstRc->aAllocations[0].enmD3DIfType != VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync Assert(pSrcRc->aAllocations[0].enmD3DIfType != VBOXDISP_D3DIFTYPE_VOLUME_TEXTURE);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxWddmRectMoved(&DstRect, &pData->SrcRect, pData->DstPoint.x, pData->DstPoint.y);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync RECT tstRect = {0,0, pDstRc->aAllocations[0].SurfDesc.width, pDstRc->aAllocations[0].SurfDesc.height};
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync hr = pDevice9If->StretchRect(pSrcSurfIf, &pData->SrcRect, pDstSurfIf, &DstRect, D3DTEXF_NONE); Assert(hr == S_OK),
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevStateSet(HANDLE hDevice, D3DDDIARG_STATESET* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetPriority(HANDLE hDevice, CONST D3DDDIARG_SETPRIORITY* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// Assert(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync// VBOXDISPCRHGSMI_SCOPE_SET_DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(RECT, left) == RT_SIZEOFMEMB(D3DRECT, x1));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(RECT, right) == RT_SIZEOFMEMB(D3DRECT, x2));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(RECT, top) == RT_SIZEOFMEMB(D3DRECT, y1));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_SIZEOFMEMB(RECT, bottom) == RT_SIZEOFMEMB(D3DRECT, y2));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(RECT, left) == RT_OFFSETOF(D3DRECT, x1));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(RECT, right) == RT_OFFSETOF(D3DRECT, x2));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(RECT, top) == RT_OFFSETOF(D3DRECT, y1));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncAssertCompile(RT_OFFSETOF(RECT, bottom) == RT_OFFSETOF(D3DRECT, y2));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevClear(HANDLE hDevice, CONST D3DDDIARG_CLEAR* pData, UINT NumRect, CONST RECT* pRect)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice9If->Clear(NumRect, (D3DRECT*)pRect /* see AssertCompile above */,
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevUpdatePalette(HANDLE hDevice, CONST D3DDDIARG_UPDATEPALETTE* pData, CONST PALETTEENTRY* pPaletteData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetPalette(HANDLE hDevice, CONST D3DDDIARG_SETPALETTE* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetVertexShaderConst(HANDLE hDevice, CONST D3DDDIARG_SETVERTEXSHADERCONST* pData , CONST VOID* pRegisters)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevMultiplyTransform(HANDLE hDevice, CONST D3DDDIARG_MULTIPLYTRANSFORM* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetTransform(HANDLE hDevice, CONST D3DDDIARG_SETTRANSFORM* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetViewport(HANDLE hDevice, CONST D3DDDIARG_VIEWPORTINFO* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice9If->SetViewport(&pDevice->ViewPort);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, hr));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsyncstatic HRESULT APIENTRY vboxWddmDDevSetZRange(HANDLE hDevice, CONST D3DDDIARG_ZRANGE* pData)
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("==> "__FUNCTION__", hDevice(0x%p)\n", hDevice));
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync PVBOXWDDMDISP_DEVICE pDevice = (PVBOXWDDMDISP_DEVICE)hDevice;
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync IDirect3DDevice9 * pDevice9If = VBOXDISP_D3DEV(pDevice);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync HRESULT hr = pDevice9If->SetViewport(&pDevice->ViewPort);
f9a51917495bc8ba8b60632219652a7b122c1190vboxsync vboxVDbgPrintF(("<== "__FUNCTION__", hDevice(0x%p), hr(0x%x)\n", hDevice, 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);
Assert((pLockAlloc->LockInfo.fFlags.Value & ~1) == (pData->Flags.Value & ~1)); /* <- 1 is "ReadOnly" flag */
Assert(0);
if (pRect)
Assert(0);
Assert((pLockAlloc->LockInfo.fFlags.Value & ~1) == (pData->Flags.Value & ~1)); /* <- 1 is "ReadOnly" flag */
if (pBox)
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);
if (minPitch)
pAllocation->SurfDesc.d3dWidth = vboxWddmCalcWidthForPitch(pAllocation->SurfDesc.pitch, pAllocation->SurfDesc.format);
Assert(VBOXWDDMDISP_IS_TEXTURE(pRc->RcDesc.fFlags) && !pRc->RcDesc.fFlags.CubeMap); /* <- tested for textures only! */
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)
if (pD3D9Surf)
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;