- Timestamp:
- Mar 14, 2022 1:09:42 PM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 4 edited
-
DevVGA-SVGA-cmd.cpp (modified) (2 diffs)
-
DevVGA-SVGA3d-win-dx.cpp (modified) (4 diffs)
-
DevVGA-SVGA3d.cpp (modified) (1 diff)
-
DevVGA-SVGA3d.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA-cmd.cpp
r94205 r94223 1415 1415 1416 1416 1417 typedef union 1418 { 1419 float f; 1420 uint32_t u; 1421 } Unsigned2Float; 1422 1423 float float16ToFloat(uint16_t f16) 1424 { 1425 /* Format specs from Wiki: [15] = sign, [14:10] = exponent, [9:0] = fraction */ 1426 uint16_t const f = f16 & 0x3FF; 1427 uint16_t const e = (f16 >> 10) & 0x1F; 1428 uint16_t const s = (f16 >> 15) & 0x1; 1429 Unsigned2Float u2f; 1430 1431 if (e == 0) 1432 { 1433 if (f == 0) 1434 { 1435 /* zero, -0 */ 1436 u2f.u = (s << 31) | (0 << 23) | 0; 1437 return u2f.f; 1438 } 1439 1440 /* subnormal numbers: (-1)^signbit * 2^-14 * 0.significantbits */ 1441 float const k = 1.0f / 16384.0f; /* 2^-14 */ 1442 return (s ? -1.0f : 1.0f) * k * (float)f / 1024.0f; 1443 } 1444 1445 if (e == 31) 1446 { 1447 if (f == 0) 1448 { 1449 /* +-infinity */ 1450 u2f.u = (s << 31) | (0xFF << 23) | 0; 1451 return u2f.f; 1452 } 1453 1454 /* NaN */ 1455 u2f.u = (s << 31) | (0xFF << 23) | 1; 1456 return u2f.f; 1457 } 1458 1459 /* normalized value: (-1)^signbit * 2^(exponent - 15) * 1.significantbits */ 1460 /* Build the float, adjusting for exponent bias (float32 bias is 127, float16 is 15) 1461 * and number of bits in the fraction (float32 has 23, float16 has 10). */ 1462 u2f.u = (s << 31) | ((e + 127 - 15) << 23) | (f << (23 - 10)); 1463 return u2f.f; 1464 } 1465 1466 1417 1467 static int vmsvga3dBmpWrite(const char *pszFilename, VMSVGA3D_MAPPED_SURFACE const *pMap) 1418 1468 { 1419 if (pMap->cbPixel != 4 )1469 if (pMap->cbPixel != 4 && pMap->format != SVGA3D_R16G16B16A16_FLOAT) 1420 1470 return VERR_NOT_SUPPORTED; 1421 1471 … … 1455 1505 { 1456 1506 fwrite(s, 1, w * pMap->cbPixel, f); 1507 1508 s += pMap->cbRowPitch; 1509 } 1510 } 1511 else if (pMap->format == SVGA3D_R16G16B16A16_FLOAT) 1512 { 1513 const uint8_t *s = (uint8_t *)pMap->pvData; 1514 for (int32_t y = 0; y < h; ++y) 1515 { 1516 for (int32_t x = 0; x < w; ++x) 1517 { 1518 uint16_t const *pu16Pixel = (uint16_t *)(s + x * 8); 1519 uint8_t r = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[0])); 1520 uint8_t g = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[1])); 1521 uint8_t b = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[2])); 1522 uint8_t a = (uint8_t)(255.0 * float16ToFloat(pu16Pixel[3])); 1523 uint32_t u32Pixel = b + (g << 8) + (r << 16) + (a << 24); 1524 fwrite(&u32Pixel, 1, 4, f); 1525 } 1457 1526 1458 1527 s += pMap->cbRowPitch; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win-dx.cpp
r94215 r94223 3240 3240 { 3241 3241 pMap->enmMapType = enmMapType; 3242 pMap->format = pSurface->format; 3242 3243 pMap->box = clipBox; 3243 3244 pMap->cbPixel = pSurface->cbBlock; … … 3313 3314 { 3314 3315 pMap->enmMapType = enmMapType; 3316 pMap->format = pSurface->format; 3315 3317 pMap->box = clipBox; 3316 3318 pMap->cbPixel = pSurface->cbBlock; … … 3362 3364 { 3363 3365 pMap->enmMapType = enmMapType; 3366 pMap->format = pSurface->format; 3364 3367 pMap->box = clipBox; 3365 3368 pMap->cbPixel = pSurface->cbBlock; … … 5389 5392 5390 5393 LogFunc(("srv[%d][%d] sid = %u, srvid = %u\n", idxShaderState, idxSR, sid, shaderResourceViewId)); 5394 5395 #ifdef DUMP_BITMAPS 5396 SVGA3dSurfaceImageId image; 5397 image.sid = sid; 5398 image.face = 0; 5399 image.mipmap = 0; 5400 VMSVGA3D_MAPPED_SURFACE map; 5401 int rc2 = vmsvga3dSurfaceMap(pThisCC, &image, NULL, VMSVGA3D_SURFACE_MAP_READ, &map); 5402 if (RT_SUCCESS(rc2)) 5403 { 5404 vmsvga3dMapWriteBmpFile(&map, "sr-"); 5405 vmsvga3dSurfaceUnmap(pThisCC, &image, &map, /* fWritten = */ false); 5406 } 5407 else 5408 Log(("Map failed %Rrc\n", rc)); 5409 #endif 5391 5410 } 5392 5411 } -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp
r94063 r94223 1428 1428 1429 1429 pMap->enmMapType = enmMapType; 1430 pMap->format = pSurface->format; 1430 1431 pMap->box = clipBox; 1431 1432 pMap->cbPixel = pSurface->cbBlock; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h
r94205 r94223 53 53 { 54 54 VMSVGA3D_SURFACE_MAP enmMapType; 55 SVGA3dSurfaceFormat format; 55 56 SVGA3dBox box; 56 57 uint32_t cbPixel;
Note:
See TracChangeset
for help on using the changeset viewer.

