- Timestamp:
- Mar 16, 2015 1:59:11 PM (10 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r54783 r54785 845 845 846 846 uint32_t cContexts; 847 PVMSVGA3DCONTEXT paContext;847 PVMSVGA3DCONTEXT *papContexts; 848 848 uint32_t cSurfaces; 849 849 PVMSVGA3DSURFACE paSurface; … … 898 898 899 899 SSMFIELD_ENTRY( VMSVGA3DSTATE, cContexts), 900 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSTATE, pa Context),900 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSTATE, papContexts), 901 901 SSMFIELD_ENTRY( VMSVGA3DSTATE, cSurfaces), 902 902 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSTATE, paSurface), … … 1320 1320 #ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE 1321 1321 PVMSVGA3DSTATE pState = RT_FROM_MEMBER(pThis, VMSVGA3DSTATE, ShaderIf); 1322 VMSVGA3D_SET_CURRENT_CONTEXT(pState, &pState->paContext[fOtherProfile ? 2 : 1]);1322 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pState->papContexts[fOtherProfile ? 2 : 1]); 1323 1323 #else 1324 1324 NOREF(pThis); … … 1444 1444 AssertRCReturn(rc, rc); 1445 1445 1446 pContext = &pState->paContext[1];1446 pContext = pState->papContexts[1]; 1447 1447 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 1448 1448 … … 1468 1468 rc = vmsvga3dContextDefineOgl(pThis, 2, VMSVGA3D_DEF_CTX_F_INIT | VMSVGA3D_DEF_CTX_F_OTHER_PROFILE); 1469 1469 AssertLogRelRCReturn(rc, rc); 1470 pContext = &pState->paContext[1]; /* Array may have been reallocated. */1471 1472 pOtherCtx = &pState->paContext[2];1470 pContext = pState->papContexts[1]; /* Array may have been reallocated. */ 1471 1472 pOtherCtx = pState->papContexts[2]; 1473 1473 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pOtherCtx); 1474 1474 … … 1832 1832 for (uint32_t i = 0; i < pState->cContexts; i++) 1833 1833 { 1834 if (pState->pa Context[i].id != SVGA3D_INVALID_ID)1835 vmsvga3dContextDestroy(pThis, pState->pa Context[i].id);1834 if (pState->papContexts[i]->id != SVGA3D_INVALID_ID) 1835 vmsvga3dContextDestroy(pThis, pState->papContexts[i]->id); 1836 1836 } 1837 1837 return VINF_SUCCESS; … … 2815 2815 for (uint32_t cid = 0; cid < pState->cContexts; cid++) 2816 2816 { 2817 pContext = &pState->paContext[cid];2817 pContext = pState->papContexts[cid]; 2818 2818 if (pContext->id == cid) 2819 2819 { … … 2834 2834 uint32_t cid = pSurface->idAssociatedContext; 2835 2835 if ( cid <= pState->cContexts 2836 && pState->pa Context[cid].id == cid)2837 { 2838 pContext = &pState->paContext[cid];2836 && pState->papContexts[cid]->id == cid) 2837 { 2838 pContext = pState->papContexts[cid]; 2839 2839 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 2840 2840 } … … 2845 2845 for (cid = 0; cid < pState->cContexts; cid++) 2846 2846 { 2847 if (pState->pa Context[cid].id == cid)2847 if (pState->papContexts[cid]->id == cid) 2848 2848 { 2849 pContext = &pState->paContext[cid];2849 pContext = pState->papContexts[cid]; 2850 2850 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 2851 2851 break; … … 3150 3150 3151 3151 #ifdef VMSVGA3D_OGL_WITH_SHARED_CTX 3152 if (idPrevCtx < pState->cContexts && pState->pa Context[idPrevCtx].id == idPrevCtx)3153 VMSVGA3D_SET_CURRENT_CONTEXT(pState, &pState->paContext[idPrevCtx]);3152 if (idPrevCtx < pState->cContexts && pState->papContexts[idPrevCtx]->id == idPrevCtx) 3153 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pState->papContexts[idPrevCtx]); 3154 3154 #endif 3155 3155 return VINF_SUCCESS; … … 3197 3197 3198 3198 if ( cid >= pState->cContexts 3199 || pState->pa Context[cid].id != cid)3199 || pState->papContexts[cid]->id != cid) 3200 3200 { 3201 3201 Log(("vmsvga3dSurfaceStretchBlt invalid context id!\n")); 3202 3202 AssertFailedReturn(VERR_INVALID_PARAMETER); 3203 3203 } 3204 pContext = &pState->paContext[cid];3204 pContext = pState->papContexts[cid]; 3205 3205 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3206 3206 #endif … … 3477 3477 uint32_t cid = pSurface->idAssociatedContext; 3478 3478 if ( cid >= pState->cContexts 3479 || pState->pa Context[cid].id != cid)3480 { 3481 Log(("vmsvga3dSurfaceDMA invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->pa Context[cid].id));3479 || pState->papContexts[cid]->id != cid) 3480 { 3481 Log(("vmsvga3dSurfaceDMA invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->papContexts[cid]->id)); 3482 3482 AssertFailedReturn(VERR_INVALID_PARAMETER); 3483 3483 } 3484 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];3484 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 3485 3485 #endif 3486 3486 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); … … 3830 3830 3831 3831 if ( cid >= pState->cContexts 3832 || pState->pa Context[cid].id != cid)3832 || pState->papContexts[cid]->id != cid) 3833 3833 { 3834 3834 Log(("vmsvga3dGenerateMipmaps invalid context id!\n")); 3835 3835 return VERR_INVALID_PARAMETER; 3836 3836 } 3837 pContext = &pState->paContext[cid];3837 pContext = pState->papContexts[cid]; 3838 3838 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3839 3839 #endif … … 3913 3913 3914 3914 if ( cid >= pState->cContexts 3915 || pState->pa Context[cid].id != cid)3915 || pState->papContexts[cid]->id != cid) 3916 3916 { 3917 3917 Log(("vmsvga3dCommandPresent invalid context id!\n")); 3918 3918 return VERR_INVALID_PARAMETER; 3919 3919 } 3920 pContext = &pState->paContext[cid];3920 pContext = pState->papContexts[cid]; 3921 3921 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 3922 3922 #endif … … 4239 4239 if (cid >= pState->cContexts) 4240 4240 { 4241 void *pvNew = RTMemRealloc(pState->paContext, sizeof(VMSVGA3DCONTEXT) * (cid + 1)); 4241 /* Grow the array. */ 4242 uint32_t cNew = RT_ALIGN(cid + 15, 16); 4243 void *pvNew = RTMemRealloc(pState->papContexts, sizeof(pState->papContexts[0]) * cNew); 4242 4244 AssertReturn(pvNew, VERR_NO_MEMORY); 4243 pState->paContext = (PVMSVGA3DCONTEXT)pvNew; 4244 memset(&pState->paContext[pState->cContexts], 0, sizeof(VMSVGA3DCONTEXT) * (cid + 1 - pState->cContexts)); 4245 for (uint32_t i = pState->cContexts; i < cid + 1; i++) 4246 pState->paContext[i].id = SVGA3D_INVALID_ID; 4247 4248 pState->cContexts = cid + 1; 4245 pState->papContexts = (PVMSVGA3DCONTEXT *)pvNew; 4246 while (pState->cContexts < cNew) 4247 { 4248 pContext = (PVMSVGA3DCONTEXT)RTMemAllocZ(sizeof(*pContext)); 4249 AssertReturn(pContext, VERR_NO_MEMORY); 4250 pContext->id = SVGA3D_INVALID_ID; 4251 pState->papContexts[pState->cContexts++] = pContext; 4252 } 4249 4253 } 4250 4254 /* If one already exists with this id, then destroy it now. */ 4251 if (pState->pa Context[cid].id != SVGA3D_INVALID_ID)4255 if (pState->papContexts[cid]->id != SVGA3D_INVALID_ID) 4252 4256 vmsvga3dContextDestroy(pThis, cid); 4253 4257 4254 pContext = &pState->paContext[cid];4258 pContext = pState->papContexts[cid]; 4255 4259 } 4256 4260 … … 4274 4278 PVMSVGA3DCONTEXT pSharedCtx = NULL; 4275 4279 for (uint32_t i = 0; i < pState->cContexts; i++) 4276 if ( pState->pa Context[i].id != SVGA3D_INVALID_ID4280 if ( pState->papContexts[i]->id != SVGA3D_INVALID_ID 4277 4281 && i != cid 4278 4282 # ifdef VBOX_VMSVGA3D_DUAL_OPENGL_PROFILE 4279 && pState->pa Context[i].fOtherProfile == RT_BOOL(fFlags & VMSVGA3D_DEF_CTX_F_OTHER_PROFILE)4283 && pState->papContexts[i]->fOtherProfile == RT_BOOL(fFlags & VMSVGA3D_DEF_CTX_F_OTHER_PROFILE) 4280 4284 # endif 4281 4285 ) 4282 4286 { 4283 4287 Log(("Sharing display lists between cid=%d and cid=%d\n", pContext->id, i)); 4284 pSharedCtx = &pState->paContext[i];4288 pSharedCtx = pState->papContexts[i]; 4285 4289 break; 4286 4290 } … … 4508 4512 4509 4513 if ( cid < pState->cContexts 4510 && pState->pa Context[cid].id == cid)4511 { 4512 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];4514 && pState->papContexts[cid]->id == cid) 4515 { 4516 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 4513 4517 4514 4518 Log(("vmsvga3dContextDestroy id %x\n", cid)); … … 4644 4648 for (uint32_t i = 0; i < pState->cContexts; i++) 4645 4649 { 4646 PVMSVGA3DCONTEXT pContext = &pState->paContext[i];4650 PVMSVGA3DCONTEXT pContext = pState->papContexts[i]; 4647 4651 uint32_t cid = pContext->id; 4648 4652 … … 4683 4687 4684 4688 if ( cid >= pState->cContexts 4685 || pState->pa Context[cid].id != cid)4689 || pState->papContexts[cid]->id != cid) 4686 4690 { 4687 4691 Log(("vmsvga3dSetTransform invalid context id!\n")); 4688 4692 return VERR_INVALID_PARAMETER; 4689 4693 } 4690 pContext = &pState->paContext[cid];4694 pContext = pState->papContexts[cid]; 4691 4695 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 4692 4696 … … 4790 4794 4791 4795 if ( cid >= pState->cContexts 4792 || pState->pa Context[cid].id != cid)4796 || pState->papContexts[cid]->id != cid) 4793 4797 { 4794 4798 Log(("vmsvga3dSetZRange invalid context id!\n")); 4795 4799 return VERR_INVALID_PARAMETER; 4796 4800 } 4797 pContext = &pState->paContext[cid];4801 pContext = pState->papContexts[cid]; 4798 4802 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 4799 4803 … … 4932 4936 4933 4937 if ( cid >= pState->cContexts 4934 || pState->pa Context[cid].id != cid)4938 || pState->papContexts[cid]->id != cid) 4935 4939 { 4936 4940 Log(("vmsvga3dSetRenderState invalid context id!\n")); 4937 4941 return VERR_INVALID_PARAMETER; 4938 4942 } 4939 pContext = &pState->paContext[cid];4943 pContext = pState->papContexts[cid]; 4940 4944 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 4941 4945 … … 5767 5771 5768 5772 if ( cid >= pState->cContexts 5769 || pState->pa Context[cid].id != cid)5773 || pState->papContexts[cid]->id != cid) 5770 5774 { 5771 5775 Log(("vmsvga3dSetRenderTarget invalid context id!\n")); 5772 5776 return VERR_INVALID_PARAMETER; 5773 5777 } 5774 pContext = &pState->paContext[cid];5778 pContext = pState->papContexts[cid]; 5775 5779 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 5776 5780 … … 5839 5843 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 5840 5844 5841 pContext = &pState->paContext[cid];5845 pContext = pState->papContexts[cid]; 5842 5846 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 5843 5847 #else … … 6090 6094 6091 6095 if ( cid >= pState->cContexts 6092 || pState->pa Context[cid].id != cid)6096 || pState->papContexts[cid]->id != cid) 6093 6097 { 6094 6098 Log(("vmsvga3dSetTextureState invalid context id!\n")); 6095 6099 return VERR_INVALID_PARAMETER; 6096 6100 } 6097 pContext = &pState->paContext[cid];6101 pContext = pState->papContexts[cid]; 6098 6102 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6099 6103 … … 6336 6340 6337 6341 if ( cid >= pState->cContexts 6338 || pState->pa Context[cid].id != cid)6342 || pState->papContexts[cid]->id != cid) 6339 6343 { 6340 6344 Log(("vmsvga3dSetMaterial invalid context id!\n")); 6341 6345 return VERR_INVALID_PARAMETER; 6342 6346 } 6343 pContext = &pState->paContext[cid];6347 pContext = pState->papContexts[cid]; 6344 6348 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6345 6349 … … 6389 6393 6390 6394 if ( cid >= pState->cContexts 6391 || pState->pa Context[cid].id != cid)6395 || pState->papContexts[cid]->id != cid) 6392 6396 { 6393 6397 Log(("vmsvga3dSetLightData invalid context id!\n")); 6394 6398 return VERR_INVALID_PARAMETER; 6395 6399 } 6396 pContext = &pState->paContext[cid];6400 pContext = pState->papContexts[cid]; 6397 6401 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6398 6402 … … 6568 6572 6569 6573 if ( cid >= pState->cContexts 6570 || pState->pa Context[cid].id != cid)6574 || pState->papContexts[cid]->id != cid) 6571 6575 { 6572 6576 Log(("vmsvga3dSetLightEnabled invalid context id!\n")); 6573 6577 return VERR_INVALID_PARAMETER; 6574 6578 } 6575 pContext = &pState->paContext[cid];6579 pContext = pState->papContexts[cid]; 6576 6580 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6577 6581 … … 6605 6609 6606 6610 if ( cid >= pState->cContexts 6607 || pState->pa Context[cid].id != cid)6611 || pState->papContexts[cid]->id != cid) 6608 6612 { 6609 6613 Log(("vmsvga3dSetViewPort invalid context id!\n")); 6610 6614 return VERR_INVALID_PARAMETER; 6611 6615 } 6612 pContext = &pState->paContext[cid];6616 pContext = pState->papContexts[cid]; 6613 6617 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6614 6618 … … 6653 6657 6654 6658 if ( cid >= pState->cContexts 6655 || pState->pa Context[cid].id != cid)6659 || pState->papContexts[cid]->id != cid) 6656 6660 { 6657 6661 Log(("vmsvga3dSetClipPlane invalid context id!\n")); 6658 6662 return VERR_INVALID_PARAMETER; 6659 6663 } 6660 pContext = &pState->paContext[cid];6664 pContext = pState->papContexts[cid]; 6661 6665 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6662 6666 … … 6686 6690 6687 6691 if ( cid >= pState->cContexts 6688 || pState->pa Context[cid].id != cid)6692 || pState->papContexts[cid]->id != cid) 6689 6693 { 6690 6694 Log(("vmsvga3dSetScissorRect invalid context id!\n")); 6691 6695 return VERR_INVALID_PARAMETER; 6692 6696 } 6693 pContext = &pState->paContext[cid];6697 pContext = pState->papContexts[cid]; 6694 6698 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6695 6699 … … 6725 6729 6726 6730 if ( cid >= pState->cContexts 6727 || pState->pa Context[cid].id != cid)6731 || pState->papContexts[cid]->id != cid) 6728 6732 { 6729 6733 Log(("vmsvga3dCommandClear invalid context id!\n")); 6730 6734 return VERR_INVALID_PARAMETER; 6731 6735 } 6732 pContext = &pState->paContext[cid];6736 pContext = pState->papContexts[cid]; 6733 6737 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 6734 6738 … … 7175 7179 7176 7180 if ( cid >= pState->cContexts 7177 || pState->pa Context[cid].id != cid)7181 || pState->papContexts[cid]->id != cid) 7178 7182 { 7179 7183 Log(("vmsvga3dDrawPrimitives invalid context id!\n")); 7180 7184 return VERR_INVALID_PARAMETER; 7181 7185 } 7182 pContext = &pState->paContext[cid];7186 pContext = pState->papContexts[cid]; 7183 7187 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7184 7188 … … 7280 7284 VMSVGA3D_CHECK_LAST_ERROR(pState, pContext); 7281 7285 7282 pContext = &pState->paContext[cid];7286 pContext = pState->papContexts[cid]; 7283 7287 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7284 7288 #endif … … 7418 7422 7419 7423 if ( cid >= pState->cContexts 7420 || pState->pa Context[cid].id != cid)7424 || pState->papContexts[cid]->id != cid) 7421 7425 { 7422 7426 Log(("vmsvga3dShaderDefine invalid context id!\n")); 7423 7427 return VERR_INVALID_PARAMETER; 7424 7428 } 7425 pContext = &pState->paContext[cid];7429 pContext = pState->papContexts[cid]; 7426 7430 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7427 7431 … … 7431 7435 if (shid >= pContext->cVertexShaders) 7432 7436 { 7433 void *pvNew = RTMemRealloc(pContext->paVertexShader, sizeof(VMSVGA3DSHADER) * (shid + 1)) 7437 void *pvNew = RTMemRealloc(pContext->paVertexShader, sizeof(VMSVGA3DSHADER) * (shid + 1)); 7434 7438 AssertReturn(pvNew, VERR_NO_MEMORY); 7435 7439 pContext->paVertexShader = (PVMSVGA3DSHADER)pvNew; … … 7518 7522 7519 7523 if ( cid >= pState->cContexts 7520 || pState->pa Context[cid].id != cid)7524 || pState->papContexts[cid]->id != cid) 7521 7525 { 7522 7526 Log(("vmsvga3dShaderDestroy invalid context id!\n")); 7523 7527 return VERR_INVALID_PARAMETER; 7524 7528 } 7525 pContext = &pState->paContext[cid];7529 pContext = pState->papContexts[cid]; 7526 7530 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7527 7531 … … 7571 7575 7572 7576 if ( cid >= pState->cContexts 7573 || pState->pa Context[cid].id != cid)7577 || pState->papContexts[cid]->id != cid) 7574 7578 { 7575 7579 Log(("vmsvga3dShaderSet invalid context id!\n")); 7576 7580 return VERR_INVALID_PARAMETER; 7577 7581 } 7578 pContext = &pState->paContext[cid];7582 pContext = pState->papContexts[cid]; 7579 7583 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7580 7584 … … 7644 7648 7645 7649 if ( cid >= pState->cContexts 7646 || pState->pa Context[cid].id != cid)7650 || pState->papContexts[cid]->id != cid) 7647 7651 { 7648 7652 Log(("vmsvga3dShaderSetConst invalid context id!\n")); 7649 7653 return VERR_INVALID_PARAMETER; 7650 7654 } 7651 pContext = &pState->paContext[cid];7655 pContext = pState->papContexts[cid]; 7652 7656 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 7653 7657 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h
r54736 r54785 52 52 AssertRCReturn(rc, rc); 53 53 54 pContext = &pState->paContext[i];54 pContext = pState->papContexts[i]; 55 55 AssertReturn(pContext->id == cid, VERR_INTERNAL_ERROR); 56 56 … … 246 246 for (uint32_t i = 0; i < pState->cContexts; i++) 247 247 { 248 PVMSVGA3DCONTEXT pContext = &pState->paContext[i];248 PVMSVGA3DCONTEXT pContext = pState->papContexts[i]; 249 249 uint32_t cid = pContext->id; 250 250 … … 357 357 for (uint32_t i = 0; i < pState->cContexts; i++) 358 358 { 359 PVMSVGA3DCONTEXT pContext = &pState->paContext[i];359 PVMSVGA3DCONTEXT pContext = pState->papContexts[i]; 360 360 uint32_t cid = pContext->id; 361 361 … … 539 539 uint32_t cid = pSurface->idAssociatedContext; 540 540 if ( cid >= pState->cContexts 541 || pState->pa Context[cid].id != cid)541 || pState->papContexts[cid]->id != cid) 542 542 { 543 Log(("vmsvga3dSaveExec invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->pa Context[cid].id));543 Log(("vmsvga3dSaveExec invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->papContexts[cid]->id)); 544 544 AssertFailedReturn(VERR_INVALID_PARAMETER); 545 545 } 546 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];546 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 547 547 548 548 hr = pSurface->bounce.pTexture->GetSurfaceLevel(i, &pDest); … … 655 655 uint32_t cid = pSurface->idAssociatedContext; 656 656 if ( cid >= pState->cContexts 657 || pState->pa Context[cid].id != cid)658 { 659 Log(("vmsvga3dSaveExec: invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->pa Context[cid].id));657 || pState->papContexts[cid]->id != cid) 658 { 659 Log(("vmsvga3dSaveExec: invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->papContexts[cid]->id)); 660 660 AssertFailedReturn(VERR_INVALID_PARAMETER); 661 661 } 662 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];662 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 663 663 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext); 664 664 # endif -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r54783 r54785 343 343 RTSEMEVENT WndRequestSem; 344 344 345 /** The size of papContexts */ 345 346 uint32_t cContexts; 346 347 uint32_t cSurfaces; 347 PVMSVGA3DCONTEXT paContext; 348 /** Contexts indexed by ID. Grown as needed. */ 349 PVMSVGA3DCONTEXT *papContexts; 348 350 PVMSVGA3DSURFACE paSurface; 349 351 … … 366 368 SSMFIELD_ENTRY( VMSVGA3DSTATE, cContexts), 367 369 SSMFIELD_ENTRY( VMSVGA3DSTATE, cSurfaces), 368 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSTATE, pa Context),370 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSTATE, papContexts), 369 371 SSMFIELD_ENTRY_IGN_HCPTR( VMSVGA3DSTATE, paSurface), 370 372 SSMFIELD_ENTRY_IGNORE( VMSVGA3DSTATE, fSupportedSurfaceINTZ), … … 600 602 for (uint32_t i = 0; i < pState->cContexts; i++) 601 603 { 602 if (pState->pa Context[i].id != SVGA3D_INVALID_ID)603 vmsvga3dContextDestroy(pThis, pState->pa Context[i].id);604 if (pState->papContexts[i]->id != SVGA3D_INVALID_ID) 605 vmsvga3dContextDestroy(pThis, pState->papContexts[i]->id); 604 606 } 605 607 return VINF_SUCCESS; … … 1618 1620 for (uint32_t cid = 0; cid < pState->cContexts; cid++) 1619 1621 { 1620 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];1622 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 1621 1623 if (pContext->id == cid) 1622 1624 { … … 1843 1845 cid = pSurfaceSrc->idAssociatedContext; 1844 1846 if ( cid >= pState->cContexts 1845 || pState->pa Context[cid].id != cid)1847 || pState->papContexts[cid]->id != cid) 1846 1848 { 1847 1849 Log(("vmsvga3dSurfaceCopy invalid context id!\n")); 1848 1850 return VERR_INVALID_PARAMETER; 1849 1851 } 1850 pContext = &pState->paContext[cid];1852 pContext = pState->papContexts[cid]; 1851 1853 1852 1854 Log(("vmsvga3dSurfaceCopy: create texture surface id=%x type=%d format=%d -> create texture\n", sidDest, pSurfaceDest->flags, pSurfaceDest->format)); … … 1865 1867 cid = pSurfaceDest->idAssociatedContext; 1866 1868 if ( cid >= pState->cContexts 1867 || pState->pa Context[cid].id != cid)1869 || pState->papContexts[cid]->id != cid) 1868 1870 { 1869 1871 Log(("vmsvga3dSurfaceCopy invalid context id!\n")); 1870 1872 return VERR_INVALID_PARAMETER; 1871 1873 } 1872 pContext = &pState->paContext[cid];1874 pContext = pState->papContexts[cid]; 1873 1875 1874 1876 /* Must flush the other context's 3d pipeline to make sure all drawing is complete for the surface we're about to use. */ … … 2211 2213 2212 2214 if ( cid >= pState->cContexts 2213 || pState->pa Context[cid].id != cid)2215 || pState->papContexts[cid]->id != cid) 2214 2216 { 2215 2217 Log(("vmsvga3dSurfaceStretchBlt invalid context id!\n")); 2216 2218 AssertFailedReturn(VERR_INVALID_PARAMETER); 2217 2219 } 2218 pContext = &pState->paContext[cid];2220 pContext = pState->papContexts[cid]; 2219 2221 2220 2222 if (!pSurfaceSrc->u.pSurface) … … 2458 2460 uint32_t cid = pSurface->idAssociatedContext; 2459 2461 if ( cid >= pState->cContexts 2460 || pState->pa Context[cid].id != cid)2462 || pState->papContexts[cid]->id != cid) 2461 2463 { 2462 Log(("vmsvga3dSurfaceDMA invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->pa Context[cid].id));2464 Log(("vmsvga3dSurfaceDMA invalid context id (%x - %x)!\n", cid, (cid >= pState->cContexts) ? -1 : pState->papContexts[cid]->id)); 2463 2465 AssertFailedReturn(VERR_INVALID_PARAMETER); 2464 2466 } 2465 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];2467 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 2466 2468 2467 2469 /* @todo only sync when something was actually rendered (since the last sync) */ … … 2527 2529 uint32_t cid = pSurface->idAssociatedContext; 2528 2530 if ( cid >= pState->cContexts 2529 || pState->pa Context[cid].id != cid)2531 || pState->papContexts[cid]->id != cid) 2530 2532 { 2531 2533 Log(("vmsvga3dSurfaceDMA invalid context id!\n")); 2532 2534 AssertFailedReturn(VERR_INVALID_PARAMETER); 2533 2535 } 2534 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];2536 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 2535 2537 2536 2538 Log(("vmsvga3dSurfaceDMA: sync texture from bounce buffer\n")); … … 2694 2696 2695 2697 if ( cid >= pState->cContexts 2696 || pState->pa Context[cid].id != cid)2698 || pState->papContexts[cid]->id != cid) 2697 2699 { 2698 2700 Log(("vmsvga3dGenerateMipmaps invalid context id!\n")); 2699 2701 return VERR_INVALID_PARAMETER; 2700 2702 } 2701 pContext = &pState->paContext[cid];2703 pContext = pState->papContexts[cid]; 2702 2704 2703 2705 if (pSurface->id == 0x5e) … … 2748 2750 2749 2751 if ( cid >= pState->cContexts 2750 || pState->pa Context[cid].id != cid)2752 || pState->papContexts[cid]->id != cid) 2751 2753 { 2752 2754 Log(("vmsvga3dGenerateMipmaps invalid context id!\n")); 2753 2755 return VERR_INVALID_PARAMETER; 2754 2756 } 2755 pContext = &pState->paContext[cid];2757 pContext = pState->papContexts[cid]; 2756 2758 2757 2759 /* Unknown surface type; turn it into a texture. */ … … 2806 2808 2807 2809 if ( cid >= pState->cContexts 2808 || pState->pa Context[cid].id != cid)2810 || pState->papContexts[cid]->id != cid) 2809 2811 { 2810 2812 Log(("vmsvga3dCommandPresent invalid context id!\n")); 2811 2813 return VERR_INVALID_PARAMETER; 2812 2814 } 2813 pContext = &pState->paContext[cid];2815 pContext = pState->papContexts[cid]; 2814 2816 2815 2817 hr = pContext->pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer); … … 2924 2926 if (cid >= pState->cContexts) 2925 2927 { 2926 void *pvNew = RTMemRealloc(pState->paContext, sizeof(VMSVGA3DCONTEXT) * (cid + 1)); 2928 /* Grow the array. */ 2929 uint32_t cNew = RT_ALIGN(cid + 15, 16); 2930 void *pvNew = RTMemRealloc(pState->papContexts, sizeof(pState->papContexts[0]) * cNew); 2927 2931 AssertReturn(pvNew, VERR_NO_MEMORY); 2928 pState->paContext = (PVMSVGA3DCONTEXT)pvNew; 2929 memset(&pState->paContext[pState->cContexts], 0, sizeof(VMSVGA3DCONTEXT) * (cid + 1 - pState->cContexts)); 2930 for (uint32_t i = pState->cContexts; i < cid + 1; i++) 2931 pState->paContext[i].id = SVGA3D_INVALID_ID; 2932 2933 pState->cContexts = cid + 1; 2932 pState->papContexts = (PVMSVGA3DCONTEXT *)pvNew; 2933 while (pState->cContexts < cNew) 2934 { 2935 pContext = (PVMSVGA3DCONTEXT)RTMemAllocZ(sizeof(*pContext)); 2936 AssertReturn(pContext, VERR_NO_MEMORY); 2937 pContext->id = SVGA3D_INVALID_ID; 2938 pState->papContexts[pState->cContexts++] = pContext; 2939 } 2934 2940 } 2935 2941 /* If one already exists with this id, then destroy it now. */ 2936 if (pState->pa Context[cid].id != SVGA3D_INVALID_ID)2942 if (pState->papContexts[cid]->id != SVGA3D_INVALID_ID) 2937 2943 vmsvga3dContextDestroy(pThis, cid); 2938 2944 2939 pContext = &pState->paContext[cid];2945 pContext = pState->papContexts[cid]; 2940 2946 memset(pContext, 0, sizeof(*pContext)); 2941 2947 pContext->id = cid; … … 3034 3040 3035 3041 if ( cid < pState->cContexts 3036 && pState->pa Context[cid].id == cid)3037 { 3038 PVMSVGA3DCONTEXT pContext = &pState->paContext[cid];3042 && pState->papContexts[cid]->id == cid) 3043 { 3044 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid]; 3039 3045 3040 3046 Log(("vmsvga3dContextDestroy id %x\n", cid)); … … 3176 3182 for (uint32_t i = 0; i < pState->cContexts; i++) 3177 3183 { 3178 PVMSVGA3DCONTEXT pContext = &pState->paContext[i];3184 PVMSVGA3DCONTEXT pContext = pState->papContexts[i]; 3179 3185 uint32_t cid = pContext->id; 3180 3186 … … 3428 3434 3429 3435 if ( cid >= pState->cContexts 3430 || pState->pa Context[cid].id != cid)3436 || pState->papContexts[cid]->id != cid) 3431 3437 { 3432 3438 Log(("vmsvga3dSetTransform invalid context id!\n")); 3433 3439 return VERR_INVALID_PARAMETER; 3434 3440 } 3435 pContext = &pState->paContext[cid];3441 pContext = pState->papContexts[cid]; 3436 3442 3437 3443 switch (type) … … 3510 3516 3511 3517 if ( cid >= pState->cContexts 3512 || pState->pa Context[cid].id != cid)3518 || pState->papContexts[cid]->id != cid) 3513 3519 { 3514 3520 Log(("vmsvga3dSetZRange invalid context id!\n")); 3515 3521 return VERR_INVALID_PARAMETER; 3516 3522 } 3517 pContext = &pState->paContext[cid];3523 pContext = pState->papContexts[cid]; 3518 3524 pContext->state.zRange = zRange; 3519 3525 pContext->state.u32UpdateFlags |= VMSVGA3D_UPDATE_ZRANGE; … … 3586 3592 3587 3593 if ( cid >= pState->cContexts 3588 || pState->pa Context[cid].id != cid)3594 || pState->papContexts[cid]->id != cid) 3589 3595 { 3590 3596 Log(("vmsvga3dSetRenderState invalid context id!\n")); 3591 3597 return VERR_INVALID_PARAMETER; 3592 3598 } 3593 pContext = &pState->paContext[cid];3599 pContext = pState->papContexts[cid]; 3594 3600 3595 3601 for (unsigned i = 0; i < cRenderStates; i++) … … 4262 4268 4263 4269 if ( cid >= pState->cContexts 4264 || pState->pa Context[cid].id != cid)4270 || pState->papContexts[cid]->id != cid) 4265 4271 { 4266 4272 Log(("vmsvga3dSetRenderTarget invalid context id!\n")); 4267 4273 return VERR_INVALID_PARAMETER; 4268 4274 } 4269 pContext = &pState->paContext[cid];4275 pContext = pState->papContexts[cid]; 4270 4276 4271 4277 /* Save for vm state save/restore. */ … … 4688 4694 4689 4695 if ( cid >= pState->cContexts 4690 || pState->pa Context[cid].id != cid)4696 || pState->papContexts[cid]->id != cid) 4691 4697 { 4692 4698 Log(("vmsvga3dSetTextureState invalid context id!\n")); 4693 4699 return VERR_INVALID_PARAMETER; 4694 4700 } 4695 pContext = &pState->paContext[cid];4701 pContext = pState->papContexts[cid]; 4696 4702 4697 4703 for (unsigned i = 0; i < cTextureStates; i++) … … 4950 4956 4951 4957 if ( cid >= pState->cContexts 4952 || pState->pa Context[cid].id != cid)4958 || pState->papContexts[cid]->id != cid) 4953 4959 { 4954 4960 Log(("vmsvga3dSetMaterial invalid context id!\n")); 4955 4961 return VERR_INVALID_PARAMETER; 4956 4962 } 4957 pContext = &pState->paContext[cid];4963 pContext = pState->papContexts[cid]; 4958 4964 4959 4965 AssertReturn(face < SVGA3D_FACE_MAX, VERR_INVALID_PARAMETER); … … 5005 5011 5006 5012 if ( cid >= pState->cContexts 5007 || pState->pa Context[cid].id != cid)5013 || pState->papContexts[cid]->id != cid) 5008 5014 { 5009 5015 Log(("vmsvga3dSetLightData invalid context id!\n")); 5010 5016 return VERR_INVALID_PARAMETER; 5011 5017 } 5012 pContext = &pState->paContext[cid];5018 pContext = pState->papContexts[cid]; 5013 5019 5014 5020 switch (pData->type) … … 5083 5089 5084 5090 if ( cid >= pState->cContexts 5085 || pState->pa Context[cid].id != cid)5091 || pState->papContexts[cid]->id != cid) 5086 5092 { 5087 5093 Log(("vmsvga3dSetLightEnabled invalid context id!\n")); 5088 5094 return VERR_INVALID_PARAMETER; 5089 5095 } 5090 pContext = &pState->paContext[cid];5096 pContext = pState->papContexts[cid]; 5091 5097 5092 5098 /* Store for vm state save/restore */ … … 5113 5119 5114 5120 if ( cid >= pState->cContexts 5115 || pState->pa Context[cid].id != cid)5121 || pState->papContexts[cid]->id != cid) 5116 5122 { 5117 5123 Log(("vmsvga3dSetViewPort invalid context id!\n")); … … 5119 5125 } 5120 5126 /* Save for vm state save/restore. */ 5121 pContext = &pState->paContext[cid];5127 pContext = pState->papContexts[cid]; 5122 5128 pContext->state.RectViewPort = *pRect; 5123 5129 pContext->state.u32UpdateFlags |= VMSVGA3D_UPDATE_VIEWPORT; … … 5149 5155 5150 5156 if ( cid >= pState->cContexts 5151 || pState->pa Context[cid].id != cid)5157 || pState->papContexts[cid]->id != cid) 5152 5158 { 5153 5159 Log(("vmsvga3dSetClipPlane invalid context id!\n")); 5154 5160 return VERR_INVALID_PARAMETER; 5155 5161 } 5156 pContext = &pState->paContext[cid];5162 pContext = pState->papContexts[cid]; 5157 5163 5158 5164 /* Store for vm state save/restore. */ … … 5177 5183 5178 5184 if ( cid >= pState->cContexts 5179 || pState->pa Context[cid].id != cid)5185 || pState->papContexts[cid]->id != cid) 5180 5186 { 5181 5187 Log(("vmsvga3dCommandClear invalid context id!\n")); 5182 5188 return VERR_INVALID_PARAMETER; 5183 5189 } 5184 pContext = &pState->paContext[cid];5190 pContext = pState->papContexts[cid]; 5185 5191 5186 5192 if (clearFlag & SVGA3D_CLEAR_COLOR) … … 5389 5395 5390 5396 if ( cid >= pState->cContexts 5391 || pState->pa Context[cid].id != cid)5397 || pState->papContexts[cid]->id != cid) 5392 5398 { 5393 5399 Log(("vmsvga3dDrawPrimitives invalid context id!\n")); … … 5395 5401 } 5396 5402 5397 pContext = &pState->paContext[cid];5403 pContext = pState->papContexts[cid]; 5398 5404 5399 5405 /* Begin a scene before rendering anything. */ … … 5677 5683 5678 5684 if ( cid >= pState->cContexts 5679 || pState->pa Context[cid].id != cid)5685 || pState->papContexts[cid]->id != cid) 5680 5686 { 5681 5687 Log(("vmsvga3dSetScissorRect invalid context id!\n")); 5682 5688 return VERR_INVALID_PARAMETER; 5683 5689 } 5684 pContext = &pState->paContext[cid];5690 pContext = pState->papContexts[cid]; 5685 5691 5686 5692 /* Store for vm state save/restore. */ … … 5712 5718 5713 5719 if ( cid >= pState->cContexts 5714 || pState->pa Context[cid].id != cid)5720 || pState->papContexts[cid]->id != cid) 5715 5721 { 5716 5722 Log(("vmsvga3dShaderDefine invalid context id!\n")); 5717 5723 return VERR_INVALID_PARAMETER; 5718 5724 } 5719 pContext = &pState->paContext[cid];5725 pContext = pState->papContexts[cid]; 5720 5726 5721 5727 AssertReturn(shid < SVGA3D_MAX_SHADER_IDS, VERR_INVALID_PARAMETER); … … 5811 5817 5812 5818 if ( cid >= pState->cContexts 5813 || pState->pa Context[cid].id != cid)5819 || pState->papContexts[cid]->id != cid) 5814 5820 { 5815 5821 Log(("vmsvga3dShaderDestroy invalid context id!\n")); 5816 5822 return VERR_INVALID_PARAMETER; 5817 5823 } 5818 pContext = &pState->paContext[cid];5824 pContext = pState->papContexts[cid]; 5819 5825 5820 5826 if (type == SVGA3D_SHADERTYPE_VS) … … 5862 5868 5863 5869 if ( cid >= pState->cContexts 5864 || pState->pa Context[cid].id != cid)5870 || pState->papContexts[cid]->id != cid) 5865 5871 { 5866 5872 Log(("vmsvga3dShaderSet invalid context id!\n")); 5867 5873 return VERR_INVALID_PARAMETER; 5868 5874 } 5869 pContext = &pState->paContext[cid];5875 pContext = pState->papContexts[cid]; 5870 5876 5871 5877 if (type == SVGA3D_SHADERTYPE_VS) … … 5934 5940 5935 5941 if ( cid >= pState->cContexts 5936 || pState->pa Context[cid].id != cid)5942 || pState->papContexts[cid]->id != cid) 5937 5943 { 5938 5944 Log(("vmsvga3dShaderSetConst invalid context id!\n")); 5939 5945 return VERR_INVALID_PARAMETER; 5940 5946 } 5941 pContext = &pState->paContext[cid];5947 pContext = pState->papContexts[cid]; 5942 5948 5943 5949 for (uint32_t i = 0; i < cRegisters; i++)
Note:
See TracChangeset
for help on using the changeset viewer.