VirtualBox

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


Ignore:
Timestamp:
Dec 17, 2023 3:39:15 PM (13 months ago)
Author:
vboxsync
Message:

Devices/Graphics: create render target, depth stencil and unordered access views on demand.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-dx11.cpp

    r102622 r102626  
    404404/* Static function prototypes. */
    405405static int dxDeviceFlush(DXDEVICE *pDevice);
    406 static int dxDefineUnorderedAccessView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, SVGACOTableDXUAViewEntry const *pEntry);
    407 static int dxDefineRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry);
    408 static int dxDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry);
    409406static int dxSetRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext);
    410407static int dxSetCSUnorderedAccessViews(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext);
     
    16451642
    16461643
    1647 static SVGACOTableDXSRViewEntry const *dxGetShaderResourceViewEntry(PVMSVGA3DDXCONTEXT pDXContext, uint32_t shaderResourceViewId)
    1648 {
    1649     ASSERT_GUEST_RETURN(shaderResourceViewId < pDXContext->cot.cSRView, NULL);
    1650 
    1651     SVGACOTableDXSRViewEntry const *pSRViewEntry = &pDXContext->cot.paSRView[shaderResourceViewId];
    1652     return pSRViewEntry;
    1653 }
    1654 
    1655 
    1656 static SVGACOTableDXUAViewEntry const *dxGetUnorderedAccessViewEntry(PVMSVGA3DDXCONTEXT pDXContext, uint32_t uaViewId)
    1657 {
    1658     ASSERT_GUEST_RETURN(uaViewId < pDXContext->cot.cUAView, NULL);
    1659 
    1660     SVGACOTableDXUAViewEntry const *pUAViewEntry = &pDXContext->cot.paUAView[uaViewId];
    1661     return pUAViewEntry;
    1662 }
    1663 
    1664 
    1665 static SVGACOTableDXDSViewEntry const *dxGetDepthStencilViewEntry(PVMSVGA3DDXCONTEXT pDXContext, uint32_t depthStencilViewId)
    1666 {
    1667     ASSERT_GUEST_RETURN(depthStencilViewId < pDXContext->cot.cDSView, NULL);
    1668 
    1669     SVGACOTableDXDSViewEntry const *pDSViewEntry = &pDXContext->cot.paDSView[depthStencilViewId];
    1670     return pDSViewEntry;
    1671 }
    1672 
    1673 
    1674 static SVGACOTableDXRTViewEntry const *dxGetRenderTargetViewEntry(PVMSVGA3DDXCONTEXT pDXContext, uint32_t renderTargetViewId)
    1675 {
    1676     ASSERT_GUEST_RETURN(renderTargetViewId < pDXContext->cot.cRTView, NULL);
    1677 
    1678     SVGACOTableDXRTViewEntry const *pRTViewEntry = &pDXContext->cot.paRTView[renderTargetViewId];
    1679     return pRTViewEntry;
    1680 }
    1681 
    1682 
    16831644static int dxTrackRenderTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    16841645{
     
    65016462            break;
    65026463        }
     6464        case DXGI_FORMAT_R8G8B8A8_SINT:
     6465        {
     6466            uint8_t const *pValues = (uint8_t const *)pvElementData;
     6467            Log8(("{ /*8sint*/  %d, %d, %d, %d },",
     6468                 pValues[0], pValues[1], pValues[2], pValues[3]));
     6469            break;
     6470        }
     6471        case DXGI_FORMAT_R8G8B8A8_UINT:
     6472        {
     6473            uint8_t const *pValues = (uint8_t const *)pvElementData;
     6474            Log8(("{ /*8uint*/  %u, %u, %u, %u },",
     6475                 pValues[0], pValues[1], pValues[2], pValues[3]));
     6476            break;
     6477        }
    65036478        case DXGI_FORMAT_R8G8B8A8_UNORM:
    65046479        {
     
    67826757
    67836758
    6784 static int dxCreateShaderResourceView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId, SVGACOTableDXSRViewEntry const *pEntry)
     6759static int dxCreateRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry)
    67856760{
    67866761    PVMSVGA3DSURFACE pSurface;
     
    67896764    AssertRCReturn(rc, rc);
    67906765
     6766    DXVIEW *pView = &pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId];
     6767    Assert(pView->u.pView == NULL);
     6768
     6769    ID3D11RenderTargetView *pRenderTargetView;
     6770    HRESULT hr = dxRenderTargetViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pRenderTargetView);
     6771    AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE);
     6772
     6773    return dxViewInit(pView, pSurface, pDXContext, renderTargetViewId, VMSVGA3D_VIEWTYPE_RENDERTARGET, pRenderTargetView);
     6774}
     6775
     6776
     6777static int dxEnsureRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId viewId, DXVIEW **ppResult)
     6778{
     6779    ASSERT_GUEST_RETURN(viewId < pDXContext->cot.cRTView, VERR_INVALID_PARAMETER);
     6780
     6781    DXVIEW *pDXView = &pDXContext->pBackendDXContext->paRenderTargetView[viewId];
     6782    if (!pDXView->u.pView)
     6783    {
     6784        SVGACOTableDXRTViewEntry const *pEntry = &pDXContext->cot.paRTView[viewId];
     6785        int rc = dxCreateRenderTargetView(pThisCC, pDXContext, viewId, pEntry);
     6786        AssertRCReturn(rc, rc);
     6787    }
     6788    *ppResult = pDXView;
     6789    return VINF_SUCCESS;
     6790}
     6791
     6792
     6793static int dxCreateDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry)
     6794{
     6795    PVMSVGA3DSURFACE pSurface;
     6796    ID3D11Resource *pResource;
     6797    int rc = dxEnsureResource(pThisCC, pDXContext, pEntry->sid, &pSurface, &pResource);
     6798    AssertRCReturn(rc, rc);
     6799
     6800    DXVIEW *pView = &pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId];
     6801    Assert(pView->u.pView == NULL);
     6802
     6803    ID3D11DepthStencilView *pDepthStencilView;
     6804    HRESULT hr = dxDepthStencilViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDepthStencilView);
     6805    AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE);
     6806
     6807    return dxViewInit(pView, pSurface, pDXContext, depthStencilViewId, VMSVGA3D_VIEWTYPE_DEPTHSTENCIL, pDepthStencilView);
     6808}
     6809
     6810
     6811static int dxEnsureDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId viewId, DXVIEW **ppResult)
     6812{
     6813    ASSERT_GUEST_RETURN(viewId < pDXContext->cot.cDSView, VERR_INVALID_PARAMETER);
     6814
     6815    DXVIEW *pDXView = &pDXContext->pBackendDXContext->paDepthStencilView[viewId];
     6816    if (!pDXView->u.pView)
     6817    {
     6818        SVGACOTableDXDSViewEntry const *pEntry = &pDXContext->cot.paDSView[viewId];
     6819        int rc = dxCreateDepthStencilView(pThisCC, pDXContext, viewId, pEntry);
     6820        AssertRCReturn(rc, rc);
     6821    }
     6822    *ppResult = pDXView;
     6823    return VINF_SUCCESS;
     6824}
     6825
     6826
     6827static int dxCreateShaderResourceView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderResourceViewId shaderResourceViewId, SVGACOTableDXSRViewEntry const *pEntry)
     6828{
     6829    PVMSVGA3DSURFACE pSurface;
     6830    ID3D11Resource *pResource;
     6831    int rc = dxEnsureResource(pThisCC, pDXContext, pEntry->sid, &pSurface, &pResource);
     6832    AssertRCReturn(rc, rc);
     6833
    67916834    DXVIEW *pView = &pDXContext->pBackendDXContext->paShaderResourceView[shaderResourceViewId];
    67926835    Assert(pView->u.pView == NULL);
     
    68146857    return VINF_SUCCESS;
    68156858}
     6859
     6860
     6861static int dxCreateUnorderedAccessView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, SVGACOTableDXUAViewEntry const *pEntry)
     6862{
     6863    PVMSVGA3DSURFACE pSurface;
     6864    ID3D11Resource *pResource;
     6865    int rc = dxEnsureResource(pThisCC, pDXContext, pEntry->sid, &pSurface, &pResource);
     6866    AssertRCReturn(rc, rc);
     6867
     6868    DXVIEW *pView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
     6869    Assert(pView->u.pView == NULL);
     6870
     6871    ID3D11UnorderedAccessView *pUnorderedAccessView;
     6872    HRESULT hr = dxUnorderedAccessViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pUnorderedAccessView);
     6873    AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE);
     6874
     6875    return dxViewInit(pView, pSurface, pDXContext, uaViewId, VMSVGA3D_VIEWTYPE_UNORDEREDACCESS, pUnorderedAccessView);
     6876}
     6877
     6878
     6879static int dxEnsureUnorderedAccessView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId viewId, DXVIEW **ppResult)
     6880{
     6881    ASSERT_GUEST_RETURN(viewId < pDXContext->cot.cUAView, VERR_INVALID_PARAMETER);
     6882
     6883    DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[viewId];
     6884    if (!pDXView->u.pView)
     6885    {
     6886        SVGACOTableDXUAViewEntry const *pEntry = &pDXContext->cot.paUAView[viewId];
     6887        int rc = dxCreateUnorderedAccessView(pThisCC, pDXContext, viewId, pEntry);
     6888        AssertRCReturn(rc, rc);
     6889    }
     6890    *ppResult = pDXView;
     6891    return VINF_SUCCESS;
     6892}
     6893
    68166894
    68176895static void dxSetupPipeline(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
     
    68536931
    68546932#ifdef LOG_ENABLED
    6855                 SVGACOTableDXSRViewEntry const *pSRViewEntry = dxGetShaderResourceViewEntry(pDXContext, shaderResourceViewId);
     6933                SVGACOTableDXSRViewEntry const *pSRViewEntry = &pDXContext->cot.paSRView[shaderResourceViewId];
    68566934                PVMSVGA3DSURFACE pSurface = NULL;
    68576935                vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pDXView->sid, &pSurface);
     
    68886966    for (uint32_t idxUA = 0; idxUA < SVGA3D_DX11_1_MAX_UAVIEWS; ++idxUA)
    68896967    {
    6890         SVGA3dUAViewId const uaViewId = pDXContext->svgaDXContext.csuaViewIds[idxUA];
    6891         if (uaViewId != SVGA3D_INVALID_ID)
    6892         {
    6893 //DEBUG_BREAKPOINT_TEST();
    6894             ASSERT_GUEST_RETURN_VOID(uaViewId < pDXContext->pBackendDXContext->cUnorderedAccessView);
    6895 
    6896             SVGACOTableDXUAViewEntry const *pUAViewEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
    6897             AssertContinue(pUAViewEntry != NULL);
    6898 
    6899             uint32_t const sid = pUAViewEntry->sid;
    6900 
    6901             PVMSVGA3DSURFACE pSurface;
    6902             rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, sid, &pSurface);
    6903             AssertRCReturnVoid(rc);
    6904 
    6905             /* The guest might have invalidated the surface in which case pSurface->pBackendSurface is NULL. */
    6906             /** @todo This is not needed for "single DX device" mode. */
    6907             if (pSurface->pBackendSurface)
    6908             {
    6909                 /* Wait for the surface to finish drawing. */
    6910                 dxSurfaceWait(pThisCC->svga.p3dState, pSurface, pDXContext->cid);
    6911             }
    6912 
    6913             /* If a view has not been created yet, do it now. */
    6914             if (!pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId].u.pView)
    6915             {
    6916                 LogFunc(("Re-creating UAV: sid=%u uaid = %u\n", sid, uaViewId));
    6917                 rc = dxDefineUnorderedAccessView(pThisCC, pDXContext, uaViewId, pUAViewEntry);
    6918                 AssertContinue(RT_SUCCESS(rc));
    6919             }
    6920 
    6921             LogFunc(("csuav[%d] sid = %u, uaid = %u\n", idxUA, sid, uaViewId));
     6968        SVGA3dUAViewId const viewId = pDXContext->svgaDXContext.csuaViewIds[idxUA];
     6969        if (viewId != SVGA3D_INVALID_ID)
     6970        {
     6971            DXVIEW *pDXView;
     6972            rc = dxEnsureUnorderedAccessView(pThisCC, pDXContext, viewId, &pDXView);
     6973            AssertContinue(RT_SUCCESS(rc));
     6974
     6975#ifdef LOG_ENABLED
     6976            SVGACOTableDXUAViewEntry const *pUAViewEntry = &pDXContext->cot.paUAView[viewId];
     6977            LogFunc(("csuav[%d] sid = %u, uaid = %u, format = %s(%d)\n", idxUA, pDXView->sid, viewId, vmsvgaLookupEnum((int)pUAViewEntry->format, &g_SVGA3dSurfaceFormat2String), pUAViewEntry->format));
     6978#endif
    69226979        }
    69236980    }
     
    69346991    AssertReturnVoid(pDevice->pDevice);
    69356992
    6936     /* Make sure that the render target views exist. Similar to SRVs. */
     6993    /* Make sure that the render target views exist. */
    69376994    if (pDXContext->svgaDXContext.renderState.depthStencilViewId != SVGA3D_INVALID_ID)
    69386995    {
    69396996        uint32_t const viewId = pDXContext->svgaDXContext.renderState.depthStencilViewId;
    69406997
    6941         ASSERT_GUEST_RETURN_VOID(viewId < pDXContext->pBackendDXContext->cDepthStencilView);
    6942 
    6943         SVGACOTableDXDSViewEntry const *pDSViewEntry = dxGetDepthStencilViewEntry(pDXContext, viewId);
    6944         AssertReturnVoid(pDSViewEntry != NULL);
    6945 
    6946         PVMSVGA3DSURFACE pSurface;
    6947         rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pDSViewEntry->sid, &pSurface);
    6948         AssertRCReturnVoid(rc);
    6949 
    6950         /* If a view has not been created yet, do it now. */
    6951         if (!pDXContext->pBackendDXContext->paDepthStencilView[viewId].u.pView)
    6952         {
    6953 //DEBUG_BREAKPOINT_TEST();
    6954             LogFunc(("Re-creating DSV: sid=%u dsvid = %u\n", pDSViewEntry->sid, viewId));
    6955             rc = dxDefineDepthStencilView(pThisCC, pDXContext, viewId, pDSViewEntry);
    6956             AssertReturnVoid(RT_SUCCESS(rc));
    6957         }
    6958 
    6959         LogFunc(("dsv sid = %u, dsvid = %u\n", pDSViewEntry->sid, viewId));
     6998        DXVIEW *pDXView;
     6999        rc = dxEnsureDepthStencilView(pThisCC, pDXContext, viewId, &pDXView);
     7000        AssertRC(rc);
     7001
     7002#ifdef LOG_ENABLED
     7003        SVGACOTableDXDSViewEntry const *pDSViewEntry = &pDXContext->cot.paDSView[viewId];
     7004        LogFunc(("dsv sid = %u, dsvid = %u, format = %s(%d)\n", pDXView->sid, viewId, vmsvgaLookupEnum((int)pDSViewEntry->format, &g_SVGA3dSurfaceFormat2String), pDSViewEntry->format));
     7005#endif
    69607006    }
    69617007
    69627008    for (uint32_t i = 0; i < SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS; ++i)
    69637009    {
    6964         if (pDXContext->svgaDXContext.renderState.renderTargetViewIds[i] != SVGA3D_INVALID_ID)
    6965         {
    6966             uint32_t const viewId = pDXContext->svgaDXContext.renderState.renderTargetViewIds[i];
    6967 
    6968             ASSERT_GUEST_RETURN_VOID(viewId < pDXContext->pBackendDXContext->cRenderTargetView);
    6969 
    6970             SVGACOTableDXRTViewEntry const *pRTViewEntry = dxGetRenderTargetViewEntry(pDXContext, viewId);
    6971             AssertReturnVoid(pRTViewEntry != NULL);
    6972 
    6973             PVMSVGA3DSURFACE pSurface;
    6974             rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pRTViewEntry->sid, &pSurface);
    6975             AssertRCReturnVoid(rc);
    6976 
    6977             /* If a view has not been created yet, do it now. */
    6978             if (!pDXContext->pBackendDXContext->paRenderTargetView[viewId].u.pView)
    6979             {
    6980 //DEBUG_BREAKPOINT_TEST();
    6981                 LogFunc(("Re-creating RTV: sid=%u rtvid = %u\n", pRTViewEntry->sid, viewId));
    6982                 rc = dxDefineRenderTargetView(pThisCC, pDXContext, viewId, pRTViewEntry);
    6983                 AssertReturnVoid(RT_SUCCESS(rc));
    6984             }
    6985 
    6986             LogFunc(("rtv sid = %u, rtvid = %u, format = %s(%d)\n", pRTViewEntry->sid, viewId, vmsvgaLookupEnum((int)pRTViewEntry->format, &g_SVGA3dSurfaceFormat2String), pRTViewEntry->format));
     7010        uint32_t const viewId = pDXContext->svgaDXContext.renderState.renderTargetViewIds[i];
     7011        if (viewId != SVGA3D_INVALID_ID)
     7012        {
     7013            DXVIEW *pDXView;
     7014            rc = dxEnsureRenderTargetView(pThisCC, pDXContext, viewId, &pDXView);
     7015            AssertContinue(RT_SUCCESS(rc));
     7016
     7017#ifdef LOG_ENABLED
     7018            SVGACOTableDXRTViewEntry const *pRTViewEntry = &pDXContext->cot.paRTView[viewId];
     7019            LogFunc(("rtv sid = %u, rtvid = %u, format = %s(%d)\n", pDXView->sid, viewId, vmsvgaLookupEnum((int)pRTViewEntry->format, &g_SVGA3dSurfaceFormat2String), pRTViewEntry->format));
     7020#endif
    69877021        }
    69887022    }
     
    69907024    for (uint32_t idxUA = 0; idxUA < SVGA3D_DX11_1_MAX_UAVIEWS; ++idxUA)
    69917025    {
    6992         SVGA3dUAViewId const uaViewId = pDXContext->svgaDXContext.uaViewIds[idxUA];
    6993         if (uaViewId != SVGA3D_INVALID_ID)
    6994         {
    6995 //DEBUG_BREAKPOINT_TEST();
    6996             ASSERT_GUEST_RETURN_VOID(uaViewId < pDXContext->pBackendDXContext->cUnorderedAccessView);
    6997 
    6998             SVGACOTableDXUAViewEntry const *pUAViewEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
    6999             AssertContinue(pUAViewEntry != NULL);
    7000 
    7001             uint32_t const sid = pUAViewEntry->sid;
    7002 
    7003             PVMSVGA3DSURFACE pSurface;
    7004             rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, sid, &pSurface);
    7005             AssertRCReturnVoid(rc);
    7006 
    7007             /* The guest might have invalidated the surface in which case pSurface->pBackendSurface is NULL. */
    7008             /** @todo This is not needed for "single DX device" mode. */
    7009             if (pSurface->pBackendSurface)
    7010             {
    7011                 /* Wait for the surface to finish drawing. */
    7012                 dxSurfaceWait(pThisCC->svga.p3dState, pSurface, pDXContext->cid);
    7013             }
    7014 
    7015             /* If a view has not been created yet, do it now. */
    7016             if (!pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId].u.pView)
    7017             {
    7018                 LogFunc(("Re-creating UAV: sid=%u uaid = %u\n", sid, uaViewId));
    7019                 rc = dxDefineUnorderedAccessView(pThisCC, pDXContext, uaViewId, pUAViewEntry);
    7020                 AssertContinue(RT_SUCCESS(rc));
    7021             }
    7022 
    7023             LogFunc(("uav[%d] sid = %u, uaid = %u\n", idxUA, sid, uaViewId));
     7026        SVGA3dUAViewId const viewId = pDXContext->svgaDXContext.uaViewIds[idxUA];
     7027        if (viewId != SVGA3D_INVALID_ID)
     7028        {
     7029            DXVIEW *pDXView;
     7030            rc = dxEnsureUnorderedAccessView(pThisCC, pDXContext, viewId, &pDXView);
     7031            AssertContinue(RT_SUCCESS(rc));
     7032
     7033#ifdef LOG_ENABLED
     7034            SVGACOTableDXUAViewEntry const *pUAViewEntry = &pDXContext->cot.paUAView[viewId];
     7035            LogFunc(("uav[%d] sid = %u, uaid = %u, format = %s(%d)\n", idxUA, pDXView->sid, viewId, vmsvgaLookupEnum((int)pUAViewEntry->format, &g_SVGA3dSurfaceFormat2String), pUAViewEntry->format));
     7036#endif
    70247037        }
    70257038    }
     
    70607073                        if (shaderResourceViewId != SVGA3D_INVALID_ID)
    70617074                        {
    7062                             SVGACOTableDXSRViewEntry const *pSRViewEntry = dxGetShaderResourceViewEntry(pDXContext, shaderResourceViewId);
    7063                             AssertContinue(pSRViewEntry != NULL);
     7075                            ASSERT_GUEST_CONTINUE(shaderResourceViewId < pDXContext->cot.cSRView);
     7076                            SVGACOTableDXSRViewEntry const *pSRViewEntry = &pDXContext->cot.paSRView[shaderResourceViewId];
    70647077
    70657078                            PVMSVGA3DSURFACE pSurface;
     
    78427855    for (uint32_t idxUA = 0; idxUA < SVGA3D_DX11_1_MAX_UAVIEWS; ++idxUA)
    78437856    {
     7857        apUnorderedAccessViews[idxUA] =  NULL;
     7858        aUAVInitialCounts[idxUA] = (UINT)-1;
     7859
    78447860        SVGA3dUAViewId const uaViewId = pDXContext->svgaDXContext.uaViewIds[idxUA];
    78457861        if (uaViewId != SVGA3D_INVALID_ID)
    78467862        {
     7863            ASSERT_GUEST_CONTINUE(uaViewId < pDXContext->cot.cUAView);
     7864
    78477865            if (NumUAVs == 0)
    78487866                UAVStartSlot = idxUA;
     
    78507868            apUnorderedAccessViews[idxUA] = pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId].u.pUnorderedAccessView;
    78517869
    7852             SVGACOTableDXUAViewEntry const *pEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
     7870            SVGACOTableDXUAViewEntry const *pEntry = &pDXContext->cot.paUAView[uaViewId];
    78537871            aUAVInitialCounts[idxUA] = pEntry->structureCount;
    7854         }
    7855         else
    7856         {
    7857             apUnorderedAccessViews[idxUA] =  NULL;
    7858             aUAVInitialCounts[idxUA] = (UINT)-1;
    78597872        }
    78607873    }
     
    83278340static DECLCALLBACK(int) vmsvga3dBackDXClearRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGA3dRGBAFloat const *pRGBA)
    83288341{
    8329     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    8330     RT_NOREF(pBackend);
    8331 
     8342    DXDEVICE *pDXDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     8343    AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE);
     8344
     8345    DXVIEW *pDXView;
     8346    int rc = dxEnsureRenderTargetView(pThisCC, pDXContext, renderTargetViewId, &pDXView);
     8347    AssertRCReturn(rc, rc);
     8348
     8349    pDXDevice->pImmediateContext->ClearRenderTargetView(pDXView->u.pRenderTargetView, pRGBA->value);
     8350    return VINF_SUCCESS;
     8351}
     8352
     8353
     8354static DECLCALLBACK(int) vmsvga3dBackVBDXClearRenderTargetViewRegion(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId,
     8355                                                                     SVGA3dRGBAFloat const *pColor, uint32_t cRect, SVGASignedRect const *paRect)
     8356{
     8357    DXDEVICE *pDXDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     8358    AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE);
     8359
     8360    DXVIEW *pDXView;
     8361    int rc = dxEnsureRenderTargetView(pThisCC, pDXContext, renderTargetViewId, &pDXView);
     8362    AssertRCReturn(rc, rc);
     8363
     8364    pDXDevice->pImmediateContext->ClearView(pDXView->u.pRenderTargetView, pColor->value, (D3D11_RECT *)paRect, cRect);
     8365    return VINF_SUCCESS;
     8366}
     8367
     8368
     8369static DECLCALLBACK(int) vmsvga3dBackDXClearDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t flags, SVGA3dDepthStencilViewId depthStencilViewId, float depth, uint8_t stencil)
     8370{
    83328371    DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    83338372    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    83348373
    8335     DXVIEW *pDXView = &pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId];
    8336     if (!pDXView->u.pRenderTargetView)
    8337     {
    8338 //DEBUG_BREAKPOINT_TEST();
    8339         /* (Re-)create the render target view, because a creation of a view is deferred until a draw or a clear call. */
    8340         SVGACOTableDXRTViewEntry const *pEntry = &pDXContext->cot.paRTView[renderTargetViewId];
    8341         int rc = dxDefineRenderTargetView(pThisCC, pDXContext, renderTargetViewId, pEntry);
    8342         AssertRCReturn(rc, rc);
    8343     }
    8344     pDevice->pImmediateContext->ClearRenderTargetView(pDXView->u.pRenderTargetView, pRGBA->value);
    8345     return VINF_SUCCESS;
    8346 }
    8347 
    8348 
    8349 static DECLCALLBACK(int) vmsvga3dBackVBDXClearRenderTargetViewRegion(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId,
    8350                                                                      SVGA3dRGBAFloat const *pColor, uint32_t cRect, SVGASignedRect const *paRect)
    8351 {
    8352     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    8353     RT_NOREF(pBackend);
    8354 
    8355     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    8356     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    8357 
    8358     DXVIEW *pDXView = &pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId];
    8359     if (!pDXView->u.pRenderTargetView)
    8360     {
    8361         /* (Re-)create the render target view, because a creation of a view is deferred until a draw or a clear call. */
    8362         SVGACOTableDXRTViewEntry const *pEntry = &pDXContext->cot.paRTView[renderTargetViewId];
    8363         int rc = dxDefineRenderTargetView(pThisCC, pDXContext, renderTargetViewId, pEntry);
    8364         AssertRCReturn(rc, rc);
    8365     }
    8366     pDevice->pImmediateContext->ClearView(pDXView->u.pRenderTargetView, pColor->value, (D3D11_RECT *)paRect, cRect);
    8367     return VINF_SUCCESS;
    8368 }
    8369 
    8370 
    8371 static DECLCALLBACK(int) vmsvga3dBackDXClearDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t flags, SVGA3dDepthStencilViewId depthStencilViewId, float depth, uint8_t stencil)
    8372 {
    8373     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    8374     RT_NOREF(pBackend);
    8375 
    8376     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    8377     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    8378 
    8379     DXVIEW *pDXView = &pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId];
    8380     if (!pDXView->u.pDepthStencilView)
    8381     {
    8382 //DEBUG_BREAKPOINT_TEST();
    8383         /* (Re-)create the depth stencil view, because a creation of a view is deferred until a draw or a clear call. */
    8384         SVGACOTableDXDSViewEntry const *pEntry = &pDXContext->cot.paDSView[depthStencilViewId];
    8385         int rc = dxDefineDepthStencilView(pThisCC, pDXContext, depthStencilViewId, pEntry);
    8386         AssertRCReturn(rc, rc);
    8387     }
     8374    DXVIEW *pDXView;
     8375    int rc = dxEnsureDepthStencilView(pThisCC, pDXContext, depthStencilViewId, &pDXView);
     8376    AssertRCReturn(rc, rc);
     8377
    83888378    pDevice->pImmediateContext->ClearDepthStencilView(pDXView->u.pDepthStencilView, flags, depth, stencil);
    83898379    return VINF_SUCCESS;
     
    89448934
    89458935
    8946 static int dxDefineRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry)
    8947 {
    8948     /* Get corresponding resource for pEntry->sid. Create the surface if does not yet exist. */
    8949     PVMSVGA3DSURFACE pSurface;
    8950     int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pEntry->sid, &pSurface);
    8951     AssertRCReturn(rc, rc);
    8952 
    8953     DXVIEW *pView = &pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId];
    8954     Assert(pView->u.pView == NULL);
    8955 
    8956     if (pSurface->pBackendSurface == NULL)
    8957     {
    8958         /* Create the actual texture. */
    8959         rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, pDXContext, pSurface);
    8960         AssertRCReturn(rc, rc);
    8961     }
    8962 
    8963     ID3D11RenderTargetView *pRenderTargetView;
    8964     HRESULT hr = dxRenderTargetViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pRenderTargetView);
    8965     AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE);
    8966 
    8967     return dxViewInit(pView, pSurface, pDXContext, renderTargetViewId, VMSVGA3D_VIEWTYPE_RENDERTARGET, pRenderTargetView);
    8968 }
    8969 
    8970 
    89718936static DECLCALLBACK(int) vmsvga3dBackDXDefineRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId, SVGACOTableDXRTViewEntry const *pEntry)
     8937{
     8938    /* The view is created when it is used in setupPipeline or ClearView. */
     8939    RT_NOREF(pThisCC, pDXContext, renderTargetViewId, pEntry);
     8940    return VINF_SUCCESS;
     8941}
     8942
     8943
     8944static DECLCALLBACK(int) vmsvga3dBackDXDestroyRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId)
    89728945{
    89738946    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    89748947    RT_NOREF(pBackend);
    89758948
    8976     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    8977     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    8978 
    8979     return dxDefineRenderTargetView(pThisCC, pDXContext, renderTargetViewId, pEntry);
    8980 }
    8981 
    8982 
    8983 static DECLCALLBACK(int) vmsvga3dBackDXDestroyRenderTargetView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dRenderTargetViewId renderTargetViewId)
     8949    DXVIEW *pDXView = &pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId];
     8950    return dxViewDestroy(pDXView);
     8951}
     8952
     8953
     8954static DECLCALLBACK(int) vmsvga3dBackDXDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry)
     8955{
     8956    /* The view is created when it is used in setupPipeline or ClearView. */
     8957    RT_NOREF(pThisCC, pDXContext, depthStencilViewId, pEntry);
     8958    return VINF_SUCCESS;
     8959}
     8960
     8961
     8962static DECLCALLBACK(int) vmsvga3dBackDXDestroyDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId)
    89848963{
    89858964    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    89868965    RT_NOREF(pBackend);
    89878966
    8988     return dxViewDestroy(&pDXContext->pBackendDXContext->paRenderTargetView[renderTargetViewId]);
    8989 }
    8990 
    8991 
    8992 static int dxDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry)
    8993 {
    8994     /* Get corresponding resource for pEntry->sid. Create the surface if does not yet exist. */
    8995     PVMSVGA3DSURFACE pSurface;
    8996     int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pEntry->sid, &pSurface);
    8997     AssertRCReturn(rc, rc);
    8998 
    8999     DXVIEW *pView = &pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId];
    9000     Assert(pView->u.pView == NULL);
    9001 
    9002     if (pSurface->pBackendSurface == NULL)
    9003     {
    9004         /* Create the actual texture. */
    9005         rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, pDXContext, pSurface);
    9006         AssertRCReturn(rc, rc);
    9007     }
    9008 
    9009     ID3D11DepthStencilView *pDepthStencilView;
    9010     HRESULT hr = dxDepthStencilViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pDepthStencilView);
    9011     AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE);
    9012 
    9013     return dxViewInit(pView, pSurface, pDXContext, depthStencilViewId, VMSVGA3D_VIEWTYPE_DEPTHSTENCIL, pDepthStencilView);
    9014 }
    9015 
    9016 static DECLCALLBACK(int) vmsvga3dBackDXDefineDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId, SVGACOTableDXDSViewEntry const *pEntry)
    9017 {
    9018     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    9019     RT_NOREF(pBackend);
    9020 
    9021     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    9022     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    9023 
    9024     return dxDefineDepthStencilView(pThisCC, pDXContext, depthStencilViewId, pEntry);
    9025 }
    9026 
    9027 
    9028 static DECLCALLBACK(int) vmsvga3dBackDXDestroyDepthStencilView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dDepthStencilViewId depthStencilViewId)
    9029 {
    9030     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    9031     RT_NOREF(pBackend);
    9032 
    9033     return dxViewDestroy(&pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId]);
     8967    DXVIEW *pDXView = &pDXContext->pBackendDXContext->paDepthStencilView[depthStencilViewId];
     8968    return dxViewDestroy(pDXView);
    90348969}
    90358970
     
    93979332                if (pDXView->u.pView)
    93989333                    dxViewAddToList(pThisCC, pDXView);
    9399                 else if (pDXView->enmViewType == VMSVGA3D_VIEWTYPE_NONE)
    9400                     dxDefineRenderTargetView(pThisCC, pDXContext, i, pEntry);
    94019334            }
    94029335            break;
     
    94299362                if (pDXView->u.pView)
    94309363                    dxViewAddToList(pThisCC, pDXView);
    9431                 else if (pDXView->enmViewType == VMSVGA3D_VIEWTYPE_NONE)
    9432                     dxDefineDepthStencilView(pThisCC, pDXContext, i, pEntry);
    94339364            }
    94349365            break;
     
    96729603                if (pDXView->u.pView)
    96739604                    dxViewAddToList(pThisCC, pDXView);
    9674                 else if (pDXView->enmViewType == VMSVGA3D_VIEWTYPE_NONE)
    9675                     dxDefineUnorderedAccessView(pThisCC, pDXContext, i, pEntry);
    96769605            }
    96779606            break;
     
    100419970
    100429971
    10043 static int dxDefineUnorderedAccessView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, SVGACOTableDXUAViewEntry const *pEntry)
    10044 {
    10045     /* Get corresponding resource for pEntry->sid. Create the surface if does not yet exist. */
    10046     PVMSVGA3DSURFACE pSurface;
    10047     int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pEntry->sid, &pSurface);
    10048     AssertRCReturn(rc, rc);
    10049 
    10050     ID3D11UnorderedAccessView *pUnorderedAccessView;
    10051     DXVIEW *pView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
    10052     Assert(pView->u.pView == NULL);
    10053 
    10054     if (pSurface->pBackendSurface == NULL)
    10055     {
    10056         /* Create the actual texture or buffer. */
    10057         /** @todo One function to create all resources from surfaces. */
    10058         if (pSurface->format != SVGA3D_BUFFER)
    10059             rc = vmsvga3dBackSurfaceCreateTexture(pThisCC, pDXContext, pSurface);
    10060         else
    10061             rc = vmsvga3dBackSurfaceCreateResource(pThisCC, pDXContext, pSurface);
    10062 
    10063         AssertRCReturn(rc, rc);
    10064     }
    10065 
    10066     HRESULT hr = dxUnorderedAccessViewCreate(pThisCC, pDXContext, pEntry, pSurface, &pUnorderedAccessView);
    10067     AssertReturn(SUCCEEDED(hr), VERR_INVALID_STATE);
    10068 
    10069     return dxViewInit(pView, pSurface, pDXContext, uaViewId, VMSVGA3D_VIEWTYPE_UNORDEREDACCESS, pUnorderedAccessView);
    10070 }
    10071 
    10072 
    100739972static DECLCALLBACK(int) vmsvga3dBackDXDefineUAView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, SVGACOTableDXUAViewEntry const *pEntry)
     9973{
     9974    /* The view is created in setupPipeline or ClearView. */
     9975    RT_NOREF(pThisCC, pDXContext, uaViewId, pEntry);
     9976    return VINF_SUCCESS;
     9977}
     9978
     9979
     9980static DECLCALLBACK(int) vmsvga3dBackDXDestroyUAView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId)
    100749981{
    100759982    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    100769983    RT_NOREF(pBackend);
    100779984
    10078     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    10079     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    10080 
    10081     /** @todo Probably not necessary because UAVs are defined in setupPipeline. */
    10082     return dxDefineUnorderedAccessView(pThisCC, pDXContext, uaViewId, pEntry);
    10083 }
    10084 
    10085 
    10086 static DECLCALLBACK(int) vmsvga3dBackDXDestroyUAView(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId)
    10087 {
    10088     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    10089     RT_NOREF(pBackend);
    10090 
    10091     return dxViewDestroy(&pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId]);
     9985    DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
     9986    return dxViewDestroy(pDXView);
    100929987}
    100939988
     
    100959990static DECLCALLBACK(int) vmsvga3dBackDXClearUAViewUint(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, uint32_t const aValues[4])
    100969991{
    10097     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    10098     RT_NOREF(pBackend);
    10099 
    10100     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    10101     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    10102 
    10103     DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
    10104     if (!pDXView->u.pUnorderedAccessView)
    10105     {
    10106         /* (Re-)create the view, because a creation of a view is deferred until a draw or a clear call. */
    10107         SVGACOTableDXUAViewEntry const *pEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
    10108         int rc = dxDefineUnorderedAccessView(pThisCC, pDXContext, uaViewId, pEntry);
    10109         AssertRCReturn(rc, rc);
    10110     }
    10111     pDevice->pImmediateContext->ClearUnorderedAccessViewUint(pDXView->u.pUnorderedAccessView, aValues);
     9992    DXDEVICE *pDXDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     9993    AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE);
     9994
     9995    DXVIEW *pDXView;
     9996    int rc = dxEnsureUnorderedAccessView(pThisCC, pDXContext, uaViewId, &pDXView);
     9997    AssertRCReturn(rc, rc);
     9998
     9999    pDXDevice->pImmediateContext->ClearUnorderedAccessViewUint(pDXView->u.pUnorderedAccessView, aValues);
    1011210000    return VINF_SUCCESS;
    1011310001}
     
    1011610004static DECLCALLBACK(int) vmsvga3dBackDXClearUAViewFloat(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId uaViewId, float const aValues[4])
    1011710005{
    10118     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    10119     RT_NOREF(pBackend);
    10120 
    10121     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    10122     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    10123 
    10124     DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
    10125     if (!pDXView->u.pUnorderedAccessView)
    10126     {
    10127         /* (Re-)create the view, because a creation of a view is deferred until a draw or a clear call. */
    10128         SVGACOTableDXUAViewEntry const *pEntry = &pDXContext->cot.paUAView[uaViewId];
    10129         int rc = dxDefineUnorderedAccessView(pThisCC, pDXContext, uaViewId, pEntry);
    10130         AssertRCReturn(rc, rc);
    10131     }
    10132     pDevice->pImmediateContext->ClearUnorderedAccessViewFloat(pDXView->u.pUnorderedAccessView, aValues);
     10006    DXDEVICE *pDXDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     10007    AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE);
     10008
     10009    DXVIEW *pDXView;
     10010    int rc = dxEnsureUnorderedAccessView(pThisCC, pDXContext, uaViewId, &pDXView);
     10011    AssertRCReturn(rc, rc);
     10012
     10013    pDXDevice->pImmediateContext->ClearUnorderedAccessViewFloat(pDXView->u.pUnorderedAccessView, aValues);
    1013310014    return VINF_SUCCESS;
    1013410015}
     
    1013710018static DECLCALLBACK(int) vmsvga3dBackDXCopyStructureCount(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dUAViewId srcUAViewId, SVGA3dSurfaceId destSid, uint32_t destByteOffset)
    1013810019{
    10139     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    10140     RT_NOREF(pBackend);
    10141 
    10142     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    10143     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     10020    DXDEVICE *pDXDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
     10021    AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE);
    1014410022
    1014510023    /* Get corresponding resource. Create the buffer if does not yet exist. */
     
    1014810026    {
    1014910027        PVMSVGA3DSURFACE pSurface;
    10150         int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, destSid, &pSurface);
     10028        ID3D11Resource *pResource;
     10029        int rc = dxEnsureResource(pThisCC, pDXContext, destSid, &pSurface, &pResource);
    1015110030        AssertRCReturn(rc, rc);
    10152 
    10153         if (pSurface->pBackendSurface == NULL)
    10154         {
    10155             /* Create the resource and initialize it with the current surface data. */
    10156             rc = vmsvga3dBackSurfaceCreateResource(pThisCC, pDXContext, pSurface);
    10157             AssertRCReturn(rc, rc);
    10158         }
    10159 
    10160         pDstBuffer = pSurface->pBackendSurface->u.pBuffer;
     10031        AssertReturn(pSurface->pBackendSurface->enmResType == VMSVGA3D_RESTYPE_BUFFER, VERR_INVALID_STATE);
     10032
     10033        pDstBuffer = (ID3D11Buffer *)pResource;
    1016110034    }
    1016210035    else
     
    1017310046        pSrcView = NULL;
    1017410047
    10175     pDevice->pImmediateContext->CopyStructureCount(pDstBuffer, destByteOffset, pSrcView);
    10176 
     10048    pDXDevice->pImmediateContext->CopyStructureCount(pDstBuffer, destByteOffset, pSrcView);
    1017710049    return VINF_SUCCESS;
    1017810050}
     
    1018110053static DECLCALLBACK(int) vmsvga3dBackDXSetUAViews(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t uavSpliceIndex, uint32_t cUAViewId, SVGA3dUAViewId const *paUAViewId)
    1018210054{
    10183     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    10184     RT_NOREF(pBackend);
    10185 
    10186     DXDEVICE *pDevice = dxDeviceFromContext(pThisCC->svga.p3dState, pDXContext);
    10187     AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
    10188 
    10189     RT_NOREF(uavSpliceIndex, cUAViewId, paUAViewId);
    10190 
     10055    /* Views are set in setupPipeline. */
     10056    RT_NOREF(pThisCC, pDXContext, uavSpliceIndex, cUAViewId, paUAViewId);
    1019110057    return VINF_SUCCESS;
    1019210058}
     
    1041410280    for (uint32_t i = 0; i < SVGA3D_DX11_1_MAX_UAVIEWS; ++i)
    1041510281    {
     10282        papUnorderedAccessView[i] = NULL;
     10283        aUAVInitialCounts[i] = (UINT)-1;
     10284
    1041610285        SVGA3dUAViewId const uaViewId = pUAIds[i];
    1041710286        if (uaViewId != SVGA3D_INVALID_ID)
    1041810287        {
    10419             ASSERT_GUEST_RETURN(uaViewId < pDXContext->pBackendDXContext->cUnorderedAccessView, VERR_INVALID_PARAMETER);
     10288            ASSERT_GUEST_CONTINUE(uaViewId < pDXContext->cot.cUAView);
    1042010289
    1042110290            DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[uaViewId];
     
    1042310292            papUnorderedAccessView[i] = pDXView->u.pUnorderedAccessView;
    1042410293
    10425             SVGACOTableDXUAViewEntry const *pEntry = dxGetUnorderedAccessViewEntry(pDXContext, uaViewId);
     10294            SVGACOTableDXUAViewEntry const *pEntry = &pDXContext->cot.paUAView[uaViewId];
    1042610295            aUAVInitialCounts[i] = pEntry->structureCount;
    10427         }
    10428         else
    10429         {
    10430             papUnorderedAccessView[i] = NULL;
    10431             aUAVInitialCounts[i] = (UINT)-1;
    1043210296        }
    1043310297    }
     
    1194711811    AssertReturn(pDXDevice->pDevice, VERR_INVALID_STATE);
    1194811812
    11949     DXVIEW *pDXView = &pDXContext->pBackendDXContext->paUnorderedAccessView[viewId];
    11950     if (!pDXView->u.pView)
    11951     {
    11952         /* (Re-)create the view, because a creation of a view is deferred until a draw or a clear call. */
    11953         SVGACOTableDXUAViewEntry const *pEntry = &pDXContext->cot.paUAView[viewId];
    11954         int rc = dxDefineUnorderedAccessView(pThisCC, pDXContext, viewId, pEntry);
    11955         AssertRCReturn(rc, rc);
    11956     }
     11813    DXVIEW *pDXView;
     11814    int rc = dxEnsureUnorderedAccessView(pThisCC, pDXContext, viewId, &pDXView);
     11815    AssertRCReturn(rc, rc);
     11816
    1195711817    pDXDevice->pImmediateContext->ClearView(pDXView->u.pView, pColor->value, (D3D11_RECT *)paRect, cRect);
    1195811818    return VINF_SUCCESS;
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