VirtualBox

Ignore:
Timestamp:
Nov 22, 2023 12:28:54 PM (14 months ago)
Author:
vboxsync
Message:

WDDM: Track shader resource views; re-create views in RotateResourceIdentities; cleanup; logging.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.cpp

    r102145 r102253  
    27832783
    27842784void vboxDXSetShaderResourceViews(PVBOXDX_DEVICE pDevice, SVGA3dShaderType enmShaderType, uint32_t StartSlot,
    2785                                   uint32_t NumViews, uint32_t *paViewIds)
    2786 {
    2787     vgpu10SetShaderResources(pDevice, enmShaderType, StartSlot, NumViews, paViewIds);
     2785                                  uint32_t NumViews, PVBOXDXSHADERRESOURCEVIEW const *papViews)
     2786{
     2787    Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
     2788    NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
     2789
     2790    /* Update the pipeline state. */
     2791    PVBOXDXSRVSTATE pSRVS = &pDevice->pipeline.aSRVs[enmShaderType - SVGA3D_SHADERTYPE_MIN];
     2792
     2793    for (unsigned i = 0; i < NumViews; ++i)
     2794        pSRVS->apShaderResourceView[StartSlot + i] = papViews[i];
     2795
     2796    uint32_t cSRV = RT_MAX(pSRVS->cShaderResourceView, StartSlot + NumViews);
     2797    while (cSRV)
     2798    {
     2799        if (pSRVS->apShaderResourceView[cSRV - 1])
     2800            break;
     2801        --cSRV;
     2802    }
     2803    pSRVS->cShaderResourceView = cSRV;
     2804
     2805    /* Fetch View ids. */
     2806    uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
     2807    for (unsigned i = 0; i < NumViews; ++i)
     2808    {
     2809        VBOXDXSHADERRESOURCEVIEW *pView = papViews[i];
     2810        aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
     2811    }
     2812
     2813    vgpu10SetShaderResources(pDevice, enmShaderType, StartSlot, NumViews, aViewIds);
    27882814}
    27892815
     
    29112937    }
    29122938
    2913     /** @todo UAV */
     2939    VBOXDXUNORDEREDACCESSVIEW *pUnorderedAccessView;
     2940    RTListForEach(&pResource->listUAV, pUnorderedAccessView, VBOXDXUNORDEREDACCESSVIEW, nodeView)
     2941    {
     2942        if (pUnorderedAccessView->fDefined)
     2943        {
     2944            vgpu10DestroyUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId);
     2945            pUnorderedAccessView->fDefined = false;
     2946        }
     2947    }
     2948
     2949    VBOXDXVIDEODECODEROUTPUTVIEW *pVDOV;
     2950    RTListForEach(&pResource->listVDOV, pVDOV, VBOXDXVIDEODECODEROUTPUTVIEW, nodeView)
     2951    {
     2952        if (pVDOV->fDefined)
     2953        {
     2954            vgpu10DestroyVideoDecoderOutputView(pDevice, pVDOV->uVideoDecoderOutputViewId);
     2955            pVDOV->fDefined = false;
     2956        }
     2957    }
     2958
     2959    VBOXDXVIDEOPROCESSORINPUTVIEW *pVPIV;
     2960    RTListForEach(&pResource->listVPIV, pVPIV, VBOXDXVIDEOPROCESSORINPUTVIEW, nodeView)
     2961    {
     2962        if (pVPIV->fDefined)
     2963        {
     2964            vgpu10DestroyVideoProcessorInputView(pDevice, pVPIV->uVideoProcessorInputViewId);
     2965            pVPIV->fDefined = false;
     2966        }
     2967    }
     2968
    29142969
    29152970    VBOXDXVIDEOPROCESSOROUTPUTVIEW *pVPOV;
     
    29643019    }
    29653020
    2966     /** @todo UAV */
     3021    VBOXDXUNORDEREDACCESSVIEW *pUnorderedAccessView;
     3022    RTListForEach(&pResource->listUAV, pUnorderedAccessView, VBOXDXUNORDEREDACCESSVIEW, nodeView)
     3023    {
     3024        if (!pUnorderedAccessView->fDefined)
     3025        {
     3026            vgpu10DefineUAView(pDevice, pUnorderedAccessView->uUnorderedAccessViewId, vboxDXGetAllocation(pUnorderedAccessView->pResource),
     3027                               pUnorderedAccessView->svga.format, pUnorderedAccessView->svga.resourceDimension,
     3028                               pUnorderedAccessView->svga.desc);
     3029            pUnorderedAccessView->fDefined = true;
     3030        }
     3031    }
     3032
     3033    VBOXDXVIDEODECODEROUTPUTVIEW *pVDOV;
     3034    RTListForEach(&pResource->listVDOV, pVDOV, VBOXDXVIDEODECODEROUTPUTVIEW, nodeView)
     3035    {
     3036        if (!pVDOV->fDefined)
     3037        {
     3038            vgpu10DefineVideoDecoderOutputView(pDevice, pVDOV->uVideoDecoderOutputViewId,
     3039                                               vboxDXGetAllocation(pVDOV->pResource),
     3040                                               pVDOV->svga.desc);
     3041            pVDOV->fDefined = true;
     3042        }
     3043    }
     3044
     3045    VBOXDXVIDEOPROCESSORINPUTVIEW *pVPIV;
     3046    RTListForEach(&pResource->listVPIV, pVPIV, VBOXDXVIDEOPROCESSORINPUTVIEW, nodeView)
     3047    {
     3048        if (!pVPIV->fDefined)
     3049        {
     3050            vgpu10DefineVideoProcessorInputView(pDevice, pVPIV->uVideoProcessorInputViewId,
     3051                                                vboxDXGetAllocation(pVPIV->pResource),
     3052                                                pVPIV->svga.ContentDesc, pVPIV->svga.VPIVDesc);
     3053            pVPIV->fDefined = true;
     3054        }
     3055    }
    29673056
    29683057    VBOXDXVIDEOPROCESSOROUTPUTVIEW *pVPOV;
     
    29803069
    29813070
     3071static void vboxdxUnbindResourceViews(PVBOXDX_DEVICE pDevice, PVBOXDX_RESOURCE pResource)
     3072{
     3073    VBOXDXSHADERRESOURCEVIEW *pShaderResourceView;
     3074    RTListForEach(&pResource->listSRV, pShaderResourceView, VBOXDXSHADERRESOURCEVIEW, nodeView)
     3075    {
     3076        /* Search this view in the pipeline state. */
     3077        for (unsigned idxShaderType = 0; idxShaderType < RT_ELEMENTS(pDevice->pipeline.aSRVs); ++idxShaderType)
     3078        {
     3079            SVGA3dShaderType const enmShaderType = (SVGA3dShaderType)(idxShaderType + SVGA3D_SHADERTYPE_MIN);
     3080
     3081            PVBOXDXSRVSTATE pSRVS = &pDevice->pipeline.aSRVs[idxShaderType];
     3082            for (unsigned i = 0; i < pSRVS->cShaderResourceView; ++i)
     3083            {
     3084                if (pSRVS->apShaderResourceView[i] == pShaderResourceView)
     3085                {
     3086                    uint32_t id = SVGA3D_INVALID_ID;
     3087                    vgpu10SetShaderResources(pDevice, enmShaderType, i, 1, &id);
     3088                }
     3089            }
     3090        }
     3091    }
     3092}
     3093
     3094
    29823095HRESULT vboxDXRotateResourceIdentities(PVBOXDX_DEVICE pDevice, UINT cResources, PVBOXDX_RESOURCE *papResources)
    29833096{
    2984     /** @todo Rebind SRVs, UAVs which are currently bound to pipeline stages. */
     3097#ifdef LOG_ENABLED
     3098    for (unsigned i = 0; i < cResources; ++i)
     3099    {
     3100        PVBOXDX_RESOURCE pResource = papResources[i];
     3101        LogFlowFunc(("Resources[%d]: pResource %p, hAllocation 0x%08x\n", i, pResource, vboxDXGetAllocation(pResource)));
     3102
     3103        unsigned iV = 0;
     3104        VBOXDXRENDERTARGETVIEW *pRTV;
     3105        RTListForEach(&pResource->listRTV, pRTV, VBOXDXRENDERTARGETVIEW, nodeView)
     3106        {
     3107            LogFlowFunc(("  RTV[%d]: %p\n", iV, pRTV));
     3108            ++iV;
     3109        }
     3110
     3111        iV = 0;
     3112        VBOXDXSHADERRESOURCEVIEW *pSRV;
     3113        RTListForEach(&pResource->listSRV, pSRV, VBOXDXSHADERRESOURCEVIEW, nodeView)
     3114        {
     3115            LogFlowFunc(("  SRV[%d]: %p\n", iV, pSRV));
     3116            ++iV;
     3117        }
     3118    }
     3119
     3120    LogFlowFunc(("Pipeline: cRTV %u, cSRV VS %u, PS %u, GS %u, HS %u, DS %u, CS %u\n",
     3121                 pDevice->pipeline.cRenderTargetViews,
     3122                 pDevice->pipeline.aSRVs[0].cShaderResourceView,
     3123                 pDevice->pipeline.aSRVs[1].cShaderResourceView,
     3124                 pDevice->pipeline.aSRVs[2].cShaderResourceView,
     3125                 pDevice->pipeline.aSRVs[3].cShaderResourceView,
     3126                 pDevice->pipeline.aSRVs[4].cShaderResourceView,
     3127                 pDevice->pipeline.aSRVs[5].cShaderResourceView));
     3128    for (unsigned i = 0; i < pDevice->pipeline.cRenderTargetViews; ++i)
     3129        LogFlowFunc(("  RTV[%d]: %p\n", i, pDevice->pipeline.apRenderTargetViews[i]));
     3130    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[0].cShaderResourceView; ++i)
     3131        LogFlowFunc(("  SRV VS[%d]: %p\n", i, pDevice->pipeline.aSRVs[0].apShaderResourceView[i]));
     3132    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[1].cShaderResourceView; ++i)
     3133        LogFlowFunc(("  SRV PS[%d]: %p\n", i, pDevice->pipeline.aSRVs[1].apShaderResourceView[i]));
     3134    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[2].cShaderResourceView; ++i)
     3135        LogFlowFunc(("  SRV GS[%d]: %p\n", i, pDevice->pipeline.aSRVs[2].apShaderResourceView[i]));
     3136    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[3].cShaderResourceView; ++i)
     3137        LogFlowFunc(("  SRV HS[%d]: %p\n", i, pDevice->pipeline.aSRVs[3].apShaderResourceView[i]));
     3138    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[4].cShaderResourceView; ++i)
     3139        LogFlowFunc(("  SRV DS[%d]: %p\n", i, pDevice->pipeline.aSRVs[4].apShaderResourceView[i]));
     3140    for (unsigned i = 0; i < pDevice->pipeline.aSRVs[5].cShaderResourceView; ++i)
     3141        LogFlowFunc(("  SRV CS[%d]: %p\n", i, pDevice->pipeline.aSRVs[5].apShaderResourceView[i]));
     3142#endif
     3143
     3144    /** @todo Rebind UAVs which are currently bound to pipeline. */
    29853145
    29863146    /* Unbind current render targets, if a resource is bound as a render target. */
     
    30293189    {
    30303190        PVBOXDX_RESOURCE pResource = papResources[i];
     3191        vboxdxUnbindResourceViews(pDevice, pResource);
    30313192        vboxDXUndefineResourceViews(pDevice, pResource);
    30323193    }
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDX.h

    r102145 r102253  
    506506} VBOXDXINDEXBUFFERSTATE, *PVBOXDXINDEXBUFFERSTATE;
    507507
     508
     509typedef struct VBOXDXSRVSTATE
     510{
     511    uint32_t cShaderResourceView;
     512    PVBOXDXSHADERRESOURCEVIEW apShaderResourceView[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
     513} VBOXDXSRVSTATE, *PVBOXDXSRVSTATE;
     514
     515
    508516typedef struct VBOXDX_DEVICE
    509517{
     
    587595        VBOXDXVERTEXBUFFERSSTATE   VertexBuffers;
    588596        VBOXDXINDEXBUFFERSTATE     IndexBuffer;
     597        VBOXDXSRVSTATE             aSRVs[SVGA3D_SHADERTYPE_MAX - SVGA3D_SHADERTYPE_MIN]; /* For each shader type. */
    589598    } pipeline;
    590599
     
    698707                            uint32_t NumRTVs, UINT ClearSlots, PVBOXDXRENDERTARGETVIEW *papRenderTargetViews);
    699708void vboxDXSetShaderResourceViews(PVBOXDX_DEVICE pDevice, SVGA3dShaderType enmShaderType, uint32_t StartSlot,
    700                                   uint32_t NumViews, uint32_t *paViewIds);
     709                                  uint32_t NumViews, PVBOXDXSHADERRESOURCEVIEW const *papViews);
    701710void vboxDXSetConstantBuffers(PVBOXDX_DEVICE pDevice, SVGA3dShaderType enmShaderType, UINT StartSlot, UINT NumBuffers,
    702711                              PVBOXDX_RESOURCE *papBuffers, const UINT *pFirstConstant, const UINT *pNumConstants);
  • trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dx/VBoxDXDDI.cpp

    r102145 r102253  
    209209    LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
    210210
    211     Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    212     NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    213 
    214     /* Fetch View ids. */
    215     uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
    216     for (unsigned i = 0; i < NumViews; ++i)
    217     {
    218         VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
    219         aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
    220     }
    221 
    222     vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_PS, StartSlot, NumViews, aViewIds);
     211    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_PS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
    223212}
    224213
     
    618607    LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
    619608
    620     Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    621     NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    622 
    623     /* Fetch View ids. */
    624     uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
    625     for (unsigned i = 0; i < NumViews; ++i)
    626     {
    627         VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
    628         aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
    629     }
    630 
    631     vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_VS, StartSlot, NumViews, aViewIds);
     609    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_VS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
    632610}
    633611
     
    668646    LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
    669647
    670     Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    671     NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    672 
    673     /* Fetch View ids. */
    674     uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
    675     for (unsigned i = 0; i < NumViews; ++i)
    676     {
    677         VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
    678         aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
    679     }
    680 
    681     vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_GS, StartSlot, NumViews, aViewIds);
     648    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_GS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
    682649}
    683650
     
    29572924    LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
    29582925
    2959     Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    2960     NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    2961 
    2962     /* Fetch View ids. */
    2963     uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
    2964     for (unsigned i = 0; i < NumViews; ++i)
    2965     {
    2966         VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
    2967         aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
    2968     }
    2969 
    2970     vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_HS, StartSlot, NumViews, aViewIds);
     2926    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_HS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
    29712927}
    29722928
     
    30503006    LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
    30513007
    3052     Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    3053     NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    3054 
    3055     /* Fetch View ids. */
    3056     uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
    3057     for (unsigned i = 0; i < NumViews; ++i)
    3058     {
    3059         VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
    3060         aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
    3061     }
    3062 
    3063     vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_DS, StartSlot, NumViews, aViewIds);
     3008    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_DS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
    30643009}
    30653010
     
    34493394    LogFlowFunc(("pDevice = %p, StartSlot = %u, NumViews = %u\n", pDevice, StartSlot, NumViews));
    34503395
    3451     Assert(NumViews <= D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    3452     NumViews = RT_MIN(NumViews, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
    3453 
    3454     /* Fetch View ids. */
    3455     uint32_t aViewIds[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
    3456     for (unsigned i = 0; i < NumViews; ++i)
    3457     {
    3458         VBOXDXSHADERRESOURCEVIEW *pView = (PVBOXDXSHADERRESOURCEVIEW)phShaderResourceViews[i].pDrvPrivate;
    3459         aViewIds[i] = pView ? pView->uShaderResourceViewId : SVGA3D_INVALID_ID;
    3460     }
    3461 
    3462     vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_CS, StartSlot, NumViews, aViewIds);
     3396    vboxDXSetShaderResourceViews(pDevice, SVGA3D_SHADERTYPE_CS, StartSlot, NumViews, (PVBOXDXSHADERRESOURCEVIEW *)phShaderResourceViews);
    34633397}
    34643398
     
    39213855    if (pRotateResourceIdentities->Resources <= 1)
    39223856        return S_OK;
    3923 
    3924 #ifdef LOG_ENABLED
    3925     for (unsigned i = 0; i < pRotateResourceIdentities->Resources; ++i)
    3926     {
    3927         PVBOXDX_RESOURCE pResource = (PVBOXDX_RESOURCE)pRotateResourceIdentities->pResources[i];
    3928         LogFlowFunc(("Resources[%d]: pResource %p, hAllocation 0x%08x", i, pResource, vboxDXGetAllocation(pResource)));
    3929     }
    3930 #endif
    39313857
    39323858    return vboxDXRotateResourceIdentities(pDevice, pRotateResourceIdentities->Resources, (PVBOXDX_RESOURCE *)pRotateResourceIdentities->pResources);
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