Changeset 82677 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jan 8, 2020 5:08:09 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r81210 r82677 76 76 * Defined Constants And Macros * 77 77 *********************************************************************************************************************************/ 78 /* 128 should be enough */ 79 #define VBOXVHWA_MAX_SURFACES 128 80 #define VBOXVHWA_MAX_WIDTH 4096 81 #define VBOXVHWA_MAX_HEIGHT 4096 82 78 83 #ifdef VBOXQGL_PROF_BASE 79 84 # ifdef VBOXQGL_DBG_SURF … … 313 318 #endif 314 319 315 VBoxVHWAHandleTable::VBoxVHWAHandleTable(uint32_t initialSize)316 { 317 m Table = new void*[initialSize];318 m emset(mTable, 0, initialSize*sizeof(void*));319 m cSize = initialSize;320 mcUsage = 0; 321 m Cursor = 1; /* 0 is treated as invalid */320 VBoxVHWAHandleTable::VBoxVHWAHandleTable(uint32_t maxSize) 321 : 322 mcSize(maxSize), 323 mcUsage(0), 324 mCursor(1) /* 0 is treated as invalid */ 325 { 326 mTable = (void **)RTMemAllocZ(sizeof(void *) * maxSize); 322 327 } 323 328 324 329 VBoxVHWAHandleTable::~VBoxVHWAHandleTable() 325 330 { 326 delete[] mTable;331 RTMemFree(mTable); 327 332 } 328 333 329 334 uint32_t VBoxVHWAHandleTable::put(void *data) 330 335 { 331 Assert(data); 332 if (!data) 333 return VBOXVHWA_SURFHANDLE_INVALID; 334 335 if (mcUsage == mcSize) 336 { 337 /** @todo resize */ 338 AssertFailed(); 339 } 340 341 Assert(mcUsage < mcSize); 342 if (mcUsage >= mcSize) 343 return VBOXVHWA_SURFHANDLE_INVALID; 336 AssertPtrReturn(data, VBOXVHWA_SURFHANDLE_INVALID); 337 AssertReturn(mcUsage < mcSize, VBOXVHWA_SURFHANDLE_INVALID); 344 338 345 339 for (int k = 0; k < 2; ++k) … … 362 356 } 363 357 364 bool VBoxVHWAHandleTable::mapPut(uint32_t h, void * data) 365 { 366 if (mcSize <= h) 367 return false; 368 if (h == 0) 369 return false; 358 bool VBoxVHWAHandleTable::mapPut(uint32_t h, void *data) 359 { 360 AssertReturn(h > 0 && h < mcSize, false); 361 RT_UNTRUSTED_VALIDATED_FENCE(); 370 362 if (mTable[h]) 371 363 return false; 372 373 364 doPut(h, data); 374 365 return true; 375 366 } 376 367 377 void * VBoxVHWAHandleTable::get(uint32_t h)378 { 379 Assert (h < mcSize);380 Assert(h > 0);368 void * VBoxVHWAHandleTable::get(uint32_t h) 369 { 370 AssertReturn(h > 0 && h < mcSize, NULL); 371 RT_UNTRUSTED_VALIDATED_FENCE(); 381 372 return mTable[h]; 382 373 } 383 374 384 void * VBoxVHWAHandleTable::remove(uint32_t h)375 void * VBoxVHWAHandleTable::remove(uint32_t h) 385 376 { 386 377 Assert(mcUsage); 387 Assert(h < mcSize); 388 void* val = mTable[h]; 378 AssertReturn(h > 0 && h < mcSize, NULL); 379 RT_UNTRUSTED_VALIDATED_FENCE(); 380 void *val = mTable[h]; 389 381 Assert(val); 390 382 if (val) … … 1491 1483 { 1492 1484 GLenum tt = texTarget(); 1485 QRect rect = mRect; 1493 1486 if (pRect) 1494 Assert(mRect.contains(*pRect)); 1495 else 1496 pRect = &mRect; 1487 rect = rect.intersected(*pRect); 1488 AssertReturnVoid(!rect.isEmpty()); 1497 1489 1498 1490 Assert(glIsTexture(mTexture)); … … 1501 1493 ); 1502 1494 1503 int x = pRect->x()/mColorFormat.widthCompression();1504 int y = pRect->y()/mColorFormat.heightCompression();1505 int width = pRect->width()/mColorFormat.widthCompression();1506 int height = pRect->height()/mColorFormat.heightCompression();1495 int x = rect.x()/mColorFormat.widthCompression(); 1496 int y = rect.y()/mColorFormat.heightCompression(); 1497 int width = rect.width()/mColorFormat.widthCompression(); 1498 int height = rect.height()/mColorFormat.heightCompression(); 1507 1499 1508 1500 uchar *address = pAddress + pointOffsetTex(x, y); … … 1668 1660 { 1669 1661 if (pRect) 1670 Assert (mRect.contains(*pRect));1662 AssertReturn(mRect.contains(*pRect), false); 1671 1663 1672 1664 if (mUpdateMem2TexRect.isClear()) … … 1865 1857 1866 1858 if (pRect) 1867 Assert (mRect.contains(*pRect));1859 AssertReturn(mRect.contains(*pRect), VERR_GENERAL_FAILURE); 1868 1860 1869 1861 Assert(mLockCount >= 0); … … 1877 1869 VBOXQGLLOG_METHODTIME("time "); 1878 1870 1879 mUpdateMem2TexRect.add(pRect ? *pRect: mRect);1871 mUpdateMem2TexRect.add(pRect ? mRect.intersected(*pRect) : mRect); 1880 1872 1881 1873 Assert(!mUpdateMem2TexRect.isClear()); … … 1894 1886 { 1895 1887 mTargRect = aTargRect; 1896 mSrcRect = aSrcRect;1888 mSrcRect = mRect.intersected(aSrcRect); 1897 1889 } 1898 1890 … … 1972 1964 void VBoxVHWASurfaceBase::updatedMem(const QRect *rec) 1973 1965 { 1974 if (rec) 1975 Assert(mRect.contains(*rec)); 1966 AssertReturnVoid(mRect.contains(*rec)); 1976 1967 mUpdateMem2TexRect.add(*rec); 1977 1968 } … … 2043 2034 } 2044 2035 2045 2046 2036 VBoxVHWAImage::VBoxVHWAImage () 2047 : mSurfHandleTable( 128) /* 128 should be enough */2037 : mSurfHandleTable(VBOXVHWA_MAX_SURFACES) 2048 2038 , mRepaintNeeded(false) 2049 2039 // , mbVGASurfCreated(false) … … 2194 2184 VBOXQGLLOG_ENTER(("\n")); 2195 2185 2186 if (pCmd->SurfInfo.width > VBOXVHWA_MAX_WIDTH || pCmd->SurfInfo.height > VBOXVHWA_MAX_HEIGHT) 2187 { 2188 AssertFailed(); 2189 pCmd->u.out.ErrInfo = -1; 2190 return VINF_SUCCESS; 2191 } 2192 2196 2193 const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(NULL); 2197 2194 … … 2292 2289 VBOXQGLLOG_ENTER (("\n")); 2293 2290 2294 uint32_t handle = VBOXVHWA_SURFHANDLE_INVALID; 2295 if (pCmd->SurfInfo.hSurf != VBOXVHWA_SURFHANDLE_INVALID) 2296 { 2297 handle = pCmd->SurfInfo.hSurf; 2291 uint32_t handle = pCmd->SurfInfo.hSurf; 2292 AssertReturn(handle == VBOXVHWA_SURFHANDLE_INVALID || handle < VBOXVHWA_MAX_SURFACES, VERR_GENERAL_FAILURE); 2293 RT_UNTRUSTED_VALIDATED_FENCE(); 2294 if (handle != VBOXVHWA_SURFHANDLE_INVALID) 2295 { 2298 2296 if (mSurfHandleTable.get(handle)) 2299 2297 { … … 2343 2341 VBoxVHWASurfaceBase *pVga = vgaSurface(); 2344 2342 #ifdef VBOX_WITH_WDDM 2345 uchar * addr = vboxVRAMAddressFromOffset(pCmd->SurfInfo.offSurface); 2346 Assert(addr); 2347 if (addr) 2348 { 2349 pVga->setAddress(addr); 2350 } 2343 uchar *addr = vboxVRAMAddressFromOffset(pCmd->SurfInfo.offSurface); 2344 AssertPtrReturn(addr, VERR_GENERAL_FAILURE); 2345 RT_UNTRUSTED_VALIDATED_FENCE(); 2346 pVga->setAddress(addr); 2351 2347 #endif 2352 2348 … … 2396 2392 if (!surf) 2397 2393 { 2394 ASSERT_GUEST_RETURN( pCmd->SurfInfo.width <= VBOXVHWA_MAX_WIDTH 2395 && pCmd->SurfInfo.height <= VBOXVHWA_MAX_HEIGHT, VERR_GENERAL_FAILURE); 2396 ASSERT_GUEST_RETURN(pCmd->SurfInfo.cBackBuffers < VBOXVHWA_MAX_SURFACES, VERR_GENERAL_FAILURE); 2397 RT_UNTRUSTED_VALIDATED_FENCE(); 2398 2398 2399 VBOXVHWAIMG_TYPE fFlags = 0; 2399 2400 if (!bNoPBO) … … 2441 2442 2442 2443 uchar *addr = vboxVRAMAddressFromOffset(pCmd->SurfInfo.offSurface); 2444 AssertReturn(addr || pCmd->SurfInfo.offSurface == VBOXVHWA_OFFSET64_VOID, VERR_GENERAL_FAILURE); 2443 2445 surf->init(mDisplay.getPrimary(), addr); 2444 2446 … … 2534 2536 int VBoxVHWAImage::vhwaSurfaceGetInfo(struct VBOXVHWACMD_SURF_GETINFO RT_UNTRUSTED_VOLATILE_GUEST *pCmd) 2535 2537 { 2538 ASSERT_GUEST_RETURN( pCmd->SurfInfo.width <= VBOXVHWA_MAX_WIDTH 2539 && pCmd->SurfInfo.height <= VBOXVHWA_MAX_HEIGHT, VERR_INVALID_PARAMETER); 2540 RT_UNTRUSTED_VALIDATED_FENCE(); 2536 2541 VBoxVHWAColorFormat format; 2537 2542 Assert(!format.isValid()); … … 2570 2575 { 2571 2576 Assert(pList); 2572 pList->remove(pSurf); 2573 if (pList->surfaces().empty()) 2574 { 2575 mDisplay.removeOverlay(pList); 2576 if (pList == mConstructingList) 2577 if (pList) 2578 { 2579 pList->remove(pSurf); 2580 if (pList->surfaces().empty()) 2577 2581 { 2578 mConstructingList = NULL; 2579 mcRemaining2Contruct = 0; 2582 mDisplay.removeOverlay(pList); 2583 if (pList == mConstructingList) 2584 { 2585 mConstructingList = NULL; 2586 mcRemaining2Contruct = 0; 2587 } 2588 delete pList; 2580 2589 } 2581 delete pList;2582 2590 } 2583 2591 … … 2586 2594 else 2587 2595 { 2588 Assert(pList); 2589 Assert(pList->size() >= 1); 2590 if (pList->size() > 1) 2596 Assert(pList && pList->size() >= 1); 2597 if (pList && pList->size() > 1) 2591 2598 { 2592 2599 if (pSurf == mDisplay.getVGA()) … … 2907 2914 if (pSrcSurf->getComplexList()->current() != NULL) 2908 2915 { 2909 Assert(pDstSurf);2910 2916 if (pDstSurf != mDisplay.getPrimary()) 2911 2917 { … … 3600 3606 uchar *VBoxVHWAImage::vboxVRAMAddressFromOffset(uint64_t offset) 3601 3607 { 3602 /** @todo check vramSize() */ 3603 return (offset != VBOXVHWA_OFFSET64_VOID) ? ((uint8_t *)vramBase()) + offset : NULL; 3608 if (offset == VBOXVHWA_OFFSET64_VOID) 3609 return NULL; 3610 AssertReturn(offset <= vramSize(), NULL); 3611 RT_UNTRUSTED_VALIDATED_FENCE(); 3612 return (uint8_t *)vramBase() + offset; 3604 3613 } 3605 3614 3606 3615 uint64_t VBoxVHWAImage::vboxVRAMOffsetFromAddress(uchar *addr) 3607 3616 { 3608 return uint64_t(addr - ((uchar *)vramBase())); 3617 AssertReturn((uintptr_t)addr >= (uintptr_t)vramBase(), VBOXVHWA_OFFSET64_VOID); 3618 uint64_t const offset = uint64_t((uintptr_t)addr - (uintptr_t)vramBase()); 3619 AssertReturn(offset <= vramSize(), VBOXVHWA_OFFSET64_VOID); 3620 return offset; 3609 3621 } 3610 3622 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.h
r78967 r82677 750 750 { 751 751 public: 752 VBoxVHWAHandleTable(uint32_t initialSize);752 VBoxVHWAHandleTable(uint32_t maxSize); 753 753 ~VBoxVHWAHandleTable(); 754 754 uint32_t put(void * data);
Note:
See TracChangeset
for help on using the changeset viewer.