mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix ToRGB/ToRGBA possible accuracy loss.
It was always like this, but not used as much before. Shifts are fast and it eneds to sum anyway, there should not be any benefit to multiplying as floats, and it will probably lose accuracy.
This commit is contained in:
parent
44e9484942
commit
a8a299c2e3
1 changed files with 7 additions and 7 deletions
14
GPU/Math3D.h
14
GPU/Math3D.h
|
@ -927,9 +927,9 @@ inline unsigned int Vec3<float>::ToRGB() const
|
|||
__m128i c16 = _mm_packs_epi32(c, c);
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(c16, c16)) & 0x00FFFFFF;
|
||||
#else
|
||||
return ((unsigned int)(r()*255.f)) +
|
||||
((unsigned int)(g()*255.f*256.f)) +
|
||||
((unsigned int)(b()*255.f*256.f*256.f));
|
||||
return ((unsigned int)(r()*255.f) << 0) |
|
||||
((unsigned int)(g()*255.f) << 8) |
|
||||
((unsigned int)(b()*255.f) << 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -981,10 +981,10 @@ inline unsigned int Vec4<float>::ToRGBA() const
|
|||
__m128i c16 = _mm_packs_epi32(c, c);
|
||||
return _mm_cvtsi128_si32(_mm_packus_epi16(c16, c16));
|
||||
#else
|
||||
return ((unsigned int)(r()*255.f)) +
|
||||
((unsigned int)(g()*255.f*256.f)) +
|
||||
((unsigned int)(b()*255.f*256.f*256.f)) +
|
||||
((unsigned int)(a()*255.f*256.f*256.f*256.f));
|
||||
return ((unsigned int)(r()*255.f) << 0) |
|
||||
((unsigned int)(g()*255.f) << 8) |
|
||||
((unsigned int)(b()*255.f) << 16) |
|
||||
((unsigned int)(a()*255.f) << 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue