summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt7
-rw-r--r--src/common/bit_field.h65
-rw-r--r--src/common/common_funcs.h2
-rw-r--r--src/common/framebuffer_layout.cpp157
-rw-r--r--src/common/framebuffer_layout.h55
-rw-r--r--src/common/hash.cpp6
-rw-r--r--src/common/telemetry.cpp40
-rw-r--r--src/common/telemetry.h196
-rw-r--r--src/common/vector_math.h10
-rw-r--r--src/common/x64/cpu_detect.cpp2
10 files changed, 297 insertions, 243 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 4b30185f1..7e83e64b0 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -27,7 +27,6 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOU
set(SRCS
break_points.cpp
file_util.cpp
- framebuffer_layout.cpp
hash.cpp
logging/filter.cpp
logging/text_formatter.cpp
@@ -38,6 +37,7 @@ set(SRCS
param_package.cpp
scm_rev.cpp
string_util.cpp
+ telemetry.cpp
thread.cpp
timer.cpp
)
@@ -55,7 +55,6 @@ set(HEADERS
common_paths.h
common_types.h
file_util.h
- framebuffer_layout.h
hash.h
linear_disk_cache.h
logging/text_formatter.h
@@ -74,6 +73,7 @@ set(HEADERS
string_util.h
swap.h
synchronized_wrapper.h
+ telemetry.h
thread.h
thread_queue_list.h
timer.h
@@ -95,6 +95,7 @@ endif()
create_directory_groups(${SRCS} ${HEADERS})
add_library(common STATIC ${SRCS} ${HEADERS})
+target_link_libraries(common PUBLIC Boost::boost microprofile)
if (ARCHITECTURE_x86_64)
- target_link_libraries(common xbyak)
+ target_link_libraries(common PRIVATE xbyak)
endif()
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index 030f7caeb..0cc0a1be0 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -108,7 +108,7 @@
* symptoms.
*/
#pragma pack(1)
-template <std::size_t position, std::size_t bits, typename T>
+template <std::size_t Position, std::size_t Bits, typename T>
struct BitField {
private:
// We hide the copy assigment operator here, because the default copy
@@ -117,7 +117,45 @@ private:
// We don't delete it because we want BitField to be trivially copyable.
BitField& operator=(const BitField&) = default;
+ // StorageType is T for non-enum types and the underlying type of T if
+ // T is an enumeration. Note that T is wrapped within an enable_if in the
+ // former case to workaround compile errors which arise when using
+ // std::underlying_type<T>::type directly.
+ using StorageType = typename std::conditional_t<std::is_enum<T>::value, std::underlying_type<T>,
+ std::enable_if<true, T>>::type;
+
+ // Unsigned version of StorageType
+ using StorageTypeU = std::make_unsigned_t<StorageType>;
+
public:
+ /// Constants to allow limited introspection of fields if needed
+ static constexpr size_t position = Position;
+ static constexpr size_t bits = Bits;
+ static constexpr StorageType mask = (((StorageTypeU)~0) >> (8 * sizeof(T) - bits)) << position;
+
+ /**
+ * Formats a value by masking and shifting it according to the field parameters. A value
+ * containing several bitfields can be assembled by formatting each of their values and ORing
+ * the results together.
+ */
+ static constexpr FORCE_INLINE StorageType FormatValue(const T& value) {
+ return ((StorageType)value << position) & mask;
+ }
+
+ /**
+ * Extracts a value from the passed storage. In most situations prefer use the member functions
+ * (such as Value() or operator T), but this can be used to extract a value from a bitfield
+ * union in a constexpr context.
+ */
+ static constexpr FORCE_INLINE T ExtractValue(const StorageType& storage) {
+ if (std::numeric_limits<T>::is_signed) {
+ std::size_t shift = 8 * sizeof(T) - bits;
+ return (T)((storage << (shift - position)) >> shift);
+ } else {
+ return (T)((storage & mask) >> position);
+ }
+ }
+
// This constructor and assignment operator might be considered ambiguous:
// Would they initialize the storage or just the bitfield?
// Hence, delete them. Use the Assign method to set bitfield values!
@@ -126,23 +164,18 @@ public:
// Force default constructor to be created
// so that we can use this within unions
- BitField() = default;
+ constexpr BitField() = default;
FORCE_INLINE operator T() const {
return Value();
}
FORCE_INLINE void Assign(const T& value) {
- storage = (storage & ~GetMask()) | (((StorageType)value << position) & GetMask());
+ storage = (storage & ~mask) | FormatValue(value);
}
FORCE_INLINE T Value() const {
- if (std::numeric_limits<T>::is_signed) {
- std::size_t shift = 8 * sizeof(T) - bits;
- return (T)((storage << (shift - position)) >> shift);
- } else {
- return (T)((storage & GetMask()) >> position);
- }
+ return ExtractValue(storage);
}
// TODO: we may want to change this to explicit operator bool() if it's bug-free in VS2015
@@ -151,20 +184,6 @@ public:
}
private:
- // StorageType is T for non-enum types and the underlying type of T if
- // T is an enumeration. Note that T is wrapped within an enable_if in the
- // former case to workaround compile errors which arise when using
- // std::underlying_type<T>::type directly.
- typedef typename std::conditional<std::is_enum<T>::value, std::underlying_type<T>,
- std::enable_if<true, T>>::type::type StorageType;
-
- // Unsigned version of StorageType
- typedef typename std::make_unsigned<StorageType>::type StorageTypeU;
-
- FORCE_INLINE StorageType GetMask() const {
- return (((StorageTypeU)~0) >> (8 * sizeof(T) - bits)) << position;
- }
-
StorageType storage;
static_assert(bits + position <= 8 * sizeof(T), "Bitfield out of range");
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index b141e79ed..2e7877500 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -7,7 +7,7 @@
#if !defined(ARCHITECTURE_x86_64) && !defined(_M_ARM)
#include <cstdlib> // for exit
#endif
-#include "common_types.h"
+#include "common/common_types.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
diff --git a/src/common/framebuffer_layout.cpp b/src/common/framebuffer_layout.cpp
deleted file mode 100644
index a2a0e7dad..000000000
--- a/src/common/framebuffer_layout.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include <cmath>
-
-#include "common/assert.h"
-#include "common/framebuffer_layout.h"
-#include "core/settings.h"
-#include "video_core/video_core.h"
-
-namespace Layout {
-
-static const float TOP_SCREEN_ASPECT_RATIO =
- static_cast<float>(VideoCore::kScreenTopHeight) / VideoCore::kScreenTopWidth;
-static const float BOT_SCREEN_ASPECT_RATIO =
- static_cast<float>(VideoCore::kScreenBottomHeight) / VideoCore::kScreenBottomWidth;
-
-// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
-template <class T>
-static MathUtil::Rectangle<T> maxRectangle(MathUtil::Rectangle<T> window_area,
- float screen_aspect_ratio) {
- float scale = std::min(static_cast<float>(window_area.GetWidth()),
- window_area.GetHeight() / screen_aspect_ratio);
- return MathUtil::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)),
- static_cast<T>(std::round(scale * screen_aspect_ratio))};
-}
-
-FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool swapped) {
- ASSERT(width > 0);
- ASSERT(height > 0);
-
- FramebufferLayout res{width, height, true, true, {}, {}};
- // Default layout gives equal screen sizes to the top and bottom screen
- MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height / 2};
- MathUtil::Rectangle<unsigned> top_screen =
- maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO);
- MathUtil::Rectangle<unsigned> bot_screen =
- maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
-
- float window_aspect_ratio = static_cast<float>(height) / width;
- // both screens height are taken into account by multiplying by 2
- float emulation_aspect_ratio = TOP_SCREEN_ASPECT_RATIO * 2;
-
- if (window_aspect_ratio < emulation_aspect_ratio) {
- // Apply borders to the left and right sides of the window.
- top_screen =
- top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2);
- bot_screen =
- bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2);
- } else {
- // Window is narrower than the emulation content => apply borders to the top and bottom
- // Recalculate the bottom screen to account for the width difference between top and bottom
- screen_window_area = {0, 0, width, top_screen.GetHeight()};
- bot_screen = maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
- bot_screen = bot_screen.TranslateX((top_screen.GetWidth() - bot_screen.GetWidth()) / 2);
- if (swapped) {
- bot_screen = bot_screen.TranslateY(height / 2 - bot_screen.GetHeight());
- } else {
- top_screen = top_screen.TranslateY(height / 2 - top_screen.GetHeight());
- }
- }
- // Move the top screen to the bottom if we are swapped.
- res.top_screen = swapped ? top_screen.TranslateY(height / 2) : top_screen;
- res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateY(height / 2);
- return res;
-}
-
-FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool swapped) {
- ASSERT(width > 0);
- ASSERT(height > 0);
- // The drawing code needs at least somewhat valid values for both screens
- // so just calculate them both even if the other isn't showing.
- FramebufferLayout res{width, height, !swapped, swapped, {}, {}};
-
- MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
- MathUtil::Rectangle<unsigned> top_screen =
- maxRectangle(screen_window_area, TOP_SCREEN_ASPECT_RATIO);
- MathUtil::Rectangle<unsigned> bot_screen =
- maxRectangle(screen_window_area, BOT_SCREEN_ASPECT_RATIO);
-
- float window_aspect_ratio = static_cast<float>(height) / width;
- float emulation_aspect_ratio = (swapped) ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
-
- if (window_aspect_ratio < emulation_aspect_ratio) {
- top_screen =
- top_screen.TranslateX((screen_window_area.GetWidth() - top_screen.GetWidth()) / 2);
- bot_screen =
- bot_screen.TranslateX((screen_window_area.GetWidth() - bot_screen.GetWidth()) / 2);
- } else {
- top_screen = top_screen.TranslateY((height - top_screen.GetHeight()) / 2);
- bot_screen = bot_screen.TranslateY((height - bot_screen.GetHeight()) / 2);
- }
- res.top_screen = top_screen;
- res.bottom_screen = bot_screen;
- return res;
-}
-
-FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped) {
- ASSERT(width > 0);
- ASSERT(height > 0);
-
- FramebufferLayout res{width, height, true, true, {}, {}};
- // Split the window into two parts. Give 4x width to the main screen and 1x width to the small
- // To do that, find the total emulation box and maximize that based on window size
- float window_aspect_ratio = static_cast<float>(height) / width;
- float emulation_aspect_ratio =
- swapped
- ? VideoCore::kScreenBottomHeight * 4 /
- (VideoCore::kScreenBottomWidth * 4.0f + VideoCore::kScreenTopWidth)
- : VideoCore::kScreenTopHeight * 4 /
- (VideoCore::kScreenTopWidth * 4.0f + VideoCore::kScreenBottomWidth);
- float large_screen_aspect_ratio = swapped ? BOT_SCREEN_ASPECT_RATIO : TOP_SCREEN_ASPECT_RATIO;
- float small_screen_aspect_ratio = swapped ? TOP_SCREEN_ASPECT_RATIO : BOT_SCREEN_ASPECT_RATIO;
-
- MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height};
- MathUtil::Rectangle<unsigned> total_rect =
- maxRectangle(screen_window_area, emulation_aspect_ratio);
- MathUtil::Rectangle<unsigned> large_screen =
- maxRectangle(total_rect, large_screen_aspect_ratio);
- MathUtil::Rectangle<unsigned> fourth_size_rect = total_rect.Scale(.25f);
- MathUtil::Rectangle<unsigned> small_screen =
- maxRectangle(fourth_size_rect, small_screen_aspect_ratio);
-
- if (window_aspect_ratio < emulation_aspect_ratio) {
- large_screen =
- large_screen.TranslateX((screen_window_area.GetWidth() - total_rect.GetWidth()) / 2);
- } else {
- large_screen = large_screen.TranslateY((height - total_rect.GetHeight()) / 2);
- }
- // Shift the small screen to the bottom right corner
- small_screen =
- small_screen.TranslateX(large_screen.right)
- .TranslateY(large_screen.GetHeight() + large_screen.top - small_screen.GetHeight());
- res.top_screen = swapped ? small_screen : large_screen;
- res.bottom_screen = swapped ? large_screen : small_screen;
- return res;
-}
-
-FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) {
- ASSERT(width > 0);
- ASSERT(height > 0);
-
- FramebufferLayout res{width, height, true, true, {}, {}};
-
- MathUtil::Rectangle<unsigned> top_screen{
- Settings::values.custom_top_left, Settings::values.custom_top_top,
- Settings::values.custom_top_right, Settings::values.custom_top_bottom};
- MathUtil::Rectangle<unsigned> bot_screen{
- Settings::values.custom_bottom_left, Settings::values.custom_bottom_top,
- Settings::values.custom_bottom_right, Settings::values.custom_bottom_bottom};
-
- res.top_screen = top_screen;
- res.bottom_screen = bot_screen;
- return res;
-}
-}
diff --git a/src/common/framebuffer_layout.h b/src/common/framebuffer_layout.h
deleted file mode 100644
index f1df5c55a..000000000
--- a/src/common/framebuffer_layout.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#pragma once
-
-#include "common/math_util.h"
-namespace Layout {
-/// Describes the layout of the window framebuffer (size and top/bottom screen positions)
-struct FramebufferLayout {
- unsigned width;
- unsigned height;
- bool top_screen_enabled;
- bool bottom_screen_enabled;
- MathUtil::Rectangle<unsigned> top_screen;
- MathUtil::Rectangle<unsigned> bottom_screen;
-};
-
-/**
- * Factory method for constructing a default FramebufferLayout
- * @param width Window framebuffer width in pixels
- * @param height Window framebuffer height in pixels
- * @param is_swapped if true, the bottom screen will be displayed above the top screen
- * @return Newly created FramebufferLayout object with default screen regions initialized
- */
-FramebufferLayout DefaultFrameLayout(unsigned width, unsigned height, bool is_swapped);
-
-/**
- * Factory method for constructing a FramebufferLayout with only the top or bottom screen
- * @param width Window framebuffer width in pixels
- * @param height Window framebuffer height in pixels
- * @param is_swapped if true, the bottom screen will be displayed (and the top won't be displayed)
- * @return Newly created FramebufferLayout object with default screen regions initialized
- */
-FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swapped);
-
-/**
- * Factory method for constructing a Frame with the a 4x size Top screen with a 1x size bottom
- * screen on the right
- * This is useful in particular because it matches well with a 1920x1080 resolution monitor
- * @param width Window framebuffer width in pixels
- * @param height Window framebuffer height in pixels
- * @param is_swapped if true, the bottom screen will be the large display
- * @return Newly created FramebufferLayout object with default screen regions initialized
- */
-FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped);
-
-/**
- * Factory method for constructing a custom FramebufferLayout
- * @param width Window framebuffer width in pixels
- * @param height Window framebuffer height in pixels
- * @return Newly created FramebufferLayout object with default screen regions initialized
- */
-FramebufferLayout CustomFrameLayout(unsigned width, unsigned height);
-}
diff --git a/src/common/hash.cpp b/src/common/hash.cpp
index f3d390dc5..a02e9e5b9 100644
--- a/src/common/hash.cpp
+++ b/src/common/hash.cpp
@@ -5,9 +5,9 @@
#if defined(_MSC_VER)
#include <stdlib.h>
#endif
-#include "common_funcs.h"
-#include "common_types.h"
-#include "hash.h"
+#include "common/common_funcs.h"
+#include "common/common_types.h"
+#include "common/hash.h"
namespace Common {
diff --git a/src/common/telemetry.cpp b/src/common/telemetry.cpp
new file mode 100644
index 000000000..bf1f54886
--- /dev/null
+++ b/src/common/telemetry.cpp
@@ -0,0 +1,40 @@
+// Copyright 2017 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <algorithm>
+#include "common/telemetry.h"
+
+namespace Telemetry {
+
+void FieldCollection::Accept(VisitorInterface& visitor) const {
+ for (const auto& field : fields) {
+ field.second->Accept(visitor);
+ }
+}
+
+void FieldCollection::AddField(std::unique_ptr<FieldInterface> field) {
+ fields[field->GetName()] = std::move(field);
+}
+
+template <class T>
+void Field<T>::Accept(VisitorInterface& visitor) const {
+ visitor.Visit(*this);
+}
+
+template class Field<bool>;
+template class Field<double>;
+template class Field<float>;
+template class Field<u8>;
+template class Field<u16>;
+template class Field<u32>;
+template class Field<u64>;
+template class Field<s8>;
+template class Field<s16>;
+template class Field<s32>;
+template class Field<s64>;
+template class Field<std::string>;
+template class Field<const char*>;
+template class Field<std::chrono::microseconds>;
+
+} // namespace Telemetry
diff --git a/src/common/telemetry.h b/src/common/telemetry.h
new file mode 100644
index 000000000..dd6bbd759
--- /dev/null
+++ b/src/common/telemetry.h
@@ -0,0 +1,196 @@
+// Copyright 2017 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <chrono>
+#include <map>
+#include <memory>
+#include <string>
+#include "common/common_types.h"
+
+namespace Telemetry {
+
+/// Field type, used for grouping fields together in the final submitted telemetry log
+enum class FieldType : u8 {
+ None = 0, ///< No specified field group
+ App, ///< Citra application fields (e.g. version, branch, etc.)
+ Session, ///< Emulated session fields (e.g. title ID, log, etc.)
+ Performance, ///< Emulated performance (e.g. fps, emulated CPU speed, etc.)
+ UserFeedback, ///< User submitted feedback (e.g. star rating, user notes, etc.)
+ UserConfig, ///< User configuration fields (e.g. emulated CPU core, renderer, etc.)
+ UserSystem, ///< User system information (e.g. host CPU type, RAM, etc.)
+};
+
+struct VisitorInterface;
+
+/**
+ * Interface class for telemetry data fields.
+ */
+class FieldInterface : NonCopyable {
+public:
+ virtual ~FieldInterface() = default;
+
+ /**
+ * Accept method for the visitor pattern.
+ * @param visitor Reference to the visitor that will visit this field.
+ */
+ virtual void Accept(VisitorInterface& visitor) const = 0;
+
+ /**
+ * Gets the name of this field.
+ * @returns Name of this field as a string.
+ */
+ virtual const std::string& GetName() const = 0;
+};
+
+/**
+ * Represents a telemetry data field, i.e. a unit of data that gets logged and submitted to our
+ * telemetry web service.
+ */
+template <typename T>
+class Field : public FieldInterface {
+public:
+ Field(FieldType type, std::string name, const T& value)
+ : type(type), name(std::move(name)), value(value) {}
+
+ Field(FieldType type, std::string name, T&& value)
+ : type(type), name(std::move(name)), value(std::move(value)) {}
+
+ Field(const Field& other) : Field(other.type, other.name, other.value) {}
+
+ Field& operator=(const Field& other) {
+ type = other.type;
+ name = other.name;
+ value = other.value;
+ return *this;
+ }
+
+ Field& operator=(Field&& other) {
+ type = other.type;
+ name = std::move(other.name);
+ value = std::move(other.value);
+ return *this;
+ }
+
+ void Accept(VisitorInterface& visitor) const override;
+
+ const std::string& GetName() const override {
+ return name;
+ }
+
+ /**
+ * Returns the type of the field.
+ */
+ FieldType GetType() const {
+ return type;
+ }
+
+ /**
+ * Returns the value of the field.
+ */
+ const T& GetValue() const {
+ return value;
+ }
+
+ inline bool operator==(const Field<T>& other) {
+ return (type == other.type) && (name == other.name) && (value == other.value);
+ }
+
+ inline bool operator!=(const Field<T>& other) {
+ return !(*this == other);
+ }
+
+private:
+ std::string name; ///< Field name, must be unique
+ FieldType type{}; ///< Field type, used for grouping fields together
+ T value; ///< Field value
+};
+
+/**
+ * Collection of data fields that have been logged.
+ */
+class FieldCollection final : NonCopyable {
+public:
+ FieldCollection() = default;
+
+ /**
+ * Accept method for the visitor pattern, visits each field in the collection.
+ * @param visitor Reference to the visitor that will visit each field.
+ */
+ void Accept(VisitorInterface& visitor) const;
+
+ /**
+ * Creates a new field and adds it to the field collection.
+ * @param type Type of the field to add.
+ * @param name Name of the field to add.
+ * @param value Value for the field to add.
+ */
+ template <typename T>
+ void AddField(FieldType type, const char* name, T value) {
+ return AddField(std::make_unique<Field<T>>(type, name, std::move(value)));
+ }
+
+ /**
+ * Adds a new field to the field collection.
+ * @param field Field to add to the field collection.
+ */
+ void AddField(std::unique_ptr<FieldInterface> field);
+
+private:
+ std::map<std::string, std::unique_ptr<FieldInterface>> fields;
+};
+
+/**
+ * Telemetry fields visitor interface class. A backend to log to a web service should implement
+ * this interface.
+ */
+struct VisitorInterface : NonCopyable {
+ virtual ~VisitorInterface() = default;
+
+ virtual void Visit(const Field<bool>& field) = 0;
+ virtual void Visit(const Field<double>& field) = 0;
+ virtual void Visit(const Field<float>& field) = 0;
+ virtual void Visit(const Field<u8>& field) = 0;
+ virtual void Visit(const Field<u16>& field) = 0;
+ virtual void Visit(const Field<u32>& field) = 0;
+ virtual void Visit(const Field<u64>& field) = 0;
+ virtual void Visit(const Field<s8>& field) = 0;
+ virtual void Visit(const Field<s16>& field) = 0;
+ virtual void Visit(const Field<s32>& field) = 0;
+ virtual void Visit(const Field<s64>& field) = 0;
+ virtual void Visit(const Field<std::string>& field) = 0;
+ virtual void Visit(const Field<const char*>& field) = 0;
+ virtual void Visit(const Field<std::chrono::microseconds>& field) = 0;
+
+ /// Completion method, called once all fields have been visited
+ virtual void Complete() = 0;
+};
+
+/**
+ * Empty implementation of VisitorInterface that drops all fields. Used when a functional
+ * backend implementation is not available.
+ */
+struct NullVisitor : public VisitorInterface {
+ ~NullVisitor() = default;
+
+ void Visit(const Field<bool>& /*field*/) override {}
+ void Visit(const Field<double>& /*field*/) override {}
+ void Visit(const Field<float>& /*field*/) override {}
+ void Visit(const Field<u8>& /*field*/) override {}
+ void Visit(const Field<u16>& /*field*/) override {}
+ void Visit(const Field<u32>& /*field*/) override {}
+ void Visit(const Field<u64>& /*field*/) override {}
+ void Visit(const Field<s8>& /*field*/) override {}
+ void Visit(const Field<s16>& /*field*/) override {}
+ void Visit(const Field<s32>& /*field*/) override {}
+ void Visit(const Field<s64>& /*field*/) override {}
+ void Visit(const Field<std::string>& /*field*/) override {}
+ void Visit(const Field<const char*>& /*field*/) override {}
+ void Visit(const Field<std::chrono::microseconds>& /*field*/) override {}
+
+ void Complete() override {}
+};
+
+} // namespace Telemetry
diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index 7ca8e15f5..c7a461a1e 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -652,6 +652,16 @@ static inline decltype((X{} * int{} + X{} * int{}) / base) LerpInt(const X& begi
return (begin * (base - t) + end * t) / base;
}
+// bilinear interpolation. s is for interpolating x00-x01 and x10-x11, and t is for the second
+// interpolation.
+template <typename X>
+inline auto BilinearInterp(const X& x00, const X& x01, const X& x10, const X& x11, const float s,
+ const float t) {
+ auto y0 = Lerp(x00, x01, s);
+ auto y1 = Lerp(x10, x11, s);
+ return Lerp(y0, y1, t);
+}
+
// Utility vector factories
template <typename T>
static inline Vec2<T> MakeVec(const T& x, const T& y) {
diff --git a/src/common/x64/cpu_detect.cpp b/src/common/x64/cpu_detect.cpp
index 2cb3ab9cc..62f17fbb5 100644
--- a/src/common/x64/cpu_detect.cpp
+++ b/src/common/x64/cpu_detect.cpp
@@ -6,7 +6,7 @@
#include <string>
#include <thread>
#include "common/common_types.h"
-#include "cpu_detect.h"
+#include "common/x64/cpu_detect.h"
#ifdef _MSC_VER
#include <intrin.h>