- Timestamp:
- Mar 25, 2022 6:26:29 PM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
r94265 r94377 951 951 } 952 952 953 954 int vmsvgaR3UpdateGBSurface(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBox)955 {956 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;957 958 SVGAOTableSurfaceEntry entrySurface;959 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],960 pImageId->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));961 if (RT_SUCCESS(rc))962 {963 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);964 if (pMob)965 {966 VMSVGA3D_MAPPED_SURFACE map;967 rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBox, VMSVGA3D_SURFACE_MAP_WRITE, &map);968 if (RT_SUCCESS(rc))969 {970 /* Copy MOB -> mapped surface. */971 uint32_t offSrc = pBox->x * map.cbPixel972 + pBox->y * entrySurface.size.width * map.cbPixel973 + pBox->z * entrySurface.size.height * entrySurface.size.width * map.cbPixel;974 uint8_t *pu8Dst = (uint8_t *)map.pvData;975 for (uint32_t z = 0; z < pBox->d; ++z)976 {977 for (uint32_t y = 0; y < pBox->h; ++y)978 {979 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offSrc, pu8Dst, pBox->w * map.cbPixel);980 if (RT_FAILURE(rc))981 break;982 983 pu8Dst += map.cbRowPitch;984 offSrc += entrySurface.size.width * map.cbPixel;985 }986 987 pu8Dst += map.cbDepthPitch;988 offSrc += entrySurface.size.height * entrySurface.size.width * map.cbPixel;989 }990 991 vmsvga3dSurfaceUnmap(pThisCC, pImageId, &map, /* fWritten= */ true);992 }993 }994 else995 rc = VERR_INVALID_STATE;996 }997 998 return rc;999 }1000 1001 1002 int vmsvgaR3UpdateGBSurfaceEx(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBoxDst, SVGA3dPoint const *pPtSrc)1003 {1004 /* pPtSrc must be verified by the caller. */1005 PVMSVGAR3STATE const pSvgaR3State = pThisCC->svga.pSvgaR3State;1006 1007 SVGAOTableSurfaceEntry entrySurface;1008 int rc = vmsvgaR3OTableRead(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE],1009 pImageId->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entrySurface, sizeof(entrySurface));1010 if (RT_SUCCESS(rc))1011 {1012 PVMSVGAMOB pMob = vmsvgaR3MobGet(pSvgaR3State, entrySurface.mobid);1013 if (pMob)1014 {1015 VMSVGA3D_MAPPED_SURFACE map;1016 rc = vmsvga3dSurfaceMap(pThisCC, pImageId, pBoxDst, VMSVGA3D_SURFACE_MAP_WRITE, &map);1017 if (RT_SUCCESS(rc))1018 {1019 /* Copy MOB -> mapped surface. */1020 uint32_t offSrc = pPtSrc->x * map.cbPixel1021 + pPtSrc->y * entrySurface.size.width * map.cbPixel1022 + pPtSrc->z * entrySurface.size.height * entrySurface.size.width * map.cbPixel;1023 uint8_t *pu8Dst = (uint8_t *)map.pvData;1024 for (uint32_t z = 0; z < pBoxDst->d; ++z)1025 {1026 for (uint32_t y = 0; y < pBoxDst->h; ++y)1027 {1028 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offSrc, pu8Dst, pBoxDst->w * map.cbPixel);1029 if (RT_FAILURE(rc))1030 break;1031 1032 pu8Dst += map.cbRowPitch;1033 offSrc += entrySurface.size.width * map.cbPixel;1034 }1035 1036 pu8Dst += map.cbDepthPitch;1037 offSrc += entrySurface.size.height * entrySurface.size.width * map.cbPixel;1038 }1039 1040 vmsvga3dSurfaceUnmap(pThisCC, pImageId, &map, /* fWritten= */ true);1041 }1042 }1043 else1044 rc = VERR_INVALID_STATE;1045 }1046 1047 return rc;1048 }1049 1050 953 #endif /* VBOX_WITH_VMSVGA3D */ 1051 954 … … 1467 1370 static int vmsvga3dBmpWrite(const char *pszFilename, VMSVGA3D_MAPPED_SURFACE const *pMap) 1468 1371 { 1469 if (pMap->cb Pixel!= 4 && pMap->format != SVGA3D_R16G16B16A16_FLOAT)1372 if (pMap->cbBlock != 4 && pMap->format != SVGA3D_R16G16B16A16_FLOAT) 1470 1373 return VERR_NOT_SUPPORTED; 1471 1374 1472 int const w = pMap-> box.w;1473 int const h = pMap-> box.h;1474 1475 const int cbBitmap = w * h* 4;1375 int const w = pMap->cbRow / pMap->cbBlock; 1376 int const h = pMap->cRows; 1377 1378 const int cbBitmap = pMap->cbRow * pMap->cRows * 4; 1476 1379 1477 1380 FILE *f = fopen(pszFilename, "wb"); … … 1499 1402 } 1500 1403 1501 if (pMap->cb Pixel== 4)1404 if (pMap->cbBlock == 4) 1502 1405 { 1503 1406 const uint8_t *s = (uint8_t *)pMap->pvData; 1504 for ( int32_t y = 0; y < h; ++y)1407 for (uint32_t iRow = 0; iRow < pMap->cRows; ++iRow) 1505 1408 { 1506 fwrite(s, 1, w * pMap->cbPixel, f);1409 fwrite(s, 1, pMap->cbRow, f); 1507 1410 1508 1411 s += pMap->cbRowPitch; … … 1563 1466 AssertFailedReturn(VERR_INVALID_PARAMETER); 1564 1467 1565 VMSGA3D_BOX_DIMENSIONS dims;1566 int rc = vmsvga3dGetBoxDimensions(pThisCC, pImage, pBox, &dims);1567 AssertRCReturn(rc, rc);1568 1569 1468 VMSVGA3D_MAPPED_SURFACE map; 1570 rc = vmsvga3dSurfaceMap(pThisCC, pImage, pBox, enmMapType, &map);1469 int rc = vmsvga3dSurfaceMap(pThisCC, pImage, pBox, enmMapType, &map); 1571 1470 if (RT_SUCCESS(rc)) 1572 1471 { 1573 1472 /* Copy mapped surface <-> MOB. */ 1574 uint8_t *pu8Map = (uint8_t *)map.pvData;1575 uint32_t offMob = dims.offSubresource + dims.offBox;1576 for (uint32_t z = 0; z < dims.cDepth; ++z)1473 VMSGA3D_BOX_DIMENSIONS dims; 1474 rc = vmsvga3dGetBoxDimensions(pThisCC, pImage, pBox, &dims); 1475 if (RT_SUCCESS(rc)) 1577 1476 { 1578 for (uint32_t y = 0; y < dims.cyBlocks; ++y)1477 for (uint32_t z = 0; z < map.box.d; ++z) 1579 1478 { 1580 if (enmTransfer == SVGA3D_READ_HOST_VRAM) 1581 rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow); 1582 else 1583 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow); 1584 AssertRCBreak(rc); 1585 1586 pu8Map += map.cbRowPitch; 1587 offMob += dims.cbPitch; 1479 uint8_t *pu8Map = (uint8_t *)map.pvData + z * map.cbDepthPitch; 1480 uint32_t offMob = dims.offSubresource + dims.offBox + z * dims.cbDepthPitch; 1481 1482 for (uint32_t iRow = 0; iRow < map.cRows; ++iRow) 1483 { 1484 if (enmTransfer == SVGA3D_READ_HOST_VRAM) 1485 rc = vmsvgaR3GboWrite(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow); 1486 else 1487 rc = vmsvgaR3GboRead(pSvgaR3State, &pMob->Gbo, offMob, pu8Map, dims.cbRow); 1488 AssertRCBreak(rc); 1489 1490 pu8Map += map.cbRowPitch; 1491 offMob += dims.cbPitch; 1492 } 1588 1493 } 1589 /** @todo Take into account map.cbDepthPitch */1590 1494 } 1591 1495 … … 1960 1864 { 1961 1865 /* Copy the screen target surface to the memory buffer. */ 1866 SVGA3dBox box; /* SurfaceMap will clip the box as necessary. */ 1867 box.x = pCmd->rect.x; 1868 box.y = pCmd->rect.y; 1869 box.z = 0; 1870 box.w = pCmd->rect.w; 1871 box.h = pCmd->rect.h; 1872 box.d = 1; 1873 1962 1874 VMSVGA3D_MAPPED_SURFACE map; 1963 rc = vmsvga3dSurfaceMap(pThisCC, &entryScreenTarget.image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map);1875 rc = vmsvga3dSurfaceMap(pThisCC, &entryScreenTarget.image, &box, VMSVGA3D_SURFACE_MAP_READ, &map); 1964 1876 if (RT_SUCCESS(rc)) 1965 1877 { 1966 uint8_t const *pu8Src = (uint8_t *)map.pvData 1967 + targetRect.x * map.cbPixel 1968 + targetRect.y * map.cbRowPitch; 1969 uint8_t *pu8Dst = (uint8_t *)pScreen->pvScreenBitmap 1970 + targetRect.x * map.cbPixel 1971 + targetRect.y * map.box.w * map.cbPixel; 1972 for (uint32_t y = 0; y < targetRect.h; ++y) 1878 VMSGA3D_BOX_DIMENSIONS dims; 1879 rc = vmsvga3dGetBoxDimensions(pThisCC, &entryScreenTarget.image, &map.box, &dims); 1880 if (RT_SUCCESS(rc)) 1973 1881 { 1974 memcpy(pu8Dst, pu8Src, targetRect.w * map.cbPixel); 1975 1976 pu8Src += map.cbRowPitch; 1977 pu8Dst += map.box.w * map.cbPixel; 1882 uint8_t const *pu8Src = (uint8_t *)map.pvData; 1883 uint8_t *pu8Dst = (uint8_t *)pScreen->pvScreenBitmap + dims.offSubresource + dims.offBox; 1884 for (uint32_t iRow = 0; iRow < map.cRows; ++iRow) 1885 { 1886 memcpy(pu8Dst, pu8Src, dims.cbRow); 1887 1888 pu8Src += map.cbRowPitch; 1889 pu8Dst += dims.cbPitch; 1890 } 1978 1891 } 1979 1892 1980 1893 vmsvga3dSurfaceUnmap(pThisCC, &entryScreenTarget.image, &map, /* fWritten = */ false); 1981 1894 1982 vmsvgaR3UpdateScreen(pThisCC, pScreen, pCmd->rect.x, pCmd->rect.y, pCmd->rect.w, pCmd->rect.h);1895 vmsvgaR3UpdateScreen(pThisCC, pScreen, map.box.x, map.box.y, map.box.w, map.box.h); 1983 1896 } 1984 1897 else … … 3240 3153 */ 3241 3154 uint8_t const *pu8BufferSrc = (uint8_t *)mapBufferSrc.pvData; 3242 uint32_t const cbBufferSrc = mapBufferSrc. box.w * mapBufferSrc.cbPixel;3155 uint32_t const cbBufferSrc = mapBufferSrc.cbRow; 3243 3156 3244 3157 uint8_t *pu8BufferDest = (uint8_t *)mapBufferDest.pvData; 3245 uint32_t const cbBufferDest = mapBufferDest. box.w * mapBufferDest.cbPixel;3158 uint32_t const cbBufferDest = mapBufferDest.cbRow; 3246 3159 3247 3160 if ( pCmd->srcX < cbBufferSrc … … 3311 3224 { 3312 3225 /* 3313 * Copy the mapped buffer to the surface. 3226 * Copy the mapped buffer to the surface. "Raw byte wise transfer" 3314 3227 */ 3315 3228 uint8_t const *pu8Buffer = (uint8_t *)mapBuffer.pvData; 3316 uint32_t const cbBuffer = mapBuffer. box.w * mapBuffer.cbPixel;3229 uint32_t const cbBuffer = mapBuffer.cbRow; 3317 3230 3318 3231 if (pCmd->srcOffset <= cbBuffer) … … 3326 3239 uint8_t *pu8Surface = (uint8_t *)mapSurface.pvData; 3327 3240 3328 uint32_t const cb Width = mapSurface.box.w * mapSurface.cbPixel;3241 uint32_t const cbRowCopy = RT_MIN(pCmd->srcPitch, mapSurface.cbRow); 3329 3242 for (uint32_t z = 0; z < mapSurface.box.d && RT_SUCCESS(rc); ++z) 3330 3243 { 3331 3244 uint8_t const *pu8BufferRow = pu8Buffer; 3332 3245 uint8_t *pu8SurfaceRow = pu8Surface; 3333 for (uint32_t y = 0; y < mapSurface.box.h; ++y)3246 for (uint32_t iRow = 0; iRow < mapSurface.cRows; ++iRow) 3334 3247 { 3335 3248 ASSERT_GUEST_STMT_BREAK( (uintptr_t)pu8BufferRow >= (uintptr_t)pu8BufferBegin 3336 3249 && (uintptr_t)pu8BufferRow < (uintptr_t)pu8BufferEnd 3337 && (uintptr_t)(pu8BufferRow + cbWidth) > (uintptr_t)pu8BufferBegin 3338 && (uintptr_t)(pu8BufferRow + cbWidth) <= (uintptr_t)pu8BufferEnd, 3250 && (uintptr_t)pu8BufferRow < (uintptr_t)(pu8BufferRow + cbRowCopy) 3251 && (uintptr_t)(pu8BufferRow + cbRowCopy) > (uintptr_t)pu8BufferBegin 3252 && (uintptr_t)(pu8BufferRow + cbRowCopy) <= (uintptr_t)pu8BufferEnd, 3339 3253 rc = VERR_INVALID_PARAMETER); 3340 3254 3341 memcpy(pu8SurfaceRow, pu8BufferRow, cb Width);3255 memcpy(pu8SurfaceRow, pu8BufferRow, cbRowCopy); 3342 3256 3343 3257 pu8SurfaceRow += mapSurface.cbRowPitch; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h
r94205 r94377 655 655 #endif 656 656 657 #ifdef VBOX_WITH_VMSVGA3D658 int vmsvgaR3UpdateGBSurface(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBox);659 int vmsvgaR3UpdateGBSurfaceEx(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImageId, SVGA3dBox const *pBoxDst, SVGA3dPoint const *pPtSrc);660 #endif661 662 657 #endif /* !VBOX_INCLUDED_SRC_Graphics_DevVGA_SVGA_h */ -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-savedstate.cpp
r94232 r94377 312 312 /* Save mapped surface data. */ 313 313 pHlp->pfnSSMPutBool(pSSM, true); 314 if (map. box.w * map.cbPixel== map.cbRowPitch)314 if (map.cbRow == map.cbRowPitch) 315 315 { 316 316 rc = pHlp->pfnSSMPutMem(pSSM, map.pvData, pMipmapLevel->cbSurface); … … 320 320 { 321 321 uint8_t *pu8Map = (uint8_t *)map.pvData; 322 for (uint32_t z = 0; z < dims.cDepth; ++z)322 for (uint32_t z = 0; z < map.box.z; ++z) 323 323 { 324 324 uint8_t *pu8MapPlane = pu8Map; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r94232 r94377 1353 1353 const char *pszPath, const char *pszNamePrefix, const char *pszNameSuffix); 1354 1354 1355 void vmsvga3dSurfaceMapInit(VMSVGA3D_MAPPED_SURFACE *pMap, VMSVGA3D_SURFACE_MAP enmMapType, SVGA3dBox const *pBox, 1356 PVMSVGA3DSURFACE pSurface, void *pvData, uint32_t cbRowPitch, uint32_t cbDepthPitch); 1357 1355 1358 #if defined(RT_OS_WINDOWS) 1356 1359 #define D3D_RELEASE(ptr) do { \ -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
r94276 r94377 3093 3093 d3d11MapType, /* MapFlags = */ 0, &mappedResource); 3094 3094 if (SUCCEEDED(hr)) 3095 { 3096 pMap->enmMapType = enmMapType; 3097 pMap->format = pSurface->format; 3098 pMap->box = clipBox; 3099 pMap->cbPixel = pSurface->cbBlock; 3100 pMap->cbRowPitch = mappedResource.RowPitch; 3101 pMap->cbDepthPitch = mappedResource.DepthPitch; 3102 pMap->pvData = (uint8_t *)mappedResource.pData 3103 + pMap->box.x * pMap->cbPixel 3104 + pMap->box.y * pMap->cbRowPitch 3105 + pMap->box.z * pMap->cbDepthPitch; 3106 } 3095 vmsvga3dSurfaceMapInit(pMap, enmMapType, &clipBox, pSurface, 3096 mappedResource.pData, mappedResource.RowPitch, mappedResource.DepthPitch); 3107 3097 else 3108 3098 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); … … 3148 3138 pMappedResource = pBackendSurface->dynamic.pResource; 3149 3139 3150 UINT const Subresource = 0; 3140 UINT const Subresource = 0; /* Dynamic or staging textures have one subresource. */ 3151 3141 HRESULT hr = pDevice->pImmediateContext->Map(pMappedResource, Subresource, 3152 3142 d3d11MapType, /* MapFlags = */ 0, &mappedResource); 3153 3143 if (SUCCEEDED(hr)) 3154 { 3155 pMap->enmMapType = enmMapType; 3156 pMap->format = pSurface->format; 3157 pMap->box = clipBox; 3158 pMap->cbPixel = pSurface->cbBlock; 3159 pMap->cbRowPitch = mappedResource.RowPitch; 3160 pMap->cbDepthPitch = mappedResource.DepthPitch; 3161 pMap->pvData = (uint8_t *)mappedResource.pData 3162 + (pMap->box.x / pSurface->cxBlock) * pMap->cbPixel 3163 + (pMap->box.y / pSurface->cyBlock) * pMap->cbRowPitch 3164 + pMap->box.z * pMap->cbDepthPitch; 3165 } 3144 vmsvga3dSurfaceMapInit(pMap, enmMapType, &clipBox, pSurface, 3145 mappedResource.pData, mappedResource.RowPitch, mappedResource.DepthPitch); 3166 3146 else 3167 3147 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); … … 3202 3182 d3d11MapType, /* MapFlags = */ 0, &mappedResource); 3203 3183 if (SUCCEEDED(hr)) 3204 { 3205 pMap->enmMapType = enmMapType; 3206 pMap->format = pSurface->format; 3207 pMap->box = clipBox; 3208 pMap->cbPixel = pSurface->cbBlock; 3209 pMap->cbRowPitch = mappedResource.RowPitch; 3210 pMap->cbDepthPitch = mappedResource.DepthPitch; 3211 pMap->pvData = (uint8_t *)mappedResource.pData 3212 + pMap->box.x * pMap->cbPixel 3213 + pMap->box.y * pMap->cbRowPitch 3214 + pMap->box.z * pMap->cbDepthPitch; 3215 } 3184 vmsvga3dSurfaceMapInit(pMap, enmMapType, &clipBox, pSurface, 3185 mappedResource.pData, mappedResource.RowPitch, mappedResource.DepthPitch); 3216 3186 else 3217 3187 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); … … 3320 3290 uint32_t const cHeight0 = pSurface->paMipmapLevels[0].mipmapSize.height; 3321 3291 uint32_t const cDepth0 = pSurface->paMipmapLevels[0].mipmapSize.depth; 3292 /** @todo Entire subresource is always mapped. So find a way to copy it back, important for DEPTH_STENCIL mipmaps. */ 3322 3293 bool const fEntireResource = pMap->box.x == 0 && pMap->box.y == 0 && pMap->box.z == 0 3323 3294 && pMap->box.w == cWidth0 && pMap->box.h == cHeight0 && pMap->box.d == cDepth0; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r94267 r94377 302 302 303 303 AssertLogRelRCReturnStmt(rc, RTMemFree(pSurface->paMipmapLevels), rc); 304 305 /* Compute the size of one array element. */ 306 pSurface->surfaceDesc.cbArrayElement = 0; 307 for (uint32_t i = 0; i < pSurface->cLevels; ++i) 308 { 309 PVMSVGA3DMIPMAPLEVEL pMipLevel = &pSurface->paMipmapLevels[i]; 310 pSurface->surfaceDesc.cbArrayElement += pMipLevel->cbSurface; 311 } 304 312 305 313 if (vmsvga3dIsLegacyBackend(pThisCC)) … … 1391 1399 */ 1392 1400 1401 void vmsvga3dSurfaceMapInit(VMSVGA3D_MAPPED_SURFACE *pMap, VMSVGA3D_SURFACE_MAP enmMapType, SVGA3dBox const *pBox, 1402 PVMSVGA3DSURFACE pSurface, void *pvData, uint32_t cbRowPitch, uint32_t cbDepthPitch) 1403 { 1404 uint32_t const cxBlocks = (pBox->w + pSurface->cxBlock - 1) / pSurface->cxBlock; 1405 uint32_t const cyBlocks = (pBox->h + pSurface->cyBlock - 1) / pSurface->cyBlock; 1406 1407 pMap->enmMapType = enmMapType; 1408 pMap->format = pSurface->format; 1409 pMap->box = *pBox; 1410 pMap->cbBlock = pSurface->cbBlock; 1411 pMap->cbRow = cxBlocks * pSurface->cbBlock; 1412 pMap->cbRowPitch = cbRowPitch; 1413 pMap->cRows = cyBlocks; 1414 pMap->cbDepthPitch = cbDepthPitch; 1415 pMap->pvData = (uint8_t *)pvData 1416 + (pBox->x / pSurface->cxBlock) * pSurface->cbBlock 1417 + (pBox->y / pSurface->cyBlock) * cbRowPitch 1418 + pBox->z * cbDepthPitch; 1419 } 1420 1421 1393 1422 int vmsvga3dSurfaceMap(PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pImage, SVGA3dBox const *pBox, 1394 1423 VMSVGA3D_SURFACE_MAP enmMapType, VMSVGA3D_MAPPED_SURFACE *pMap) … … 1436 1465 // RT_BZERO(.); 1437 1466 1438 pMap->enmMapType = enmMapType; 1439 pMap->format = pSurface->format; 1440 pMap->box = clipBox; 1441 pMap->cbPixel = pSurface->cbBlock; 1442 pMap->cbRowPitch = pMipLevel->cbSurfacePitch; 1443 pMap->cbDepthPitch = pMipLevel->cbSurfacePlane; 1444 pMap->pvData = (uint8_t *)pMipLevel->pSurfaceData 1445 + (pMap->box.x / pSurface->cxBlock) * pMap->cbPixel 1446 + (pMap->box.y / pSurface->cyBlock) * pMap->cbRowPitch 1447 + pMap->box.z * pMap->cbDepthPitch; 1467 vmsvga3dSurfaceMapInit(pMap, enmMapType, &clipBox, pSurface, 1468 pMipLevel->pSurfaceData, pMipLevel->cbSurfacePitch, pMipLevel->cbSurfacePlane); 1448 1469 1449 1470 LogFunc(("SysMem: pvData %p\n", pMap->pvData)); … … 1498 1519 AssertRCReturn(rc, 0); 1499 1520 1500 /** @todo Store cbArraySlice in the surface structure. */ 1501 uint32_t cbArraySlice = 0; 1502 for (uint32_t i = 0; i < pSurface->cLevels; ++i) 1503 { 1504 PVMSVGA3DMIPMAPLEVEL pMipLevel = &pSurface->paMipmapLevels[i]; 1505 cbArraySlice += pMipLevel->cbSurface; 1506 } 1521 ASSERT_GUEST_RETURN(pImage->face < pSurface->surfaceDesc.numArrayElements, 0); 1507 1522 1508 1523 uint32_t offMipLevel = 0; … … 1513 1528 } 1514 1529 1515 uint32_t offSubresource = cbArraySlice* pImage->face + offMipLevel;1530 uint32_t offSubresource = pSurface->surfaceDesc.cbArrayElement * pImage->face + offMipLevel; 1516 1531 /** @todo Multisample? */ 1517 1532 return offSubresource; … … 1574 1589 uint32_t const cBlocksY = (clipBox.h + pSurface->cyBlock - 1) / pSurface->cyBlock; 1575 1590 1576 /** @todo Calculate offSubresource here, when pSurface will have cbArraySlice field. */1577 1591 pResult->offSubresource = vmsvga3dCalcSubresourceOffset(pThisCC, pImage); 1578 1592 pResult->offBox = (clipBox.x / pSurface->cxBlock) * pSurface->cbBlock … … 1582 1596 pResult->cbPitch = pMipLevel->cbSurfacePitch; 1583 1597 pResult->cyBlocks = cBlocksY; 1584 pResult->c Depth = clipBox.d;1598 pResult->cbDepthPitch = pMipLevel->cbSurfacePlane; 1585 1599 1586 1600 return VINF_SUCCESS; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r94265 r94377 58 58 * texture number of faces * array_size." 59 59 */ 60 uint32 cbArrayElement; /* Size of one array element. */ 60 61 uint32 bufferByteStride; 61 62 } VMSVGA3D_SURFACE_DESC; … … 74 75 SVGA3dSurfaceFormat format; 75 76 SVGA3dBox box; 76 uint32_t cbPixel; 77 uint32_t cbRowPitch; 78 uint32_t cbDepthPitch; 77 uint32_t cbBlock; /* Size of pixel block, usualy of 1 pixel for uncompressed formats. */ 78 uint32_t cbRow; /* Bytes per row. */ 79 uint32_t cbRowPitch; /* Bytes between rows. */ 80 uint32_t cRows; /* Number of rows. */ 81 uint32_t cbDepthPitch; /* Bytes between planes. */ 79 82 void *pvData; 80 83 } VMSVGA3D_MAPPED_SURFACE; … … 155 158 int32_t cbPitch; /* Bytes between rows. */ 156 159 uint32_t cyBlocks; /* Number of rows. */ 157 uint32_t c Depth; /* Number ofplanes. */160 uint32_t cbDepthPitch; /* Number of bytes between planes. */ 158 161 } VMSGA3D_BOX_DIMENSIONS; 159 162
Note:
See TracChangeset
for help on using the changeset viewer.