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

types.hpp: more cleanup

Also fix compilation.
This commit is contained in:
Nekotekina 2020-12-22 18:04:08 +03:00
parent 6357b9a04f
commit a8e0d261b7
42 changed files with 88 additions and 78 deletions

View File

@ -1715,7 +1715,7 @@ u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment)
if (!root_dir)
{
return static_cast<u64>(umax);
return -1;
}
for (const auto& entry : root_dir)

View File

@ -236,6 +236,12 @@ void fmt_class_string<bool>::format(std::string& out, u64 arg)
out += arg ? "true" : "false";
}
template <>
void fmt_class_string<b8>::format(std::string& out, u64 arg)
{
out += get_object(arg) ? "true" : "false";
}
template <>
void fmt_class_string<v128>::format(std::string& out, u64 arg)
{

View File

@ -64,17 +64,6 @@ struct fmt_unveil<T, std::enable_if_t<std::is_floating_point<T>::value && sizeof
}
};
template <>
struct fmt_unveil<f16, void>
{
using type = f16;
static inline u64 get(const f16& arg)
{
return fmt_unveil<f64>::get(arg.operator float());
}
};
template <typename T>
struct fmt_unveil<T, std::enable_if_t<std::is_enum<T>::value>>
{
@ -108,17 +97,6 @@ struct fmt_unveil<T[N], void>
}
};
template <>
struct fmt_unveil<b8, void>
{
using type = bool;
static inline u64 get(const b8& value)
{
return fmt_unveil<bool>::get(value);
}
};
template <typename T, bool Se, usz Align>
struct fmt_unveil<se_t<T, Se, Align>, void>
{

View File

@ -71,7 +71,7 @@ inline int futex(volatile void* uaddr, int futex_op, uint val, const timespec* t
};
std::mutex mutex;
std::unordered_multimap<volatile void*, waiter*, pointer_hash<volatile void, alignof(int)>> map;
std::unordered_multimap<volatile void*, waiter*> map;
int operator()(volatile void* uaddr, int futex_op, uint val, const timespec* timeout, uint mask)
{

View File

@ -433,7 +433,7 @@ struct surmixer_thread : ppu_thread
g_surmx.mixdata[i * 8 + 1] += right;
}
if ((p.m_position == p.m_samples && p.m_speed > 0.0f) ||
(p.m_position = umax && p.m_speed < 0.0f)) // loop or stop
(p.m_position == umax && p.m_speed < 0.0f)) // loop or stop
{
if (p.m_loop_mode == CELL_SSPLAYER_LOOP_ON)
{

View File

@ -3,6 +3,7 @@
#include "Keyboard.h"
#include <mutex>
#include <vector>
#include "util/init_mutex.hpp"

View File

@ -2,6 +2,7 @@
#include <list>
#include <algorithm>
#include <vector>
#include "Utilities/mutex.h"
#include "util/init_mutex.hpp"

View File

@ -1,11 +1,17 @@
#pragma once
#include <cmath>
#include "pad_types.h"
#include "pad_config.h"
#include "pad_config_types.h"
#include "util/types.hpp"
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <memory>
#include <unordered_map>
struct PadDevice
{
pad_config* config{ nullptr };

View File

@ -2,6 +2,7 @@
#include <queue>
#include <map>
#include <unordered_map>
#include "Emu/Memory/vm_ptr.h"
#include "Emu/Cell/Modules/sceNp.h"

View File

@ -2,6 +2,7 @@
#include "Emu/CPU/CPUThread.h"
#include "Emu/RSX/rsx_methods.h"
#include <unordered_map>
#include <cereal/types/vector.hpp>
#include <cereal/types/array.hpp>

View File

@ -9,6 +9,7 @@
#include "Utilities/span.h"
#include <deque>
#include <unordered_map>
enum class SHADER_TYPE
{

View File

@ -6,6 +6,8 @@
#include "Utilities/StrUtil.h"
#include "util/types.hpp"
#include <unordered_map>
enum class FUNCTION
{
FUNCTION_DP2,

View File

@ -7,6 +7,8 @@
#include "util/asm.hpp"
#include <unordered_map>
namespace rsx
{
namespace utility

View File

@ -4,6 +4,8 @@
#include "texture_cache_predictor.h"
#include "texture_cache_helpers.h"
#include <unordered_map>
extern u64 get_system_time();
#define RSX_GCM_FORMAT_IGNORED 0

View File

@ -4,6 +4,8 @@
#include "../rsx_utils.h"
#include "TextureUtils.h"
#include <unordered_map>
namespace rsx
{
/**

View File

@ -5,6 +5,7 @@
#include "GLHelpers.h"
#include "util/asm.hpp"
#include <unordered_map>
namespace gl
{

View File

@ -10,6 +10,7 @@
#include "GLShaderInterpreter.h"
#include <optional>
#include <unordered_map>
#ifdef _WIN32
#pragma comment(lib, "opengl32.lib")

View File

@ -4,6 +4,8 @@
#include "GLCompute.h"
#include "util/logs.hpp"
#include <unordered_map>
namespace gl
{
std::unordered_map<u32, std::unique_ptr<gl::compute_task>> g_compute_tasks;

View File

@ -4,6 +4,7 @@
#include "GLHelpers.h"
#include "../Overlays/overlays.h"
#include <string>
#include <unordered_map>
extern u64 get_system_time();

View File

@ -3,6 +3,8 @@
#include "../Common/ProgramStateCache.h"
#include "../Common/TextureUtils.h"
#include <unordered_map>
namespace gl
{
using namespace ::glsl;

View File

@ -5,6 +5,7 @@
#include "../Common/TextGlyphs.h"
#include <string>
#include <vector>
#include <unordered_map>
namespace gl
{

View File

@ -5,6 +5,8 @@
#include "../Common/TextureUtils.h"
#include "GLHelpers.h"
#include <unordered_map>
namespace rsx
{
class vertex_texture;

View File

@ -3,6 +3,8 @@
#include "Emu/RSX/RSXVertexProgram.h"
#include "GLHelpers.h"
#include <unordered_map>
enum
{
GL_VP_FORCE_ATTRIB_SCALING = 1, //Scale vertex read result

View File

@ -1,6 +1,8 @@
#include "stdafx.h"
#include "overlay_utils.h"
#include <unordered_map>
LOG_CHANNEL(overlays);
static auto s_ascii_lowering_map = []()

View File

@ -4,6 +4,7 @@
#include <deque>
#include <variant>
#include <stack>
#include <unordered_map>
#include "GCM.h"
#include "rsx_cache.h"

View File

@ -6,6 +6,7 @@
#include "Emu/IdManager.h"
#include "util/asm.hpp"
#include <unordered_map>
#define VK_MAX_COMPUTE_TASKS 4096 // Max number of jobs per frame

View File

@ -4,6 +4,7 @@
#include "VKDMA.h"
#include "util/asm.hpp"
#include <unordered_map>
namespace vk
{

View File

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "VKFramebuffer.h"
#include <unordered_map>
namespace vk
{

View File

@ -13,6 +13,7 @@
#include "Emu/RSX/rsx_methods.h"
#include "Utilities/mutex.h"
#include "Utilities/lockless.h"
#include <unordered_map>
namespace vk
{

View File

@ -11,6 +11,7 @@
#include "../Overlays/overlays.h"
#include "Utilities/hash.h"
#include <unordered_map>
#define VK_OVERLAY_MAX_DRAW_CALLS 1024

View File

@ -1,6 +1,10 @@
#pragma once
#include "VKHelpers.h"
#include <unordered_map>
#include <deque>
#include <memory>
namespace vk
{
u64 get_event_id();

View File

@ -1,5 +1,6 @@
#pragma once
#include "VKProgramBuffer.h"
#include <unordered_map>
namespace vk
{

View File

@ -5,6 +5,7 @@
#include "VKRenderPass.h"
#include "VKPipelineCompiler.h"
#include "../Common/TextGlyphs.h"
#include <unordered_map>
namespace vk
{

View File

@ -13,7 +13,7 @@
#include "rsx_utils.h"
#include <thread>
#include <chrono>
#include <unordered_map>
#include "util/vm.hpp"

View File

@ -4,6 +4,8 @@
#include "hidapi.h"
#include <unordered_map>
class ds3_pad_handler final : public PadHandlerBase
{
enum DS3KeyCodes

View File

@ -4,6 +4,8 @@
#include "Utilities/CRC.h"
#include "hidapi.h"
#include <unordered_map>
class ds4_pad_handler final : public PadHandlerBase
{
// These are all the possible buttons on a standard DS4 controller

View File

@ -4,6 +4,8 @@
#include "Utilities/CRC.h"
#include "hidapi.h"
#include <unordered_map>
class dualsense_pad_handler final : public PadHandlerBase
{
enum DualSenseKeyCodes

View File

@ -1,6 +1,9 @@
#pragma once
#include "Emu/Io/PadHandler.h"
#include <unordered_map>
#ifndef NOMINMAX
#define NOMINMAX
#endif

View File

@ -28,6 +28,7 @@
#include <memory>
#include <set>
#include <regex>
#include <unordered_map>
#include <QtConcurrent>
#include <QDesktopServices>

View File

@ -6,6 +6,7 @@
#include <QMimeData>
#include "Utilities/bin_patch.h"
#include <unordered_map>
namespace Ui
{

View File

@ -401,6 +401,19 @@ void Buffer::ShowWindowed()
namespace
{
f32 f16_to_f32(f16 val)
{
// See http://stackoverflow.com/a/26779139
// The conversion doesn't handle NaN/Inf
const u16 _u16 = static_cast<u16>(val);
const u32 raw = ((_u16 & 0x8000) << 16) | // Sign (just moved)
(((_u16 & 0x7c00) + 0x1C000) << 13) | // Exponent ( exp - 15 + 127)
((_u16 & 0x03FF) << 13); // Mantissa
return std::bit_cast<f32>(raw);
}
std::array<u8, 3> get_value(gsl::span<const std::byte> orig_buffer, rsx::surface_color_format format, usz idx)
{
switch (format)
@ -438,9 +451,9 @@ namespace
const f16 h0 = f16(ptr[4 * idx]);
const f16 h1 = f16(ptr[4 * idx + 1]);
const f16 h2 = f16(ptr[4 * idx + 2]);
const f32 f0 = float(h0);
const f32 f1 = float(h1);
const f32 f2 = float(h2);
const f32 f0 = f16_to_f32(h0);
const f32 f1 = f16_to_f32(h1);
const f32 f2 = f16_to_f32(h2);
const u8 val0 = f0 * 255.;
const u8 val1 = f1 * 255.;

View File

@ -48,9 +48,7 @@ using namespace std::literals;
#define AUDIT(...) (static_cast<void>(0))
#endif
#if __cpp_lib_bit_cast >= 201806L
#include <bit>
#else
#if __cpp_lib_bit_cast < 201806L
namespace std
{
template <class To, class From, typename = std::enable_if_t<sizeof(To) == sizeof(From)>>
@ -64,7 +62,7 @@ namespace std
}
To result{};
std::memcpy(&result, &from, sizeof(From));
__builtin_memcpy(&result, &from, sizeof(From));
return result;
}
}
@ -152,36 +150,29 @@ template <>
struct get_int_impl<sizeof(u8)>
{
using utype = u8;
using stype = s8;
};
template <>
struct get_int_impl<sizeof(u16)>
{
using utype = u16;
using stype = s16;
};
template <>
struct get_int_impl<sizeof(u32)>
{
using utype = u32;
using stype = s32;
};
template <>
struct get_int_impl<sizeof(u64)>
{
using utype = u64;
using stype = s64;
};
template <usz N>
using get_uint_t = typename get_int_impl<N>::utype;
template <usz N>
using get_sint_t = typename get_int_impl<N>::stype;
template <typename T>
std::remove_cvref_t<T> as_rvalue(T&& obj)
{
@ -529,12 +520,6 @@ constexpr inline struct umax_helper
{
constexpr umax_helper() noexcept = default;
template <typename T, typename S = simple_t<T>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
explicit constexpr operator T() const
{
return static_cast<S>(-1);
}
template <typename T, typename S = simple_t<T>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
constexpr bool operator==(const T& rhs) const
{
@ -566,30 +551,11 @@ constexpr inline struct umax_helper
#endif
} umax;
enum class f16 : u16{};
using f32 = float;
using f64 = double;
struct f16
{
u16 _u16;
explicit f16(u16 raw)
{
_u16 = raw;
}
explicit operator f32() 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 std::bit_cast<f32>(raw);
}
};
template <typename T, typename T2>
inline u32 offset32(T T2::*const mptr)
{
@ -855,16 +821,7 @@ template <typename T, usz Size>
return static_cast<u32>(Size);
}
// Simplified hash algorithm for pointers. May be used in std::unordered_(map|set).
template <typename T, usz Align = alignof(T)>
struct pointer_hash
{
usz operator()(T* ptr) const
{
return reinterpret_cast<uptr>(ptr) / Align;
}
};
// Simplified hash algorithm. May be used in std::unordered_(map|set).
template <typename T, usz Shift = 0>
struct value_hash
{