diff --git a/include/Nazara/Core/Core.hpp b/include/Nazara/Core/Core.hpp index 10cc2eb65..ff7dbb40c 100644 --- a/include/Nazara/Core/Core.hpp +++ b/include/Nazara/Core/Core.hpp @@ -8,6 +8,7 @@ #define NAZARA_CORE_HPP #include +#include #include #include diff --git a/include/Nazara/Core/ModuleBase.hpp b/include/Nazara/Core/ModuleBase.hpp index d17e32116..2796ed8f2 100644 --- a/include/Nazara/Core/ModuleBase.hpp +++ b/include/Nazara/Core/ModuleBase.hpp @@ -36,6 +36,7 @@ namespace Nz ModuleBase(std::string moduleName, T* pointer, NoLog); void LogInit(); + void LogUninit(); std::string m_moduleName; }; diff --git a/include/Nazara/Core/ModuleBase.inl b/include/Nazara/Core/ModuleBase.inl index 0ec21b215..8a8006111 100644 --- a/include/Nazara/Core/ModuleBase.inl +++ b/include/Nazara/Core/ModuleBase.inl @@ -26,7 +26,7 @@ namespace Nz template ModuleBase::~ModuleBase() { - NazaraNotice("Uninitializing " + m_moduleName + "..."); + LogUninit(); T::s_instance = nullptr; } @@ -41,6 +41,12 @@ namespace Nz { NazaraNotice("Initializing " + m_moduleName + "..."); } + + template + void ModuleBase::LogUninit() + { + NazaraNotice("Uninitializing " + m_moduleName + "..."); + } } #include diff --git a/include/Nazara/Utility/PixelFormat.hpp b/include/Nazara/Utility/PixelFormat.hpp index bf7e138eb..f12be11fd 100644 --- a/include/Nazara/Utility/PixelFormat.hpp +++ b/include/Nazara/Utility/PixelFormat.hpp @@ -11,8 +11,8 @@ #include #include #include +#include #include -#include ///TODO: Permettre la conversion automatique entre les formats via des renseignements de bits et de type pour chaque format. /// Ce serait plus lent que la conversion spécialisée (qui ne disparaîtra donc pas) mais ça permettrait au moteur de faire la conversion @@ -87,9 +87,9 @@ namespace Nz static bool Initialize(); static void Uninitialize(); - static PixelFormatDescription s_pixelFormatInfos[PixelFormatCount]; - static ConvertFunction s_convertFunctions[PixelFormatCount][PixelFormatCount]; - static std::map s_flipFunctions[PixelFlippingCount]; + static std::array, PixelFormatCount> s_convertFunctions; + static std::array, PixelFormatCount> s_flipFunctions; + static std::array s_pixelFormatInfos; }; } diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index 86f5b3435..7f62d15a0 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -269,7 +269,7 @@ namespace Nz inline void PixelFormatInfo::SetFlipFunction(PixelFlipping flipping, PixelFormat format, FlipFunction func) { - s_flipFunctions[UnderlyingCast(flipping)][format] = func; + s_flipFunctions[UnderlyingCast(flipping)][UnderlyingCast(format)] = func; } } diff --git a/src/Nazara/Audio/Formats/libvorbisLoader.cpp b/src/Nazara/Audio/Formats/libvorbisLoader.cpp index 67fc81f37..bc540e587 100644 --- a/src/Nazara/Audio/Formats/libvorbisLoader.cpp +++ b/src/Nazara/Audio/Formats/libvorbisLoader.cpp @@ -145,7 +145,11 @@ namespace Nz bool IsSupported(const std::string_view& extension) { - return extension == "ogg"; + static std::set supportedExtensions = { + "oga", "ogg", "ogm", "ogv", "ogx", "opus", "spx" + }; + + return supportedExtensions.find(extension) != supportedExtensions.end(); } Ternary CheckOgg(Stream& stream) diff --git a/src/Nazara/Core/Core.cpp b/src/Nazara/Core/Core.cpp index 17db66a9f..e1cd2862a 100644 --- a/src/Nazara/Core/Core.cpp +++ b/src/Nazara/Core/Core.cpp @@ -29,6 +29,7 @@ namespace Nz Core::~Core() { + LogUninit(); HardwareInfo::Uninitialize(); Log::Uninitialize(); PluginManager::Uninitialize(); diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index 7b0265bd2..d14a3a332 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -361,8 +361,9 @@ namespace Nz NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle"); NazaraAssert(buffer && size > 0, "Invalid buffer"); - CallOnExit updateSent; std::size_t totalByteSent = 0; + + CallOnExit updateSent; if (sent) { updateSent.Reset([sent, &totalByteSent] () diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index f68ef4a20..27f9b9ca2 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -110,7 +110,7 @@ namespace Nz { NazaraAssert(handle != InvalidHandle, "Invalid handle"); - if (GetLastError(handle, nullptr) != SocketError::Internal) + if (GetLastError(handle, nullptr) == SocketError::Internal) NazaraWarning("Failed to clear socket error code: " + Error::GetLastSystemError(WSAGetLastError())); } diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index 3ac70f768..9c17f8d7f 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -1307,19 +1307,11 @@ namespace Nz bool PixelFormatInfo::Flip(PixelFlipping flipping, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst) { - #if NAZARA_UTILITY_SAFE - if (!IsValid(format)) - { - NazaraError("Invalid pixel format"); - return false; - } - #endif + NazaraAssert(IsValid(format), "invalid pixel format"); - std::size_t flippingIndex = UnderlyingCast(flipping); - - auto it = s_flipFunctions[flippingIndex].find(format); - if (it != s_flipFunctions[flippingIndex].end()) - it->second(width, height, depth, reinterpret_cast(src), reinterpret_cast(dst)); + auto& flipFunction = s_flipFunctions[UnderlyingCast(format)][UnderlyingCast(flipping)]; + if (flipFunction) + flipFunction(width, height, depth, reinterpret_cast(src), reinterpret_cast(dst)); else { // Flipping générique @@ -1496,9 +1488,6 @@ namespace Nz NazaraWarning("Pixel format 0x" + NumberToString(i, 16) + " (" + GetName(static_cast(i)) + ") failed validation tests"); } - // Reset functions - std::memset(s_convertFunctions, 0, (PixelFormatCount)*(PixelFormatCount)*sizeof(PixelFormatInfo::ConvertFunction)); - /***********************************A8************************************/ RegisterConverter(); RegisterConverter(); @@ -1725,16 +1714,18 @@ namespace Nz void PixelFormatInfo::Uninitialize() { - for (unsigned int i = 0; i < PixelFormatCount; ++i) + for (std::size_t i = 0; i < PixelFormatCount; ++i) + { s_pixelFormatInfos[i].Clear(); + for (std::size_t j = 0; j < PixelFormatCount; ++j) + s_convertFunctions[i][j] = nullptr; - std::memset(s_convertFunctions, 0, (PixelFormatCount)*(PixelFormatCount)*sizeof(PixelFormatInfo::ConvertFunction)); - - for (unsigned int i = 0; i < PixelFlippingCount; ++i) - s_flipFunctions[i].clear(); + for (std::size_t j = 0; j < PixelFlippingCount; ++j) + s_flipFunctions[i][j] = nullptr; + } } - PixelFormatDescription PixelFormatInfo::s_pixelFormatInfos[PixelFormatCount]; - PixelFormatInfo::ConvertFunction PixelFormatInfo::s_convertFunctions[PixelFormatCount][PixelFormatCount]; - std::map PixelFormatInfo::s_flipFunctions[PixelFlippingCount]; + std::array, PixelFormatCount> PixelFormatInfo::s_convertFunctions; + std::array, PixelFormatCount> PixelFormatInfo::s_flipFunctions; + std::array PixelFormatInfo::s_pixelFormatInfos; } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index 61e76f6a2..56332e0fd 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -219,7 +219,7 @@ namespace Nz } VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT }; - callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; + callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT; callbackCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; callbackCreateInfo.pfnUserCallback = &DebugCallback; diff --git a/tests/Engine/Physics2D/PhysWorld2DTest.cpp b/tests/Engine/Physics2D/PhysWorld2DTest.cpp index dc3579776..58c4da8e9 100644 --- a/tests/Engine/Physics2D/PhysWorld2DTest.cpp +++ b/tests/Engine/Physics2D/PhysWorld2DTest.cpp @@ -106,6 +106,8 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]") unsigned int WALL_COLLISION_ID = 2; unsigned int TRIGGER_COLLISION_ID = 3; + int statusTriggerCollision = 0; + Nz::PhysWorld2D world; Nz::Rectf characterAABB(0.f, 0.f, 1.f, 1.f); @@ -129,7 +131,6 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]") world.Step(0.f); - int statusTriggerCollision = 0; Nz::PhysWorld2D::Callback characterTriggerCallback; characterTriggerCallback.startCallback = [&](Nz::PhysWorld2D&, Nz::Arbiter2D&, Nz::RigidBody2D&, Nz::RigidBody2D&, void*) -> bool { statusTriggerCollision = statusTriggerCollision | 1 << 0; diff --git a/tests/main_client.cpp b/tests/main_client.cpp index 86dcbbb18..a68bae484 100644 --- a/tests/main_client.cpp +++ b/tests/main_client.cpp @@ -12,8 +12,6 @@ int main(int argc, char* argv[]) Nz::Modules nazaza; Ndk::ClientApplication app(argc, argv); - Nz::Log::GetLogger()->EnableStdReplication(false); - int result = Catch::Session().run(argc, argv); return result; diff --git a/tests/xmake.lua b/tests/xmake.lua index 120153c73..edbf0facb 100644 --- a/tests/xmake.lua +++ b/tests/xmake.lua @@ -1,3 +1,8 @@ +if is_mode("asan") then + add_defines("CATCH_CONFIG_NO_WINDOWS_SEH") + add_defines("CATCH_CONFIG_NO_POSIX_SIGNALS") +end + target("NazaraClientUnitTests") set_group("Tests") set_kind("binary") diff --git a/xmake.lua b/xmake.lua index 58dc3d5fc..31edb641f 100644 --- a/xmake.lua +++ b/xmake.lua @@ -111,6 +111,8 @@ add_rules("build_rendererplugins") if is_mode("debug") then add_rules("debug_suffix") +elseif is_mode("asan") then + set_optimize("none") -- by default xmake will optimize asan builds end add_includedirs("include")