diff --git a/parallel-rdp/interface.cpp b/parallel-rdp/interface.cpp index 45c98827..7395fcca 100644 --- a/parallel-rdp/interface.cpp +++ b/parallel-rdp/interface.cpp @@ -391,7 +391,7 @@ static ImageHandle create_message_image(Vulkan::Device &device, int width, return handle; } -void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, +bool rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, size_t font_size, uint32_t save_state_slot) { memset(&rdp_device, 0, sizeof(RDP_DEVICE)); memset(&callback, 0, sizeof(CALL_BACK)); @@ -401,7 +401,7 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, bool result = SDL_AddEventWatch(sdl_event_filter, nullptr); if (!result) { LOGE("Could not add event watch.\n"); - return; + return false; } gfx_info = _gfx_info; @@ -429,19 +429,22 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, Context::SystemHandles handles = {}; if (!::Vulkan::Context::init_loader( (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr())) { + LOGE("Failed to init vulkan loader.\n"); rdp_close(); - return; + return false; } if (!wsi->init_simple(1, handles)) { + LOGE("Failed to init parallel-rdp.\n"); rdp_close(); - return; + return false; } rdp_new_processor(); if (!processor->device_is_supported()) { + LOGE("Failed to init parallel-rdp processor.\n"); rdp_close(); - return; + return false; } message_font = @@ -452,8 +455,9 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, achievement_challenge_indicator_font_size * SDL_GetWindowDisplayScale(window)); if (!message_font || !achievement_challenge_indicator_font) { + LOGE("Failed to init fonts.\n"); rdp_close(); - return; + return false; } wsi->begin_frame(); @@ -473,6 +477,8 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, achievement_progress_indicator_image = Vulkan::ImageHandle(); fps_image = Vulkan::ImageHandle(); display_fps = false; + + return true; } void rdp_close() { diff --git a/parallel-rdp/interface.hpp b/parallel-rdp/interface.hpp index db2062d1..c273d14a 100644 --- a/parallel-rdp/interface.hpp +++ b/parallel-rdp/interface.hpp @@ -52,7 +52,7 @@ typedef enum { MESSAGE_LONG = 6000, } MESSAGE_LENGTH; -void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, +bool rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, size_t font_size, uint32_t save_state_slot); void rdp_close(); void rdp_set_vi_register(uint32_t reg, uint32_t value); @@ -65,7 +65,8 @@ void rdp_onscreen_message(const char *message, MESSAGE_LENGTH milliseconds); void rdp_check_framebuffers(uint32_t address, uint32_t length); size_t rdp_state_size(); void rdp_save_state(uint8_t *state); -void rdp_load_state(GFX_INFO _gfx_info, const uint8_t *state, size_t state_size); +void rdp_load_state(GFX_INFO _gfx_info, const uint8_t *state, + size_t state_size); void rdp_set_fps(uint32_t fps, uint32_t vis); JoystickEvent get_joystick_event(); diff --git a/src/ui/video.rs b/src/ui/video.rs index 62ad5b30..922f3d99 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -126,13 +126,15 @@ pub fn init(device: &mut device::Device, netplay: bool) { unsafe { let font_bytes = include_bytes!("../../data/ui/RobotoMono-Regular.ttf"); - rdp_init( + if !rdp_init( device.ui.video.window as *mut std::ffi::c_void, gfx_info, font_bytes.as_ptr() as *const std::ffi::c_void, font_bytes.len(), device.ui.storage.save_state_slot, - ) + ) { + panic!("Failed to init parallel-rdp."); + } } fps_counter(&mut device.ui);