Misc: Replace a bunch of static qualifiers with inline

Allows deduplication, shaves a couple percent off the debug binary size.
Release binary size difference is negligible.
pull/3498/head
Stenzek 3 months ago
parent c8dd9995ec
commit 52d9f73f98
No known key found for this signature in database

@ -65,20 +65,20 @@ enum class Channel : u32
// Packs a level and channel into one 16-bit number.
using MessageCategory = u32;
[[maybe_unused]] ALWAYS_INLINE static constexpr u32 PackCategory(Channel channel, Level level, Color colour)
[[maybe_unused]] ALWAYS_INLINE constexpr u32 PackCategory(Channel channel, Level level, Color colour)
{
return ((static_cast<MessageCategory>(colour) << 10) | (static_cast<MessageCategory>(channel) << 3) |
static_cast<MessageCategory>(level));
}
[[maybe_unused]] ALWAYS_INLINE static constexpr Color UnpackColor(MessageCategory cat)
[[maybe_unused]] ALWAYS_INLINE constexpr Color UnpackColor(MessageCategory cat)
{
return static_cast<Color>((cat >> 10) & 0x1f);
}
[[maybe_unused]] ALWAYS_INLINE static constexpr Channel UnpackChannel(MessageCategory cat)
[[maybe_unused]] ALWAYS_INLINE constexpr Channel UnpackChannel(MessageCategory cat)
{
return static_cast<Channel>((cat >> 3) & 0x7f);
}
[[maybe_unused]] ALWAYS_INLINE static constexpr Level UnpackLevel(MessageCategory cat)
[[maybe_unused]] ALWAYS_INLINE constexpr Level UnpackLevel(MessageCategory cat)
{
return static_cast<Level>(cat & 0x7);
}
@ -136,50 +136,49 @@ void Write(MessageCategory cat, const char* functionName, std::string_view messa
void WriteFmtArgs(MessageCategory cat, fmt::string_view fmt, fmt::format_args args);
void WriteFmtArgs(MessageCategory cat, const char* functionName, fmt::string_view fmt, fmt::format_args args);
ALWAYS_INLINE static void FastWrite(Channel channel, Level level, std::string_view message)
ALWAYS_INLINE void FastWrite(Channel channel, Level level, std::string_view message)
{
if (level <= GetLogLevel()) [[unlikely]]
Write(PackCategory(channel, level, Color::Default), message);
}
ALWAYS_INLINE static void FastWrite(Channel channel, const char* functionName, Level level, std::string_view message)
ALWAYS_INLINE void FastWrite(Channel channel, const char* functionName, Level level, std::string_view message)
{
if (level <= GetLogLevel()) [[unlikely]]
Write(PackCategory(channel, level, Color::Default), functionName, message);
}
template<typename... T>
ALWAYS_INLINE static void FastWrite(Channel channel, Level level, fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE void FastWrite(Channel channel, Level level, fmt::format_string<T...> fmt, T&&... args)
{
if (level <= GetLogLevel()) [[unlikely]]
WriteFmtArgs(PackCategory(channel, level, Color::Default), fmt, fmt::make_format_args(args...));
}
template<typename... T>
ALWAYS_INLINE static void FastWrite(Channel channel, const char* functionName, Level level,
fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE void FastWrite(Channel channel, const char* functionName, Level level, fmt::format_string<T...> fmt,
T&&... args)
{
if (level <= GetLogLevel()) [[unlikely]]
WriteFmtArgs(PackCategory(channel, level, Color::Default), functionName, fmt, fmt::make_format_args(args...));
}
ALWAYS_INLINE static void FastWrite(Channel channel, Level level, Color colour, std::string_view message)
ALWAYS_INLINE void FastWrite(Channel channel, Level level, Color colour, std::string_view message)
{
if (level <= GetLogLevel()) [[unlikely]]
Write(PackCategory(channel, level, colour), message);
}
ALWAYS_INLINE static void FastWrite(Channel channel, const char* functionName, Level level, Color colour,
std::string_view message)
ALWAYS_INLINE void FastWrite(Channel channel, const char* functionName, Level level, Color colour,
std::string_view message)
{
if (level <= GetLogLevel()) [[unlikely]]
Write(PackCategory(channel, level, colour), functionName, message);
}
template<typename... T>
ALWAYS_INLINE static void FastWrite(Channel channel, Level level, Color colour, fmt::format_string<T...> fmt,
T&&... args)
ALWAYS_INLINE void FastWrite(Channel channel, Level level, Color colour, fmt::format_string<T...> fmt, T&&... args)
{
if (level <= GetLogLevel()) [[unlikely]]
WriteFmtArgs(PackCategory(channel, level, colour), fmt, fmt::make_format_args(args...));
}
template<typename... T>
ALWAYS_INLINE static void FastWrite(Channel channel, const char* functionName, Level level, Color colour,
fmt::format_string<T...> fmt, T&&... args)
ALWAYS_INLINE void FastWrite(Channel channel, const char* functionName, Level level, Color colour,
fmt::format_string<T...> fmt, T&&... args)
{
if (level <= GetLogLevel()) [[unlikely]]
WriteFmtArgs(PackCategory(channel, level, colour), functionName, fmt, fmt::make_format_args(args...));

@ -2,8 +2,9 @@
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
#include "log.h"
#include "types.h"
#include "small_string.h"
#include "string_util.h"
#include "types.h"
#include "ryml.hpp"
@ -12,22 +13,22 @@
// RapidYAML utility routines.
static inline std::string_view to_stringview(const c4::csubstr& s)
inline std::string_view to_stringview(const c4::csubstr& s)
{
return std::string_view(s.data(), s.size());
}
static inline std::string_view to_stringview(const c4::substr& s)
inline std::string_view to_stringview(const c4::substr& s)
{
return std::string_view(s.data(), s.size());
}
static inline c4::csubstr to_csubstr(std::string_view sv)
inline c4::csubstr to_csubstr(std::string_view sv)
{
return c4::csubstr(sv.data(), sv.length());
}
static inline bool GetStringFromObject(const ryml::ConstNodeRef& object, std::string_view key, std::string* dest)
inline bool GetStringFromObject(const ryml::ConstNodeRef& object, std::string_view key, std::string* dest)
{
dest->clear();
@ -42,7 +43,7 @@ static inline bool GetStringFromObject(const ryml::ConstNodeRef& object, std::st
return true;
}
static inline bool GetStringFromObject(const ryml::ConstNodeRef& object, std::string_view key, std::string_view* dest)
inline bool GetStringFromObject(const ryml::ConstNodeRef& object, std::string_view key, std::string_view* dest)
{
const ryml::ConstNodeRef member = object.find_child(to_csubstr(key));
if (!member.valid())
@ -56,7 +57,7 @@ static inline bool GetStringFromObject(const ryml::ConstNodeRef& object, std::st
}
template<typename T>
static inline bool GetUIntFromObject(const ryml::ConstNodeRef& object, std::string_view key, T* dest)
inline bool GetUIntFromObject(const ryml::ConstNodeRef& object, std::string_view key, T* dest)
{
*dest = 0;
@ -84,7 +85,7 @@ static inline bool GetUIntFromObject(const ryml::ConstNodeRef& object, std::stri
}
template<typename T>
static inline std::optional<T> GetOptionalTFromObject(const ryml::ConstNodeRef& object, std::string_view key)
inline std::optional<T> GetOptionalTFromObject(const ryml::ConstNodeRef& object, std::string_view key)
{
std::optional<T> ret;
@ -125,8 +126,8 @@ static inline std::optional<T> GetOptionalTFromObject(const ryml::ConstNodeRef&
}
template<typename T>
static inline std::optional<T> ParseOptionalTFromObject(const ryml::ConstNodeRef& object, std::string_view key,
std::optional<T> (*from_string_function)(const char* str))
inline std::optional<T> ParseOptionalTFromObject(const ryml::ConstNodeRef& object, std::string_view key,
std::optional<T> (*from_string_function)(const char* str))
{
std::optional<T> ret;
@ -151,7 +152,7 @@ static inline std::optional<T> ParseOptionalTFromObject(const ryml::ConstNodeRef
return ret;
}
static inline void SetRymlCallbacks()
inline void SetRymlCallbacks()
{
ryml::Callbacks callbacks = ryml::get_callbacks();
callbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void* userdata) {

@ -30,11 +30,11 @@
namespace StringUtil {
/// Returns the given character in uppercase.
ALWAYS_INLINE static char ToLower(char ch)
ALWAYS_INLINE char ToLower(char ch)
{
return ch + ((static_cast<u8>(ch) >= 'A' && static_cast<u8>(ch) <= 'Z') ? ('a' - 'A') : 0);
}
ALWAYS_INLINE static char ToUpper(char ch)
ALWAYS_INLINE char ToUpper(char ch)
{
return ch - ((static_cast<u8>(ch) >= 'a' && static_cast<u8>(ch) <= 'z') ? ('a' - 'A') : 0);
}
@ -52,7 +52,7 @@ std::size_t Strlcpy(char* dst, const std::string_view src, std::size_t size);
std::size_t Strnlen(const char* str, std::size_t max_size);
/// Platform-independent strcasecmp
static inline int Strcasecmp(const char* s1, const char* s2)
inline int Strcasecmp(const char* s1, const char* s2)
{
#ifdef _MSC_VER
return _stricmp(s1, s2);
@ -62,7 +62,7 @@ static inline int Strcasecmp(const char* s1, const char* s2)
}
/// Platform-independent strcasecmp
static inline int Strncasecmp(const char* s1, const char* s2, std::size_t n)
inline int Strncasecmp(const char* s1, const char* s2, std::size_t n)
{
#ifdef _MSC_VER
return _strnicmp(s1, s2, n);
@ -72,7 +72,7 @@ static inline int Strncasecmp(const char* s1, const char* s2, std::size_t n)
}
// Case-insensitive equality of string views.
static inline bool EqualNoCase(std::string_view s1, std::string_view s2)
inline bool EqualNoCase(std::string_view s1, std::string_view s2)
{
const size_t s1_len = s1.length();
const size_t s2_len = s2.length();
@ -83,7 +83,7 @@ static inline bool EqualNoCase(std::string_view s1, std::string_view s2)
return (Strncasecmp(s1.data(), s2.data(), s1_len) == 0);
}
static inline int CompareNoCase(std::string_view s1, std::string_view s2)
inline int CompareNoCase(std::string_view s1, std::string_view s2)
{
const size_t s1_len = s1.length();
const size_t s2_len = s2.length();
@ -91,7 +91,7 @@ static inline int CompareNoCase(std::string_view s1, std::string_view s2)
const int compare_res = (compare_len > 0) ? Strncasecmp(s1.data(), s2.data(), compare_len) : 0;
return (compare_len != 0) ? compare_res : ((s1_len < s2_len) ? -1 : ((s1_len > s2_len) ? 1 : 0));
}
static inline bool ContainsNoCase(std::string_view s1, std::string_view s2)
inline bool ContainsNoCase(std::string_view s1, std::string_view s2)
{
return (std::search(s1.begin(), s1.end(), s2.begin(), s2.end(),
[](char lhs, char rhs) { return (ToLower(lhs) == ToLower(rhs)); }) != s1.end());
@ -249,7 +249,7 @@ inline std::string ToChars(bool value, int base)
}
/// Returns true if the given character is whitespace.
ALWAYS_INLINE static bool IsWhitespace(char ch)
ALWAYS_INLINE bool IsWhitespace(char ch)
{
return ((ch >= 0x09 && ch <= 0x0D) || // horizontal tab, line feed, vertical tab, form feed, carriage return
ch == 0x20); // space
@ -261,14 +261,14 @@ size_t DecodeHex(std::span<u8> dest, const std::string_view str);
std::optional<std::vector<u8>> DecodeHex(const std::string_view str);
std::string EncodeHex(const void* data, size_t length);
template<typename T>
ALWAYS_INLINE static std::string EncodeHex(const std::span<const T> data)
ALWAYS_INLINE std::string EncodeHex(const std::span<const T> data)
{
return EncodeHex(data.data(), data.size_bytes());
}
/// Returns true if the character is a hexadecimal digit.
template<typename T>
ALWAYS_INLINE static bool IsHexDigit(T ch)
ALWAYS_INLINE bool IsHexDigit(T ch)
{
return ((ch >= static_cast<T>('a') && ch <= static_cast<T>('f')) ||
(ch >= static_cast<T>('A') && ch <= static_cast<T>('F')) ||
@ -277,7 +277,7 @@ ALWAYS_INLINE static bool IsHexDigit(T ch)
/// Returns a byte array from the provided hex string, computed at compile-time.
template<size_t Length>
static constexpr std::array<u8, Length> ParseFixedHexString(const char str[])
inline constexpr std::array<u8, Length> ParseFixedHexString(const char str[])
{
std::array<u8, Length> h{};
for (int i = 0; str[i] != '\0'; i++)
@ -297,7 +297,7 @@ static constexpr std::array<u8, Length> ParseFixedHexString(const char str[])
}
/// Encode/decode Base64 buffers.
static constexpr size_t DecodedBase64Length(const std::string_view str)
inline constexpr size_t DecodedBase64Length(const std::string_view str)
{
// Should be a multiple of 4.
const size_t str_length = str.length();
@ -314,7 +314,7 @@ static constexpr size_t DecodedBase64Length(const std::string_view str)
return (str_length / 4) * 3 - padding;
}
static constexpr size_t EncodedBase64Length(const std::span<const u8> data)
inline constexpr size_t EncodedBase64Length(const std::span<const u8> data)
{
return ((data.size() + 2) / 3) * 4;
}
@ -324,11 +324,11 @@ std::string EncodeBase64(const std::span<u8> data);
std::optional<std::vector<u8>> DecodeBase64(const std::string_view str);
/// StartsWith/EndsWith variants which aren't case sensitive.
ALWAYS_INLINE static bool StartsWithNoCase(const std::string_view str, const std::string_view prefix)
ALWAYS_INLINE bool StartsWithNoCase(const std::string_view str, const std::string_view prefix)
{
return (!str.empty() && Strncasecmp(str.data(), prefix.data(), prefix.length()) == 0);
}
ALWAYS_INLINE static bool EndsWithNoCase(const std::string_view str, const std::string_view suffix)
ALWAYS_INLINE bool EndsWithNoCase(const std::string_view str, const std::string_view suffix)
{
const std::size_t suffix_length = suffix.length();
return (str.length() >= suffix_length &&
@ -347,14 +347,14 @@ void StripWhitespace(std::string* str);
/// Returns true if the given string is found in the string list container.
template<typename T>
static inline bool IsInStringList(const T& list, const std::string_view str)
inline bool IsInStringList(const T& list, const std::string_view str)
{
return std::any_of(std::begin(list), std::end(list), [&str](const auto& it) { return (str == it); });
}
/// Adds a string to a string list container. No append is performed if the string already exists.
template<typename T>
static inline bool AddToStringList(T& list, const std::string_view str)
inline bool AddToStringList(T& list, const std::string_view str)
{
if (IsInStringList(list, str))
return false;
@ -365,7 +365,7 @@ static inline bool AddToStringList(T& list, const std::string_view str)
/// Removes a string from a string list container.
template<typename T>
static inline bool RemoveFromStringList(T& list, const std::string_view str)
inline bool RemoveFromStringList(T& list, const std::string_view str)
{
bool removed = false;
for (auto iter = std::begin(list); iter != std::end(list);)
@ -386,7 +386,7 @@ static inline bool RemoveFromStringList(T& list, const std::string_view str)
/// Joins a string together using the specified delimiter.
template<typename T>
static inline std::string JoinString(const T& start, const T& end, char delimiter)
inline std::string JoinString(const T& start, const T& end, char delimiter)
{
std::string ret;
for (auto it = start; it != end; ++it)
@ -398,12 +398,12 @@ static inline std::string JoinString(const T& start, const T& end, char delimite
return ret;
}
template<typename T>
static inline std::string JoinString(const T& list, char delimiter)
inline std::string JoinString(const T& list, char delimiter)
{
return JoinString(std::begin(list), std::end(list), delimiter);
}
template<typename T>
static inline std::string JoinString(const T& start, const T& end, const std::string_view delimiter)
inline std::string JoinString(const T& start, const T& end, const std::string_view delimiter)
{
std::string ret;
for (auto it = start; it != end; ++it)
@ -415,7 +415,7 @@ static inline std::string JoinString(const T& start, const T& end, const std::st
return ret;
}
template<typename T>
static inline std::string JoinString(const T& list, const std::string_view delimiter)
inline std::string JoinString(const T& list, const std::string_view delimiter)
{
return JoinString(std::begin(list), std::end(list), delimiter);
}
@ -477,8 +477,8 @@ void EllipsiseInPlace(std::string& str, u32 max_length, const char* ellipsis = "
std::optional<size_t> BytePatternSearch(const std::span<const u8> bytes, const std::string_view pattern);
/// Strided memcpy/memcmp.
ALWAYS_INLINE static void StrideMemCpy(void* dst, std::size_t dst_stride, const void* src, std::size_t src_stride,
std::size_t copy_size, std::size_t count)
ALWAYS_INLINE void StrideMemCpy(void* dst, std::size_t dst_stride, const void* src, std::size_t src_stride,
std::size_t copy_size, std::size_t count)
{
if (src_stride == dst_stride && src_stride == copy_size)
{
@ -496,8 +496,8 @@ ALWAYS_INLINE static void StrideMemCpy(void* dst, std::size_t dst_stride, const
}
}
ALWAYS_INLINE static int StrideMemCmp(const void* p1, std::size_t p1_stride, const void* p2, std::size_t p2_stride,
std::size_t copy_size, std::size_t count)
ALWAYS_INLINE int StrideMemCmp(const void* p1, std::size_t p1_stride, const void* p2, std::size_t p2_stride,
std::size_t copy_size, std::size_t count)
{
if (p1_stride == p2_stride && p1_stride == copy_size)
return std::memcmp(p1, p2, p1_stride * count);

@ -173,8 +173,6 @@ static bool InjectELF(const ELFFile& elf, bool set_pc, Error* error);
static void SetHandlers();
static void UpdateMappedRAMSize();
template<typename FP>
static FP* OffsetHandlerArray(void** handlers, MemoryAccessSize size, MemoryAccessType type);
} // namespace Bus
namespace MemoryMap {

@ -134,7 +134,7 @@ using MemoryWriteHandler = void (*)(VirtualMemoryAddress, u32);
void** GetMemoryHandlers(bool isolate_cache, bool swap_caches);
template<typename FP>
ALWAYS_INLINE_RELEASE static FP* OffsetHandlerArray(void** handlers, MemoryAccessSize size, MemoryAccessType type)
ALWAYS_INLINE_RELEASE FP* OffsetHandlerArray(void** handlers, MemoryAccessSize size, MemoryAccessType type)
{
return reinterpret_cast<FP*>(handlers +
(((static_cast<size_t>(size) * 2) + static_cast<size_t>(type)) * MEMORY_LUT_SIZE));
@ -158,19 +158,19 @@ extern std::array<TickCount, 3> g_cdrom_access_time;
extern std::array<TickCount, 3> g_spu_access_time;
/// Returns true if the address specified is writable (RAM).
ALWAYS_INLINE static bool IsRAMAddress(PhysicalMemoryAddress address)
ALWAYS_INLINE bool IsRAMAddress(PhysicalMemoryAddress address)
{
return address < RAM_MIRROR_END;
}
/// Returns the code page index for a RAM address.
ALWAYS_INLINE static u32 GetRAMCodePageIndex(PhysicalMemoryAddress address)
ALWAYS_INLINE u32 GetRAMCodePageIndex(PhysicalMemoryAddress address)
{
return (address & g_ram_mask) >> HOST_PAGE_SHIFT;
}
/// Returns true if the specified page contains code.
ALWAYS_INLINE static bool IsRAMCodePage(u32 index)
ALWAYS_INLINE bool IsRAMCodePage(u32 index)
{
return g_ram_code_bits[index];
}
@ -191,7 +191,7 @@ bool IsCodePageAddress(PhysicalMemoryAddress address);
bool HasCodePagesInRange(PhysicalMemoryAddress start_address, u32 size);
/// Returns the number of cycles stolen by DMA RAM access.
ALWAYS_INLINE static TickCount GetDMARAMTickCount(u32 word_count)
ALWAYS_INLINE TickCount GetDMARAMTickCount(u32 word_count)
{
// DMA is using DRAM Hyper Page mode, allowing it to access DRAM rows at 1 clock cycle per word (effectively around
// 17 clks per 16 words, due to required row address loading, probably plus some further minimal overload due to

@ -143,34 +143,35 @@ void Execute();
// Forces an early exit from the CPU dispatcher.
[[noreturn]] void ExitExecution();
ALWAYS_INLINE static Registers& GetRegs()
ALWAYS_INLINE Registers& GetRegs()
{
return g_state.regs;
}
ALWAYS_INLINE static u32 GetPendingTicks()
ALWAYS_INLINE u32 GetPendingTicks()
{
return g_state.pending_ticks;
}
ALWAYS_INLINE static void ResetPendingTicks()
ALWAYS_INLINE void ResetPendingTicks()
{
g_state.gte_completion_tick =
(g_state.pending_ticks < g_state.gte_completion_tick) ? (g_state.gte_completion_tick - g_state.pending_ticks) : 0;
g_state.muldiv_completion_tick =
(g_state.pending_ticks < g_state.muldiv_completion_tick) ? (g_state.muldiv_completion_tick - g_state.pending_ticks) : 0;
g_state.muldiv_completion_tick = (g_state.pending_ticks < g_state.muldiv_completion_tick) ?
(g_state.muldiv_completion_tick - g_state.pending_ticks) :
0;
g_state.pending_ticks = 0;
}
ALWAYS_INLINE static void AddPendingTicks(TickCount ticks)
ALWAYS_INLINE void AddPendingTicks(TickCount ticks)
{
g_state.pending_ticks += static_cast<u32>(ticks);
}
// state helpers
ALWAYS_INLINE static bool InUserMode()
ALWAYS_INLINE bool InUserMode()
{
return g_state.cop0_regs.sr.KUc;
}
ALWAYS_INLINE static bool InKernelMode()
ALWAYS_INLINE bool InKernelMode()
{
return !g_state.cop0_regs.sr.KUc;
}

@ -24,13 +24,13 @@ void RaiseException(Exception excode);
void RaiseException(u32 CAUSE_bits, u32 EPC);
void RaiseBreakException(u32 CAUSE_bits, u32 EPC, u32 instruction_bits);
ALWAYS_INLINE static bool HasPendingInterrupt()
ALWAYS_INLINE bool HasPendingInterrupt()
{
return g_state.cop0_regs.sr.IEc &&
(((g_state.cop0_regs.cause.bits & g_state.cop0_regs.sr.bits) & (UINT32_C(0xFF) << 8)) != 0);
}
ALWAYS_INLINE static void CheckForPendingInterrupt()
ALWAYS_INLINE void CheckForPendingInterrupt()
{
if (HasPendingInterrupt())
g_state.downcount = 0;
@ -42,40 +42,40 @@ void DispatchInterrupt();
fastjmp_buf* GetExecutionJmpBuf();
// icache stuff
ALWAYS_INLINE static bool IsCachedAddress(VirtualMemoryAddress address)
ALWAYS_INLINE bool IsCachedAddress(VirtualMemoryAddress address)
{
// KUSEG, KSEG0
return (address >> 29) <= 4;
}
ALWAYS_INLINE static u32 GetICacheLine(VirtualMemoryAddress address)
ALWAYS_INLINE u32 GetICacheLine(VirtualMemoryAddress address)
{
return ((address >> 4) & 0xFFu);
}
ALWAYS_INLINE static u32 GetICacheLineOffset(VirtualMemoryAddress address)
ALWAYS_INLINE u32 GetICacheLineOffset(VirtualMemoryAddress address)
{
return (address & (ICACHE_LINE_SIZE - 1));
}
ALWAYS_INLINE static u32 GetICacheLineWordOffset(VirtualMemoryAddress address)
ALWAYS_INLINE u32 GetICacheLineWordOffset(VirtualMemoryAddress address)
{
return (address >> 2) & 0x03u;
}
ALWAYS_INLINE static u32 GetICacheTagForAddress(VirtualMemoryAddress address)
ALWAYS_INLINE u32 GetICacheTagForAddress(VirtualMemoryAddress address)
{
return (address & ICACHE_TAG_ADDRESS_MASK);
}
ALWAYS_INLINE static u32 GetICacheFillTagForAddress(VirtualMemoryAddress address)
ALWAYS_INLINE u32 GetICacheFillTagForAddress(VirtualMemoryAddress address)
{
static const u32 invalid_bits[4] = {0, 1, 3, 7};
return GetICacheTagForAddress(address) | invalid_bits[(address >> 2) & 0x03u];
}
ALWAYS_INLINE static u32 GetICacheTagMaskForAddress(VirtualMemoryAddress address)
ALWAYS_INLINE u32 GetICacheTagMaskForAddress(VirtualMemoryAddress address)
{
static const u32 mask[4] = {ICACHE_TAG_ADDRESS_MASK | 1, ICACHE_TAG_ADDRESS_MASK | 2, ICACHE_TAG_ADDRESS_MASK | 4,
ICACHE_TAG_ADDRESS_MASK | 8};
return mask[(address >> 2) & 0x03u];
}
ALWAYS_INLINE static bool CompareICacheTag(VirtualMemoryAddress address)
ALWAYS_INLINE bool CompareICacheTag(VirtualMemoryAddress address)
{
const u32 line = GetICacheLine(address);
return ((g_state.icache_tags[line] & GetICacheTagMaskForAddress(address)) == GetICacheTagForAddress(address));
@ -86,7 +86,7 @@ TickCount GetICacheFillTicks(VirtualMemoryAddress address);
u32 FillICache(VirtualMemoryAddress address);
void CheckAndUpdateICacheTags(u32 line_count);
ALWAYS_INLINE static Segment GetSegmentForAddress(VirtualMemoryAddress address)
ALWAYS_INLINE Segment GetSegmentForAddress(VirtualMemoryAddress address)
{
switch ((address >> 29))
{
@ -109,13 +109,13 @@ ALWAYS_INLINE static Segment GetSegmentForAddress(VirtualMemoryAddress address)
}
}
ALWAYS_INLINE static constexpr PhysicalMemoryAddress VirtualAddressToPhysical(VirtualMemoryAddress address)
ALWAYS_INLINE constexpr PhysicalMemoryAddress VirtualAddressToPhysical(VirtualMemoryAddress address)
{
// KUSEG goes to the first 2GB, others are only 512MB.
return (address & ((address & 0x80000000u) ? KSEG_MASK : KUSEG_MASK));
}
ALWAYS_INLINE static VirtualMemoryAddress PhysicalAddressToVirtual(PhysicalMemoryAddress address, Segment segment)
ALWAYS_INLINE VirtualMemoryAddress PhysicalAddressToVirtual(PhysicalMemoryAddress address, Segment segment)
{
static constexpr std::array<VirtualMemoryAddress, 4> bases = {{0x00000000, 0x80000000, 0xA0000000, 0xE0000000}};
return bases[static_cast<u32>(segment)] | address;
@ -129,29 +129,29 @@ bool SafeReadInstruction(VirtualMemoryAddress addr, u32* value);
void* GetDirectReadMemoryPointer(VirtualMemoryAddress address, MemoryAccessSize size, TickCount* read_ticks);
void* GetDirectWriteMemoryPointer(VirtualMemoryAddress address, MemoryAccessSize size);
ALWAYS_INLINE static void AddGTETicks(TickCount ticks)
ALWAYS_INLINE void AddGTETicks(TickCount ticks)
{
g_state.gte_completion_tick = g_state.pending_ticks + ticks + 1;
}
ALWAYS_INLINE static void StallUntilGTEComplete()
ALWAYS_INLINE void StallUntilGTEComplete()
{
g_state.pending_ticks =
(g_state.gte_completion_tick > g_state.pending_ticks) ? g_state.gte_completion_tick : g_state.pending_ticks;
}
ALWAYS_INLINE static void AddMulDivTicks(TickCount ticks)
ALWAYS_INLINE void AddMulDivTicks(TickCount ticks)
{
g_state.muldiv_completion_tick = g_state.pending_ticks + ticks;
}
ALWAYS_INLINE static void StallUntilMulDivComplete()
ALWAYS_INLINE void StallUntilMulDivComplete()
{
g_state.pending_ticks =
(g_state.muldiv_completion_tick > g_state.pending_ticks) ? g_state.muldiv_completion_tick : g_state.pending_ticks;
}
ALWAYS_INLINE static constexpr TickCount GetMultTicks(s32 rs)
ALWAYS_INLINE constexpr TickCount GetMultTicks(s32 rs)
{
// Subtract one because of the instruction cycle.
if (rs < 0)
@ -160,12 +160,12 @@ ALWAYS_INLINE static constexpr TickCount GetMultTicks(s32 rs)
return (rs < 0x800) ? (6 - 1) : ((rs < 0x100000) ? (9 - 1) : (13 - 1));
}
ALWAYS_INLINE static constexpr TickCount GetMultTicks(u32 rs)
ALWAYS_INLINE constexpr TickCount GetMultTicks(u32 rs)
{
return (rs < 0x800) ? (6 - 1) : ((rs < 0x100000) ? (9 - 1) : (13 - 1));
}
ALWAYS_INLINE static constexpr TickCount GetDivTicks()
ALWAYS_INLINE constexpr TickCount GetDivTicks()
{
return (36 - 1);
}

@ -66,7 +66,7 @@ void CPU_MTC0(Instruction instr, u32 rdVal, u32 rtVal);
// Utility functions.
ALWAYS_INLINE static u32 PackMoveArgs(Reg rd, Reg rs)
ALWAYS_INLINE u32 PackMoveArgs(Reg rd, Reg rs)
{
return (static_cast<u32>(rd) << 8) | static_cast<u32>(rs);
}

@ -11,7 +11,6 @@ public:
GPUShaderGen(RenderAPI render_api, bool supports_dual_source_blend, bool supports_framebuffer_fetch);
~GPUShaderGen();
std::string GenerateDisplayVertexShader() const;
std::string GenerateDisplayFragmentShader(bool clamp_uv, bool nearest) const;
std::string GenerateDisplaySharpBilinearFragmentShader() const;
std::string GenerateDisplayLanczosFragmentShader() const;

@ -52,19 +52,19 @@ extern CopyVRAMFunction CopyVRAM;
extern void SelectImplementation();
ALWAYS_INLINE static DrawLineFunction GetDrawLineFunction(bool shading_enable, bool transparency_enable)
ALWAYS_INLINE DrawLineFunction GetDrawLineFunction(bool shading_enable, bool transparency_enable)
{
return (*DrawLineFunctions)[u8(shading_enable)][u8(transparency_enable)];
}
ALWAYS_INLINE static DrawRectangleFunction GetDrawRectangleFunction(bool texture_enable, bool raw_texture_enable,
bool transparency_enable)
ALWAYS_INLINE DrawRectangleFunction GetDrawRectangleFunction(bool texture_enable, bool raw_texture_enable,
bool transparency_enable)
{
return (*DrawRectangleFunctions)[u8(texture_enable)][u8(raw_texture_enable)][u8(transparency_enable)];
}
ALWAYS_INLINE static DrawTriangleFunction GetDrawTriangleFunction(bool shading_enable, bool texture_enable,
bool raw_texture_enable, bool transparency_enable)
ALWAYS_INLINE DrawTriangleFunction GetDrawTriangleFunction(bool shading_enable, bool texture_enable,
bool raw_texture_enable, bool transparency_enable)
{
return (
*DrawTriangleFunctions)[u8(shading_enable)][u8(texture_enable)][u8(raw_texture_enable)][u8(transparency_enable)];

@ -227,7 +227,7 @@ union GPUSTAT
}
};
ALWAYS_INLINE static constexpr u32 VRAMRGBA5551ToRGBA8888(u32 color)
ALWAYS_INLINE constexpr u32 VRAMRGBA5551ToRGBA8888(u32 color)
{
// Helper/format conversion functions - constants from https://stackoverflow.com/a/9069480
#define E5TO8(color) ((((color) * 527u) + 23u) >> 6)
@ -241,7 +241,7 @@ ALWAYS_INLINE static constexpr u32 VRAMRGBA5551ToRGBA8888(u32 color)
#undef E5TO8
}
ALWAYS_INLINE static constexpr u16 VRAMRGBA8888ToRGBA5551(u32 color)
ALWAYS_INLINE constexpr u16 VRAMRGBA8888ToRGBA5551(u32 color)
{
const u32 r = (color & 0xFFu) >> 3;
const u32 g = ((color >> 8) & 0xFFu) >> 3;
@ -252,12 +252,12 @@ ALWAYS_INLINE static constexpr u16 VRAMRGBA8888ToRGBA5551(u32 color)
#ifdef CPU_ARCH_SIMD
ALWAYS_INLINE static GSVector4i VRAM5BitTo8Bit(GSVector4i val)
ALWAYS_INLINE GSVector4i VRAM5BitTo8Bit(GSVector4i val)
{
return val.mul32l(GSVector4i::cxpr(527)).add32(GSVector4i::cxpr(23)).srl32<6>();
}
ALWAYS_INLINE static GSVector4i VRAMRGB5A1ToRGBA8888(GSVector4i val)
ALWAYS_INLINE GSVector4i VRAMRGB5A1ToRGBA8888(GSVector4i val)
{
static constexpr GSVector4i cmask = GSVector4i::cxpr(0x1F);
@ -270,7 +270,7 @@ ALWAYS_INLINE static GSVector4i VRAMRGB5A1ToRGBA8888(GSVector4i val)
}
template<GPUTexture::Format format>
ALWAYS_INLINE static void ConvertVRAMPixels(u8*& dest, GSVector4i c16)
ALWAYS_INLINE void ConvertVRAMPixels(u8*& dest, GSVector4i c16)
{
if constexpr (format == GPUTexture::Format::RGBA8)
{
@ -317,7 +317,7 @@ ALWAYS_INLINE static void ConvertVRAMPixels(u8*& dest, GSVector4i c16)
#endif
template<GPUTexture::Format format>
ALWAYS_INLINE static void ConvertVRAMPixel(u8*& dest, u16 c16)
ALWAYS_INLINE void ConvertVRAMPixel(u8*& dest, u16 c16)
{
if constexpr (format == GPUTexture::Format::RGBA8)
{
@ -354,7 +354,7 @@ union GPUVertexPosition
};
// Sprites/rectangles should be clipped to 11 bits before drawing.
static constexpr s32 TruncateGPUVertexPosition(s32 x)
inline constexpr s32 TruncateGPUVertexPosition(s32 x)
{
return SignExtendN<11, s32>(x);
}
@ -427,77 +427,77 @@ union GPUTextureWindow
}
};
ALWAYS_INLINE static constexpr u32 VRAMPageIndex(u32 px, u32 py)
ALWAYS_INLINE constexpr u32 VRAMPageIndex(u32 px, u32 py)
{
return ((py * VRAM_PAGES_WIDE) + px);
}
ALWAYS_INLINE static constexpr GSVector4i VRAMPageRect(u32 px, u32 py)
ALWAYS_INLINE constexpr GSVector4i VRAMPageRect(u32 px, u32 py)
{
return GSVector4i::cxpr(px * VRAM_PAGE_WIDTH, py * VRAM_PAGE_HEIGHT, (px + 1) * VRAM_PAGE_WIDTH,
(py + 1) * VRAM_PAGE_HEIGHT);
}
ALWAYS_INLINE static constexpr GSVector4i VRAMPageRect(u32 pn)
ALWAYS_INLINE constexpr GSVector4i VRAMPageRect(u32 pn)
{
// TODO: Put page rects in a LUT instead?
return VRAMPageRect(pn % VRAM_PAGES_WIDE, pn / VRAM_PAGES_WIDE);
}
ALWAYS_INLINE static constexpr u32 VRAMCoordinateToPage(u32 x, u32 y)
ALWAYS_INLINE constexpr u32 VRAMCoordinateToPage(u32 x, u32 y)
{
return VRAMPageIndex(x / VRAM_PAGE_WIDTH, y / VRAM_PAGE_HEIGHT);
}
ALWAYS_INLINE static constexpr u32 VRAMPageStartX(u32 pn)
ALWAYS_INLINE constexpr u32 VRAMPageStartX(u32 pn)
{
return (pn % VRAM_PAGES_WIDE) * VRAM_PAGE_WIDTH;
}
ALWAYS_INLINE static constexpr u32 VRAMPageStartY(u32 pn)
ALWAYS_INLINE constexpr u32 VRAMPageStartY(u32 pn)
{
return (pn / VRAM_PAGES_WIDE) * VRAM_PAGE_HEIGHT;
}
ALWAYS_INLINE static constexpr u8 GetTextureModeShift(GPUTextureMode mode)
ALWAYS_INLINE constexpr u8 GetTextureModeShift(GPUTextureMode mode)
{
return ((mode < GPUTextureMode::Direct16Bit) ? (2 - static_cast<u8>(mode)) : 0);
}
ALWAYS_INLINE static constexpr u32 ApplyTextureModeShift(GPUTextureMode mode, u32 vram_width)
ALWAYS_INLINE constexpr u32 ApplyTextureModeShift(GPUTextureMode mode, u32 vram_width)
{
return vram_width << GetTextureModeShift(mode);
}
ALWAYS_INLINE static GSVector4i ApplyTextureModeShift(GPUTextureMode mode, const GSVector4i rect)
ALWAYS_INLINE GSVector4i ApplyTextureModeShift(GPUTextureMode mode, const GSVector4i rect)
{
return rect.sll32(GetTextureModeShift(mode));
}
ALWAYS_INLINE static constexpr u32 TexturePageCountForMode(GPUTextureMode mode)
ALWAYS_INLINE constexpr u32 TexturePageCountForMode(GPUTextureMode mode)
{
return ((mode < GPUTextureMode::Direct16Bit) ? (1 + static_cast<u8>(mode)) : 4);
}
ALWAYS_INLINE static constexpr u32 TexturePageWidthForMode(GPUTextureMode mode)
ALWAYS_INLINE constexpr u32 TexturePageWidthForMode(GPUTextureMode mode)
{
return TEXTURE_PAGE_WIDTH >> GetTextureModeShift(mode);
}
ALWAYS_INLINE static constexpr bool TexturePageIsWrapping(GPUTextureMode mode, u32 pn)
ALWAYS_INLINE constexpr bool TexturePageIsWrapping(GPUTextureMode mode, u32 pn)
{
return ((VRAMPageStartX(pn) + TexturePageWidthForMode(mode)) > VRAM_WIDTH);
}
ALWAYS_INLINE static constexpr u32 PalettePageCountForMode(GPUTextureMode mode)
ALWAYS_INLINE constexpr u32 PalettePageCountForMode(GPUTextureMode mode)
{
return (mode == GPUTextureMode::Palette4Bit) ? 1 : 4;
}
ALWAYS_INLINE static constexpr u32 PalettePageNumber(GPUTexturePaletteReg reg)
ALWAYS_INLINE constexpr u32 PalettePageNumber(GPUTexturePaletteReg reg)
{
return VRAMCoordinateToPage(reg.GetXBase(), reg.GetYBase());
}
ALWAYS_INLINE static constexpr GSVector4i GetTextureRect(u32 pn, GPUTextureMode mode)
ALWAYS_INLINE constexpr GSVector4i GetTextureRect(u32 pn, GPUTextureMode mode)
{
u32 left = VRAMPageStartX(pn);
u32 top = VRAMPageStartY(pn);
@ -517,7 +517,7 @@ ALWAYS_INLINE static constexpr GSVector4i GetTextureRect(u32 pn, GPUTextureMode
return GSVector4i::cxpr(left, top, right, bottom);
}
ALWAYS_INLINE static constexpr GSVector4i GetTextureRectWithoutWrap(u32 pn, GPUTextureMode mode)
ALWAYS_INLINE constexpr GSVector4i GetTextureRectWithoutWrap(u32 pn, GPUTextureMode mode)
{
const u32 left = VRAMPageStartX(pn);
const u32 top = VRAMPageStartY(pn);
@ -527,14 +527,14 @@ ALWAYS_INLINE static constexpr GSVector4i GetTextureRectWithoutWrap(u32 pn, GPUT
}
/// Returns the maximum index for a paletted texture.
ALWAYS_INLINE static constexpr u32 GetPaletteWidth(GPUTextureMode mode)
ALWAYS_INLINE constexpr u32 GetPaletteWidth(GPUTextureMode mode)
{
return (mode == GPUTextureMode::Palette4Bit ? 16 : ((mode == GPUTextureMode::Palette8Bit) ? 256 : 0));
}
/// Returns a rectangle comprising the texture palette area.
ALWAYS_INLINE static constexpr GSVector4i GetPaletteRect(GPUTexturePaletteReg palette, GPUTextureMode mode,
bool clamp_instead_of_wrapping = false)
ALWAYS_INLINE constexpr GSVector4i GetPaletteRect(GPUTexturePaletteReg palette, GPUTextureMode mode,
bool clamp_instead_of_wrapping = false)
{
const u32 width = GetPaletteWidth(mode);
u32 left = palette.GetXBase();

@ -24,7 +24,7 @@
namespace ControllerSettingWidgetBinder {
/// Interface specific method of BindWidgetToBoolSetting().
template<typename WidgetType>
static void BindWidgetToInputProfileBool(SettingsInterface* sif, WidgetType* widget, std::string section,
inline void BindWidgetToInputProfileBool(SettingsInterface* sif, WidgetType* widget, std::string section,
std::string key, bool default_value)
{
using Accessor = SettingWidgetBinder::SettingAccessor<WidgetType>;
@ -57,7 +57,7 @@ static void BindWidgetToInputProfileBool(SettingsInterface* sif, WidgetType* wid
/// Interface specific method of BindWidgetToIntSetting().
template<typename WidgetType>
static void BindWidgetToInputProfileInt(SettingsInterface* sif, WidgetType* widget, std::string section,
inline void BindWidgetToInputProfileInt(SettingsInterface* sif, WidgetType* widget, std::string section,
std::string key, int default_value, int option_offset = 0)
{
using Accessor = SettingWidgetBinder::SettingAccessor<WidgetType>;
@ -92,7 +92,7 @@ static void BindWidgetToInputProfileInt(SettingsInterface* sif, WidgetType* widg
/// Interface specific method of BindWidgetToFloatSetting().
template<typename WidgetType>
static void BindWidgetToInputProfileFloat(SettingsInterface* sif, WidgetType* widget, std::string section,
inline void BindWidgetToInputProfileFloat(SettingsInterface* sif, WidgetType* widget, std::string section,
std::string key, float default_value)
{
using Accessor = SettingWidgetBinder::SettingAccessor<WidgetType>;
@ -125,7 +125,7 @@ static void BindWidgetToInputProfileFloat(SettingsInterface* sif, WidgetType* wi
/// Interface specific method of BindWidgetToNormalizedSetting().
template<typename WidgetType>
static void BindWidgetToInputProfileNormalized(SettingsInterface* sif, WidgetType* widget, std::string section,
inline void BindWidgetToInputProfileNormalized(SettingsInterface* sif, WidgetType* widget, std::string section,
std::string key, float range, float default_value)
{
using Accessor = SettingWidgetBinder::SettingAccessor<WidgetType>;
@ -158,7 +158,7 @@ static void BindWidgetToInputProfileNormalized(SettingsInterface* sif, WidgetTyp
/// Interface specific method of BindWidgetToStringSetting().
template<typename WidgetType>
static void BindWidgetToInputProfileString(SettingsInterface* sif, WidgetType* widget, std::string section,
inline void BindWidgetToInputProfileString(SettingsInterface* sif, WidgetType* widget, std::string section,
std::string key, std::string default_value = std::string())
{
using Accessor = SettingWidgetBinder::SettingAccessor<WidgetType>;
@ -194,7 +194,7 @@ static void BindWidgetToInputProfileString(SettingsInterface* sif, WidgetType* w
/// Interface specific method of BindWidgetToEnumSetting().
template<typename WidgetType, typename DataType, typename ValueCountType>
static void BindWidgetToInputProfileEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section,
inline void BindWidgetToInputProfileEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section,
std::string key,
std::optional<DataType> (*from_string_function)(const char* str),
const char* (*to_string_function)(DataType value),

@ -56,7 +56,7 @@ void ShowOrRaiseWindow(QWidget* window);
/// Closes and deletes a window later, outside of this event pump.
template<typename T>
[[maybe_unused]] static void CloseAndDeleteWindow(T*& window)
inline void CloseAndDeleteWindow(T*& window)
{
if (!window)
return;
@ -129,8 +129,7 @@ bool RestoreWindowGeometry(std::string_view window_name, QWidget* widget);
/// CPU-friendly way of blocking the UI thread while some predicate holds true.
template<typename Predicate>
[[maybe_unused]] static void ProcessEventsWithSleep(QEventLoop::ProcessEventsFlags flags, const Predicate& pred,
int sleep_time_ms = 10)
inline void ProcessEventsWithSleep(QEventLoop::ProcessEventsFlags flags, const Predicate& pred, int sleep_time_ms = 10)
{
if (sleep_time_ms == 0)
{

@ -745,7 +745,7 @@ struct SettingAccessor<QAction>
/// Binds a widget's value to a setting, updating it when the value changes.
template<typename WidgetType>
static void BindWidgetToBoolSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToBoolSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
bool default_value)
{
using Accessor = SettingAccessor<WidgetType>;
@ -786,7 +786,7 @@ static void BindWidgetToBoolSetting(SettingsInterface* sif, WidgetType* widget,
}
template<typename WidgetType>
static void BindWidgetToIntSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToIntSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
int default_value, int option_offset = 0)
{
using Accessor = SettingAccessor<WidgetType>;
@ -830,7 +830,7 @@ static void BindWidgetToIntSetting(SettingsInterface* sif, WidgetType* widget, s
}
template<typename WidgetType>
static void BindWidgetToIntSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToIntSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
int default_value, std::span<const int> values)
{
using Accessor = SettingAccessor<WidgetType>;
@ -881,9 +881,9 @@ static void BindWidgetToIntSetting(SettingsInterface* sif, WidgetType* widget, s
}
template<typename WidgetType>
static inline void BindWidgetAndLabelToIntSetting(SettingsInterface* sif, WidgetType* widget, QLabel* label,
const QString& label_suffix, std::string section, std::string key,
int default_value, int option_offset = 0)
inline void BindWidgetAndLabelToIntSetting(SettingsInterface* sif, WidgetType* widget, QLabel* label,
const QString& label_suffix, std::string section, std::string key,
int default_value, int option_offset = 0)
{
using Accessor = SettingAccessor<WidgetType>;
@ -962,7 +962,7 @@ static inline void BindWidgetAndLabelToIntSetting(SettingsInterface* sif, Widget
}
template<typename WidgetType>
static void BindWidgetToFloatSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToFloatSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
float default_value)
{
using Accessor = SettingAccessor<WidgetType>;
@ -1003,7 +1003,7 @@ static void BindWidgetToFloatSetting(SettingsInterface* sif, WidgetType* widget,
}
template<typename WidgetType>
static void BindWidgetToNormalizedSetting(SettingsInterface* sif, WidgetType* widget, std::string section,
inline void BindWidgetToNormalizedSetting(SettingsInterface* sif, WidgetType* widget, std::string section,
std::string key, float range, float default_value)
{
using Accessor = SettingAccessor<WidgetType>;
@ -1044,7 +1044,7 @@ static void BindWidgetToNormalizedSetting(SettingsInterface* sif, WidgetType* wi
}
template<typename WidgetType>
static void BindWidgetToStringSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToStringSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
std::string default_value = std::string())
{
using Accessor = SettingAccessor<WidgetType>;
@ -1086,7 +1086,7 @@ static void BindWidgetToStringSetting(SettingsInterface* sif, WidgetType* widget
}
template<typename WidgetType, typename DataType>
static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
std::optional<DataType> (*from_string_function)(const char* str),
const char* (*to_string_function)(DataType value), DataType default_value)
{
@ -1152,7 +1152,7 @@ static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget,
}
template<typename WidgetType, typename DataType, typename ValueCountType>
static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
std::optional<DataType> (*from_string_function)(const char* str),
const char* (*to_string_function)(DataType value),
const char* (*to_display_name_function)(DataType value), DataType default_value,
@ -1223,7 +1223,7 @@ static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget,
}
template<typename DataType, typename ValueCountType>
static void BindMenuToEnumSetting(QMenu* menu, std::string section, std::string key,
inline void BindMenuToEnumSetting(QMenu* menu, std::string section, std::string key,
std::optional<DataType> (*from_string_function)(const char* str),
const char* (*to_string_function)(DataType value),
const char* (*to_display_name_function)(DataType value), DataType default_value,
@ -1260,7 +1260,7 @@ static void BindMenuToEnumSetting(QMenu* menu, std::string section, std::string
}
template<typename WidgetType, typename DataType>
static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
const char** enum_names, DataType default_value)
{
using Accessor = SettingAccessor<WidgetType>;
@ -1323,7 +1323,7 @@ static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget,
}
template<typename WidgetType>
static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
inline void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget, std::string section, std::string key,
const char** enum_names, const char** enum_values, const char* default_value,
const char* translation_ctx = nullptr)
{
@ -1391,10 +1391,10 @@ static void BindWidgetToEnumSetting(SettingsInterface* sif, WidgetType* widget,
}
}
static inline void BindWidgetToFolderSetting(SettingsInterface* sif, QLineEdit* widget, QAbstractButton* browse_button,
QString browse_title, QAbstractButton* open_button,
QAbstractButton* reset_button, std::string section, std::string key,
std::string default_value, bool use_relative = true)
inline void BindWidgetToFolderSetting(SettingsInterface* sif, QLineEdit* widget, QAbstractButton* browse_button,
QString browse_title, QAbstractButton* open_button, QAbstractButton* reset_button,
std::string section, std::string key, std::string default_value,
bool use_relative = true)
{
using Accessor = SettingAccessor<QLineEdit>;
@ -1497,14 +1497,14 @@ static inline void BindWidgetToFolderSetting(SettingsInterface* sif, QLineEdit*
}
template<typename WidgetType>
static inline void DisconnectWidget(WidgetType* widget)
inline void DisconnectWidget(WidgetType* widget)
{
using Accessor = SettingAccessor<WidgetType>;
Accessor::disconnect(widget);
}
template<typename WidgetType>
static inline void SetAvailability(WidgetType* widget, bool available, QLabel* widget_label = nullptr)
inline void SetAvailability(WidgetType* widget, bool available, QLabel* widget_label = nullptr)
{
if (available)
return;

@ -127,7 +127,7 @@ private:
#ifdef ENABLE_GPU_OBJECT_NAMES
void SetObjectName(ID3D12Object* object, std::string_view name);
#else
static inline void SetObjectName(ID3D12Object* object, std::string_view name)
inline void SetObjectName(ID3D12Object* object, std::string_view name)
{
}
#endif

@ -106,45 +106,45 @@ struct ALIGN_TO_CACHE_LINE UIStyles
extern UIStyles UIStyle;
ALWAYS_INLINE static float LayoutScale(float v)
ALWAYS_INLINE float LayoutScale(float v)
{
return ImCeil(UIStyle.LayoutScale * v);
}
ALWAYS_INLINE static ImVec2 LayoutScale(const ImVec2& v)
ALWAYS_INLINE ImVec2 LayoutScale(const ImVec2& v)
{
return ImVec2(ImCeil(v.x * UIStyle.LayoutScale), ImCeil(v.y * UIStyle.LayoutScale));
}
ALWAYS_INLINE static ImVec2 LayoutScale(float x, float y)
ALWAYS_INLINE ImVec2 LayoutScale(float x, float y)
{
return ImVec2(ImCeil(x * UIStyle.LayoutScale), ImCeil(y * UIStyle.LayoutScale));
}
ALWAYS_INLINE static float LayoutUnscale(float v)
ALWAYS_INLINE float LayoutUnscale(float v)
{
return ImCeil(UIStyle.RcpLayoutScale * v);
}
ALWAYS_INLINE static ImVec2 LayoutUnscale(const ImVec2& v)
ALWAYS_INLINE ImVec2 LayoutUnscale(const ImVec2& v)
{
return ImVec2(ImCeil(v.x * UIStyle.RcpLayoutScale), ImCeil(v.y * UIStyle.RcpLayoutScale));
}
ALWAYS_INLINE static ImVec2 LayoutUnscale(float x, float y)
ALWAYS_INLINE ImVec2 LayoutUnscale(float x, float y)
{
return ImVec2(ImCeil(x * UIStyle.RcpLayoutScale), ImCeil(y * UIStyle.RcpLayoutScale));
}
ALWAYS_INLINE static ImVec4 ModAlpha(const ImVec4& v, float a)
ALWAYS_INLINE ImVec4 ModAlpha(const ImVec4& v, float a)
{
return ImVec4(v.x, v.y, v.z, a);
}
ALWAYS_INLINE static u32 ModAlpha(u32 col32, float a)
ALWAYS_INLINE u32 ModAlpha(u32 col32, float a)
{
return (col32 & ~IM_COL32_A_MASK) | (static_cast<u32>(a * 255.0f) << IM_COL32_A_SHIFT);
}
// lighter in light themes
ALWAYS_INLINE static ImVec4 DarkerColor(const ImVec4& v, float f = 0.8f)
ALWAYS_INLINE ImVec4 DarkerColor(const ImVec4& v, float f = 0.8f)
{
// light theme
f = (UIStyle.PrimaryTextColor.x < UIStyle.PrimaryColor.x) ? (1.0f / f) : f;
@ -152,25 +152,25 @@ ALWAYS_INLINE static ImVec4 DarkerColor(const ImVec4& v, float f = 0.8f)
v.w);
}
ALWAYS_INLINE static ImVec4 MulAlpha(const ImVec4& v, float a)
ALWAYS_INLINE ImVec4 MulAlpha(const ImVec4& v, float a)
{
return ImVec4(v.x, v.y, v.z, v.w * a);
}
ALWAYS_INLINE static u32 MulAlpha(u32 col32, float a)
ALWAYS_INLINE u32 MulAlpha(u32 col32, float a)
{
return (col32 & ~IM_COL32_A_MASK) |
(static_cast<u32>(static_cast<float>((col32 /*& IM_COL32_A_MASK*/) >> IM_COL32_A_SHIFT) * a)
<< IM_COL32_A_SHIFT);
}
ALWAYS_INLINE static u32 MulAlpha(u32 col32, u32 a)
ALWAYS_INLINE u32 MulAlpha(u32 col32, u32 a)
{
return (col32 & ~IM_COL32_A_MASK) |
(((((col32 /*& IM_COL32_A_MASK*/) >> IM_COL32_A_SHIFT) * a) / 255u) << IM_COL32_A_SHIFT);
}
ALWAYS_INLINE static std::string_view RemoveHash(std::string_view s)
ALWAYS_INLINE std::string_view RemoveHash(std::string_view s)
{
const std::string_view::size_type pos = s.find("##");
return (pos != std::string_view::npos) ? s.substr(0, pos) : s;

@ -394,7 +394,7 @@ struct VkObjectTypeMap;
#endif
template<typename T>
static inline void SetObjectName(VkDevice device, T object_handle, const std::string_view name)
inline void SetObjectName(VkDevice device, T object_handle, const std::string_view name)
{
#ifdef ENABLE_VULKAN_DEBUG_OBJECTS
if (!vkSetDebugUtilsObjectNameEXT)

Loading…
Cancel
Save