1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

rsx: Refactor rsx_decode.h and bugfixes

This commit is contained in:
Eladash 2019-07-07 11:53:07 +03:00 committed by kd-11
parent db4bc6f6be
commit d57b4dc8f3
5 changed files with 859 additions and 1208 deletions

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "types.h" #include "types.h"
#include <limits>
template<typename T, uint N> template<typename T, uint N>
struct bf_base struct bf_base
@ -15,11 +16,11 @@ struct bf_base
// Field bitsize // Field bitsize
static constexpr uint bitsize = N; static constexpr uint bitsize = N;
// Value mask
static constexpr utype vmask = static_cast<utype>(~utype{} >> (bitmax - bitsize));
// All ones mask // All ones mask
static constexpr utype mask1 = static_cast<utype>(~utype{}); static constexpr utype mask1 = std::numeric_limits<utype>::max();
// Value mask
static constexpr utype vmask = mask1 >> (bitmax - bitsize);
protected: protected:
type m_data; type m_data;

View File

@ -62,7 +62,7 @@ struct fmt_unveil<T, std::enable_if_t<std::is_floating_point<T>::value && sizeof
// Convert FP to f64 and reinterpret as u64 // Convert FP to f64 and reinterpret as u64
static inline u64 get(const f64& arg) static inline u64 get(const f64& arg)
{ {
return *reinterpret_cast<const u64*>(reinterpret_cast<const u8*>(&arg)); return std::bit_cast<u64>(arg);
} }
}; };

View File

@ -131,6 +131,39 @@ using steady_clock = std::conditional<
std::chrono::high_resolution_clock::is_steady, std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock, std::chrono::steady_clock>::type; std::chrono::high_resolution_clock, std::chrono::steady_clock>::type;
// Get unsigned integral type from type size
template<size_t N>
struct get_int_impl
{
};
template<>
struct get_int_impl<sizeof(u8)>
{
using type = u8;
};
template<>
struct get_int_impl<sizeof(u16)>
{
using type = u16;
};
template<>
struct get_int_impl<sizeof(u32)>
{
using type = u32;
};
template<>
struct get_int_impl<sizeof(u64)>
{
using type = u64;
};
template <size_t N>
using get_int_t = typename get_int_impl<N>::type;
namespace gsl namespace gsl
{ {
using std::byte; using std::byte;
@ -855,3 +888,34 @@ inline void busy_wait(std::size_t cycles = 3000)
const u64 s = __rdtsc(); const u64 s = __rdtsc();
do _mm_pause(); while (__rdtsc() - s < cycles); do _mm_pause(); while (__rdtsc() - s < cycles);
} }
// TODO: Remove when moving to c++20
template <typename T>
inline constexpr uintmax_t floor2(T value)
{
value >>= 1;
for (uintmax_t i = 0;; i++, value >>= 1)
{
if (value == 0)
{
return i;
}
}
}
template <typename T>
inline constexpr uintmax_t ceil2(T value)
{
const uintmax_t ispow2 = value & (value - 1); // if power of 2 the result is 0
value >>= 1;
for (uintmax_t i = 0;; i++, value >>= 1)
{
if (value == 0)
{
return i + std::min<uintmax_t>(ispow2, 1);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -493,7 +493,7 @@ namespace rsx
using decoded_type = typename registers_decoder<opcode>::decoded_type; using decoded_type = typename registers_decoder<opcode>::decoded_type;
template<u32 opcode> template<u32 opcode>
decoded_type<opcode> decode() const const decoded_type<opcode> decode() const
{ {
u32 register_value = registers[opcode]; u32 register_value = registers[opcode];
return decoded_type<opcode>(register_value); return decoded_type<opcode>(register_value);