Changeset 104811 in vbox for trunk/src/VBox/Devices
- Timestamp:
- May 29, 2024 5:29:10 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-dx11.cpp
r104805 r104811 5 5 6 6 /* 7 * Copyright (C) 2020-202 3Oracle and/or its affiliates.7 * Copyright (C) 2020-2024 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 38 38 #include <iprt/asm-mem.h> 39 39 #include <iprt/assert.h> 40 #include <iprt/avl.h>41 40 #include <iprt/errcore.h> 42 41 #include <iprt/mem.h> … … 66 65 #endif 67 66 68 /* One ID3D11Device object is used for all VMSVGA contexts. */ 69 /** @todo This should be the only option because VGPU freely uses surfaces from different VMSVGA contexts 70 * and synchronization of access to shared surfaces kills performance. 67 /* One ID3D11Device object is used for all VMSVGA guest contexts because the VGPU design makes resources 68 * independent from rendering contexts. I.e. multiple guest contexts freely access a surface. 69 * 70 * The initial implementation of this backend has used separate ID3D11Devices for each VMSVGA context 71 * and created shared resources to allow one ID3D11Device to access a resource which was rendered to by 72 * another ID3D11Device. This synchronization of access to shared resources kills performance actually. 71 73 */ 72 #define DX_FORCE_SINGLE_DEVICE 74 73 75 /* A single staging ID3D11Buffer is used for uploading data to other buffers. */ 74 76 #define DX_COMMON_STAGING_BUFFER … … 80 82 # define D3D_RELEASE(a_Ptr) do { if ((a_Ptr)) (a_Ptr)->Release(); (a_Ptr) = NULL; } while (0) 81 83 #endif 82 83 /** Fake ID for the backend DX context. The context creates all shared textures. */84 #define DX_CID_BACKEND UINT32_C(0xfffffffe)85 84 86 85 #define D3D_RELEASE_ARRAY(a_Count, a_papArray) do { \ … … 217 216 } staging; 218 217 219 /* Screen targets are created as shared surfaces. */220 HANDLE SharedHandle; /* The shared handle of this structure. */221 222 /* DX context which last rendered to the texture.223 * This is only for render targets and screen targets, which can be shared between contexts.224 * The backend context (cid == DX_CID_BACKEND) can also be a drawing context.225 */226 uint32_t cidDrawing;227 228 /** AVL tree containing DXSHAREDTEXTURE structures. */229 AVLU32TREE SharedTextureTree;230 231 218 /* Render target views, depth stencil views and shader resource views created for this texture or buffer. */ 232 219 RTLISTANCHOR listView; /* DXVIEW */ 233 220 234 221 } VMSVGA3DBACKENDSURFACE; 235 236 /* "The only resources that can be shared are 2D non-mipmapped textures." */237 typedef struct DXSHAREDTEXTURE238 {239 AVLU32NODECORE Core; /* Key is context id which opened this texture. */240 ID3D11Texture2D *pTexture; /* The opened shared texture. */241 uint32_t sid; /* Surface id. */242 } DXSHAREDTEXTURE;243 222 244 223 … … 388 367 PFN_D3D_DISASSEMBLE pfnD3DDisassemble; 389 368 390 DXDEVICE dxDevice; /* Device for the VMSVGA3D context independent operation. */369 DXDEVICE dxDevice; 391 370 UINT VendorId; 392 371 UINT DeviceId; … … 395 374 396 375 DXBOUNDRESOURCES resources; /* What is currently applied to the pipeline. */ 397 398 bool fSingleDevice; /* Whether to use one DX device for all guest contexts. */399 400 /** @todo Here a set of functions which do different job in single and multiple device modes. */401 376 } VMSVGA3DBACKEND; 402 377 … … 1196 1171 int rc = VINF_SUCCESS; 1197 1172 1198 if (pBackend-> fSingleDevice && pBackend->dxDevice.pDevice)1173 if (pBackend->dxDevice.pDevice) 1199 1174 { 1200 1175 pDXDevice->pDevice = pBackend->dxDevice.pDevice; … … 1482 1457 1483 1458 1484 DECLINLINE(bool) dxIsSurfaceShareable(PVMSVGA3DSURFACE pSurface) 1485 { 1486 /* It is not expected that volume textures will be shared between contexts. */ 1487 if (pSurface->f.surfaceFlags & SVGA3D_SURFACE_VOLUME) 1488 return false; 1489 1490 return (pSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) 1491 || (pSurface->f.surfaceFlags & SVGA3D_SURFACE_BIND_RENDER_TARGET); 1492 } 1493 1494 1459 /// @todo Rename, parameters 1495 1460 static DXDEVICE *dxDeviceFromCid(uint32_t cid, PVMSVGA3DSTATE pState) 1496 1461 { 1497 if (cid != DX_CID_BACKEND) 1498 { 1499 if (pState->pBackend->fSingleDevice) 1500 return &pState->pBackend->dxDevice; 1501 1502 VMSVGA3DDXCONTEXT *pDXContext; 1503 int rc = vmsvga3dDXContextFromCid(pState, cid, &pDXContext); 1504 if (RT_SUCCESS(rc)) 1505 return &pDXContext->pBackendDXContext->dxDevice; 1506 } 1507 else 1508 return &pState->pBackend->dxDevice; 1509 1510 AssertFailed(); 1511 return NULL; 1512 } 1513 1514 1462 RT_NOREF(cid); 1463 return &pState->pBackend->dxDevice; 1464 } 1465 1466 1467 /// @todo Rename, parameters 1515 1468 static DXDEVICE *dxDeviceFromContext(PVMSVGA3DSTATE p3dState, VMSVGA3DDXCONTEXT *pDXContext) 1516 1469 { 1517 DXDEVICE *pDXDevice; 1518 if (pDXContext && !p3dState->pBackend->fSingleDevice) 1519 pDXDevice = &pDXContext->pBackendDXContext->dxDevice; 1520 else 1521 pDXDevice = &p3dState->pBackend->dxDevice; 1522 1470 RT_NOREF(pDXContext); 1471 DXDEVICE *pDXDevice = &p3dState->pBackend->dxDevice; 1523 1472 #ifdef DEBUG 1524 1473 HRESULT hr = pDXDevice->pDevice->GetDeviceRemovedReason(); … … 1553 1502 1554 1503 1555 static int dxContextWait(uint32_t cidDrawing, PVMSVGA3DSTATE pState) 1556 { 1557 if (pState->pBackend->fSingleDevice) 1558 return VINF_SUCCESS; 1559 1560 /* Flush cidDrawing context and issue a query. */ 1561 DXDEVICE *pDXDevice = dxDeviceFromCid(cidDrawing, pState); 1562 if (pDXDevice) 1563 return dxDeviceFlush(pDXDevice); 1564 /* cidDrawing does not exist anymore. */ 1565 return VINF_SUCCESS; 1566 } 1567 1568 1569 static int dxSurfaceWait(PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface, uint32_t cidRequesting) 1570 { 1571 if (pState->pBackend->fSingleDevice) 1572 return VINF_SUCCESS; 1573 1574 VMSVGA3DBACKENDSURFACE *pBackendSurface = pSurface->pBackendSurface; 1575 if (!pBackendSurface) 1576 AssertFailedReturn(VERR_INVALID_STATE); 1577 1578 int rc = VINF_SUCCESS; 1579 if (pBackendSurface->cidDrawing != SVGA_ID_INVALID) 1580 { 1581 if (pBackendSurface->cidDrawing != cidRequesting) 1582 { 1583 LogFunc(("sid = %u, assoc cid = %u, drawing cid = %u, req cid = %u\n", 1584 pSurface->id, pSurface->idAssociatedContext, pBackendSurface->cidDrawing, cidRequesting)); 1585 Assert(dxIsSurfaceShareable(pSurface)); 1586 rc = dxContextWait(pBackendSurface->cidDrawing, pState); 1587 pBackendSurface->cidDrawing = SVGA_ID_INVALID; 1588 } 1589 } 1590 return rc; 1591 } 1592 1593 1504 /// @todo Parameters 1594 1505 static ID3D11Resource *dxResource(PVMSVGA3DSTATE pState, PVMSVGA3DSURFACE pSurface, VMSVGA3DDXCONTEXT *pDXContext) 1595 1506 { 1507 RT_NOREF(pState, pDXContext); 1596 1508 VMSVGA3DBACKENDSURFACE *pBackendSurface = pSurface->pBackendSurface; 1597 1509 if (!pBackendSurface) 1598 1510 AssertFailedReturn(NULL); 1599 1511 1600 ID3D11Resource *pResource; 1601 1602 uint32_t const cidRequesting = pDXContext ? pDXContext->cid : DX_CID_BACKEND; 1603 if (cidRequesting == pSurface->idAssociatedContext || pState->pBackend->fSingleDevice) 1604 pResource = pBackendSurface->u.pResource; 1605 else 1606 { 1607 /* 1608 * Context, which as not created the surface, is requesting. 1609 */ 1610 AssertReturn(pDXContext, NULL); 1611 1612 Assert(dxIsSurfaceShareable(pSurface)); 1613 Assert(pSurface->idAssociatedContext == DX_CID_BACKEND); 1614 1615 DXSHAREDTEXTURE *pSharedTexture = (DXSHAREDTEXTURE *)RTAvlU32Get(&pBackendSurface->SharedTextureTree, pDXContext->cid); 1616 if (!pSharedTexture) 1617 { 1618 DXDEVICE *pDevice = dxDeviceFromContext(pState, pDXContext); 1619 AssertReturn(pDevice->pDevice, NULL); 1620 1621 AssertReturn(pBackendSurface->SharedHandle, NULL); 1622 1623 /* This context has not yet opened the texture. */ 1624 pSharedTexture = (DXSHAREDTEXTURE *)RTMemAllocZ(sizeof(DXSHAREDTEXTURE)); 1625 AssertReturn(pSharedTexture, NULL); 1626 1627 pSharedTexture->Core.Key = pDXContext->cid; 1628 bool const fSuccess = RTAvlU32Insert(&pBackendSurface->SharedTextureTree, &pSharedTexture->Core); 1629 AssertReturn(fSuccess, NULL); 1630 1631 HRESULT hr = pDevice->pDevice->OpenSharedResource(pBackendSurface->SharedHandle, __uuidof(ID3D11Texture2D), (void**)&pSharedTexture->pTexture); 1632 Assert(SUCCEEDED(hr)); 1633 if (SUCCEEDED(hr)) 1634 pSharedTexture->sid = pSurface->id; 1635 else 1636 { 1637 RTAvlU32Remove(&pBackendSurface->SharedTextureTree, pDXContext->cid); 1638 RTMemFree(pSharedTexture); 1639 return NULL; 1640 } 1641 } 1642 1643 pResource = pSharedTexture->pTexture; 1644 } 1645 1646 /* Wait for drawing to finish. */ 1647 dxSurfaceWait(pState, pSurface, cidRequesting); 1648 1649 return pResource; 1512 return pBackendSurface->u.pResource; 1650 1513 } 1651 1514 … … 1657 1520 SVGACOTableDXRTViewEntry const *pRTViewEntry = &pDXContext->cot.paRTView[renderTargetViewId]; 1658 1521 return pRTViewEntry->sid; 1659 }1660 1661 1662 static int dxTrackRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)1663 {1664 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;1665 AssertReturn(pState, VERR_INVALID_STATE);1666 1667 for (unsigned long i = 0; i < RT_ELEMENTS(pDXContext->svgaDXContext.renderState.renderTargetViewIds); ++i)1668 {1669 uint32_t const renderTargetViewId = pDXContext->svgaDXContext.renderState.renderTargetViewIds[i];1670 if (renderTargetViewId == SVGA_ID_INVALID)1671 continue;1672 1673 uint32_t const sid = dxGetRenderTargetViewSid(pDXContext, renderTargetViewId);1674 LogFunc(("[%u] sid = %u, drawing cid = %u\n", i, sid, pDXContext->cid));1675 1676 PVMSVGA3DSURFACE pSurface;1677 int rc = vmsvga3dSurfaceFromSid(pState, sid, &pSurface);1678 if (RT_SUCCESS(rc))1679 {1680 AssertContinue(pSurface->pBackendSurface);1681 pSurface->pBackendSurface->cidDrawing = pDXContext->cid;1682 }1683 }1684 return VINF_SUCCESS;1685 1522 } 1686 1523 … … 2487 2324 PVMSVGA3DBACKENDSURFACE pBackendSurface = (PVMSVGA3DBACKENDSURFACE)RTMemAllocZ(sizeof(VMSVGA3DBACKENDSURFACE)); 2488 2325 AssertPtrReturn(pBackendSurface, VERR_NO_MEMORY); 2489 pBackendSurface->cidDrawing = SVGA_ID_INVALID;2490 2326 RTListInit(&pBackendSurface->listView); 2491 2327 *ppBackendSurface = pBackendSurface; 2492 2328 return VINF_SUCCESS; 2493 }2494 2495 2496 static HRESULT dxInitSharedHandle(PVMSVGA3DBACKEND pBackend, PVMSVGA3DBACKENDSURFACE pBackendSurface)2497 {2498 if (pBackend->fSingleDevice)2499 return S_OK;2500 2501 /* Get the shared handle. */2502 IDXGIResource *pDxgiResource = NULL;2503 HRESULT hr = pBackendSurface->u.pResource->QueryInterface(__uuidof(IDXGIResource), (void**)&pDxgiResource);2504 Assert(SUCCEEDED(hr));2505 if (SUCCEEDED(hr))2506 {2507 hr = pDxgiResource->GetSharedHandle(&pBackendSurface->SharedHandle);2508 Assert(SUCCEEDED(hr));2509 D3D_RELEASE(pDxgiResource);2510 }2511 2512 return hr;2513 2329 } 2514 2330 … … 2537 2353 2538 2354 2355 /// @todo Parameters 2539 2356 static DXDEVICE *dxSurfaceDevice(PVMSVGA3DSTATE p3dState, PVMSVGA3DSURFACE pSurface, PVMSVGA3DDXCONTEXT pDXContext, UINT *pMiscFlags) 2540 2357 { 2541 if (p3dState->pBackend->fSingleDevice) 2542 { 2543 *pMiscFlags = 0; 2544 return &p3dState->pBackend->dxDevice; 2545 } 2546 2547 if (!pDXContext || dxIsSurfaceShareable(pSurface)) 2548 { 2549 *pMiscFlags = D3D11_RESOURCE_MISC_SHARED; 2550 return &p3dState->pBackend->dxDevice; 2551 } 2552 2358 RT_NOREF(pSurface, pDXContext); 2553 2359 *pMiscFlags = 0; 2554 return &p DXContext->pBackendDXContext->dxDevice;2360 return &p3dState->pBackend->dxDevice; 2555 2361 } 2556 2362 … … 2806 2612 2807 2613 if (SUCCEEDED(hr)) 2808 hr = dxInitSharedHandle(pBackend, pBackendSurface);2809 2810 if (SUCCEEDED(hr))2811 2614 { 2812 2615 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_CUBE; … … 2861 2664 Assert(SUCCEEDED(hr)); 2862 2665 } 2863 2864 if (SUCCEEDED(hr))2865 hr = dxInitSharedHandle(pBackend, pBackendSurface);2866 2666 2867 2667 if (SUCCEEDED(hr)) … … 2921 2721 Assert(SUCCEEDED(hr)); 2922 2722 } 2923 2924 if (SUCCEEDED(hr))2925 hr = dxInitSharedHandle(pBackend, pBackendSurface);2926 2723 2927 2724 if (SUCCEEDED(hr)) … … 2986 2783 2987 2784 if (SUCCEEDED(hr)) 2988 hr = dxInitSharedHandle(pBackend, pBackendSurface);2989 2990 if (SUCCEEDED(hr))2991 2785 { 2992 2786 pBackendSurface->enmResType = VMSVGA3D_RESTYPE_TEXTURE_2D; … … 3017 2811 pBackendSurface->enmDxgiFormat = dxgiFormat; 3018 2812 pSurface->pBackendSurface = pBackendSurface; 3019 if (p3dState->pBackend->fSingleDevice || RT_BOOL(MiscFlags & D3D11_RESOURCE_MISC_SHARED))3020 pSurface->idAssociatedContext = DX_CID_BACKEND;3021 else3022 pSurface->idAssociatedContext = pDXContext->cid;3023 2813 return VINF_SUCCESS; 3024 2814 } … … 3110 2900 pBackendSurface->enmDxgiFormat = DXGI_FORMAT_UNKNOWN; 3111 2901 pSurface->pBackendSurface = pBackendSurface; 3112 pSurface->idAssociatedContext = pDXContext->cid;3113 2902 return VINF_SUCCESS; 3114 2903 } … … 3183 2972 pBackendSurface->enmDxgiFormat = DXGI_FORMAT_UNKNOWN; 3184 2973 pSurface->pBackendSurface = pBackendSurface; 3185 pSurface->idAssociatedContext = pDXContext->cid;3186 2974 return VINF_SUCCESS; 3187 2975 } … … 3255 3043 pBackendSurface->enmDxgiFormat = DXGI_FORMAT_UNKNOWN; 3256 3044 pSurface->pBackendSurface = pBackendSurface; 3257 pSurface->idAssociatedContext = pDXContext->cid;3258 3045 return VINF_SUCCESS; 3259 3046 } … … 3395 3182 */ 3396 3183 pSurface->pBackendSurface = pBackendSurface; 3397 pSurface->idAssociatedContext = pDXContext->cid;3398 3184 return VINF_SUCCESS; 3399 3185 } … … 3511 3297 Log6Func(("Load D3DDisassemble: %Rrc\n", rc2)); 3512 3298 } 3513 3514 #if !defined(RT_OS_WINDOWS) || defined(DX_FORCE_SINGLE_DEVICE)3515 pBackend->fSingleDevice = true;3516 #endif3517 3518 LogRelMax(1, ("VMSVGA: Single DX device mode: %s\n", pBackend->fSingleDevice ? "enabled" : "disabled"));3519 3299 3520 3300 vmsvga3dDXInitContextMobData(&pBackend->svgaDXContext); … … 3872 3652 || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D) 3873 3653 { 3874 dxSurfaceWait(pState, pSurface, pSurface->idAssociatedContext);3875 3876 3654 ID3D11Resource *pMappedResource; 3877 3655 if (enmMapType == VMSVGA3D_SURFACE_MAP_READ) … … 4090 3868 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 4091 3869 pSrcResource, SrcSubresource, pSrcBox); 4092 4093 pBackendSurface->cidDrawing = pSurface->idAssociatedContext;4094 3870 } 4095 3871 } … … 4164 3940 pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 4165 3941 pSrcResource, SrcSubresource, &SrcBox); 4166 4167 pBackendSurface->cidDrawing = pSurface->idAssociatedContext;4168 3942 } 4169 3943 #endif … … 4263 4037 vmsvgaR3Clip3dRect(&boundRect, &clipRect); 4264 4038 ASSERT_GUEST_RETURN(clipRect.w && clipRect.h, VERR_INVALID_PARAMETER); 4265 4266 /* Wait for the surface to finish drawing. */4267 dxSurfaceWait(pState, pSurface, DX_CID_BACKEND);4268 4039 4269 4040 /* Copy the screen texture to the shared surface. */ … … 4880 4651 AssertRCReturn(rc, rc); 4881 4652 4882 LogFunc(("src%s cid %d -> dst%s cid %d\n", 4883 pSrcSurface->pBackendSurface ? "" : " sysmem", 4884 pSrcSurface ? pSrcSurface->idAssociatedContext : SVGA_ID_INVALID, 4885 pDstSurface->pBackendSurface ? "" : " sysmem", 4886 pDstSurface ? pDstSurface->idAssociatedContext : SVGA_ID_INVALID)); 4653 LogFunc(("src%s sid = %u -> dst%s sid = %u\n", 4654 pSrcSurface->pBackendSurface ? "" : " sysmem", pSrcSurface->id, 4655 pDstSurface->pBackendSurface ? "" : " sysmem", pDstSurface->id)); 4887 4656 4888 4657 //DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext); … … 4893 4662 if (pDstSurface->pBackendSurface == NULL) 4894 4663 { 4895 /* Create the target if it can be used as a device context shared resource (render or screen target). */ 4896 if (pBackend->fSingleDevice || dxIsSurfaceShareable(pDstSurface)) 4897 { 4898 rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, NULL, pDstSurface); 4899 AssertRCReturn(rc, rc); 4900 } 4664 rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, NULL, pDstSurface); 4665 AssertRCReturn(rc, rc); 4901 4666 } 4902 4667 … … 4904 4669 { 4905 4670 /* Surface -> Surface. */ 4906 /* Expect both of them to be shared surfaces created by the backend context. */4907 Assert(pSrcSurface->idAssociatedContext == DX_CID_BACKEND && pDstSurface->idAssociatedContext == DX_CID_BACKEND);4908 4909 /* Wait for the source surface to finish drawing. */4910 dxSurfaceWait(pState, pSrcSurface, DX_CID_BACKEND);4911 4912 4671 DXDEVICE *pDXDevice = &pBackend->dxDevice; 4913 4672 … … 4947 4706 pDXDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ, 4948 4707 pSrcResource, SrcSubresource, &SrcBox); 4949 4950 pDstSurface->pBackendSurface->cidDrawing = DX_CID_BACKEND;4951 4708 } 4952 4709 else … … 5400 5157 5401 5158 RTMemFree(pBackendSurface); 5402 5403 /* No context has created the surface, because the surface does not exist anymore. */5404 pSurface->idAssociatedContext = SVGA_ID_INVALID;5405 5159 } 5406 5160 … … 5760 5514 RTMemFreeZ(pBackendDXContext->paVideoProcessorOutputView, sizeof(pBackendDXContext->paVideoProcessorOutputView[0]) * pBackendDXContext->cVideoProcessorOutputView); 5761 5515 5762 /* Destroy backend surfaces which belong to this context. */5763 /** @todo The context should have a list of surfaces (and also shared resources). */5764 /** @todo This should not be needed in fSingleDevice mode. */5765 for (uint32_t sid = 0; sid < pThisCC->svga.p3dState->cSurfaces; ++sid)5766 {5767 PVMSVGA3DSURFACE const pSurface = pThisCC->svga.p3dState->papSurfaces[sid];5768 if ( pSurface5769 && pSurface->id == sid)5770 {5771 if (pSurface->idAssociatedContext == pDXContext->cid)5772 {5773 if (pSurface->pBackendSurface)5774 vmsvga3dBackSurfaceDestroy(pThisCC, true, pSurface);5775 }5776 else if (pSurface->idAssociatedContext == DX_CID_BACKEND)5777 {5778 /* May have shared resources in this context. */5779 if (pSurface->pBackendSurface)5780 {5781 DXSHAREDTEXTURE *pSharedTexture = (DXSHAREDTEXTURE *)RTAvlU32Get(&pSurface->pBackendSurface->SharedTextureTree, pDXContext->cid);5782 if (pSharedTexture)5783 {5784 Assert(pSharedTexture->sid == sid);5785 RTAvlU32Remove(&pSurface->pBackendSurface->SharedTextureTree, pDXContext->cid);5786 D3D_RELEASE(pSharedTexture->pTexture);5787 RTMemFreeZ(pSharedTexture, sizeof(*pSharedTexture));5788 }5789 }5790 }5791 }5792 }5793 5794 5516 dxDeviceDestroy(pBackend, &pBackendDXContext->dxDevice); 5795 5517 … … 5811 5533 static DECLCALLBACK(int) vmsvga3dBackDXSwitchContext(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext) 5812 5534 { 5813 PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;5814 if (!pBackend->fSingleDevice)5815 return VINF_NOT_IMPLEMENTED; /* Not required. */5816 5817 5535 /* The new context state will be applied by the generic DX code. */ 5818 RT_NOREF(p DXContext);5536 RT_NOREF(pThisCC, pDXContext); 5819 5537 return VINF_SUCCESS; 5820 5538 } … … 7378 7096 } 7379 7097 7380 /* Note which surfaces are being drawn. */7381 dxTrackRenderTargets(pThisCC, pDXContext);7382 7383 7098 #ifdef DX_FLUSH_AFTER_DRAW 7384 7099 dxDeviceFlush(pDevice); … … 7637 7352 } 7638 7353 7639 /* Note which surfaces are being drawn. */7640 dxTrackRenderTargets(pThisCC, pDXContext);7641 7642 7354 #ifdef DX_FLUSH_AFTER_DRAW 7643 7355 dxDeviceFlush(pDevice); … … 7668 7380 pDevice->pImmediateContext->DrawInstanced(vertexCountPerInstance, instanceCount, startVertexLocation, startInstanceLocation); 7669 7381 7670 /* Note which surfaces are being drawn. */7671 dxTrackRenderTargets(pThisCC, pDXContext);7672 7673 7382 #ifdef DX_FLUSH_AFTER_DRAW 7674 7383 dxDeviceFlush(pDevice); … … 7699 7408 pDevice->pImmediateContext->DrawIndexedInstanced(indexCountPerInstance, instanceCount, startIndexLocation, baseVertexLocation, startInstanceLocation); 7700 7409 7701 /* Note which surfaces are being drawn. */7702 dxTrackRenderTargets(pThisCC, pDXContext);7703 7704 7410 #ifdef DX_FLUSH_AFTER_DRAW 7705 7411 dxDeviceFlush(pDevice); … … 7723 7429 7724 7430 pDevice->pImmediateContext->DrawAuto(); 7725 7726 /* Note which surfaces are being drawn. */7727 dxTrackRenderTargets(pThisCC, pDXContext);7728 7431 7729 7432 #ifdef DX_FLUSH_AFTER_DRAW … … 8410 8113 } 8411 8114 8412 LogFunc(("cid %d: src cid %d%s -> dst cid %d%s\n", 8413 pDXContext->cid, pSrcSurface->idAssociatedContext, 8414 (pSrcSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", 8415 pDstSurface->idAssociatedContext, 8416 (pDstSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "")); 8115 LogFunc(("src%s sid = %u -> dst%s sid = %u\n", 8116 (pSrcSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", pSrcSurface->id, 8117 (pDstSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", pDstSurface->id)); 8417 8118 8418 8119 /* Clip the box. */ … … 8476 8177 #endif 8477 8178 8478 pDstSurface->pBackendSurface->cidDrawing = pDXContext->cid;8479 8179 return VINF_SUCCESS; 8480 8180 } … … 8517 8217 } 8518 8218 8519 LogFunc(("cid %d: src cid %d%s -> dst cid %d%s\n", 8520 pDXContext->cid, pSrcSurface->idAssociatedContext, 8521 (pSrcSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", 8522 pDstSurface->idAssociatedContext, 8523 (pDstSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "")); 8219 LogFunc(("src%s sid = %u -> dst%s sid = %u\n", 8220 (pSrcSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", pSrcSurface->id, 8221 (pDstSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", pDstSurface->id)); 8524 8222 8525 8223 ID3D11Resource *pDstResource = dxResource(pThisCC->svga.p3dState, pDstSurface, pDXContext); … … 8528 8226 pDevice->pImmediateContext->CopyResource(pDstResource, pSrcResource); 8529 8227 8530 pDstSurface->pBackendSurface->cidDrawing = pDXContext->cid;8531 8228 return VINF_SUCCESS; 8532 8229 } … … 8829 8526 #endif 8830 8527 8831 LogFunc(("cid %d: src cid %d%s -> dst cid %d%s\n", 8832 pDXContext->cid, pSrcSurface->idAssociatedContext, 8833 (pSrcSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", 8834 pDstSurface->idAssociatedContext, 8835 (pDstSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "")); 8528 LogFunc(("src%s sid = %u -> dst%s sid = %u\n", 8529 (pSrcSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", pSrcSurface->id, 8530 (pDstSurface->f.surfaceFlags & SVGA3D_SURFACE_SCREENTARGET) ? " st" : "", pDstSurface->id)); 8836 8531 8837 8532 /* Clip the box. */ … … 8895 8590 D3D_RELEASE(pDstRenderTargetView); 8896 8591 8897 pDstSurface->pBackendSurface->cidDrawing = pDXContext->cid;8898 8592 return VINF_SUCCESS; 8899 8593 } … … 9849 9543 vmsvgaR3ClipCopyBox(&pMipLevel->mipmapSize, &pMipLevel->mipmapSize, &clipBox); 9850 9544 9851 LogFunc(("surface%s cid %d\n", 9852 pSurface->pBackendSurface ? "" : " sysmem", 9853 pSurface ? pSurface->idAssociatedContext : SVGA_ID_INVALID)); 9545 LogFunc(("surface%s sid = %u\n", 9546 pSurface->pBackendSurface ? "" : " sysmem", pSurface->id)); 9854 9547 9855 9548 if (pSurface->pBackendSurface) … … 9940 9633 pDXDevice->pImmediateContext->ResolveSubresource(pDstResource, dstSubResource, pSrcResource, srcSubResource, dxgiFormat); 9941 9634 9942 pDstSurface->pBackendSurface->cidDrawing = pDXContext->cid;9943 9635 return VINF_SUCCESS; 9944 9636 } … … 10103 9795 pDevice->pImmediateContext->DrawIndexedInstancedIndirect(pBufferForArgs, byteOffsetForArgs); 10104 9796 10105 /* Note which surfaces are being drawn. */10106 dxTrackRenderTargets(pThisCC, pDXContext);10107 10108 9797 #ifdef DX_FLUSH_AFTER_DRAW 10109 9798 dxDeviceFlush(pDevice); … … 10142 9831 10143 9832 pDevice->pImmediateContext->DrawInstancedIndirect(pBufferForArgs, byteOffsetForArgs); 10144 10145 /* Note which surfaces are being drawn. */10146 dxTrackRenderTargets(pThisCC, pDXContext);10147 9833 10148 9834 #ifdef DX_FLUSH_AFTER_DRAW
Note:
See TracChangeset
for help on using the changeset viewer.