VirtualBox

Changeset 51036 in vbox


Ignore:
Timestamp:
Apr 10, 2014 12:38:51 PM (11 years ago)
Author:
vboxsync
Message:

wddm: new command submission fixes

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm
Files:
3 edited

Legend:

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

    r50947 r51036  
    930930}
    931931
    932 int VBoxCmdVbvaSubmit(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, struct VBOXCMDVBVA_HDR *pCmd, uint32_t cbCmd)
     932int VBoxCmdVbvaSubmit(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, struct VBOXCMDVBVA_HDR *pCmd, uint32_t u32FenceID, uint32_t cbCmd)
    933933{
    934934    int rc = VINF_SUCCESS;
    935935
    936     Assert(pCmd->u32FenceID);
     936    Assert(u32FenceID);
    937937
    938938    pCmd->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    939939#ifdef DEBUG_misha
    940     Assert(pCmd->u32FenceID == pVbva->u32FenceSubmitted + 1);
     940    Assert(u32FenceID == pVbva->u32FenceSubmitted + 1);
    941941#endif
    942     pVbva->u32FenceSubmitted = pCmd->u32FenceID;
    943 
    944942    if (VBoxVBVAExGetSize(&pVbva->Vbva) < cbCmd)
    945943    {
     
    989987    }
    990988
     989    pVbva->u32FenceSubmitted = u32FenceID;
     990
    991991    Assert(pvBuffer);
    992992
    993993    memcpy(pvBuffer, pCmd, cbCmd);
     994
     995    ((VBOXCMDVBVA_HDR*)pvBuffer)->u32FenceID = u32FenceID;
    994996
    995997    VBoxVBVAExBufferEndUpdate(&pVbva->Vbva);
     
    11871189    *pcPagesWritten = i;
    11881190    Assert(cbInitBuffer - cbBuffer == RT_OFFSETOF(VBOXCMDVBVA_PAGING_TRANSFER, Data.aPageNumbers[i]));
     1191    Assert(cbInitBuffer - cbBuffer >= sizeof (VBOXCMDVBVA_PAGING_TRANSFER));
    11891192    return cbInitBuffer - cbBuffer;
    11901193}
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVbva.h

    r50947 r51036  
    212212int VBoxCmdVbvaDestroy(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva);
    213213int VBoxCmdVbvaCreate(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, ULONG offBuffer, ULONG cbBuffer);
    214 int VBoxCmdVbvaSubmit(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, struct VBOXCMDVBVA_HDR *pCmd, uint32_t cbCmd);
     214int VBoxCmdVbvaSubmit(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, struct VBOXCMDVBVA_HDR *pCmd, uint32_t u32FenceID, uint32_t cbCmd);
    215215bool VBoxCmdVbvaPreempt(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, uint32_t u32FenceID);
    216216uint32_t VBoxCmdVbvaCheckCompleted(PVBOXMP_DEVEXT pDevExt, VBOXCMDVBVA *pVbva, bool fPingHost);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp

    r51018 r51036  
    20962096
    20972097                pQsOut->PagingBufferSegmentId = 0;
    2098                 pQsOut->PagingBufferSize = 0xc00;
    2099                 pQsOut->PagingBufferPrivateDataSize = 0;
     2098                pQsOut->PagingBufferSize = PAGE_SIZE;
     2099                pQsOut->PagingBufferPrivateDataSize = PAGE_SIZE;
    21002100            }
    21012101            }
     
    31073107#endif
    31083108
    3109     /* the DMA command buffer is located in system RAM, the host will need to pick it from there */
    3110     //BufInfo.fFlags = 0; /* see VBOXVDMACBUF_FLAG_xx */
     3109    uint32_t cbCmd = pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset - pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset;
     3110    uint32_t cbDma = pSubmitCommand->DmaBufferSubmissionEndOffset - pSubmitCommand->DmaBufferSubmissionStartOffset;
    31113111    VBOXCMDVBVA_HDR *pHdr;
    3112     VBOXCMDVBVA_SYSMEMCMD SysMem;
    3113     uint32_t cbCmd = pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset - pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset;
    3114     if (!cbCmd)
    3115     {
    3116         cbCmd = pSubmitCommand->DmaBufferSubmissionEndOffset - pSubmitCommand->DmaBufferSubmissionStartOffset;
    3117         if (!cbCmd || VBOXWDDM_DUMMY_DMABUFFER_SIZE == cbCmd)
    3118         {
    3119             SysMem.Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
    3120             SysMem.Hdr.u8Flags = 0;
    3121             SysMem.Hdr.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    3122             cbCmd = sizeof (SysMem.Hdr);
    3123         }
    3124         else
    3125         {
    3126             if (cbCmd < sizeof (VBOXCMDVBVA_HDR))
    3127             {
    3128                 WARN(("DmaBufferPrivateDataSubmissionEndOffset (%d) - DmaBufferPrivateDataSubmissionStartOffset (%d) < sizeof (VBOXCMDVBVA_HDR) (%d)",
    3129                         pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset,
    3130                         pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset,
    3131                         sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)));
    3132                 return STATUS_INVALID_PARAMETER;
    3133             }
    3134 
    3135             if (cbCmd > 0xffff)
    3136             {
    3137                 WARN(("cbCmd too big"));
    3138                 return STATUS_INVALID_PARAMETER;
    3139             }
    3140 
    3141             SysMem.Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_SYSMEMCMD;
    3142             SysMem.Hdr.u8Flags = cbCmd & 0xff;
    3143             SysMem.Hdr.u.u8PrimaryID = (cbCmd >> 8) & 0xff;
    3144             SysMem.Hdr.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
     3112    VBOXCMDVBVA_HDR NopCmd;
     3113    if (cbCmd < sizeof (VBOXCMDVBVA_HDR))
     3114    {
     3115        if (cbCmd)
     3116        {
     3117            WARN(("invalid command data"));
     3118            return STATUS_INVALID_PARAMETER;
     3119        }
     3120        NopCmd.u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
     3121        NopCmd.u8Flags = 0;
     3122        NopCmd.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
     3123        NopCmd.u32FenceID = sizeof (VBOXCMDVBVA_HDR);
     3124        cbCmd = sizeof (VBOXCMDVBVA_HDR);
     3125        pHdr = &NopCmd;
     3126    }
     3127    else
     3128    {
     3129        pHdr = (VBOXCMDVBVA_HDR*)(((uint8_t*)pSubmitCommand->pDmaBufferPrivateData) + pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset);
     3130        if (cbCmd != pHdr->u32FenceID)
     3131        {
     3132            WARN(("partial submission start!"));
     3133            cbCmd = pHdr->u32FenceID;
     3134        }
     3135    }
     3136
     3137    switch (pHdr->u8OpCode)
     3138    {
     3139        case VBOXCMDVBVA_OPTYPE_SYSMEMCMD:
     3140        {
     3141            VBOXCMDVBVA_SYSMEMCMD *pSysMem = (VBOXCMDVBVA_SYSMEMCMD*)pHdr;
    31453142            if (pSubmitCommand->DmaBufferPhysicalAddress.QuadPart & PAGE_OFFSET_MASK)
    31463143            {
     
    31483145                return STATUS_INVALID_PARAMETER;
    31493146            }
    3150             SysMem.phCmd = (VBOXCMDVBVAPHADDR)(pSubmitCommand->DmaBufferPhysicalAddress.QuadPart + pSubmitCommand->DmaBufferSubmissionStartOffset);
    3151 
    3152             cbCmd = sizeof (SysMem);
    3153         }
    3154 
    3155         pHdr = &SysMem.Hdr;
    3156     }
    3157     else
    3158     {
    3159         if (cbCmd < sizeof (VBOXCMDVBVA_HDR))
    3160         {
    3161             WARN(("DmaBufferPrivateDataSubmissionEndOffset (%d) - DmaBufferPrivateDataSubmissionStartOffset (%d) < sizeof (VBOXCMDVBVA_HDR) (%d)",
    3162                     pSubmitCommand->DmaBufferPrivateDataSubmissionEndOffset,
    3163                     pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset,
    3164                     sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)));
    3165             return STATUS_INVALID_PARAMETER;
    3166         }
    3167 
    3168         pHdr = (VBOXCMDVBVA_HDR*)((uint8_t*)pSubmitCommand->pDmaBufferPrivateData + pSubmitCommand->DmaBufferPrivateDataSubmissionStartOffset);
    3169     }
    3170 
    3171     pHdr->u32FenceID = pSubmitCommand->SubmissionFenceId;
    3172     int rc = VBoxCmdVbvaSubmit(pDevExt, &pDevExt->CmdVbva, pHdr, cbCmd);
     3147            pSysMem->phCmd = (VBOXCMDVBVAPHADDR)(pSubmitCommand->DmaBufferPhysicalAddress.QuadPart + pSubmitCommand->DmaBufferSubmissionStartOffset);
     3148#ifdef DEBUG
     3149            {
     3150                uint32_t cbRealDmaCmd = (pSysMem->Hdr.u8Flags | (pSysMem->Hdr.u.u8PrimaryID << 8));
     3151                Assert(cbRealDmaCmd >= cbDma);
     3152                if (cbDma < cbRealDmaCmd)
     3153                    WARN(("parrtial sysmem transfer"));
     3154            }
     3155#endif
     3156            break;
     3157        }
     3158        default:
     3159            break;
     3160    }
     3161
     3162    int rc = VBoxCmdVbvaSubmit(pDevExt, &pDevExt->CmdVbva, pHdr, pSubmitCommand->SubmissionFenceId, cbCmd);
    31733163    if (RT_SUCCESS(rc))
    31743164        return STATUS_SUCCESS;
     
    34423432#endif
    34433433
     3434            if (pBuildPagingBuffer->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_SYSMEMCMD))
     3435            {
     3436                WARN(("private data too small"));
     3437                return STATUS_INVALID_PARAMETER;
     3438            }
     3439
    34443440            Assert(!pBuildPagingBuffer->Transfer.MdlOffset);
    34453441
     
    34763472            pPaging->Hdr.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    34773473            pPaging->Hdr.u32FenceID = 0;
    3478 
    34793474
    34803475            PMDL pMdl;
     
    35283523                pBuildPagingBuffer->MultipassOffset = 0;
    35293524
     3525            VBOXCMDVBVA_SYSMEMCMD *pSysMemCmd = (VBOXCMDVBVA_SYSMEMCMD*)pBuildPagingBuffer->pDmaBufferPrivateData;
     3526            pSysMemCmd->Hdr.u8OpCode = VBOXCMDVBVA_OPTYPE_SYSMEMCMD;
     3527            pSysMemCmd->Hdr.u8Flags = cbBuffer & 0xff;
     3528            pSysMemCmd->Hdr.u.u8PrimaryID = (cbBuffer >> 8) & 0xff;
     3529            pSysMemCmd->Hdr.u8State = VBOXCMDVBVA_STATE_SUBMITTED;
     3530            pSysMemCmd->Hdr.u32FenceID = sizeof (*pSysMemCmd);
     3531            pSysMemCmd->phCmd = 0;
     3532
     3533            cbPrivateData = sizeof (*pSysMemCmd);
     3534
    35303535            break;
    35313536        }
     
    35393544                return STATUS_INVALID_PARAMETER;
    35403545            }
     3546
     3547            if (pBuildPagingBuffer->DmaBufferPrivateDataSize < sizeof (VBOXCMDVBVA_HDR))
     3548            {
     3549                WARN(("private data too small"));
     3550                return STATUS_INVALID_PARAMETER;
     3551            }
     3552
     3553            VBOXCMDVBVA_HDR *pHdr = (VBOXCMDVBVA_HDR*)pBuildPagingBuffer->pDmaBufferPrivateData;
     3554            pHdr->u8OpCode = VBOXCMDVBVA_OPTYPE_NOPCMD;
     3555            pHdr->u8Flags = 0;
     3556            pHdr->u.u8PrimaryID = 0;
     3557            pHdr->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
     3558            pHdr->u32FenceID = sizeof (*pHdr);
     3559
     3560            cbPrivateData = sizeof (*pHdr);
    35413561            /** @todo: add necessary bits */
    35423562//            WARN(("Impl!"));
     
    35623582    }
    35633583
    3564     Assert(!cbPrivateData);
    3565 
    35663584    Assert(pBuildPagingBuffer->Operation == DXGK_OPERATION_DISCARD_CONTENT || cbBuffer);
     3585    Assert(cbBuffer <= pBuildPagingBuffer->DmaSize);
     3586    Assert(cbBuffer == 0 || cbBuffer >= sizeof (VBOXCMDVBVA_PAGING_TRANSFER) || cbBuffer == VBOXWDDM_DUMMY_DMABUFFER_SIZE);
     3587    AssertCompile(VBOXWDDM_DUMMY_DMABUFFER_SIZE < 8);
    35673588    pBuildPagingBuffer->pDmaBuffer = ((uint8_t*)pBuildPagingBuffer->pDmaBuffer) + cbBuffer;
    35683589    pBuildPagingBuffer->pDmaBufferPrivateData = ((uint8_t*)pBuildPagingBuffer->pDmaBufferPrivateData) + cbPrivateData;
     
    58275848        uint32_t cbBuffer = 0;
    58285849        uint32_t cbPrivateData = 0;
     5850        uint32_t cbCmd = 0;
    58295851        VBOXCMDVBVA_HDR* pCmd = (VBOXCMDVBVA_HDR*)pRender->pDmaBufferPrivateData;
    58305852
     
    59155937                }
    59165938
     5939                cbCmd = cbPrivateData;
     5940
    59175941                break;
    59185942            }
     
    59465970                }
    59475971
     5972                cbCmd = cbPrivateData;
     5973
    59485974                break;
    59495975            }
     
    59595985
    59605986        pCmd->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    5961         /* sanity */
    5962         pCmd->u32FenceID = 0;
     5987        pCmd->u32FenceID = cbPrivateData;
    59635988    }
    59645989    __except (EXCEPTION_EXECUTE_HANDLER)
     
    59675992        WARN(("invalid parameter"));
    59685993    }
    5969 //    LOGF(("LEAVE, hContext(0x%x)", hContext));
    5970 
    5971     return Status;
    5972 
    59735994//    LOGF(("LEAVE, hContext(0x%x)", hContext));
    59745995
     
    65166537
    65176538    pHdr->u8State = VBOXCMDVBVA_STATE_SUBMITTED;
    6518     /* sanity */
    6519     pHdr->u32FenceID = 0;
     6539
     6540    pHdr->u32FenceID = cbPrivateData;
    65206541
    65216542    Assert(cbBuffer);
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