VirtualBox

Ignore:
Timestamp:
May 16, 2022 3:00:15 PM (3 years ago)
Author:
vboxsync
Message:

Devices/Graphics: constant buffers (regression fix): bugref:9830

File:
1 edited

Legend:

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

    r95017 r95022  
    25892589}
    25902590
     2591#if 0
    25912592static int vmsvga3dBackSurfaceCreateConstantBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface, uint32_t offsetInBytes, uint32_t sizeInBytes)
    25922593{
     
    26552656    return VERR_NO_MEMORY;
    26562657}
    2657 
     2658#endif
    26582659
    26592660static int vmsvga3dBackSurfaceCreateResource(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface)
     
    51535154    AssertRCReturn(rc, rc);
    51545155
    5155     if (pSurface->pBackendSurface == NULL)
    5156     {
    5157         /* Create the resource and initialize it with the current surface data. */
    5158         rc = vmsvga3dBackSurfaceCreateConstantBuffer(pThisCC, pDXContext, pSurface, offsetInBytes, sizeInBytes);
    5159         AssertRCReturn(rc, rc);
    5160     }
    5161 
    5162     /* Create the actual constane buffer taking into account offsetInBytes and sizeInBytes. */
     5156    PVMSVGA3DMIPMAPLEVEL pMipLevel;
     5157    rc = vmsvga3dMipmapLevel(pSurface, 0, 0, &pMipLevel);
     5158    AssertRCReturn(rc, rc);
     5159
     5160    uint32_t const cbSurface = pMipLevel->cbSurface;
     5161    ASSERT_GUEST_RETURN(   offsetInBytes < cbSurface
     5162                        && sizeInBytes <= cbSurface - offsetInBytes, VERR_INVALID_PARAMETER);
     5163
     5164    /* Constant buffers are created on demand. */
     5165    Assert(pSurface->pBackendSurface == NULL);
     5166
     5167    /* Upload the current data, if any. */
     5168    D3D11_SUBRESOURCE_DATA *pInitialData = NULL;
     5169    D3D11_SUBRESOURCE_DATA initialData;
     5170    if (pMipLevel->pSurfaceData)
     5171    {
     5172        initialData.pSysMem          = (uint8_t *)pMipLevel->pSurfaceData + offsetInBytes;
     5173        initialData.SysMemPitch      = sizeInBytes;
     5174        initialData.SysMemSlicePitch = sizeInBytes;
     5175
     5176        pInitialData = &initialData;
     5177
     5178        // Log(("%.*Rhxd\n", sizeInBytes, initialData.pSysMem));
     5179    }
     5180
    51635181    D3D11_BUFFER_DESC bd;
    51645182    RT_ZERO(bd);
     
    51665184    bd.Usage               = D3D11_USAGE_DEFAULT;
    51675185    bd.BindFlags           = D3D11_BIND_CONSTANT_BUFFER;
     5186    bd.CPUAccessFlags      = 0;
     5187    bd.MiscFlags           = 0;
     5188    bd.StructureByteStride = 0;
    51685189
    51695190    ID3D11Buffer *pBuffer = 0;
    5170     HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, NULL, &pBuffer);
     5191    HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBuffer);
    51715192    if (SUCCEEDED(hr))
    51725193    {
    5173        ID3D11Resource *pDstResource = pBuffer;
    5174        UINT DstSubresource = 0;
    5175        UINT DstX = 0;
    5176        UINT DstY = 0;
    5177        UINT DstZ = 0;
    5178        ID3D11Resource *pSrcResource = pSurface->pBackendSurface->u.pResource;
    5179        UINT SrcSubresource = 0;
    5180        D3D11_BOX SrcBox;
    5181        SrcBox.left   = offsetInBytes;
    5182        SrcBox.top    = 0;
    5183        SrcBox.front  = 0;
    5184        SrcBox.right  = offsetInBytes + sizeInBytes;
    5185        SrcBox.bottom = 1;
    5186        SrcBox.back   = 1;
    5187        pDevice->pImmediateContext->CopySubresourceRegion(pDstResource, DstSubresource, DstX, DstY, DstZ,
    5188                                                          pSrcResource, SrcSubresource, &SrcBox);
    5189 
    51905194       dxConstantBufferSet(pDevice, slot, type, pBuffer);
    51915195       D3D_RELEASE(pBuffer); /* xSSetConstantBuffers "will hold a reference to the interfaces passed in." */
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