summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt35
-rw-r--r--src/common/algorithm.h (renamed from src/common/binary_find.h)6
-rw-r--r--src/common/alignment.h10
-rw-r--r--src/common/bit_field.h11
-rw-r--r--src/common/common_funcs.h26
-rw-r--r--src/common/file_util.cpp3
-rw-r--r--src/common/hash.h40
-rw-r--r--src/common/logging/backend.cpp8
-rw-r--r--src/common/multi_level_queue.h7
-rw-r--r--src/common/scm_rev.cpp.in6
-rw-r--r--src/common/scm_rev.h3
11 files changed, 93 insertions, 62 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index dfed8b51d..9b0c3db68 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -3,23 +3,26 @@
# could affect the result, but much more unlikely than the following files. Keeping a list of files
# like this allows for much better caching since it doesn't force the user to recompile binary shaders every update
set(VIDEO_CORE "${CMAKE_SOURCE_DIR}/src/video_core")
-if (DEFINED ENV{CI})
- if (DEFINED ENV{TRAVIS})
- set(BUILD_REPOSITORY $ENV{TRAVIS_REPO_SLUG})
- set(BUILD_TAG $ENV{TRAVIS_TAG})
- elseif(DEFINED ENV{APPVEYOR})
- set(BUILD_REPOSITORY $ENV{APPVEYOR_REPO_NAME})
- set(BUILD_TAG $ENV{APPVEYOR_REPO_TAG_NAME})
- elseif(DEFINED ENV{AZURE})
- set(BUILD_REPOSITORY $ENV{AZURE_REPO_NAME})
- set(BUILD_TAG $ENV{AZURE_REPO_TAG})
- endif()
+if (DEFINED ENV{AZURECIREPO})
+ set(BUILD_REPOSITORY $ENV{AZURECIREPO})
endif()
+if (DEFINED ENV{TITLEBARFORMATIDLE})
+ set(TITLE_BAR_FORMAT_IDLE $ENV{TITLEBARFORMATIDLE})
+endif ()
+if (DEFINED ENV{TITLEBARFORMATRUNNING})
+ set(TITLE_BAR_FORMAT_RUNNING $ENV{TITLEBARFORMATRUNNING})
+endif ()
+if (DEFINED ENV{DISPLAYVERSION})
+ set(DISPLAY_VERSION $ENV{DISPLAYVERSION})
+endif ()
add_custom_command(OUTPUT scm_rev.cpp
COMMAND ${CMAKE_COMMAND}
-DSRC_DIR="${CMAKE_SOURCE_DIR}"
-DBUILD_REPOSITORY="${BUILD_REPOSITORY}"
+ -DTITLE_BAR_FORMAT_IDLE="${TITLE_BAR_FORMAT_IDLE}"
+ -DTITLE_BAR_FORMAT_RUNNING="${TITLE_BAR_FORMAT_RUNNING}"
-DBUILD_TAG="${BUILD_TAG}"
+ -DBUILD_ID="${DISPLAY_VERSION}"
-P "${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake"
DEPENDS
# WARNING! It was too much work to try and make a common location for this list,
@@ -60,9 +63,17 @@ add_custom_command(OUTPUT scm_rev.cpp
"${VIDEO_CORE}/shader/decode/video.cpp"
"${VIDEO_CORE}/shader/decode/warp.cpp"
"${VIDEO_CORE}/shader/decode/xmad.cpp"
+ "${VIDEO_CORE}/shader/ast.cpp"
+ "${VIDEO_CORE}/shader/ast.h"
+ "${VIDEO_CORE}/shader/compiler_settings.cpp"
+ "${VIDEO_CORE}/shader/compiler_settings.h"
+ "${VIDEO_CORE}/shader/const_buffer_locker.cpp"
+ "${VIDEO_CORE}/shader/const_buffer_locker.h"
"${VIDEO_CORE}/shader/control_flow.cpp"
"${VIDEO_CORE}/shader/control_flow.h"
"${VIDEO_CORE}/shader/decode.cpp"
+ "${VIDEO_CORE}/shader/expr.cpp"
+ "${VIDEO_CORE}/shader/expr.h"
"${VIDEO_CORE}/shader/node.h"
"${VIDEO_CORE}/shader/node_helper.cpp"
"${VIDEO_CORE}/shader/node_helper.h"
@@ -77,11 +88,11 @@ add_custom_command(OUTPUT scm_rev.cpp
)
add_library(common STATIC
+ algorithm.h
alignment.h
assert.h
detached_tasks.cpp
detached_tasks.h
- binary_find.h
bit_field.h
bit_util.h
cityhash.cpp
diff --git a/src/common/binary_find.h b/src/common/algorithm.h
index 5cc523bf9..e21b1373c 100644
--- a/src/common/binary_find.h
+++ b/src/common/algorithm.h
@@ -5,6 +5,12 @@
#pragma once
#include <algorithm>
+#include <functional>
+
+// Algorithms that operate on iterators, much like the <algorithm> header.
+//
+// Note: If the algorithm is not general-purpose and/or doesn't operate on iterators,
+// it should probably not be placed within this header.
namespace Common {
diff --git a/src/common/alignment.h b/src/common/alignment.h
index 88d5d3a65..cdd4833f8 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -51,7 +51,17 @@ public:
using reference = T&;
using const_reference = const T&;
+ using propagate_on_container_copy_assignment = std::true_type;
+ using propagate_on_container_move_assignment = std::true_type;
+ using propagate_on_container_swap = std::true_type;
+ using is_always_equal = std::true_type;
+
public:
+ constexpr AlignmentAllocator() noexcept = default;
+
+ template <typename T2>
+ constexpr AlignmentAllocator(const AlignmentAllocator<T2, Align>&) noexcept {}
+
pointer address(reference r) noexcept {
return std::addressof(r);
}
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index 902e668e3..fd2bbbd99 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -36,6 +36,13 @@
#include "common/common_funcs.h"
#include "common/swap.h"
+// Inlining
+#ifdef _WIN32
+#define FORCE_INLINE __forceinline
+#else
+#define FORCE_INLINE inline __attribute__((always_inline))
+#endif
+
/*
* Abstract bitfield class
*
@@ -168,11 +175,11 @@ public:
constexpr BitField(BitField&&) noexcept = default;
constexpr BitField& operator=(BitField&&) noexcept = default;
- constexpr FORCE_INLINE operator T() const {
+ constexpr operator T() const {
return Value();
}
- constexpr FORCE_INLINE void Assign(const T& value) {
+ constexpr void Assign(const T& value) {
storage = (static_cast<StorageType>(storage) & ~mask) | FormatValue(value);
}
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 04ecac959..052254678 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -1,10 +1,11 @@
-// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
+// Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <algorithm>
+#include <array>
#include <string>
#if !defined(ARCHITECTURE_x86_64)
@@ -16,18 +17,17 @@
#define CONCAT2(x, y) DO_CONCAT2(x, y)
#define DO_CONCAT2(x, y) x##y
-// helper macro to properly align structure members.
-// Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121",
-// depending on the current source line to make sure variable names are unique.
-#define INSERT_PADDING_BYTES(num_bytes) u8 CONCAT2(pad, __LINE__)[(num_bytes)]
-#define INSERT_PADDING_WORDS(num_words) u32 CONCAT2(pad, __LINE__)[(num_words)]
+/// Helper macros to insert unused bytes or words to properly align structs. These values will be
+/// zero-initialized.
+#define INSERT_PADDING_BYTES(num_bytes) \
+ std::array<u8, num_bytes> CONCAT2(pad, __LINE__) {}
+#define INSERT_PADDING_WORDS(num_words) \
+ std::array<u32, num_words> CONCAT2(pad, __LINE__) {}
-// Inlining
-#ifdef _WIN32
-#define FORCE_INLINE __forceinline
-#else
-#define FORCE_INLINE inline __attribute__((always_inline))
-#endif
+/// These are similar to the INSERT_PADDING_* macros, but are needed for padding unions. This is
+/// because unions can only be initialized by one member.
+#define INSERT_UNION_PADDING_BYTES(num_bytes) std::array<u8, num_bytes> CONCAT2(pad, __LINE__)
+#define INSERT_UNION_PADDING_WORDS(num_words) std::array<u32, num_words> CONCAT2(pad, __LINE__)
#ifndef _MSC_VER
@@ -58,7 +58,7 @@ std::string GetLastErrorMsg();
namespace Common {
constexpr u32 MakeMagic(char a, char b, char c, char d) {
- return a | b << 8 | c << 16 | d << 24;
+ return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24;
}
} // namespace Common
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 2d9374783..41167f57a 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -713,7 +713,6 @@ const std::string& GetUserPath(UserPath path, const std::string& new_path) {
case UserPath::RootDir:
user_path = paths[UserPath::RootDir] + DIR_SEP;
break;
-
case UserPath::UserDir:
user_path = paths[UserPath::RootDir] + DIR_SEP;
paths[UserPath::ConfigDir] = user_path + CONFIG_DIR DIR_SEP;
@@ -721,6 +720,8 @@ const std::string& GetUserPath(UserPath path, const std::string& new_path) {
paths[UserPath::SDMCDir] = user_path + SDMC_DIR DIR_SEP;
paths[UserPath::NANDDir] = user_path + NAND_DIR DIR_SEP;
break;
+ default:
+ break;
}
}
diff --git a/src/common/hash.h b/src/common/hash.h
index 40194d1ee..b2538f3ea 100644
--- a/src/common/hash.h
+++ b/src/common/hash.h
@@ -6,6 +6,8 @@
#include <cstddef>
#include <cstring>
+#include <utility>
+#include <boost/functional/hash.hpp>
#include "common/cityhash.h"
#include "common/common_types.h"
@@ -33,38 +35,12 @@ static inline u64 ComputeStructHash64(const T& data) {
return ComputeHash64(&data, sizeof(data));
}
-/// A helper template that ensures the padding in a struct is initialized by memsetting to 0.
-template <typename T>
-struct HashableStruct {
- // In addition to being trivially copyable, T must also have a trivial default constructor,
- // because any member initialization would be overridden by memset
- static_assert(std::is_trivial_v<T>, "Type passed to HashableStruct must be trivial");
- /*
- * We use a union because "implicitly-defined copy/move constructor for a union X copies the
- * object representation of X." and "implicitly-defined copy assignment operator for a union X
- * copies the object representation (3.9) of X." = Bytewise copy instead of memberwise copy.
- * This is important because the padding bytes are included in the hash and comparison between
- * objects.
- */
- union {
- T state;
- };
-
- HashableStruct() {
- // Memset structure to zero padding bits, so that they will be deterministic when hashing
- std::memset(&state, 0, sizeof(T));
- }
-
- bool operator==(const HashableStruct<T>& o) const {
- return std::memcmp(&state, &o.state, sizeof(T)) == 0;
- };
-
- bool operator!=(const HashableStruct<T>& o) const {
- return !(*this == o);
- };
-
- std::size_t Hash() const {
- return Common::ComputeStructHash64(state);
+struct PairHash {
+ template <class T1, class T2>
+ std::size_t operator()(const std::pair<T1, T2>& pair) const noexcept {
+ std::size_t seed = std::hash<T1>()(pair.first);
+ boost::hash_combine(seed, std::hash<T2>()(pair.second));
+ return seed;
}
};
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 1111cfbad..8f2591d53 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -272,8 +272,10 @@ const char* GetLogClassName(Class log_class) {
#undef CLS
#undef SUB
case Class::Count:
- UNREACHABLE();
+ break;
}
+ UNREACHABLE();
+ return "Invalid";
}
const char* GetLevelName(Level log_level) {
@@ -288,9 +290,11 @@ const char* GetLevelName(Level log_level) {
LVL(Error);
LVL(Critical);
case Level::Count:
- UNREACHABLE();
+ break;
}
#undef LVL
+ UNREACHABLE();
+ return "Invalid";
}
void SetGlobalFilter(const Filter& filter) {
diff --git a/src/common/multi_level_queue.h b/src/common/multi_level_queue.h
index 9cb448f56..50acfdbf2 100644
--- a/src/common/multi_level_queue.h
+++ b/src/common/multi_level_queue.h
@@ -304,6 +304,13 @@ public:
return levels[priority == Depth ? 63 : priority].back();
}
+ void clear() {
+ used_priorities = 0;
+ for (std::size_t i = 0; i < Depth; i++) {
+ levels[i].clear();
+ }
+ }
+
private:
using const_list_iterator = typename std::list<T>::const_iterator;
diff --git a/src/common/scm_rev.cpp.in b/src/common/scm_rev.cpp.in
index d69038f65..5f126f324 100644
--- a/src/common/scm_rev.cpp.in
+++ b/src/common/scm_rev.cpp.in
@@ -11,6 +11,9 @@
#define BUILD_DATE "@BUILD_DATE@"
#define BUILD_FULLNAME "@BUILD_FULLNAME@"
#define BUILD_VERSION "@BUILD_VERSION@"
+#define BUILD_ID "@BUILD_ID@"
+#define TITLE_BAR_FORMAT_IDLE "@TITLE_BAR_FORMAT_IDLE@"
+#define TITLE_BAR_FORMAT_RUNNING "@TITLE_BAR_FORMAT_RUNNING@"
#define SHADER_CACHE_VERSION "@SHADER_CACHE_VERSION@"
namespace Common {
@@ -22,6 +25,9 @@ const char g_build_name[] = BUILD_NAME;
const char g_build_date[] = BUILD_DATE;
const char g_build_fullname[] = BUILD_FULLNAME;
const char g_build_version[] = BUILD_VERSION;
+const char g_build_id[] = BUILD_ID;
+const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
+const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
const char g_shader_cache_version[] = SHADER_CACHE_VERSION;
} // namespace
diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h
index 666bf0367..563015ec9 100644
--- a/src/common/scm_rev.h
+++ b/src/common/scm_rev.h
@@ -13,6 +13,9 @@ extern const char g_build_name[];
extern const char g_build_date[];
extern const char g_build_fullname[];
extern const char g_build_version[];
+extern const char g_build_id[];
+extern const char g_title_bar_format_idle[];
+extern const char g_title_bar_format_running[];
extern const char g_shader_cache_version[];
} // namespace Common