mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-28 12:40:12 +00:00
RSX: Returns texture bias as a float, considering the stored value is a half float.
This commit is contained in:
parent
9f49232cac
commit
8afa6e59b2
@ -26,6 +26,21 @@ union alignas(2) f16
|
||||
{
|
||||
u16 _u16;
|
||||
u8 _u8[2];
|
||||
|
||||
explicit f16(u16 raw)
|
||||
{
|
||||
_u16 = raw;
|
||||
}
|
||||
|
||||
explicit operator float() const
|
||||
{
|
||||
// See http://stackoverflow.com/a/26779139
|
||||
// The conversion doesn't handle NaN/Inf
|
||||
u32 raw = ((_u16 & 0x8000) << 16) | // Sign (just moved)
|
||||
(((_u16 & 0x7c00) + 0x1C000) << 13) | // Exponent ( exp - 15 + 127)
|
||||
((_u16 & 0x03FF) << 13); // Mantissa
|
||||
return (float&)raw;
|
||||
}
|
||||
};
|
||||
|
||||
using f32 = float;
|
||||
|
@ -144,9 +144,9 @@ namespace rsx
|
||||
return (method_registers[NV4097_SET_TEXTURE_CONTROL1 + (m_index * 8)]);
|
||||
}
|
||||
|
||||
u16 texture::bias() const
|
||||
float texture::bias() const
|
||||
{
|
||||
return ((method_registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)]) & 0x1fff);
|
||||
return float(f16((method_registers[NV4097_SET_TEXTURE_FILTER + (m_index * 8)]) & 0x1fff));
|
||||
}
|
||||
|
||||
u8 texture::min_filter() const
|
||||
|
@ -44,7 +44,7 @@ namespace rsx
|
||||
u32 remap() const;
|
||||
|
||||
// Filter
|
||||
u16 bias() const;
|
||||
float bias() const;
|
||||
u8 min_filter() const;
|
||||
u8 mag_filter() const;
|
||||
u8 convolution_filter() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user