VirtualBox

Changeset 51018 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Apr 9, 2014 4:32:52 PM (11 years ago)
Author:
vboxsync
Message:

wddm: formatting

File:
1 edited

Legend:

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

    r51017 r51018  
    58225822    __try
    58235823    {
    5824     PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pInputHdr = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)pRender->pCommand;
    5825     NTSTATUS Status = STATUS_SUCCESS;
    5826 
    5827     uint32_t cbBuffer = 0;
    5828     uint32_t cbPrivateData = 0;
    5829     VBOXCMDVBVA_HDR* pCmd = (VBOXCMDVBVA_HDR*)pRender->pDmaBufferPrivateData;
    5830 
    5831     switch (pInputHdr->enmCmd)
    5832     {
    5833         case VBOXVDMACMD_TYPE_CHROMIUM_CMD:
    5834         {
    5835             if (pRender->AllocationListSize >= (UINT32_MAX - RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos))/ RT_SIZEOFMEMB(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[0]))
    5836             {
    5837                 WARN(("Invalid AllocationListSize %d", pRender->AllocationListSize));
    5838                 return STATUS_INVALID_PARAMETER;
    5839             }
    5840 
    5841             if (pRender->CommandLength != RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize]))
    5842             {
    5843                 WARN(("pRender->CommandLength (%d) != RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize](%d)",
    5844                         pRender->CommandLength, RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize])));
    5845                 return STATUS_INVALID_PARAMETER;
    5846             }
    5847 
    5848             if (pRender->AllocationListSize >= (UINT32_MAX - RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd.aBuffers))/ RT_SIZEOFMEMB(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[0]))
    5849             {
    5850                 WARN(("Invalid AllocationListSize %d", pRender->AllocationListSize));
    5851                 return STATUS_INVALID_PARAMETER;
    5852             }
    5853 
    5854             cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    5855             cbPrivateData = RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[pRender->AllocationListSize]);
    5856 
    5857             if (pRender->DmaBufferPrivateDataSize < cbPrivateData)
    5858             {
    5859                 WARN(("pRender->DmaBufferPrivateDataSize too small %d, requested %d", pRender->DmaBufferPrivateDataSize, cbPrivateData));
    5860                 return STATUS_INVALID_PARAMETER;
    5861             }
    5862 
    5863             if (pRender->DmaSize < cbBuffer)
    5864             {
    5865                 WARN(("dma buffer %d too small", pRender->DmaSize));
    5866                 return STATUS_INVALID_PARAMETER;
    5867             }
    5868 
    5869 //            Assert(pRender->PatchLocationListOutSize == pRender->AllocationListSize);
    5870 
    5871             if (pRender->PatchLocationListOutSize < pRender->AllocationListSize)
    5872             {
    5873                 WARN(("pRender->PatchLocationListOutSize too small %d, requested %d", pRender->PatchLocationListOutSize, pRender->AllocationListSize));
    5874                 return STATUS_INVALID_PARAMETER;
    5875             }
    5876 
    5877             PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD pUmCmd = (PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD)pInputHdr;
    5878             VBOXCMDVBVA_CRCMD* pChromiumCmd = (VBOXCMDVBVA_CRCMD*)pRender->pDmaBufferPrivateData;
    5879 
    5880             PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)hContext;
    5881             PVBOXWDDM_DEVICE pDevice = pContext->pDevice;
    5882             PVBOXMP_DEVEXT pDevExt = pDevice->pAdapter;
    5883 
    5884             pChromiumCmd->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_CRCMD;
    5885             pChromiumCmd->Hdr.u8Flags = 0;
    5886             pChromiumCmd->Cmd.cBuffers = pRender->AllocationListSize;
    5887 
    5888             DXGK_ALLOCATIONLIST *pAllocationList = pRender->pAllocationList;
    5889             VBOXCMDVBVA_CRCMD_BUFFER *pSubmInfo = pChromiumCmd->Cmd.aBuffers;
    5890             PVBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO pSubmUmInfo = pUmCmd->aBufInfos;
    5891 
    5892             for (UINT i = 0; i < pRender->AllocationListSize; ++i, ++pRender->pPatchLocationListOut, ++pAllocationList, ++pSubmInfo, ++pSubmUmInfo)
    5893             {
    5894                 VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO SubmUmInfo = *pSubmUmInfo;
    5895                 D3DDDI_PATCHLOCATIONLIST* pPLL = pRender->pPatchLocationListOut;
    5896                 PVBOXWDDM_ALLOCATION pAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pAllocationList);
    5897                 if (SubmUmInfo.offData >= pAlloc->AllocData.SurfDesc.cbSize
    5898                         || SubmUmInfo.cbData > pAlloc->AllocData.SurfDesc.cbSize
    5899                         || SubmUmInfo.offData + SubmUmInfo.cbData > pAlloc->AllocData.SurfDesc.cbSize)
    5900                 {
    5901                     WARN(("invalid data"));
     5824        PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR pInputHdr = (PVBOXWDDM_DMA_PRIVATEDATA_BASEHDR)pRender->pCommand;
     5825        NTSTATUS Status = STATUS_SUCCESS;
     5826
     5827        uint32_t cbBuffer = 0;
     5828        uint32_t cbPrivateData = 0;
     5829        VBOXCMDVBVA_HDR* pCmd = (VBOXCMDVBVA_HDR*)pRender->pDmaBufferPrivateData;
     5830
     5831        switch (pInputHdr->enmCmd)
     5832        {
     5833            case VBOXVDMACMD_TYPE_CHROMIUM_CMD:
     5834            {
     5835                if (pRender->AllocationListSize >= (UINT32_MAX - RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos))/ RT_SIZEOFMEMB(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[0]))
     5836                {
     5837                    WARN(("Invalid AllocationListSize %d", pRender->AllocationListSize));
    59025838                    return STATUS_INVALID_PARAMETER;
    59035839                }
    59045840
    5905                 memset(pPLL, 0, sizeof (*pPLL));
    5906 
    5907                 if (pAllocationList->SegmentId)
    5908                     pSubmInfo->offBuffer = pAllocationList->PhysicalAddress.LowPart + SubmUmInfo.offData;
    5909 
    5910                 pSubmInfo->cbBuffer = SubmUmInfo.cbData;
    5911 
    5912                 pPLL->AllocationIndex = i;
    5913                 pPLL->PatchOffset = RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[i].offBuffer);
    5914                 pPLL->AllocationOffset = SubmUmInfo.offData;
    5915             }
    5916 
    5917             break;
    5918         }
    5919         case VBOXVDMACMD_TYPE_DMA_NOP:
    5920         {
    5921             cbPrivateData = sizeof (VBOXCMDVBVA_HDR);
    5922             cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
    5923 
    5924             if (pRender->DmaBufferPrivateDataSize < cbPrivateData)
    5925             {
    5926                 WARN(("pRender->DmaBufferPrivateDataSize too small %d, requested %d", pRender->DmaBufferPrivateDataSize, cbPrivateData));
    5927                 return STATUS_INVALID_PARAMETER;
    5928             }
    5929 
    5930             if (pRender->DmaSize < cbBuffer)
    5931             {
    5932                 WARN(("dma buffer %d too small", pRender->DmaSize));
    5933                 return STATUS_INVALID_PARAMETER;
    5934             }
    5935 
    5936             pCmd->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    5937             pCmd->u8Flags = 0;
    5938 
    5939             for (UINT i = 0; i < pRender->AllocationListSize; ++i, ++pRender->pPatchLocationListOut)
    5940             {
    5941                 D3DDDI_PATCHLOCATIONLIST* pPLL = pRender->pPatchLocationListOut;
    5942                 memset(pPLL, 0, sizeof (*pPLL));
    5943                 pPLL->AllocationIndex = i;
    5944                 pPLL->PatchOffset = ~0UL;
    5945                 pPLL->AllocationOffset = 0;
    5946             }
    5947 
    5948             break;
    5949         }
    5950         default:
    5951          {
    5952              WARN(("unsupported render command %d", pInputHdr->enmCmd));
    5953              return STATUS_INVALID_PARAMETER;
    5954          }
    5955     }
    5956 
    5957     pRender->pDmaBufferPrivateData = ((uint8_t*)pRender->pDmaBufferPrivateData) + cbPrivateData;
    5958     pRender->pDmaBuffer = ((uint8_t*)pRender->pDmaBuffer) + cbBuffer;
    5959 
    5960     pCmd->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    5961     /* sanity */
    5962     pCmd->u32FenceID = 0;
     5841                if (pRender->CommandLength != RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize]))
     5842                {
     5843                    WARN(("pRender->CommandLength (%d) != RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize](%d)",
     5844                            pRender->CommandLength, RT_OFFSETOF(VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD, aBufInfos[pRender->AllocationListSize])));
     5845                    return STATUS_INVALID_PARAMETER;
     5846                }
     5847
     5848                if (pRender->AllocationListSize >= (UINT32_MAX - RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd.aBuffers))/ RT_SIZEOFMEMB(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[0]))
     5849                {
     5850                    WARN(("Invalid AllocationListSize %d", pRender->AllocationListSize));
     5851                    return STATUS_INVALID_PARAMETER;
     5852                }
     5853
     5854                cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
     5855                cbPrivateData = RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[pRender->AllocationListSize]);
     5856
     5857                if (pRender->DmaBufferPrivateDataSize < cbPrivateData)
     5858                {
     5859                    WARN(("pRender->DmaBufferPrivateDataSize too small %d, requested %d", pRender->DmaBufferPrivateDataSize, cbPrivateData));
     5860                    return STATUS_INVALID_PARAMETER;
     5861                }
     5862
     5863                if (pRender->DmaSize < cbBuffer)
     5864                {
     5865                    WARN(("dma buffer %d too small", pRender->DmaSize));
     5866                    return STATUS_INVALID_PARAMETER;
     5867                }
     5868
     5869    //            Assert(pRender->PatchLocationListOutSize == pRender->AllocationListSize);
     5870
     5871                if (pRender->PatchLocationListOutSize < pRender->AllocationListSize)
     5872                {
     5873                    WARN(("pRender->PatchLocationListOutSize too small %d, requested %d", pRender->PatchLocationListOutSize, pRender->AllocationListSize));
     5874                    return STATUS_INVALID_PARAMETER;
     5875                }
     5876
     5877                PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD pUmCmd = (PVBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD)pInputHdr;
     5878                VBOXCMDVBVA_CRCMD* pChromiumCmd = (VBOXCMDVBVA_CRCMD*)pRender->pDmaBufferPrivateData;
     5879
     5880                PVBOXWDDM_CONTEXT pContext = (PVBOXWDDM_CONTEXT)hContext;
     5881                PVBOXWDDM_DEVICE pDevice = pContext->pDevice;
     5882                PVBOXMP_DEVEXT pDevExt = pDevice->pAdapter;
     5883
     5884                pChromiumCmd->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_CRCMD;
     5885                pChromiumCmd->Hdr.u8Flags = 0;
     5886                pChromiumCmd->Cmd.cBuffers = pRender->AllocationListSize;
     5887
     5888                DXGK_ALLOCATIONLIST *pAllocationList = pRender->pAllocationList;
     5889                VBOXCMDVBVA_CRCMD_BUFFER *pSubmInfo = pChromiumCmd->Cmd.aBuffers;
     5890                PVBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO pSubmUmInfo = pUmCmd->aBufInfos;
     5891
     5892                for (UINT i = 0; i < pRender->AllocationListSize; ++i, ++pRender->pPatchLocationListOut, ++pAllocationList, ++pSubmInfo, ++pSubmUmInfo)
     5893                {
     5894                    VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO SubmUmInfo = *pSubmUmInfo;
     5895                    D3DDDI_PATCHLOCATIONLIST* pPLL = pRender->pPatchLocationListOut;
     5896                    PVBOXWDDM_ALLOCATION pAlloc = vboxWddmGetAllocationFromAllocList(pDevExt, pAllocationList);
     5897                    if (SubmUmInfo.offData >= pAlloc->AllocData.SurfDesc.cbSize
     5898                            || SubmUmInfo.cbData > pAlloc->AllocData.SurfDesc.cbSize
     5899                            || SubmUmInfo.offData + SubmUmInfo.cbData > pAlloc->AllocData.SurfDesc.cbSize)
     5900                    {
     5901                        WARN(("invalid data"));
     5902                        return STATUS_INVALID_PARAMETER;
     5903                    }
     5904
     5905                    memset(pPLL, 0, sizeof (*pPLL));
     5906
     5907                    if (pAllocationList->SegmentId)
     5908                        pSubmInfo->offBuffer = pAllocationList->PhysicalAddress.LowPart + SubmUmInfo.offData;
     5909
     5910                    pSubmInfo->cbBuffer = SubmUmInfo.cbData;
     5911
     5912                    pPLL->AllocationIndex = i;
     5913                    pPLL->PatchOffset = RT_OFFSETOF(VBOXCMDVBVA_CRCMD, Cmd.aBuffers[i].offBuffer);
     5914                    pPLL->AllocationOffset = SubmUmInfo.offData;
     5915                }
     5916
     5917                break;
     5918            }
     5919            case VBOXVDMACMD_TYPE_DMA_NOP:
     5920            {
     5921                cbPrivateData = sizeof (VBOXCMDVBVA_HDR);
     5922                cbBuffer = VBOXWDDM_DUMMY_DMABUFFER_SIZE;
     5923
     5924                if (pRender->DmaBufferPrivateDataSize < cbPrivateData)
     5925                {
     5926                    WARN(("pRender->DmaBufferPrivateDataSize too small %d, requested %d", pRender->DmaBufferPrivateDataSize, cbPrivateData));
     5927                    return STATUS_INVALID_PARAMETER;
     5928                }
     5929
     5930                if (pRender->DmaSize < cbBuffer)
     5931                {
     5932                    WARN(("dma buffer %d too small", pRender->DmaSize));
     5933                    return STATUS_INVALID_PARAMETER;
     5934                }
     5935
     5936                pCmd->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
     5937                pCmd->u8Flags = 0;
     5938
     5939                for (UINT i = 0; i < pRender->AllocationListSize; ++i, ++pRender->pPatchLocationListOut)
     5940                {
     5941                    D3DDDI_PATCHLOCATIONLIST* pPLL = pRender->pPatchLocationListOut;
     5942                    memset(pPLL, 0, sizeof (*pPLL));
     5943                    pPLL->AllocationIndex = i;
     5944                    pPLL->PatchOffset = ~0UL;
     5945                    pPLL->AllocationOffset = 0;
     5946                }
     5947
     5948                break;
     5949            }
     5950            default:
     5951             {
     5952                 WARN(("unsupported render command %d", pInputHdr->enmCmd));
     5953                 return STATUS_INVALID_PARAMETER;
     5954             }
     5955        }
     5956
     5957        pRender->pDmaBufferPrivateData = ((uint8_t*)pRender->pDmaBufferPrivateData) + cbPrivateData;
     5958        pRender->pDmaBuffer = ((uint8_t*)pRender->pDmaBuffer) + cbBuffer;
     5959
     5960        pCmd->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
     5961        /* sanity */
     5962        pCmd->u32FenceID = 0;
    59635963    }
    59645964    __except (EXCEPTION_EXECUTE_HANDLER)
Note: See TracChangeset for help on using the changeset viewer.

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