common: Resolve C4267 warning on MSVC
Also removes Timer::GetDoubleTime() as it is unused.
This commit is contained in:
parent
46c6e5c4c0
commit
1cc1c33a15
6 changed files with 7 additions and 28 deletions
|
@ -10,7 +10,7 @@ namespace Common {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
[[nodiscard]] constexpr T AlignUp(T value, std::size_t size) {
|
[[nodiscard]] constexpr T AlignUp(T value, std::size_t size) {
|
||||||
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
|
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
|
||||||
auto mod{value % size};
|
auto mod{static_cast<T>(value % size)};
|
||||||
value -= mod;
|
value -= mod;
|
||||||
return static_cast<T>(mod == T{0} ? value : value + size);
|
return static_cast<T>(mod == T{0} ? value : value + size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
void FlipRGBA8Texture(std::vector<u8>& tex, u64 width, u64 height) {
|
void FlipRGBA8Texture(std::vector<u8>& tex, u32 width, u32 height) {
|
||||||
ASSERT(tex.size() == width * height * 4);
|
ASSERT(tex.size() == width * height * 4);
|
||||||
const u64 line_size = width * 4;
|
const u32 line_size = width * 4;
|
||||||
for (u64 line = 0; line < height / 2; line++) {
|
for (u32 line = 0; line < height / 2; line++) {
|
||||||
const u32 offset_1 = line * line_size;
|
const u32 offset_1 = line * line_size;
|
||||||
const u32 offset_2 = (height - line - 1) * line_size;
|
const u32 offset_2 = (height - line - 1) * line_size;
|
||||||
// Swap lines
|
// Swap lines
|
||||||
|
|
|
@ -8,5 +8,5 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
void FlipRGBA8Texture(std::vector<u8>& tex, u64 width, u64 height);
|
void FlipRGBA8Texture(std::vector<u8>& tex, u32 width, u32 height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,24 +137,4 @@ std::string Timer::GetTimeFormatted() {
|
||||||
return fmt::format("{}:{:03}", tmp, milliseconds);
|
return fmt::format("{}:{:03}", tmp, milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a timestamp with decimals for precise time comparisons
|
|
||||||
// ----------------
|
|
||||||
double Timer::GetDoubleTime() {
|
|
||||||
// Get continuous timestamp
|
|
||||||
u64 TmpSeconds = static_cast<u64>(Common::Timer::GetTimeSinceJan1970().count());
|
|
||||||
double ms = static_cast<u64>(GetTimeMs().count()) % 1000;
|
|
||||||
|
|
||||||
// Remove a few years. We only really want enough seconds to make
|
|
||||||
// sure that we are detecting actual actions, perhaps 60 seconds is
|
|
||||||
// enough really, but I leave a year of seconds anyway, in case the
|
|
||||||
// user's clock is incorrect or something like that.
|
|
||||||
TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60);
|
|
||||||
|
|
||||||
// Make a smaller integer that fits in the double
|
|
||||||
u32 Seconds = static_cast<u32>(TmpSeconds);
|
|
||||||
double TmpTime = Seconds + ms;
|
|
||||||
|
|
||||||
return TmpTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Namespace Common
|
} // Namespace Common
|
||||||
|
|
|
@ -24,7 +24,6 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] static std::chrono::seconds GetTimeSinceJan1970();
|
[[nodiscard]] static std::chrono::seconds GetTimeSinceJan1970();
|
||||||
[[nodiscard]] static std::chrono::seconds GetLocalTimeSinceJan1970();
|
[[nodiscard]] static std::chrono::seconds GetLocalTimeSinceJan1970();
|
||||||
[[nodiscard]] static double GetDoubleTime();
|
|
||||||
|
|
||||||
[[nodiscard]] static std::string GetTimeFormatted();
|
[[nodiscard]] static std::string GetTimeFormatted();
|
||||||
[[nodiscard]] std::string GetTimeElapsedFormatted() const;
|
[[nodiscard]] std::string GetTimeElapsedFormatted() const;
|
||||||
|
|
|
@ -158,10 +158,10 @@ struct ABIFrameInfo {
|
||||||
|
|
||||||
inline ABIFrameInfo ABI_CalculateFrameSize(std::bitset<32> regs, std::size_t rsp_alignment,
|
inline ABIFrameInfo ABI_CalculateFrameSize(std::bitset<32> regs, std::size_t rsp_alignment,
|
||||||
std::size_t needed_frame_size) {
|
std::size_t needed_frame_size) {
|
||||||
int count = (regs & ABI_ALL_GPRS).count();
|
const auto count = (regs & ABI_ALL_GPRS).count();
|
||||||
rsp_alignment -= count * 8;
|
rsp_alignment -= count * 8;
|
||||||
std::size_t subtraction = 0;
|
std::size_t subtraction = 0;
|
||||||
int xmm_count = (regs & ABI_ALL_XMMS).count();
|
const auto xmm_count = (regs & ABI_ALL_XMMS).count();
|
||||||
if (xmm_count) {
|
if (xmm_count) {
|
||||||
// If we have any XMMs to save, we must align the stack here.
|
// If we have any XMMs to save, we must align the stack here.
|
||||||
subtraction = rsp_alignment & 0xF;
|
subtraction = rsp_alignment & 0xF;
|
||||||
|
|
Loading…
Reference in a new issue