VirtualBox

Changeset 91375 in vbox


Ignore:
Timestamp:
Sep 27, 2021 6:46:37 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147053
Message:

Devices/Graphics: fixes for mapping, constant buffers and parser: bugref:9830

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

Legend:

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

    r91364 r91375  
    955955        {
    956956            VMSVGA3D_MAPPED_SURFACE map;
    957             rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBox, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map);
     957            rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBox, VMSVGA3D_SURFACE_MAP_WRITE, &map);
    958958            if (RT_SUCCESS(rc))
    959959            {
     
    10041004        {
    10051005            VMSVGA3D_MAPPED_SURFACE map;
    1006             rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBoxDst, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map);
     1006            rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBoxDst, VMSVGA3D_SURFACE_MAP_WRITE, &map);
    10071007            if (RT_SUCCESS(rc))
    10081008            {
     
    14781478    VMSVGA3D_SURFACE_MAP enmMapType;
    14791479    if (enmTransfer == SVGA3D_WRITE_HOST_VRAM)
    1480         enmMapType = VMSVGA3D_SURFACE_MAP_WRITE_DISCARD;
     1480        enmMapType = pBox
     1481                   ? VMSVGA3D_SURFACE_MAP_WRITE
     1482                   : VMSVGA3D_SURFACE_MAP_WRITE_DISCARD;
    14811483    else if (enmTransfer == SVGA3D_READ_HOST_VRAM)
    14821484        enmMapType = VMSVGA3D_SURFACE_MAP_READ;
     
    19361938    // entry.mobPitch = 0;
    19371939    // ...
     1940Assert(   pCmd->arraySize == 0
     1941       || pCmd->arraySize == 1
     1942       || (pCmd->arraySize == 6 && (pCmd->surfaceFlags & SVGA3D_SURFACE_CUBEMAP)));
    19381943    int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],
    19391944                                 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry));
     
    25352540{
    25362541#ifdef VMSVGA3D_DX
    2537     DEBUG_BREAKPOINT_TEST();
    2538     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    2539     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    2540     return vmsvga3dDXSetSOTargets(pThisCC, idDXContext);
     2542    //DEBUG_BREAKPOINT_TEST();
     2543    SVGA3dSoTarget const *paSoTarget = (SVGA3dSoTarget *)&pCmd[1];
     2544    uint32_t const cSoTarget = (cbCmd - sizeof(*pCmd)) / sizeof(SVGA3dSoTarget);
     2545    return vmsvga3dDXSetSOTargets(pThisCC, idDXContext, cSoTarget, paSoTarget);
    25412546#else
    25422547    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
     
    30393044{
    30403045#ifdef VMSVGA3D_DX
    3041     DEBUG_BREAKPOINT_TEST();
    3042     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3043     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    3044     return vmsvga3dDXDestroyShader(pThisCC, idDXContext);
     3046    //DEBUG_BREAKPOINT_TEST();
     3047    RT_NOREF(cbCmd);
     3048    return vmsvga3dDXDestroyShader(pThisCC, idDXContext, pCmd);
    30453049#else
    30463050    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
     
    30723076#ifdef VMSVGA3D_DX
    30733077    DEBUG_BREAKPOINT_TEST();
    3074     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3075     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    3076     return vmsvga3dDXDefineStreamOutput(pThisCC, idDXContext);
     3078    RT_NOREF(cbCmd);
     3079    return vmsvga3dDXDefineStreamOutput(pThisCC, idDXContext, pCmd);
    30773080#else
    30783081    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
     
    30873090#ifdef VMSVGA3D_DX
    30883091    DEBUG_BREAKPOINT_TEST();
    3089     PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;
    3090     RT_NOREF(pSvgaR3State, pCmd, cbCmd);
    3091     return vmsvga3dDXDestroyStreamOutput(pThisCC, idDXContext);
     3092    RT_NOREF(cbCmd);
     3093    return vmsvga3dDXDestroyStreamOutput(pThisCC, idDXContext, pCmd);
    30923094#else
    30933095    RT_NOREF(pThisCC, idDXContext, pCmd, cbCmd);
     
    31943196         */
    31953197        VMSVGA3D_MAPPED_SURFACE mapSurface;
    3196         rc = vmsvga3dSurfaceMap(pThisCC, &imageSurface, &pCmd->destBox, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &mapSurface);
     3198        rc = vmsvga3dSurfaceMap(pThisCC, &imageSurface, &pCmd->destBox, VMSVGA3D_SURFACE_MAP_WRITE, &mapSurface);
    31973199        if (RT_SUCCESS(rc))
    31983200        {
     
    32073209                RT_UNTRUSTED_VALIDATED_FENCE();
    32083210                uint8_t const *pu8BufferBegin = pu8Buffer;
    3209                 uint8_t const *pu8BufferEnd = pu8Buffer + (cbBuffer - pCmd->srcOffset);
     3211                uint8_t const *pu8BufferEnd = pu8Buffer + cbBuffer;
    32103212
    32113213                pu8Buffer += pCmd->srcOffset;
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-shader.cpp

    r90853 r91375  
    16291629                                    || opcode.aValOperand[0].aOperandIndex[0].indexRepresentation == VGPU10_OPERAND_INDEX_IMMEDIATE64,
    16301630                                    VERR_NOT_SUPPORTED);
    1631                 pSignatureEntry->registerIndex = opcode.aValOperand[0].aOperandIndex[0].iOperandImmediate;
    1632                 pSignatureEntry->semanticName  = opcode.semanticName;
     1631
     1632                uint32_t const indexDimension = opcode.aValOperand[0].indexDimension;
     1633                if (indexDimension == VGPU10_OPERAND_INDEX_0D)
     1634                {
     1635                    if (opcode.aValOperand[0].operandType == VGPU10_OPERAND_TYPE_INPUT_PRIMITIVEID)
     1636                    {
     1637                        pSignatureEntry->registerIndex = 0;
     1638                        pSignatureEntry->semanticName  = SVGADX_SIGNATURE_SEMANTIC_NAME_PRIMITIVE_ID;
     1639                    }
     1640                    else
     1641                        ASSERT_GUEST_FAILED_RETURN(VERR_NOT_SUPPORTED);
     1642                }
     1643                else
     1644                {
     1645                    ASSERT_GUEST_RETURN(   indexDimension == VGPU10_OPERAND_INDEX_1D
     1646                                        || indexDimension == VGPU10_OPERAND_INDEX_2D
     1647                                        || indexDimension == VGPU10_OPERAND_INDEX_3D,
     1648                                        VERR_NOT_SUPPORTED);
     1649                    /* The register index seems to be in the highest dimension. */
     1650                    pSignatureEntry->registerIndex = opcode.aValOperand[0].aOperandIndex[indexDimension - VGPU10_OPERAND_INDEX_1D].iOperandImmediate;
     1651                    pSignatureEntry->semanticName  = opcode.semanticName;
     1652                }
    16331653                pSignatureEntry->mask          = opcode.aValOperand[0].mask;
    16341654                pSignatureEntry->componentType = SVGADX_SIGNATURE_REGISTER_COMPONENT_UNKNOWN; /// @todo Proper value? Seems that it is not important.
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx.cpp

    r91361 r91375  
    726726
    727727
    728 int vmsvga3dDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext)
     728int vmsvga3dDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cSoTarget, SVGA3dSoTarget const *paSoTarget)
    729729{
    730730    int rc;
     
    738738    AssertRCReturn(rc, rc);
    739739
    740     rc = pSvgaR3State->pFuncsDX->pfnDXSetSOTargets(pThisCC, pDXContext);
     740    ASSERT_GUEST_RETURN(cSoTarget < SVGA3D_DX_MAX_SOTARGETS, VERR_INVALID_PARAMETER);
     741
     742    rc = pSvgaR3State->pFuncsDX->pfnDXSetSOTargets(pThisCC, pDXContext, cSoTarget, paSoTarget);
    741743    return rc;
    742744}
     
    13751377    pEntry->mobid         = SVGA_ID_INVALID;
    13761378
    1377     /** @todo Remove from here. */
    1378 //    if (!pDXContext->paShader)
    1379 //    {
    1380 //        /* Create host array for information about shaders. */
    1381 //        pDXContext->paShader = (PVMSVGA3DSHADER)RTMemAllocZ(pDXContext->cot.cShader * sizeof(VMSVGA3DSHADER));
    1382 //        AssertReturn(pDXContext->paShader, VERR_NO_MEMORY);
    1383 //        for (uint32_t i = 0; i < pDXContext->cot.cShader; ++i)
    1384 //            pDXContext->paShader[i].id = SVGA_ID_INVALID;
    1385 //    }
    1386 
    13871379    PVMSVGA3DSHADER pShader = &pDXContext->paShader[shaderId];
    13881380    if (pShader->id != SVGA_ID_INVALID)
    13891381    {
    1390         /** @todo Cleanup current shader. */
    1391         pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext);
     1382        /* Cleanup the current shader. */
     1383        pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext, shaderId);
    13921384        RTMemFree(pShader->pShaderProgram);
    13931385    }
     
    14051397
    14061398
    1407 int vmsvga3dDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext)
     1399int vmsvga3dDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShader const *pCmd)
    14081400{
    14091401    int rc;
     
    14171409    AssertRCReturn(rc, rc);
    14181410
    1419     rc = pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext);
     1411    AssertReturn(pDXContext->paShader, VERR_INVALID_STATE);
     1412
     1413    SVGA3dShaderId const shaderId = pCmd->shaderId;
     1414
     1415    ASSERT_GUEST_RETURN(pDXContext->cot.paShader, VERR_INVALID_STATE);
     1416    ASSERT_GUEST_RETURN(shaderId < pDXContext->cot.cShader, VERR_INVALID_PARAMETER);
     1417    RT_UNTRUSTED_VALIDATED_FENCE();
     1418
     1419    rc = pSvgaR3State->pFuncsDX->pfnDXDestroyShader(pThisCC, pDXContext, shaderId);
     1420
     1421    /* Cleanup COTable entries.*/
     1422    SVGACOTableDXShaderEntry *pEntry = &pDXContext->cot.paShader[shaderId];
     1423    pEntry->type          = SVGA3D_SHADERTYPE_INVALID;
     1424    pEntry->sizeInBytes   = 0;
     1425    pEntry->offsetInBytes = 0;
     1426    pEntry->mobid         = SVGA_ID_INVALID;
     1427
     1428    PVMSVGA3DSHADER pShader = &pDXContext->paShader[shaderId];
     1429    pShader->id                = SVGA_ID_INVALID;
     1430    pShader->cid               = SVGA_ID_INVALID;
     1431    pShader->type              = SVGA3D_SHADERTYPE_INVALID;
     1432    pShader->cbData            = 0;
     1433    RTMemFree(pShader->pShaderProgram);
     1434    pShader->pShaderProgram    = NULL;
     1435    pShader->u.pvBackendShader = NULL;
     1436
    14201437    return rc;
    14211438}
     
    14491466            if (pSignatureHeader->headerVersion == SVGADX_SIGNATURE_HEADER_VERSION_0)
    14501467            {
     1468                DEBUG_BREAKPOINT_TEST();
    14511469                ASSERT_GUEST_RETURN(   pSignatureHeader->numInputSignatures <= RT_ELEMENTS(pShader->shaderInfo.aInputSignature)
    14521470                                    && pSignatureHeader->numOutputSignatures <= RT_ELEMENTS(pShader->shaderInfo.aOutputSignature)
     
    15401558
    15411559
    1542 int vmsvga3dDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext)
     1560int vmsvga3dDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutput const *pCmd)
    15431561{
    15441562    int rc;
     
    15521570    AssertRCReturn(rc, rc);
    15531571
    1554     rc = pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutput(pThisCC, pDXContext);
    1555     return rc;
    1556 }
    1557 
    1558 
    1559 int vmsvga3dDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext)
     1572    SVGA3dStreamOutputId const soid = pCmd->soid;
     1573
     1574    ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
     1575    ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
     1576    ASSERT_GUEST_RETURN(pCmd->numOutputStreamEntries < SVGA3D_MAX_DX10_STREAMOUT_DECLS, VERR_INVALID_PARAMETER);
     1577    RT_UNTRUSTED_VALIDATED_FENCE();
     1578
     1579    SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
     1580    pEntry->numOutputStreamEntries = pCmd->numOutputStreamEntries;
     1581    memcpy(pEntry->decl, pCmd->decl, sizeof(pEntry->decl));
     1582    memcpy(pEntry->streamOutputStrideInBytes, pCmd->streamOutputStrideInBytes, sizeof(pEntry->streamOutputStrideInBytes));
     1583    pEntry->rasterizedStream = pCmd->rasterizedStream;
     1584    pEntry->numOutputStreamStrides;
     1585    pEntry->mobid = SVGA_ID_INVALID;
     1586    pEntry->offsetInBytes = 0;
     1587    pEntry->usesMob = 0;
     1588    pEntry->pad0 = 0;
     1589    pEntry->pad1 = 0;
     1590    RT_ZERO(pEntry->pad2);
     1591
     1592    rc = pSvgaR3State->pFuncsDX->pfnDXDefineStreamOutput(pThisCC, pDXContext, soid, pEntry);
     1593    return rc;
     1594}
     1595
     1596
     1597int vmsvga3dDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyStreamOutput const *pCmd)
    15601598{
    15611599    int rc;
     
    15691607    AssertRCReturn(rc, rc);
    15701608
    1571     rc = pSvgaR3State->pFuncsDX->pfnDXDestroyStreamOutput(pThisCC, pDXContext);
     1609    SVGA3dStreamOutputId const soid = pCmd->soid;
     1610
     1611    ASSERT_GUEST_RETURN(pDXContext->cot.paStreamOutput, VERR_INVALID_STATE);
     1612    ASSERT_GUEST_RETURN(soid < pDXContext->cot.cStreamOutput, VERR_INVALID_PARAMETER);
     1613    RT_UNTRUSTED_VALIDATED_FENCE();
     1614
     1615    rc = pSvgaR3State->pFuncsDX->pfnDXDestroyStreamOutput(pThisCC, pDXContext, soid);
     1616
     1617    SVGACOTableDXStreamOutputEntry *pEntry = &pDXContext->cot.paStreamOutput[soid];
     1618    RT_ZERO(*pEntry);
     1619    pEntry->mobid = SVGA_ID_INVALID;
     1620
    15721621    return rc;
    15731622}
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp

    r91364 r91375  
    147147} DXSHADER;
    148148
     149typedef struct DXSTREAMOUTPUT
     150{
     151    ID3D11Buffer *pSOBuffer;
     152} DXSTREAMOUTPUT;
     153
    149154typedef struct VMSVGA3DBACKENDDXCONTEXT
    150155{
     
    162167    uint32_t                   cQuery;                 /* papQuery */
    163168    uint32_t                   cShader;                /* papShader */
     169    uint32_t                   cStreamOutput;          /* papStreamOutput */
    164170    ID3D11BlendState         **papBlendState;
    165171    ID3D11DepthStencilState  **papDepthStencilState;
     
    172178    ID3D11Query              **papQuery;
    173179    DXSHADER                  *paShader;
     180    DXSTREAMOUTPUT            *paStreamOutput;
    174181} VMSVGA3DBACKENDDXCONTEXT;
    175182
     
    728735                pInfoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, true);
    729736
     737                /* No breakpoints for the following messages. */
    730738                D3D11_MESSAGE_ID saIgnoredMessageIds[] =
    731739                {
    732740                    /* Message ID:                                    Caused by: */
    733741                    D3D11_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH, /* Autogenerated input signatures. */
     742                    D3D11_MESSAGE_ID_LIVE_DEVICE,                     /* Live object report. Does not seem to prevent a breakpoint. */
     743                    (D3D11_MESSAGE_ID)3146081 /*DEVICE_DRAW_RENDERTARGETVIEW_NOT_SET*/, /* U. */
     744                    D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET,     /* U. */
     745                    D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_MISMATCH,    /* U. */
    734746                };
    735747
     
    772784{
    773785    RT_NOREF(pBackend);
     786    if (pDevice->pImmediateContext)
     787        pDevice->pImmediateContext->ClearState();
     788
     789    D3D_RELEASE(pDevice->pDxgiFactory);
     790    D3D_RELEASE(pDevice->pImmediateContext);
     791
     792#ifdef DEBUG
     793    HRESULT hr2;
     794    ID3D11Debug *pDebug = 0;
     795    hr2 = pDevice->pDevice->QueryInterface(__uuidof(ID3D11Debug), (void**)&pDebug);
     796    if (SUCCEEDED(hr2))
     797    {
     798        //pDebug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL | (D3D11_RLDO_FLAGS)0x4 /*D3D11_RLDO_IGNORE_INTERNAL*/);
     799        D3D_RELEASE(pDebug);
     800    }
     801#endif
     802
    774803    D3D_RELEASE(pDevice->pDevice);
    775     D3D_RELEASE(pDevice->pImmediateContext);
    776     D3D_RELEASE(pDevice->pDxgiFactory);
    777804    RT_ZERO(*pDevice);
    778805}
     
    925952}
    926953
     954static int dxDefineStreamOutput(PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid, SVGACOTableDXStreamOutputEntry const *pEntry)
     955{
     956    RT_NOREF(pDXContext, soid, pEntry);
     957    return VINF_SUCCESS;
     958}
     959
     960static void dxDestroyStreamOutput(DXSTREAMOUTPUT *pDXStreamOutput)
     961{
     962    D3D_RELEASE(pDXStreamOutput->pSOBuffer);
     963}
     964
    927965static D3D11_BLEND dxBlendFactorAlpha(uint8_t svgaBlend)
    928966{
     
    942980}
    943981
     982
    944983static D3D11_BLEND dxBlendFactorColor(uint8_t svgaBlend)
    945984{
     
    947986}
    948987
     988
    949989static D3D11_BLEND_OP dxBlendOp(uint8_t svgaBlendEq)
    950990{
    951991    return (D3D11_BLEND_OP)svgaBlendEq;
    952992}
     993
    953994
    954995/** @todo AssertCompile for types like D3D11_COMPARISON_FUNC and SVGA3dComparisonFunc */
     
    12701311            break;
    12711312        case SVGA3D_SHADERTYPE_GS:
     1313            hr = pDevice->pDevice->CreateGeometryShader(pDXShader->pvDXBC, pDXShader->cbDXBC, NULL, &pDXShader->pGeometryShader);
     1314            Assert(SUCCEEDED(hr));
     1315            break;
    12721316        case SVGA3D_SHADERTYPE_HS:
    12731317        case SVGA3D_SHADERTYPE_DS:
     
    12921336            break;
    12931337        case SVGA3D_SHADERTYPE_GS:
     1338            pDevice->pImmediateContext->GSSetShader(pDXShader ? pDXShader->pGeometryShader : NULL, NULL, 0);
     1339            break;
    12941340        case SVGA3D_SHADERTYPE_HS:
    12951341        case SVGA3D_SHADERTYPE_DS:
     
    13121358            break;
    13131359        case SVGA3D_SHADERTYPE_GS:
     1360            pDevice->pImmediateContext->GSSetConstantBuffers(slot, 1, &pConstantBuffer);
     1361            break;
    13141362        case SVGA3D_SHADERTYPE_HS:
    13151363        case SVGA3D_SHADERTYPE_DS:
     
    13321380            break;
    13331381        case SVGA3D_SHADERTYPE_GS:
     1382            pDevice->pImmediateContext->GSSetSamplers(startSampler, cSampler, papSampler);
     1383            break;
    13341384        case SVGA3D_SHADERTYPE_HS:
    13351385        case SVGA3D_SHADERTYPE_DS:
     
    13521402            break;
    13531403        case SVGA3D_SHADERTYPE_GS:
     1404            pDevice->pImmediateContext->GSSetShaderResources(startView, cShaderResourceView, papShaderResourceView);
     1405            break;
    13541406        case SVGA3D_SHADERTYPE_HS:
    13551407        case SVGA3D_SHADERTYPE_DS:
     
    14281480        td.Usage          = D3D11_USAGE_STAGING;
    14291481        td.BindFlags      = 0; /* No flags allowed. */
    1430         td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
     1482        td.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
    14311483        hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->pStagingTexture);
    14321484        Assert(SUCCEEDED(hr));
     
    15711623            td.Usage          = D3D11_USAGE_STAGING;
    15721624            td.BindFlags      = 0; /* No flags allowed. */
    1573             td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
     1625            td.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
    15741626            hr = pDXDevice->pDevice->CreateTexture2D(&td, 0, &pBackendSurface->pStagingTexture);
    15751627            Assert(SUCCEEDED(hr));
     
    16601712            td.Usage          = D3D11_USAGE_STAGING;
    16611713            td.BindFlags      = 0; /* No flags allowed. */
    1662             td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
     1714            td.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
    16631715            td.MiscFlags      = 0;
    16641716            hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pStagingTexture);
     
    17501802                td.Usage          = D3D11_USAGE_STAGING;
    17511803                td.BindFlags      = 0; /* No flags allowed. */
    1752                 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
     1804                td.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
    17531805                td.MiscFlags      = 0;
    17541806                hr = pDXDevice->pDevice->CreateTexture3D(&td, paInitialData, &pBackendSurface->pStagingTexture3D);
     
    18351887                td.Usage          = D3D11_USAGE_STAGING;
    18361888                td.BindFlags      = 0; /* No flags allowed. */
    1837                 td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
     1889                td.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
    18381890                td.MiscFlags      = 0;
    18391891                hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pStagingTexture);
     
    19622014        td.Usage          = D3D11_USAGE_STAGING;
    19632015        td.BindFlags      = 0; /* No flags allowed. */
    1964         td.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
     2016        td.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
    19652017        td.MiscFlags      = 0;
    19662018        hr = pDXDevice->pDevice->CreateTexture2D(&td, paInitialData, &pBackendSurface->pStagingTexture);
     
    20482100
    20492101
    2050 static int vmsvga3dBackSurfaceCreateConstantBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface)
     2102static int vmsvga3dBackSurfaceCreateSoBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface)
    20512103{
    20522104    DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;
     
    20542106
    20552107    /* Buffers should be created as such. */
    2056     AssertReturn(RT_BOOL(pSurface->surfaceFlags & ( SVGA3D_SURFACE_BIND_CONSTANT_BUFFER)), VERR_INVALID_PARAMETER);
     2108    AssertReturn(RT_BOOL(pSurface->surfaceFlags & SVGA3D_SURFACE_BIND_STREAM_OUTPUT), VERR_INVALID_PARAMETER);
    20572109
    20582110    if (pSurface->pBackendSurface != NULL)
     
    20682120    D3D11_BUFFER_DESC bd;
    20692121    RT_ZERO(bd);
    2070     bd.ByteWidth = pSurface->paMipmapLevels[0].cbSurface;
    2071     bd.Usage = D3D11_USAGE_DYNAMIC;
    2072     bd.BindFlags           = D3D11_BIND_CONSTANT_BUFFER;
    2073     bd.CPUAccessFlags      = D3D11_CPU_ACCESS_WRITE;
     2122    bd.ByteWidth           = pSurface->paMipmapLevels[0].cbSurface;
     2123    bd.Usage               = D3D11_USAGE_DEFAULT;
     2124    bd.BindFlags           = dxBindFlags(pSurface->surfaceFlags); // D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_STREAM_OUTPUT;
     2125    bd.CPUAccessFlags      = 0; /// @todo ? D3D11_CPU_ACCESS_READ;
    20742126    bd.MiscFlags           = 0;
    20752127    bd.StructureByteStride = 0;
     
    20862138        pSurface->idAssociatedContext = pDXContext->cid;
    20872139        pSurface->fDirty = true;
     2140        return VINF_SUCCESS;
     2141    }
     2142
     2143    /* Failure. */
     2144    D3D_RELEASE(pBackendSurface->u.pBuffer);
     2145    RTMemFree(pBackendSurface);
     2146    return VERR_NO_MEMORY;
     2147}
     2148
     2149/** @todo Not needed */
     2150static int vmsvga3dBackSurfaceCreateConstantBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface)
     2151{
     2152    DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;
     2153    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     2154
     2155    /* Buffers should be created as such. */
     2156    AssertReturn(RT_BOOL(pSurface->surfaceFlags & ( SVGA3D_SURFACE_BIND_CONSTANT_BUFFER)), VERR_INVALID_PARAMETER);
     2157
     2158    if (pSurface->pBackendSurface != NULL)
     2159    {
     2160        AssertFailed(); /** @todo Should the function not be used like that? */
     2161        vmsvga3dBackSurfaceDestroy(pThisCC, pSurface);
     2162    }
     2163
     2164    PVMSVGA3DMIPMAPLEVEL pMipLevel;
     2165    int rc = vmsvga3dMipmapLevel(pSurface, 0, 0, &pMipLevel);
     2166    AssertRCReturn(rc, rc);
     2167
     2168    PVMSVGA3DBACKENDSURFACE pBackendSurface;
     2169    rc = dxBackendSurfaceAlloc(&pBackendSurface);
     2170    AssertRCReturn(rc, rc);
     2171
     2172    /* Upload the current data, if any. */
     2173    D3D11_SUBRESOURCE_DATA *pInitialData = NULL;
     2174    D3D11_SUBRESOURCE_DATA initialData;
     2175    if (pMipLevel->pSurfaceData)
     2176    {
     2177        initialData.pSysMem          = pMipLevel->pSurfaceData;
     2178        initialData.SysMemPitch      = pMipLevel->cbSurface;
     2179        initialData.SysMemSlicePitch = pMipLevel->cbSurface;
     2180
     2181        pInitialData = &initialData;
     2182
     2183        pMipLevel->fDirty = false;
     2184        pSurface->fDirty = false;
     2185    }
     2186
     2187    D3D11_BUFFER_DESC bd;
     2188    RT_ZERO(bd);
     2189    bd.ByteWidth           = pMipLevel->cbSurface;
     2190    bd.Usage               = D3D11_USAGE_DYNAMIC;
     2191    bd.BindFlags           = D3D11_BIND_CONSTANT_BUFFER;
     2192    bd.CPUAccessFlags      = D3D11_CPU_ACCESS_WRITE;
     2193    bd.MiscFlags           = 0;
     2194    bd.StructureByteStride = 0;
     2195
     2196    HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBackendSurface->u.pBuffer);
     2197    if (SUCCEEDED(hr))
     2198    {
     2199        /*
     2200         * Success.
     2201         */
     2202        pBackendSurface->enmResType = VMSVGA3D_RESTYPE_BUFFER;
     2203        pBackendSurface->enmDxgiFormat = DXGI_FORMAT_UNKNOWN;
     2204        pSurface->pBackendSurface = pBackendSurface;
     2205        pSurface->idAssociatedContext = pDXContext->cid;
    20882206        return VINF_SUCCESS;
    20892207    }
     
    21282246}
    21292247
    2130 
     2248/** @todo Not needed? */
    21312249static int vmsvga3dBackSurfaceCreate(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface)
    21322250{
     
    25422660    }
    25432661
    2544     /** @todo D3D11_MAP_WRITE does not work with D3D11_USAGE_DYNAMIC resources. Probably VMSVGA3D_SURFACE_MAP_WRITE is not necessary. */
     2662/// @todo Hack. Need Staging buffer ro CopyResource data to the actual buffer
     2663if (enmMapType == VMSVGA3D_SURFACE_MAP_WRITE && pBackendSurface->enmResType == VMSVGA3D_RESTYPE_BUFFER)
     2664    enmMapType = VMSVGA3D_SURFACE_MAP_WRITE_DISCARD;
     2665
    25452666    D3D11_MAP d3d11MapType;
    25462667    switch (enmMapType)
     
    25772698            pDevice->pImmediateContext->CopyResource(pBackendSurface->pStagingTexture, pBackendSurface->u.pTexture2D);
    25782699        }
     2700        else if (enmMapType == VMSVGA3D_SURFACE_MAP_WRITE)
     2701            pMappedTexture = pBackendSurface->pStagingTexture;
    25792702        else
    25802703            pMappedTexture = pBackendSurface->pDynamicTexture;
     
    26032726    {
    26042727//Assert(pImage->face == 0 && pImage->mipmap == 0);
    2605 if (!pBackendSurface->pStagingTexture || !pBackendSurface->pDynamicTexture) return VERR_NOT_IMPLEMENTED;
    2606         ID3D11Texture2D *pMappedTexture;
     2728if (!(   (pBackendSurface->pStagingTexture && pBackendSurface->pDynamicTexture)
     2729      || (pBackendSurface->pStagingTexture3D && pBackendSurface->pDynamicTexture3D)
     2730     )
     2731   )
     2732{
     2733    AssertFailed();
     2734    return VERR_NOT_IMPLEMENTED;
     2735}
     2736
     2737        ID3D11Resource *pMappedResource;
    26072738        if (enmMapType == VMSVGA3D_SURFACE_MAP_READ)
    26082739        {
    2609             pMappedTexture = pBackendSurface->pStagingTexture;
     2740            pMappedResource = (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D)
     2741                            ? (ID3D11Resource *)pBackendSurface->pStagingTexture3D
     2742                            : (ID3D11Resource *)pBackendSurface->pStagingTexture;
    26102743
    26112744            /* Wait for the surface to finish drawing. */
     
    26212754             * Always copy entire miplevel so all Dst are zero and pSrcBox is NULL, as D3D11 requires.
    26222755             */
    2623             ID3D11Resource *pDstResource = pBackendSurface->pStagingTexture;
     2756            ID3D11Resource *pDstResource = pMappedResource;
    26242757            UINT DstSubresource = 0;
    26252758            UINT DstX = 0;
    26262759            UINT DstY = 0;
    26272760            UINT DstZ = 0;
    2628             ID3D11Resource *pSrcResource = pBackendSurface->u.pTexture2D;
     2761            ID3D11Resource *pSrcResource = pBackendSurface->u.pResource;
    26292762            UINT SrcSubresource = D3D11CalcSubresource(pImage->mipmap, pImage->face, pSurface->cLevels);
    26302763            D3D11_BOX *pSrcBox = NULL;
     
    26392772                                                              pSrcResource, SrcSubresource, pSrcBox);
    26402773        }
     2774        else if (enmMapType == VMSVGA3D_SURFACE_MAP_WRITE)
     2775            pMappedResource = (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D)
     2776                            ? (ID3D11Resource *)pBackendSurface->pStagingTexture3D
     2777                            : (ID3D11Resource *)pBackendSurface->pStagingTexture;
    26412778        else
    2642             pMappedTexture = pBackendSurface->pDynamicTexture;
     2779            pMappedResource = (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D)
     2780                            ? (ID3D11Resource *)pBackendSurface->pDynamicTexture3D
     2781                            : (ID3D11Resource *)pBackendSurface->pDynamicTexture;
    26432782
    26442783        UINT const Subresource = 0;
    2645         HRESULT hr = pDevice->pImmediateContext->Map(pMappedTexture, Subresource,
     2784        HRESULT hr = pDevice->pImmediateContext->Map(pMappedResource, Subresource,
    26462785                                                     d3d11MapType, /* MapFlags =  */ 0, &mappedResource);
    26472786        if (SUCCEEDED(hr))
     
    27202859        ID3D11Texture2D *pMappedTexture;
    27212860        if (pMap->enmMapType == VMSVGA3D_SURFACE_MAP_READ)
     2861            pMappedTexture = pBackendSurface->pStagingTexture;
     2862        else if (pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE)
    27222863            pMappedTexture = pBackendSurface->pStagingTexture;
    27232864        else
     
    27572898             || pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D)
    27582899    {
    2759         ID3D11Texture2D *pMappedTexture;
     2900        ID3D11Resource *pMappedResource;
    27602901        if (pMap->enmMapType == VMSVGA3D_SURFACE_MAP_READ)
    2761             pMappedTexture = pBackendSurface->pStagingTexture;
     2902            pMappedResource = (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D)
     2903                            ? (ID3D11Resource *)pBackendSurface->pStagingTexture3D
     2904                            : (ID3D11Resource *)pBackendSurface->pStagingTexture;
     2905        else if (pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE)
     2906            pMappedResource = (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D)
     2907                            ? (ID3D11Resource *)pBackendSurface->pStagingTexture3D
     2908                            : (ID3D11Resource *)pBackendSurface->pStagingTexture;
    27622909        else
    2763             pMappedTexture = pBackendSurface->pDynamicTexture;
     2910            pMappedResource = (pBackendSurface->enmResType == VMSVGA3D_RESTYPE_TEXTURE_3D)
     2911                            ? (ID3D11Resource *)pBackendSurface->pDynamicTexture3D
     2912                            : (ID3D11Resource *)pBackendSurface->pDynamicTexture;
    27642913
    27652914        UINT const Subresource = 0; /* Staging or dynamic textures have one subresource. */
    2766         pDevice->pImmediateContext->Unmap(pMappedTexture, Subresource);
     2915        pDevice->pImmediateContext->Unmap(pMappedResource, Subresource);
    27672916
    27682917        if (   fWritten
     
    27712920                || pMap->enmMapType == VMSVGA3D_SURFACE_MAP_WRITE_DISCARD))
    27722921        {
    2773             ID3D11Resource *pDstResource = pBackendSurface->u.pTexture2D;
     2922            /* If entire resource must be copied then use pSrcBox = NULL and dst point (0,0,0)
     2923             * Because DX11 insists on this for some resource types, for example DEPTH_STENCIL resources.
     2924             */
     2925            uint32_t const cWidth0 = pSurface->paMipmapLevels[0].mipmapSize.width;
     2926            uint32_t const cHeight0 = pSurface->paMipmapLevels[0].mipmapSize.height;
     2927            uint32_t const cDepth0 = pSurface->paMipmapLevels[0].mipmapSize.depth;
     2928            bool const fEntireResource = pMap->box.x == 0 && pMap->box.y == 0 && pMap->box.z == 0
     2929                                      && pMap->box.w == cWidth0 && pMap->box.h == cHeight0 && pMap->box.d == cDepth0;
     2930
     2931            ID3D11Resource *pDstResource = pBackendSurface->u.pResource;
    27742932            UINT DstSubresource = D3D11CalcSubresource(pImage->mipmap, pImage->face, pSurface->cLevels);
    2775             UINT DstX = pMap->box.x;
    2776             UINT DstY = pMap->box.y;
     2933            UINT DstX = (pMap->box.x / pSurface->cxBlock) * pSurface->cxBlock;
     2934            UINT DstY = (pMap->box.y / pSurface->cyBlock) * pSurface->cyBlock;
    27772935            UINT DstZ = pMap->box.z;
    2778             ID3D11Resource *pSrcResource = pBackendSurface->pDynamicTexture;
     2936            ID3D11Resource *pSrcResource = pMappedResource;
    27792937            UINT SrcSubresource = Subresource;
     2938            D3D11_BOX *pSrcBox;
    27802939            D3D11_BOX SrcBox;
    2781             SrcBox.left   = pMap->box.x;
    2782             SrcBox.top    = pMap->box.y;
    2783             SrcBox.front  = pMap->box.z;
    2784             SrcBox.right  = pMap->box.x + pMap->box.w;
    2785             SrcBox.bottom = pMap->box.y + pMap->box.h;
    2786             SrcBox.back   = pMap->box.z + pMap->box.d;
     2940            if (fEntireResource)
     2941                pSrcBox = NULL;
     2942            else
     2943            {
     2944                uint32_t const cxBlocks = (pMap->box.w + pSurface->cxBlock - 1) / pSurface->cxBlock;
     2945                uint32_t const cyBlocks = (pMap->box.h + pSurface->cyBlock - 1) / pSurface->cyBlock;
     2946
     2947                SrcBox.left   = DstX;
     2948                SrcBox.top    = DstY;
     2949                SrcBox.front  = DstZ;
     2950                SrcBox.right  = DstX + cxBlocks * pSurface->cxBlock;
     2951                SrcBox.bottom = DstY + cyBlocks * pSurface->cyBlock;
     2952                SrcBox.back   = DstZ + pMap->box.d;
     2953                pSrcBox = &SrcBox;
     2954            }
    27872955
    27882956            pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ,
    2789                                                               pSrcResource, SrcSubresource, &SrcBox);
     2957                                                              pSrcResource, SrcSubresource, pSrcBox);
    27902958
    27912959            pBackendSurface->cidDrawing = pSurface->idAssociatedContext;
     
    35333701            Assert(pSrcSurface->idAssociatedContext == DX_CID_BACKEND && pDstSurface->idAssociatedContext == DX_CID_BACKEND);
    35343702
     3703            /* Wait for the source surface to finish drawing. */
     3704            if (pSrcSurface->pBackendSurface->cidDrawing != SVGA_ID_INVALID)
     3705            {
     3706                dxContextWait(pSrcSurface->pBackendSurface->cidDrawing, pState);
     3707                pSrcSurface->pBackendSurface->cidDrawing = SVGA_ID_INVALID;
     3708            }
     3709
    35353710            DXDEVICE *pDXDevice = &pBackend->device;
    35363711
     
    40194194
    40204195        VMSVGA3D_MAPPED_SURFACE map;
    4021         rc = vmsvga3dBackSurfaceMap(pThisCC, &image, &box, VMSVGA3D_SURFACE_MAP_WRITE_DISCARD, &map);
     4196        rc = vmsvga3dBackSurfaceMap(pThisCC, &image, &box, VMSVGA3D_SURFACE_MAP_WRITE, &map);
    40224197        if (RT_SUCCESS(rc))
    40234198        {
     
    40944269
    40954270        VMSVGA3D_SURFACE_MAP const enmMap = transfer == SVGA3D_WRITE_HOST_VRAM
    4096                                           ? VMSVGA3D_SURFACE_MAP_WRITE_DISCARD
     4271                                          ? VMSVGA3D_SURFACE_MAP_WRITE
    40974272                                          : VMSVGA3D_SURFACE_MAP_READ;
    40984273
     
    41014276        if (RT_SUCCESS(rc))
    41024277        {
     4278#if 0
     4279            if (box.w == 250 && box.h == 250 && box.d == 1 && enmMap == VMSVGA3D_SURFACE_MAP_READ)
     4280            {
     4281                DEBUG_BREAKPOINT_TEST();
     4282                vmsvga3dMapWriteBmpFile(&map, "P");
     4283            }
     4284#endif
    41034285            /* Prepare parameters for vmsvgaR3GmrTransfer, which needs the host buffer address, size
    41044286             * and offset of the first scanline.
     
    42534435        {
    42544436            for (uint32_t i = 0; i < pBackendDXContext->cShader; ++i)
    4255                 D3D_RELEASE(pBackendDXContext->paShader[i].pShader);
     4437                D3D_RELEASE(pBackendDXContext->paShader[i].pShader); /// @todo dxDestroyShader
     4438        }
     4439        if (pBackendDXContext->paStreamOutput)
     4440        {
     4441            for (uint32_t i = 0; i < pBackendDXContext->cStreamOutput; ++i)
     4442                dxDestroyStreamOutput(&pBackendDXContext->paStreamOutput[i]);
    42564443        }
    42574444
     
    42664453        RTMemFreeZ(pBackendDXContext->papQuery, sizeof(pBackendDXContext->papQuery[0]) * pBackendDXContext->cQuery);
    42674454        RTMemFreeZ(pBackendDXContext->paShader, sizeof(pBackendDXContext->paShader[0]) * pBackendDXContext->cShader);
     4455        RTMemFreeZ(pBackendDXContext->paStreamOutput, sizeof(pBackendDXContext->paStreamOutput[0]) * pBackendDXContext->cStreamOutput);
    42684456
    42694457        /* Destroy backend surfaces which belong to this context. */
     
    43494537    AssertRCReturn(rc, rc);
    43504538
    4351     uint32_t const cbSurface = pSurface->paMipmapLevels[0].cbSurface;
     4539    PVMSVGA3DMIPMAPLEVEL pMipLevel;
     4540    rc = vmsvga3dMipmapLevel(pSurface, 0, 0, &pMipLevel);
     4541    AssertRCReturn(rc, rc);
     4542
     4543    uint32_t const cbSurface = pMipLevel->cbSurface;
    43524544    ASSERT_GUEST_RETURN(   offsetInBytes < cbSurface
    43534545                        && sizeInBytes <= cbSurface - offsetInBytes, VERR_INVALID_PARAMETER);
    43544546
    4355     if (pSurface->pBackendSurface == NULL)
    4356     {
    4357         /* Create the resource. */
    4358         rc = vmsvga3dBackSurfaceCreateConstantBuffer(pThisCC, pDXContext, pSurface);
    4359         AssertRCReturn(rc, rc);
    4360     }
    4361 
    4362     if (pSurface->fDirty)
    4363     {
    4364         /* Get mobid for the surface and read from the MOB. */
    4365         SVGA3dSurfaceImageId imageId;
    4366         imageId.sid = sid;
    4367         imageId.face = 0;
    4368         imageId.mipmap = 0;
    4369 
    4370         SVGA3dPoint ptSrc;
    4371         ptSrc.x = offsetInBytes / pSurface->cbBlock;
    4372         ptSrc.y = 0;
    4373         ptSrc.z = 0;
    4374 
    4375         SVGA3dBox boxDst;
    4376         boxDst.x = 0;
    4377         boxDst.y = 0;
    4378         boxDst.z = 0;
    4379         boxDst.w = sizeInBytes / pSurface->cbBlock;
    4380         boxDst.h = 1;
    4381         boxDst.d = 1;
    4382 
    4383         rc = vmsvgaR3UpdateGBSurfaceEx(pThisCC, &imageId, &boxDst, &ptSrc);
    4384         AssertRCReturn(rc, rc);
    4385     }
    4386 
    4387     dxConstantBufferSet(pDevice, slot, type, pSurface->pBackendSurface->u.pBuffer);
     4547    /* Constant buffers are created on demand. */
     4548    Assert(pSurface->pBackendSurface == NULL);
     4549
     4550    /* Upload the current data, if any. */
     4551    D3D11_SUBRESOURCE_DATA *pInitialData = NULL;
     4552    D3D11_SUBRESOURCE_DATA initialData;
     4553    if (pMipLevel->pSurfaceData)
     4554    {
     4555        initialData.pSysMem          = (uint8_t *)pMipLevel->pSurfaceData + offsetInBytes;
     4556        initialData.SysMemPitch      = sizeInBytes;
     4557        initialData.SysMemSlicePitch = sizeInBytes;
     4558
     4559        pInitialData = &initialData;
     4560    }
     4561
     4562    D3D11_BUFFER_DESC bd;
     4563    RT_ZERO(bd);
     4564    bd.ByteWidth           = sizeInBytes;
     4565    bd.Usage               = D3D11_USAGE_DEFAULT;
     4566    bd.BindFlags           = D3D11_BIND_CONSTANT_BUFFER;
     4567    bd.CPUAccessFlags      = 0;
     4568    bd.MiscFlags           = 0;
     4569    bd.StructureByteStride = 0;
     4570
     4571    ID3D11Buffer *pBuffer = 0;
     4572    HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBuffer);
     4573    if (SUCCEEDED(hr))
     4574    {
     4575       dxConstantBufferSet(pDevice, slot, type, pBuffer);
     4576       D3D_RELEASE(pBuffer);
     4577    }
     4578
    43884579    return VINF_SUCCESS;
    43894580}
     
    44314622    {
    44324623        pDXShader = &pDXContext->pBackendDXContext->paShader[pShader->id];
     4624        Assert(pDXShader->pShader);
    44334625        Assert(pDXShader->enmShaderType >= SVGA3D_SHADERTYPE_MIN && pDXShader->enmShaderType < SVGA3D_SHADERTYPE_MAX);
    44344626        uint32_t const idxShaderState = pDXShader->enmShaderType - SVGA3D_SHADERTYPE_MIN;
     
    47154907            }
    47164908
     4909            Assert(pSurface->pBackendSurface->u.pBuffer);
    47174910            paResources[idxVertexBuffer] = pSurface->pBackendSurface->u.pBuffer;
    47184911            paStride[idxVertexBuffer] = paVertexBuffer[i].stride;
     
    50245217
    50255218
    5026 static DECLCALLBACK(int) vmsvga3dBackDXSetSOTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    5027 {
    5028     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    5029 
    5030     RT_NOREF(pBackend, pDXContext);
    5031     AssertFailed(); /** @todo Implement */
    5032     return VERR_NOT_IMPLEMENTED;
     5219static DECLCALLBACK(int) vmsvga3dBackDXSetSOTargets(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t cSoTarget, SVGA3dSoTarget const *paSoTarget)
     5220{
     5221    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     5222    RT_NOREF(pBackend);
     5223
     5224    DXDEVICE *pDevice = &pDXContext->pBackendDXContext->device;
     5225    AssertReturn(pDevice->pDevice, VERR_INVALID_STATE);
     5226
     5227    /* For each paSoTarget[i]:
     5228     *   If the stream outout buffer object does not exist then create it.
     5229     *   If the surface has been updated by the guest then update the buffer object.
     5230     * Use SOSetTargets to set the buffers.
     5231     */
     5232
     5233    ID3D11Buffer *paResource[SVGA3D_DX_MAX_SOTARGETS];
     5234    UINT paOffset[SVGA3D_DX_MAX_SOTARGETS];
     5235
     5236    /* Always re-bind all 4 SO targets. They can be NULL. */
     5237    for (uint32_t i = 0; i < SVGA3D_DX_MAX_SOTARGETS; ++i)
     5238    {
     5239        /* Get corresponding resource. Create the buffer if does not yet exist. */
     5240        if (i < cSoTarget && paSoTarget[i].sid != SVGA_ID_INVALID)
     5241        {
     5242            PVMSVGA3DSURFACE pSurface;
     5243            int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, paSoTarget[i].sid, &pSurface);
     5244            AssertRCReturn(rc, rc);
     5245
     5246            if (pSurface->pBackendSurface == NULL)
     5247            {
     5248                /* Create the resource. */
     5249                rc = vmsvga3dBackSurfaceCreateSoBuffer(pThisCC, pDXContext, pSurface);
     5250                AssertRCReturn(rc, rc);
     5251            }
     5252
     5253            /** @todo How paSoTarget[i].sizeInBytes is used? Maybe when the buffer is created? */
     5254            paResource[i] = pSurface->pBackendSurface->u.pBuffer;
     5255            paOffset[i] = paSoTarget[i].offset;
     5256
     5257            /** @todo This should be in the caller. */
     5258            pDXContext->svgaDXContext.streamOut.targets[i] = paSoTarget[i].sid;
     5259        }
     5260        else
     5261        {
     5262            paResource[i] = NULL;
     5263            paOffset[i] = 0;
     5264
     5265            /** @todo This should be in the caller. */
     5266            pDXContext->svgaDXContext.streamOut.targets[i] = SVGA_ID_INVALID;
     5267        }
     5268
     5269        /// @todo pDXContext->svgaDXContext.streamOut.soid?
     5270    }
     5271
     5272    pDevice->pImmediateContext->SOSetTargets(SVGA3D_DX_MAX_SOTARGETS, paResource, paOffset);
     5273
     5274    return VINF_SUCCESS;
    50335275}
    50345276
     
    53135555        && pDXContext->cid != pSurface->idAssociatedContext)
    53145556    {
    5315         /* Supposed to be per context. */
    5316 //AssertFailed(); // test
     5557        /* Supposed to be per context. Sometimes the guest reuses the texture in another context. */
    53175558        vmsvga3dBackSurfaceDestroy(pThisCC, pSurface);
    53185559    }
     
    55545795
    55555796
     5797static int dxDestroyShader(DXSHADER *pDXShader)
     5798{
     5799    pDXShader->enmShaderType = SVGA3D_SHADERTYPE_INVALID;
     5800    D3D_RELEASE(pDXShader->pShader);
     5801    RTMemFree(pDXShader->pvDXBC);
     5802    pDXShader->pvDXBC = NULL;
     5803    pDXShader->cbDXBC = 0;
     5804    return VINF_SUCCESS;
     5805}
     5806
     5807
    55565808static DECLCALLBACK(int) vmsvga3dBackDXDefineShader(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId, SVGACOTableDXShaderEntry const *pEntry)
    55575809{
     
    55605812
    55615813    DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[shaderId];
    5562     D3D_RELEASE(pDXShader->pShader);
     5814    dxDestroyShader(pDXShader);
    55635815
    55645816    return dxDefineShader(pDXContext, shaderId, pEntry);
     
    55665818
    55675819
    5568 static DECLCALLBACK(int) vmsvga3dBackDXDestroyShader(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    5569 {
    5570     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    5571 
    5572     RT_NOREF(pBackend, pDXContext);
    5573     AssertFailed(); /** @todo Implement */
    5574     return VERR_NOT_IMPLEMENTED;
     5820static DECLCALLBACK(int) vmsvga3dBackDXDestroyShader(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId)
     5821{
     5822    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     5823    RT_NOREF(pBackend);
     5824
     5825    DXSHADER *pDXShader = &pDXContext->pBackendDXContext->paShader[shaderId];
     5826    dxDestroyShader(pDXShader);
     5827
     5828    return VINF_SUCCESS;
    55755829}
    55765830
     
    56065860            {
    56075861                if (i > 0)
    5608                     Log((",\n"));
    5609 
    5610                 Log(("    %#04x", pu8[i]));
     5862                    Log6((",\n"));
     5863
     5864                Log6(("    %#04x", pu8[i]));
    56115865            }
    56125866            else
    56135867            {
    5614                 Log((", %#04x", pu8[i]));
     5868                Log6((", %#04x", pu8[i]));
    56155869            }
    56165870        }
    5617         Log(("\n"));
     5871        Log6(("\n"));
    56185872#endif
    56195873
     
    56525906
    56535907
    5654 static DECLCALLBACK(int) vmsvga3dBackDXDefineStreamOutput(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    5655 {
    5656     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    5657 
    5658     RT_NOREF(pBackend, pDXContext);
    5659     AssertFailed(); /** @todo Implement */
    5660     return VERR_NOT_IMPLEMENTED;
    5661 }
    5662 
    5663 
    5664 static DECLCALLBACK(int) vmsvga3dBackDXDestroyStreamOutput(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext)
    5665 {
    5666     PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
    5667 
    5668     RT_NOREF(pBackend, pDXContext);
    5669     AssertFailed(); /** @todo Implement */
    5670     return VERR_NOT_IMPLEMENTED;
     5908static DECLCALLBACK(int) vmsvga3dBackDXDefineStreamOutput(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid, SVGACOTableDXStreamOutputEntry const *pEntry)
     5909{
     5910    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     5911    RT_NOREF(pBackend);
     5912
     5913    DXSTREAMOUTPUT *pDXStreamOutput = &pDXContext->pBackendDXContext->paStreamOutput[soid];
     5914    dxDestroyStreamOutput(pDXStreamOutput);
     5915
     5916    return dxDefineStreamOutput(pDXContext, soid, pEntry);
     5917}
     5918
     5919
     5920static DECLCALLBACK(int) vmsvga3dBackDXDestroyStreamOutput(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid)
     5921{
     5922    PVMSVGA3DBACKEND pBackend = pThisCC->svga.p3dState->pBackend;
     5923    RT_NOREF(pBackend);
     5924
     5925    DXSTREAMOUTPUT *pDXStreamOutput = &pDXContext->pBackendDXContext->paStreamOutput[soid];
     5926    dxDestroyStreamOutput(pDXStreamOutput);
     5927
     5928    return VINF_SUCCESS;
    56715929}
    56725930
     
    56825940
    56835941
    5684 static int dxCOTableRealloc(void **ppvCOTable, uint32_t *pcCOTable, uint32_t cbEntry, uint32_t cEntries)
    5685 {
     5942static int dxCOTableRealloc(void **ppvCOTable, uint32_t *pcCOTable, uint32_t cbEntry, uint32_t cEntries, uint32_t cValidEntries)
     5943{
     5944    uint32_t const cCOTableCurrent = *pcCOTable;
     5945
    56865946    if (*pcCOTable != cEntries)
    56875947    {
     
    57035963
    57045964    if (*ppvCOTable)
    5705         memset(*ppvCOTable, 0, cEntries * cbEntry);
     5965    {
     5966        uint32_t const cEntriesToKeep = RT_MIN(cCOTableCurrent, cValidEntries);
     5967        memset((uint8_t *)(*ppvCOTable) + cEntriesToKeep * cbEntry, 0, (cEntries - cEntriesToKeep) * cbEntry);
     5968    }
    57065969
    57075970    return VINF_SUCCESS;
     
    57275990            /* Clear current entries. */
    57285991            if (pBackendDXContext->papRenderTargetView)
    5729                 DX_RELEASE_ARRAY(pBackendDXContext->cRenderTargetView, pBackendDXContext->papRenderTargetView);
     5992            {
     5993                for (uint32_t i = cValidEntries; i < pBackendDXContext->cRenderTargetView; ++i)
     5994                    D3D_RELEASE(pBackendDXContext->papRenderTargetView[i]);
     5995            }
    57305996
    57315997            rc = dxCOTableRealloc((void **)&pBackendDXContext->papRenderTargetView, &pBackendDXContext->cRenderTargetView,
    5732                                   sizeof(pBackendDXContext->papRenderTargetView[0]), pDXContext->cot.cRTView);
     5998                                  sizeof(pBackendDXContext->papRenderTargetView[0]), pDXContext->cot.cRTView, cValidEntries);
    57335999            AssertRCBreak(rc);
    57346000
     
    57446010        case SVGA_COTABLE_DSVIEW:
    57456011            if (pBackendDXContext->papDepthStencilView)
    5746                 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilView, pBackendDXContext->papDepthStencilView);
     6012            {
     6013                for (uint32_t i = cValidEntries; i < pBackendDXContext->cDepthStencilView; ++i)
     6014                    D3D_RELEASE(pBackendDXContext->papDepthStencilView[i]);
     6015            }
    57476016
    57486017            rc = dxCOTableRealloc((void **)&pBackendDXContext->papDepthStencilView, &pBackendDXContext->cDepthStencilView,
    5749                                   sizeof(pBackendDXContext->papDepthStencilView[0]), pDXContext->cot.cDSView);
     6018                                  sizeof(pBackendDXContext->papDepthStencilView[0]), pDXContext->cot.cDSView, cValidEntries);
    57506019            AssertRCBreak(rc);
    57516020
     
    57616030        case SVGA_COTABLE_SRVIEW:
    57626031            if (pBackendDXContext->papShaderResourceView)
    5763                 DX_RELEASE_ARRAY(pBackendDXContext->cShaderResourceView, pBackendDXContext->papShaderResourceView);
     6032            {
     6033                for (uint32_t i = cValidEntries; i < pBackendDXContext->cShaderResourceView; ++i)
     6034                    D3D_RELEASE(pBackendDXContext->papShaderResourceView[i]);
     6035            }
    57646036
    57656037            rc = dxCOTableRealloc((void **)&pBackendDXContext->papShaderResourceView, &pBackendDXContext->cShaderResourceView,
    5766                                   sizeof(pBackendDXContext->papShaderResourceView[0]), pDXContext->cot.cSRView);
     6038                                  sizeof(pBackendDXContext->papShaderResourceView[0]), pDXContext->cot.cSRView, cValidEntries);
    57676039            AssertRCBreak(rc);
    57686040
     
    57796051            if (pBackendDXContext->paElementLayout)
    57806052            {
    5781                 for (uint32_t i = 0; i < pBackendDXContext->cElementLayout; ++i)
     6053                for (uint32_t i = cValidEntries; i < pBackendDXContext->cElementLayout; ++i)
    57826054                    D3D_RELEASE(pBackendDXContext->paElementLayout[i].pElementLayout);
    57836055            }
    57846056
    57856057            rc = dxCOTableRealloc((void **)&pBackendDXContext->paElementLayout, &pBackendDXContext->cElementLayout,
    5786                                   sizeof(pBackendDXContext->paElementLayout[0]), pDXContext->cot.cElementLayout);
     6058                                  sizeof(pBackendDXContext->paElementLayout[0]), pDXContext->cot.cElementLayout, cValidEntries);
    57876059            AssertRCBreak(rc);
    57886060
     
    57986070        case SVGA_COTABLE_BLENDSTATE:
    57996071            if (pBackendDXContext->papBlendState)
    5800                 DX_RELEASE_ARRAY(pBackendDXContext->cBlendState, pBackendDXContext->papBlendState);
     6072            {
     6073                for (uint32_t i = cValidEntries; i < pBackendDXContext->cBlendState; ++i)
     6074                    D3D_RELEASE(pBackendDXContext->papBlendState[i]);
     6075            }
    58016076
    58026077            rc = dxCOTableRealloc((void **)&pBackendDXContext->papBlendState, &pBackendDXContext->cBlendState,
    5803                                   sizeof(pBackendDXContext->papBlendState[0]), pDXContext->cot.cBlendState);
     6078                                  sizeof(pBackendDXContext->papBlendState[0]), pDXContext->cot.cBlendState, cValidEntries);
    58046079            AssertRCBreak(rc);
    58056080
     
    58156090        case SVGA_COTABLE_DEPTHSTENCIL:
    58166091            if (pBackendDXContext->papDepthStencilState)
    5817                 DX_RELEASE_ARRAY(pBackendDXContext->cDepthStencilState, pBackendDXContext->papDepthStencilState);
     6092            {
     6093                for (uint32_t i = cValidEntries; i < pBackendDXContext->cDepthStencilState; ++i)
     6094                    D3D_RELEASE(pBackendDXContext->papDepthStencilState[i]);
     6095            }
    58186096
    58196097            rc = dxCOTableRealloc((void **)&pBackendDXContext->papDepthStencilState, &pBackendDXContext->cDepthStencilState,
    5820                                   sizeof(pBackendDXContext->papDepthStencilState[0]), pDXContext->cot.cDepthStencil);
     6098                                  sizeof(pBackendDXContext->papDepthStencilState[0]), pDXContext->cot.cDepthStencil, cValidEntries);
    58216099            AssertRCBreak(rc);
    58226100
     
    58326110        case SVGA_COTABLE_RASTERIZERSTATE:
    58336111            if (pBackendDXContext->papRasterizerState)
    5834                 DX_RELEASE_ARRAY(pBackendDXContext->cRasterizerState, pBackendDXContext->papRasterizerState);
     6112            {
     6113                for (uint32_t i = cValidEntries; i < pBackendDXContext->cRasterizerState; ++i)
     6114                    D3D_RELEASE(pBackendDXContext->papRasterizerState[i]);
     6115            }
    58356116
    58366117            rc = dxCOTableRealloc((void **)&pBackendDXContext->papRasterizerState, &pBackendDXContext->cRasterizerState,
    5837                                   sizeof(pBackendDXContext->papRasterizerState[0]), pDXContext->cot.cRasterizerState);
     6118                                  sizeof(pBackendDXContext->papRasterizerState[0]), pDXContext->cot.cRasterizerState, cValidEntries);
    58386119            AssertRCBreak(rc);
    58396120
     
    58496130        case SVGA_COTABLE_SAMPLER:
    58506131            if (pBackendDXContext->papSamplerState)
    5851                 DX_RELEASE_ARRAY(pBackendDXContext->cSamplerState, pBackendDXContext->papSamplerState);
     6132            {
     6133                for (uint32_t i = cValidEntries; i < pBackendDXContext->cSamplerState; ++i)
     6134                    D3D_RELEASE(pBackendDXContext->papSamplerState[i]);
     6135            }
    58526136
    58536137            rc = dxCOTableRealloc((void **)&pBackendDXContext->papSamplerState, &pBackendDXContext->cSamplerState,
    5854                                   sizeof(pBackendDXContext->papSamplerState[0]), pDXContext->cot.cSampler);
     6138                                  sizeof(pBackendDXContext->papSamplerState[0]), pDXContext->cot.cSampler, cValidEntries);
    58556139            AssertRCBreak(rc);
    58566140
     
    58656149            break;
    58666150        case SVGA_COTABLE_STREAMOUTPUT:
    5867             //AssertFailed(); /** @todo Implement */
     6151            if (pBackendDXContext->paStreamOutput)
     6152            {
     6153                for (uint32_t i = cValidEntries; i < pBackendDXContext->cStreamOutput; ++i)
     6154                    dxDestroyStreamOutput(&pBackendDXContext->paStreamOutput[i]);
     6155            }
     6156
     6157            rc = dxCOTableRealloc((void **)&pBackendDXContext->paStreamOutput, &pBackendDXContext->cStreamOutput,
     6158                                  sizeof(pBackendDXContext->paStreamOutput[0]), pDXContext->cot.cStreamOutput, cValidEntries);
     6159            AssertRCBreak(rc);
     6160
     6161            for (uint32_t i = 0; i < cValidEntries; ++i)
     6162            {
     6163                SVGACOTableDXStreamOutputEntry const *pEntry = &pDXContext->cot.paStreamOutput[i];
     6164                /** @todo The caller must verify the COTable content using same rules as when a new entry is defined. */
     6165                if (ASMMemFirstNonZero(pEntry, sizeof(*pEntry)) == NULL)
     6166                    continue; /* Skip uninitialized entry. */
     6167
     6168                dxDefineStreamOutput(pDXContext, i, pEntry);
     6169            }
    58686170            break;
    58696171        case SVGA_COTABLE_DXQUERY:
    58706172            if (pBackendDXContext->papQuery)
    5871                 DX_RELEASE_ARRAY(pBackendDXContext->cQuery, pBackendDXContext->papQuery);
     6173            {
     6174                for (uint32_t i = cValidEntries; i < pBackendDXContext->cQuery; ++i)
     6175                    D3D_RELEASE(pBackendDXContext->papQuery[i]);
     6176            }
    58726177
    58736178            rc = dxCOTableRealloc((void **)&pBackendDXContext->papQuery, &pBackendDXContext->cQuery,
    5874                                   sizeof(pBackendDXContext->papQuery[0]), pDXContext->cot.cQuery);
     6179                                  sizeof(pBackendDXContext->papQuery[0]), pDXContext->cot.cQuery, cValidEntries);
    58756180            AssertRCBreak(rc);
    58766181
     
    58876192            if (pBackendDXContext->paShader)
    58886193            {
    5889                 for (uint32_t i = 0; i < pBackendDXContext->cShader; ++i)
    5890                     D3D_RELEASE(pBackendDXContext->paShader[i].pShader);
     6194                /* Destroy the no longer used entries. */
     6195                for (uint32_t i = cValidEntries; i < pBackendDXContext->cShader; ++i)
     6196                    dxDestroyShader(&pBackendDXContext->paShader[i]);
    58916197            }
    58926198
    58936199            rc = dxCOTableRealloc((void **)&pBackendDXContext->paShader, &pBackendDXContext->cShader,
    5894                                   sizeof(pBackendDXContext->paShader[0]), pDXContext->cot.cShader);
     6200                                  sizeof(pBackendDXContext->paShader[0]), pDXContext->cot.cShader, cValidEntries);
    58956201            AssertRCBreak(rc);
    58966202
     
    59026208                    continue; /* Skip uninitialized entry. */
    59036209
    5904                 /** @todo this should be in the commd DX code (the caller). */
     6210                /** @todo this should be in the common DX code (the caller). */
    59056211                PVMSVGA3DSHADER pShader = &pDXContext->paShader[i];
    59066212                pShader->id                = i;
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp

    r91362 r91375  
    15351535    }
    15361536
     1537    uint32_t const cBlocksX = (clipBox.w + pSurface->cxBlock - 1) / pSurface->cxBlock;
     1538    uint32_t const cBlocksY = (clipBox.h + pSurface->cyBlock - 1) / pSurface->cyBlock;
     1539
    15371540    /** @todo Calculate offSubresource here, when pSurface will have cbArraySlice field. */
    15381541    pResult->offSubresource = vmsvga3dCalcSubresourceOffset(pThisCC, pImage);
     
    15401543                      + (clipBox.y / pSurface->cyBlock) * pMipLevel->cbSurfacePitch
    15411544                      + clipBox.z * pMipLevel->cbSurfacePlane;
    1542     pResult->cbRow    = (clipBox.w / pSurface->cxBlock) * pSurface->cbBlock;
     1545    pResult->cbRow    = cBlocksX * pSurface->cbBlock;
    15431546    pResult->cbPitch  = pMipLevel->cbSurfacePitch;
    1544     pResult->cyBlocks = clipBox.h / pSurface->cyBlock;
     1547    pResult->cyBlocks = cBlocksY;
    15451548    pResult->cDepth   = clipBox.d;
    15461549
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h

    r91361 r91375  
    424424    DECLCALLBACKMEMBER(int, pfnDXReadbackQuery,             (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    425425    DECLCALLBACKMEMBER(int, pfnDXSetPredication,            (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    426     DECLCALLBACKMEMBER(int, pfnDXSetSOTargets,              (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
     426    DECLCALLBACKMEMBER(int, pfnDXSetSOTargets,              (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t cSoTarget, SVGA3dSoTarget const *paSoTarget));
    427427    DECLCALLBACKMEMBER(int, pfnDXSetViewports,              (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t cViewport, SVGA3dViewport const *paViewport));
    428428    DECLCALLBACKMEMBER(int, pfnDXSetScissorRects,           (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, uint32_t cRect, SVGASignedRect const *paRect));
     
    450450    DECLCALLBACKMEMBER(int, pfnDXDestroySamplerState,       (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    451451    DECLCALLBACKMEMBER(int, pfnDXDefineShader,              (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId, SVGACOTableDXShaderEntry const *pEntry));
    452     DECLCALLBACKMEMBER(int, pfnDXDestroyShader,             (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
     452    DECLCALLBACKMEMBER(int, pfnDXDestroyShader,             (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dShaderId shaderId));
    453453    DECLCALLBACKMEMBER(int, pfnDXBindShader,                (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSHADER pShader, void const *pvShaderBytecode));
    454     DECLCALLBACKMEMBER(int, pfnDXDefineStreamOutput,        (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    455     DECLCALLBACKMEMBER(int, pfnDXDestroyStreamOutput,       (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
     454    DECLCALLBACKMEMBER(int, pfnDXDefineStreamOutput,        (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid, SVGACOTableDXStreamOutputEntry const *pEntry));
     455    DECLCALLBACKMEMBER(int, pfnDXDestroyStreamOutput,       (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGA3dStreamOutputId soid));
    456456    DECLCALLBACKMEMBER(int, pfnDXSetStreamOutput,           (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext));
    457457    DECLCALLBACKMEMBER(int, pfnDXSetCOTable,                (PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, SVGACOTableType type, uint32_t cValidEntries));
     
    553553int vmsvga3dDXReadbackQuery(PVGASTATECC pThisCC, uint32_t idDXContext);
    554554int vmsvga3dDXSetPredication(PVGASTATECC pThisCC, uint32_t idDXContext);
    555 int vmsvga3dDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext);
     555int vmsvga3dDXSetSOTargets(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cSoTarget, SVGA3dSoTarget const *paSoTarget);
    556556int vmsvga3dDXSetViewports(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cViewport, SVGA3dViewport const *paViewport);
    557557int vmsvga3dDXSetScissorRects(PVGASTATECC pThisCC, uint32_t idDXContext, uint32_t cRect, SVGASignedRect const *paRect);
     
    579579int vmsvga3dDXDestroySamplerState(PVGASTATECC pThisCC, uint32_t idDXContext);
    580580int vmsvga3dDXDefineShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineShader const *pCmd);
    581 int vmsvga3dDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext);
     581int vmsvga3dDXDestroyShader(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyShader const *pCmd);
    582582int vmsvga3dDXBindShader(PVGASTATECC pThisCC, SVGA3dCmdDXBindShader const *pCmd, PVMSVGAMOB pMob);
    583 int vmsvga3dDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext);
    584 int vmsvga3dDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext);
     583int vmsvga3dDXDefineStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDefineStreamOutput const *pCmd);
     584int vmsvga3dDXDestroyStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext, SVGA3dCmdDXDestroyStreamOutput const *pCmd);
    585585int vmsvga3dDXSetStreamOutput(PVGASTATECC pThisCC, uint32_t idDXContext);
    586586int vmsvga3dDXSetCOTable(PVGASTATECC pThisCC, SVGA3dCmdDXSetCOTable const *pCmd, PVMSVGAMOB pMob);
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