MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / MapToF16

Function MapToF16

cmp_compressonatorlib/bc6h/bc6h_encode.cpp:1488–1529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1486#endif
1487
1488static float MapToF16(float f, bool isSigned)
1489{
1490 const float normalization = 1.0; // For future use
1491
1492 float result = 0.0f;
1493
1494 // negative infinity for signed formats
1495 if (isSigned && cmp_isinf(f) && f < 0.0f)
1496 {
1497 result = F16_MAX_NEGATIVE_BITS;
1498 }
1499 // positive infinity
1500 else if (cmp_isinf(f) && f > 0.0f)
1501 {
1502 result = F16_MAX_BITS;
1503 }
1504 // NaN, or negative infinity for non-signed formats
1505 else if (cmp_isnan(f) || cmp_isinf(f))
1506 {
1507 result = 0.0f;
1508 }
1509 // signed number is very close to zero
1510 else if (isSigned && f > -0.00001f && f < 0.00001f)
1511 {
1512 result = 0.0f;
1513 }
1514 // non-signed number is negative or very close to zero
1515 else if (!isSigned && f < 0.00001f)
1516 {
1517 result = 0.0f;
1518 }
1519 else if (isSigned && f < 0.0f)
1520 {
1521 result = -CMP_HALF(abs(f / normalization)).bits();
1522 }
1523 else
1524 {
1525 result = CMP_HALF(f / normalization).bits();
1526 }
1527
1528 return result;
1529}
1530
1531float BC6HBlockEncoder::CompressBlock(float in[MAX_SUBSET_SIZE][MAX_DIMENSION_BIG], BYTE out[COMPRESSED_BLOCK_SIZE])
1532{

Callers 1

CompressBlockMethod · 0.85

Calls 2

absFunction · 0.85
bitsMethod · 0.80

Tested by

no test coverage detected