Bug fixes and ASan build submodule

This commit is contained in:
Jack Andersen 2017-12-11 16:06:19 -10:00
parent 8901ac2150
commit ce6a3aa50c
13 changed files with 96 additions and 40 deletions

3
.gitmodules vendored
View File

@ -24,3 +24,6 @@
path = hecl-gui path = hecl-gui
url = ../hecl-gui url = ../hecl-gui
[submodule "sanitizers-cmake"]
path = sanitizers-cmake
url = git://github.com/arsenm/sanitizers-cmake.git

View File

@ -7,7 +7,25 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE) set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE)
set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE) set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
find_package(Sanitizers)
option(URDE_SSE2 "Enable SSE2 flags." Off)
option(URDE_SSE3 "Enable SSE3 flags." On)
option(URDE_SSE41 "Enable SSE4.1 flags." Off)
if(MSVC) if(MSVC)
if(URDE_SSE41)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
elseif(URDE_SSE3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
elseif(URDE_SSE2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
endif()
if(${CMAKE_GENERATOR} MATCHES "Visual Studio*") if(${CMAKE_GENERATOR} MATCHES "Visual Studio*")
set(VS_DEFINES "/MP") set(VS_DEFINES "/MP")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT urde) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT urde)
@ -34,6 +52,17 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
else() else()
if(URDE_SSE41)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
elseif(URDE_SSE3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
elseif(URDE_SSE2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\
-Wno-multichar -fno-exceptions -Wno-narrowing -Wno-nullability-completeness -Werror=return-type") -Wno-multichar -fno-exceptions -Wno-narrowing -Wno-nullability-completeness -Werror=return-type")

View File

@ -69,3 +69,6 @@ add_library(RetroDataSpec
AssetNameMap32.bin AssetNameMap32.c AssetNameMap32.bin AssetNameMap32.c
AssetNameMap64.bin AssetNameMap64.c AssetNameMap64.bin AssetNameMap64.c
RetroMasterShader.c) RetroMasterShader.c)
if(COMMAND add_sanitizers)
add_sanitizers(RetroDataSpec)
endif()

View File

@ -94,6 +94,9 @@ target_link_libraries(urde
${PNG_LIB} libjpeg-turbo squish xxhash zeus ${PNG_LIB} libjpeg-turbo squish xxhash zeus
kabufuda jbus ${ZLIB_LIBRARIES} ${LZO_LIB} kabufuda jbus ${ZLIB_LIBRARIES} ${LZO_LIB}
${BOO_SYS_LIBS}) ${BOO_SYS_LIBS})
if(COMMAND add_sanitizers)
add_sanitizers(urde)
endif()
set_target_properties(urde PROPERTIES set_target_properties(urde PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist") MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist")

View File

@ -284,6 +284,7 @@ bool ViewManager::proc()
m_mainWindow->waitForRetrace(m_voiceEngine.get()); m_mainWindow->waitForRetrace(m_voiceEngine.get());
CBooModel::ClearModelUniformCounters(); CBooModel::ClearModelUniformCounters();
CGraphics::TickRenderTimings(); CGraphics::TickRenderTimings();
++logvisor::FrameIndex;
return true; return true;
} }

View File

