Minor fixes
This commit is contained in:
parent
8fe11711a3
commit
4b3b595a99
|
|
@ -8,6 +8,7 @@
|
||||||
#define NAZARA_CORE_HPP
|
#define NAZARA_CORE_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
|
#include <Nazara/Core/Modules.hpp>
|
||||||
#include <Nazara/Core/ModuleBase.hpp>
|
#include <Nazara/Core/ModuleBase.hpp>
|
||||||
#include <Nazara/Core/TypeList.hpp>
|
#include <Nazara/Core/TypeList.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ namespace Nz
|
||||||
ModuleBase(std::string moduleName, T* pointer, NoLog);
|
ModuleBase(std::string moduleName, T* pointer, NoLog);
|
||||||
|
|
||||||
void LogInit();
|
void LogInit();
|
||||||
|
void LogUninit();
|
||||||
|
|
||||||
std::string m_moduleName;
|
std::string m_moduleName;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ModuleBase<T>::~ModuleBase()
|
ModuleBase<T>::~ModuleBase()
|
||||||
{
|
{
|
||||||
NazaraNotice("Uninitializing " + m_moduleName + "...");
|
LogUninit();
|
||||||
T::s_instance = nullptr;
|
T::s_instance = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,6 +41,12 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraNotice("Initializing " + m_moduleName + "...");
|
NazaraNotice("Initializing " + m_moduleName + "...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void ModuleBase<T>::LogUninit()
|
||||||
|
{
|
||||||
|
NazaraNotice("Uninitializing " + m_moduleName + "...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
#include <Nazara/Core/Bitset.hpp>
|
#include <Nazara/Core/Bitset.hpp>
|
||||||
#include <Nazara/Utility/Config.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <Nazara/Utility/Enums.hpp>
|
#include <Nazara/Utility/Enums.hpp>
|
||||||
|
#include <array>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
///TODO: Permettre la conversion automatique entre les formats via des renseignements de bits et de type pour chaque format.
|
///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
|
/// 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 bool Initialize();
|
||||||
static void Uninitialize();
|
static void Uninitialize();
|
||||||
|
|
||||||
static PixelFormatDescription s_pixelFormatInfos[PixelFormatCount];
|
static std::array<std::array<ConvertFunction, PixelFormatCount>, PixelFormatCount> s_convertFunctions;
|
||||||
static ConvertFunction s_convertFunctions[PixelFormatCount][PixelFormatCount];
|
static std::array<std::array<PixelFormatInfo::FlipFunction, PixelFlippingCount>, PixelFormatCount> s_flipFunctions;
|
||||||
static std::map<PixelFormat, FlipFunction> s_flipFunctions[PixelFlippingCount];
|
static std::array<PixelFormatDescription, PixelFormatCount> s_pixelFormatInfos;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,7 @@ namespace Nz
|
||||||
|
|
||||||
inline void PixelFormatInfo::SetFlipFunction(PixelFlipping flipping, PixelFormat format, FlipFunction func)
|
inline void PixelFormatInfo::SetFlipFunction(PixelFlipping flipping, PixelFormat format, FlipFunction func)
|
||||||
{
|
{
|
||||||
s_flipFunctions[UnderlyingCast(flipping)][format] = func;
|
s_flipFunctions[UnderlyingCast(flipping)][UnderlyingCast(format)] = func;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,11 @@ namespace Nz
|
||||||
|
|
||||||
bool IsSupported(const std::string_view& extension)
|
bool IsSupported(const std::string_view& extension)
|
||||||
{
|
{
|
||||||
return extension == "ogg";
|
static std::set<std::string_view> supportedExtensions = {
|
||||||
|
"oga", "ogg", "ogm", "ogv", "ogx", "opus", "spx"
|
||||||
|
};
|
||||||
|
|
||||||
|
return supportedExtensions.find(extension) != supportedExtensions.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ternary CheckOgg(Stream& stream)
|
Ternary CheckOgg(Stream& stream)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ namespace Nz
|
||||||
|
|
||||||
Core::~Core()
|
Core::~Core()
|
||||||
{
|
{
|
||||||
|
LogUninit();
|
||||||
HardwareInfo::Uninitialize();
|
HardwareInfo::Uninitialize();
|
||||||
Log::Uninitialize();
|
Log::Uninitialize();
|
||||||
PluginManager::Uninitialize();
|
PluginManager::Uninitialize();
|
||||||
|
|
|
||||||
|
|
@ -361,8 +361,9 @@ namespace Nz
|
||||||
NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle");
|
NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle");
|
||||||
NazaraAssert(buffer && size > 0, "Invalid buffer");
|
NazaraAssert(buffer && size > 0, "Invalid buffer");
|
||||||
|
|
||||||
CallOnExit updateSent;
|
|
||||||
std::size_t totalByteSent = 0;
|
std::size_t totalByteSent = 0;
|
||||||
|
|
||||||
|
CallOnExit updateSent;
|
||||||
if (sent)
|
if (sent)
|
||||||
{
|
{
|
||||||
updateSent.Reset([sent, &totalByteSent] ()
|
updateSent.Reset([sent, &totalByteSent] ()
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NazaraAssert(handle != InvalidHandle, "Invalid handle");
|
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()));
|
NazaraWarning("Failed to clear socket error code: " + Error::GetLastSystemError(WSAGetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
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
|
NazaraAssert(IsValid(format), "invalid pixel format");
|
||||||
if (!IsValid(format))
|
|
||||||
{
|
|
||||||
NazaraError("Invalid pixel format");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::size_t flippingIndex = UnderlyingCast(flipping);
|
auto& flipFunction = s_flipFunctions[UnderlyingCast(format)][UnderlyingCast(flipping)];
|
||||||
|
if (flipFunction)
|
||||||
auto it = s_flipFunctions[flippingIndex].find(format);
|
flipFunction(width, height, depth, reinterpret_cast<const UInt8*>(src), reinterpret_cast<UInt8*>(dst));
|
||||||
if (it != s_flipFunctions[flippingIndex].end())
|
|
||||||
it->second(width, height, depth, reinterpret_cast<const UInt8*>(src), reinterpret_cast<UInt8*>(dst));
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Flipping générique
|
// Flipping générique
|
||||||
|
|
@ -1496,9 +1488,6 @@ namespace Nz
|
||||||
NazaraWarning("Pixel format 0x" + NumberToString(i, 16) + " (" + GetName(static_cast<Nz::PixelFormat>(i)) + ") failed validation tests");
|
NazaraWarning("Pixel format 0x" + NumberToString(i, 16) + " (" + GetName(static_cast<Nz::PixelFormat>(i)) + ") failed validation tests");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset functions
|
|
||||||
std::memset(s_convertFunctions, 0, (PixelFormatCount)*(PixelFormatCount)*sizeof(PixelFormatInfo::ConvertFunction));
|
|
||||||
|
|
||||||
/***********************************A8************************************/
|
/***********************************A8************************************/
|
||||||
RegisterConverter<PixelFormat::A8, PixelFormat::BGRA8>();
|
RegisterConverter<PixelFormat::A8, PixelFormat::BGRA8>();
|
||||||
RegisterConverter<PixelFormat::A8, PixelFormat::LA8>();
|
RegisterConverter<PixelFormat::A8, PixelFormat::LA8>();
|
||||||
|
|
@ -1725,16 +1714,18 @@ namespace Nz
|
||||||
|
|
||||||
void PixelFormatInfo::Uninitialize()
|
void PixelFormatInfo::Uninitialize()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < PixelFormatCount; ++i)
|
for (std::size_t i = 0; i < PixelFormatCount; ++i)
|
||||||
|
{
|
||||||
s_pixelFormatInfos[i].Clear();
|
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 (std::size_t j = 0; j < PixelFlippingCount; ++j)
|
||||||
|
s_flipFunctions[i][j] = nullptr;
|
||||||
for (unsigned int i = 0; i < PixelFlippingCount; ++i)
|
}
|
||||||
s_flipFunctions[i].clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelFormatDescription PixelFormatInfo::s_pixelFormatInfos[PixelFormatCount];
|
std::array<std::array<PixelFormatInfo::ConvertFunction, PixelFormatCount>, PixelFormatCount> PixelFormatInfo::s_convertFunctions;
|
||||||
PixelFormatInfo::ConvertFunction PixelFormatInfo::s_convertFunctions[PixelFormatCount][PixelFormatCount];
|
std::array<std::array<PixelFormatInfo::FlipFunction, PixelFlippingCount>, PixelFormatCount> PixelFormatInfo::s_flipFunctions;
|
||||||
std::map<PixelFormat, PixelFormatInfo::FlipFunction> PixelFormatInfo::s_flipFunctions[PixelFlippingCount];
|
std::array<PixelFormatDescription, PixelFormatCount> PixelFormatInfo::s_pixelFormatInfos;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT };
|
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.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;
|
callbackCreateInfo.pfnUserCallback = &DebugCallback;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,8 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]")
|
||||||
unsigned int WALL_COLLISION_ID = 2;
|
unsigned int WALL_COLLISION_ID = 2;
|
||||||
unsigned int TRIGGER_COLLISION_ID = 3;
|
unsigned int TRIGGER_COLLISION_ID = 3;
|
||||||
|
|
||||||
|
int statusTriggerCollision = 0;
|
||||||
|
|
||||||
Nz::PhysWorld2D world;
|
Nz::PhysWorld2D world;
|
||||||
|
|
||||||
Nz::Rectf characterAABB(0.f, 0.f, 1.f, 1.f);
|
Nz::Rectf characterAABB(0.f, 0.f, 1.f, 1.f);
|
||||||
|
|
@ -129,7 +131,6 @@ SCENARIO("PhysWorld2D", "[PHYSICS2D][PHYSWORLD2D]")
|
||||||
|
|
||||||
world.Step(0.f);
|
world.Step(0.f);
|
||||||
|
|
||||||
int statusTriggerCollision = 0;
|
|
||||||
Nz::PhysWorld2D::Callback characterTriggerCallback;
|
Nz::PhysWorld2D::Callback characterTriggerCallback;
|
||||||
characterTriggerCallback.startCallback = [&](Nz::PhysWorld2D&, Nz::Arbiter2D&, Nz::RigidBody2D&, Nz::RigidBody2D&, void*) -> bool {
|
characterTriggerCallback.startCallback = [&](Nz::PhysWorld2D&, Nz::Arbiter2D&, Nz::RigidBody2D&, Nz::RigidBody2D&, void*) -> bool {
|
||||||
statusTriggerCollision = statusTriggerCollision | 1 << 0;
|
statusTriggerCollision = statusTriggerCollision | 1 << 0;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ int main(int argc, char* argv[])
|
||||||
Nz::Modules<Ndk::ClientSdk> nazaza;
|
Nz::Modules<Ndk::ClientSdk> nazaza;
|
||||||
Ndk::ClientApplication app(argc, argv);
|
Ndk::ClientApplication app(argc, argv);
|
||||||
|
|
||||||
Nz::Log::GetLogger()->EnableStdReplication(false);
|
|
||||||
|
|
||||||
int result = Catch::Session().run(argc, argv);
|
int result = Catch::Session().run(argc, argv);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -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")
|
target("NazaraClientUnitTests")
|
||||||
set_group("Tests")
|
set_group("Tests")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ add_rules("build_rendererplugins")
|
||||||
|
|
||||||
if is_mode("debug") then
|
if is_mode("debug") then
|
||||||
add_rules("debug_suffix")
|
add_rules("debug_suffix")
|
||||||
|
elseif is_mode("asan") then
|
||||||
|
set_optimize("none") -- by default xmake will optimize asan builds
|
||||||
end
|
end
|
||||||
|
|
||||||
add_includedirs("include")
|
add_includedirs("include")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue