Changeset 33714 in vbox for trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
- Timestamp:
- Nov 2, 2010 11:36:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
r33684 r33714 16 16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 17 17 */ 18 19 18 #ifdef RT_OS_WINDOWS 20 19 #include <windows.h> … … 226 225 227 226 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) 228 typedef struct CRVBOXHGSMI_CLIENT {229 PVBOXUHGSMI pHgsmi;230 PVBOXUHGSMI_BUFFER pCmdBuffer;231 PVBOXUHGSMI_BUFFER pHGBuffer;232 void *pvHGBuffer;233 CRBufferPool *bufpool;234 } CRVBOXHGSMI_CLIENT, *PCRVBOXHGSMI_CLIENT;235 227 236 228 /* add sizeof header + page align */ … … 243 235 #define CRVBOXHGSMI_BUF_OFFSET(_st2, _st1) ((uint32_t)(((uint8_t*)(_st2)) - ((uint8_t*)(_st1)))) 244 236 237 static int _crVBoxHGSMIClientInit(PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI pHgsmi) 238 { 239 int rc; 240 pClient->pHgsmi = pHgsmi; 241 rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(1), 242 VBOXUHGSMI_SYNCHOBJECT_TYPE_EVENT, 243 NULL, 244 &pClient->pCmdBuffer); 245 AssertRC(rc); 246 if (RT_SUCCESS(rc)) 247 { 248 rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(1), 249 VBOXUHGSMI_SYNCHOBJECT_TYPE_EVENT, 250 NULL, 251 &pClient->pHGBuffer); 252 AssertRC(rc); 253 if (RT_SUCCESS(rc)) 254 { 255 pClient->pvHGBuffer = NULL; 256 pClient->bufpool = crBufferPoolInit(16); 257 return VINF_SUCCESS; 258 } 259 pClient->pCmdBuffer->pfnDestroy(pClient->pCmdBuffer); 260 } 261 pClient->pHgsmi = NULL; 262 return rc; 263 } 264 265 void _crVBoxHGSMIBufferFree(void *data) 266 { 267 PVBOXUHGSMI_BUFFER pBuffer = (PVBOXUHGSMI_BUFFER)data; 268 pBuffer->pfnDestroy(pBuffer); 269 } 270 271 static int _crVBoxHGSMIClientTerm(PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI *ppHgsmi) 272 { 273 if (pClient->bufpool) 274 crBufferPoolCallbackFree(pClient->bufpool, _crVBoxHGSMIBufferFree); 275 pClient->bufpool = NULL; 276 277 if (pClient->pHGBuffer) 278 { 279 pClient->pHGBuffer->pfnDestroy(pClient->pHGBuffer); 280 pClient->pHGBuffer = NULL; 281 } 282 283 if (pClient->pCmdBuffer) 284 { 285 pClient->pCmdBuffer->pfnDestroy(pClient->pCmdBuffer); 286 pClient->pCmdBuffer = NULL; 287 } 288 289 if (ppHgsmi) 290 { 291 *ppHgsmi = pClient->pHgsmi; 292 } 293 pClient->pHgsmi = NULL; 294 295 return VINF_SUCCESS; 296 } 297 298 299 #ifdef VBOX_CRHGSMI_WITH_D3DDEV 300 301 DECLCALLBACK(HVBOXCRHGSMI_CLIENT) _crVBoxHGSMIClientCreate(PVBOXUHGSMI pHgsmi) 302 { 303 PCRVBOXHGSMI_CLIENT pClient = crAlloc(sizeof (CRVBOXHGSMI_CLIENT)); 304 305 if (pClient) 306 { 307 int rc = _crVBoxHGSMIClientInit(pClient, pHgsmi); 308 AssertRC(rc); 309 if (RT_SUCCESS(rc)) 310 return (HVBOXCRHGSMI_CLIENT)pClient; 311 312 crFree(pCLient); 313 } 314 315 return NULL; 316 } 317 318 DECLCALLBACK(void) _crVBoxHGSMIClientDestroy(HVBOXCRHGSMI_CLIENT hClient) 319 { 320 PCRVBOXHGSMI_CLIENT pClient = (PCRVBOXHGSMI_CLIENT)hClient; 321 _crVBoxHGSMIClientTerm(pClient, NULL); 322 crFree(pClient); 323 } 324 #endif 325 245 326 DECLINLINE(PCRVBOXHGSMI_CLIENT) _crVBoxHGSMIClientGet(CRConnection *conn) 246 327 { 328 #ifdef VBOX_CRHGSMI_WITH_D3DDEV 247 329 PCRVBOXHGSMI_CLIENT pClient = (PCRVBOXHGSMI_CLIENT)VBoxCrHgsmiQueryClient(); 248 330 Assert(pClient); 249 331 return pClient; 332 #else 333 if (conn->HgsmiClient.pHgsmi) 334 return &conn->HgsmiClient; 335 { 336 PVBOXUHGSMI pHgsmi = VBoxCrHgsmiCreate(); 337 Assert(pHgsmi); 338 if (pHgsmi) 339 { 340 int rc = _crVBoxHGSMIClientInit(&conn->HgsmiClient, pHgsmi); 341 AssertRC(rc); 342 if (RT_SUCCESS(rc)) 343 { 344 Assert(conn->HgsmiClient.pHgsmi); 345 return &conn->HgsmiClient; 346 } 347 VBoxCrHgsmiDestroy(pHgsmi); 348 } 349 } 350 return NULL; 351 #endif 250 352 } 251 353 … … 1369 1471 1370 1472 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) 1371 DECLCALLBACK(HVBOXCRHGSMI_CLIENT) _crVBoxHGSMIClientCreate(PVBOXUHGSMI pHgsmi) 1372 { 1373 PCRVBOXHGSMI_CLIENT pClient = crAlloc(sizeof (CRVBOXHGSMI_CLIENT)); 1374 1375 if (pClient) 1473 1474 bool _crVBoxHGSMIInit() 1475 { 1476 #ifndef VBOX_CRHGSMI_WITH_D3DDEV 1477 static 1478 #endif 1479 int bHasHGSMI = -1; 1480 1481 if (bHasHGSMI < 0) 1376 1482 { 1377 1483 int rc; 1378 pClient->pHgsmi = pHgsmi; 1379 rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(1), 1380 VBOXUHGSMI_SYNCHOBJECT_TYPE_EVENT, 1381 NULL, 1382 &pClient->pCmdBuffer); 1383 AssertRC(rc); 1384 if (RT_SUCCESS(rc)) 1385 { 1386 rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(1), 1387 VBOXUHGSMI_SYNCHOBJECT_TYPE_EVENT, 1388 NULL, 1389 &pClient->pHGBuffer); 1390 AssertRC(rc); 1391 if (RT_SUCCESS(rc)) 1392 { 1393 pClient->pvHGBuffer = NULL; 1394 pClient->bufpool = crBufferPoolInit(16); 1395 return (HVBOXCRHGSMI_CLIENT) pClient; 1396 } 1397 pClient->pCmdBuffer->pfnDestroy(pClient->pCmdBuffer); 1398 } 1399 } 1400 1401 return NULL; 1402 } 1403 1404 DECLCALLBACK(void) _crVBoxHGSMIClientDestroy(HVBOXCRHGSMI_CLIENT hClient) 1405 { 1406 Assert(0); 1407 1408 /* @todo */ 1409 } 1410 1411 bool _crVBoxHGSMIInit() 1412 { 1413 int bHasHGSMI = -1; 1414 1415 if (bHasHGSMI < 0) 1416 { 1417 int rc; 1484 #ifndef VBOX_CRHGSMI_WITH_D3DDEV 1485 rc = VBoxCrHgsmiInit(); 1486 #else 1418 1487 VBOXCRHGSMI_CALLBACKS Callbacks; 1419 1488 Callbacks.pfnClientCreate = _crVBoxHGSMIClientCreate; 1420 1489 Callbacks.pfnClientDestroy = _crVBoxHGSMIClientDestroy; 1421 1490 rc = VBoxCrHgsmiInit(&Callbacks); 1491 #endif 1422 1492 AssertRC(rc); 1423 1493 if (RT_SUCCESS(rc)) … … 2004 2074 static void crVBoxHGSMIDoDisconnect( CRConnection *conn ) 2005 2075 { 2076 #ifndef VBOX_CRHGSMI_WITH_D3DDEV 2077 if (conn->HgsmiClient.pHgsmi) 2078 { 2079 PVBOXUHGSMI pHgsmi; 2080 _crVBoxHGSMIClientTerm(&conn->HgsmiClient, &pHgsmi); 2081 Assert(pHgsmi); 2082 VBoxCrHgsmiDestroy(pHgsmi); 2083 } 2084 2085 #endif 2006 2086 crVBoxHGCMDoDisconnect(conn); 2007 2087 }
Note:
See TracChangeset
for help on using the changeset viewer.