mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2026-05-10 19:01:53 +00:00
Remove rt64
This commit is contained in:
parent
55801577be
commit
5bd4fc2958
9 changed files with 42 additions and 48 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "thirdparty/xxHash"]
|
||||||
|
path = thirdparty/xxHash
|
||||||
|
url = git@github.com:Cyan4973/xxHash.git
|
||||||
|
|
@ -5,9 +5,10 @@ This repo is a WIP as files are moved out of Zelda64Recomp and genericized. It c
|
||||||
|
|
||||||
This repo contains two libraries: Ultramodern and Librecomp.
|
This repo contains two libraries: Ultramodern and Librecomp.
|
||||||
|
|
||||||
### Ultramodern
|
## Ultramodern
|
||||||
|
|
||||||
Ultramodern is a reimplementation of much of the core functionality of libultra. It can be used with either statically recompiled projects that use N64Recomp or direct source ports. It implements the following libultra functionality:
|
Ultramodern is a reimplementation of much of the core functionality of libultra. It can be used with either statically recompiled projects that use N64Recomp or direct source ports. It implements the following libultra functionality:
|
||||||
|
|
||||||
* Threads
|
* Threads
|
||||||
* Controllers
|
* Controllers
|
||||||
* Audio
|
* Audio
|
||||||
|
|
@ -18,11 +19,12 @@ Ultramodern is a reimplementation of much of the core functionality of libultra.
|
||||||
|
|
||||||
Platform-specific I/O is handled via callbacks that are provided by the project using ultramodern. This includes reading from controllers and playing back audio samples.
|
Platform-specific I/O is handled via callbacks that are provided by the project using ultramodern. This includes reading from controllers and playing back audio samples.
|
||||||
|
|
||||||
Currently, ultramodern depends directly on [RT64](https://github.com/rt64/rt64) for rendering. It may be decoupled in the future to allow using other renderers for targeting different platforms.
|
ultramodern expects the user to provide and regiter a graphics renderer. The recommended one is [RT64](https://github.com/rt64/rt64).
|
||||||
|
|
||||||
### Librecomp
|
## Librecomp
|
||||||
|
|
||||||
Librecomp is a library meant to be used to bridge the gap between code generated by N64Recomp and ultramodern. It provides wrappers to allow recompiled code to call ultramodern. Librecomp also provides some of the remaining libultra functionality that ultramodern doesn't provide, which includes:
|
Librecomp is a library meant to be used to bridge the gap between code generated by N64Recomp and ultramodern. It provides wrappers to allow recompiled code to call ultramodern. Librecomp also provides some of the remaining libultra functionality that ultramodern doesn't provide, which includes:
|
||||||
|
|
||||||
* Overlay handling
|
* Overlay handling
|
||||||
* PI DMA (ROM reads)
|
* PI DMA (ROM reads)
|
||||||
* EEPROM, SRAM and Flashram saving (these may be partially moved to ultramodern in the future)
|
* EEPROM, SRAM and Flashram saving (these may be partially moved to ultramodern in the future)
|
||||||
|
|
@ -26,12 +26,9 @@ add_library(librecomp STATIC
|
||||||
target_include_directories(librecomp PUBLIC
|
target_include_directories(librecomp PUBLIC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||||
"${PROJECT_SOURCE_DIR}/../ultramodern/include"
|
"${PROJECT_SOURCE_DIR}/../ultramodern/include"
|
||||||
|
"${PROJECT_SOURCE_DIR}/../thirdparty"
|
||||||
"${PROJECT_SOURCE_DIR}/../thirdparty/concurrentqueue"
|
"${PROJECT_SOURCE_DIR}/../thirdparty/concurrentqueue"
|
||||||
)
|
)
|
||||||
target_include_directories(librecomp PRIVATE
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src/contrib"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/librecomp"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_compile_options(librecomp PRIVATE -Wno-deprecated-declarations)
|
target_compile_options(librecomp PRIVATE -Wno-deprecated-declarations)
|
||||||
|
|
||||||
|
|
|
||||||
1
rt64
1
rt64
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 1adcbea31a04f2403da729eb5dfed3950dd7ec52
|
|
||||||
1
thirdparty/xxHash
vendored
Submodule
1
thirdparty/xxHash
vendored
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit ac3a25da3d957d9ef3e4114d9f8332d34ce83a46
|
||||||
|
|
@ -28,21 +28,11 @@ add_library(ultramodern STATIC
|
||||||
|
|
||||||
target_include_directories(ultramodern PUBLIC
|
target_include_directories(ultramodern PUBLIC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
|
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
|
||||||
|
"${PROJECT_SOURCE_DIR}/../thirdparty"
|
||||||
"${PROJECT_SOURCE_DIR}/../thirdparty/concurrentqueue"
|
"${PROJECT_SOURCE_DIR}/../thirdparty/concurrentqueue"
|
||||||
"${PROJECT_SOURCE_DIR}/../thirdparty/sse2neon"
|
"${PROJECT_SOURCE_DIR}/../thirdparty/sse2neon"
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: remove when rt64 is no longer a hard dependency
|
|
||||||
target_include_directories(ultramodern PRIVATE
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src"
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src/contrib"
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src/contrib/hlslpp/include"
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src/contrib/dxc/inc"
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src/rhi"
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src/render"
|
|
||||||
"${PROJECT_SOURCE_DIR}/../rt64/src/contrib/nativefiledialog-extended/src/include"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
# Fetch SDL2 on windows
|
# Fetch SDL2 on windows
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
|
||||||
#include "ultra64.h"
|
#include "ultra64.h"
|
||||||
|
|
@ -20,6 +21,7 @@ namespace ultramodern {
|
||||||
virtual ~GraphicsConfig() = 0;
|
virtual ~GraphicsConfig() = 0;
|
||||||
|
|
||||||
virtual std::string get_graphics_api_name() const = 0;
|
virtual std::string get_graphics_api_name() const = 0;
|
||||||
|
virtual std::optional<uint32_t> get_target_framerate() const = 0;
|
||||||
|
|
||||||
auto operator<=>(const GraphicsConfig& rhs) const = default;
|
auto operator<=>(const GraphicsConfig& rhs) const = default;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -227,21 +227,12 @@ std::atomic_uint32_t display_refresh_rate = 60;
|
||||||
std::atomic<float> resolution_scale = 1.0f;
|
std::atomic<float> resolution_scale = 1.0f;
|
||||||
|
|
||||||
uint32_t ultramodern::get_target_framerate(uint32_t original) {
|
uint32_t ultramodern::get_target_framerate(uint32_t original) {
|
||||||
#if 0
|
auto maybe_framerate = ultramodern::renderer::get_graphics_config()->get_target_framerate();
|
||||||
ultramodern::GraphicsConfig graphics_config = ultramodern::get_graphics_config();
|
|
||||||
|
|
||||||
switch (graphics_config.rr_option) {
|
if (maybe_framerate.has_value()) {
|
||||||
case RT64::UserConfiguration::RefreshRate::Original:
|
return maybe_framerate.value();
|
||||||
default:
|
|
||||||
return original;
|
|
||||||
case RT64::UserConfiguration::RefreshRate::Manual:
|
|
||||||
return graphics_config.rr_manual_value;
|
|
||||||
case RT64::UserConfiguration::RefreshRate::Display:
|
|
||||||
#endif
|
|
||||||
return display_refresh_rate.load();
|
|
||||||
#if 0
|
|
||||||
}
|
}
|
||||||
#endif
|
return display_refresh_rate.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ultramodern::get_display_refresh_rate() {
|
uint32_t ultramodern::get_display_refresh_rate() {
|
||||||
|
|
@ -256,7 +247,7 @@ void ultramodern::load_shader_cache(std::span<const char> cache_data) {
|
||||||
events_context.action_queue.enqueue(LoadShaderCacheAction{cache_data});
|
events_context.action_queue.enqueue(LoadShaderCacheAction{cache_data});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::atomic<ultramodern::renderer::SetupResult> rt64_setup_result = ultramodern::renderer::SetupResult::Success;
|
std::atomic<ultramodern::renderer::SetupResult> renderer_setup_result = ultramodern::renderer::SetupResult::Success;
|
||||||
|
|
||||||
void gfx_thread_func(uint8_t* rdram, moodycamel::LightweightSemaphore* thread_ready, ultramodern::WindowHandle window_handle) {
|
void gfx_thread_func(uint8_t* rdram, moodycamel::LightweightSemaphore* thread_ready, ultramodern::WindowHandle window_handle) {
|
||||||
bool enabled_instant_present = false;
|
bool enabled_instant_present = false;
|
||||||
|
|
@ -267,11 +258,10 @@ void gfx_thread_func(uint8_t* rdram, moodycamel::LightweightSemaphore* thread_re
|
||||||
|
|
||||||
auto old_config = ultramodern::renderer::get_graphics_config();
|
auto old_config = ultramodern::renderer::get_graphics_config();
|
||||||
|
|
||||||
//ultramodern::RT64Context rt64{rdram, window_handle, cur_config.load().developer_mode};
|
|
||||||
auto renderer_context = ultramodern::renderer::create_render_context(rdram, window_handle, ultramodern::renderer::get_graphics_config()->developer_mode);
|
auto renderer_context = ultramodern::renderer::create_render_context(rdram, window_handle, ultramodern::renderer::get_graphics_config()->developer_mode);
|
||||||
|
|
||||||
if (!renderer_context->valid()) {
|
if (!renderer_context->valid()) {
|
||||||
rt64_setup_result.store(renderer_context->get_setup_result());
|
renderer_setup_result.store(renderer_context->get_setup_result());
|
||||||
// Notify the caller thread that this thread is ready.
|
// Notify the caller thread that this thread is ready.
|
||||||
thread_ready->signal();
|
thread_ready->signal();
|
||||||
return;
|
return;
|
||||||
|
|
@ -304,11 +294,11 @@ void gfx_thread_func(uint8_t* rdram, moodycamel::LightweightSemaphore* thread_re
|
||||||
sp_complete();
|
sp_complete();
|
||||||
ultramodern::measure_input_latency();
|
ultramodern::measure_input_latency();
|
||||||
|
|
||||||
auto rt64_start = std::chrono::high_resolution_clock::now();
|
auto renderer_start = std::chrono::high_resolution_clock::now();
|
||||||
renderer_context->send_dl(&task_action->task);
|
renderer_context->send_dl(&task_action->task);
|
||||||
auto rt64_end = std::chrono::high_resolution_clock::now();
|
auto renderer_end = std::chrono::high_resolution_clock::now();
|
||||||
dp_complete();
|
dp_complete();
|
||||||
// printf("RT64 ProcessDList time: %d us\n", static_cast<u32>(std::chrono::duration_cast<std::chrono::microseconds>(rt64_end - rt64_start).count()));
|
// printf("Renderer ProcessDList time: %d us\n", static_cast<u32>(std::chrono::duration_cast<std::chrono::microseconds>(renderer_end - renderer_start).count()));
|
||||||
}
|
}
|
||||||
else if (const auto* swap_action = std::get_if<SwapBuffersAction>(&action)) {
|
else if (const auto* swap_action = std::get_if<SwapBuffersAction>(&action)) {
|
||||||
events_context.vi.current_buffer = events_context.vi.next_buffer;
|
events_context.vi.current_buffer = events_context.vi.next_buffer;
|
||||||
|
|
@ -511,32 +501,32 @@ void ultramodern::init_events(RDRAM_ARG ultramodern::WindowHandle window_handle)
|
||||||
gfx_thread_ready.wait();
|
gfx_thread_ready.wait();
|
||||||
task_thread_ready.wait();
|
task_thread_ready.wait();
|
||||||
|
|
||||||
ultramodern::renderer::SetupResult setup_result = rt64_setup_result.load();
|
ultramodern::renderer::SetupResult setup_result = renderer_setup_result.load();
|
||||||
if (rt64_setup_result != ultramodern::renderer::SetupResult::Success) {
|
if (renderer_setup_result != ultramodern::renderer::SetupResult::Success) {
|
||||||
auto show_rt64_error = [](const std::string& msg) {
|
auto show_renderer_error = [](const std::string& msg) {
|
||||||
std::string error_msg = "An error has been encountered on startup: " + msg;
|
std::string error_msg = "An error has been encountered on startup: " + msg;
|
||||||
|
|
||||||
ultramodern::error_handling::message_box(error_msg.c_str());
|
ultramodern::error_handling::message_box(error_msg.c_str());
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string driver_os_suffix = "\nPlease make sure your GPU drivers and your OS are up to date.";
|
const std::string driver_os_suffix = "\nPlease make sure your GPU drivers and your OS are up to date.";
|
||||||
switch (rt64_setup_result) {
|
switch (renderer_setup_result) {
|
||||||
case ultramodern::renderer::SetupResult::Success:
|
case ultramodern::renderer::SetupResult::Success:
|
||||||
break;
|
break;
|
||||||
case ultramodern::renderer::SetupResult::DynamicLibrariesNotFound:
|
case ultramodern::renderer::SetupResult::DynamicLibrariesNotFound:
|
||||||
show_rt64_error("Failed to load dynamic libraries. Make sure the DLLs are next to the recomp executable.");
|
show_renderer_error("Failed to load dynamic libraries. Make sure the DLLs are next to the recomp executable.");
|
||||||
break;
|
break;
|
||||||
case ultramodern::renderer::SetupResult::InvalidGraphicsAPI:
|
case ultramodern::renderer::SetupResult::InvalidGraphicsAPI:
|
||||||
show_rt64_error(ultramodern::renderer::get_graphics_config()->get_graphics_api_name() + " is not supported on this platform. Please select a different graphics API.");
|
show_renderer_error(ultramodern::renderer::get_graphics_config()->get_graphics_api_name() + " is not supported on this platform. Please select a different graphics API.");
|
||||||
break;
|
break;
|
||||||
case ultramodern::renderer::SetupResult::GraphicsAPINotFound:
|
case ultramodern::renderer::SetupResult::GraphicsAPINotFound:
|
||||||
show_rt64_error("Unable to initialize " + ultramodern::renderer::get_graphics_config()->get_graphics_api_name() + "." + driver_os_suffix);
|
show_renderer_error("Unable to initialize " + ultramodern::renderer::get_graphics_config()->get_graphics_api_name() + "." + driver_os_suffix);
|
||||||
break;
|
break;
|
||||||
case ultramodern::renderer::SetupResult::GraphicsDeviceNotFound:
|
case ultramodern::renderer::SetupResult::GraphicsDeviceNotFound:
|
||||||
show_rt64_error("Unable to find compatible graphics device." + driver_os_suffix);
|
show_renderer_error("Unable to find compatible graphics device." + driver_os_suffix);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw std::runtime_error("Failed to initialize RT64");
|
throw std::runtime_error("Failed to initialize the renderer");
|
||||||
}
|
}
|
||||||
|
|
||||||
events_context.vi.thread = std::thread{ vi_thread_func };
|
events_context.vi.thread = std::thread{ vi_thread_func };
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include "ultramodern/renderer_wrapper.hpp"
|
#include "ultramodern/renderer_wrapper.hpp"
|
||||||
#include "ultramodern/ultramodern.hpp"
|
#include "ultramodern/ultramodern.hpp"
|
||||||
|
|
||||||
|
|
@ -24,9 +26,17 @@ static std::mutex graphic_config_mutex;
|
||||||
|
|
||||||
void ultramodern::renderer::set_graphics_config(const GraphicsConfig* config) {
|
void ultramodern::renderer::set_graphics_config(const GraphicsConfig* config) {
|
||||||
std::lock_guard<std::mutex> lock(graphic_config_mutex);
|
std::lock_guard<std::mutex> lock(graphic_config_mutex);
|
||||||
|
assert(config != nullptr);
|
||||||
graphic_config.reset(config);
|
graphic_config.reset(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ultramodern::renderer::GraphicsConfig* ultramodern::renderer::get_graphics_config() {
|
const ultramodern::renderer::GraphicsConfig* ultramodern::renderer::get_graphics_config() {
|
||||||
return graphic_config.get();
|
std::lock_guard<std::mutex> lock(graphic_config_mutex);
|
||||||
|
auto ptr = graphic_config.get();
|
||||||
|
if (ptr == nullptr) {
|
||||||
|
error_handling::message_box("[Error] The graphic configuration was not registered");
|
||||||
|
// TODO: should we make a macro for this?
|
||||||
|
error_handling::quick_exit(__FILE__, __LINE__, __func__);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue