Changeset 95022 in vbox for trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
- Timestamp:
- May 16, 2022 3:00:15 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
r95017 r95022 2589 2589 } 2590 2590 2591 #if 0 2591 2592 static int vmsvga3dBackSurfaceCreateConstantBuffer(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface, uint32_t offsetInBytes, uint32_t sizeInBytes) 2592 2593 { … … 2655 2656 return VERR_NO_MEMORY; 2656 2657 } 2657 2658 #endif 2658 2659 2659 2660 static int vmsvga3dBackSurfaceCreateResource(PVGASTATECC pThisCC, PVMSVGA3DDXCONTEXT pDXContext, PVMSVGA3DSURFACE pSurface) … … 5153 5154 AssertRCReturn(rc, rc); 5154 5155 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 5163 5181 D3D11_BUFFER_DESC bd; 5164 5182 RT_ZERO(bd); … … 5166 5184 bd.Usage = D3D11_USAGE_DEFAULT; 5167 5185 bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; 5186 bd.CPUAccessFlags = 0; 5187 bd.MiscFlags = 0; 5188 bd.StructureByteStride = 0; 5168 5189 5169 5190 ID3D11Buffer *pBuffer = 0; 5170 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, NULL, &pBuffer);5191 HRESULT hr = pDevice->pDevice->CreateBuffer(&bd, pInitialData, &pBuffer); 5171 5192 if (SUCCEEDED(hr)) 5172 5193 { 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 5190 5194 dxConstantBufferSet(pDevice, slot, type, pBuffer); 5191 5195 D3D_RELEASE(pBuffer); /* xSSetConstantBuffers "will hold a reference to the interfaces passed in." */
Note:
See TracChangeset
for help on using the changeset viewer.