Changeset 33530 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Display
- Timestamp:
- Oct 27, 2010 7:59:36 PM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxCrHgsmi.cpp
r33306 r33530 112 112 if (pHgsmiGL) 113 113 { 114 #if 0 114 115 HRESULT hr = vboxUhgsmiKmtCreate(pHgsmiGL, TRUE /* bD3D tmp for injection thread*/); 116 #else 117 HRESULT hr = vboxUhgsmiKmtEscCreate(pHgsmiGL, TRUE /* bD3D tmp for injection thread*/); 118 #endif 115 119 Assert(hr == S_OK); 116 120 if (hr == S_OK) -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiKmt.cpp
r33241 r33530 26 26 } VBOXUHGSMI_BUFFER_PRIVATE_KMT, *PVBOXUHGSMI_BUFFER_PRIVATE_KMT; 27 27 28 typedef struct VBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC 29 { 30 VBOXUHGSMI_BUFFER Base; 31 PVBOXUHGSMI_PRIVATE_KMT pHgsmi; 32 VBOXVIDEOCM_UM_ALLOC Alloc; 33 } VBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC, *PVBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC; 34 35 #define VBOXUHGSMIKMT_GET_BUFFER(_p) VBOXUHGSMIKMT_GET_PRIVATE(_p, VBOXUHGSMI_BUFFER_PRIVATE_KMT) 36 #define VBOXUHGSMIKMTESC_GET_PRIVATE(_p, _t) ((_t*)(((uint8_t*)_p) - RT_OFFSETOF(_t, Base))) 37 #define VBOXUHGSMIKMTESC_GET_BUFFER(_p) VBOXUHGSMIKMTESC_GET_PRIVATE(_p, VBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC) 38 28 39 DECLCALLBACK(int) vboxUhgsmiKmtBufferDestroy(PVBOXUHGSMI_BUFFER pBuf) 29 40 { … … 207 218 } 208 219 209 HRESULT vboxUhgsmiKmtCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D) 210 { 211 pHgsmi->BasePrivate.Base.pfnBufferCreate = vboxUhgsmiKmtBufferCreate; 212 pHgsmi->BasePrivate.Base.pfnBufferSubmitAsynch = vboxUhgsmiKmtBufferSubmitAsynch; 213 pHgsmi->BasePrivate.hClient = NULL; 214 220 221 DECLCALLBACK(int) vboxUhgsmiKmtEscBufferLock(PVBOXUHGSMI_BUFFER pBuf, uint32_t offLock, uint32_t cbLock, VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags, void**pvLock) 222 { 223 PVBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC pBuffer = VBOXUHGSMIKMTESC_GET_BUFFER(pBuf); 224 *pvLock = pBuffer->Alloc.pvData + offLock; 225 return VINF_SUCCESS; 226 } 227 228 DECLCALLBACK(int) vboxUhgsmiKmtEscBufferUnlock(PVBOXUHGSMI_BUFFER pBuf) 229 { 230 return VINF_SUCCESS; 231 } 232 233 DECLCALLBACK(int) vboxUhgsmiKmtEscBufferDestroy(PVBOXUHGSMI_BUFFER pBuf) 234 { 235 PVBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC pBuffer = VBOXUHGSMIKMTESC_GET_BUFFER(pBuf); 236 PVBOXUHGSMI_PRIVATE_KMT pPrivate = pBuffer->pHgsmi; 237 D3DKMT_ESCAPE DdiEscape = {0}; 238 VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE DeallocInfo = {0}; 239 DdiEscape.hAdapter = pPrivate->Adapter.hAdapter; 240 DdiEscape.hDevice = pPrivate->Device.hDevice; 241 DdiEscape.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; 242 //Buf.DdiEscape.Flags.HardwareAccess = 1; 243 DdiEscape.pPrivateDriverData = &DeallocInfo; 244 DdiEscape.PrivateDriverDataSize = sizeof (DeallocInfo); 245 DdiEscape.hContext = pPrivate->Context.hContext; 246 247 DeallocInfo.EscapeHdr.escapeCode = VBOXESC_UHGSMI_DEALLOCATE; 248 DeallocInfo.hAlloc = pBuffer->Alloc.hAlloc; 249 250 HRESULT hr = pPrivate->Callbacks.pfnD3DKMTEscape(&DdiEscape); 251 Assert(hr == S_OK); 252 if (hr == S_OK) 253 { 254 if (pBuffer->Base.bSynchCreated) 255 { 256 CloseHandle(pBuffer->Base.hSynch); 257 } 258 RTMemFree(pBuffer); 259 return VINF_SUCCESS; 260 } 261 262 return VERR_GENERAL_FAILURE; 263 } 264 265 DECLCALLBACK(int) vboxUhgsmiKmtEscBufferCreate(PVBOXUHGSMI pHgsmi, uint32_t cbBuf, 266 VBOXUHGSMI_SYNCHOBJECT_TYPE enmSynchType, HVBOXUHGSMI_SYNCHOBJECT hSynch, 267 PVBOXUHGSMI_BUFFER* ppBuf) 268 { 269 bool bSynchCreated = false; 270 if (!cbBuf) 271 return VERR_INVALID_PARAMETER; 272 273 int rc = vboxUhgsmiBaseEventChkCreate(enmSynchType, &hSynch, &bSynchCreated); 274 AssertRC(rc); 275 if (RT_FAILURE(rc)) 276 return rc; 277 278 cbBuf = VBOXWDDM_ROUNDBOUND(cbBuf, 0x1000); 279 Assert(cbBuf); 280 uint32_t cPages = cbBuf >> 12; 281 Assert(cPages); 282 283 PVBOXUHGSMI_PRIVATE_KMT pPrivate = VBOXUHGSMIKMT_GET(pHgsmi); 284 PVBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC pBuf = (PVBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC)RTMemAllocZ(RT_OFFSETOF(VBOXUHGSMI_BUFFER_PRIVATE_KMT, aLockPageIndices[cPages])); 285 Assert(pBuf); 286 if (pBuf) 287 { 288 struct 289 { 290 D3DKMT_ESCAPE DdiEscape; 291 VBOXDISPIFESCAPE_UHGSMI_ALLOCATE AllocInfo; 292 } Buf; 293 memset(&Buf, 0, sizeof (Buf)); 294 Buf.DdiEscape.hAdapter = pPrivate->Adapter.hAdapter; 295 Buf.DdiEscape.hDevice = pPrivate->Device.hDevice; 296 Buf.DdiEscape.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; 297 //Buf.DdiEscape.Flags.HardwareAccess = 1; 298 Buf.DdiEscape.pPrivateDriverData = &Buf.AllocInfo; 299 Buf.DdiEscape.PrivateDriverDataSize = sizeof (Buf.AllocInfo); 300 Buf.DdiEscape.hContext = pPrivate->Context.hContext; 301 302 Buf.AllocInfo.EscapeHdr.escapeCode = VBOXESC_UHGSMI_ALLOCATE; 303 Buf.AllocInfo.Alloc.cbData = cbBuf; 304 Buf.AllocInfo.Alloc.hSynch = hSynch; 305 Buf.AllocInfo.Alloc.enmSynchType = enmSynchType; 306 307 HRESULT hr = pPrivate->Callbacks.pfnD3DKMTEscape(&Buf.DdiEscape); 308 Assert(hr == S_OK); 309 if (hr == S_OK) 310 { 311 pBuf->Alloc = Buf.AllocInfo.Alloc; 312 Assert(pBuf->Alloc.pvData); 313 pBuf->pHgsmi = pPrivate; 314 pBuf->Base.pfnLock = vboxUhgsmiKmtEscBufferLock; 315 pBuf->Base.pfnUnlock = vboxUhgsmiKmtEscBufferUnlock; 316 // pBuf->Base.pfnAdjustValidDataRange = vboxUhgsmiKmtBufferAdjustValidDataRange; 317 pBuf->Base.pfnDestroy = vboxUhgsmiKmtEscBufferDestroy; 318 319 pBuf->Base.hSynch = hSynch; 320 pBuf->Base.enmSynchType = enmSynchType; 321 pBuf->Base.cbBuffer = Buf.AllocInfo.Alloc.cbData; 322 pBuf->Base.bSynchCreated = bSynchCreated; 323 324 *ppBuf = &pBuf->Base; 325 326 return VINF_SUCCESS; 327 } 328 329 RTMemFree(pBuf); 330 } 331 else 332 rc = VERR_NO_MEMORY; 333 334 if (bSynchCreated) 335 CloseHandle(hSynch); 336 337 return rc; 338 } 339 340 DECLCALLBACK(int) vboxUhgsmiKmtEscBufferSubmitAsynch(PVBOXUHGSMI pHgsmi, PVBOXUHGSMI_BUFFER_SUBMIT aBuffers, uint32_t cBuffers) 341 { 342 /* we no chromium will not submit more than three buffers actually, 343 * for simplicity allocate it statically on the stack */ 344 struct 345 { 346 VBOXDISPIFESCAPE_UHGSMI_SUBMIT SubmitInfo; 347 VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE aBufInfos[3]; 348 } Buf; 349 350 if (cBuffers > RT_ELEMENTS(Buf.aBufInfos) + 1) 351 { 352 Assert(0); 353 return VERR_INVALID_PARAMETER; 354 } 355 356 357 PVBOXUHGSMI_PRIVATE_KMT pPrivate = VBOXUHGSMIKMT_GET(pHgsmi); 358 D3DKMT_ESCAPE DdiEscape = {0}; 359 360 DdiEscape.hAdapter = pPrivate->Adapter.hAdapter; 361 DdiEscape.hDevice = pPrivate->Device.hDevice; 362 DdiEscape.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; 363 //Buf.DdiEscape.Flags.HardwareAccess = 1; 364 DdiEscape.pPrivateDriverData = &Buf.SubmitInfo; 365 DdiEscape.PrivateDriverDataSize = RT_OFFSETOF(VBOXDISPIFESCAPE_UHGSMI_SUBMIT, aBuffers[cBuffers]); 366 DdiEscape.hContext = pPrivate->Context.hContext; 367 368 Buf.SubmitInfo.EscapeHdr.escapeCode = VBOXESC_UHGSMI_SUBMIT; 369 Buf.SubmitInfo.EscapeHdr.u32CmdSpecific = cBuffers; 370 for (UINT i = 0; i < cBuffers; ++i) 371 { 372 VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE *pSubmInfo = &Buf.SubmitInfo.aBuffers[i]; 373 PVBOXUHGSMI_BUFFER_SUBMIT pBufInfo = &aBuffers[i]; 374 PVBOXUHGSMI_BUFFER_PRIVATE_KMT_ESC pBuf = VBOXUHGSMIKMTESC_GET_BUFFER(pBufInfo->pBuf); 375 pSubmInfo->hAlloc = pBuf->Alloc.hAlloc; 376 pSubmInfo->Info.fSubFlags = pBufInfo->fFlags; 377 if (pBufInfo->fFlags.bEntireBuffer) 378 { 379 pSubmInfo->Info.offData = 0; 380 pSubmInfo->Info.cbData = pBuf->Base.cbBuffer; 381 } 382 else 383 { 384 pSubmInfo->Info.offData = pBufInfo->offData; 385 pSubmInfo->Info.cbData = pBufInfo->cbData; 386 } 387 } 388 389 HRESULT hr = pPrivate->Callbacks.pfnD3DKMTEscape(&DdiEscape); 390 Assert(hr == S_OK); 391 if (hr == S_OK) 392 { 393 return VINF_SUCCESS; 394 } 395 396 return VERR_GENERAL_FAILURE; 397 } 398 399 static HRESULT vboxUhgsmiKmtEngineCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D) 400 { 215 401 HRESULT hr = vboxDispKmtCallbacksInit(&pHgsmi->Callbacks); 216 402 Assert(hr == S_OK); … … 239 425 return hr; 240 426 } 241 427 HRESULT vboxUhgsmiKmtCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D) 428 { 429 pHgsmi->BasePrivate.Base.pfnBufferCreate = vboxUhgsmiKmtBufferCreate; 430 pHgsmi->BasePrivate.Base.pfnBufferSubmitAsynch = vboxUhgsmiKmtBufferSubmitAsynch; 431 pHgsmi->BasePrivate.hClient = NULL; 432 return vboxUhgsmiKmtEngineCreate(pHgsmi, bD3D); 433 } 434 435 HRESULT vboxUhgsmiKmtEscCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D) 436 { 437 pHgsmi->BasePrivate.Base.pfnBufferCreate = vboxUhgsmiKmtEscBufferCreate; 438 pHgsmi->BasePrivate.Base.pfnBufferSubmitAsynch = vboxUhgsmiKmtEscBufferSubmitAsynch; 439 pHgsmi->BasePrivate.hClient = NULL; 440 return vboxUhgsmiKmtEngineCreate(pHgsmi, bD3D); 441 } 242 442 243 443 HRESULT vboxUhgsmiKmtDestroy(PVBOXUHGSMI_PRIVATE_KMT pHgsmi) -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxUhgsmiKmt.h
r33116 r33530 90 90 #define VBOXUHGSMIKMT_GET_PRIVATE(_p, _t) ((_t*)(((uint8_t*)_p) - RT_OFFSETOF(_t, BasePrivate.Base))) 91 91 #define VBOXUHGSMIKMT_GET(_p) VBOXUHGSMIKMT_GET_PRIVATE(_p, VBOXUHGSMI_PRIVATE_KMT) 92 #define VBOXUHGSMIKMT_GET_BUFFER(_p) VBOXUHGSMIKMT_GET_PRIVATE(_p, VBOXUHGSMI_BUFFER_PRIVATE_KMT)93 92 94 93 HRESULT vboxDispKmtOpenAdapter(PVBOXDISPKMT_CALLBACKS pCallbacks, PVBOXDISPKMT_ADAPTER pAdapter); … … 102 101 HRESULT vboxUhgsmiKmtDestroy(PVBOXUHGSMI_PRIVATE_KMT pHgsmi); 103 102 103 HRESULT vboxUhgsmiKmtEscCreate(PVBOXUHGSMI_PRIVATE_KMT pHgsmi, BOOL bD3D); 104 104 105 105
Note:
See TracChangeset
for help on using the changeset viewer.