diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/bit_field.h | 44 | ||||
| -rw-r--r-- | src/common/color.h | 16 | ||||
| -rw-r--r-- | src/common/emu_window.cpp | 4 | ||||
| -rw-r--r-- | src/common/key_map.h | 14 | ||||
| -rw-r--r-- | src/common/logging/backend.cpp | 3 | ||||
| -rw-r--r-- | src/common/logging/backend.h | 20 | ||||
| -rw-r--r-- | src/common/logging/log.h | 3 | ||||
| -rw-r--r-- | src/common/x64/emitter.cpp | 4 |
8 files changed, 47 insertions, 61 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 66689f398..371eb17a1 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -115,29 +115,24 @@ template<std::size_t position, std::size_t bits, typename T> | |||
| 115 | struct BitField | 115 | struct BitField |
| 116 | { | 116 | { |
| 117 | private: | 117 | private: |
| 118 | // This constructor might be considered ambiguous: | 118 | // We hide the copy assigment operator here, because the default copy |
| 119 | // Would it initialize the storage or just the bitfield? | 119 | // assignment would copy the full storage value, rather than just the bits |
| 120 | // Hence, delete it. Use the assignment operator to set bitfield values! | 120 | // relevant to this particular bit field. |
| 121 | BitField(T val) = delete; | 121 | // We don't delete it because we want BitField to be trivially copyable. |
| 122 | BitField& operator=(const BitField&) = default; | ||
| 122 | 123 | ||
| 123 | public: | 124 | public: |
| 125 | // This constructor and assignment operator might be considered ambiguous: | ||
| 126 | // Would they initialize the storage or just the bitfield? | ||
| 127 | // Hence, delete them. Use the Assign method to set bitfield values! | ||
| 128 | BitField(T val) = delete; | ||
| 129 | BitField& operator=(T val) = delete; | ||
| 130 | |||
| 124 | // Force default constructor to be created | 131 | // Force default constructor to be created |
| 125 | // so that we can use this within unions | 132 | // so that we can use this within unions |
| 126 | BitField() = default; | 133 | BitField() = default; |
| 127 | 134 | ||
| 128 | // We explicitly delete the copy assigment operator here, because the | 135 | FORCE_INLINE operator T() const { |
| 129 | // default copy assignment would copy the full storage value, rather than | ||
| 130 | // just the bits relevant to this particular bit field. | ||
| 131 | BitField& operator=(const BitField&) = delete; | ||
| 132 | |||
| 133 | FORCE_INLINE BitField& operator=(T val) | ||
| 134 | { | ||
| 135 | Assign(val); | ||
| 136 | return *this; | ||
| 137 | } | ||
| 138 | |||
| 139 | FORCE_INLINE operator T() const | ||
| 140 | { | ||
| 141 | return Value(); | 136 | return Value(); |
| 142 | } | 137 | } |
| 143 | 138 | ||
| @@ -145,8 +140,7 @@ public: | |||
| 145 | storage = (storage & ~GetMask()) | (((StorageType)value << position) & GetMask()); | 140 | storage = (storage & ~GetMask()) | (((StorageType)value << position) & GetMask()); |
| 146 | } | 141 | } |
| 147 | 142 | ||
| 148 | FORCE_INLINE T Value() const | 143 | FORCE_INLINE T Value() const { |
| 149 | { | ||
| 150 | if (std::numeric_limits<T>::is_signed) | 144 | if (std::numeric_limits<T>::is_signed) |
| 151 | { | 145 | { |
| 152 | std::size_t shift = 8 * sizeof(T)-bits; | 146 | std::size_t shift = 8 * sizeof(T)-bits; |
| @@ -159,8 +153,7 @@ public: | |||
| 159 | } | 153 | } |
| 160 | 154 | ||
| 161 | // TODO: we may want to change this to explicit operator bool() if it's bug-free in VS2015 | 155 | // TODO: we may want to change this to explicit operator bool() if it's bug-free in VS2015 |
| 162 | FORCE_INLINE bool ToBool() const | 156 | FORCE_INLINE bool ToBool() const { |
| 163 | { | ||
| 164 | return Value() != 0; | 157 | return Value() != 0; |
| 165 | } | 158 | } |
| 166 | 159 | ||
| @@ -176,8 +169,7 @@ private: | |||
| 176 | // Unsigned version of StorageType | 169 | // Unsigned version of StorageType |
| 177 | typedef typename std::make_unsigned<StorageType>::type StorageTypeU; | 170 | typedef typename std::make_unsigned<StorageType>::type StorageTypeU; |
| 178 | 171 | ||
| 179 | FORCE_INLINE StorageType GetMask() const | 172 | FORCE_INLINE StorageType GetMask() const { |
| 180 | { | ||
| 181 | return (((StorageTypeU)~0) >> (8 * sizeof(T)-bits)) << position; | 173 | return (((StorageTypeU)~0) >> (8 * sizeof(T)-bits)) << position; |
| 182 | } | 174 | } |
| 183 | 175 | ||
| @@ -189,6 +181,10 @@ private: | |||
| 189 | static_assert(position < 8 * sizeof(T), "Invalid position"); | 181 | static_assert(position < 8 * sizeof(T), "Invalid position"); |
| 190 | static_assert(bits <= 8 * sizeof(T), "Invalid number of bits"); | 182 | static_assert(bits <= 8 * sizeof(T), "Invalid number of bits"); |
| 191 | static_assert(bits > 0, "Invalid number of bits"); | 183 | static_assert(bits > 0, "Invalid number of bits"); |
| 192 | static_assert(std::is_standard_layout<T>::value, "Invalid base type"); | 184 | static_assert(std::is_pod<T>::value, "Invalid base type"); |
| 193 | }; | 185 | }; |
| 194 | #pragma pack() | 186 | #pragma pack() |
| 187 | |||
| 188 | #if (__GNUC__ >= 5) || defined(__clang__) || defined(_MSC_VER) | ||
| 189 | static_assert(std::is_trivially_copyable<BitField<0, 1, u32>>::value, "BitField must be trivially copyable"); | ||
| 190 | #endif | ||
diff --git a/src/common/color.h b/src/common/color.h index eb199e308..908879ea6 100644 --- a/src/common/color.h +++ b/src/common/color.h | |||
| @@ -11,42 +11,42 @@ | |||
| 11 | namespace Color { | 11 | namespace Color { |
| 12 | 12 | ||
| 13 | /// Convert a 1-bit color component to 8 bit | 13 | /// Convert a 1-bit color component to 8 bit |
| 14 | inline u8 Convert1To8(u8 value) { | 14 | constexpr u8 Convert1To8(u8 value) { |
| 15 | return value * 255; | 15 | return value * 255; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | /// Convert a 4-bit color component to 8 bit | 18 | /// Convert a 4-bit color component to 8 bit |
| 19 | inline u8 Convert4To8(u8 value) { | 19 | constexpr u8 Convert4To8(u8 value) { |
| 20 | return (value << 4) | value; | 20 | return (value << 4) | value; |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | /// Convert a 5-bit color component to 8 bit | 23 | /// Convert a 5-bit color component to 8 bit |
| 24 | inline u8 Convert5To8(u8 value) { | 24 | constexpr u8 Convert5To8(u8 value) { |
| 25 | return (value << 3) | (value >> 2); | 25 | return (value << 3) | (value >> 2); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | /// Convert a 6-bit color component to 8 bit | 28 | /// Convert a 6-bit color component to 8 bit |
| 29 | inline u8 Convert6To8(u8 value) { | 29 | constexpr u8 Convert6To8(u8 value) { |
| 30 | return (value << 2) | (value >> 4); | 30 | return (value << 2) | (value >> 4); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | /// Convert a 8-bit color component to 1 bit | 33 | /// Convert a 8-bit color component to 1 bit |
| 34 | inline u8 Convert8To1(u8 value) { | 34 | constexpr u8 Convert8To1(u8 value) { |
| 35 | return value >> 7; | 35 | return value >> 7; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | /// Convert a 8-bit color component to 4 bit | 38 | /// Convert a 8-bit color component to 4 bit |
| 39 | inline u8 Convert8To4(u8 value) { | 39 | constexpr u8 Convert8To4(u8 value) { |
| 40 | return value >> 4; | 40 | return value >> 4; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | /// Convert a 8-bit color component to 5 bit | 43 | /// Convert a 8-bit color component to 5 bit |
| 44 | inline u8 Convert8To5(u8 value) { | 44 | constexpr u8 Convert8To5(u8 value) { |
| 45 | return value >> 3; | 45 | return value >> 3; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | /// Convert a 8-bit color component to 6 bit | 48 | /// Convert a 8-bit color component to 6 bit |
| 49 | inline u8 Convert8To6(u8 value) { | 49 | constexpr u8 Convert8To6(u8 value) { |
| 50 | return value >> 2; | 50 | return value >> 2; |
| 51 | } | 51 | } |
| 52 | 52 | ||
diff --git a/src/common/emu_window.cpp b/src/common/emu_window.cpp index b69b05cb9..b2807354a 100644 --- a/src/common/emu_window.cpp +++ b/src/common/emu_window.cpp | |||
| @@ -55,14 +55,14 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { | |||
| 55 | (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top); | 55 | (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top); |
| 56 | 56 | ||
| 57 | touch_pressed = true; | 57 | touch_pressed = true; |
| 58 | pad_state.touch = 1; | 58 | pad_state.touch.Assign(1); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | void EmuWindow::TouchReleased() { | 61 | void EmuWindow::TouchReleased() { |
| 62 | touch_pressed = false; | 62 | touch_pressed = false; |
| 63 | touch_x = 0; | 63 | touch_x = 0; |
| 64 | touch_y = 0; | 64 | touch_y = 0; |
| 65 | pad_state.touch = 0; | 65 | pad_state.touch.Assign(0); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { | 68 | void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { |
diff --git a/src/common/key_map.h b/src/common/key_map.h index 0ecec714f..68f7e2f99 100644 --- a/src/common/key_map.h +++ b/src/common/key_map.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <tuple> | ||
| 7 | #include "core/hle/service/hid/hid.h" | 8 | #include "core/hle/service/hid/hid.h" |
| 8 | 9 | ||
| 9 | namespace KeyMap { | 10 | namespace KeyMap { |
| @@ -15,15 +16,14 @@ struct HostDeviceKey { | |||
| 15 | int key_code; | 16 | int key_code; |
| 16 | int device_id; ///< Uniquely identifies a host device | 17 | int device_id; ///< Uniquely identifies a host device |
| 17 | 18 | ||
| 18 | bool operator < (const HostDeviceKey &other) const { | 19 | bool operator<(const HostDeviceKey &other) const { |
| 19 | if (device_id == other.device_id) { | 20 | return std::tie(key_code, device_id) < |
| 20 | return key_code < other.key_code; | 21 | std::tie(other.key_code, other.device_id); |
| 21 | } | ||
| 22 | return device_id < other.device_id; | ||
| 23 | } | 22 | } |
| 24 | 23 | ||
| 25 | bool operator == (const HostDeviceKey &other) const { | 24 | bool operator==(const HostDeviceKey &other) const { |
| 26 | return device_id == other.device_id && key_code == other.key_code; | 25 | return std::tie(key_code, device_id) == |
| 26 | std::tie(other.key_code, other.device_id); | ||
| 27 | } | 27 | } |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d186ba8f8..54291429a 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -49,6 +49,7 @@ namespace Log { | |||
| 49 | SUB(Service, DSP) \ | 49 | SUB(Service, DSP) \ |
| 50 | SUB(Service, HID) \ | 50 | SUB(Service, HID) \ |
| 51 | SUB(Service, SOC) \ | 51 | SUB(Service, SOC) \ |
| 52 | SUB(Service, IR) \ | ||
| 52 | SUB(Service, Y2R) \ | 53 | SUB(Service, Y2R) \ |
| 53 | CLS(HW) \ | 54 | CLS(HW) \ |
| 54 | SUB(HW, Memory) \ | 55 | SUB(HW, Memory) \ |
| @@ -58,6 +59,8 @@ namespace Log { | |||
| 58 | CLS(Render) \ | 59 | CLS(Render) \ |
| 59 | SUB(Render, Software) \ | 60 | SUB(Render, Software) \ |
| 60 | SUB(Render, OpenGL) \ | 61 | SUB(Render, OpenGL) \ |
| 62 | CLS(Audio) \ | ||
| 63 | SUB(Audio, DSP) \ | ||
| 61 | CLS(Loader) | 64 | CLS(Loader) |
| 62 | 65 | ||
| 63 | // GetClassName is a macro defined by Windows.h, grrr... | 66 | // GetClassName is a macro defined by Windows.h, grrr... |
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index c1f4d08e4..795d42ebd 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h | |||
| @@ -27,25 +27,9 @@ struct Entry { | |||
| 27 | std::string message; | 27 | std::string message; |
| 28 | 28 | ||
| 29 | Entry() = default; | 29 | Entry() = default; |
| 30 | Entry(Entry&& o) = default; | ||
| 30 | 31 | ||
| 31 | // TODO(yuriks) Use defaulted move constructors once MSVC supports them | 32 | Entry& operator=(Entry&& o) = default; |
| 32 | #define MOVE(member) member(std::move(o.member)) | ||
| 33 | Entry(Entry&& o) | ||
| 34 | : MOVE(timestamp), MOVE(log_class), MOVE(log_level), | ||
| 35 | MOVE(location), MOVE(message) | ||
| 36 | {} | ||
| 37 | #undef MOVE | ||
| 38 | |||
| 39 | Entry& operator=(const Entry&& o) { | ||
| 40 | #define MOVE(member) member = std::move(o.member) | ||
| 41 | MOVE(timestamp); | ||
| 42 | MOVE(log_class); | ||
| 43 | MOVE(log_level); | ||
| 44 | MOVE(location); | ||
| 45 | MOVE(message); | ||
| 46 | #undef MOVE | ||
| 47 | return *this; | ||
| 48 | } | ||
| 49 | }; | 33 | }; |
| 50 | 34 | ||
| 51 | /** | 35 | /** |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 2d9323a7b..4b01805ae 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -64,6 +64,7 @@ enum class Class : ClassType { | |||
| 64 | Service_DSP, ///< The DSP (DSP control) service | 64 | Service_DSP, ///< The DSP (DSP control) service |
| 65 | Service_HID, ///< The HID (Human interface device) service | 65 | Service_HID, ///< The HID (Human interface device) service |
| 66 | Service_SOC, ///< The SOC (Socket) service | 66 | Service_SOC, ///< The SOC (Socket) service |
| 67 | Service_IR, ///< The IR service | ||
| 67 | Service_Y2R, ///< The Y2R (YUV to RGB conversion) service | 68 | Service_Y2R, ///< The Y2R (YUV to RGB conversion) service |
| 68 | HW, ///< Low-level hardware emulation | 69 | HW, ///< Low-level hardware emulation |
| 69 | HW_Memory, ///< Memory-map and address translation | 70 | HW_Memory, ///< Memory-map and address translation |
| @@ -73,6 +74,8 @@ enum class Class : ClassType { | |||
| 73 | Render, ///< Emulator video output and hardware acceleration | 74 | Render, ///< Emulator video output and hardware acceleration |
| 74 | Render_Software, ///< Software renderer backend | 75 | Render_Software, ///< Software renderer backend |
| 75 | Render_OpenGL, ///< OpenGL backend | 76 | Render_OpenGL, ///< OpenGL backend |
| 77 | Audio, ///< Emulator audio output | ||
| 78 | Audio_DSP, ///< The HLE implementation of the DSP | ||
| 76 | Loader, ///< ROM loader | 79 | Loader, ///< ROM loader |
| 77 | 80 | ||
| 78 | Count ///< Total number of logging classes | 81 | Count ///< Total number of logging classes |
diff --git a/src/common/x64/emitter.cpp b/src/common/x64/emitter.cpp index 939df210e..1dcf2416c 100644 --- a/src/common/x64/emitter.cpp +++ b/src/common/x64/emitter.cpp | |||
| @@ -225,14 +225,14 @@ void OpArg::WriteVex(XEmitter* emit, X64Reg regOp1, X64Reg regOp2, int L, int pp | |||
| 225 | // do we need any VEX fields that only appear in the three-byte form? | 225 | // do we need any VEX fields that only appear in the three-byte form? |
| 226 | if (X == 1 && B == 1 && W == 0 && mmmmm == 1) | 226 | if (X == 1 && B == 1 && W == 0 && mmmmm == 1) |
| 227 | { | 227 | { |
| 228 | u8 RvvvvLpp = (R << 7) | (vvvv << 3) | (L << 1) | pp; | 228 | u8 RvvvvLpp = (R << 7) | (vvvv << 3) | (L << 2) | pp; |
| 229 | emit->Write8(0xC5); | 229 | emit->Write8(0xC5); |
| 230 | emit->Write8(RvvvvLpp); | 230 | emit->Write8(RvvvvLpp); |
| 231 | } | 231 | } |
| 232 | else | 232 | else |
| 233 | { | 233 | { |
| 234 | u8 RXBmmmmm = (R << 7) | (X << 6) | (B << 5) | mmmmm; | 234 | u8 RXBmmmmm = (R << 7) | (X << 6) | (B << 5) | mmmmm; |
| 235 | u8 WvvvvLpp = (W << 7) | (vvvv << 3) | (L << 1) | pp; | 235 | u8 WvvvvLpp = (W << 7) | (vvvv << 3) | (L << 2) | pp; |
| 236 | emit->Write8(0xC4); | 236 | emit->Write8(0xC4); |
| 237 | emit->Write8(RXBmmmmm); | 237 | emit->Write8(RXBmmmmm); |
| 238 | emit->Write8(WvvvvLpp); | 238 | emit->Write8(WvvvvLpp); |