VirtualBox

Changeset 95012 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
May 14, 2022 9:30:07 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151443
Message:

Devices/Graphics: new commands; fixes for CreateInputLayout, CreateResource; set initial count for unordered access views: bugref:9830

Location:
trunk/src/VBox/Devices/Graphics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp

    r95008 r95012  
    38073807{
    38083808#ifdef VMSVGA3D_DX
    3809     DEBUG_BREAKPOINT_TEST();
    3810     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3811     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    3812     return vmsvga3dDXCopyStructureCount(pThisCC, idDXContext);
     3809    //DEBUG_BREAKPOINT_TEST();
     3810    RT_NOREF(cbCmd);
     3811    return vmsvga3dDXCopyStructureCount(pThisCC, idDXContext, pCmd);
    38133812#else
    38143813    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
     
    38373836{
    38383837#ifdef VMSVGA3D_DX
    3839     DEBUG_BREAKPOINT_TEST();
    3840     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3841     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    3842     return vmsvga3dDXDrawIndexedInstancedIndirect(pThisCC, idDXContext);
     3838    //DEBUG_BREAKPOINT_TEST();
     3839    RT_NOREF(cbCmd);
     3840    return vmsvga3dDXDrawIndexedInstancedIndirect(pThisCC, idDXContext, pCmd);
    38433841#else
    38443842    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
     
    38523850{
    38533851#ifdef VMSVGA3D_DX
    3854     DEBUG_BREAKPOINT_TEST();
    3855     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3856     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    3857     return vmsvga3dDXDrawInstancedIndirect(pThisCC, idDXContext);
     3852    //DEBUG_BREAKPOINT_TEST();
     3853    RT_NOREF(cbCmd);
     3854    return vmsvga3dDXDrawInstancedIndirect(pThisCC, idDXContext, pCmd);
    38583855#else
    38593856    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
     
    39413938{
    39423939#ifdef VMSVGA3D_DX
    3943     DEBUG_BREAKPOINT_TEST();
    3944     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3945     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    3946     return vmsvga3dDXSetStructureCount(pThisCC, idDXContext);
     3940    //DEBUG_BREAKPOINT_TEST();
     3941    RT_NOREF(cbCmd);
     3942    return vmsvga3dDXSetStructureCount(pThisCC, idDXContext, pCmd);
    39473943#else
    39483944    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp

    r95008 r95012  
    28862886
    28872887
    2888 int vmsvga3dDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext)
     2888int vmsvga3dDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXCopyStructureCount const *pCmd)
    28892889{
    28902890    int rc;
     
    28982898    AssertRCReturn(rc, rc);
    28992899
    2900     rc = pSvgaR3State->pFuncsDX->pfnDXCopyStructureCount(pThisCC, pDXContext);
     2900    SVGA3dUAViewId const uaViewId = pCmd->srcUAViewId;
     2901
     2902    ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
     2903    ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
     2904    RT_UNTRUSTED_VALIDATED_FENCE();
     2905
     2906    rc = pSvgaR3State->pFuncsDX->pfnDXCopyStructureCount(pThisCC, pDXContext, uaViewId, pCmd->destSid, pCmd->destByteOffset);
    29012907    return rc;
    29022908}
     
    29342940
    29352941
    2936 int vmsvga3dDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext)
     2942int vmsvga3dDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstancedIndirect const *pCmd)
    29372943{
    29382944    int rc;
     
    29462952    AssertRCReturn(rc, rc);
    29472953
    2948     rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstancedIndirect(pThisCC, pDXContext);
    2949     return rc;
    2950 }
    2951 
    2952 
    2953 int vmsvga3dDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext)
     2954    rc = pSvgaR3State->pFuncsDX->pfnDXDrawIndexedInstancedIndirect(pThisCC, pDXContext, pCmd->argsBufferSid, pCmd->byteOffsetForArgs);
     2955    return rc;
     2956}
     2957
     2958
     2959int vmsvga3dDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstancedIndirect const *pCmd)
    29542960{
    29552961    int rc;
     
    29632969    AssertRCReturn(rc, rc);
    29642970
    2965     rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstancedIndirect(pThisCC, pDXContext);
     2971    rc = pSvgaR3State->pFuncsDX->pfnDXDrawInstancedIndirect(pThisCC, pDXContext, pCmd->argsBufferSid, pCmd->byteOffsetForArgs);
    29662972    return rc;
    29672973}
     
    30533059
    30543060
    3055 int vmsvga3dDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext)
    3056 {
    3057     int rc;
    3058     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3059     AssertReturn(pSvgaR3State->pFuncsDX && pSvgaR3State->pFuncsDX->pfnDXSetStructureCount, VERR_INVALID_STATE);
    3060     PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
    3061     AssertReturn(p3dState, VERR_INVALID_STATE);
    3062 
    3063     PVMSVGA3DDXCONTEXT pDXContext;
    3064     rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
    3065     AssertRCReturn(rc, rc);
    3066 
    3067     rc = pSvgaR3State->pFuncsDX->pfnDXSetStructureCount(pThisCC, pDXContext);
    3068     return rc;
     3061int vmsvga3dDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStructureCount const *pCmd)
     3062{
     3063    int rc;
     3064    PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
     3065    AssertReturn(pSvgaR3State->pFuncsDX, VERR_INVALID_STATE);
     3066    PVMSVGA3DSTATE p3dState = pThisCC->svga.p3dState;
     3067    AssertReturn(p3dState, VERR_INVALID_STATE);
     3068
     3069    PVMSVGA3DDXCONTEXT pDXContext;
     3070    rc = vmsvga3dDXContextFromCid(p3dState, idDXContext, &pDXContext);
     3071    AssertRCReturn(rc, rc);
     3072
     3073    SVGA3dUAViewId const uaViewId = pCmd->uaViewId;
     3074
     3075    ASSERT_GUEST_RETURN(pDXContext->cot.paUAView, VERR_INVALID_STATE);
     3076    ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
     3077    RT_UNTRUSTED_VALIDATED_FENCE();
     3078
     3079    SVGACOTableDXUAViewEntry *pEntry = &pDXContext->cot.paUAView[uaViewId];
     3080    pEntry->structureCount = pCmd->structureCount;
     3081
     3082    return VINF_SUCCESS;
    30693083}
    30703084
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp

    r95008 r95012  
    26452645
    26462646
    2647 static int vmsvga3dBackSurfaceCreateResource(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface, UINT MiscFlags = 0)
     2647static int vmsvga3dBackSurfaceCreateResource(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface)
    26482648{
    26492649    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     
    27032703            bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    27042704
    2705         bd.MiscFlags |= MiscFlags;
     2705        if (pSurface->f.surfaceFlags & SVGA3D_SURFACE_DRAWINDIRECT_ARGS)
     2706            bd.MiscFlags |= D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS;
     2707        if (pSurface->f.surfaceFlags & SVGA3D_SURFACE_BIND_RAW_VIEWS)
     2708            bd.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS;
     2709        if (pSurface->f.surfaceFlags & SVGA3D_SURFACE_BUFFER_STRUCTURED)
     2710            bd.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
     2711        if (pSurface->f.surfaceFlags & SVGA3D_SURFACE_RESOURCE_CLAMP)
     2712            bd.MiscFlags |= D3D11_RESOURCE_MISC_RESOURCE_CLAMP;
     2713
     2714        if (bd.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED)
     2715        {
     2716            SVGAOTableSurfaceEntry entrySurface;
     2717            rc = vmsvgaR3OTableReadSurface(pThisCC->svga.pSvgaR3State, pSurface->id, &entrySurface);
     2718            AssertRCReturn(rc, rc);
     2719
     2720            bd.StructureByteStride = entrySurface.bufferByteStride;
     2721        }
    27062722
    27072723        hr = pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBackendSurface->u.pBuffer);
     
    52215237
    52225238
     5239static void dxCreateInputLayout(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dElementLayoutId elementLayoutId, DXSHADER *pDXShader)
     5240{
     5241    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     5242    AssertReturnVoid(pDevice->pDevice);
     5243
     5244    SVGACOTableDXElementLayoutEntry const *pEntry = &pDXContext->cot.paElementLayout[elementLayoutId];
     5245    DXELEMENTLAYOUT *pDXElementLayout = &pDXContext->pBackendDXContext->paElementLayout[elementLayoutId];
     5246
     5247    if (pDXElementLayout->cElementDesc == 0)
     5248    {
     5249        /* Semantic name is not interpreted by D3D, therefore arbitrary names can be used
     5250         * if they are consistent between the element layout and shader input signature.
     5251         * "In general, data passed between pipeline stages is completely generic and is not uniquely
     5252         * interpreted by the system; arbitrary semantics are allowed ..."
     5253         *
     5254         * However D3D runtime insists that "SemanticName string ("POSITIO1") cannot end with a number."
     5255         *
     5256         * System-Value semantics ("SV_*") between shaders require proper names of course.
     5257         * But they are irrelevant for input attributes.
     5258         */
     5259        pDXElementLayout->cElementDesc = pEntry->numDescs;
     5260        for (uint32_t i = 0; i < pEntry->numDescs; ++i)
     5261        {
     5262            D3D11_INPUT_ELEMENT_DESC *pDst = &pDXElementLayout->aElementDesc[i];
     5263            SVGA3dInputElementDesc const *pSrc = &pEntry->descs[i];
     5264            pDst->SemanticName         = "ATTRIB";
     5265            pDst->SemanticIndex        = pSrc->inputRegister;
     5266            pDst->Format               = vmsvgaDXSurfaceFormat2Dxgi(pSrc->format);
     5267            Assert(pDst->Format != DXGI_FORMAT_UNKNOWN);
     5268            pDst->InputSlot            = pSrc->inputSlot;
     5269            pDst->AlignedByteOffset    = pSrc->alignedByteOffset;
     5270            pDst->InputSlotClass       = (D3D11_INPUT_CLASSIFICATION)pSrc->inputSlotClass;
     5271            pDst->InstanceDataStepRate = pSrc->instanceDataStepRate;
     5272        }
     5273    }
     5274
     5275    HRESULT hr = pDevice->pDevice->CreateInputLayout(pDXElementLayout->aElementDesc,
     5276                                                     pDXElementLayout->cElementDesc,
     5277                                                     pDXShader->pvDXBC,
     5278                                                     pDXShader->cbDXBC,
     5279                                                     &pDXElementLayout->pElementLayout);
     5280    Assert(SUCCEEDED(hr)); RT_NOREF(hr);
     5281}
     5282
     5283
    52235284static void dxSetupPipeline(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    52245285{
     
    55725633                DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[shid];
    55735634                if (pDXShader->pvDXBC)
    5574                 {
    5575                     HRESULT hr = pDevice->pDevice->CreateInputLayout(pDXElementLayout->aElementDesc,
    5576                                                                      pDXElementLayout->cElementDesc,
    5577                                                                      pDXShader->pvDXBC,
    5578                                                                      pDXShader->cbDXBC,
    5579                                                                      &pDXElementLayout->pElementLayout);
    5580                     Assert(SUCCEEDED(hr)); RT_NOREF(hr);
    5581                 }
     5635                    dxCreateInputLayout(pThisCC, pDXContext, elementLayoutId, pDXShader);
    55825636                else
    55835637                    LogRelMax(16, ("VMSVGA: DX shader bytecode is not available in DXSetInputLayout: shid = %u\n", shid));
     
    61256179            NumUAVs = idxUA - UAVStartSlot + 1;
    61266180            apUnorderedAccessViews[idxUA] = pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId].u.pUnorderedAccessView;
     6181
     6182            SVGACOTableDXUAViewEntry const *pEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
     6183            aUAVInitialCounts[idxUA] = pEntry->structureCount;
    61276184        }
    61286185        else
     6186        {
    61296187            apUnorderedAccessViews[idxUA] =  NULL;
    6130 
    6131         /** @todo */
    6132         aUAVInitialCounts[idxUA] = (UINT)-1;
     6188            aUAVInitialCounts[idxUA] = (UINT)-1;
     6189        }
    61336190    }
    61346191
     
    69356992    DXELEMENTLAYOUT *pDXElementLayout = &pDXContext->pBackendDXContext->paElementLayout[elementLayoutId];
    69366993    D3D_RELEASE(pDXElementLayout->pElementLayout);
    6937 
    6938     /* Semantic name is not interpreted by D3D, therefore arbitrary names can be used
    6939      * if they are consistent between the element layout and shader input signature.
    6940      * "In general, data passed between pipeline stages is completely generic and is not uniquely
    6941      * interpreted by the system; arbitrary semantics are allowed ..."
    6942      *
    6943      * However D3D runtime insists that "SemanticName string ("POSITIO1") cannot end with a number."
    6944      *
    6945      * System-Value semantics ("SV_*") between shaders require proper names of course.
    6946      * But they are irrelevant for input attributes.
    6947      */
    6948     pDXElementLayout->cElementDesc = pEntry->numDescs;
    6949     for (uint32_t i = 0; i < pEntry->numDescs; ++i)
    6950     {
    6951         D3D11_INPUT_ELEMENT_DESC *pDst = &pDXElementLayout->aElementDesc[i];
    6952         SVGA3dInputElementDesc const *pSrc = &pEntry->descs[i];
    6953         pDst->SemanticName         = "ATTRIB";
    6954         pDst->SemanticIndex        = i; /// @todo 'pSrc->inputRegister' is unused, maybe it should somehow.
    6955         pDst->Format               = vmsvgaDXSurfaceFormat2Dxgi(pSrc->format);
    6956         AssertReturn(pDst->Format != DXGI_FORMAT_UNKNOWN, VERR_NOT_IMPLEMENTED);
    6957         pDst->InputSlot            = pSrc->inputSlot;
    6958         pDst->AlignedByteOffset    = pSrc->alignedByteOffset;
    6959         pDst->InputSlotClass       = (D3D11_INPUT_CLASSIFICATION)pSrc->inputSlotClass;
    6960         pDst->InstanceDataStepRate = pSrc->instanceDataStepRate;
    6961     }
     6994    pDXElementLayout->cElementDesc = 0;
     6995    RT_ZERO(pDXElementLayout->aElementDesc);
     6996
     6997    RT_NOREF(pEntry);
    69626998
    69636999    return VINF_SUCCESS;
     
    78337869            rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, pDXContext, pSurface);
    78347870        else
    7835         {
    7836             UINT MiscFlags = 0;
    7837             if (   pEntry->resourceDimension == SVGA3D_RESOURCE_BUFFER
    7838                 && (pEntry->desc.buffer.flags & (SVGA3D_UABUFFER_APPEND | SVGA3D_UABUFFER_COUNTER)))
    7839                 MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
    7840 
    7841             rc = vmsvga3dBackSurfaceCreateResource(pThisCC, pDXContext, pSurface, MiscFlags);
    7842         }
     7871            rc = vmsvga3dBackSurfaceCreateResource(pThisCC, pDXContext, pSurface);
    78437872
    78447873        AssertRCReturn(rc, rc);
     
    78757904
    78767905static DECLCALLBACK(int) vmsvga3dBackDXClearUAViewUint(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, uint32_t const aValues[4])
     7906{
     7907    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     7908    RT_NOREF(pBackend);
     7909
     7910    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     7911    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     7912
     7913    DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
     7914    if (!pDXView->u.pUnorderedAccessView)
     7915    {
     7916        /* (Re-)create the view, because a creation of a view is deferred until a draw or a clear call. */
     7917        SVGACOTableDXUAViewEntry const *pEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
     7918        int rc = dxDefineUnorderedAccessView(pThisCC, pDXContext, uaViewId, pEntry);
     7919        AssertRCReturn(rc, rc);
     7920    }
     7921    pDevice->pImmediateContext->ClearUnorderedAccessViewUint(pDXView->u.pUnorderedAccessView, aValues);
     7922    return VINF_SUCCESS;
     7923}
     7924
     7925
     7926static DECLCALLBACK(int) vmsvga3dBackDXClearUAViewFloat(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, float const aValues[4])
    78777927{
    78787928    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     
    78907940        AssertRCReturn(rc, rc);
    78917941    }
    7892     pDevice->pImmediateContext->ClearUnorderedAccessViewUint(pDXView->u.pUnorderedAccessView, aValues);
    7893     return VINF_SUCCESS;
    7894 }
    7895 
    7896 
    7897 static DECLCALLBACK(int) vmsvga3dBackDXClearUAViewFloat(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, float const aValues[4])
     7942    pDevice->pImmediateContext->ClearUnorderedAccessViewFloat(pDXView->u.pUnorderedAccessView, aValues);
     7943    return VINF_SUCCESS;
     7944}
     7945
     7946
     7947static DECLCALLBACK(int) vmsvga3dBackDXCopyStructureCount(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId srcUAViewId, SVGA3dSurfaceId destSid, uint32_t destByteOffset)
    78987948{
    78997949    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     
    79037953    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    79047954
    7905     DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
    7906     if (!pDXView->u.pUnorderedAccessView)
    7907     {
    7908         /* (Re-)create the view, because a creation of a view is deferred until a draw or a clear call. */
    7909         SVGACOTableDXUAViewEntry const *pEntry = &pDXContext->cot.paUAView[uaViewId];
    7910         int rc = dxDefineUnorderedAccessView(pThisCC, pDXContext, uaViewId, pEntry);
     7955    /* Get corresponding resource. Create the buffer if does not yet exist. */
     7956    ID3D11Buffer *pDstBuffer;
     7957    if (destSid != SVGA3D_INVALID_ID)
     7958    {
     7959        PVMSVGA3DSURFACE pSurface;
     7960        int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, destSid, &pSurface);
    79117961        AssertRCReturn(rc, rc);
    7912     }
    7913     pDevice->pImmediateContext->ClearUnorderedAccessViewFloat(pDXView->u.pUnorderedAccessView, aValues);
    7914     return VINF_SUCCESS;
    7915 }
    7916 
    7917 
    7918 static DECLCALLBACK(int) vmsvga3dBackDXCopyStructureCount(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
     7962
     7963        if (pSurface->pBackendSurface == NULL)
     7964        {
     7965            /* Create the resource and initialize it with the current surface data. */
     7966            rc = vmsvga3dBackSurfaceCreateResource(pThisCC, pDXContext, pSurface);
     7967            AssertRCReturn(rc, rc);
     7968        }
     7969
     7970        pDstBuffer = pSurface->pBackendSurface->u.pBuffer;
     7971    }
     7972    else
     7973        pDstBuffer = NULL;
     7974
     7975    ID3D11UnorderedAccessView *pSrcView;
     7976    if (srcUAViewId != SVGA3D_INVALID_ID)
     7977    {
     7978        DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[srcUAViewId];
     7979        AssertReturn(pDXView->u.pUnorderedAccessView, VERR_INVALID_STATE);
     7980        pSrcView = pDXView->u.pUnorderedAccessView;
     7981    }
     7982    else
     7983        pSrcView = NULL;
     7984
     7985    pDevice->pImmediateContext->CopyStructureCount(pDstBuffer, destByteOffset, pSrcView);
     7986
     7987    return VINF_SUCCESS;
     7988}
     7989
     7990
     7991static DECLCALLBACK(int) vmsvga3dBackDXSetUAViews(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t uavSpliceIndex, uint32_t cUAViewId, SVGA3dUAViewId const *paUAViewId)
     7992{
     7993    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     7994    RT_NOREF(pBackend);
     7995
     7996    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     7997    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     7998
     7999    RT_NOREF(uavSpliceIndex, cUAViewId, paUAViewId);
     8000
     8001    return VINF_SUCCESS;
     8002}
     8003
     8004
     8005static DECLCALLBACK(int) vmsvga3dBackDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSurfaceId argsBufferSid, uint32_t byteOffsetForArgs)
     8006{
     8007    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     8008    RT_NOREF(pBackend);
     8009
     8010    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     8011    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     8012
     8013    /* Get corresponding resource. Create the buffer if does not yet exist. */
     8014    ID3D11Buffer *pBufferForArgs;
     8015    if (argsBufferSid != SVGA_ID_INVALID)
     8016    {
     8017        PVMSVGA3DSURFACE pSurface;
     8018        int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, argsBufferSid, &pSurface);
     8019        AssertRCReturn(rc, rc);
     8020
     8021        if (pSurface->pBackendSurface == NULL)
     8022        {
     8023            /* Create the resource and initialize it with the current surface data. */
     8024            rc = vmsvga3dBackSurfaceCreateResource(pThisCC, pDXContext, pSurface);
     8025            AssertRCReturn(rc, rc);
     8026        }
     8027
     8028        pBufferForArgs = pSurface->pBackendSurface->u.pBuffer;
     8029    }
     8030    else
     8031        pBufferForArgs = NULL;
     8032
     8033    dxSetupPipeline(pThisCC, pDXContext);
     8034
     8035    Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN);
     8036
     8037    pDevice->pImmediateContext->DrawIndexedInstancedIndirect(pBufferForArgs, byteOffsetForArgs);
     8038
     8039    /* Note which surfaces are being drawn. */
     8040    dxTrackRenderTargets(pThisCC, pDXContext);
     8041
     8042    return VINF_SUCCESS;
     8043}
     8044
     8045
     8046static DECLCALLBACK(int) vmsvga3dBackDXDrawInstancedIndirect(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSurfaceId argsBufferSid, uint32_t byteOffsetForArgs)
     8047{
     8048    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     8049    RT_NOREF(pBackend);
     8050
     8051    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     8052    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     8053
     8054    /* Get corresponding resource. Create the buffer if does not yet exist. */
     8055    ID3D11Buffer *pBufferForArgs;
     8056    if (argsBufferSid != SVGA_ID_INVALID)
     8057    {
     8058        PVMSVGA3DSURFACE pSurface;
     8059        int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, argsBufferSid, &pSurface);
     8060        AssertRCReturn(rc, rc);
     8061
     8062        if (pSurface->pBackendSurface == NULL)
     8063        {
     8064            /* Create the resource and initialize it with the current surface data. */
     8065            rc = vmsvga3dBackSurfaceCreateResource(pThisCC, pDXContext, pSurface);
     8066            AssertRCReturn(rc, rc);
     8067        }
     8068
     8069        pBufferForArgs = pSurface->pBackendSurface->u.pBuffer;
     8070    }
     8071    else
     8072        pBufferForArgs = NULL;
     8073
     8074    dxSetupPipeline(pThisCC, pDXContext);
     8075
     8076    Assert(pDXContext->svgaDXContext.inputAssembly.topology != SVGA3D_PRIMITIVE_TRIANGLEFAN);
     8077
     8078    pDevice->pImmediateContext->DrawInstancedIndirect(pBufferForArgs, byteOffsetForArgs);
     8079
     8080    /* Note which surfaces are being drawn. */
     8081    dxTrackRenderTargets(pThisCC, pDXContext);
     8082
     8083    return VINF_SUCCESS;
     8084}
     8085
     8086
     8087static DECLCALLBACK(int) vmsvga3dBackDXDispatch(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ)
     8088{
     8089    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     8090    RT_NOREF(pBackend);
     8091
     8092    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     8093    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     8094
     8095    pDevice->pImmediateContext->Dispatch(threadGroupCountX, threadGroupCountY, threadGroupCountZ);
     8096
     8097    return VINF_SUCCESS;
     8098}
     8099
     8100
     8101static DECLCALLBACK(int) vmsvga3dBackDXDispatchIndirect(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    79198102{
    79208103    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     
    79268109
    79278110
    7928 static DECLCALLBACK(int) vmsvga3dBackDXSetUAViews(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t uavSpliceIndex, uint32_t cUAViewId, SVGA3dUAViewId const *paUAViewId)
    7929 {
    7930     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    7931     RT_NOREF(pBackend);
    7932 
    7933     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    7934     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    7935 
    7936     RT_NOREF(uavSpliceIndex, cUAViewId, paUAViewId);
    7937 
    7938     return VINF_SUCCESS;
    7939 }
    7940 
    7941 
    7942 static DECLCALLBACK(int) vmsvga3dBackDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
     8111static DECLCALLBACK(int) vmsvga3dBackWriteZeroSurface(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    79438112{
    79448113    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     
    79508119
    79518120
    7952 static DECLCALLBACK(int) vmsvga3dBackDXDrawInstancedIndirect(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
     8121static DECLCALLBACK(int) vmsvga3dBackHintZeroSurface(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    79538122{
    79548123    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     
    79608129
    79618130
    7962 static DECLCALLBACK(int) vmsvga3dBackDXDispatch(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ)
    7963 {
    7964     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    7965     RT_NOREF(pBackend);
    7966 
    7967     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    7968     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    7969 
    7970     pDevice->pImmediateContext->Dispatch(threadGroupCountX, threadGroupCountY, threadGroupCountZ);
    7971 
    7972     return VINF_SUCCESS;
    7973 }
    7974 
    7975 
    7976 static DECLCALLBACK(int) vmsvga3dBackDXDispatchIndirect(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    7977 {
    7978     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    7979 
    7980     RT_NOREF(pBackend, pDXContext);
    7981     AssertFailed(); /** @todo Implement */
    7982     return VERR_NOT_IMPLEMENTED;
    7983 }
    7984 
    7985 
    7986 static DECLCALLBACK(int) vmsvga3dBackWriteZeroSurface(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    7987 {
    7988     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    7989 
    7990     RT_NOREF(pBackend, pDXContext);
    7991     AssertFailed(); /** @todo Implement */
    7992     return VERR_NOT_IMPLEMENTED;
    7993 }
    7994 
    7995 
    7996 static DECLCALLBACK(int) vmsvga3dBackHintZeroSurface(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    7997 {
    7998     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    7999 
    8000     RT_NOREF(pBackend, pDXContext);
    8001     AssertFailed(); /** @todo Implement */
    8002     return VERR_NOT_IMPLEMENTED;
    8003 }
    8004 
    8005 
    80068131static DECLCALLBACK(int) vmsvga3dBackDXTransferToBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    8007 {
    8008     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    8009 
    8010     RT_NOREF(pBackend, pDXContext);
    8011     AssertFailed(); /** @todo Implement */
    8012     return VERR_NOT_IMPLEMENTED;
    8013 }
    8014 
    8015 
    8016 static DECLCALLBACK(int) vmsvga3dBackDXSetStructureCount(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    80178132{
    80188133    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     
    81038218            Assert(pDXView->u.pUnorderedAccessView);
    81048219            papUnorderedAccessView[i] = pDXView->u.pUnorderedAccessView;
     8220
     8221            SVGACOTableDXUAViewEntry const *pEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
     8222            aUAVInitialCounts[i] = pEntry->structureCount;
    81058223        }
    81068224        else
     8225        {
    81078226            papUnorderedAccessView[i] = NULL;
    8108 
    8109         aUAVInitialCounts[i] = (UINT)-1; /** @todo */
     8227            aUAVInitialCounts[i] = (UINT)-1;
     8228        }
    81108229    }
    81118230
     
    84128531                p->pfnHintZeroSurface             = vmsvga3dBackHintZeroSurface;
    84138532                p->pfnDXTransferToBuffer          = vmsvga3dBackDXTransferToBuffer;
    8414                 p->pfnDXSetStructureCount         = vmsvga3dBackDXSetStructureCount;
    84158533                p->pfnLogicOpsBitBlt              = vmsvga3dBackLogicOpsBitBlt;
    84168534                p->pfnLogicOpsTransBlt            = vmsvga3dBackLogicOpsTransBlt;
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h

    r95008 r95012  
    508508    DECLCALLBACKMEMBER(int, pfnDXClearUAViewUint,           (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, uint32_t const aValues[4]));
    509509    DECLCALLBACKMEMBER(int, pfnDXClearUAViewFloat,          (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, float const aValues[4]));
    510     DECLCALLBACKMEMBER(int, pfnDXCopyStructureCount,        (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
     510    DECLCALLBACKMEMBER(int, pfnDXCopyStructureCount,        (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId srcUAViewId, SVGA3dSurfaceId destSid, uint32_t destByteOffset));
    511511    DECLCALLBACKMEMBER(int, pfnDXSetUAViews,                (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t uavSpliceIndex, uint32_t cUAViewId, SVGA3dUAViewId const *paUAViewId));
    512     DECLCALLBACKMEMBER(int, pfnDXDrawIndexedInstancedIndirect, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    513     DECLCALLBACKMEMBER(int, pfnDXDrawInstancedIndirect,     (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
     512    DECLCALLBACKMEMBER(int, pfnDXDrawIndexedInstancedIndirect, (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSurfaceId argsBufferSid, uint32_t byteOffsetForArgs));
     513    DECLCALLBACKMEMBER(int, pfnDXDrawInstancedIndirect,     (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dSurfaceId argsBufferSid, uint32_t byteOffsetForArgs));
    514514    DECLCALLBACKMEMBER(int, pfnDXDispatch,                  (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t threadGroupCountX, uint32_t threadGroupCountY, uint32_t threadGroupCountZ));
    515515    DECLCALLBACKMEMBER(int, pfnDXDispatchIndirect,          (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
     
    517517    DECLCALLBACKMEMBER(int, pfnHintZeroSurface,             (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    518518    DECLCALLBACKMEMBER(int, pfnDXTransferToBuffer,          (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    519     DECLCALLBACKMEMBER(int, pfnDXSetStructureCount,         (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    520519    DECLCALLBACKMEMBER(int, pfnLogicOpsBitBlt,              (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    521520    DECLCALLBACKMEMBER(int, pfnLogicOpsTransBlt,            (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
     
    636635int vmsvga3dDXClearUAViewUint(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewUint const *pCmd);
    637636int vmsvga3dDXClearUAViewFloat(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXClearUAViewFloat const *pCmd);
    638 int vmsvga3dDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext);
     637int vmsvga3dDXCopyStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXCopyStructureCount const *pCmd);
    639638int vmsvga3dDXSetUAViews(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetUAViews const *pCmd, uint32_t cUAViewId, SVGA3dUAViewId const *paUAViewId);
    640 int vmsvga3dDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext);
    641 int vmsvga3dDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext);
     639int vmsvga3dDXDrawIndexedInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawIndexedInstancedIndirect const *pCmd);
     640int vmsvga3dDXDrawInstancedIndirect(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDrawInstancedIndirect const *pCmd);
    642641int vmsvga3dDXDispatch(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDispatch const *pCmd);
    643642int vmsvga3dDXDispatchIndirect(PVGASTATECC pThisCC, uint32_t idDXContext);
     
    645644int vmsvga3dHintZeroSurface(PVGASTATECC pThisCC, uint32_t idDXContext);
    646645int vmsvga3dDXTransferToBuffer(PVGASTATECC pThisCC, uint32_t idDXContext);
    647 int vmsvga3dDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext);
     646int vmsvga3dDXSetStructureCount(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXSetStructureCount const *pCmd);
    648647int vmsvga3dLogicOpsBitBlt(PVGASTATECC pThisCC, uint32_t idDXContext);
    649648int vmsvga3dLogicOpsTransBlt(PVGASTATECC pThisCC, uint32_t idDXContext);
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