Changeset 94232 in vbox for trunk/src/VBox
- Timestamp:
- Mar 15, 2022 8:47:10 AM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
r94223 r94232 1291 1291 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, 1292 1292 pCmd->multisampleCount, pCmd->autogenFilter, 1293 pCmd->face[0].numMipLevels, &paMipLevelSizes[0], /* fAllocMipLevels = */ true);1293 pCmd->face[0].numMipLevels, &paMipLevelSizes[0], /* arraySize = */ 0, /* fAllocMipLevels = */ true); 1294 1294 } 1295 1295 … … 1363 1363 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, 1364 1364 pCmd->multisampleCount, pCmd->autogenFilter, 1365 pCmd->numMipLevels, &pCmd->size, /* fAllocMipLevels = */ false);1365 pCmd->numMipLevels, &pCmd->size, /* arraySize = */ 0, /* fAllocMipLevels = */ false); 1366 1366 } 1367 1367 } … … 1660 1660 if (pMob) 1661 1661 { 1662 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 1663 ? SVGA3D_MAX_SURFACE_FACES 1664 : RT_MAX(entrySurface.arraySize, 1); 1662 uint32 const arraySize = vmsvga3dGetArrayElements(pThisCC, pCmd->sid); 1665 1663 for (uint32_t iArray = 0; iArray < arraySize; ++iArray) 1666 1664 { … … 1724 1722 if (pMob) 1725 1723 { 1726 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 1727 ? SVGA3D_MAX_SURFACE_FACES 1728 : RT_MAX(entrySurface.arraySize, 1); 1724 uint32 const arraySize = vmsvga3dGetArrayElements(pThisCC, pCmd->sid); 1729 1725 for (uint32_t iArray = 0; iArray < arraySize; ++iArray) 1730 1726 { … … 2015 2011 // entry.mobPitch = 0; 2016 2012 // ... 2017 Assert( pCmd->arraySize == 0 2018 || pCmd->arraySize == 1 2019 || (pCmd->arraySize == 6 && (pCmd->surfaceFlags & SVGA3D_SURFACE_CUBEMAP))); 2013 2020 2014 int rc = vmsvgaR3OTableWrite(pSvgaR3State, &pSvgaR3State->aGboOTables[SVGA_OTABLE_SURFACE], 2021 2015 pCmd->sid, SVGA3D_OTABLE_SURFACE_ENTRY_SIZE, &entry, sizeof(entry)); … … 2026 2020 vmsvga3dSurfaceDefine(pThisCC, pCmd->sid, pCmd->surfaceFlags, pCmd->format, 2027 2021 pCmd->multisampleCount, pCmd->autogenFilter, 2028 pCmd->numMipLevels, &pCmd->size, /* fAllocMipLevels = */ false);2022 pCmd->numMipLevels, &pCmd->size, pCmd->arraySize, /* fAllocMipLevels = */ false); 2029 2023 } 2030 2024 } … … 2764 2758 if (pMob) 2765 2759 { 2766 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 2767 ? SVGA3D_MAX_SURFACE_FACES 2768 : RT_MAX(entrySurface.arraySize, 1); 2769 ASSERT_GUEST_RETURN(pCmd->subResource < arraySize * entrySurface.numMipLevels, VERR_INVALID_PARAMETER); 2760 uint32 const cSubresource = vmsvga3dGetSubresourceCount(pThisCC, pCmd->sid); 2761 ASSERT_GUEST_RETURN(pCmd->subResource < cSubresource, VERR_INVALID_PARAMETER); 2770 2762 /* pCmd->box will be verified by the mapping function. */ 2771 2763 RT_UNTRUSTED_VALIDATED_FENCE(); … … 2809 2801 if (pMob) 2810 2802 { 2811 uint32 const arraySize = (entrySurface.surface1Flags & SVGA3D_SURFACE_CUBEMAP) 2812 ? SVGA3D_MAX_SURFACE_FACES 2813 : RT_MAX(entrySurface.arraySize, 1); 2814 ASSERT_GUEST_RETURN(pCmd->subResource < arraySize * entrySurface.numMipLevels, VERR_INVALID_PARAMETER); 2803 uint32 const cSubresource = vmsvga3dGetSubresourceCount(pThisCC, pCmd->sid); 2804 ASSERT_GUEST_RETURN(pCmd->subResource < cSubresource, VERR_INVALID_PARAMETER); 2815 2805 RT_UNTRUSTED_VALIDATED_FENCE(); 2816 2806 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-savedstate.cpp
r94215 r94232 64 64 entrySurface.multisampleCount, entrySurface.autogenFilter, 65 65 entrySurface.numMipLevels, &entrySurface.size, 66 entrySurface.arraySize, 66 67 /* fAllocMipLevels = */ true); 67 68 AssertRCReturn(rc, rc); … … 74 75 75 76 /* Load miplevels data to the surface buffers. */ 76 for (uint32_t j = 0; j < pSurface->cLevels * pSurface-> cFaces; j++)77 for (uint32_t j = 0; j < pSurface->cLevels * pSurface->surfaceDesc.numArrayElements; j++) 77 78 { 78 79 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[j]; … … 268 269 pHlp->pfnSSMPutU32(pSSM, pSurface->idAssociatedContext); 269 270 270 for (uint32_t iArray = 0; iArray < pSurface-> cFaces; ++iArray) /* Texture array index or face for cube textures */271 for (uint32_t iArray = 0; iArray < pSurface->surfaceDesc.numArrayElements; ++iArray) 271 272 { 272 273 for (uint32_t iMipmap = 0; iMipmap < pSurface->cLevels; ++iMipmap) -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-shader.cpp
r94146 r94232 2365 2365 } 2366 2366 2367 int DXShaderUpdateResourceTypes(DXShaderInfo const *pInfo, SVGA3dResourceType*paResourceType, uint32_t cResourceType)2367 int DXShaderUpdateResourceTypes(DXShaderInfo const *pInfo, VGPU10_RESOURCE_DIMENSION *paResourceType, uint32_t cResourceType) 2368 2368 { 2369 2369 for (uint32_t i = 0; i < pInfo->cDclResource; ++i) 2370 2370 { 2371 SVGA3dResourceType const resourceType = i < cResourceType ? paResourceType[i] : SVGA3D_RESOURCE_TEXTURE2D;2372 AssertContinue(resourceType < SVGA3D_RESOURCE_TYPE_MAX);2371 VGPU10_RESOURCE_DIMENSION const resourceType = i < cResourceType ? paResourceType[i] : VGPU10_RESOURCE_DIMENSION_TEXTURE2D; 2372 AssertContinue(resourceType <= VGPU10_RESOURCE_DIMENSION_TEXTURECUBEARRAY); 2373 2373 2374 2374 uint32_t const offToken = pInfo->aOffDclResource[i]; … … 2376 2376 uint32_t *paToken = (uint32_t *)((uintptr_t)pInfo->pvBytecode + offToken); 2377 2377 2378 uint8_t resourceDimension;2379 uint32_t returnType;2380 switch (resourceType)2381 {2382 case SVGA3D_RESOURCE_BUFFER:2383 resourceDimension = VGPU10_RESOURCE_DIMENSION_BUFFER;2384 returnType = 0x5555; /* float */2385 break;2386 case SVGA3D_RESOURCE_TEXTURE1D:2387 resourceDimension = VGPU10_RESOURCE_DIMENSION_TEXTURE1D;2388 returnType = 0x5555; /* float */2389 break;2390 default:2391 case SVGA3D_RESOURCE_TEXTURE2D:2392 resourceDimension = VGPU10_RESOURCE_DIMENSION_TEXTURE2D;2393 returnType = 0x5555; /* float */2394 break;2395 case SVGA3D_RESOURCE_TEXTURE3D:2396 resourceDimension = VGPU10_RESOURCE_DIMENSION_TEXTURE3D;2397 returnType = 0x5555; /* float */2398 break;2399 case SVGA3D_RESOURCE_TEXTURECUBE:2400 resourceDimension = VGPU10_RESOURCE_DIMENSION_TEXTURECUBE;2401 returnType = 0x5555; /* float */2402 break;2403 case SVGA3D_RESOURCE_BUFFEREX:2404 resourceDimension = VGPU10_RESOURCE_DIMENSION_BUFFER;2405 returnType = 0x5555; /* float */2406 break;2407 }2408 2409 2378 VGPU10OpcodeToken0 *pOpcode = (VGPU10OpcodeToken0 *)&paToken[0]; 2410 pOpcode->resourceDimension = resource Dimension;2379 pOpcode->resourceDimension = resourceType; 2411 2380 // paToken[1] unmodified 2412 2381 // paToken[2] unmodified 2413 paToken[3] = returnType;2382 paToken[3] = 0x5555; /* float */; 2414 2383 } 2415 2384 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-shader.h
r94146 r94232 52 52 int DXShaderParse(void const *pvCode, uint32_t cbCode, DXShaderInfo *pInfo); 53 53 void DXShaderFree(DXShaderInfo *pInfo); 54 int DXShaderUpdateResourceTypes(DXShaderInfo const *pInfo, SVGA3dResourceType*paResourceType, uint32_t cResourceType);54 int DXShaderUpdateResourceTypes(DXShaderInfo const *pInfo, VGPU10_RESOURCE_DIMENSION *paResourceType, uint32_t cResourceType); 55 55 int DXShaderCreateDXBC(DXShaderInfo const *pInfo, void **ppvDXBC, uint32_t *pcbDXBC); 56 56 char const *DXShaderGetOutputSemanticName(DXShaderInfo const *pInfo, uint32_t idxRegister); -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r94146 r94232 553 553 uint32_t idAssociatedContext; 554 554 555 /** @todo Only numArrayElements field is used currently. The code uses old fields cLevels, etc for anything else. */ 556 VMSVGA3D_SURFACE_DESC surfaceDesc; 557 555 558 SVGA3dSurface1Flags surfaceFlags; /** @todo SVGA3dSurfaceAllFlags as an union. */ 556 559 SVGA3dSurfaceFormat format; … … 574 577 uint32_t cFaces; /* Number of faces: 6 for cubemaps, 1 for everything else. */ 575 578 uint32_t cLevels; /* Number of mipmap levels per face. */ 576 PVMSVGA3DMIPMAPLEVEL paMipmapLevels; /* cFaces * cLevels elements. */579 PVMSVGA3DMIPMAPLEVEL paMipmapLevels; /* surfaceDesc.numArrayElements * cLevels elements. */ 577 580 uint32_t multiSampleCount; 578 581 SVGA3dTextureFilter autogenFilter; … … 1333 1336 } 1334 1337 1335 DECLINLINE(int) vmsvga3dMipmapLevel(PVMSVGA3DSURFACE pSurface, uint32_t face, uint32_t mipmap,1338 DECLINLINE(int) vmsvga3dMipmapLevel(PVMSVGA3DSURFACE pSurface, uint32_t iArrayElement, uint32_t mipmap, 1336 1339 PVMSVGA3DMIPMAPLEVEL *ppMipmapLevel) 1337 1340 { 1338 AssertMsgReturn( face < pSurface->cFaces,1339 (" cFaces %d, face %d\n", pSurface->cFaces, face),1341 AssertMsgReturn(iArrayElement < pSurface->surfaceDesc.numArrayElements, 1342 ("numArrayElements %d, iArrayElement %d\n", pSurface->surfaceDesc.numArrayElements, iArrayElement), 1340 1343 VERR_INVALID_PARAMETER); 1341 1344 AssertMsgReturn(mipmap < pSurface->cLevels, … … 1343 1346 VERR_INVALID_PARAMETER); 1344 1347 1345 *ppMipmapLevel = &pSurface->paMipmapLevels[ face* pSurface->cLevels + mipmap];1348 *ppMipmapLevel = &pSurface->paMipmapLevels[iArrayElement * pSurface->cLevels + mipmap]; 1346 1349 return VINF_SUCCESS; 1347 1350 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-savedstate.cpp
r93115 r94232 497 497 498 498 rc = vmsvga3dSurfaceDefine(pThisCC, sid, surface.surfaceFlags, surface.format, surface.multiSampleCount, 499 surface.autogenFilter, surface.cLevels, &pMipmapLevelSize[0], /* fAllocMipLevels = */ true);499 surface.autogenFilter, surface.cLevels, &pMipmapLevelSize[0], /* arraySize = */ 0, /* fAllocMipLevels = */ true); 500 500 AssertRCReturn(rc, rc); 501 501 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
r94227 r94232 1416 1416 break; 1417 1417 case SVGA3D_RESOURCE_TEXTURE1D: 1418 if (p Entry->desc.tex.arraySize<= 1)1418 if (pSurface->surfaceDesc.numArrayElements <= 1) 1419 1419 { 1420 1420 desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D; … … 1430 1430 break; 1431 1431 case SVGA3D_RESOURCE_TEXTURE2D: 1432 if (p Entry->desc.tex.arraySize<= 1)1432 if (pSurface->surfaceDesc.numArrayElements <= 1) 1433 1433 { 1434 1434 desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; … … 1491 1491 break; 1492 1492 case SVGA3D_RESOURCE_TEXTURE1D: 1493 if (p Entry->desc.tex.arraySize<= 1)1493 if (pSurface->surfaceDesc.numArrayElements <= 1) 1494 1494 { 1495 1495 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; … … 1507 1507 break; 1508 1508 case SVGA3D_RESOURCE_TEXTURE2D: 1509 if (p Entry->desc.tex.arraySize<= 1)1509 if (pSurface->surfaceDesc.numArrayElements <= 1) 1510 1510 { 1511 1511 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; … … 1528 1528 break; 1529 1529 case SVGA3D_RESOURCE_TEXTURECUBE: 1530 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; 1531 desc.TextureCube.MostDetailedMip = pEntry->desc.tex.mostDetailedMip; 1532 desc.TextureCube.MipLevels = pEntry->desc.tex.mipLevels; 1530 if (pSurface->surfaceDesc.numArrayElements <= 6) 1531 { 1532 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; 1533 desc.TextureCube.MostDetailedMip = pEntry->desc.tex.mostDetailedMip; 1534 desc.TextureCube.MipLevels = pEntry->desc.tex.mipLevels; 1535 } 1536 else 1537 { 1538 desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY; 1539 desc.TextureCubeArray.MostDetailedMip = pEntry->desc.tex.mostDetailedMip; 1540 desc.TextureCubeArray.MipLevels = pEntry->desc.tex.mipLevels; 1541 desc.TextureCubeArray.First2DArrayFace = pEntry->desc.tex.firstArraySlice; 1542 desc.TextureCubeArray.NumCubes = pEntry->desc.tex.arraySize / 6; 1543 } 1533 1544 break; 1534 1545 case SVGA3D_RESOURCE_BUFFEREX: … … 1563 1574 { 1564 1575 case SVGA3D_RESOURCE_TEXTURE1D: 1565 if (p Entry->arraySize<= 1)1576 if (pSurface->surfaceDesc.numArrayElements <= 1) 1566 1577 { 1567 1578 desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE1D; … … 1577 1588 break; 1578 1589 case SVGA3D_RESOURCE_TEXTURE2D: 1579 if (p Entry->arraySize<= 1)1590 if (pSurface->surfaceDesc.numArrayElements <= 1) 1580 1591 { 1581 1592 desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; … … 2019 2030 /** @todo Can happen for a non GBO surface or if GBO texture was updated prior to creation if the hardware resource. Test this. */ 2020 2031 /** @todo for (i = 0; i < pSurface->cFaces * numMipLevels; ++i) */ 2021 for (uint32_t i Face = 0; iFace < 6; ++iFace)2032 for (uint32_t iArray = 0; iArray < pSurface->surfaceDesc.numArrayElements; ++iArray) 2022 2033 { 2023 2034 for (uint32_t i = 0; i < numMipLevels; ++i) 2024 2035 { 2025 uint32_t const iSubresource = vmsvga3dCalcSubresource(i, i Face, numMipLevels);2036 uint32_t const iSubresource = vmsvga3dCalcSubresource(i, iArray, numMipLevels); 2026 2037 2027 2038 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[iSubresource]; … … 2040 2051 td.Height = cHeight; 2041 2052 td.MipLevels = numMipLevels; 2042 td.ArraySize = 6;2053 td.ArraySize = pSurface->surfaceDesc.numArrayElements; /* This is 6 * numCubes */ 2043 2054 td.Format = dxgiFormat; 2044 2055 td.SampleDesc.Count = 1; … … 2216 2227 td.Height = cHeight; 2217 2228 td.MipLevels = numMipLevels; 2218 td.ArraySize = 1; /** @todo */2229 td.ArraySize = pSurface->surfaceDesc.numArrayElements; 2219 2230 td.Format = dxgiFormat; 2220 2231 td.SampleDesc.Count = 1; … … 2234 2245 /* Map-able texture. */ 2235 2246 td.MipLevels = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 2247 td.ArraySize = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 2236 2248 td.Usage = D3D11_USAGE_DYNAMIC; 2237 2249 td.BindFlags = D3D11_BIND_SHADER_RESOURCE; /* Have to specify a supported flag, otherwise E_INVALIDARG will be returned. */ … … 2349 2361 /** @todo Can happen for a non GBO surface or if GBO texture was updated prior to creation if the hardware resource. Test this. */ 2350 2362 /** @todo for (i = 0; i < pSurface->cFaces * numMipLevels; ++i) */ 2351 for (uint32_t i Face = 0; iFace < 6; ++iFace)2363 for (uint32_t iArray = 0; iArray < pSurface->surfaceDesc.numArrayElements; ++iArray) 2352 2364 { 2353 2365 for (uint32_t i = 0; i < numMipLevels; ++i) 2354 2366 { 2355 uint32_t const iSubresource = vmsvga3dCalcSubresource(i, i Face, numMipLevels);2367 uint32_t const iSubresource = vmsvga3dCalcSubresource(i, iArray, numMipLevels); 2356 2368 2357 2369 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[iSubresource]; … … 2370 2382 td.Height = cHeight; 2371 2383 td.MipLevels = 1; 2372 td.ArraySize = 6;2384 td.ArraySize = pSurface->surfaceDesc.numArrayElements; 2373 2385 td.Format = dxgiFormat; 2374 2386 td.SampleDesc.Count = 1; … … 2451 2463 td.Height = cHeight; 2452 2464 td.MipLevels = 1; 2453 td.ArraySize = 1;2465 td.ArraySize = pSurface->surfaceDesc.numArrayElements; 2454 2466 td.Format = dxgiFormat; 2455 2467 td.SampleDesc.Count = 1; … … 2466 2478 /* Map-able texture. */ 2467 2479 td.MipLevels = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 2480 td.ArraySize = 1; /* Must be for D3D11_USAGE_DYNAMIC. */ 2468 2481 td.Usage = D3D11_USAGE_DYNAMIC; 2469 2482 td.BindFlags = D3D11_BIND_SHADER_RESOURCE; /* Have to specify a supported flag, otherwise E_INVALIDARG will be returned. */ … … 5239 5252 5240 5253 pInitialData = &initialData; 5254 5255 // Log(("%.*Rhxd\n", sizeInBytes, initialData.pSysMem)); 5241 5256 } 5242 5257 … … 5504 5519 if (shaderType == SVGA3D_SHADERTYPE_PS) 5505 5520 { 5506 SVGA3dResourceTypeaResourceType[SVGA3D_DX_MAX_SRVIEWS];5521 VGPU10_RESOURCE_DIMENSION aResourceType[SVGA3D_DX_MAX_SRVIEWS]; 5507 5522 RT_ZERO(aResourceType); 5508 5523 uint32_t cResourceType = 0; … … 5516 5531 AssertContinue(pSRViewEntry != NULL); 5517 5532 5518 aResourceType[idxSR] = pSRViewEntry->resourceDimension; 5533 PVMSVGA3DSURFACE pSurface; 5534 rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, pSRViewEntry->sid, &pSurface); 5535 AssertRCReturnVoid(rc); 5536 5537 switch (pSRViewEntry->resourceDimension) 5538 { 5539 case SVGA3D_RESOURCE_BUFFEREX: 5540 case SVGA3D_RESOURCE_BUFFER: 5541 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_BUFFER; 5542 break; 5543 case SVGA3D_RESOURCE_TEXTURE1D: 5544 if (pSurface->surfaceDesc.numArrayElements <= 1) 5545 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURE1D; 5546 else 5547 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURE1DARRAY; 5548 break; 5549 case SVGA3D_RESOURCE_TEXTURE2D: 5550 if (pSurface->surfaceDesc.numArrayElements <= 1) 5551 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURE2D; 5552 else 5553 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURE2DARRAY; 5554 break; 5555 case SVGA3D_RESOURCE_TEXTURE3D: 5556 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURE3D; 5557 break; 5558 case SVGA3D_RESOURCE_TEXTURECUBE: 5559 if (pSurface->surfaceDesc.numArrayElements <= 6) 5560 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURECUBE; 5561 else 5562 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURECUBEARRAY; 5563 break; 5564 default: 5565 ASSERT_GUEST_FAILED(); 5566 aResourceType[idxSR] = VGPU10_RESOURCE_DIMENSION_TEXTURE2D; 5567 } 5568 5519 5569 cResourceType = idxSR + 1; 5520 5570 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r94063 r94232 2749 2749 2750 2750 rc = vmsvga3dSurfaceDefine(pThisCC, sid, surfaceFlags, format, multisampleCount, autogenFilter, 2751 cMipLevels, &pMipLevelSize[0], /* fAllocMipLevels = */ true);2751 cMipLevels, &pMipLevelSize[0], /* arraySize = */ 0, /* fAllocMipLevels = */ true); 2752 2752 AssertRC(rc); 2753 2753 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r94223 r94232 45 45 { 46 46 /* Allocate buffer to hold the surface data until we can move it into a D3D object */ 47 for (uint32_t i = 0; i < pSurface->cLevels * pSurface-> cFaces; ++i)47 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->surfaceDesc.numArrayElements; ++i) 48 48 { 49 49 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; … … 58 58 static void vmsvga3dSurfaceFreeMipLevels(PVMSVGA3DSURFACE pSurface) 59 59 { 60 for (uint32_t i = 0; i < pSurface->cLevels * pSurface-> cFaces; ++i)60 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->surfaceDesc.numArrayElements; ++i) 61 61 { 62 62 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; … … 84 84 int vmsvga3dSurfaceDefine(PVGASTATECC pThisCC, uint32_t sid, SVGA3dSurface1Flags surfaceFlags, SVGA3dSurfaceFormat format, 85 85 uint32_t multisampleCount, SVGA3dTextureFilter autogenFilter, 86 uint32_t numMipLevels, SVGA3dSize const *pMipLevel0Size, bool fAllocMipLevels)86 uint32_t numMipLevels, SVGA3dSize const *pMipLevel0Size, uint32_t arraySize, bool fAllocMipLevels) 87 87 { 88 88 PVMSVGA3DSURFACE pSurface; … … 95 95 96 96 ASSERT_GUEST_RETURN(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER); 97 ASSERT_GUEST_RETURN(numMipLevels >= 1 && numMipLevels < SVGA3D_MAX_MIP_LEVELS, VERR_INVALID_PARAMETER); 97 ASSERT_GUEST_RETURN(numMipLevels >= 1 && numMipLevels <= SVGA3D_MAX_MIP_LEVELS, VERR_INVALID_PARAMETER); 98 ASSERT_GUEST_RETURN(arraySize <= SVGA3D_MAX_SURFACE_ARRAYSIZE, VERR_INVALID_PARAMETER); 98 99 99 100 if (sid >= pState->cSurfaces) … … 122 123 pSurface->id = SVGA3D_INVALID_ID; /* Keep this value until the surface init completes */ 123 124 pSurface->idAssociatedContext = SVGA3D_INVALID_ID; 125 126 if (arraySize) 127 pSurface->surfaceDesc.numArrayElements = arraySize; /* Also for an array of cubemaps where arraySize = 6 * numCubes. */ 128 else if (surfaceFlags & SVGA3D_SURFACE_CUBEMAP) 129 pSurface->surfaceDesc.numArrayElements = SVGA3D_MAX_SURFACE_FACES; 130 else 131 pSurface->surfaceDesc.numArrayElements = 1; 124 132 125 133 /** @todo This 'switch' and the surfaceFlags tweaks should not be necessary. … … 214 222 Assert(autogenFilter != SVGA3D_TEX_FILTER_FLATCUBIC); 215 223 Assert(autogenFilter != SVGA3D_TEX_FILTER_GAUSSIANCUBIC); 216 pSurface->paMipmapLevels = (PVMSVGA3DMIPMAPLEVEL)RTMemAllocZ(numMipLevels * pSurface-> cFaces * sizeof(VMSVGA3DMIPMAPLEVEL));224 pSurface->paMipmapLevels = (PVMSVGA3DMIPMAPLEVEL)RTMemAllocZ(numMipLevels * pSurface->surfaceDesc.numArrayElements * sizeof(VMSVGA3DMIPMAPLEVEL)); 217 225 AssertReturn(pSurface->paMipmapLevels, VERR_NO_MEMORY); 218 226 … … 227 235 for (uint32_t i = 0; i < numMipLevels; ++i) 228 236 { 229 for (uint32_t i Face = 0; iFace < pSurface->cFaces; ++iFace)230 { 231 uint32_t const iMipmap = iFace * numMipLevels + i;232 LogFunc(("[%d] face%d mip level %d (%d,%d,%d) cbBlock=%#x block %dx%d\n",233 iMipmap, i Face, i, mipmapSize.width, mipmapSize.height, mipmapSize.depth,237 for (uint32_t iArray = 0; iArray < pSurface->surfaceDesc.numArrayElements; ++iArray) 238 { 239 uint32_t const iMipmap = vmsvga3dCalcSubresource(i, iArray, numMipLevels); 240 LogFunc(("[%d] array %d mip level %d (%d,%d,%d) cbBlock=%#x block %dx%d\n", 241 iMipmap, iArray, i, mipmapSize.width, mipmapSize.height, mipmapSize.depth, 234 242 pSurface->cbBlock, pSurface->cxBlock, pSurface->cyBlock)); 235 243 … … 1136 1144 pSvgaR3State->pFuncs3D->pfnSurfaceDestroy(pThisCC, pSurface); 1137 1145 1138 for (uint32_t i = 0; i < pSurface->cLevels * pSurface-> cFaces; ++i)1146 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->surfaceDesc.numArrayElements; ++i) 1139 1147 { 1140 1148 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i]; … … 1434 1442 pMap->cbDepthPitch = pMipLevel->cbSurfacePlane; 1435 1443 pMap->pvData = (uint8_t *)pMipLevel->pSurfaceData 1436 + pMap->box.x* pMap->cbPixel1437 + pMap->box.y* pMap->cbRowPitch1444 + (pMap->box.x / pSurface->cxBlock) * pMap->cbPixel 1445 + (pMap->box.y / pSurface->cyBlock) * pMap->cbRowPitch 1438 1446 + pMap->box.z * pMap->cbDepthPitch; 1439 1447 1448 LogFunc(("SysMem: pvData %p\n", pMap->pvData)); 1440 1449 return VINF_SUCCESS; 1441 1450 } … … 1506 1515 /** @todo Multisample? */ 1507 1516 return offSubresource; 1517 } 1518 1519 1520 uint32_t vmsvga3dGetArrayElements(PVGASTATECC pThisCC, SVGA3dSurfaceId sid) 1521 { 1522 PVMSVGA3DSURFACE pSurface; 1523 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, sid, &pSurface); 1524 AssertRCReturn(rc, 0); 1525 1526 return pSurface->surfaceDesc.numArrayElements; 1527 } 1528 1529 1530 uint32_t vmsvga3dGetSubresourceCount(PVGASTATECC pThisCC, SVGA3dSurfaceId sid) 1531 { 1532 PVMSVGA3DSURFACE pSurface; 1533 int rc = vmsvga3dSurfaceFromSid(pThisCC->svga.p3dState, sid, &pSurface); 1534 AssertRCReturn(rc, 0); 1535 1536 return pSurface->surfaceDesc.numArrayElements * pSurface->cLevels; 1508 1537 } 1509 1538 -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r94223 r94232 42 42 43 43 44 /** @todo Use this as a parameter for vmsvga3dSurfaceDefine and a field in VMSVGA3DSURFACE instead of a multiple values. */ 45 /* A surface description provided by the guest. Mostly mirrors SVGA3dCmdDefineGBSurface_v4 */ 46 typedef struct VMSVGA3D_SURFACE_DESC 47 { 48 SVGA3dSurface1Flags surface1Flags; 49 SVGA3dSurface2Flags surface2Flags; 50 SVGA3dSurfaceFormat format; 51 uint32 numMipLevels; 52 uint32 multisampleCount; 53 SVGA3dMSPattern multisamplePattern; 54 SVGA3dMSQualityLevel qualityLevel; 55 SVGA3dTextureFilter autogenFilter; 56 SVGA3dSize size; 57 uint32 numArrayElements; /* "Number of array elements for a 1D/2D texture. For cubemap 58 * texture number of faces * array_size." 59 */ 60 uint32 bufferByteStride; 61 } VMSVGA3D_SURFACE_DESC; 62 44 63 typedef enum VMSVGA3D_SURFACE_MAP 45 64 { … … 77 96 int vmsvga3dSurfaceDefine(PVGASTATECC pThisCC, uint32_t sid, SVGA3dSurface1Flags surfaceFlags, SVGA3dSurfaceFormat format, 78 97 uint32_t multisampleCount, SVGA3dTextureFilter autogenFilter, 79 uint32_t cMipLevels, SVGA3dSize const *pMipLevel0Size, bool fAllocMipLevels);98 uint32_t cMipLevels, SVGA3dSize const *pMipLevel0Size, uint32_t arraySize, bool fAllocMipLevels); 80 99 int vmsvga3dSurfaceDestroy(PVGASTATECC pThisCC, uint32_t sid); 81 100 int vmsvga3dSurfaceCopy(PVGASTATECC pThisCC, SVGA3dSurfaceImageId dest, SVGA3dSurfaceImageId src, … … 149 168 } 150 169 151 DECLINLINE(uint32_t) vmsvga3dCalcSubresource(uint32_t iMipLevel, uint32_t iFace, uint32_t cMipLevels) 170 uint32_t vmsvga3dGetArrayElements(PVGASTATECC pThisCC, SVGA3dSurfaceId sid); 171 uint32_t vmsvga3dGetSubresourceCount(PVGASTATECC pThisCC, SVGA3dSurfaceId sid); 172 173 DECLINLINE(uint32_t) vmsvga3dCalcSubresource(uint32_t iMipLevel, uint32_t iArray, uint32_t cMipLevels) 152 174 { 153 175 /* Same as in D3D */ 154 return iMipLevel + i Face* cMipLevels;176 return iMipLevel + iArray * cMipLevels; 155 177 } 156 178
Note:
See TracChangeset
for help on using the changeset viewer.