Compare commits

...

6 Commits

Author SHA1 Message Date
Luke Street b247eaa5d3 (Temp) Disable map scale 2026-06-08 22:49:58 -06:00
Luke Street a58f64ed80 Update aurora 2026-06-08 22:49:28 -06:00
Luke Street 28a37f6b4f Check for sNoUseDrawMtxPtr in J3DModel::entry 2026-06-08 22:14:34 -06:00
Luke Street 285691cd19 Add -debug-asan presets with AddressSanitizer 2026-06-08 22:14:10 -06:00
Luke Street 93e33ecf1a Cap map resolution multiplier
Resolves #1058
Resolves #1422
Resolves #1668
2026-06-08 00:08:00 -06:00
Reilly Brogan e26fab71d6 Add DUSK_PACKAGE_INSTALL (#1966)
Signed-off-by: Reilly Brogan <reilly@reillybrogan.com>
2026-06-07 23:33:49 -06:00
9 changed files with 167 additions and 21 deletions
+48 -7
View File
@@ -126,6 +126,33 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_cmake") set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "_cmake")
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
if (ENABLE_ASAN)
if (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/fsanitize=address>)
add_link_options(/fsanitize=address /INCREMENTAL:NO)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase")
foreach (_lang C CXX)
foreach (_rtc_flag /RTC1 /RTCc /RTCs /RTCu)
string(REPLACE "${_rtc_flag}" "" CMAKE_${_lang}_FLAGS_DEBUG "${CMAKE_${_lang}_FLAGS_DEBUG}")
endforeach ()
endforeach ()
elseif (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
add_compile_options(
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-fsanitize=address>
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:-fno-omit-frame-pointer>
)
add_link_options(-fsanitize=address)
else ()
message(FATAL_ERROR "ENABLE_ASAN requires GNU-like or MSVC-like C/C++ compiler frontends")
endif ()
add_compile_definitions(NDEBUG_SANITIZER) # Avoids absl issue with SwissTable debug code
message(STATUS "dusklight: Enabled AddressSanitizer")
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL Linux) if (CMAKE_SYSTEM_NAME STREQUAL Linux)
set(DAWN_USE_WAYLAND ON CACHE BOOL "Enable support for Wayland surface" FORCE) set(DAWN_USE_WAYLAND ON CACHE BOOL "Enable support for Wayland surface" FORCE)
endif () endif ()
@@ -148,6 +175,7 @@ option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled
option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON)
option(DUSK_ENABLE_UPDATE_CHECKER "Enable update checking support" ON) option(DUSK_ENABLE_UPDATE_CHECKER "Enable update checking support" ON)
option(DUSK_ENABLE_SENTRY_NATIVE "Enable sentry-native crash reporting support" OFF) option(DUSK_ENABLE_SENTRY_NATIVE "Enable sentry-native crash reporting support" OFF)
option(DUSK_PACKAGE_INSTALL "Install Dusklight with a Linux-native file structure" OFF)
option(DUSK_GFX_DEBUG_GROUPS "Report debug groups to the native graphics API" ${DUSK_GFX_DEBUG_GROUPS_DEFAULT}) option(DUSK_GFX_DEBUG_GROUPS "Report debug groups to the native graphics API" ${DUSK_GFX_DEBUG_GROUPS_DEFAULT})
set(DUSK_SENTRY_DSN "" CACHE STRING "Sentry DSN") set(DUSK_SENTRY_DSN "" CACHE STRING "Sentry DSN")
set(DUSK_SENTRY_ENVIRONMENT "development" CACHE STRING "Sentry environment") set(DUSK_SENTRY_ENVIRONMENT "development" CACHE STRING "Sentry environment")
@@ -256,7 +284,6 @@ elseif (MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/utf-8>) add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/utf-8>)
endif () endif ()
include(FetchContent) include(FetchContent)
# Declare all dependencies first so CMake can download them in parallel # Declare all dependencies first so CMake can download them in parallel
@@ -351,9 +378,7 @@ set(GAME_INCLUDE_DIRS
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd set(GAME_LIBS aurora::core aurora::gx aurora::gd aurora::si aurora::vi aurora::pad aurora::mtx aurora::os aurora::dvd
aurora::card freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt aurora::card freeverb cxxopts::cxxopts absl::flat_hash_map nlohmann_json::nlohmann_json TracyClient fmt::fmt
Threads::Threads) Threads::Threads zstd::libzstd)
list(APPEND GAME_LIBS zstd::libzstd)
if (DUSK_ENABLE_SENTRY_NATIVE) if (DUSK_ENABLE_SENTRY_NATIVE)
list(APPEND GAME_LIBS sentry) list(APPEND GAME_LIBS sentry)
@@ -425,6 +450,11 @@ if(ANDROID)
list(APPEND GAME_COMPILE_DEFS TARGET_ANDROID=1) list(APPEND GAME_COMPILE_DEFS TARGET_ANDROID=1)
endif () endif ()
if (DUSK_PACKAGE_INSTALL)
include(GNUInstallDirs)
list(APPEND GAME_COMPILE_DEFS DUSK_ASSET_DIR="${CMAKE_INSTALL_FULL_DATADIR}/dusklight/")
endif ()
if (DUSK_GFX_DEBUG_GROUPS) if (DUSK_GFX_DEBUG_GROUPS)
list(APPEND GAME_COMPILE_DEFS DUSK_GFX_DEBUG_GROUPS=1) list(APPEND GAME_COMPILE_DEFS DUSK_GFX_DEBUG_GROUPS=1)
target_compile_definitions(aurora_gx PRIVATE AURORA_GFX_DEBUG_GROUPS) target_compile_definitions(aurora_gx PRIVATE AURORA_GFX_DEBUG_GROUPS)
@@ -486,6 +516,9 @@ if(ANDROID)
else () else ()
add_executable(dusklight ${DUSK_FILES}) add_executable(dusklight ${DUSK_FILES})
endif () endif ()
if (ENABLE_ASAN)
target_sources(dusklight PRIVATE src/dusk/asan_options.c)
endif ()
target_compile_definitions(dusklight PRIVATE ${GAME_COMPILE_DEFS}) target_compile_definitions(dusklight PRIVATE ${GAME_COMPILE_DEFS})
target_include_directories(dusklight PRIVATE ${GAME_INCLUDE_DIRS}) target_include_directories(dusklight PRIVATE ${GAME_INCLUDE_DIRS})
@@ -648,12 +681,20 @@ set(EXTRA_TARGETS "")
if (TARGET crashpad_handler) if (TARGET crashpad_handler)
list(APPEND EXTRA_TARGETS crashpad_handler) list(APPEND EXTRA_TARGETS crashpad_handler)
endif () endif ()
install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}) if (DUSK_PACKAGE_INSTALL)
install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
install(TARGETS ${BINARY_TARGETS} ${EXTRA_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
aurora_install_runtime_dlls(dusklight ${CMAKE_INSTALL_PREFIX}) aurora_install_runtime_dlls(dusklight ${CMAKE_INSTALL_PREFIX})
if (NOT APPLE) if (NOT APPLE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX}) if (DUSK_PACKAGE_INSTALL)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dusklight)
else()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
endif () endif ()
if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) if (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo AND NOT DUSK_PACKAGE_INSTALL)
set(DEBUG_FILES_LIST "") set(DEBUG_FILES_LIST "")
foreach (target IN LISTS BINARY_TARGETS EXTRA_TARGETS) foreach (target IN LISTS BINARY_TARGETS EXTRA_TARGETS)
get_target_output_name(${target} output_name) get_target_output_name(${target} output_name)
+70
View File
@@ -52,6 +52,16 @@
} }
} }
}, },
{
"name": "asan",
"hidden": true,
"cacheVariables": {
"ENABLE_ASAN": {
"type": "BOOL",
"value": true
}
}
},
{ {
"name": "linux-default", "name": "linux-default",
"displayName": "Linux (default)", "displayName": "Linux (default)",
@@ -83,6 +93,15 @@
"linux-default" "linux-default"
] ]
}, },
{
"name": "linux-default-debug-asan",
"displayName": "Linux (default) Debug ASan",
"inherits": [
"debug",
"linux-default",
"asan"
]
},
{ {
"name": "linux-default-relwithdebinfo", "name": "linux-default-relwithdebinfo",
"displayName": "Linux (default) RelWithDebInfo", "displayName": "Linux (default) RelWithDebInfo",
@@ -110,6 +129,15 @@
"linux-clang" "linux-clang"
] ]
}, },
{
"name": "linux-clang-debug-asan",
"displayName": "Linux (Clang) Debug ASan",
"inherits": [
"debug",
"linux-clang",
"asan"
]
},
{ {
"name": "linux-clang-relwithdebinfo", "name": "linux-clang-relwithdebinfo",
"displayName": "Linux (Clang) RelWithDebInfo", "displayName": "Linux (Clang) RelWithDebInfo",
@@ -148,6 +176,15 @@
"windows-msvc" "windows-msvc"
] ]
}, },
{
"name": "windows-msvc-debug-asan",
"displayName": "Windows (MSVC) Debug ASan",
"inherits": [
"debug",
"windows-msvc",
"asan"
]
},
{ {
"name": "windows-msvc-relwithdebinfo", "name": "windows-msvc-relwithdebinfo",
"displayName": "Windows (MSVC) RelWithDebInfo", "displayName": "Windows (MSVC) RelWithDebInfo",
@@ -239,6 +276,15 @@
"macos-default" "macos-default"
] ]
}, },
{
"name": "macos-default-debug-asan",
"displayName": "macOS (default) Debug ASan",
"inherits": [
"debug",
"macos-default",
"asan"
]
},
{ {
"name": "macos-default-relwithdebinfo", "name": "macos-default-relwithdebinfo",
"displayName": "macOS (default) RelWithDebInfo", "displayName": "macOS (default) RelWithDebInfo",
@@ -529,6 +575,12 @@
"description": "Linux (default) debug build", "description": "Linux (default) debug build",
"displayName": "Linux (default) Debug" "displayName": "Linux (default) Debug"
}, },
{
"name": "linux-default-debug-asan",
"configurePreset": "linux-default-debug-asan",
"description": "Linux (default) debug build with AddressSanitizer",
"displayName": "Linux (default) Debug ASan"
},
{ {
"name": "linux-default-relwithdebinfo", "name": "linux-default-relwithdebinfo",
"configurePreset": "linux-default-relwithdebinfo", "configurePreset": "linux-default-relwithdebinfo",
@@ -541,6 +593,12 @@
"description": "Linux (Clang) debug build", "description": "Linux (Clang) debug build",
"displayName": "Linux (Clang) Debug" "displayName": "Linux (Clang) Debug"
}, },
{
"name": "linux-clang-debug-asan",
"configurePreset": "linux-clang-debug-asan",
"description": "Linux (Clang) debug build with AddressSanitizer",
"displayName": "Linux (Clang) Debug ASan"
},
{ {
"name": "linux-clang-relwithdebinfo", "name": "linux-clang-relwithdebinfo",
"configurePreset": "linux-clang-relwithdebinfo", "configurePreset": "linux-clang-relwithdebinfo",
@@ -553,6 +611,12 @@
"description": "macOS debug build", "description": "macOS debug build",
"displayName": "macOS Debug" "displayName": "macOS Debug"
}, },
{
"name": "macos-default-debug-asan",
"configurePreset": "macos-default-debug-asan",
"description": "macOS debug build with AddressSanitizer",
"displayName": "macOS Debug ASan"
},
{ {
"name": "macos-default-relwithdebinfo", "name": "macos-default-relwithdebinfo",
"configurePreset": "macos-default-relwithdebinfo", "configurePreset": "macos-default-relwithdebinfo",
@@ -610,6 +674,12 @@
"description": "Windows (MSVC) debug build", "description": "Windows (MSVC) debug build",
"displayName": "Windows (MSVC) Debug" "displayName": "Windows (MSVC) Debug"
}, },
{
"name": "windows-msvc-debug-asan",
"configurePreset": "windows-msvc-debug-asan",
"description": "Windows (MSVC) debug build with AddressSanitizer",
"displayName": "Windows (MSVC) Debug ASan"
},
{ {
"name": "windows-msvc-relwithdebinfo", "name": "windows-msvc-relwithdebinfo",
"configurePreset": "windows-msvc-relwithdebinfo", "configurePreset": "windows-msvc-relwithdebinfo",
+4
View File
@@ -180,6 +180,7 @@ cmake --build --preset macos-default-relwithdebinfo
Alternate presets available: Alternate presets available:
* `macos-default-debug`: Clang, Debug * `macos-default-debug`: Clang, Debug
* `macos-default-debug-asan`: Clang, Debug, AddressSanitizer
**ninja (Linux)** **ninja (Linux)**
@@ -191,8 +192,10 @@ cmake --build --preset linux-default-relwithdebinfo
Alternate presets available: Alternate presets available:
* `linux-default-debug`: GCC, Debug * `linux-default-debug`: GCC, Debug
* `linux-default-debug-asan`: GCC, Debug, AddressSanitizer
* `linux-clang-relwithdebinfo`: Clang, RelWithDebInfo * `linux-clang-relwithdebinfo`: Clang, RelWithDebInfo
* `linux-clang-debug`: Clang, Debug * `linux-clang-debug`: Clang, Debug
* `linux-clang-debug-asan`: Clang, Debug, AddressSanitizer
**ninja (Windows)** **ninja (Windows)**
@@ -204,6 +207,7 @@ cmake --build --preset windows-msvc-relwithdebinfo
Alternate presets available: Alternate presets available:
* `windows-msvc-debug`: MSVC, Debug * `windows-msvc-debug`: MSVC, Debug
* `windows-msvc-debug-asan`: MSVC, Debug, AddressSanitizer
* `windows-clang-relwithdebinfo`: Clang-cl, RelWithDebInfo * `windows-clang-relwithdebinfo`: Clang-cl, RelWithDebInfo
* `windows-clang-debug`: Clang-cl, Debug * `windows-clang-debug`: Clang-cl, Debug
+1 -1
@@ -542,8 +542,11 @@ void J3DModel::viewCalc() {
} }
#ifdef TARGET_PC #ifdef TARGET_PC
for (u16 i = 0; i < mModelData->getDrawMtxNum(); ++i) { Mtx* drawMtx = getDrawMtxPtr();
dusk::frame_interp::record_final_mtx(getDrawMtxPtr()[i]); if (drawMtx != J3DMtxBuffer::sNoUseDrawMtxPtr) {
for (u16 i = 0; i < mModelData->getDrawMtxNum(); ++i) {
dusk::frame_interp::record_final_mtx(drawMtx[i]);
}
} }
#endif #endif
+29 -11
View File
@@ -19,12 +19,30 @@
#include <numbers> #include <numbers>
#include <array> #include <array>
constexpr u16 kMapResolutionMultiplier = 4; constexpr u16 kPreferredMapResolutionMultiplier = 1;
constexpr u16 kMapImageSide = 16 * kMapResolutionMultiplier; constexpr u32 kMaxMapRenderPixels = 2048 * 2048;
constexpr u16 kMapImageSide = 16 * kPreferredMapResolutionMultiplier;
constexpr u32 kMapImageTotalPixels = kMapImageSide * kMapImageSide; constexpr u32 kMapImageTotalPixels = kMapImageSide * kMapImageSide;
typedef std::function<u8(size_t, size_t)> PaintI8Fn; typedef std::function<u8(size_t, size_t)> PaintI8Fn;
u16 map_resolution_multiplier(u16 width, u16 height) {
const u32 basePixels = static_cast<u32>(width) * height;
if (basePixels == 0) {
return 1;
}
u16 scale = kPreferredMapResolutionMultiplier;
while (scale > 1) {
const u32 scalePixels = static_cast<u32>(scale) * scale;
if (basePixels <= kMaxMapRenderPixels / scalePixels) {
break;
}
scale--;
}
return scale;
}
void paint_i8(std::span<u8> dst, size_t width, PaintI8Fn paint) { void paint_i8(std::span<u8> dst, size_t width, PaintI8Fn paint) {
const auto blocksAcross = width >> 3; const auto blocksAcross = width >> 3;
@@ -478,9 +496,9 @@ void dRenderingMap_c::makeResTIMG(ResTIMG* p_image, u16 width, u16 height, u8* p
p_image->format = GX_TF_C8; p_image->format = GX_TF_C8;
p_image->alphaEnabled = 2; p_image->alphaEnabled = 2;
#ifdef TARGET_PC #ifdef TARGET_PC
// Increase map render resolution const u16 scale = map_resolution_multiplier(width, height);
p_image->width = width * kMapResolutionMultiplier; p_image->width = width * scale;
p_image->height = height * kMapResolutionMultiplier; p_image->height = height * scale;
#else #else
p_image->width = width; p_image->width = width;
p_image->height = height; p_image->height = height;
@@ -563,9 +581,9 @@ void dRenderingFDAmap_c::drawBack() const {
void dRenderingFDAmap_c::preRenderingMap() { void dRenderingFDAmap_c::preRenderingMap() {
#ifdef TARGET_PC #ifdef TARGET_PC
// Increase map render resolution const u16 scale = map_resolution_multiplier(mTexWidth, mTexHeight);
const u16 w = mTexWidth * kMapResolutionMultiplier; const u16 w = mTexWidth * scale;
const u16 h = mTexHeight * kMapResolutionMultiplier; const u16 h = mTexHeight * scale;
GXCreateFrameBuffer(w, h); GXCreateFrameBuffer(w, h);
// Set logical viewport dimensions // Set logical viewport dimensions
GXSetViewport(0.0f, 0.0f, mTexWidth, mTexHeight, 0.0f, 1.0f); GXSetViewport(0.0f, 0.0f, mTexWidth, mTexHeight, 0.0f, 1.0f);
@@ -610,9 +628,9 @@ void dRenderingFDAmap_c::preRenderingMap() {
void dRenderingFDAmap_c::postRenderingMap() { void dRenderingFDAmap_c::postRenderingMap() {
GXSetCopyFilter(GX_FALSE, NULL, GX_FALSE, NULL); GXSetCopyFilter(GX_FALSE, NULL, GX_FALSE, NULL);
#ifdef TARGET_PC #ifdef TARGET_PC
// Increase map render resolution const u16 scale = map_resolution_multiplier(mTexWidth, mTexHeight);
const u16 w = mTexWidth * kMapResolutionMultiplier; const u16 w = mTexWidth * scale;
const u16 h = mTexHeight * kMapResolutionMultiplier; const u16 h = mTexHeight * scale;
GXSetTexCopySrc(0, 0, w, h); GXSetTexCopySrc(0, 0, w, h);
GXSetTexCopyDst(w, h, GX_CTF_R8, GX_FALSE); GXSetTexCopyDst(w, h, GX_CTF_R8, GX_FALSE);
GXCopyTex(field_0x4, GX_TRUE); GXCopyTex(field_0x4, GX_TRUE);
+3
View File
@@ -0,0 +1,3 @@
const char* __asan_default_options(void) {
return "abort_on_error=1:symbolize=1:intercept_memcmp=0:detect_leaks=0";
}
+4
View File
@@ -20,7 +20,11 @@
namespace dusk { namespace dusk {
namespace { namespace {
std::string GetAssetPath(const char* assetName) { std::string GetAssetPath(const char* assetName) {
#ifdef DUSK_ASSET_DIR
const char* basePath = DUSK_ASSET_DIR;
#else
const char* basePath = SDL_GetBasePath(); const char* basePath = SDL_GetBasePath();
#endif
if (basePath != nullptr && basePath[0] != '\0') { if (basePath != nullptr && basePath[0] != '\0') {
return std::string(basePath) + "res/" + assetName; return std::string(basePath) + "res/" + assetName;
} }
+3
View File
@@ -577,6 +577,9 @@ int game_main(int argc, char* argv[]) {
config.appName = dusk::AppName; config.appName = dusk::AppName;
config.userPath = reinterpret_cast<const char*>(userPathString.c_str()); config.userPath = reinterpret_cast<const char*>(userPathString.c_str());
config.cachePath = reinterpret_cast<const char*>(cachePathString.c_str()); config.cachePath = reinterpret_cast<const char*>(cachePathString.c_str());
#ifdef DUSK_ASSET_DIR
config.resourcesPath = DUSK_ASSET_DIR;
#endif
config.vsync = dusk::getSettings().video.enableVsync; config.vsync = dusk::getSettings().video.enableVsync;
config.startFullscreen = dusk::getSettings().video.enableFullscreen; config.startFullscreen = dusk::getSettings().video.enableFullscreen;
config.windowPosX = -1; config.windowPosX = -1;