VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiKmt.cpp@ 33146

Last change on this file since 33146 was 33146, checked in by vboxsync, 14 years ago

wddm/3d: chromium hgsmi, host part + guest part debugging

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.4 KB
Line 
1/** @file
2 *
3 * VBoxVideo Display D3D User mode dll
4 *
5 * Copyright (C) 2010 Oracle Corporation
6 *
7 * This file is part of VirtualBox Open Source Edition (OSE), as
8 * available from http://www.virtualbox.org. This file is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License (GPL) as published by the Free Software
11 * Foundation, in version 2 as it comes in the "COPYING" file of the
12 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14 */
15#include "VBoxDispD3DCmn.h"
16
17#include <iprt/mem.h>
18#include <iprt/err.h>
19
20typedef struct VBOXUHGSMI_BUFFER_PRIVATE_KMT
21{
22 VBOXUHGSMI_BUFFER_PRIVATE_BASE BasePrivate;
23 PVBOXUHGSMI_PRIVATE_KMT pHgsmi;
24 UINT aLockPageIndices[1];
25} VBOXUHGSMI_BUFFER_PRIVATE_KMT, *PVBOXUHGSMI_BUFFER_PRIVATE_KMT;
26
27DECLCALLBACK(int) vboxUhgsmiKmtBufferDestroy(PVBOXUHGSMI_BUFFER pBuf)
28{
29 PVBOXUHGSMI_BUFFER_PRIVATE_KMT pBuffer = VBOXUHGSMIKMT_GET_BUFFER(pBuf);
30 D3DKMT_DESTROYALLOCATION DdiDealloc;
31 DdiDealloc.hDevice = pBuffer->pHgsmi->Device.hDevice;
32 DdiDealloc.hResource = NULL;
33 DdiDealloc.phAllocationList = &pBuffer->BasePrivate.hAllocation;
34 DdiDealloc.AllocationCount = 1;
35 NTSTATUS Status = pBuffer->pHgsmi->Callbacks.pfnD3DKMTDestroyAllocation(&DdiDealloc);
36 Assert(!Status);
37 if (!Status)
38 {
39 if (pBuffer->BasePrivate.Base.bSynchCreated)
40 {
41 CloseHandle(pBuffer->BasePrivate.Base.hSynch);
42 }
43 RTMemFree(pBuffer);
44 return VINF_SUCCESS;
45 }
46 return VERR_GENERAL_FAILURE;
47}
48
49DECLCALLBACK(int) vboxUhgsmiKmtBufferLock(PVBOXUHGSMI_BUFFER pBuf, uint32_t offLock, uint32_t cbLock, VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags, void**pvLock)
50{
51 PVBOXUHGSMI_BUFFER_PRIVATE_KMT pBuffer = VBOXUHGSMIKMT_GET_BUFFER(pBuf);
52 D3DKMT_LOCK DdiLock;
53 DdiLock.hDevice = pBuffer->pHgsmi->Device.hDevice;
54 DdiLock.hAllocation = pBuffer->BasePrivate.hAllocation;
55 DdiLock.PrivateDriverData = NULL;
56
57 int rc = vboxUhgsmiBaseLockData(pBuf, offLock, cbLock, fFlags,
58 &DdiLock.Flags, pBuffer->aLockPageIndices, &DdiLock.NumPages);
59 AssertRC(rc);
60 if (RT_FAILURE(rc))
61 return rc;
62
63 DdiLock.pPages = pBuffer->aLockPageIndices;
64
65 NTSTATUS Status = pBuffer->pHgsmi->Callbacks.pfnD3DKMTLock(&DdiLock);
66 Assert(!Status);
67 if (!Status)
68 {
69 *pvLock = (void*)(((uint8_t*)DdiLock.pData) + (offLock & 0xfff));
70 return VINF_SUCCESS;
71 }
72 return VERR_GENERAL_FAILURE;
73}
74
75DECLCALLBACK(int) vboxUhgsmiKmtBufferUnlock(PVBOXUHGSMI_BUFFER pBuf)
76{
77 PVBOXUHGSMI_BUFFER_PRIVATE_KMT pBuffer = VBOXUHGSMIKMT_GET_BUFFER(pBuf);
78 D3DKMT_UNLOCK DdiUnlock;
79
80 DdiUnlock.hDevice = pBuffer->pHgsmi->Device.hDevice;
81 DdiUnlock.NumAllocations = 1;
82 DdiUnlock.phAllocations = &pBuffer->BasePrivate.hAllocation;
83 NTSTATUS Status = pBuffer->pHgsmi->Callbacks.pfnD3DKMTUnlock(&DdiUnlock);
84 Assert(!Status);
85 if (!Status)
86 return VINF_SUCCESS;
87 return VERR_GENERAL_FAILURE;
88}
89
90DECLCALLBACK(int) vboxUhgsmiKmtBufferCreate(PVBOXUHGSMI pHgsmi, uint32_t cbBuf,
91 VBOXUHGSMI_SYNCHOBJECT_TYPE enmSynchType, HVBOXUHGSMI_SYNCHOBJECT hSynch,
92 PVBOXUHGSMI_BUFFER* ppBuf)
93{
94 bool bSynchCreated = false;
95 if (!cbBuf)
96 return VERR_INVALID_PARAMETER;
97
98 int rc = vboxUhgsmiBaseEventChkCreate(enmSynchType, &hSynch, &bSynchCreated);
99 AssertRC(rc);
100 if (RT_FAILURE(rc))
101 return rc;
102
103 cbBuf = VBOXWDDM_ROUNDBOUND(cbBuf, 0x1000);
104 Assert(cbBuf);
105 uint32_t cPages = cbBuf >> 12;
106 Assert(cPages);
107
108 PVBOXUHGSMI_PRIVATE_KMT pPrivate = VBOXUHGSMIKMT_GET(pHgsmi);
109 PVBOXUHGSMI_BUFFER_PRIVATE_KMT pBuf = (PVBOXUHGSMI_BUFFER_PRIVATE_KMT)RTMemAllocZ(RT_OFFSETOF(VBOXUHGSMI_BUFFER_PRIVATE_KMT, aLockPageIndices));
110 Assert(pBuf);
111 if (pBuf)
112 {
113 struct
114 {
115 D3DKMT_CREATEALLOCATION DdiAlloc;
116 D3DDDI_ALLOCATIONINFO DdiAllocInfo;
117 VBOXWDDM_ALLOCINFO AllocInfo;
118 } Buf;
119 memset(&Buf, 0, sizeof (Buf));
120 Buf.DdiAlloc.hDevice = pPrivate->Device.hDevice;
121 Buf.DdiAlloc.NumAllocations = 1;
122 Buf.DdiAlloc.pAllocationInfo = &Buf.DdiAllocInfo;
123 Buf.DdiAllocInfo.pPrivateDriverData = &Buf.AllocInfo;
124 Buf.DdiAllocInfo.PrivateDriverDataSize = sizeof (Buf.AllocInfo);
125 Buf.AllocInfo.enmType = VBOXWDDM_ALLOC_TYPE_UMD_HGSMI_BUFFER;
126 Buf.AllocInfo.cbBuffer = cbBuf;
127 Buf.AllocInfo.hSynch = hSynch;
128 Buf.AllocInfo.enmSynchType = enmSynchType;
129
130 HRESULT hr = pPrivate->Callbacks.pfnD3DKMTCreateAllocation(&Buf.DdiAlloc);
131 Assert(hr == S_OK);
132 if (hr == S_OK)
133 {
134 Assert(Buf.DdiAllocInfo.hAllocation);
135 pBuf->BasePrivate.Base.pfnLock = vboxUhgsmiKmtBufferLock;
136 pBuf->BasePrivate.Base.pfnUnlock = vboxUhgsmiKmtBufferUnlock;
137// pBuf->Base.pfnAdjustValidDataRange = vboxUhgsmiKmtBufferAdjustValidDataRange;
138 pBuf->BasePrivate.Base.pfnDestroy = vboxUhgsmiKmtBufferDestroy;
139
140 pBuf->BasePrivate.Base.hSynch = hSynch;
141 pBuf->BasePrivate.Base.enmSynchType = enmSynchType;
142 pBuf->BasePrivate.Base.cbBuffer = cbBuf;
143 pBuf->BasePrivate.Base.bSynchCreated = bSynchCreated;
144
145 pBuf->pHgsmi = pPrivate;
146 pBuf->BasePrivate.hAllocation = Buf.DdiAllocInfo.hAllocation;
147
148 *ppBuf = &pBuf->BasePrivate.Base;
149
150 return VINF_SUCCESS;
151 }
152
153 RTMemFree(pBuf);
154 }
155 else
156 rc = VERR_NO_MEMORY;
157
158 if (bSynchCreated)
159 CloseHandle(hSynch);
160
161 return rc;
162}
163
164DECLCALLBACK(int) vboxUhgsmiKmtBufferSubmitAsynch(PVBOXUHGSMI pHgsmi, PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers)
165{
166 PVBOXUHGSMI_PRIVATE_KMT pHg = VBOXUHGSMIKMT_GET(pHgsmi);
167 UINT cbDmaCmd = pHg->Context.CommandBufferSize;
168 int rc = vboxUhgsmiBaseDmaFill(aBuffers, cBuffers,
169 pHg->Context.pCommandBuffer, &cbDmaCmd,
170 pHg->Context.pAllocationList, pHg->Context.AllocationListSize,
171 pHg->Context.pPatchLocationList, pHg->Context.PatchLocationListSize);
172 AssertRC(rc);
173 if (RT_FAILURE(rc))
174 return rc;
175
176 D3DKMT_RENDER DdiRender = {0};
177 DdiRender.hContext = pHg->Context.hContext;
178 DdiRender.CommandLength = cbDmaCmd;
179 DdiRender.AllocationCount = cBuffers;
180 Assert(DdiRender.CommandLength);
181 Assert(DdiRender.CommandLength < UINT32_MAX/2);
182
183 HRESULT hr = pHg->Callbacks.pfnD3DKMTRender(&DdiRender);
184 Assert(hr == S_OK);
185 if (hr == S_OK)
186 {
187 pHg->Context.CommandBufferSize = DdiRender.NewCommandBufferSize;
188 pHg->Context.pCommandBuffer = DdiRender.pNewCommandBuffer;
189 pHg->Context.AllocationListSize = DdiRender.NewAllocationListSize;
190 pHg->Context.pAllocationList = DdiRender.pNewAllocationList;
191 pHg->Context.PatchLocationListSize = DdiRender.NewPatchLocationListSize;
192 pHg->Context.pPatchLocationList = DdiRender.pNewPatchLocationList;
193
194 return VINF_SUCCESS;
195 }
196
197 return VERR_GENERAL_FAILURE;
198}
199
200HRESULT vboxUhgsmiKmtCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D)
201{
202 pHgsmi->BasePrivate.Base.pfnBufferCreate = vboxUhgsmiKmtBufferCreate;
203 pHgsmi->BasePrivate.Base.pfnBufferSubmitAsynch = vboxUhgsmiKmtBufferSubmitAsynch;
204 pHgsmi->BasePrivate.hClient = NULL;
205
206 HRESULT hr = vboxDispKmtCallbacksInit(&pHgsmi->Callbacks);
207 Assert(hr == S_OK);
208 if (hr == S_OK)
209 {
210 hr = vboxDispKmtOpenAdapter(&pHgsmi->Callbacks, &pHgsmi->Adapter);
211 Assert(hr == S_OK);
212 if (hr == S_OK)
213 {
214 hr = vboxDispKmtCreateDevice(&pHgsmi->Adapter, &pHgsmi->Device);
215 Assert(hr == S_OK);
216 if (hr == S_OK)
217 {
218 hr = vboxDispKmtCreateContext(&pHgsmi->Device, &pHgsmi->Context, bD3D);
219 Assert(hr == S_OK);
220 if (hr == S_OK)
221 {
222 return S_OK;
223 }
224 vboxDispKmtDestroyDevice(&pHgsmi->Device);
225 }
226 vboxDispKmtCloseAdapter(&pHgsmi->Adapter);
227 }
228 vboxDispKmtCallbacksTerm(&pHgsmi->Callbacks);
229 }
230 return hr;
231}
232
233
234HRESULT vboxUhgsmiKmtDestroy(PVBOXUHGSMI_PRIVATE_KMT pHgsmi)
235{
236 HRESULT hr = vboxDispKmtDestroyContext(&pHgsmi->Context);
237 Assert(hr == S_OK);
238 if (hr == S_OK)
239 {
240 hr = vboxDispKmtDestroyDevice(&pHgsmi->Device);
241 Assert(hr == S_OK);
242 if (hr == S_OK)
243 {
244 hr = vboxDispKmtCloseAdapter(&pHgsmi->Adapter);
245 Assert(hr == S_OK);
246 if (hr == S_OK)
247 {
248 hr = vboxDispKmtCallbacksTerm(&pHgsmi->Callbacks);
249 Assert(hr == S_OK);
250 if (hr == S_OK)
251 return S_OK;
252 }
253 }
254 }
255 return hr;
256}
257
258HRESULT vboxDispKmtCallbacksInit(PVBOXDISPKMT_CALLBACKS pCallbacks)
259{
260 HRESULT hr = S_OK;
261
262 memset(pCallbacks, 0, sizeof (*pCallbacks));
263
264 pCallbacks->hGdi32 = LoadLibraryW(L"gdi32.dll");
265 if (pCallbacks->hGdi32 != NULL)
266 {
267 bool bSupported = true;
268 pCallbacks->pfnD3DKMTOpenAdapterFromHdc = (PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress(pCallbacks->hGdi32, "D3DKMTOpenAdapterFromHdc");
269 Log((__FUNCTION__"pfnD3DKMTOpenAdapterFromHdc = %p\n", pCallbacks->pfnD3DKMTOpenAdapterFromHdc));
270 bSupported &= !!(pCallbacks->pfnD3DKMTOpenAdapterFromHdc);
271
272 pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName = (PFND3DKMT_OPENADAPTERFROMGDIDISPLAYNAME)GetProcAddress(pCallbacks->hGdi32, "D3DKMTOpenAdapterFromGdiDisplayName");
273 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName = %p\n", pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName));
274 bSupported &= !!(pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName);
275
276 pCallbacks->pfnD3DKMTCloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCloseAdapter");
277 Log((__FUNCTION__": pfnD3DKMTCloseAdapter = %p\n", pCallbacks->pfnD3DKMTCloseAdapter));
278 bSupported &= !!(pCallbacks->pfnD3DKMTCloseAdapter);
279
280 pCallbacks->pfnD3DKMTEscape = (PFND3DKMT_ESCAPE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTEscape");
281 Log((__FUNCTION__": pfnD3DKMTEscape = %p\n", pCallbacks->pfnD3DKMTEscape));
282 bSupported &= !!(pCallbacks->pfnD3DKMTEscape);
283
284 pCallbacks->pfnD3DKMTCreateDevice = (PFND3DKMT_CREATEDEVICE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateDevice");
285 Log((__FUNCTION__": pfnD3DKMTCreateDevice = %p\n", pCallbacks->pfnD3DKMTCreateDevice));
286 bSupported &= !!(pCallbacks->pfnD3DKMTCreateDevice);
287
288 pCallbacks->pfnD3DKMTDestroyDevice = (PFND3DKMT_DESTROYDEVICE)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyDevice");
289 Log((__FUNCTION__": pfnD3DKMTDestroyDevice = %p\n", pCallbacks->pfnD3DKMTDestroyDevice));
290 bSupported &= !!(pCallbacks->pfnD3DKMTDestroyDevice);
291
292 pCallbacks->pfnD3DKMTCreateContext = (PFND3DKMT_CREATECONTEXT)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateContext");
293 Log((__FUNCTION__": pfnD3DKMTCreateContext = %p\n", pCallbacks->pfnD3DKMTCreateContext));
294 bSupported &= !!(pCallbacks->pfnD3DKMTCreateContext);
295
296 pCallbacks->pfnD3DKMTDestroyContext = (PFND3DKMT_DESTROYCONTEXT)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyContext");
297 Log((__FUNCTION__": pfnD3DKMTDestroyContext = %p\n", pCallbacks->pfnD3DKMTDestroyContext));
298 bSupported &= !!(pCallbacks->pfnD3DKMTDestroyContext);
299
300 pCallbacks->pfnD3DKMTRender = (PFND3DKMT_RENDER)GetProcAddress(pCallbacks->hGdi32, "D3DKMTRender");
301 Log((__FUNCTION__": pfnD3DKMTRender = %p\n", pCallbacks->pfnD3DKMTRender));
302 bSupported &= !!(pCallbacks->pfnD3DKMTRender);
303
304 pCallbacks->pfnD3DKMTCreateAllocation = (PFND3DKMT_CREATEALLOCATION)GetProcAddress(pCallbacks->hGdi32, "D3DKMTCreateAllocation");
305 Log((__FUNCTION__": pfnD3DKMTCreateAllocation = %p\n", pCallbacks->pfnD3DKMTCreateAllocation));
306 bSupported &= !!(pCallbacks->pfnD3DKMTCreateAllocation);
307
308 pCallbacks->pfnD3DKMTDestroyAllocation = (PFND3DKMT_DESTROYALLOCATION)GetProcAddress(pCallbacks->hGdi32, "D3DKMTDestroyAllocation");
309 Log((__FUNCTION__": pfnD3DKMTDestroyAllocation = %p\n", pCallbacks->pfnD3DKMTDestroyAllocation));
310 bSupported &= !!(pCallbacks->pfnD3DKMTDestroyAllocation);
311
312 pCallbacks->pfnD3DKMTLock = (PFND3DKMT_LOCK)GetProcAddress(pCallbacks->hGdi32, "D3DKMTLock");
313 Log((__FUNCTION__": pfnD3DKMTLock = %p\n", pCallbacks->pfnD3DKMTLock));
314 bSupported &= !!(pCallbacks->pfnD3DKMTLock);
315
316 pCallbacks->pfnD3DKMTUnlock = (PFND3DKMT_UNLOCK)GetProcAddress(pCallbacks->hGdi32, "D3DKMTUnlock");
317 Log((__FUNCTION__": pfnD3DKMTUnlock = %p\n", pCallbacks->pfnD3DKMTUnlock));
318 bSupported &= !!(pCallbacks->pfnD3DKMTUnlock);
319
320 Assert(bSupported);
321 if (bSupported)
322 {
323 return S_OK;
324 }
325 else
326 {
327 Log((__FUNCTION__": one of pfnD3DKMT function pointers failed to initialize\n"));
328 hr = E_NOINTERFACE;
329 }
330
331 FreeLibrary(pCallbacks->hGdi32);
332 }
333 else
334 {
335 DWORD winEr = GetLastError();
336 hr = HRESULT_FROM_WIN32(winEr);
337 Assert(0);
338 Assert(hr != S_OK);
339 Assert(hr != S_FALSE);
340 if (hr == S_OK || hr == S_FALSE)
341 hr = E_FAIL;
342 }
343
344 return hr;
345}
346
347HRESULT vboxDispKmtCallbacksTerm(PVBOXDISPKMT_CALLBACKS pCallbacks)
348{
349 FreeLibrary(pCallbacks->hGdi32);
350 return S_OK;
351}
352
353HRESULT vboxDispKmtOpenAdapter(PVBOXDISPKMT_CALLBACKS pCallbacks, PVBOXDISPKMT_ADAPTER pAdapter)
354{
355 D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME OpenAdapterData = {0};
356 wcsncpy(OpenAdapterData.DeviceName, L"\\\\.\\DISPLAY1", RT_ELEMENTS(OpenAdapterData.DeviceName) - 1 /* the last one is always \0 */);
357 HRESULT hr = S_OK;
358 NTSTATUS Status = pCallbacks->pfnD3DKMTOpenAdapterFromGdiDisplayName(&OpenAdapterData);
359 Assert(!Status);
360 if (!Status)
361 {
362 pAdapter->hAdapter = OpenAdapterData.hAdapter;
363 pAdapter->pCallbacks = pCallbacks;
364 return S_OK;
365 }
366 else
367 {
368 Log((__FUNCTION__": pfnD3DKMTOpenAdapterFromGdiDisplayName failed, Status (0x%x)\n", Status));
369 hr = E_FAIL;
370 }
371
372 return hr;
373
374}
375
376HRESULT vboxDispKmtCloseAdapter(PVBOXDISPKMT_ADAPTER pAdapter)
377{
378 D3DKMT_CLOSEADAPTER ClosaAdapterData = {0};
379 ClosaAdapterData.hAdapter = pAdapter->hAdapter;
380 NTSTATUS Status = pAdapter->pCallbacks->pfnD3DKMTCloseAdapter(&ClosaAdapterData);
381 Assert(!Status);
382 if (!Status)
383 {
384 return S_OK;
385 }
386
387 Log((__FUNCTION__": pfnD3DKMTCloseAdapter failed, Status (0x%x)\n", Status));
388 /* ignore */
389 Status = 0;
390 return E_FAIL;
391}
392
393HRESULT vboxDispKmtCreateDevice(PVBOXDISPKMT_ADAPTER pAdapter, PVBOXDISPKMT_DEVICE pDevice)
394{
395 D3DKMT_CREATEDEVICE CreateDeviceData = {0};
396 CreateDeviceData.hAdapter = pAdapter->hAdapter;
397 NTSTATUS Status = pAdapter->pCallbacks->pfnD3DKMTCreateDevice(&CreateDeviceData);
398 Assert(!Status);
399 if (!Status)
400 {
401 pDevice->pAdapter = pAdapter;
402 pDevice->hDevice = CreateDeviceData.hDevice;
403 pDevice->pCommandBuffer = CreateDeviceData.pCommandBuffer;
404 pDevice->CommandBufferSize = CreateDeviceData.CommandBufferSize;
405 pDevice->pAllocationList = CreateDeviceData.pAllocationList;
406 pDevice->AllocationListSize = CreateDeviceData.AllocationListSize;
407 pDevice->pPatchLocationList = CreateDeviceData.pPatchLocationList;
408 pDevice->PatchLocationListSize = CreateDeviceData.PatchLocationListSize;
409
410 return S_OK;
411 }
412
413 return E_FAIL;
414}
415
416HRESULT vboxDispKmtDestroyDevice(PVBOXDISPKMT_DEVICE pDevice)
417{
418 D3DKMT_DESTROYDEVICE DestroyDeviceData = {0};
419 DestroyDeviceData.hDevice = pDevice->hDevice;
420 NTSTATUS Status = pDevice->pAdapter->pCallbacks->pfnD3DKMTDestroyDevice(&DestroyDeviceData);
421 Assert(!Status);
422 if (!Status)
423 {
424 return S_OK;
425 }
426 return E_FAIL;
427}
428
429HRESULT vboxDispKmtCreateContext(PVBOXDISPKMT_DEVICE pDevice, PVBOXDISPKMT_CONTEXT pContext, BOOL bD3D)
430{
431 VBOXWDDM_CREATECONTEXT_INFO Info = {0};
432 Info.u32IfVersion = 9;
433 Info.enmType = bD3D ? VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_3D : VBOXWDDM_CONTEXT_TYPE_CUSTOM_UHGSMI_GL;
434 D3DKMT_CREATECONTEXT ContextData = {0};
435 ContextData.hDevice = pDevice->hDevice;
436 ContextData.NodeOrdinal = 0;
437 ContextData.EngineAffinity = 0;
438 ContextData.pPrivateDriverData = &Info;
439 ContextData.PrivateDriverDataSize = sizeof (Info);
440 ContextData.ClientHint = bD3D ? D3DKMT_CLIENTHINT_DX9 : D3DKMT_CLIENTHINT_OPENGL;
441 NTSTATUS Status = pDevice->pAdapter->pCallbacks->pfnD3DKMTCreateContext(&ContextData);
442 Assert(!Status);
443 if (!Status)
444 {
445 pContext->pDevice = pDevice;
446 pContext->hContext = ContextData.hContext;
447 pContext->pCommandBuffer = ContextData.pCommandBuffer;
448 pContext->CommandBufferSize = ContextData.CommandBufferSize;
449 pContext->pAllocationList = ContextData.pAllocationList;
450 pContext->AllocationListSize = ContextData.AllocationListSize;
451 pContext->pPatchLocationList = ContextData.pPatchLocationList;
452 pContext->PatchLocationListSize = ContextData.PatchLocationListSize;
453 return S_OK;
454 }
455 return E_FAIL;
456}
457
458HRESULT vboxDispKmtDestroyContext(PVBOXDISPKMT_CONTEXT pContext)
459{
460 D3DKMT_DESTROYCONTEXT DestroyContextData = {0};
461 DestroyContextData.hContext = pContext->hContext;
462 NTSTATUS Status = pContext->pDevice->pAdapter->pCallbacks->pfnD3DKMTDestroyContext(&DestroyContextData);
463 Assert(!Status);
464 if (!Status)
465 return S_OK;
466 return E_FAIL;
467}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette