DECLCALLBACK(int) vboxUhgsmiKmtBufferSubmitAsynch(PVBOXUHGSMI pHgsmi, PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers) { PVBOXUHGSMI_PRIVATE_KMT pHg = VBOXUHGSMIKMT_GET(pHgsmi); UINT cbDmaCmd = pHg->Context.CommandBufferSize; int rc = vboxUhgsmiBaseDmaFill(aBuffers, cBuffers, pHg->Context.pCommandBuffer, &cbDmaCmd, pHg->Context.pAllocationList, pHg->Context.AllocationListSize, pHg->Context.pPatchLocationList, pHg->Context.PatchLocationListSize); AssertRC(rc); if (RT_FAILURE(rc)) return rc; D3DKMT_RENDER DdiRender = {0}; DdiRender.hContext = pHg->Context.hContext; DdiRender.CommandLength = cbDmaCmd; DdiRender.AllocationCount = cBuffers; Assert(DdiRender.CommandLength); Assert(DdiRender.CommandLength < UINT32_MAX/2); HRESULT hr = pHg->Callbacks.pfnD3DKMTRender(&DdiRender); Assert(hr == S_OK); if (hr == S_OK) { pHg->Context.CommandBufferSize = DdiRender.NewCommandBufferSize; pHg->Context.pCommandBuffer = DdiRender.pNewCommandBuffer; pHg->Context.AllocationListSize = DdiRender.NewAllocationListSize; pHg->Context.pAllocationList = DdiRender.pNewAllocationList; pHg->Context.PatchLocationListSize = DdiRender.NewPatchLocationListSize; pHg->Context.pPatchLocationList = DdiRender.pNewPatchLocationList; return VINF_SUCCESS; } return VERR_GENERAL_FAILURE; }
DECLCALLBACK(int) vboxUhgsmiD3DBufferSubmit(PVBOXUHGSMI pHgsmi, PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers) { PVBOXUHGSMI_PRIVATE_D3D pHg = VBOXUHGSMID3D_GET(pHgsmi); PVBOXWDDMDISP_DEVICE pDevice = pHg->pDevice; UINT cbDmaCmd = pDevice->DefaultContext.ContextInfo.CommandBufferSize; int rc = vboxUhgsmiBaseDmaFill(aBuffers, cBuffers, pDevice->DefaultContext.ContextInfo.pCommandBuffer, &cbDmaCmd, pDevice->DefaultContext.ContextInfo.pAllocationList, pDevice->DefaultContext.ContextInfo.AllocationListSize, pDevice->DefaultContext.ContextInfo.pPatchLocationList, pDevice->DefaultContext.ContextInfo.PatchLocationListSize); AssertRC(rc); if (RT_FAILURE(rc)) return rc; D3DDDICB_RENDER DdiRender = {0}; DdiRender.CommandLength = cbDmaCmd; Assert(DdiRender.CommandLength); Assert(DdiRender.CommandLength < UINT32_MAX/2); DdiRender.CommandOffset = 0; DdiRender.NumAllocations = cBuffers; DdiRender.NumPatchLocations = 0; // DdiRender.NewCommandBufferSize = sizeof (VBOXVDMACMD) + 4 * (100); // DdiRender.NewAllocationListSize = 100; // DdiRender.NewPatchLocationListSize = 100; DdiRender.hContext = pDevice->DefaultContext.ContextInfo.hContext; HRESULT hr = pDevice->RtCallbacks.pfnRenderCb(pDevice->hDevice, &DdiRender); Assert(hr == S_OK); if (hr == S_OK) { pDevice->DefaultContext.ContextInfo.CommandBufferSize = DdiRender.NewCommandBufferSize; pDevice->DefaultContext.ContextInfo.pCommandBuffer = DdiRender.pNewCommandBuffer; pDevice->DefaultContext.ContextInfo.AllocationListSize = DdiRender.NewAllocationListSize; pDevice->DefaultContext.ContextInfo.pAllocationList = DdiRender.pNewAllocationList; pDevice->DefaultContext.ContextInfo.PatchLocationListSize = DdiRender.NewPatchLocationListSize; pDevice->DefaultContext.ContextInfo.pPatchLocationList = DdiRender.pNewPatchLocationList; return VINF_SUCCESS; } return VERR_GENERAL_FAILURE; }