microsoft / DirectXMath

DirectXMath is an all inline SIMD C++ linear algebra library for use in games and graphics apps
https://walbourn.github.io/introducing-directxmath/
MIT License
1.52k stars 234 forks source link

DirectXTex converts floating point numbers to integers by different way between BC4 and BC5. #105

Closed yosshin4004 closed 4 years ago

yosshin4004 commented 4 years ago

DirectXTex converts floating point numbers to integers by different way between BC4 and BC5. Is this correct behaviour?

    float v = XMVectorGetX(*sPtr++);
    v = std::max<float>(std::min<float>(v, 1.f), -1.f);
    *(dPtr++) = static_cast<int8_t>(v * 127.f);
    // Clamp to bounds
    XMVECTOR vResult = _mm_max_ps(V,g_XMNegativeOne);
    vResult = _mm_min_ps(vResult,g_XMOne);
    // Scale by multiplication
    vResult = _mm_mul_ps(vResult,g_ByteMax);
    // Convert to int by rounding
    __m128i vInt = _mm_cvtps_epi32(vResult);
yosshin4004 commented 4 years ago

Sorry, I sent it by mistake. This issue is for DirectXTex.