VirtualBox

Ignore:
Timestamp:
May 5, 2022 3:10:52 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151254
Message:

WDDM: Patch. bugref:9845

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/gallium/VBoxMPDX.cpp

    r94847 r94854  
    874874}
    875875
     876
     877NTSTATUS APIENTRY DxgkDdiDXPatch(PVBOXMP_DEVEXT pDevExt, const DXGKARG_PATCH *pPatch)
     878{
     879    GALOG(("pDmaBuffer = %p, cbDmaBuffer = %u, cPatches = %u\n",
     880           pPatch->pDmaBuffer, pPatch->DmaBufferSubmissionEndOffset - pPatch->DmaBufferSubmissionStartOffset,
     881           pPatch->PatchLocationListSubmissionLength));
     882
     883    DEBUG_BREAKPOINT_TEST();
     884
     885    for (UINT i = 0; i < pPatch->PatchLocationListSubmissionLength; ++i)
     886    {
     887        D3DDDI_PATCHLOCATIONLIST const *pPatchListEntry
     888            = &pPatch->pPatchLocationList[pPatch->PatchLocationListSubmissionStart + i];
     889        void * const pPatchAddress = (uint8_t *)pPatch->pDmaBuffer + pPatchListEntry->PatchOffset;
     890        VBOXDXALLOCATIONTYPE const enmAllocationType = (VBOXDXALLOCATIONTYPE)pPatchListEntry->DriverId;
     891
     892        /* Ignore a dummy patch request. */
     893        if (pPatchListEntry->PatchOffset == ~0UL)
     894            continue;
     895
     896        AssertReturn(   pPatchListEntry->PatchOffset >= pPatch->DmaBufferSubmissionStartOffset
     897                     && pPatchListEntry->PatchOffset < pPatch->DmaBufferSubmissionEndOffset, STATUS_INVALID_PARAMETER);
     898        AssertReturn(pPatchListEntry->AllocationIndex < pPatch->AllocationListSize, STATUS_INVALID_PARAMETER);
     899
     900        DXGK_ALLOCATIONLIST const *pAllocationListEntry = &pPatch->pAllocationList[pPatchListEntry->AllocationIndex];
     901        AssertContinue(pAllocationListEntry->SegmentId != 0);
     902
     903        PVBOXWDDM_OPENALLOCATION pOA = (PVBOXWDDM_OPENALLOCATION)pAllocationListEntry->hDeviceSpecificAllocation;
     904        if (pOA)
     905        {
     906            PVBOXWDDM_ALLOCATION pAllocation = pOA->pAllocation;
     907            /* Allocation type determines what the patch is about. */
     908            Assert(pAllocation->dx.desc.enmAllocationType == enmAllocationType);
     909            if (enmAllocationType == VBOXDXALLOCATIONTYPE_SURFACE)
     910            {
     911                Assert(pAllocation->dx.sid != SVGA3D_INVALID_ID);
     912                *(uint32_t *)pPatchAddress = pAllocation->dx.sid;
     913            }
     914            else if (enmAllocationType == VBOXDXALLOCATIONTYPE_SHADERS)
     915            {
     916                Assert(pAllocation->dx.mobid != SVGA3D_INVALID_ID);
     917                *(uint32_t *)pPatchAddress = pAllocation->dx.mobid;
     918            }
     919            else
     920            {
     921                AssertFailed();
     922                uint32_t *poffVRAM = (uint32_t *)pPatchAddress;
     923                *poffVRAM = pAllocationListEntry->PhysicalAddress.LowPart + pPatchListEntry->AllocationOffset;
     924            }
     925        }
     926        else
     927            AssertFailed(); /* Render should have already filtered out such patches. */
     928    }
     929
     930#ifdef DEBUG
     931    if (!pPatch->Flags.Paging && !pPatch->Flags.Present)
     932    {
     933        SvgaDebugCommandsD3D(pDevExt->pGa->hw.pSvga,
     934                             ((PVBOXWDDM_CONTEXT)pPatch->hContext)->pSvgaContext,
     935                             (uint8_t *)pPatch->pDmaBuffer + pPatch->DmaBufferSubmissionStartOffset,
     936                             pPatch->DmaBufferSubmissionEndOffset - pPatch->DmaBufferSubmissionStartOffset);
     937    }
     938#else
     939    RT_NOREF(pDevExt);
     940#endif
     941    return STATUS_SUCCESS;
     942}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette