Changeset 108880 in vbox
- Timestamp:
- Apr 8, 2025 9:27:48 AM (12 days ago)
- svn:sync-xref-src-repo-rev:
- 168331
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.cpp
r107086 r108880 5 5 6 6 /* 7 * Copyright (C) 2022-202 4Oracle and/or its affiliates.7 * Copyright (C) 2022-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 46 46 47 47 48 static uint32_t vboxDXGetSubresourceOffset( PVBOXDX_RESOURCE pResource, UINT Subresource)48 static uint32_t vboxDXGetSubresourceOffset(VBOXDXALLOCATIONDESC const *pAllocationDesc, UINT Subresource) 49 49 { 50 50 surf_size_struct baseLevelSize; 51 baseLevelSize.width = p Resource->AllocationDesc.surfaceInfo.size.width;52 baseLevelSize.height = p Resource->AllocationDesc.surfaceInfo.size.height;53 baseLevelSize.depth = p Resource->AllocationDesc.surfaceInfo.size.depth;54 55 uint32_t const numMipLevels = p Resource->AllocationDesc.surfaceInfo.numMipLevels;51 baseLevelSize.width = pAllocationDesc->surfaceInfo.size.width; 52 baseLevelSize.height = pAllocationDesc->surfaceInfo.size.height; 53 baseLevelSize.depth = pAllocationDesc->surfaceInfo.size.depth; 54 55 uint32_t const numMipLevels = pAllocationDesc->surfaceInfo.numMipLevels; 56 56 uint32_t const face = Subresource / numMipLevels; 57 57 uint32_t const mip = Subresource % numMipLevels; 58 return svga3dsurface_get_image_offset(p Resource->AllocationDesc.surfaceInfo.format,58 return svga3dsurface_get_image_offset(pAllocationDesc->surfaceInfo.format, 59 59 baseLevelSize, numMipLevels, face, mip); 60 60 } 61 61 62 62 63 static uint32_t vboxDXGetSubresourceSize( PVBOXDX_RESOURCE pResource, UINT Subresource)63 static uint32_t vboxDXGetSubresourceSize(VBOXDXALLOCATIONDESC const *pAllocationDesc, UINT Subresource) 64 64 { 65 65 surf_size_struct baseLevelSize; 66 baseLevelSize.width = p Resource->AllocationDesc.surfaceInfo.size.width;67 baseLevelSize.height = p Resource->AllocationDesc.surfaceInfo.size.height;68 baseLevelSize.depth = p Resource->AllocationDesc.surfaceInfo.size.depth;69 70 uint32_t const numMipLevels = p Resource->AllocationDesc.surfaceInfo.numMipLevels;66 baseLevelSize.width = pAllocationDesc->surfaceInfo.size.width; 67 baseLevelSize.height = pAllocationDesc->surfaceInfo.size.height; 68 baseLevelSize.depth = pAllocationDesc->surfaceInfo.size.depth; 69 70 uint32_t const numMipLevels = pAllocationDesc->surfaceInfo.numMipLevels; 71 71 /*uint32_t const face = Subresource / numMipLevels; - unused */ 72 72 uint32_t const mip = Subresource % numMipLevels; 73 73 74 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(p Resource->AllocationDesc.surfaceInfo.format);74 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(pAllocationDesc->surfaceInfo.format); 75 75 76 76 surf_size_struct mipSize = svga3dsurface_get_mip_size(baseLevelSize, mip); … … 79 79 80 80 81 static void vboxDXGetSubresourcePitch( PVBOXDX_RESOURCE pResource, UINT Subresource, UINT *pRowPitch, UINT *pDepthPitch)82 { 83 if (p Resource->AllocationDesc.surfaceInfo.format == SVGA3D_BUFFER)84 { 85 *pRowPitch = p Resource->AllocationDesc.surfaceInfo.size.width;81 static void vboxDXGetSubresourcePitch(VBOXDXALLOCATIONDESC const *pAllocationDesc, UINT Subresource, UINT *pRowPitch, UINT *pDepthPitch) 82 { 83 if (pAllocationDesc->surfaceInfo.format == SVGA3D_BUFFER) 84 { 85 *pRowPitch = pAllocationDesc->surfaceInfo.size.width; 86 86 *pDepthPitch = *pRowPitch; 87 87 return; 88 88 } 89 89 90 uint32_t const numMipLevels = p Resource->AllocationDesc.surfaceInfo.numMipLevels;90 uint32_t const numMipLevels = pAllocationDesc->surfaceInfo.numMipLevels; 91 91 /* uint32_t const face = Subresource / numMipLevels; - unused */ 92 92 uint32_t const mip = Subresource % numMipLevels; 93 93 94 94 surf_size_struct baseLevelSize; 95 baseLevelSize.width = p Resource->AllocationDesc.surfaceInfo.size.width;96 baseLevelSize.height = p Resource->AllocationDesc.surfaceInfo.size.height;97 baseLevelSize.depth = p Resource->AllocationDesc.surfaceInfo.size.depth;98 99 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(p Resource->AllocationDesc.surfaceInfo.format);95 baseLevelSize.width = pAllocationDesc->surfaceInfo.size.width; 96 baseLevelSize.height = pAllocationDesc->surfaceInfo.size.height; 97 baseLevelSize.depth = pAllocationDesc->surfaceInfo.size.depth; 98 99 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(pAllocationDesc->surfaceInfo.format); 100 100 101 101 surf_size_struct mipSize = svga3dsurface_get_mip_size(baseLevelSize, mip); … … 108 108 109 109 110 static void vboxDXGetResourceBoxDimensions( PVBOXDX_RESOURCE pResource, UINT Subresource, SVGA3dBox *pBox,110 static void vboxDXGetResourceBoxDimensions(VBOXDXALLOCATIONDESC const *pAllocationDesc, UINT Subresource, SVGA3dBox *pBox, 111 111 uint32_t *pOffPixel, uint32_t *pcbRow, uint32_t *pcRows, uint32_t *pDepth) 112 112 { 113 if (p Resource->AllocationDesc.surfaceInfo.format == SVGA3D_BUFFER)113 if (pAllocationDesc->surfaceInfo.format == SVGA3D_BUFFER) 114 114 { 115 115 *pOffPixel = pBox->x; … … 120 120 } 121 121 122 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(p Resource->AllocationDesc.surfaceInfo.format);122 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(pAllocationDesc->surfaceInfo.format); 123 123 124 124 surf_size_struct baseLevelSize; 125 baseLevelSize.width = p Resource->AllocationDesc.surfaceInfo.size.width;126 baseLevelSize.height = p Resource->AllocationDesc.surfaceInfo.size.height;127 baseLevelSize.depth = p Resource->AllocationDesc.surfaceInfo.size.depth;128 129 uint32_t const numMipLevels = p Resource->AllocationDesc.surfaceInfo.numMipLevels;125 baseLevelSize.width = pAllocationDesc->surfaceInfo.size.width; 126 baseLevelSize.height = pAllocationDesc->surfaceInfo.size.height; 127 baseLevelSize.depth = pAllocationDesc->surfaceInfo.size.depth; 128 129 uint32_t const numMipLevels = pAllocationDesc->surfaceInfo.numMipLevels; 130 130 uint32_t const mip = Subresource % numMipLevels; 131 131 … … 139 139 svga3dsurface_get_size_in_blocks(desc, &boxSize, &blocks); 140 140 141 *pOffPixel = svga3dsurface_get_pixel_offset(p Resource->AllocationDesc.surfaceInfo.format,141 *pOffPixel = svga3dsurface_get_pixel_offset(pAllocationDesc->surfaceInfo.format, 142 142 mipSize.width, mipSize.height, 143 143 pBox->x, pBox->y, pBox->z); … … 147 147 } 148 148 149 static void vboxDXGetSubresourceBox(PVBOXDX_RESOURCE pResource, UINT Subresource, SVGA3dBox *pBox) 149 150 static void vboxDXGetSubresourceBox(VBOXDXALLOCATIONDESC const *pAllocationDesc, UINT Subresource, SVGA3dBox *pBox) 150 151 { 151 152 surf_size_struct baseLevelSize; 152 baseLevelSize.width = p Resource->AllocationDesc.surfaceInfo.size.width;153 baseLevelSize.height = p Resource->AllocationDesc.surfaceInfo.size.height;154 baseLevelSize.depth = p Resource->AllocationDesc.surfaceInfo.size.depth;155 156 uint32_t const numMipLevels = p Resource->AllocationDesc.surfaceInfo.numMipLevels;153 baseLevelSize.width = pAllocationDesc->surfaceInfo.size.width; 154 baseLevelSize.height = pAllocationDesc->surfaceInfo.size.height; 155 baseLevelSize.depth = pAllocationDesc->surfaceInfo.size.depth; 156 157 uint32_t const numMipLevels = pAllocationDesc->surfaceInfo.numMipLevels; 157 158 uint32_t const mip = Subresource % numMipLevels; 158 159 … … 235 236 236 237 237 void vboxDXStorePatchLocation(PVBOXDX_DEVICE pDevice, void *pvPatch, VBOXDXALLOCATIONTYPE enmAllocationType, 238 D3DKMT_HANDLE hAllocation, uint32_t offAllocation, bool fWriteOperation) 239 { 238 void vboxDXStorePatchLocation(PVBOXDX_DEVICE pDevice, void *pvPatch, PVBOXDXKMRESOURCE pKMResource, 239 uint32_t offAllocation, bool fWriteOperation) 240 { 241 D3DKMT_HANDLE hAllocation = vboxDXGetAllocation(pKMResource); 240 242 if (!hAllocation) 241 243 return; … … 272 274 pPatchLocation->AllocationIndex = idxAllocation; 273 275 pPatchLocation->Value = 0; 274 pPatchLocation->DriverId = enmAllocationType;276 pPatchLocation->DriverId = pKMResource->AllocationDesc.enmAllocationType; 275 277 pPatchLocation->AllocationOffset = offAllocation; 276 278 pPatchLocation->PatchOffset = (uintptr_t)pvPatch - (uintptr_t)pDevice->pCommandBuffer; 277 279 pPatchLocation->SplitOffset = pDevice->cbCommandBuffer; 278 280 ++pDevice->cPatchLocations; 281 282 /* Move the KM resource to the head of the resource list. */ 283 RTListNodeRemove(&pKMResource->nodeResource); 284 RTListPrepend(&pDevice->listResources, &pKMResource->nodeResource); 279 285 } 280 286 … … 313 319 if (pResource) 314 320 { 315 D3DKMT_HANDLE const hAllocation = vboxDXGetAllocation(pResource);321 PVBOXDXKMRESOURCE const pKMResource = vboxDXGetKMResource(pResource); 316 322 uint32 const offsetInBytes = pCBS->aFirstConstant[i] * (4 * sizeof(UINT)); 317 323 uint32 const sizeInBytes = pCBS->aNumConstants[i] * (4 * sizeof(UINT)); 318 324 LogFunc(("type %d, slot %d, off %d, size %d, cbAllocation %d", 319 enmShaderType, i, offsetInBytes, sizeInBytes, p Resource->AllocationDesc.cbAllocation));320 321 vgpu10SetSingleConstantBuffer(pDevice, i, enmShaderType, hAllocation, offsetInBytes, sizeInBytes);325 enmShaderType, i, offsetInBytes, sizeInBytes, pKMResource->AllocationDesc.cbAllocation)); 326 327 vgpu10SetSingleConstantBuffer(pDevice, i, enmShaderType, pKMResource, offsetInBytes, sizeInBytes); 322 328 } 323 329 else … … 349 355 350 356 /* Fetch allocation handles. */ 351 D3DKMT_HANDLE aAllocations[SVGA3D_MAX_VERTEX_ARRAYS];357 PVBOXDXKMRESOURCE aKMResources[SVGA3D_MAX_VERTEX_ARRAYS]; 352 358 for (unsigned i = pVBS->StartSlot; i < pVBS->StartSlot + pVBS->NumBuffers; ++i) 353 359 { 354 360 PVBOXDX_RESOURCE pResource = pVBS->apResource[i]; 355 a Allocations[i] = vboxDXGetAllocation(pResource);356 } 357 358 vgpu10SetVertexBuffers(pDevice, pVBS->StartSlot, pVBS->NumBuffers, a Allocations,361 aKMResources[i] = vboxDXGetKMResource(pResource); 362 } 363 364 vgpu10SetVertexBuffers(pDevice, pVBS->StartSlot, pVBS->NumBuffers, aKMResources, 359 365 &pVBS->aStrides[pVBS->StartSlot], &pVBS->aOffsets[pVBS->StartSlot]); 360 366 … … 381 387 PVBOXDXINDEXBUFFERSTATE pIBS = &pDevice->pipeline.IndexBuffer; 382 388 383 D3DKMT_HANDLE const hAllocation = vboxDXGetAllocation(pIBS->pBuffer);389 PVBOXDXKMRESOURCE const pKMResource = vboxDXGetKMResource(pIBS->pBuffer); 384 390 SVGA3dSurfaceFormat const svgaFormat = vboxDXDxgiToSvgaFormat(pIBS->Format); 385 vgpu10SetIndexBuffer(pDevice, hAllocation, svgaFormat, pIBS->Offset);391 vgpu10SetIndexBuffer(pDevice, pKMResource, svgaFormat, pIBS->Offset); 386 392 } 387 393 … … 577 583 578 584 579 static uint32_t vboxDXCalcResourceAllocationSize(PVBOXDX_RESOURCE pResource) 585 PVBOXDXKMRESOURCE vboxDXAllocateKMResource(PVBOXDX_DEVICE pDevice, HANDLE hResource, 586 PFNVBOXDXINITALLOCATIONDESC pfnInitAllocationDesc, 587 void const *pvInitData, bool fZero) 588 { 589 PVBOXDXKMRESOURCE pKMResource = (PVBOXDXKMRESOURCE)RTMemAllocZ(sizeof(VBOXDXKMRESOURCE)); 590 AssertReturnStmt(pKMResource, vboxDXDeviceSetError(pDevice, E_OUTOFMEMORY), NULL); 591 592 pfnInitAllocationDesc(&pKMResource->AllocationDesc, pvInitData); 593 594 D3DDDI_ALLOCATIONINFO2 ddiAllocationInfo; 595 RT_ZERO(ddiAllocationInfo); 596 ddiAllocationInfo.pPrivateDriverData = &pKMResource->AllocationDesc; 597 ddiAllocationInfo.PrivateDriverDataSize = sizeof(pKMResource->AllocationDesc); 598 if (pKMResource->AllocationDesc.fPrimary) 599 { 600 ddiAllocationInfo.VidPnSourceId = pKMResource->AllocationDesc.PrimaryDesc.VidPnSourceId; 601 ddiAllocationInfo.Flags.Primary = 1; 602 } 603 604 D3DDDICB_ALLOCATE ddiAllocate; 605 RT_ZERO(ddiAllocate); 606 ddiAllocate.hResource = hResource; 607 ddiAllocate.NumAllocations = 1; 608 ddiAllocate.pAllocationInfo2 = &ddiAllocationInfo; 609 610 HRESULT hr = pDevice->pRTCallbacks->pfnAllocateCb(pDevice->hRTDevice.handle, &ddiAllocate); 611 LogFlowFunc(("pfnAllocateCb returned 0x%x, hKMResource 0x%X, hAllocation 0x%X", hr, ddiAllocate.hKMResource, ddiAllocationInfo.hAllocation)); 612 AssertReturnStmt(SUCCEEDED(hr), 613 vboxDXDeallocateKMResource(pDevice, pKMResource); vboxDXDeviceSetError(pDevice, hr), 614 false); 615 616 pKMResource->hAllocation = ddiAllocationInfo.hAllocation; 617 618 if (fZero) 619 { 620 D3DDDICB_LOCK ddiLock; 621 RT_ZERO(ddiLock); 622 ddiLock.hAllocation = ddiAllocationInfo.hAllocation; 623 ddiLock.Flags.WriteOnly = 1; 624 hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); 625 if (SUCCEEDED(hr)) 626 { 627 memset(ddiLock.pData, 0, pKMResource->AllocationDesc.cbAllocation); 628 629 D3DDDICB_UNLOCK ddiUnlock; 630 ddiUnlock.NumAllocations = 1; 631 ddiUnlock.phAllocations = &ddiLock.hAllocation; 632 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 633 } 634 AssertReturnStmt(SUCCEEDED(hr), 635 vboxDXDeallocateKMResource(pDevice, pKMResource); vboxDXDeviceSetError(pDevice, hr), 636 false); 637 } 638 639 return pKMResource; 640 } 641 642 643 PVBOXDXKMRESOURCE vboxDXOpenKMResource(PVBOXDX_DEVICE pDevice, D3DKMT_HANDLE hAllocation, 644 VBOXDXALLOCATIONDESC const *pDesc) 645 { 646 PVBOXDXKMRESOURCE pKMResource = (PVBOXDXKMRESOURCE)RTMemAllocZ(sizeof(VBOXDXKMRESOURCE)); 647 AssertReturnStmt(pKMResource, vboxDXDeviceSetError(pDevice, E_OUTOFMEMORY), NULL); 648 649 pKMResource->hAllocation = hAllocation; 650 pKMResource->AllocationDesc = *pDesc; 651 pKMResource->flags.fOpened = 1; 652 return pKMResource; 653 } 654 655 656 void vboxDXDeallocateKMResource(PVBOXDX_DEVICE pDevice, PVBOXDXKMRESOURCE pKMResource) 657 { 658 if (pKMResource) 659 { 660 Assert(!pKMResource->flags.fOpened); 661 662 if (pKMResource->hAllocation) 663 { 664 D3DDDICB_DEALLOCATE ddiDeallocate; 665 RT_ZERO(ddiDeallocate); 666 //ddiDeallocate.hResource = NULL; 667 ddiDeallocate.NumAllocations = 1; 668 ddiDeallocate.HandleList = &pKMResource->hAllocation; 669 670 HRESULT hr = pDevice->pRTCallbacks->pfnDeallocateCb(pDevice->hRTDevice.handle, &ddiDeallocate); 671 LogFlowFunc(("pfnDeallocateCb returned 0x%x, hAllocation 0x%x", hr, pKMResource->hAllocation)); 672 AssertStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr)); 673 } 674 675 RTMemFree(pKMResource); 676 } 677 } 678 679 680 static uint32_t vboxDXCalcResourceAllocationSize(VBOXDXALLOCATIONDESC const *pAllocationDesc) 580 681 { 581 682 /* The allocation holds the entire resource: … … 585 686 */ 586 687 surf_size_struct base_level_size; 587 base_level_size.width = p Resource->AllocationDesc.surfaceInfo.size.width;588 base_level_size.height = p Resource->AllocationDesc.surfaceInfo.size.height;589 base_level_size.depth = p Resource->AllocationDesc.surfaceInfo.size.depth;590 591 return svga3dsurface_get_serialized_size_extended(p Resource->AllocationDesc.surfaceInfo.format,688 base_level_size.width = pAllocationDesc->surfaceInfo.size.width; 689 base_level_size.height = pAllocationDesc->surfaceInfo.size.height; 690 base_level_size.depth = pAllocationDesc->surfaceInfo.size.depth; 691 692 return svga3dsurface_get_serialized_size_extended(pAllocationDesc->surfaceInfo.format, 592 693 base_level_size, 593 p Resource->AllocationDesc.surfaceInfo.numMipLevels,594 p Resource->AllocationDesc.surfaceInfo.arraySize,595 p Resource->AllocationDesc.surfaceInfo.multisampleCount);694 pAllocationDesc->surfaceInfo.numMipLevels, 695 pAllocationDesc->surfaceInfo.arraySize, 696 pAllocationDesc->surfaceInfo.multisampleCount); 596 697 } 597 698 … … 695 796 696 797 697 int vboxDXInitResourceData(PVBOXDX_RESOURCE pResource, const D3D11DDIARG_CREATERESOURCE *pCreateResource) 698 { 699 /* Store data which might be needed later. */ 700 pResource->ResourceDimension = pCreateResource->ResourceDimension; 701 pResource->Usage = (D3D10_DDI_RESOURCE_USAGE)pCreateResource->Usage; 702 for (UINT i = 0; i < pCreateResource->MipLevels; ++i) 703 pResource->aMipInfoList[i] = pCreateResource->pMipInfoList[i]; 798 static void resourceAllocationDesc(VBOXDXALLOCATIONDESC *pDesc, void const *pvInitData) 799 { 800 const D3D11DDIARG_CREATERESOURCE *pCreateResource = (const D3D11DDIARG_CREATERESOURCE *)pvInitData; 704 801 705 802 /* Init surface information which will be used by the miniport to define the surface. */ 706 VBOXDXALLOCATIONDESC *pDesc = &pResource->AllocationDesc;707 803 pDesc->surfaceInfo.surfaceFlags = vboxDXCalcSurfaceFlags(pCreateResource); 708 804 pDesc->surfaceInfo.format = vboxDXDxgiToSvgaFormat(pCreateResource->Format); … … 741 837 /* Finally set the allocation type and compute the size. */ 742 838 pDesc->enmAllocationType = VBOXDXALLOCATIONTYPE_SURFACE; 743 pDesc->cbAllocation = vboxDXCalcResourceAllocationSize(pResource); 744 745 /* Init remaining fields. */ 839 pDesc->cbAllocation = vboxDXCalcResourceAllocationSize(pDesc); 840 } 841 842 843 bool vboxDXCreateResource(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pResource, 844 const D3D11DDIARG_CREATERESOURCE *pCreateResource) 845 { 846 bool const fZero = pCreateResource->pInitialDataUP == NULL 847 && ( pCreateResource->Usage == D3D10_DDI_USAGE_DYNAMIC 848 || pCreateResource->Usage == D3D10_DDI_USAGE_STAGING); 849 850 pResource->pKMResource = vboxDXAllocateKMResource(pDevice, pResource->hRTResource.handle, 851 resourceAllocationDesc, pCreateResource, fZero); 852 if (!pResource->pKMResource) 853 { 854 /* Might be not enough memory due to temporary staging buffers. */ 855 vboxDXFlush(pDevice, true); 856 pResource->pKMResource = vboxDXAllocateKMResource(pDevice, pResource->hRTResource.handle, 857 resourceAllocationDesc, pCreateResource, fZero); 858 } 859 860 if (!pResource->pKMResource) 861 return false; 862 863 pResource->ResourceDimension = pCreateResource->ResourceDimension; 864 pResource->Usage = (D3D10_DDI_RESOURCE_USAGE)pCreateResource->Usage; 865 for (UINT i = 0; i < pCreateResource->MipLevels; ++i) 866 pResource->aMipInfoList[i] = pCreateResource->pMipInfoList[i]; 746 867 pResource->cSubresources = pCreateResource->MipLevels * pCreateResource->ArraySize; 747 pResource->pKMResource = NULL;748 868 pResource->uMap = 0; 869 749 870 RTListInit(&pResource->listSRV); 750 871 RTListInit(&pResource->listRTV); … … 755 876 RTListInit(&pResource->listVPOV); 756 877 757 return VINF_SUCCESS; 758 } 759 760 761 static HRESULT dxAllocate(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pResource, D3DKMT_HANDLE *phAllocation) 762 { 763 D3DDDI_ALLOCATIONINFO2 ddiAllocationInfo; 764 RT_ZERO(ddiAllocationInfo); 765 //ddiAllocationInfo.pSystemMem = 0; 766 ddiAllocationInfo.pPrivateDriverData = &pResource->AllocationDesc; 767 ddiAllocationInfo.PrivateDriverDataSize = sizeof(pResource->AllocationDesc); 768 if (pResource->AllocationDesc.fPrimary) 769 { 770 ddiAllocationInfo.VidPnSourceId = pResource->AllocationDesc.PrimaryDesc.VidPnSourceId; 771 ddiAllocationInfo.Flags.Primary = pResource->AllocationDesc.fPrimary; 772 } 773 774 D3DDDICB_ALLOCATE ddiAllocate; 775 RT_ZERO(ddiAllocate); 776 //ddiAllocate.pPrivateDriverData = NULL; 777 //ddiAllocate.PrivateDriverDataSize = 0; 778 ddiAllocate.hResource = pResource->hRTResource.handle; 779 ddiAllocate.NumAllocations = 1; 780 ddiAllocate.pAllocationInfo2 = &ddiAllocationInfo; 781 782 HRESULT hr = pDevice->pRTCallbacks->pfnAllocateCb(pDevice->hRTDevice.handle, &ddiAllocate); 783 LogFlowFunc((" pfnAllocateCb returned %d, hKMResource 0x%X, hAllocation 0x%X", hr, ddiAllocate.hKMResource, ddiAllocationInfo.hAllocation)); 784 785 if (SUCCEEDED(hr)) 786 *phAllocation = ddiAllocationInfo.hAllocation; 787 788 return hr; 789 } 790 791 792 bool vboxDXCreateResource(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pResource, 793 const D3D11DDIARG_CREATERESOURCE *pCreateResource) 794 { 795 pResource->pKMResource = (PVBOXDXKMRESOURCE)RTMemAllocZ(sizeof(VBOXDXKMRESOURCE)); 796 AssertReturnStmt(pResource->pKMResource, vboxDXDeviceSetError(pDevice, E_OUTOFMEMORY), false); 797 798 D3DKMT_HANDLE hAllocation = 0; 799 HRESULT hr = dxAllocate(pDevice, pResource, &hAllocation); 800 if (FAILED(hr)) 801 { 802 /* Might be not enough memory due to temporary staging buffers. */ 803 vboxDXFlush(pDevice, true); 804 hr = dxAllocate(pDevice, pResource, &hAllocation); 805 } 806 AssertReturnStmt(SUCCEEDED(hr), RTMemFree(pResource->pKMResource); vboxDXDeviceSetError(pDevice, hr), false); 807 808 pResource->pKMResource->pResource = pResource; 809 pResource->pKMResource->hAllocation = hAllocation; 878 pResource->pKMResource->resource.pResource = pResource; 879 810 880 RTListAppend(&pDevice->listResources, &pResource->pKMResource->nodeResource); 811 881 … … 813 883 { 814 884 /* Upload the data to the resource. */ 815 for ( unsignedi = 0; i < pResource->cSubresources; ++i)885 for (UINT i = 0; i < pResource->cSubresources; ++i) 816 886 vboxDXResourceUpdateSubresourceUP(pDevice, pResource, i, NULL, 817 887 pCreateResource->pInitialDataUP[i].pSysMem, … … 820 890 821 891 } 822 else823 {824 /** @todo Test Lock/Unlock. Not sure if memset is really necessary. */825 if ( pResource->Usage == D3D10_DDI_USAGE_DYNAMIC826 || pResource->Usage == D3D10_DDI_USAGE_STAGING)827 {828 /* Zero the allocation. */829 D3DDDICB_LOCK ddiLock;830 RT_ZERO(ddiLock);831 ddiLock.hAllocation = vboxDXGetAllocation(pResource);832 ddiLock.Flags.WriteOnly = 1;833 hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock);834 if (SUCCEEDED(hr))835 {836 memset(ddiLock.pData, 0, pResource->AllocationDesc.cbAllocation);837 838 hAllocation = vboxDXGetAllocation(pResource);839 840 D3DDDICB_UNLOCK ddiUnlock;841 ddiUnlock.NumAllocations = 1;842 ddiUnlock.phAllocations = &hAllocation;843 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock);844 }845 }846 }847 892 848 893 return true; … … 858 903 vboxDXDeviceSetError(pDevice, E_INVALIDARG), false); 859 904 860 pResource->pKMResource = (PVBOXDXKMRESOURCE)RTMemAllocZ(sizeof(VBOXDXKMRESOURCE)); 861 AssertReturnStmt(pResource->pKMResource, vboxDXDeviceSetError(pDevice, E_OUTOFMEMORY), false); 862 863 VBOXDXALLOCATIONDESC const *pDesc = (VBOXDXALLOCATIONDESC *)pOpenResource->pOpenAllocationInfo2[0].pPrivateDriverData; 905 pResource->pKMResource = vboxDXOpenKMResource(pDevice, pOpenResource->pOpenAllocationInfo2[0].hAllocation, 906 (VBOXDXALLOCATIONDESC *)pOpenResource->pOpenAllocationInfo2[0].pPrivateDriverData); 907 if (!pResource->pKMResource) 908 return false; 909 910 VBOXDXALLOCATIONDESC const *pDesc = vboxDXGetAllocationDesc(pResource); 864 911 865 912 /* Restore resource data. */ … … 868 915 for (UINT i = 0; i < pDesc->surfaceInfo.numMipLevels; ++i) 869 916 RT_ZERO(pResource->aMipInfoList[i]); 870 871 pResource->AllocationDesc = *pDesc;872 pResource->AllocationDesc.resourceInfo.MiscFlags |= D3D10_DDI_RESOURCE_MISC_SHARED;873 874 /* Init remaining fields. */875 917 pResource->cSubresources = pDesc->surfaceInfo.numMipLevels * pDesc->surfaceInfo.arraySize; 876 pResource->uMap = 0; 918 pResource->uMap = 0; 919 877 920 RTListInit(&pResource->listSRV); 878 921 RTListInit(&pResource->listRTV); … … 883 926 RTListInit(&pResource->listVPOV); 884 927 885 pResource->pKMResource-> pResource = pResource;886 pResource->pKMResource->hAllocation = pOpenResource->pOpenAllocationInfo2[0].hAllocation; 928 pResource->pKMResource->resource.pResource = pResource; 929 887 930 RTListAppend(&pDevice->listResources, &pResource->pKMResource->nodeResource); 931 888 932 return true; 889 933 } … … 912 956 RTListNodeRemove(&pResource->pKMResource->nodeResource); 913 957 914 if (pResource-> AllocationDesc.fPrimary)958 if (pResource->pKMResource->AllocationDesc.fPrimary) 915 959 { 916 960 /* Delete immediately. */ 917 D3DDDICB_DEALLOCATE ddiDeallocate; 918 RT_ZERO(ddiDeallocate); 919 //ddiDeallocate.hResource = NULL; 920 ddiDeallocate.NumAllocations = 1; 921 ddiDeallocate.HandleList = &pResource->pKMResource->hAllocation; 922 923 HRESULT hr = pDevice->pRTCallbacks->pfnDeallocateCb(pDevice->hRTDevice.handle, &ddiDeallocate); 924 LogFlowFunc(("pfnDeallocateCb returned %d", hr)); 925 AssertStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr)); 926 927 RTMemFree(pResource->pKMResource); 961 vboxDXDeallocateKMResource(pDevice, pResource->pKMResource); 962 pResource->pKMResource = 0; 928 963 } 929 964 else 930 965 { 931 if (!RT_BOOL(pResource->AllocationDesc.resourceInfo.MiscFlags & D3D10_DDI_RESOURCE_MISC_SHARED)) 966 if ( !pResource->pKMResource->flags.fOpened 967 && !RT_BOOL(pResource->pKMResource->AllocationDesc.resourceInfo.MiscFlags & D3D10_DDI_RESOURCE_MISC_SHARED)) 932 968 { 933 969 /* Set the resource for deferred destruction. */ 934 pResource->pKMResource-> pResource = NULL;970 pResource->pKMResource->resource.pResource = NULL; 935 971 RTListAppend(&pDevice->listDestroyedResources, &pResource->pKMResource->nodeResource); 936 972 } … … 1508 1544 { 1509 1545 vboxDXSetupPipeline(pDevice); 1510 vgpu10DrawIndexedInstancedIndirect(pDevice, vboxDXGet Allocation(pResource), AlignedByteOffsetForArgs);1546 vgpu10DrawIndexedInstancedIndirect(pDevice, vboxDXGetKMResource(pResource), AlignedByteOffsetForArgs); 1511 1547 } 1512 1548 … … 1515 1551 { 1516 1552 vboxDXSetupPipeline(pDevice); 1517 vgpu10DrawInstancedIndirect(pDevice, vboxDXGet Allocation(pResource), AlignedByteOffsetForArgs);1553 vgpu10DrawInstancedIndirect(pDevice, vboxDXGetKMResource(pResource), AlignedByteOffsetForArgs); 1518 1554 } 1519 1555 … … 1533 1569 1534 1570 1535 static void vboxDXDestroyCOAllocation(PVBOXDX_DEVICE pDevice, PVBOXDX COALLOCATIONpCOAllocation)1571 static void vboxDXDestroyCOAllocation(PVBOXDX_DEVICE pDevice, PVBOXDXKMRESOURCE pCOAllocation) 1536 1572 { 1537 1573 if (pCOAllocation) 1538 1574 { 1539 if (pCOAllocation->hCOAllocation) 1540 { 1541 D3DDDICB_DEALLOCATE ddiDeallocate; 1542 RT_ZERO(ddiDeallocate); 1543 ddiDeallocate.NumAllocations = 1; 1544 ddiDeallocate.HandleList = &pCOAllocation->hCOAllocation; 1545 1546 HRESULT hr = pDevice->pRTCallbacks->pfnDeallocateCb(pDevice->hRTDevice.handle, &ddiDeallocate); 1547 LogFlowFunc(("pfnDeallocateCb returned %d", hr)); 1548 AssertStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr)); 1549 1550 pCOAllocation->hCOAllocation = 0; 1551 } 1552 1553 RTMemFree(pCOAllocation); 1554 } 1555 } 1556 1557 1558 static bool vboxDXCreateCOAllocation(PVBOXDX_DEVICE pDevice, RTLISTANCHOR *pList, PVBOXDXCOALLOCATION *ppCOAllocation, uint32_t cbAllocation) 1559 { 1560 PVBOXDXCOALLOCATION pCOAllocation = (PVBOXDXCOALLOCATION)RTMemAllocZ(sizeof(VBOXDXCOALLOCATION)); 1561 AssertReturnStmt(pCOAllocation, vboxDXDeviceSetError(pDevice, E_OUTOFMEMORY), false); 1562 1563 VBOXDXALLOCATIONDESC desc; 1564 RT_ZERO(desc); 1565 desc.enmAllocationType = VBOXDXALLOCATIONTYPE_CO; 1566 desc.cbAllocation = cbAllocation; 1567 1568 D3DDDI_ALLOCATIONINFO2 ddiAllocationInfo; 1569 RT_ZERO(ddiAllocationInfo); 1570 ddiAllocationInfo.pPrivateDriverData = &desc; 1571 ddiAllocationInfo.PrivateDriverDataSize = sizeof(desc); 1572 1573 D3DDDICB_ALLOCATE ddiAllocate; 1574 RT_ZERO(ddiAllocate); 1575 ddiAllocate.NumAllocations = 1; 1576 ddiAllocate.pAllocationInfo2 = &ddiAllocationInfo; 1577 1578 HRESULT hr = pDevice->pRTCallbacks->pfnAllocateCb(pDevice->hRTDevice.handle, &ddiAllocate); 1579 LogFlowFunc(("pfnAllocateCb returned %d, hKMResource 0x%X, hAllocation 0x%X", hr, ddiAllocate.hKMResource, ddiAllocationInfo.hAllocation)); 1580 AssertReturnStmt(SUCCEEDED(hr), 1581 vboxDXDestroyCOAllocation(pDevice, pCOAllocation); vboxDXDeviceSetError(pDevice, hr), false); 1582 1583 pCOAllocation->hCOAllocation = ddiAllocationInfo.hAllocation; 1584 1585 D3DDDICB_LOCK ddiLock; 1586 RT_ZERO(ddiLock); 1587 ddiLock.hAllocation = ddiAllocationInfo.hAllocation; 1588 ddiLock.Flags.WriteOnly = 1; 1589 hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); 1590 if (SUCCEEDED(hr)) 1591 { 1592 memset(ddiLock.pData, 0, cbAllocation); 1593 1594 D3DDDICB_UNLOCK ddiUnlock; 1595 ddiUnlock.NumAllocations = 1; 1596 ddiUnlock.phAllocations = &ddiAllocationInfo.hAllocation; 1597 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 1598 } 1599 AssertReturnStmt(SUCCEEDED(hr), 1600 vboxDXDestroyCOAllocation(pDevice, pCOAllocation); vboxDXDeviceSetError(pDevice, hr), false); 1601 1602 pCOAllocation->cbAllocation = cbAllocation; 1575 Assert(pCOAllocation->AllocationDesc.enmAllocationType == VBOXDXALLOCATIONTYPE_CO); 1576 1577 /* Remove from the global list of resources. */ 1578 RTListNodeRemove(&pCOAllocation->nodeResource); 1579 vboxDXDeallocateKMResource(pDevice, pCOAllocation); 1580 } 1581 } 1582 1583 1584 static void coAllocationDesc(VBOXDXALLOCATIONDESC *pDesc, void const *pvInitData) 1585 { 1586 pDesc->enmAllocationType = VBOXDXALLOCATIONTYPE_CO; /* Context Object allocation. */ 1587 pDesc->cbAllocation = *(uint32_t *)pvInitData; 1588 } 1589 1590 1591 static bool vboxDXCreateCOAllocation(PVBOXDX_DEVICE pDevice, RTLISTANCHOR *pList, PVBOXDXKMRESOURCE *ppCOAllocation, uint32_t cbAllocation) 1592 { 1593 PVBOXDXKMRESOURCE pCOAllocation = vboxDXAllocateKMResource(pDevice, 0, coAllocationDesc, &cbAllocation, true); 1594 if (!pCOAllocation) 1595 return false; 1603 1596 1604 1597 /* Initially the allocation contains one big free block and zero sized free blocks. */ 1605 pCOAllocation->aOffset[0] = 0; 1606 for (unsigned i = 1; i < RT_ELEMENTS(pCOAllocation->aOffset); ++i) 1607 pCOAllocation->aOffset[i] = cbAllocation; 1608 1609 RTListAppend(pList, &pCOAllocation->nodeAllocationsChain); 1598 pCOAllocation->co.aOffset[0] = 0; 1599 for (unsigned i = 1; i < RT_ELEMENTS(pCOAllocation->co.aOffset); ++i) 1600 pCOAllocation->co.aOffset[i] = cbAllocation; 1601 1602 /* Add to the chain of COAs. */ 1603 RTListAppend(pList, &pCOAllocation->co.nodeAllocationsChain); 1604 1605 /* Add to the global list of resources. */ 1606 RTListAppend(&pDevice->listResources, &pCOAllocation->nodeResource); 1610 1607 1611 1608 *ppCOAllocation = pCOAllocation; … … 1613 1610 } 1614 1611 1615 #define IS_CO_BLOCK_FREE(_a, _i) (((_a)->u64Bitmap & (1ULL << (_i))) == 0) 1616 #define IS_CO_BLOCK_USED(_a, _i) (((_a)->u64Bitmap & (1ULL << (_i))) != 0) 1617 #define SET_CO_BLOCK_FREE(_a, _i) (((_a)->u64Bitmap &= ~(1ULL << (_i)))) 1618 #define SET_CO_BLOCK_USED(_a, _i) (((_a)->u64Bitmap |= (1ULL << (_i)))) 1619 1620 static bool vboxDXCOABlockAlloc(PVBOXDXCOALLOCATION pCOAllocation, uint32_t cb, uint32_t *poff) 1621 { 1612 #define IS_CO_BLOCK_FREE(_a, _i) (((_a)->co.u64Bitmap & (1ULL << (_i))) == 0) 1613 #define IS_CO_BLOCK_USED(_a, _i) (((_a)->co.u64Bitmap & (1ULL << (_i))) != 0) 1614 #define SET_CO_BLOCK_FREE(_a, _i) (((_a)->co.u64Bitmap &= ~(1ULL << (_i)))) 1615 #define SET_CO_BLOCK_USED(_a, _i) (((_a)->co.u64Bitmap |= (1ULL << (_i)))) 1616 1617 static bool vboxDXCOABlockAlloc(PVBOXDXKMRESOURCE pCOAllocation, uint32_t cb, uint32_t *poff) 1618 { 1619 Assert(pCOAllocation->AllocationDesc.enmAllocationType == VBOXDXALLOCATIONTYPE_CO); 1620 1622 1621 //DEBUG_BREAKPOINT_TEST(); 1623 1622 /* Search for a big enough free block. The last block is a special case. */ 1624 1623 unsigned i = 0; 1625 for (; i < RT_ELEMENTS(pCOAllocation-> aOffset) - 1; ++i)1624 for (; i < RT_ELEMENTS(pCOAllocation->co.aOffset) - 1; ++i) 1626 1625 { 1627 1626 if ( IS_CO_BLOCK_FREE(pCOAllocation, i) 1628 && pCOAllocation-> aOffset[i + 1] - pCOAllocation->aOffset[i] >= cb)1627 && pCOAllocation->co.aOffset[i + 1] - pCOAllocation->co.aOffset[i] >= cb) 1629 1628 { 1630 1629 /* Found one. */ … … 1633 1632 /* If the next block is free, then add the remaining space to it. */ 1634 1633 if (IS_CO_BLOCK_FREE(pCOAllocation, i + 1)) 1635 pCOAllocation-> aOffset[i + 1] = pCOAllocation->aOffset[i] + cb;1636 1637 *poff = pCOAllocation-> aOffset[i];1634 pCOAllocation->co.aOffset[i + 1] = pCOAllocation->co.aOffset[i] + cb; 1635 1636 *poff = pCOAllocation->co.aOffset[i]; 1638 1637 return true; 1639 1638 } … … 1642 1641 /* Last block. */ 1643 1642 if ( IS_CO_BLOCK_FREE(pCOAllocation, i) 1644 && pCOAllocation-> cbAllocation - pCOAllocation->aOffset[i] >= cb)1643 && pCOAllocation->AllocationDesc.cbAllocation - pCOAllocation->co.aOffset[i] >= cb) 1645 1644 { 1646 1645 /* Found one. */ 1647 1646 SET_CO_BLOCK_USED(pCOAllocation, i); 1648 1647 1649 *poff = pCOAllocation-> aOffset[i];1648 *poff = pCOAllocation->co.aOffset[i]; 1650 1649 return true; 1651 1650 } … … 1655 1654 1656 1655 1657 static void vboxDXCOABlockFree(PVBOXDXCOALLOCATION pCOAllocation, uint32_t offBlock) 1658 { 1656 static void vboxDXCOABlockFree(PVBOXDXKMRESOURCE pCOAllocation, uint32_t offBlock) 1657 { 1658 Assert(pCOAllocation->AllocationDesc.enmAllocationType == VBOXDXALLOCATIONTYPE_CO); 1659 1659 1660 //DEBUG_BREAKPOINT_TEST(); 1660 for (unsigned i = 0; i < RT_ELEMENTS(pCOAllocation-> aOffset); ++i)1661 { 1662 if (pCOAllocation-> aOffset[i] == offBlock)1661 for (unsigned i = 0; i < RT_ELEMENTS(pCOAllocation->co.aOffset); ++i) 1662 { 1663 if (pCOAllocation->co.aOffset[i] == offBlock) 1663 1664 { 1664 1665 Assert(IS_CO_BLOCK_USED(pCOAllocation, i)); … … 1672 1673 1673 1674 1675 static void shadersAllocationDesc(VBOXDXALLOCATIONDESC *pDesc, void const *pvInitData) 1676 { 1677 pDesc->enmAllocationType = VBOXDXALLOCATIONTYPE_SHADERS; 1678 pDesc->cbAllocation = *(uint32_t *)pvInitData; 1679 } 1680 1681 1674 1682 static bool vboxDXEnsureShaderAllocation(PVBOXDX_DEVICE pDevice) 1675 1683 { 1676 if (!pDevice->hShaderAllocation) 1677 { 1678 VBOXDXALLOCATIONDESC desc; 1679 RT_ZERO(desc); 1680 desc.enmAllocationType = VBOXDXALLOCATIONTYPE_SHADERS; 1681 desc.cbAllocation = SVGA3D_MAX_SHADER_MEMORY_BYTES; 1682 1683 D3DDDI_ALLOCATIONINFO2 ddiAllocationInfo; 1684 RT_ZERO(ddiAllocationInfo); 1685 //ddiAllocationInfo.pSystemMem = 0; 1686 ddiAllocationInfo.pPrivateDriverData = &desc; 1687 ddiAllocationInfo.PrivateDriverDataSize = sizeof(desc); 1688 //ddiAllocationInfo.VidPnSourceId = 0; 1689 //ddiAllocationInfo.Flags.Value = 0; 1690 1691 D3DDDICB_ALLOCATE ddiAllocate; 1692 RT_ZERO(ddiAllocate); 1693 //ddiAllocate.pPrivateDriverData = NULL; 1694 //ddiAllocate.PrivateDriverDataSize = 0; 1695 //ddiAllocate.hResource = 0; 1696 ddiAllocate.NumAllocations = 1; 1697 ddiAllocate.pAllocationInfo2 = &ddiAllocationInfo; 1698 1699 HRESULT hr = pDevice->pRTCallbacks->pfnAllocateCb(pDevice->hRTDevice.handle, &ddiAllocate); 1700 LogFlowFunc((" pfnAllocateCb returned %d, hKMResource 0x%X, hAllocation 0x%X", hr, ddiAllocate.hKMResource, ddiAllocationInfo.hAllocation)); 1701 AssertReturnStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr), false); 1702 1703 pDevice->hShaderAllocation = ddiAllocationInfo.hAllocation; 1704 pDevice->cbShaderAllocation = SVGA3D_MAX_SHADER_MEMORY_BYTES; 1705 pDevice->cbShaderAvailable = SVGA3D_MAX_SHADER_MEMORY_BYTES; 1684 if (!pDevice->pShadersKMResource) 1685 { 1686 uint32_t const cbAllocation = SVGA3D_MAX_SHADER_MEMORY_BYTES; 1687 pDevice->pShadersKMResource = vboxDXAllocateKMResource(pDevice, 0, shadersAllocationDesc, 1688 &cbAllocation, false); 1689 if (!pDevice->pShadersKMResource) 1690 return false; 1691 1692 pDevice->cbShaderAvailable = cbAllocation; 1706 1693 pDevice->offShaderFree = 0; 1694 1695 RTListAppend(&pDevice->listResources, &pDevice->pShadersKMResource->nodeResource); 1707 1696 } 1708 1697 … … 1772 1761 1773 1762 uint32_t const cbShaderTotal = pShader->cbShader + pShader->cbSignatures; 1774 if (pDevice-> cbShaderAllocation - pDevice->offShaderFree < cbShaderTotal)1763 if (pDevice->pShadersKMResource->AllocationDesc.cbAllocation - pDevice->offShaderFree < cbShaderTotal) 1775 1764 { 1776 1765 if (pDevice->cbShaderAvailable < cbShaderTotal) … … 1824 1813 D3DDDICB_LOCK ddiLock; 1825 1814 RT_ZERO(ddiLock); 1826 ddiLock.hAllocation = pDevice->hShaderAllocation;1815 ddiLock.hAllocation = vboxDXGetAllocation(pDevice->pShadersKMResource); 1827 1816 ddiLock.Flags.WriteOnly = 1; 1828 1817 HRESULT hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); … … 1838 1827 D3DDDICB_UNLOCK ddiUnlock; 1839 1828 ddiUnlock.NumAllocations = 1; 1840 ddiUnlock.phAllocations = & pDevice->hShaderAllocation;1829 ddiUnlock.phAllocations = &ddiLock.hAllocation; 1841 1830 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 1842 1831 } … … 1851 1840 1852 1841 vgpu10DefineShader(pDevice, pShader->uShaderId, pShader->enmShaderType, cbShaderTotal); 1853 vgpu10BindShader(pDevice, pShader->uShaderId, pDevice-> hShaderAllocation, pShader->offShader);1842 vgpu10BindShader(pDevice, pShader->uShaderId, pDevice->pShadersKMResource, pShader->offShader); 1854 1843 } 1855 1844 … … 1880 1869 pShader->gs.cbOutputStreamDecls = pShader->gs.NumEntries * sizeof(*pOutputStreamDecl); 1881 1870 pShader->gs.pCOAllocation = NULL; 1882 PVBOXDX COALLOCATIONpIter;1883 RTListForEach(&pDevice->listCOAStreamOutput, pIter, VBOXDX COALLOCATION,nodeAllocationsChain)1871 PVBOXDXKMRESOURCE pIter; 1872 RTListForEach(&pDevice->listCOAStreamOutput, pIter, VBOXDXKMRESOURCE, co.nodeAllocationsChain) 1884 1873 { 1885 1874 if (vboxDXCOABlockAlloc(pIter, pShader->gs.cbOutputStreamDecls, &pShader->gs.offStreamOutputDecls)) … … 1904 1893 D3DDDICB_LOCK ddiLock; 1905 1894 RT_ZERO(ddiLock); 1906 ddiLock.hAllocation = pShader->gs.pCOAllocation->hCOAllocation;1895 ddiLock.hAllocation = vboxDXGetAllocation(pShader->gs.pCOAllocation); 1907 1896 ddiLock.Flags.WriteOnly = 1; 1908 1897 HRESULT hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); … … 1927 1916 D3DDDICB_UNLOCK ddiUnlock; 1928 1917 ddiUnlock.NumAllocations = 1; 1929 ddiUnlock.phAllocations = & pShader->gs.pCOAllocation->hCOAllocation;1918 ddiUnlock.phAllocations = &ddiLock.hAllocation; 1930 1919 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 1931 1920 } 1932 1921 AssertReturnVoidStmt(SUCCEEDED(hr), 1933 vboxDXHandleFree(pDevice->hHTS hader, &pShader->uShaderId);1922 vboxDXHandleFree(pDevice->hHTStreamOutput, &pShader->gs.uStreamOutputId); 1934 1923 vboxDXDeviceSetError(pDevice, hr)); 1935 1924 … … 1937 1926 vgpu10DefineStreamOutputWithMob(pDevice, pShader->gs.uStreamOutputId, pShader->gs.NumEntries, pShader->gs.NumStrides, 1938 1927 pShader->gs.BufferStridesInBytes, pShader->gs.RasterizedStream); 1939 vgpu10BindStreamOutput(pDevice, pShader->gs.uStreamOutputId, pShader->gs.pCOAllocation ->hCOAllocation,1928 vgpu10BindStreamOutput(pDevice, pShader->gs.uStreamOutputId, pShader->gs.pCOAllocation, 1940 1929 pShader->gs.offStreamOutputDecls, pShader->gs.cbOutputStreamDecls); 1941 1930 } … … 2054 2043 pQuery->pCOAllocation = NULL; 2055 2044 uint32_t const cbAlloc = (pQuery->Query != D3D10DDI_QUERY_EVENT ? sizeof(uint32_t) : 0) + pQueryInfo->cbDataSvga; 2056 PVBOXDX COALLOCATIONpIter;2057 RTListForEach(&pDevice->listCOAQuery, pIter, VBOXDX COALLOCATION,nodeAllocationsChain)2045 PVBOXDXKMRESOURCE pIter; 2046 RTListForEach(&pDevice->listCOAQuery, pIter, VBOXDXKMRESOURCE, co.nodeAllocationsChain) 2058 2047 { 2059 2048 if (vboxDXCOABlockAlloc(pIter, cbAlloc, &pQuery->offQuery)) … … 2082 2071 D3DDDICB_LOCK ddiLock; 2083 2072 RT_ZERO(ddiLock); 2084 ddiLock.hAllocation = pQuery->pCOAllocation->hCOAllocation;2073 ddiLock.hAllocation = vboxDXGetAllocation(pQuery->pCOAllocation); 2085 2074 ddiLock.Flags.WriteOnly = 1; 2086 2075 HRESULT hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); … … 2091 2080 D3DDDICB_UNLOCK ddiUnlock; 2092 2081 ddiUnlock.NumAllocations = 1; 2093 ddiUnlock.phAllocations = & pQuery->pCOAllocation->hCOAllocation;2082 ddiUnlock.phAllocations = &ddiLock.hAllocation; 2094 2083 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 2095 2084 } … … 2097 2086 2098 2087 vgpu10DefineQuery(pDevice, pQuery->uQueryId, pQuery->svga.queryType, pQuery->svga.flags); 2099 vgpu10BindQuery(pDevice, pQuery->uQueryId, pQuery->pCOAllocation ->hCOAllocation);2088 vgpu10BindQuery(pDevice, pQuery->uQueryId, pQuery->pCOAllocation); 2100 2089 vgpu10SetQueryOffset(pDevice, pQuery->uQueryId, pQuery->offQuery); 2101 2090 } … … 2145 2134 { 2146 2135 pQuery->u64Value = ASMAtomicIncU64(&pDevice->u64MobFenceValue); 2147 vgpu10MobFence64(pDevice, pQuery->u64Value, pQuery->pCOAllocation ->hCOAllocation, pQuery->offQuery);2136 vgpu10MobFence64(pDevice, pQuery->u64Value, pQuery->pCOAllocation, pQuery->offQuery); 2148 2137 return; 2149 2138 } … … 2166 2155 D3DDDICB_LOCK ddiLock; 2167 2156 RT_ZERO(ddiLock); 2168 ddiLock.hAllocation = pQuery->pCOAllocation->hCOAllocation;2157 ddiLock.hAllocation = vboxDXGetAllocation(pQuery->pCOAllocation); 2169 2158 ddiLock.Flags.ReadOnly = 1; 2170 2159 HRESULT hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); … … 2175 2164 D3DDDICB_UNLOCK ddiUnlock; 2176 2165 ddiUnlock.NumAllocations = 1; 2177 ddiUnlock.phAllocations = & pQuery->pCOAllocation->hCOAllocation;2166 ddiUnlock.phAllocations = &ddiLock.hAllocation; 2178 2167 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 2179 2168 } … … 2204 2193 D3DDDICB_LOCK ddiLock; 2205 2194 RT_ZERO(ddiLock); 2206 ddiLock.hAllocation = pQuery->pCOAllocation->hCOAllocation;2195 ddiLock.hAllocation = vboxDXGetAllocation(pQuery->pCOAllocation); 2207 2196 ddiLock.Flags.ReadOnly = 1; 2208 2197 HRESULT hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); … … 2216 2205 D3DDDICB_UNLOCK ddiUnlock; 2217 2206 ddiUnlock.NumAllocations = 1; 2218 ddiUnlock.phAllocations = & pQuery->pCOAllocation->hCOAllocation;2207 ddiUnlock.phAllocations = &ddiLock.hAllocation; 2219 2208 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 2220 2209 } … … 2383 2372 2384 2373 void vboxDXSoSetTargets(PVBOXDX_DEVICE pDevice, uint32_t NumTargets, 2385 D3DKMT_HANDLE *paAllocations, uint32_t *paOffsets, uint32_t *paSizes)2386 { 2387 vgpu10SoSetTargets(pDevice, NumTargets, pa Allocations, paOffsets, paSizes);2374 PVBOXDXKMRESOURCE *papKMResources, uint32_t *paOffsets, uint32_t *paSizes) 2375 { 2376 vgpu10SoSetTargets(pDevice, NumTargets, papKMResources, paOffsets, paSizes); 2388 2377 } 2389 2378 … … 2397 2386 || pDstResource->Usage == D3D10_DDI_USAGE_STAGING, 2398 2387 vboxDXDeviceSetError(pDevice, E_INVALIDARG), false); 2388 2389 VBOXDXALLOCATIONDESC const *pDstAllocationDesc = vboxDXGetAllocationDesc(pDstResource); 2390 AssertReturn(pDstAllocationDesc, false); 2399 2391 2400 2392 SVGA3dBox destBox; … … 2410 2402 else 2411 2403 { 2412 vboxDXGetSubresourceBox(pDst Resource, DstSubresource, &destBox);2404 vboxDXGetSubresourceBox(pDstAllocationDesc, DstSubresource, &destBox); 2413 2405 } 2414 2406 … … 2417 2409 uint32_t cRows; 2418 2410 uint32_t Depth; 2419 vboxDXGetResourceBoxDimensions(pDst Resource, DstSubresource, &destBox, &offPixel, &cbRow, &cRows, &Depth);2411 vboxDXGetResourceBoxDimensions(pDstAllocationDesc, DstSubresource, &destBox, &offPixel, &cbRow, &cRows, &Depth); 2420 2412 2421 2413 UINT DstRowPitch; 2422 2414 UINT DstDepthPitch; 2423 vboxDXGetSubresourcePitch(pDst Resource, DstSubresource, &DstRowPitch, &DstDepthPitch);2415 vboxDXGetSubresourcePitch(pDstAllocationDesc, DstSubresource, &DstRowPitch, &DstDepthPitch); 2424 2416 2425 2417 /* The allocation contains all subresources, so get subresource offset too. */ 2426 offPixel += vboxDXGetSubresourceOffset(pDst Resource, DstSubresource);2427 //uint32_t const cbSubresource = vboxDXGetSubresourceSize(pDst Resource, DstSubresource);2418 offPixel += vboxDXGetSubresourceOffset(pDstAllocationDesc, DstSubresource); 2419 //uint32_t const cbSubresource = vboxDXGetSubresourceSize(pDstAllocationDesc, DstSubresource); 2428 2420 2429 2421 D3DDDICB_LOCK ddiLock; … … 2446 2438 } 2447 2439 2448 D3DKMT_HANDLE const hAllocation = vboxDXGetAllocation(pDstResource);2449 2450 2440 D3DDDICB_UNLOCK ddiUnlock; 2451 2441 ddiUnlock.NumAllocations = 1; 2452 ddiUnlock.phAllocations = & hAllocation;2442 ddiUnlock.phAllocations = &ddiLock.hAllocation; 2453 2443 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 2454 2444 if (SUCCEEDED(hr)) … … 2456 2446 /* Inform the host that the resource has been updated. */ 2457 2447 SVGA3dBox box; 2458 vboxDXGetSubresourceBox(pDst Resource, DstSubresource, &box);2459 vgpu10UpdateSubResource(pDevice, vboxDXGet Allocation(pDstResource), DstSubresource, &box);2448 vboxDXGetSubresourceBox(pDstAllocationDesc, DstSubresource, &box); 2449 vgpu10UpdateSubResource(pDevice, vboxDXGetKMResource(pDstResource), DstSubresource, &box); 2460 2450 return true; 2461 2451 } … … 2490 2480 } 2491 2481 2492 D3DKMT_HANDLE const hAllocation = vboxDXGetAllocation(pBuffer);2493 2494 2482 D3DDDICB_UNLOCK ddiUnlock; 2495 2483 ddiUnlock.NumAllocations = 1; 2496 ddiUnlock.phAllocations = & hAllocation;2484 ddiUnlock.phAllocations = &ddiLock.hAllocation; 2497 2485 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 2498 2486 if (SUCCEEDED(hr)) … … 2538 2526 2539 2527 pStagingResource->hRTResource.handle = 0; /* This resource has not been created by D3D runtime. */ 2540 int rc = vboxDXInitResourceData(pStagingResource, &createResource); 2541 if (RT_SUCCESS(rc)) 2542 { 2543 if (vboxDXCreateResource(pDevice, pStagingResource, &createResource)) 2544 return pStagingResource; 2545 } 2528 if (vboxDXCreateResource(pDevice, pStagingResource, &createResource)) 2529 return pStagingResource; 2530 2546 2531 RTMemFree(pStagingResource); 2547 2532 vboxDXDeviceSetError(pDevice, E_OUTOFMEMORY); … … 2601 2586 */ 2602 2587 2588 VBOXDXALLOCATIONDESC const *pDstAllocationDesc = vboxDXGetAllocationDesc(pDstResource); 2589 AssertReturnVoid(pDstAllocationDesc); 2590 2603 2591 /* 2604 2592 * Allocate a staging buffer big enough to hold the entire subresource. 2605 2593 */ 2606 uint32_t const cbStagingBuffer = vboxDXGetSubresourceSize(pDst Resource, DstSubresource);2594 uint32_t const cbStagingBuffer = vboxDXGetSubresourceSize(pDstAllocationDesc, DstSubresource); 2607 2595 PVBOXDX_RESOURCE pStagingBuffer = vboxDXCreateStagingBuffer(pDevice, cbStagingBuffer); 2608 2596 if (!pStagingBuffer) … … 2623 2611 } 2624 2612 else 2625 vboxDXGetSubresourceBox(pDst Resource, DstSubresource, &destBox);2613 vboxDXGetSubresourceBox(pDstAllocationDesc, DstSubresource, &destBox); 2626 2614 2627 2615 uint32_t offPixel; … … 2629 2617 UINT cRows; 2630 2618 UINT Depth; 2631 vboxDXGetResourceBoxDimensions(pDst Resource, DstSubresource, &destBox, &offPixel, &cbRow, &cRows, &Depth);2619 vboxDXGetResourceBoxDimensions(pDstAllocationDesc, DstSubresource, &destBox, &offPixel, &cbRow, &cRows, &Depth); 2632 2620 2633 2621 UINT cbRowPitch; 2634 2622 UINT cbDepthPitch; 2635 vboxDXGetSubresourcePitch(pDst Resource, DstSubresource, &cbRowPitch, &cbDepthPitch);2623 vboxDXGetSubresourcePitch(pDstAllocationDesc, DstSubresource, &cbRowPitch, &cbDepthPitch); 2636 2624 2637 2625 if (!vboxDXUpdateStagingBufferUP(pDevice, pStagingBuffer, … … 2651 2639 box.h = 1; 2652 2640 box.d = 1; 2653 vgpu10UpdateSubResource(pDevice, vboxDXGet Allocation(pStagingBuffer), 0, &box);2641 vgpu10UpdateSubResource(pDevice, vboxDXGetKMResource(pStagingBuffer), 0, &box); 2654 2642 2655 2643 /* Issue SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER */ … … 2657 2645 uint32 srcPitch = cbRowPitch; 2658 2646 uint32 srcSlicePitch = cbDepthPitch; 2659 vgpu10TransferFromBuffer(pDevice, vboxDXGet Allocation(pStagingBuffer), srcOffset, srcPitch, srcSlicePitch,2660 vboxDXGet Allocation(pDstResource), DstSubresource, destBox);2661 2662 RTListPrepend(&pDevice->listStagingResources, &pStagingBuffer->pKMResource-> nodeStaging);2647 vgpu10TransferFromBuffer(pDevice, vboxDXGetKMResource(pStagingBuffer), srcOffset, srcPitch, srcSlicePitch, 2648 vboxDXGetKMResource(pDstResource), DstSubresource, destBox); 2649 2650 RTListPrepend(&pDevice->listStagingResources, &pStagingBuffer->pKMResource->resource.nodeStaging); 2663 2651 } 2664 2652 … … 2670 2658 D3D10_DDI_MAP DDIMap, UINT Flags, D3D10DDI_MAPPED_SUBRESOURCE *pMappedSubResource) 2671 2659 { 2660 D3DKMT_HANDLE const hAllocation = vboxDXGetAllocation(pResource); 2661 AssertReturnVoidStmt(hAllocation, vboxDXDeviceSetError(pDevice, E_INVALIDARG)); 2662 2672 2663 /** @todo Need to take into account various variants Dynamic/Staging/ Discard/NoOverwrite, etc. */ 2673 2664 Assert(pResource->uMap == 0); /* Must not be already mapped */ 2674 2665 2675 if (dxIsAllocationInUse(pDevice, vboxDXGetAllocation(pResource)))2666 if (dxIsAllocationInUse(pDevice, hAllocation)) 2676 2667 { 2677 2668 vboxDXFlush(pDevice, true); … … 2687 2678 if (DDIMap == D3D10_DDI_MAP_READ || DDIMap == D3D10_DDI_MAP_READWRITE) 2688 2679 { 2689 vgpu10ReadbackSubResource(pDevice, vboxDXGet Allocation(pResource), Subresource);2680 vgpu10ReadbackSubResource(pDevice, vboxDXGetKMResource(pResource), Subresource); 2690 2681 vboxDXFlush(pDevice, true); 2691 2682 /* DXGK now knows that the allocation is in use. So pfnLockCb waits until the data is ready. */ … … 2697 2688 { 2698 2689 RT_ZERO(ddiLock); 2699 ddiLock.hAllocation = vboxDXGetAllocation(pResource);2690 ddiLock.hAllocation = hAllocation; 2700 2691 ddiLock.Flags.ReadOnly = DDIMap == D3D10_DDI_MAP_READ; 2701 2692 ddiLock.Flags.WriteOnly = DDIMap == D3D10_DDI_MAP_WRITE … … 2727 2718 pResource->pKMResource->hAllocation = ddiLock.hAllocation; 2728 2719 2729 uint32_t const offSubresource = vboxDXGetSubresourceOffset(pResource, Subresource); 2720 VBOXDXALLOCATIONDESC const *pAllocationDesc = vboxDXGetAllocationDesc(pResource); 2721 2722 uint32_t const offSubresource = vboxDXGetSubresourceOffset(pAllocationDesc, Subresource); 2730 2723 pMappedSubResource->pData = (uint8_t *)ddiLock.pData + offSubresource; 2731 vboxDXGetSubresourcePitch(p Resource, Subresource, &pMappedSubResource->RowPitch, &pMappedSubResource->DepthPitch);2724 vboxDXGetSubresourcePitch(pAllocationDesc, Subresource, &pMappedSubResource->RowPitch, &pMappedSubResource->DepthPitch); 2732 2725 2733 2726 pResource->DDIMap = DDIMap; … … 2741 2734 { 2742 2735 D3DKMT_HANDLE const hAllocation = vboxDXGetAllocation(pResource); 2736 AssertReturnVoidStmt(hAllocation, vboxDXDeviceSetError(pDevice, E_INVALIDARG)); 2743 2737 2744 2738 D3DDDICB_UNLOCK ddiUnlock; … … 2754 2748 /* Inform the host that the resource has been updated. */ 2755 2749 SVGA3dBox box; 2756 vboxDXGetSubresourceBox( pResource, Subresource, &box);2757 vgpu10UpdateSubResource(pDevice, vboxDXGet Allocation(pResource), Subresource, &box);2750 vboxDXGetSubresourceBox(vboxDXGetAllocationDesc(pResource), Subresource, &box); 2751 vgpu10UpdateSubResource(pDevice, vboxDXGetKMResource(pResource), Subresource, &box); 2758 2752 } 2759 2753 … … 2831 2825 } 2832 2826 2833 vgpu10DefineShaderResourceView(pDevice, pShaderResourceView->uShaderResourceViewId, vboxDXGet Allocation(pShaderResourceView->pResource),2827 vgpu10DefineShaderResourceView(pDevice, pShaderResourceView->uShaderResourceViewId, vboxDXGetKMResource(pShaderResourceView->pResource), 2834 2828 pShaderResourceView->svga.format, pShaderResourceView->svga.resourceDimension, 2835 2829 &pShaderResourceView->svga.desc); … … 2896 2890 } 2897 2891 2898 vgpu10DefineRenderTargetView(pDevice, pRenderTargetView->uRenderTargetViewId, vboxDXGet Allocation(pRenderTargetView->pResource),2892 vgpu10DefineRenderTargetView(pDevice, pRenderTargetView->uRenderTargetViewId, vboxDXGetKMResource(pRenderTargetView->pResource), 2899 2893 pRenderTargetView->svga.format, pRenderTargetView->svga.resourceDimension, 2900 2894 &pRenderTargetView->svga.desc); … … 2965 2959 pDepthStencilView->svga.flags = pDepthStencilView->Flags; 2966 2960 2967 vgpu10DefineDepthStencilView(pDevice, pDepthStencilView->uDepthStencilViewId, vboxDXGet Allocation(pDepthStencilView->pResource),2961 vgpu10DefineDepthStencilView(pDevice, pDepthStencilView->uDepthStencilViewId, vboxDXGetKMResource(pDepthStencilView->pResource), 2968 2962 pDepthStencilView->svga.format, pDepthStencilView->svga.resourceDimension, 2969 2963 pDepthStencilView->svga.mipSlice, pDepthStencilView->svga.firstArraySlice, … … 3082 3076 if (pResource) 3083 3077 { 3084 uint32_t const cMaxConstants = pResource-> AllocationDesc.cbAllocation / (4 * sizeof(UINT));3078 uint32_t const cMaxConstants = pResource->pKMResource->AllocationDesc.cbAllocation / (4 * sizeof(UINT)); 3085 3079 uint32_t const FirstConstant = pFirstConstant ? pFirstConstant[i] : 0; 3086 3080 uint32_t NumConstants = pNumConstants ? pNumConstants[i] : cMaxConstants; … … 3102 3096 LogFunc(("type %d, slot %d, first %d, num %d, cbAllocation %d", 3103 3097 enmShaderType, StartSlot + i, pCBS->aFirstConstant[StartSlot + i], pCBS->aNumConstants[StartSlot + i], 3104 pResource ? pResource-> AllocationDesc.cbAllocation : -1));3098 pResource ? pResource->pKMResource->AllocationDesc.cbAllocation : -1)); 3105 3099 } 3106 3100 … … 3139 3133 else 3140 3134 { 3141 vboxDXGetSubresourceBox( pSrcResource, SrcSubresource, &srcBox);3142 } 3143 3144 vgpu10ResourceCopyRegion(pDevice, vboxDXGet Allocation(pDstResource), DstSubresource,3145 DstX, DstY, DstZ, vboxDXGet Allocation(pSrcResource), SrcSubresource, srcBox);3135 vboxDXGetSubresourceBox(vboxDXGetAllocationDesc(pSrcResource), SrcSubresource, &srcBox); 3136 } 3137 3138 vgpu10ResourceCopyRegion(pDevice, vboxDXGetKMResource(pDstResource), DstSubresource, 3139 DstX, DstY, DstZ, vboxDXGetKMResource(pSrcResource), SrcSubresource, srcBox); 3146 3140 } 3147 3141 … … 3149 3143 void vboxDXResourceCopy(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pDstResource, PVBOXDX_RESOURCE pSrcResource) 3150 3144 { 3151 vgpu10ResourceCopy(pDevice, vboxDXGet Allocation(pDstResource), vboxDXGetAllocation(pSrcResource));3145 vgpu10ResourceCopy(pDevice, vboxDXGetKMResource(pDstResource), vboxDXGetKMResource(pSrcResource)); 3152 3146 } 3153 3147 … … 3157 3151 { 3158 3152 SVGA3dSurfaceFormat const copyFormat = vboxDXDxgiToSvgaFormat(ResolveFormat); 3159 vgpu10ResolveCopy(pDevice, vboxDXGet Allocation(pDstResource), DstSubresource,3160 vboxDXGet Allocation(pSrcResource), SrcSubresource, copyFormat);3153 vgpu10ResolveCopy(pDevice, vboxDXGetKMResource(pDstResource), DstSubresource, 3154 vboxDXGetKMResource(pSrcResource), SrcSubresource, copyFormat); 3161 3155 } 3162 3156 … … 3243 3237 if (!pShaderResourceView->fDefined) 3244 3238 { 3245 vgpu10DefineShaderResourceView(pDevice, pShaderResourceView->uShaderResourceViewId, vboxDXGet Allocation(pShaderResourceView->pResource),3239 vgpu10DefineShaderResourceView(pDevice, pShaderResourceView->uShaderResourceViewId, vboxDXGetKMResource(pShaderResourceView->pResource), 3246 3240 pShaderResourceView->svga.format, pShaderResourceView->svga.resourceDimension, 3247 3241 &pShaderResourceView->svga.desc); … … 3255 3249 if (!pRenderTargetView->fDefined) 3256 3250 { 3257 vgpu10DefineRenderTargetView(pDevice, pRenderTargetView->uRenderTargetViewId, vboxDXGet Allocation(pRenderTargetView->pResource),3251 vgpu10DefineRenderTargetView(pDevice, pRenderTargetView->uRenderTargetViewId, vboxDXGetKMResource(pRenderTargetView->pResource), 3258 3252 pRenderTargetView->svga.format, pRenderTargetView->svga.resourceDimension, 3259 3253 &pRenderTargetView->svga.desc); … … 3267 3261 if (!pDepthStencilView->fDefined) 3268 3262 { 3269 vgpu10DefineDepthStencilView(pDevice, pDepthStencilView->uDepthStencilViewId, vboxDXGet Allocation(pDepthStencilView->pResource),3263 vgpu10DefineDepthStencilView(pDevice, pDepthStencilView->uDepthStencilViewId, vboxDXGetKMResource(pDepthStencilView->pResource), 3270 3264 pDepthStencilView->svga.format, pDepthStencilView->svga.resourceDimension, 3271 3265 pDepthStencilView->svga.mipSlice, pDepthStencilView->svga.firstArraySlice, … … 3280 3274 if (!pUnorderedAccessView->fDefined) 3281 3275 { 3282 vgpu10DefineUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId, vboxDXGet Allocation(pUnorderedAccessView->pResource),3276 vgpu10DefineUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId, vboxDXGetKMResource(pUnorderedAccessView->pResource), 3283 3277 pUnorderedAccessView->svga.format, pUnorderedAccessView->svga.resourceDimension, 3284 3278 pUnorderedAccessView->svga.desc); … … 3293 3287 { 3294 3288 vgpu10DefineVideoDecoderOutputView(pDevice, pVDOV->uVideoDecoderOutputViewId, 3295 vboxDXGet Allocation(pVDOV->pResource),3289 vboxDXGetKMResource(pVDOV->pResource), 3296 3290 pVDOV->svga.desc); 3297 3291 pVDOV->fDefined = true; … … 3305 3299 { 3306 3300 vgpu10DefineVideoProcessorInputView(pDevice, pVPIV->uVideoProcessorInputViewId, 3307 vboxDXGet Allocation(pVPIV->pResource),3301 vboxDXGetKMResource(pVPIV->pResource), 3308 3302 pVPIV->svga.ContentDesc, pVPIV->svga.VPIVDesc); 3309 3303 pVPIV->fDefined = true; … … 3317 3311 { 3318 3312 vgpu10DefineVideoProcessorOutputView(pDevice, pVPOV->uVideoProcessorOutputViewId, 3319 vboxDXGet Allocation(pVPOV->pResource),3313 vboxDXGetKMResource(pVPOV->pResource), 3320 3314 pVPOV->svga.ContentDesc, pVPOV->svga.VPOVDesc); 3321 3315 pVPOV->fDefined = true; … … 3594 3588 } 3595 3589 3596 vgpu10DefineUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId, vboxDXGet Allocation(pUnorderedAccessView->pResource),3590 vgpu10DefineUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId, vboxDXGetKMResource(pUnorderedAccessView->pResource), 3597 3591 pUnorderedAccessView->svga.format, pUnorderedAccessView->svga.resourceDimension, 3598 3592 pUnorderedAccessView->svga.desc); … … 3681 3675 { 3682 3676 vboxDXSetupPipeline(pDevice); 3683 vgpu10DispatchIndirect(pDevice, vboxDXGet Allocation(pResource), AlignedByteOffsetForArgs);3677 vgpu10DispatchIndirect(pDevice, vboxDXGetKMResource(pResource), AlignedByteOffsetForArgs); 3684 3678 } 3685 3679 … … 3687 3681 void vboxDXCopyStructureCount(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pDstBuffer, UINT DstAlignedByteOffset, PVBOXDXUNORDEREDACCESSVIEW pSrcView) 3688 3682 { 3689 vgpu10CopyStructureCount(pDevice, pSrcView->uUnorderedAccessViewId, vboxDXGet Allocation(pDstBuffer), DstAlignedByteOffset);3683 vgpu10CopyStructureCount(pDevice, pSrcView->uUnorderedAccessViewId, vboxDXGetKMResource(pDstBuffer), DstAlignedByteOffset); 3690 3684 } 3691 3685 … … 3700 3694 3701 3695 SVGA3dBox boxSrc; 3702 vboxDXGetSubresourceBox( pSrcResource, SrcSubresource, &boxSrc); /* Entire subresource. */3696 vboxDXGetSubresourceBox(vboxDXGetAllocationDesc(pSrcResource), SrcSubresource, &boxSrc); /* Entire subresource. */ 3703 3697 3704 3698 SVGA3dBox boxDest; … … 3712 3706 SVGA3dDXPresentBltMode mode = 0; 3713 3707 3714 vgpu10PresentBlt(pDevice, vboxDXGet Allocation(pSrcResource), SrcSubresource, vboxDXGetAllocation(pDstResource), DstSubresource,3708 vgpu10PresentBlt(pDevice, vboxDXGetKMResource(pSrcResource), SrcSubresource, vboxDXGetKMResource(pDstResource), DstSubresource, 3715 3709 boxSrc, boxDest, mode); 3716 3710 return S_OK; … … 3749 3743 /* Move staging resources to the deferred destruction queue. */ 3750 3744 PVBOXDXKMRESOURCE pKMResource, pNextKMResource; 3751 RTListForEachSafe(&pDevice->listStagingResources, pKMResource, pNextKMResource, VBOXDXKMRESOURCE, nodeStaging)3752 { 3753 RTListNodeRemove(&pKMResource-> nodeStaging);3754 3755 PVBOXDX_RESOURCE pStagingResource = pKMResource-> pResource;3756 pKMResource-> pResource = NULL;3745 RTListForEachSafe(&pDevice->listStagingResources, pKMResource, pNextKMResource, VBOXDXKMRESOURCE, resource.nodeStaging) 3746 { 3747 RTListNodeRemove(&pKMResource->resource.nodeStaging); 3748 3749 PVBOXDX_RESOURCE pStagingResource = pKMResource->resource.pResource; 3750 pKMResource->resource.pResource = NULL; 3757 3751 3758 3752 Assert(pStagingResource->pKMResource == pKMResource); … … 3774 3768 { 3775 3769 RTListNodeRemove(&pKMResource->nodeResource); 3776 3777 D3DDDICB_DEALLOCATE ddiDeallocate; 3778 RT_ZERO(ddiDeallocate); 3779 //ddiDeallocate.hResource = NULL; 3780 ddiDeallocate.NumAllocations = 1; 3781 ddiDeallocate.HandleList = &pKMResource->hAllocation; 3782 3783 HRESULT hr = pDevice->pRTCallbacks->pfnDeallocateCb(pDevice->hRTDevice.handle, &ddiDeallocate); 3784 LogFlowFunc(("pfnDeallocateCb returned %d", hr)); 3785 AssertStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr)); 3786 3787 RTMemFree(pKMResource); 3770 vboxDXDeallocateKMResource(pDevice, pKMResource); 3788 3771 } 3789 3772 } … … 4065 4048 PVBOXDXKMRESOURCE pKMResource, pNextKMResource; 4066 4049 RTListForEachSafe(&pDevice->listResources, pKMResource, pNextKMResource, VBOXDXKMRESOURCE, nodeResource) 4067 vboxDXDestroyResource(pDevice, pKMResource->pResource); 4050 { 4051 if (pKMResource->AllocationDesc.enmAllocationType == VBOXDXALLOCATIONTYPE_SURFACE) 4052 vboxDXDestroyResource(pDevice, pKMResource->resource.pResource); 4053 } 4068 4054 4069 4055 dxDestroyDeferredResources(pDevice); … … 4077 4063 vboxDXDestroyQuery(pDevice, pQuery); 4078 4064 4079 PVBOXDX COALLOCATIONpCOA, pNextCOA;4080 RTListForEachSafe(&pDevice->listCOAQuery, pCOA, pNextCOA, VBOXDX COALLOCATION,nodeAllocationsChain)4065 PVBOXDXKMRESOURCE pCOA, pNextCOA; 4066 RTListForEachSafe(&pDevice->listCOAQuery, pCOA, pNextCOA, VBOXDXKMRESOURCE, co.nodeAllocationsChain) 4081 4067 vboxDXDestroyCOAllocation(pDevice, pCOA); 4082 RTListForEachSafe(&pDevice->listCOAStreamOutput, pCOA, pNextCOA, VBOXDX COALLOCATION,nodeAllocationsChain)4068 RTListForEachSafe(&pDevice->listCOAStreamOutput, pCOA, pNextCOA, VBOXDXKMRESOURCE, co.nodeAllocationsChain) 4083 4069 vboxDXDestroyCOAllocation(pDevice, pCOA); 4084 4070 4085 if (pDevice->hShaderAllocation) 4086 { 4087 D3DDDICB_DEALLOCATE ddiDeallocate; 4088 RT_ZERO(ddiDeallocate); 4089 ddiDeallocate.NumAllocations = 1; 4090 ddiDeallocate.HandleList = &pDevice->hShaderAllocation; 4091 4092 HRESULT hr = pDevice->pRTCallbacks->pfnDeallocateCb(pDevice->hRTDevice.handle, &ddiDeallocate); 4093 LogFlowFunc(("pfnDeallocateCb returned %d", hr)); 4094 AssertStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr)); 4095 4096 pDevice->hShaderAllocation = 0; 4071 if (pDevice->pShadersKMResource) 4072 { 4073 RTListNodeRemove(&pDevice->pShadersKMResource->nodeResource); 4074 vboxDXDeallocateKMResource(pDevice, pDevice->pShadersKMResource); 4075 pDevice->pShadersKMResource = 0; 4097 4076 } 4098 4077 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.h
r106061 r108880 5 5 6 6 /* 7 * Copyright (C) 2011-202 4Oracle and/or its affiliates.7 * Copyright (C) 2011-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 117 117 118 118 /* 119 * A Context Object Allocation holds up to VBOXDX_COALLOCATION_MAX_OBJECTS objects (queries, etc)119 * A Context Object Allocation (COA) holds up to VBOXDX_COALLOCATION_MAX_OBJECTS objects (queries, etc) 120 120 */ 121 121 #define VBOXDX_COALLOCATION_MAX_OBJECTS (64) /* Use a 64 bit field as free bitmap. */ 122 typedef struct VBOXDXCOALLOCATION /* Allocation for context objects (query, etc). */ 123 { 124 RTLISTNODE nodeAllocationsChain; /* Allocations can be chained. */ 125 D3DKMT_HANDLE hCOAllocation; /* Allocation handle. */ 126 uint32_t cbAllocation; /* Size of this allocation. */ 127 uint64_t u64Bitmap; /* Bitmap of allocated blocks. */ 128 uint32_t aOffset[VBOXDX_COALLOCATION_MAX_OBJECTS]; /* Start offsets of blocks. */ 129 } VBOXDXCOALLOCATION, *PVBOXDXCOALLOCATION; 122 123 /* 124 * This structure is allocated by the driver. It is used for accounting of allocations 125 * and for storing information which might be needed after the resource is destroyed by D3D runtime. 126 * KM stands for Kernel Mode. 127 */ 128 typedef struct VBOXDXKMRESOURCE 129 { 130 RTLISTNODE nodeResource; /* VBOXDX_DEVICE::listResources, listDestroyedResources. */ 131 D3DKMT_HANDLE hAllocation; 132 struct 133 { 134 uint32_t fOpened : 1; 135 uint32_t fReserved : 31; 136 } flags; 137 VBOXDXALLOCATIONDESC AllocationDesc; 138 union 139 { 140 struct /* D3D resource */ 141 { 142 struct VBOXDX_RESOURCE *pResource; /* The structure allocated by D3D runtime. */ 143 RTLISTNODE nodeStaging; /* VBOXDX_DEVICE::listStagingResources if this resource is a staging buffer. */ 144 } resource; 145 struct /* Context object allocation */ 146 { 147 RTLISTNODE nodeAllocationsChain; /* CO allocations can be chained. */ 148 uint64_t u64Bitmap; /* Bitmap of allocated blocks. */ 149 uint32_t aOffset[VBOXDX_COALLOCATION_MAX_OBJECTS]; /* Start offsets of blocks. */ 150 } co; 151 }; 152 } VBOXDXKMRESOURCE, *PVBOXDXKMRESOURCE; 130 153 131 154 typedef struct VBOXDXSHADER … … 149 172 uint32_t offStreamOutputDecls; /* Offset of the declarations in the CO allocation. */ 150 173 uint32_t cbOutputStreamDecls; 151 PVBOXDX COALLOCATIONpCOAllocation;174 PVBOXDXKMRESOURCE pCOAllocation; 152 175 } gs; /* For GS. */ 153 176 /* shader bytecode */ … … 179 202 uint32_t uQueryId; 180 203 uint32_t offQuery; /* Offset of the query in the query allocation. */ 181 PVBOXDX COALLOCATIONpCOAllocation;204 PVBOXDXKMRESOURCE pCOAllocation; 182 205 uint64_t u64Value; 183 206 /* Result for queries in SIGNALED state. */ 184 207 } VBOXDXQUERY, *PVBOXDXQUERY; 185 208 186 /*187 * This structure is allocated by the driver. It is used for accounting of resources188 * and for storing information which might be needed after the resource is destroyed by runtime.189 * KM stands for Kernel Mode.190 */191 typedef struct VBOXDXKMRESOURCE192 {193 RTLISTNODE nodeResource; /* VBOXDX_DEVICE::listResources, listDestroyedResources. */194 struct VBOXDX_RESOURCE *pResource; /* The structure allocated by D3D runtime. */195 D3DKMT_HANDLE hAllocation;196 RTLISTNODE nodeStaging; /* VBOXDX_DEVICE::listStagingResources if this resource is a staging buffer. */197 } VBOXDXKMRESOURCE, *PVBOXDXKMRESOURCE;198 199 209 typedef struct VBOXDX_RESOURCE 200 210 { 201 211 PVBOXDXKMRESOURCE pKMResource; 202 //RTLISTNODE nodeResource; /* VBOXDX_DEVICE::listResources. */203 212 D3D10DDI_HRTRESOURCE hRTResource; 204 213 D3D10DDIRESOURCE_TYPE ResourceDimension; 205 214 D3D10_DDI_RESOURCE_USAGE Usage; 206 VBOXDXALLOCATIONDESC AllocationDesc;207 215 UINT cSubresources; 208 216 union … … 581 589 582 590 /* Shaders */ 583 D3DKMT_HANDLE hShaderAllocation; /* Shader allocation for this context. */ 584 uint32_t cbShaderAllocation; /* Size of the shader's allocation: SVGA3D_MAX_SHADER_MEMORY_BYTES. */ 591 PVBOXDXKMRESOURCE pShadersKMResource; /* Shader's allocation: SVGA3D_MAX_SHADER_MEMORY_BYTES. */ 585 592 uint32_t cbShaderAvailable; /* How many bytes is free in the shader's allocation. */ 586 593 uint32_t offShaderFree; /* Offset of the next free byte in the shader's allocation. */ … … 589 596 /* Queries */ 590 597 RTLISTANCHOR listQueries; /* All queries of this device, to be able to repack them in the allocation. */ 591 RTLISTANCHOR listCOAQuery; /* List of VBOXDXCOALLOCATIONfor all query types. */598 RTLISTANCHOR listCOAQuery; /* List of COA VBOXDXKMRESOURCEs for all query types. */ 592 599 uint64_t volatile u64MobFenceValue; 593 600 594 601 /* Stream output declarations */ 595 RTLISTANCHOR listCOAStreamOutput; /* List of VBOXDXCOALLOCATIONfor stream output declarations. */602 RTLISTANCHOR listCOAStreamOutput; /* List of COA VBOXDXKMRESOURCEs for stream output declarations. */ 596 603 597 604 /* Pipeline state. */ … … 614 621 struct 615 622 { 616 D3DKMT_HANDLE hAllocation; /* For querying capabilities of the host device. */ 617 uint32_t cbAllocation; 623 PVBOXDXKMRESOURCE pKMResource; /* For querying capabilities of the host device. */ 618 624 uint64_t volatile u64MobFenceValue; /* Fence value for host queries. */ 619 625 … … 645 651 void vboxDXCommandBufferCommit(PVBOXDX_DEVICE pDevice); 646 652 647 void vboxDXStorePatchLocation(PVBOXDX_DEVICE pDevice, void *pvPatch, VBOXDXALLOCATIONTYPE enmAllocationType, 648 D3DKMT_HANDLE hAllocation, uint32_t offAllocation, bool fWriteOperation); 653 void vboxDXStorePatchLocation(PVBOXDX_DEVICE pDevice, void *pvPatch, PVBOXDXKMRESOURCE pKMResource, 654 uint32_t offAllocation, bool fWriteOperation); 655 656 typedef void FNVBOXDXINITALLOCATIONDESC(VBOXDXALLOCATIONDESC *pDesc, void const *pvInitData); 657 typedef FNVBOXDXINITALLOCATIONDESC *PFNVBOXDXINITALLOCATIONDESC; 658 PVBOXDXKMRESOURCE vboxDXAllocateKMResource(PVBOXDX_DEVICE pDevice, HANDLE hResource, 659 PFNVBOXDXINITALLOCATIONDESC pfnInitAllocationDesc, 660 void const *pvInitData, bool fZero); 661 void vboxDXDeallocateKMResource(PVBOXDX_DEVICE pDevice, PVBOXDXKMRESOURCE pKMResource); 649 662 650 663 SVGA3dSurfaceFormat vboxDXDxgiToSvgaFormat(DXGI_FORMAT enmDxgiFormat); 651 664 652 int vboxDXInitResourceData(PVBOXDX_RESOURCE pResource, const D3D11DDIARG_CREATERESOURCE *pCreateResource);653 665 bool vboxDXCreateResource(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pResource, 654 666 const D3D11DDIARG_CREATERESOURCE *pCreateResource); … … 711 723 D3D10_DDI_MAP DDIMap, UINT Flags, D3D10DDI_MAPPED_SUBRESOURCE *pMappedSubResource); 712 724 void vboxDXResourceUnmap(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pResource, UINT Subresource); 713 void vboxDXSoSetTargets(PVBOXDX_DEVICE pDevice, uint32_t NumTargets, D3DKMT_HANDLE *paAllocations, uint32_t *paOffsets, uint32_t *paSizes);725 void vboxDXSoSetTargets(PVBOXDX_DEVICE pDevice, uint32_t NumTargets, PVBOXDXKMRESOURCE *papKMResources, uint32_t *paOffsets, uint32_t *paSizes); 714 726 void vboxDXCreateShaderResourceView(PVBOXDX_DEVICE pDevice, PVBOXDXSHADERRESOURCEVIEW pShaderResourceView); 715 727 void vboxDXGenMips(PVBOXDX_DEVICE pDevice, PVBOXDXSHADERRESOURCEVIEW pShaderResourceView); … … 833 845 } 834 846 847 DECLINLINE(PVBOXDXKMRESOURCE) vboxDXGetKMResource(PVBOXDX_RESOURCE pResource) 848 { 849 return pResource ? pResource->pKMResource : 0; 850 } 851 852 DECLINLINE(D3DKMT_HANDLE) vboxDXGetAllocation(PVBOXDXKMRESOURCE pKMResource) 853 { 854 return pKMResource ? pKMResource->hAllocation : 0; 855 } 856 835 857 DECLINLINE(D3DKMT_HANDLE) vboxDXGetAllocation(PVBOXDX_RESOURCE pResource) 836 858 { 837 return pResource ? pResource->pKMResource->hAllocation: 0;859 return pResource ? vboxDXGetAllocation(pResource->pKMResource) : 0; 838 860 } 839 861 862 DECLINLINE(VBOXDXALLOCATIONDESC *) vboxDXGetAllocationDesc(PVBOXDXKMRESOURCE pKMResource) 863 { 864 return pKMResource ? &pKMResource->AllocationDesc : 0; 865 } 866 867 DECLINLINE(VBOXDXALLOCATIONDESC *) vboxDXGetAllocationDesc(PVBOXDX_RESOURCE pResource) 868 { 869 return pResource ? vboxDXGetAllocationDesc(pResource->pKMResource) : 0; 870 } 871 840 872 #endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_wddm_dx_VBoxDX_h */ -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXCmd.cpp
r106061 r108880 5 5 6 6 /* 7 * Copyright (C) 2022-202 4Oracle and/or its affiliates.7 * Copyright (C) 2022-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 656 656 int vgpu10BindStreamOutput(PVBOXDX_DEVICE pDevice, 657 657 SVGA3dStreamOutputId soid, 658 D3DKMT_HANDLE hAllocation,658 PVBOXDXKMRESOURCE pKMResource, 659 659 uint32 offsetInBytes, 660 660 uint32 sizeInBytes) … … 671 671 SET_CMD_FIELD(sizeInBytes); 672 672 673 vboxDXStorePatchLocation(pDevice, &cmd->mobid, VBOXDXALLOCATIONTYPE_CO,674 hAllocation,offsetInBytes, true);673 vboxDXStorePatchLocation(pDevice, &cmd->mobid, pKMResource, 674 offsetInBytes, true); 675 675 676 676 vboxDXCommandBufferCommit(pDevice); … … 712 712 int vgpu10BindShader(PVBOXDX_DEVICE pDevice, 713 713 uint32_t shid, 714 D3DKMT_HANDLE hAllocation,714 PVBOXDXKMRESOURCE pKMResource, 715 715 uint32_t offsetInBytes) 716 716 { … … 726 726 SET_CMD_FIELD(offsetInBytes); 727 727 728 vboxDXStorePatchLocation(pDevice, &cmd->mobid, VBOXDXALLOCATIONTYPE_SHADERS,729 hAllocation,offsetInBytes, true);728 vboxDXStorePatchLocation(pDevice, &cmd->mobid, pKMResource, 729 offsetInBytes, true); 730 730 731 731 vboxDXCommandBufferCommit(pDevice); … … 753 753 uint32_t startBuffer, 754 754 uint32_t numBuffers, 755 D3DKMT_HANDLE *paAllocations,755 PVBOXDXKMRESOURCE *papKMResources, 756 756 const UINT *paStrides, 757 757 const UINT *paOffsets) … … 773 773 pVertexBuffer->stride = paStrides[i]; 774 774 pVertexBuffer->offset = paOffsets[i]; 775 vboxDXStorePatchLocation(pDevice, &pVertexBuffer->sid, VBOXDXALLOCATIONTYPE_SURFACE,776 paAllocations[i],0, false);775 vboxDXStorePatchLocation(pDevice, &pVertexBuffer->sid, papKMResources[i], 776 0, false); 777 777 } 778 778 … … 782 782 783 783 int vgpu10SetIndexBuffer(PVBOXDX_DEVICE pDevice, 784 D3DKMT_HANDLE hAllocation,784 PVBOXDXKMRESOURCE pKMResource, 785 785 SVGA3dSurfaceFormat format, 786 786 uint32_t offset) … … 795 795 SET_CMD_FIELD(format); 796 796 SET_CMD_FIELD(offset); 797 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,798 hAllocation,0, false);797 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 798 0, false); 799 799 800 800 vboxDXCommandBufferCommit(pDevice); … … 804 804 int vgpu10SoSetTargets(PVBOXDX_DEVICE pDevice, 805 805 uint32_t numTargets, 806 D3DKMT_HANDLE *paAllocations,806 PVBOXDXKMRESOURCE *papKMResources, 807 807 uint32_t *paOffsets, 808 808 uint32_t *paSizes) … … 824 824 pSoTarget->offset = paOffsets[i]; 825 825 pSoTarget->sizeInBytes = paSizes[i]; 826 vboxDXStorePatchLocation(pDevice, &pSoTarget->sid, VBOXDXALLOCATIONTYPE_SURFACE,827 paAllocations[i],0, true);826 vboxDXStorePatchLocation(pDevice, &pSoTarget->sid, papKMResources[i], 827 0, true); 828 828 } 829 829 … … 835 835 int vgpu10DefineShaderResourceView(PVBOXDX_DEVICE pDevice, 836 836 SVGA3dShaderResourceViewId shaderResourceViewId, 837 D3DKMT_HANDLE hAllocation,837 PVBOXDXKMRESOURCE pKMResource, 838 838 SVGA3dSurfaceFormat format, 839 839 SVGA3dResourceType resourceDimension, … … 851 851 SET_CMD_FIELD(resourceDimension); 852 852 cmd->desc = *pDesc; 853 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,854 hAllocation,0, false);853 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 854 0, false); 855 855 856 856 vboxDXCommandBufferCommit(pDevice); … … 893 893 int vgpu10DefineRenderTargetView(PVBOXDX_DEVICE pDevice, 894 894 SVGA3dRenderTargetViewId renderTargetViewId, 895 D3DKMT_HANDLE hAllocation,895 PVBOXDXKMRESOURCE pKMResource, 896 896 SVGA3dSurfaceFormat format, 897 897 SVGA3dResourceType resourceDimension, … … 909 909 SET_CMD_FIELD(resourceDimension); 910 910 cmd->desc = *pDesc; 911 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,912 hAllocation,0, true);911 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 912 0, true); 913 913 914 914 vboxDXCommandBufferCommit(pDevice); … … 1026 1026 int vgpu10DefineDepthStencilView(PVBOXDX_DEVICE pDevice, 1027 1027 SVGA3dDepthStencilViewId depthStencilViewId, 1028 D3DKMT_HANDLE hAllocation,1028 PVBOXDXKMRESOURCE pKMResource, 1029 1029 SVGA3dSurfaceFormat format, 1030 1030 SVGA3dResourceType resourceDimension, … … 1048 1048 SET_CMD_FIELD(arraySize); 1049 1049 SET_CMD_FIELD(flags); 1050 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1051 hAllocation,0, true);1050 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1051 0, true); 1052 1052 1053 1053 vboxDXCommandBufferCommit(pDevice); … … 1146 1146 uint32 slot, 1147 1147 SVGA3dShaderType type, 1148 D3DKMT_HANDLE hAllocation,1148 PVBOXDXKMRESOURCE pKMResource, 1149 1149 uint32 offsetInBytes, 1150 1150 uint32 sizeInBytes) … … 1161 1161 SET_CMD_FIELD(offsetInBytes); 1162 1162 SET_CMD_FIELD(sizeInBytes); 1163 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1164 hAllocation,0, false);1163 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1164 0, false); 1165 1165 1166 1166 vboxDXCommandBufferCommit(pDevice); … … 1170 1170 1171 1171 int vgpu10UpdateSubResource(PVBOXDX_DEVICE pDevice, 1172 D3DKMT_HANDLE hAllocation,1172 PVBOXDXKMRESOURCE pKMResource, 1173 1173 uint32 subResource, 1174 1174 const SVGA3dBox *pBox) … … 1183 1183 SET_CMD_FIELD(subResource); 1184 1184 cmd->box = *pBox; 1185 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1186 hAllocation,0, true);1185 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1186 0, true); 1187 1187 1188 1188 vboxDXCommandBufferCommit(pDevice); … … 1192 1192 1193 1193 int vgpu10ReadbackSubResource(PVBOXDX_DEVICE pDevice, 1194 D3DKMT_HANDLE hAllocation,1194 PVBOXDXKMRESOURCE pKMResource, 1195 1195 uint32 subResource) 1196 1196 { … … 1207 1207 * before getting the allocation data in pfnLockCb. 1208 1208 */ 1209 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1210 hAllocation,0, true);1209 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1210 0, true); 1211 1211 1212 1212 vboxDXCommandBufferCommit(pDevice); … … 1216 1216 1217 1217 int vgpu10TransferFromBuffer(PVBOXDX_DEVICE pDevice, 1218 D3DKMT_HANDLE hSrcAllocation,1218 PVBOXDXKMRESOURCE pSrcKMResource, 1219 1219 uint32 srcOffset, 1220 1220 uint32 srcPitch, 1221 1221 uint32 srcSlicePitch, 1222 D3DKMT_HANDLE hDstAllocation,1222 PVBOXDXKMRESOURCE pDstKMResource, 1223 1223 uint32 destSubResource, 1224 1224 SVGA3dBox const &destBox) … … 1237 1237 SET_CMD_FIELD(destSubResource); 1238 1238 SET_CMD_FIELD(destBox); 1239 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, VBOXDXALLOCATIONTYPE_SURFACE,1240 hSrcAllocation,0, false);1241 vboxDXStorePatchLocation(pDevice, &cmd->destSid, VBOXDXALLOCATIONTYPE_SURFACE,1242 hDstAllocation,0, true);1239 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, pSrcKMResource, 1240 0, false); 1241 vboxDXStorePatchLocation(pDevice, &cmd->destSid, pDstKMResource, 1242 0, true); 1243 1243 1244 1244 vboxDXCommandBufferCommit(pDevice); … … 1248 1248 1249 1249 int vgpu10ResourceCopyRegion(PVBOXDX_DEVICE pDevice, 1250 D3DKMT_HANDLE hDstAllocation,1250 PVBOXDXKMRESOURCE pDstKMResource, 1251 1251 uint32 dstSubResource, 1252 1252 uint32 dstX, 1253 1253 uint32 dstY, 1254 1254 uint32 dstZ, 1255 D3DKMT_HANDLE hSrcAllocation,1255 PVBOXDXKMRESOURCE pSrcKMResource, 1256 1256 uint32 srcSubResource, 1257 1257 SVGA3dBox const &srcBox) … … 1277 1277 cmd->box.srcz = srcBox.z; 1278 1278 1279 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, VBOXDXALLOCATIONTYPE_SURFACE,1280 hDstAllocation,0, true);1281 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, VBOXDXALLOCATIONTYPE_SURFACE,1282 hSrcAllocation,0, false);1279 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, pDstKMResource, 1280 0, true); 1281 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, pSrcKMResource, 1282 0, false); 1283 1283 1284 1284 vboxDXCommandBufferCommit(pDevice); … … 1288 1288 1289 1289 int vgpu10ResourceCopy(PVBOXDX_DEVICE pDevice, 1290 D3DKMT_HANDLE hDstAllocation,1291 D3DKMT_HANDLE hSrcAllocation)1290 PVBOXDXKMRESOURCE pDstKMResource, 1291 PVBOXDXKMRESOURCE pSrcKMResource) 1292 1292 { 1293 1293 void *pvCmd = vboxDXCommandBufferReserve(pDevice, SVGA_3D_CMD_DX_PRED_COPY, … … 1300 1300 cmd->srcSid = SVGA3D_INVALID_ID; 1301 1301 1302 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, VBOXDXALLOCATIONTYPE_SURFACE,1303 hDstAllocation,0, true);1304 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, VBOXDXALLOCATIONTYPE_SURFACE,1305 hSrcAllocation,0, false);1302 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, pDstKMResource, 1303 0, true); 1304 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, pSrcKMResource, 1305 0, false); 1306 1306 1307 1307 vboxDXCommandBufferCommit(pDevice); … … 1311 1311 1312 1312 int vgpu10ResolveCopy(PVBOXDX_DEVICE pDevice, 1313 D3DKMT_HANDLE hDstAllocation,1313 PVBOXDXKMRESOURCE pDstKMResource, 1314 1314 uint32 dstSubResource, 1315 D3DKMT_HANDLE hSrcAllocation,1315 PVBOXDXKMRESOURCE pSrcKMResource, 1316 1316 uint32 srcSubResource, 1317 1317 SVGA3dSurfaceFormat copyFormat) … … 1329 1329 SET_CMD_FIELD(copyFormat); 1330 1330 1331 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, VBOXDXALLOCATIONTYPE_SURFACE,1332 hDstAllocation,0, true);1333 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, VBOXDXALLOCATIONTYPE_SURFACE,1334 hSrcAllocation,0, false);1331 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, pDstKMResource, 1332 0, true); 1333 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, pSrcKMResource, 1334 0, false); 1335 1335 1336 1336 vboxDXCommandBufferCommit(pDevice); … … 1341 1341 int vgpu10MobFence64(PVBOXDX_DEVICE pDevice, 1342 1342 uint64 value, 1343 D3DKMT_HANDLE hAllocation,1343 PVBOXDXKMRESOURCE pKMResource, 1344 1344 uint32 mobOffset) 1345 1345 { … … 1354 1354 SET_CMD_FIELD(mobOffset); 1355 1355 1356 vboxDXStorePatchLocation(pDevice, &cmd->mobId, VBOXDXALLOCATIONTYPE_CO,1357 hAllocation,mobOffset, true);1356 vboxDXStorePatchLocation(pDevice, &cmd->mobId, pKMResource, 1357 mobOffset, true); 1358 1358 1359 1359 vboxDXCommandBufferCommit(pDevice); … … 1400 1400 int vgpu10BindQuery(PVBOXDX_DEVICE pDevice, 1401 1401 SVGA3dQueryId queryId, 1402 D3DKMT_HANDLE hAllocation)1402 PVBOXDXKMRESOURCE pKMResource) 1403 1403 { 1404 1404 void *pvCmd = vboxDXCommandBufferReserve(pDevice, SVGA_3D_CMD_DX_BIND_QUERY, … … 1411 1411 cmd->mobid = SVGA3D_INVALID_ID; 1412 1412 1413 vboxDXStorePatchLocation(pDevice, &cmd->mobid, VBOXDXALLOCATIONTYPE_CO,1414 hAllocation,0, true);1413 vboxDXStorePatchLocation(pDevice, &cmd->mobid, pKMResource, 1414 0, true); 1415 1415 1416 1416 vboxDXCommandBufferCommit(pDevice); … … 1505 1505 int vgpu10DefineUAView(PVBOXDX_DEVICE pDevice, 1506 1506 SVGA3dUAViewId uaViewId, 1507 D3DKMT_HANDLE hAllocation,1507 PVBOXDXKMRESOURCE pKMResource, 1508 1508 SVGA3dSurfaceFormat format, 1509 1509 SVGA3dResourceType resourceDimension, … … 1521 1521 SET_CMD_FIELD(resourceDimension); 1522 1522 SET_CMD_FIELD(desc); 1523 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1524 hAllocation,0, true);1523 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1524 0, true); 1525 1525 1526 1526 vboxDXCommandBufferCommit(pDevice); … … 1666 1666 1667 1667 int vgpu10DispatchIndirect(PVBOXDX_DEVICE pDevice, 1668 D3DKMT_HANDLE hAllocation,1668 PVBOXDXKMRESOURCE pKMResource, 1669 1669 uint32 byteOffsetForArgs) 1670 1670 { … … 1678 1678 SET_CMD_FIELD(byteOffsetForArgs); 1679 1679 1680 vboxDXStorePatchLocation(pDevice, &cmd->argsBufferSid, VBOXDXALLOCATIONTYPE_SURFACE,1681 hAllocation,0, false);1680 vboxDXStorePatchLocation(pDevice, &cmd->argsBufferSid, pKMResource, 1681 0, false); 1682 1682 1683 1683 vboxDXCommandBufferCommit(pDevice); … … 1687 1687 1688 1688 int vgpu10DrawIndexedInstancedIndirect(PVBOXDX_DEVICE pDevice, 1689 D3DKMT_HANDLE hAllocation,1689 PVBOXDXKMRESOURCE pKMResource, 1690 1690 uint32 byteOffsetForArgs) 1691 1691 { … … 1699 1699 SET_CMD_FIELD(byteOffsetForArgs); 1700 1700 1701 vboxDXStorePatchLocation(pDevice, &cmd->argsBufferSid, VBOXDXALLOCATIONTYPE_SURFACE,1702 hAllocation,0, false);1701 vboxDXStorePatchLocation(pDevice, &cmd->argsBufferSid, pKMResource, 1702 0, false); 1703 1703 1704 1704 vboxDXCommandBufferCommit(pDevice); … … 1708 1708 1709 1709 int vgpu10DrawInstancedIndirect(PVBOXDX_DEVICE pDevice, 1710 D3DKMT_HANDLE hAllocation,1710 PVBOXDXKMRESOURCE pKMResource, 1711 1711 uint32 byteOffsetForArgs) 1712 1712 { … … 1720 1720 SET_CMD_FIELD(byteOffsetForArgs); 1721 1721 1722 vboxDXStorePatchLocation(pDevice, &cmd->argsBufferSid, VBOXDXALLOCATIONTYPE_SURFACE,1723 hAllocation,0, false);1722 vboxDXStorePatchLocation(pDevice, &cmd->argsBufferSid, pKMResource, 1723 0, false); 1724 1724 1725 1725 vboxDXCommandBufferCommit(pDevice); … … 1730 1730 int vgpu10CopyStructureCount(PVBOXDX_DEVICE pDevice, 1731 1731 SVGA3dUAViewId srcUAViewId, 1732 D3DKMT_HANDLE hDstBuffer,1732 PVBOXDXKMRESOURCE pDstKMResource, 1733 1733 uint32 destByteOffset) 1734 1734 { … … 1743 1743 SET_CMD_FIELD(destByteOffset); 1744 1744 1745 vboxDXStorePatchLocation(pDevice, &cmd->destSid, VBOXDXALLOCATIONTYPE_SURFACE,1746 hDstBuffer,0, true);1745 vboxDXStorePatchLocation(pDevice, &cmd->destSid, pDstKMResource, 1746 0, true); 1747 1747 1748 1748 vboxDXCommandBufferCommit(pDevice); … … 1752 1752 1753 1753 int vgpu10PresentBlt(PVBOXDX_DEVICE pDevice, 1754 D3DKMT_HANDLE hSrcAllocation,1754 PVBOXDXKMRESOURCE pSrcKMResource, 1755 1755 uint32 srcSubResource, 1756 D3DKMT_HANDLE hDstAllocation,1756 PVBOXDXKMRESOURCE pDstKMResource, 1757 1757 uint32 destSubResource, 1758 1758 SVGA3dBox const &boxSrc, … … 1774 1774 SET_CMD_FIELD(mode); 1775 1775 1776 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, VBOXDXALLOCATIONTYPE_SURFACE,1777 hSrcAllocation,0, false);1778 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, VBOXDXALLOCATIONTYPE_SURFACE,1779 hDstAllocation,0, true);1776 vboxDXStorePatchLocation(pDevice, &cmd->srcSid, pSrcKMResource, 1777 0, false); 1778 vboxDXStorePatchLocation(pDevice, &cmd->dstSid, pDstKMResource, 1779 0, true); 1780 1780 1781 1781 vboxDXCommandBufferCommit(pDevice); … … 1804 1804 int vgpu10DefineVideoDecoderOutputView(PVBOXDX_DEVICE pDevice, 1805 1805 VBSVGA3dVideoDecoderOutputViewId videoDecoderOutputViewId, 1806 D3DKMT_HANDLE hAllocation,1806 PVBOXDXKMRESOURCE pKMResource, 1807 1807 VBSVGA3dVDOVDesc const &desc) 1808 1808 { … … 1816 1816 cmd->sid = SVGA3D_INVALID_ID; 1817 1817 SET_CMD_FIELD(desc); 1818 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1819 hAllocation,0, true);1818 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1819 0, true); 1820 1820 1821 1821 vboxDXCommandBufferCommit(pDevice); … … 1865 1865 VBSVGA3dVideoDecoderId videoDecoderId, 1866 1866 uint32 bufferCount, 1867 D3DKMT_HANDLE const *pahAllocation,1867 PVBOXDXKMRESOURCE const *papKMResources, 1868 1868 VBSVGA3dVideoDecoderBufferDesc const *paBufferDesc) 1869 1869 { … … 1883 1883 for (uint32_t i = 0; i < bufferCount; ++i) 1884 1884 { 1885 vboxDXStorePatchLocation(pDevice, &paCmdBufferDesc[i].sidBuffer, VBOXDXALLOCATIONTYPE_SURFACE,1886 pahAllocation[i],0, false);1885 vboxDXStorePatchLocation(pDevice, &paCmdBufferDesc[i].sidBuffer, papKMResources[i], 1886 0, false); 1887 1887 } 1888 1888 … … 1910 1910 int vgpu10DefineVideoProcessorInputView(PVBOXDX_DEVICE pDevice, 1911 1911 VBSVGA3dVideoProcessorInputViewId videoProcessorInputViewId, 1912 D3DKMT_HANDLE hAllocation,1912 PVBOXDXKMRESOURCE pKMResource, 1913 1913 VBSVGA3dVideoProcessorDesc const &contentDesc, 1914 1914 VBSVGA3dVPIVDesc const &desc) … … 1924 1924 SET_CMD_FIELD(contentDesc); 1925 1925 SET_CMD_FIELD(desc); 1926 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1927 hAllocation,0, true);1926 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1927 0, true); 1928 1928 1929 1929 vboxDXCommandBufferCommit(pDevice); … … 1934 1934 int vgpu10DefineVideoProcessorOutputView(PVBOXDX_DEVICE pDevice, 1935 1935 VBSVGA3dVideoProcessorOutputViewId videoProcessorOutputViewId, 1936 D3DKMT_HANDLE hAllocation,1936 PVBOXDXKMRESOURCE pKMResource, 1937 1937 VBSVGA3dVideoProcessorDesc const &contentDesc, 1938 1938 VBSVGA3dVPOVDesc const &desc) … … 1948 1948 SET_CMD_FIELD(contentDesc); 1949 1949 SET_CMD_FIELD(desc); 1950 vboxDXStorePatchLocation(pDevice, &cmd->sid, VBOXDXALLOCATIONTYPE_SURFACE,1951 hAllocation,0, true);1950 vboxDXStorePatchLocation(pDevice, &cmd->sid, pKMResource, 1951 0, true); 1952 1952 1953 1953 vboxDXCommandBufferCommit(pDevice); … … 2490 2490 int vgpu10GetVideoCapability(PVBOXDX_DEVICE pDevice, 2491 2491 VBSVGA3dVideoCapability capability, 2492 D3DKMT_HANDLE hAllocation,2492 PVBOXDXKMRESOURCE pKMResource, 2493 2493 uint32 offsetInBytes, 2494 2494 uint32 sizeInBytes, … … 2507 2507 SET_CMD_FIELD(fenceValue); 2508 2508 2509 vboxDXStorePatchLocation(pDevice, &cmd->mobid, VBOXDXALLOCATIONTYPE_CO,2510 hAllocation,offsetInBytes, true);2511 2512 vboxDXCommandBufferCommit(pDevice); 2513 return VINF_SUCCESS; 2514 } 2509 vboxDXStorePatchLocation(pDevice, &cmd->mobid, pKMResource, 2510 offsetInBytes, true); 2511 2512 vboxDXCommandBufferCommit(pDevice); 2513 return VINF_SUCCESS; 2514 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXCmd.h
r106061 r108880 5 5 6 6 /* 7 * Copyright (C) 2022-202 4Oracle and/or its affiliates.7 * Copyright (C) 2022-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 171 171 int vgpu10BindStreamOutput(PVBOXDX_DEVICE pDevice, 172 172 SVGA3dStreamOutputId soid, 173 D3DKMT_HANDLE hAllocation,173 PVBOXDXKMRESOURCE pKMResource, 174 174 uint32 offsetInBytes, 175 175 uint32 sizeInBytes); … … 180 180 int vgpu10BindShader(PVBOXDX_DEVICE pDevice, 181 181 uint32_t shid, 182 D3DKMT_HANDLE hAllocation,182 PVBOXDXKMRESOURCE pKMResource, 183 183 uint32_t offsetInBytes); 184 184 int vgpu10SetShader(PVBOXDX_DEVICE pDevice, … … 188 188 uint32_t startBuffer, 189 189 uint32_t numBuffers, 190 D3DKMT_HANDLE *paAllocations,190 PVBOXDXKMRESOURCE *papKMResources, 191 191 const UINT *paStrides, 192 192 const UINT *paOffsets); 193 193 int vgpu10SetIndexBuffer(PVBOXDX_DEVICE pDevice, 194 D3DKMT_HANDLE hAllocation,194 PVBOXDXKMRESOURCE pKMResource, 195 195 SVGA3dSurfaceFormat format, 196 196 uint32_t offset); 197 197 int vgpu10SoSetTargets(PVBOXDX_DEVICE pDevice, 198 198 uint32_t numTargets, 199 D3DKMT_HANDLE *paAllocations,199 PVBOXDXKMRESOURCE *papKMResources, 200 200 uint32_t *paOffsets, 201 201 uint32_t *paSizes); 202 202 int vgpu10DefineShaderResourceView(PVBOXDX_DEVICE pDevice, 203 203 SVGA3dShaderResourceViewId shaderResourceViewId, 204 D3DKMT_HANDLE hAllocation,204 PVBOXDXKMRESOURCE pKMResource, 205 205 SVGA3dSurfaceFormat format, 206 206 SVGA3dResourceType resourceDimension, … … 212 212 int vgpu10DefineRenderTargetView(PVBOXDX_DEVICE pDevice, 213 213 SVGA3dRenderTargetViewId renderTargetViewId, 214 D3DKMT_HANDLE hAllocation,214 PVBOXDXKMRESOURCE pKMResource, 215 215 SVGA3dSurfaceFormat format, 216 216 SVGA3dResourceType resourceDimension, … … 223 223 int vgpu10DefineDepthStencilView(PVBOXDX_DEVICE pDevice, 224 224 SVGA3dDepthStencilViewId depthStencilViewId, 225 D3DKMT_HANDLE hAllocation,225 PVBOXDXKMRESOURCE pKMResource, 226 226 SVGA3dSurfaceFormat format, 227 227 SVGA3dResourceType resourceDimension, … … 250 250 uint32 slot, 251 251 SVGA3dShaderType type, 252 D3DKMT_HANDLE hAllocation,252 PVBOXDXKMRESOURCE pKMResource, 253 253 uint32 offsetInBytes, 254 254 uint32 sizeInBytes); 255 255 int vgpu10UpdateSubResource(PVBOXDX_DEVICE pDevice, 256 D3DKMT_HANDLE hAllocation,256 PVBOXDXKMRESOURCE pKMResource, 257 257 uint32 subResource, 258 258 const SVGA3dBox *pBox); 259 259 int vgpu10ReadbackSubResource(PVBOXDX_DEVICE pDevice, 260 D3DKMT_HANDLE hAllocation,260 PVBOXDXKMRESOURCE pKMResource, 261 261 uint32 subResource); 262 262 int vgpu10TransferFromBuffer(PVBOXDX_DEVICE pDevice, 263 D3DKMT_HANDLE hSrcAllocation,263 PVBOXDXKMRESOURCE pSrcKMResource, 264 264 uint32 srcOffset, 265 265 uint32 srcPitch, 266 266 uint32 srcSlicePitch, 267 D3DKMT_HANDLE hDstAllocation,267 PVBOXDXKMRESOURCE pDstKMResource, 268 268 uint32 destSubResource, 269 269 SVGA3dBox const &destBox); 270 270 int vgpu10ResourceCopyRegion(PVBOXDX_DEVICE pDevice, 271 D3DKMT_HANDLE hDstAllocation,271 PVBOXDXKMRESOURCE pDstKMResource, 272 272 uint32 dstSubResource, 273 273 uint32 dstX, 274 274 uint32 dstY, 275 275 uint32 dstZ, 276 D3DKMT_HANDLE hSrcAllocation,276 PVBOXDXKMRESOURCE pSrcKMResource, 277 277 uint32 srcSubResource, 278 278 SVGA3dBox const &srcBox); 279 279 int vgpu10ResourceCopy(PVBOXDX_DEVICE pDevice, 280 D3DKMT_HANDLE hDstAllocation,281 D3DKMT_HANDLE hSrcAllocation);280 PVBOXDXKMRESOURCE pDstKMResource, 281 PVBOXDXKMRESOURCE pSrcKMResource); 282 282 int vgpu10ResolveCopy(PVBOXDX_DEVICE pDevice, 283 D3DKMT_HANDLE hDstAllocation,283 PVBOXDXKMRESOURCE pDstKMResource, 284 284 uint32 dstSubResource, 285 D3DKMT_HANDLE hSrcAllocation,285 PVBOXDXKMRESOURCE pSrcKMResource, 286 286 uint32 srcSubResource, 287 287 SVGA3dSurfaceFormat copyFormat); 288 288 int vgpu10MobFence64(PVBOXDX_DEVICE pDevice, 289 289 uint64 value, 290 D3DKMT_HANDLE hAllocation,290 PVBOXDXKMRESOURCE pKMResource, 291 291 uint32 mobOffset); 292 292 int vgpu10DefineQuery(PVBOXDX_DEVICE pDevice, … … 298 298 int vgpu10BindQuery(PVBOXDX_DEVICE pDevice, 299 299 SVGA3dQueryId queryId, 300 D3DKMT_HANDLE hAllocation);300 PVBOXDXKMRESOURCE pKMResource); 301 301 int vgpu10SetQueryOffset(PVBOXDX_DEVICE pDevice, 302 302 SVGA3dQueryId queryId, … … 313 313 int vgpu10DefineUAView(PVBOXDX_DEVICE pDevice, 314 314 SVGA3dUAViewId uaViewId, 315 D3DKMT_HANDLE hAllocation,315 PVBOXDXKMRESOURCE pKMResource, 316 316 SVGA3dSurfaceFormat format, 317 317 SVGA3dResourceType resourceDimension, … … 341 341 uint32 threadGroupCountZ); 342 342 int vgpu10DispatchIndirect(PVBOXDX_DEVICE pDevice, 343 D3DKMT_HANDLE hAllocation,343 PVBOXDXKMRESOURCE pKMResource, 344 344 uint32 byteOffsetForArgs); 345 345 int vgpu10DrawIndexedInstancedIndirect(PVBOXDX_DEVICE pDevice, 346 D3DKMT_HANDLE hAllocation,346 PVBOXDXKMRESOURCE pKMResource, 347 347 uint32 byteOffsetForArgs); 348 348 int vgpu10DrawInstancedIndirect(PVBOXDX_DEVICE pDevice, 349 D3DKMT_HANDLE hAllocation,349 PVBOXDXKMRESOURCE pKMResource, 350 350 uint32 byteOffsetForArgs); 351 351 int vgpu10CopyStructureCount(PVBOXDX_DEVICE pDevice, 352 352 SVGA3dUAViewId srcUAViewId, 353 D3DKMT_HANDLE hDstBuffer,353 PVBOXDXKMRESOURCE pDstKMResource, 354 354 uint32 destByteOffset); 355 355 int vgpu10ClearRenderTargetViewRegion(PVBOXDX_DEVICE pDevice, … … 359 359 uint32_t cRects); 360 360 int vgpu10PresentBlt(PVBOXDX_DEVICE pDevice, 361 D3DKMT_HANDLE hSrcAllocation,361 PVBOXDXKMRESOURCE pSrcKMResource, 362 362 uint32 srcSubResource, 363 D3DKMT_HANDLE hDstAllocation,363 PVBOXDXKMRESOURCE pDstKMResource, 364 364 uint32 destSubResource, 365 365 SVGA3dBox const &boxSrc, … … 372 372 int vgpu10DefineVideoDecoderOutputView(PVBOXDX_DEVICE pDevice, 373 373 VBSVGA3dVideoDecoderOutputViewId videoDecoderOutputViewId, 374 D3DKMT_HANDLE hAllocation,374 PVBOXDXKMRESOURCE pKMResource, 375 375 VBSVGA3dVDOVDesc const &desc); 376 376 int vgpu10DefineVideoDecoder(PVBOXDX_DEVICE pDevice, … … 384 384 VBSVGA3dVideoDecoderId videoDecoderId, 385 385 uint32 bufferCount, 386 D3DKMT_HANDLE const *pahAllocation,386 PVBOXDXKMRESOURCE const *papKMResources, 387 387 VBSVGA3dVideoDecoderBufferDesc const *paBufferDesc); 388 388 int vgpu10VideoDecoderEndFrame(PVBOXDX_DEVICE pDevice, … … 390 390 int vgpu10DefineVideoProcessorInputView(PVBOXDX_DEVICE pDevice, 391 391 VBSVGA3dVideoProcessorInputViewId videoProcessorInputViewId, 392 D3DKMT_HANDLE hAllocation,392 PVBOXDXKMRESOURCE pKMResource, 393 393 VBSVGA3dVideoProcessorDesc const &contentDesc, 394 394 VBSVGA3dVPIVDesc const &desc); 395 395 int vgpu10DefineVideoProcessorOutputView(PVBOXDX_DEVICE pDevice, 396 396 VBSVGA3dVideoProcessorOutputViewId videoProcessorOutputViewId, 397 D3DKMT_HANDLE hAllocation,397 PVBOXDXKMRESOURCE pKMResource, 398 398 VBSVGA3dVideoProcessorDesc const &contentDesc, 399 399 VBSVGA3dVPOVDesc const &desc); … … 509 509 int vgpu10GetVideoCapability(PVBOXDX_DEVICE pDevice, 510 510 VBSVGA3dVideoCapability capability, 511 D3DKMT_HANDLE hAllocation,511 PVBOXDXKMRESOURCE pKMResource, 512 512 uint32 offsetInBytes, 513 513 uint32 sizeInBytes, -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXDDI.cpp
r106582 r108880 5 5 6 6 /* 7 * Copyright (C) 2020-202 4Oracle and/or its affiliates.7 * Copyright (C) 2020-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 973 973 974 974 /* Fetch allocation handles. */ 975 D3DKMT_HANDLE aAllocations[SVGA3D_DX_MAX_SOTARGETS];975 PVBOXDXKMRESOURCE apKMResources[SVGA3D_DX_MAX_SOTARGETS]; 976 976 uint32_t aOffsets[SVGA3D_DX_MAX_SOTARGETS]; 977 977 uint32_t aSizes[SVGA3D_DX_MAX_SOTARGETS]; … … 981 981 { 982 982 VBOXDX_RESOURCE *pResource = (PVBOXDX_RESOURCE)phResource[i].pDrvPrivate; 983 a Allocations[i] = vboxDXGetAllocation(pResource);983 apKMResources[i] = vboxDXGetKMResource(pResource); 984 984 aOffsets[i] = pOffsets[i]; 985 aSizes[i] = pResource ? pResource->AllocationDesc.cbAllocation : 0;985 aSizes[i] = apKMResources[i] ? apKMResources[i]->AllocationDesc.cbAllocation : 0; 986 986 } 987 987 else 988 988 { 989 a Allocations[i] = 0;989 apKMResources[i] = 0; 990 990 aOffsets[i] = 0; 991 991 aSizes[i] = 0; … … 993 993 } 994 994 995 vboxDXSoSetTargets(pDevice, NumTargets, a Allocations, aOffsets, aSizes);995 vboxDXSoSetTargets(pDevice, NumTargets, apKMResources, aOffsets, aSizes); 996 996 } 997 997 … … 1358 1358 1359 1359 pResource->hRTResource = hRTResource; 1360 int rc = vboxDXInitResourceData(pResource, pCreateResource); 1361 if (RT_SUCCESS(rc)) 1362 vboxDXCreateResource(pDevice, pResource, pCreateResource); 1360 vboxDXCreateResource(pDevice, pResource, pCreateResource); 1363 1361 } 1364 1362 … … 1388 1386 pCreateResource->ArraySize)); 1389 1387 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1388 D3D11DDIARG_CREATERESOURCE CreateResource; 1389 CreateResource.pMipInfoList = pCreateResource->pMipInfoList; 1390 CreateResource.pInitialDataUP = pCreateResource->pInitialDataUP; 1391 CreateResource.ResourceDimension = pCreateResource->ResourceDimension; 1392 CreateResource.Usage = pCreateResource->Usage; 1393 CreateResource.BindFlags = pCreateResource->BindFlags; 1394 CreateResource.MapFlags = pCreateResource->MapFlags; 1395 CreateResource.MiscFlags = pCreateResource->MiscFlags; 1396 CreateResource.Format = pCreateResource->Format; 1397 CreateResource.SampleDesc = pCreateResource->SampleDesc; 1398 CreateResource.MipLevels = pCreateResource->MipLevels; 1399 CreateResource.ArraySize = pCreateResource->ArraySize; 1400 CreateResource.pPrimaryDesc = pCreateResource->pPrimaryDesc; 1401 CreateResource.ByteStride = 0; 1402 CreateResource.DecoderBufferType = D3D11_1DDI_VIDEO_DECODER_BUFFER_UNKNOWN; 1403 CreateResource.TextureLayout = D3DWDDM2_0DDI_TL_UNDEFINED; 1406 1404 1407 1405 pResource->hRTResource = hRTResource; 1408 int rc = vboxDXInitResourceData(pResource, &CreateResource); 1409 if (RT_SUCCESS(rc)) 1410 vboxDXCreateResource(pDevice, pResource, &CreateResource); 1406 vboxDXCreateResource(pDevice, pResource, &CreateResource); 1411 1407 } 1412 1408 … … 3867 3863 LogFlowFunc(("pDevice 0x%p, pResource 0x%p, subres %d", pDevice, pResource, pDisplayModeData->SubResourceIndex)); 3868 3864 3869 AssertReturn(pResource->AllocationDesc.fPrimary && pDisplayModeData->SubResourceIndex == 0, E_INVALIDARG); 3865 AssertReturn(pResource->pKMResource 3866 && pResource->pKMResource->AllocationDesc.fPrimary 3867 && pDisplayModeData->SubResourceIndex == 0, E_INVALIDARG); 3870 3868 3871 3869 D3DDDICB_SETDISPLAYMODE ddiSetDisplayMode; -
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXVideo.cpp
r106061 r108880 5 5 6 6 /* 7 * Copyright (C) 2023-202 4Oracle and/or its affiliates.7 * Copyright (C) 2023-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 42 42 static void vboxDXDestroyVideoDeviceAllocation(PVBOXDX_DEVICE pDevice) 43 43 { 44 if (pDevice->VideoDevice.hAllocation) 45 { 46 D3DDDICB_DEALLOCATE ddiDeallocate; 47 RT_ZERO(ddiDeallocate); 48 ddiDeallocate.NumAllocations = 1; 49 ddiDeallocate.HandleList = &pDevice->VideoDevice.hAllocation; 50 51 HRESULT hr = pDevice->pRTCallbacks->pfnDeallocateCb(pDevice->hRTDevice.handle, &ddiDeallocate); 52 LogFlowFunc(("pfnDeallocateCb returned %d", hr)); 53 AssertStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr)); 54 55 pDevice->VideoDevice.hAllocation = 0; 56 pDevice->VideoDevice.cbAllocation = 0; 57 } 44 if (pDevice->VideoDevice.pKMResource) 45 { 46 RTListNodeRemove(&pDevice->VideoDevice.pKMResource->nodeResource); 47 vboxDXDeallocateKMResource(pDevice, pDevice->VideoDevice.pKMResource); 48 pDevice->VideoDevice.pKMResource = 0; 49 } 50 } 51 52 53 static void videoDeviceAllocationDesc(VBOXDXALLOCATIONDESC *pDesc, void const *pvInitData) 54 { 55 pDesc->enmAllocationType = VBOXDXALLOCATIONTYPE_CO; /* Context Object allocation. */ 56 pDesc->cbAllocation = *(uint32_t *)pvInitData; 58 57 } 59 58 … … 61 60 static bool vboxDXCreateVideoDeviceAllocation(PVBOXDX_DEVICE pDevice, uint32_t cbAllocation) 62 61 { 63 VBOXDXALLOCATIONDESC desc; 64 RT_ZERO(desc); 65 desc.enmAllocationType = VBOXDXALLOCATIONTYPE_CO; /* Context Object allocation. */ 66 desc.cbAllocation = cbAllocation; 67 68 D3DDDI_ALLOCATIONINFO2 ddiAllocationInfo; 69 RT_ZERO(ddiAllocationInfo); 70 ddiAllocationInfo.pPrivateDriverData = &desc; 71 ddiAllocationInfo.PrivateDriverDataSize = sizeof(desc); 72 73 D3DDDICB_ALLOCATE ddiAllocate; 74 RT_ZERO(ddiAllocate); 75 ddiAllocate.NumAllocations = 1; 76 ddiAllocate.pAllocationInfo2 = &ddiAllocationInfo; 77 78 HRESULT hr = pDevice->pRTCallbacks->pfnAllocateCb(pDevice->hRTDevice.handle, &ddiAllocate); 79 LogFlowFunc(("pfnAllocateCb returned %d, hKMResource 0x%X, hAllocation 0x%X", hr, ddiAllocate.hKMResource, ddiAllocationInfo.hAllocation)); 80 AssertReturnStmt(SUCCEEDED(hr), vboxDXDeviceSetError(pDevice, hr), false); 81 82 pDevice->VideoDevice.hAllocation = ddiAllocationInfo.hAllocation; 83 pDevice->VideoDevice.cbAllocation = cbAllocation; 84 85 D3DDDICB_LOCK ddiLock; 86 RT_ZERO(ddiLock); 87 ddiLock.hAllocation = ddiAllocationInfo.hAllocation; 88 ddiLock.Flags.WriteOnly = 1; 89 hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); 90 if (SUCCEEDED(hr)) 91 { 92 memset(ddiLock.pData, 0, cbAllocation); 93 94 D3DDDICB_UNLOCK ddiUnlock; 95 ddiUnlock.NumAllocations = 1; 96 ddiUnlock.phAllocations = &ddiAllocationInfo.hAllocation; 97 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 98 } 99 AssertReturnStmt(SUCCEEDED(hr), 100 vboxDXDestroyVideoDeviceAllocation(pDevice); vboxDXDeviceSetError(pDevice, hr), false); 62 pDevice->VideoDevice.pKMResource = vboxDXAllocateKMResource(pDevice, 0, videoDeviceAllocationDesc, 63 &cbAllocation, true); 64 if (!pDevice->VideoDevice.pKMResource) 65 return false; 66 67 RTListAppend(&pDevice->listResources, &pDevice->VideoDevice.pKMResource->nodeResource); 101 68 return true; 102 69 } … … 105 72 static bool vboxDXEnsureVideoDeviceAllocation(PVBOXDX_DEVICE pDevice) 106 73 { 107 if (!pDevice->VideoDevice. hAllocation)74 if (!pDevice->VideoDevice.pKMResource) 108 75 return vboxDXCreateVideoDeviceAllocation(pDevice, _64K); 109 76 return true; … … 120 87 121 88 uint32 const offsetInBytes = 0; 122 uint32 const sizeInBytes = pDevice->VideoDevice. cbAllocation - offsetInBytes;89 uint32 const sizeInBytes = pDevice->VideoDevice.pKMResource->AllocationDesc.cbAllocation - offsetInBytes; 123 90 AssertReturnVoid(cbDataIn <= sizeInBytes - RT_UOFFSETOF(VBSVGA3dVideoCapabilityMobLayout, data)); 124 91 … … 127 94 D3DDDICB_LOCK ddiLock; 128 95 RT_ZERO(ddiLock); 129 ddiLock.hAllocation = pDevice->VideoDevice.hAllocation;96 ddiLock.hAllocation = vboxDXGetAllocation(pDevice->VideoDevice.pKMResource); 130 97 ddiLock.Flags.ReadOnly = 1; 131 98 HRESULT hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); … … 137 104 D3DDDICB_UNLOCK ddiUnlock; 138 105 ddiUnlock.NumAllocations = 1; 139 ddiUnlock.phAllocations = & pDevice->VideoDevice.hAllocation;106 ddiUnlock.phAllocations = &ddiLock.hAllocation; 140 107 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 141 108 } … … 144 111 145 112 uint64_t const fenceValue = ASMAtomicIncU64(&pDevice->VideoDevice.u64MobFenceValue); 146 vgpu10GetVideoCapability(pDevice, cap, pDevice->VideoDevice. hAllocation, offsetInBytes, sizeInBytes, fenceValue);113 vgpu10GetVideoCapability(pDevice, cap, pDevice->VideoDevice.pKMResource, offsetInBytes, sizeInBytes, fenceValue); 147 114 vboxDXDeviceFlushCommands(pDevice); 148 115 … … 155 122 D3DDDICB_LOCK ddiLock; 156 123 RT_ZERO(ddiLock); 157 ddiLock.hAllocation = pDevice->VideoDevice.hAllocation;124 ddiLock.hAllocation = vboxDXGetAllocation(pDevice->VideoDevice.pKMResource); 158 125 ddiLock.Flags.ReadOnly = 1; 159 126 HRESULT hr = pDevice->pRTCallbacks->pfnLockCb(pDevice->hRTDevice.handle, &ddiLock); … … 181 148 D3DDDICB_UNLOCK ddiUnlock; 182 149 ddiUnlock.NumAllocations = 1; 183 ddiUnlock.phAllocations = & pDevice->VideoDevice.hAllocation;150 ddiUnlock.phAllocations = &ddiLock.hAllocation; 184 151 hr = pDevice->pRTCallbacks->pfnUnlockCb(pDevice->hRTDevice.handle, &ddiUnlock); 185 152 } … … 498 465 499 466 vgpu10DefineVideoDecoderOutputView(pDevice, pVideoDecoderOutputView->uVideoDecoderOutputViewId, 500 vboxDXGet Allocation(pVideoDecoderOutputView->pResource),467 vboxDXGetKMResource(pVideoDecoderOutputView->pResource), 501 468 pVideoDecoderOutputView->svga.desc); 502 469 … … 555 522 UINT BufferCount, D3D11_1DDI_VIDEO_DECODER_BUFFER_DESC const *pBufferDesc) 556 523 { 557 void *pvTmpBuffer = RTMemTmpAlloc(BufferCount * (sizeof( D3DKMT_HANDLE) + sizeof(VBSVGA3dVideoDecoderBufferDesc)));524 void *pvTmpBuffer = RTMemTmpAlloc(BufferCount * (sizeof(PVBOXDXKMRESOURCE) + sizeof(VBSVGA3dVideoDecoderBufferDesc))); 558 525 if (!pvTmpBuffer) 559 526 return E_OUTOFMEMORY; 560 527 561 D3DKMT_HANDLE *pahAllocation = (D3DKMT_HANDLE *)pvTmpBuffer;562 VBSVGA3dVideoDecoderBufferDesc *paBD = (VBSVGA3dVideoDecoderBufferDesc *)((uint8_t *)pvTmpBuffer + BufferCount * sizeof( D3DKMT_HANDLE));528 PVBOXDXKMRESOURCE *papKMResource = (PVBOXDXKMRESOURCE *)pvTmpBuffer; 529 VBSVGA3dVideoDecoderBufferDesc *paBD = (VBSVGA3dVideoDecoderBufferDesc *)((uint8_t *)pvTmpBuffer + BufferCount * sizeof(PVBOXDXKMRESOURCE)); 563 530 564 531 for (UINT i = 0; i < BufferCount; ++i) … … 567 534 568 535 PVBOXDX_RESOURCE pBuffer = (PVBOXDX_RESOURCE)s->hResource.pDrvPrivate; 569 pa hAllocation[i] = vboxDXGetAllocation(pBuffer);536 papKMResource[i] = vboxDXGetKMResource(pBuffer); 570 537 571 538 VBSVGA3dVideoDecoderBufferDesc *d = &paBD[i]; … … 601 568 } 602 569 603 vgpu10VideoDecoderSubmitBuffers(pDevice, pVideoDecoder->uVideoDecoderId, BufferCount, pa hAllocation, paBD);570 vgpu10VideoDecoderSubmitBuffers(pDevice, pVideoDecoder->uVideoDecoderId, BufferCount, papKMResource, paBD); 604 571 RTMemTmpFree(pvTmpBuffer); 605 572 return S_OK; … … 635 602 636 603 vgpu10DefineVideoProcessorInputView(pDevice, pVideoProcessorInputView->uVideoProcessorInputViewId, 637 vboxDXGet Allocation(pVideoProcessorInputView->pResource),604 vboxDXGetKMResource(pVideoProcessorInputView->pResource), 638 605 pVideoProcessorInputView->svga.ContentDesc, *pDesc); 639 606 … … 670 637 671 638 vgpu10DefineVideoProcessorOutputView(pDevice, pVideoProcessorOutputView->uVideoProcessorOutputViewId, 672 vboxDXGet Allocation(pVideoProcessorOutputView->pResource),639 vboxDXGetKMResource(pVideoProcessorOutputView->pResource), 673 640 pVideoProcessorOutputView->svga.ContentDesc, *pDesc); 674 641
Note:
See TracChangeset
for help on using the changeset viewer.