@ -20,6 +20,33 @@ namespace urde
{ {
static logvisor::Module Log{"URDE"}; static logvisor::Module Log{"URDE"};
static hecl::SystemString CPUFeatureString(const zeus::CPUInfo& cpuInf)
{
hecl::SystemString features;
if (cpuInf.AESNI)
features += _S("AES-NI");
if (cpuInf.SSE1)
{
if (!features.empty())
features += _S(", SSE1");
else
features += _S("SSE1");
}
if (cpuInf.SSE2)
features += _S(", SSE2");
if (cpuInf.SSE3)
features += _S(", SSE3");
if (cpuInf.SSSE3)
features += _S(", SSSE3");
if (cpuInf.SSE4a)
features += _S(", SSE4a");
if (cpuInf.SSE41)
features += _S(", SSE4.1");
if (cpuInf.SSE42)
features += _S(", SSE4.2");
return features;
}
struct Application : boo::IApplicationCallback struct Application : boo::IApplicationCallback
{ {
hecl::Runtime::FileStoreManager m_fileMgr; hecl::Runtime::FileStoreManager m_fileMgr;
@ -85,39 +112,7 @@ struct Application : boo::IApplicationCallback
const zeus::CPUInfo& cpuInf = zeus::cpuFeatures(); const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand); Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand);
Log.report(logvisor::Info, "CPU Vendor: %s", cpuInf.cpuVendor); Log.report(logvisor::Info, "CPU Vendor: %s", cpuInf.cpuVendor);
hecl::SystemString features; Log.report(logvisor::Info, _S("CPU Features: %s"), CPUFeatureString(cpuInf).c_str());
if (cpuInf.AESNI)
features += _S("AES-NI");
if (cpuInf.SSE1)
{
if (!features.empty())
features += _S(", SSE1");
else
features += _S("SSE1");
}
else
{
Log.report(logvisor::Fatal, _S("URDE requires SSE1 minimum"));
return;
}
if (cpuInf.SSE2)
features += _S(", SSE2");
else
{
Log.report(logvisor::Fatal, _S("URDE requires SSE2 minimum"));
return;
}
if (cpuInf.SSE3)
features += _S(", SSE3");
if (cpuInf.SSSE3)
features += _S(", SSSE3");
if (cpuInf.SSE4a)
features += _S(", SSE4a");
if (cpuInf.SSE41)
features += _S(", SSE4.1");
if (cpuInf.SSE42)
features += _S(", SSE4.2");
Log.report(logvisor::Info, _S("CPU Features: %s"), features.c_str());
} }
}; };
@ -128,6 +123,22 @@ hecl::SystemString ExeDir;
static void SetupBasics(bool logging) static void SetupBasics(bool logging)
{ {
auto result = zeus::validateCPU();
if (!result.first)
{
#if _WIN32 && !WINDOWS_STORE
char* msg;
asprintf(&msg, "ERROR: This build of URDE requires the following CPU features:\n%s\n",
urde::CPUFeatureString(result.second).c_str());
MessageBoxA(nullptr, msg, "CPU error", MB_OK | MB_ICONERROR);
free(msg);
#else
fprintf(stderr, "ERROR: This build of URDE requires the following CPU features:\n%s\n",
urde::CPUFeatureString(result.second).c_str());
#endif
exit(1);
}
logvisor::RegisterStandardExceptions(); logvisor::RegisterStandardExceptions();
if (logging) if (logging)
logvisor::RegisterConsoleLogger(); logvisor::RegisterConsoleLogger();

View File

@ -1518,12 +1518,13 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
} }
} }
} }
zeus::CTransform modelXf = planeXf * preXf;
CMapWorld::CMapWorldDrawParms parms( CMapWorld::CMapWorldDrawParms parms(
xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp, xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp, xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp, xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp,
mapAlpha, 2.f, mgr, planeXf * preXf, camXf, *x24_world, mapAlpha, 2.f, mgr, modelXf, camXf, *x24_world,
mwInfo, x1dc_playerFlashPulse, hintFlash, objectScale, true); mwInfo, x1dc_playerFlashPulse, hintFlash, objectScale, true);
mw->Draw(parms, xa0_curAreaId, xa0_curAreaId, mw->Draw(parms, xa0_curAreaId, xa0_curAreaId,
xa8_renderStates[0].x2c_drawDepth1, xa8_renderStates[0].x2c_drawDepth1,
@ -1549,12 +1550,13 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
{ {
const CMapWorld* mw = x24_world->IGetMapWorld(); const CMapWorld* mw = x24_world->IGetMapWorld();
const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo(); const CMapWorldInfo& mwInfo = *g_GameState->StateForWorld(x24_world->IGetWorldAssetId()).MapWorldInfo();
zeus::CTransform modelXf = planeXf * preXf;
CMapWorld::CMapWorldDrawParms parms( CMapWorld::CMapWorldDrawParms parms(
xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp, xa8_renderStates[0].x34_alphaSurfaceVisited * alphaInterp,
xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp, xa8_renderStates[0].x38_alphaOutlineVisited * alphaInterp,
xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp, xa8_renderStates[0].x3c_alphaSurfaceUnvisited * alphaInterp,
xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp, xa8_renderStates[0].x40_alphaOutlineUnvisited * alphaInterp,
mapAlpha, 2.f, mgr, planeXf * preXf, camXf, *x24_world, mapAlpha, 2.f, mgr, modelXf, camXf, *x24_world,
mwInfo, 0.f, 0.f, objectScale, true); mwInfo, 0.f, 0.f, objectScale, true);
mw->Draw(parms, xa0_curAreaId, xa0_curAreaId, mw->Draw(parms, xa0_curAreaId, xa0_curAreaId,
xa8_renderStates[0].x2c_drawDepth1, xa8_renderStates[0].x2c_drawDepth1,

View File

@ -117,6 +117,9 @@ add_library(RuntimeCommon
TCastTo.hpp TCastTo.cpp TCastTo.hpp TCastTo.cpp
GCNTypes.hpp GCNTypes.hpp
${PLAT_SRCS}) ${PLAT_SRCS})
if(COMMAND add_sanitizers)
add_sanitizers(RuntimeCommon)
endif()
if(WINDOWS_STORE) if(WINDOWS_STORE)
set_property(TARGET RuntimeCommon PROPERTY VS_WINRT_COMPONENT TRUE) set_property(TARGET RuntimeCommon PROPERTY VS_WINRT_COMPONENT TRUE)

View File

@ -288,7 +288,7 @@ CPhysicsState CPhysicsActor::GetPhysicsState() const
CMotionState CPhysicsActor::PredictMotion_Internal(float dt) const CMotionState CPhysicsActor::PredictMotion_Internal(float dt) const
{ {
if (xf8_25_angularEnabled) if (xf8_25_angularEnabled)
return PredictMotion(dt); return PredictLinearMotion(dt);
CMotionState msl = PredictLinearMotion(dt); CMotionState msl = PredictLinearMotion(dt);
CMotionState msa = PredictAngularMotion(dt); CMotionState msa = PredictAngularMotion(dt);
@ -313,7 +313,7 @@ CMotionState CPhysicsActor::PredictAngularMotion(float dt) const
{ {
const zeus::CVector3f v1 = xf4_inertiaTensorRecip * (x180_angularImpulse + x198_moveAngularImpulse); const zeus::CVector3f v1 = xf4_inertiaTensorRecip * (x180_angularImpulse + x198_moveAngularImpulse);
zeus::CNUQuaternion q = 0.5f * zeus::CNUQuaternion(0.f, x144_angularVelocity.getVector() + v1); zeus::CNUQuaternion q = 0.5f * zeus::CNUQuaternion(0.f, x144_angularVelocity.getVector() + v1);
CMotionState ret = {zeus::CVector3f::skZero, q * zeus::CNUQuaternion(x34_transform.buildMatrix3f()) * dt, CMotionState ret = {zeus::CVector3f::skZero, (q * zeus::CNUQuaternion(x34_transform.buildMatrix3f())) * dt,
zeus::CVector3f::skZero, (x174_torque * dt) + x180_angularImpulse}; zeus::CVector3f::skZero, (x174_torque * dt) + x180_angularImpulse};
return ret; return ret;
} }

2
amuse

@ -1 +1 @@
Subproject commit 6f7d09ce4582ee7114985de5f3ef75d8d3299d51 Subproject commit 91b88c0568334c49a22c8f7bcc94f35e495f9a00

2
hecl

@ -1 +1 @@
Subproject commit 3650eccc26d5d245cb964a3d16e2a9905de82fa7 Subproject commit a7310a277f6c225dc6731b13a915b6cd1129ab24

1
sanitizers-cmake Submodule

@ -0,0 +1 @@
Subproject commit 6947cff3a9c9305eb9c16135dd81da3feb4bf87f

@ -1 +1 @@
Subproject commit 23eefd6872b03b6701c18be2ea00e517ac8e1f0e Subproject commit 654374c1f28180b47f96a1524662756adfb1ac9c