From 218f52c5bf39e133628ed2465790e309514cb97c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 21 Jul 2015 01:45:32 +0200 Subject: [PATCH 1/6] Minor nits --- gfx/drivers/gl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 249a5717bc..9ceb367168 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -106,8 +106,8 @@ static INLINE bool gl_query_extension(gl_t *gl, const char *ext) if (gl->core_context) { #ifdef GL_NUM_EXTENSIONS - GLint i, exts; - exts = 0; + GLint i; + GLint exts = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &exts); for (i = 0; i < exts; i++) { @@ -327,8 +327,10 @@ static INLINE GLenum min_filter_to_mag(GLenum type) case GL_NEAREST_MIPMAP_NEAREST: return GL_NEAREST; default: - return type; + break; } + + return type; } #ifdef HAVE_FBO From 7df80fea83e0fe9758ea6a25393bff78dde0b362 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 21 Jul 2015 01:58:57 +0200 Subject: [PATCH 2/6] Take out one ifndef HAVE_PSGL preprocessor define --- gfx/drivers/gl_common.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gfx/drivers/gl_common.c b/gfx/drivers/gl_common.c index fa81ad4e3a..7b908cfaee 100644 --- a/gfx/drivers/gl_common.c +++ b/gfx/drivers/gl_common.c @@ -95,9 +95,7 @@ void gl_load_texture_data(GLuint id, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); -#ifndef HAVE_PSGL glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); -#endif glTexImage2D(GL_TEXTURE_2D, 0, (driver->gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, From 248e8ad1ca794e1bd245e45252ef6466f6c87e27 Mon Sep 17 00:00:00 2001 From: Toad King Date: Mon, 20 Jul 2015 20:08:13 -0500 Subject: [PATCH 3/6] [GX] properly shut down dev thread --- frontend/drivers/platform_gx.c | 35 +++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index d4b010639e..57a551baf5 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -53,6 +53,7 @@ extern void system_exec_wii(const char *path, bool should_load_game); #endif #include #include +#include #ifdef USBGECKO #include @@ -108,10 +109,12 @@ static struct { static slock_t *gx_device_mutex; static slock_t *gx_device_cond_mutex; static scond_t *gx_device_cond; +static sthread_t *gx_device_thread; +static volatile bool gx_stop_dev_thread; -static void *gx_devthread(void *a) +static void gx_devthread(void *a) { - while (1) + while (!gx_stop_dev_thread) { unsigned i; @@ -119,7 +122,7 @@ static void *gx_devthread(void *a) for (i = 0; i < GX_DEVICE_END; i++) { - if (gx_devices[i].mounted && + if (gx_devices[i].mounted && !gx_devices[i].interface->isInserted()) { gx_devices[i].mounted = false; @@ -135,8 +138,6 @@ static void *gx_devthread(void *a) scond_wait_timeout(gx_device_cond, gx_device_cond_mutex, 1000000); slock_unlock(gx_device_cond_mutex); } - - return NULL; } static int gx_get_device_from_path(const char *path) @@ -222,7 +223,7 @@ static void frontend_gx_get_environment_settings(int *argc, char *argv[], gx_rom_path[0] = '\0'; #else #ifdef HW_RVL - /* needed on Wii; loaders follow a dumb standard where the path and + /* needed on Wii; loaders follow a dumb standard where the path and * filename are separate in the argument list */ if (*argc > 2 && argv[1] != NULL && argv[2] != NULL) { @@ -297,7 +298,6 @@ static void frontend_gx_init(void *data) #endif #if defined(HW_RVL) && !defined(IS_SALAMANDER) - OSThread gx_device_thread; gx_devices[GX_DEVICE_SD].interface = &__io_wiisd; gx_devices[GX_DEVICE_SD].name = "sd"; gx_devices[GX_DEVICE_SD].mounted = fatMountSimple( @@ -312,7 +312,20 @@ static void frontend_gx_init(void *data) gx_device_cond_mutex = slock_new(); gx_device_cond = scond_new(); gx_device_mutex = slock_new(); - OSCreateThread(&gx_device_thread, gx_devthread, 0, NULL, NULL, 0, 66, 0); + gx_device_thread = sthread_create(gx_devthread, NULL); +#endif +} + +static void frontend_gx_deinit(void *data) +{ + (void)data; + +#if defined(HW_RVL) && !defined(IS_SALAMANDER) + slock_lock(gx_device_cond_mutex); + gx_stop_dev_thread = true; + slock_unlock(gx_device_cond_mutex); + scond_signal(gx_device_cond); + sthread_join(gx_device_thread); #endif } @@ -346,7 +359,7 @@ static void frontend_gx_process_args(int *argc, char *argv[]) #ifndef IS_SALAMANDER settings_t *settings = config_get_ptr(); - /* A big hack: sometimes Salamander doesn't save the new core + /* A big hack: sometimes Salamander doesn't save the new core * it loads on first boot, so we make sure * settings->libretro is set here. */ if (!settings->libretro[0] && *argc >= 1 && strrchr(argv[0], '/')) @@ -407,7 +420,7 @@ static int frontend_gx_parse_drive_list(void *data) const frontend_ctx_driver_t frontend_ctx_gx = { frontend_gx_get_environment_settings, frontend_gx_init, - NULL, /* deinit */ + frontend_gx_deinit, frontend_gx_exitspawn, frontend_gx_process_args, frontend_gx_exec, From 866970fb1c82540490375bee5cc54728444dfa5a Mon Sep 17 00:00:00 2001 From: Toad King Date: Mon, 20 Jul 2015 21:01:11 -0500 Subject: [PATCH 4/6] small changes to hotplugging support --- frontend/drivers/platform_gx.c | 28 ++++++++++------------------ menu/menu_displaylist.c | 19 ++++--------------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 57a551baf5..f8a1e57d45 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -120,15 +120,16 @@ static void gx_devthread(void *a) slock_lock(gx_device_mutex); - for (i = 0; i < GX_DEVICE_END; i++) - { - if (gx_devices[i].mounted && - !gx_devices[i].interface->isInserted()) - { - gx_devices[i].mounted = false; - char n[8]; - snprintf(n, sizeof(n), "%s:", gx_devices[i].name); - fatUnmount(n); + for (i = 0; i < GX_DEVICE_END; i++) { + if (gx_devices[i].mounted) { + if (!gx_devices[i].interface->isInserted()) { + gx_devices[i].mounted = false; + char n[8]; + snprintf(n, sizeof(n), "%s:", gx_devices[i].name); + fatUnmount(n); + } + } else if (gx_devices[i].interface->startup() && gx_devices[i].interface->isInserted()) { + gx_devices[i].mounted = fatMountSimple(gx_devices[i].name, gx_devices[i].interface); } } @@ -139,15 +140,6 @@ static void gx_devthread(void *a) slock_unlock(gx_device_cond_mutex); } } - -static int gx_get_device_from_path(const char *path) -{ - if (strstr(path, "sd:") == path) - return GX_DEVICE_SD; - if (strstr(path, "usb:") == path) - return GX_DEVICE_USB; - return -1; -} #endif #ifdef HAVE_LOGGER diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index eef24caeeb..877cc02395 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -89,7 +89,7 @@ static void print_buf_lines(file_list_t *list, char *buf, int buf_size, char *last = NULL; fill_pathname_join(core_path, settings->libretro_info_path, line_start, sizeof(core_path)); - + (void)last; path_remove_extension(core_path); @@ -814,7 +814,7 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, fill_short_pathname_representation(path_short, path, sizeof(path_short)); - strlcpy(fill_buf, + strlcpy(fill_buf, (label && label[0] != '\0') ? label : path_short, sizeof(fill_buf)); @@ -1936,17 +1936,6 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n return 0; } -#if defined(GEKKO) && defined(HW_RVL) - slock_lock(gx_device_mutex); - device = gx_get_device_from_path(info->path); - - if (device != -1 && !gx_devices[device].mounted && - gx_devices[device].interface->isInserted()) - fatMountSimple(gx_devices[device].name, gx_devices[device].interface); - - slock_unlock(gx_device_mutex); -#endif - path_is_compressed = path_is_compressed_file(info->path); push_dir = (info->setting && info->setting->browser_selection_type == ST_DIR); @@ -2314,7 +2303,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) (type == DISPLAYLIST_PERFCOUNTERS_CORE) ? perf_ptr_libretro : perf_ptr_rarch , (type == DISPLAYLIST_PERFCOUNTERS_CORE) ? - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN : + MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN : MENU_SETTINGS_PERF_COUNTERS_BEGIN); ret = 0; @@ -2464,7 +2453,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) menu_hash_to_str(MENU_LABEL_VALUE_DISK_INDEX), menu_hash_to_str(MENU_LABEL_DISK_INDEX), MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_INDEX, 0, 0); - menu_list_push(info->list, + menu_list_push(info->list, menu_hash_to_str(MENU_LABEL_VALUE_DISK_CYCLE_TRAY_STATUS), menu_hash_to_str(MENU_LABEL_DISK_CYCLE_TRAY_STATUS), MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_CYCLE_TRAY_STATUS, 0, 0); From 0776932b3a52353bad6685f215fb7ff409ff378f Mon Sep 17 00:00:00 2001 From: vanfanel Date: Tue, 21 Jul 2015 14:22:39 +0200 Subject: [PATCH 5/6] VIDEO/SUNXI: Make setting aspect ratio in menu work and fixed segfault on new content loading. --- gfx/drivers/sunxi_gfx.c | 108 ++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index 547696b25b..4c038c7fca 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -542,7 +542,8 @@ struct sunxi_video unsigned int menu_height; unsigned int menu_pitch; - bool aspect_changed; + float aspect_ratio; + bool readjust_pending; }; static void sunxi_blank_console(struct sunxi_video *_dispvars) @@ -633,6 +634,11 @@ static void *sunxi_gfx_init(const video_info_t *video, _dispvars->keep_vsync = true; _dispvars->menu_active = false; _dispvars->bytes_per_pixel = video->rgb32 ? 4 : 2; + /* It's very important that we set aspect here because the + * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame() + * and we don't want the main surface to be setup in set_aspect() + * before we get to gfx_frame(). */ + _dispvars->aspect_ratio = video_driver_get_aspect_ratio(); switch (_dispvars->bytes_per_pixel) { @@ -745,29 +751,7 @@ static void sunxi_setup_scale (void *data, _dispvars->pages[i].address = ((uint32_t*) _dispvars->sunxi_disp->framebuffer_addr + (_dispvars->sunxi_disp->yres + i * _dispvars->src_height) * _dispvars->dst_pitch/4); } - switch (settings->video.aspect_ratio_idx) - { - case ASPECT_RATIO_4_3: - aspect = (float)4 / (float)3; - break; - case ASPECT_RATIO_16_9: - aspect = (float)16 / (float)9; - break; - case ASPECT_RATIO_16_10: - aspect = (float)16 / (float)10; - break; - case ASPECT_RATIO_16_15: - aspect = (float)16 / (float)15; - break; - case ASPECT_RATIO_CORE: - aspect = (float)_dispvars->src_width / (float)_dispvars->src_height; - break; - default: - aspect = (float)_dispvars->src_width / (float)_dispvars->src_height; - break; - } - - visible_width = _dispvars->sunxi_disp->yres * aspect; + visible_width = _dispvars->sunxi_disp->yres * _dispvars->aspect_ratio; xpos = (_dispvars->sunxi_disp->xres - visible_width) / 2; /* setup layer window */ @@ -782,7 +766,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, { struct sunxi_video *_dispvars = (struct sunxi_video*)data; - if (_dispvars->src_width != width || _dispvars->src_height != height) + if (_dispvars->src_width != width || _dispvars->src_height != height || _dispvars->readjust_pending) { /* Sanity check on new dimensions */ if (width == 0 || height == 0) @@ -792,6 +776,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, _dispvars->src_width, _dispvars->src_height, width, height); sunxi_setup_scale(_dispvars, width, height, pitch); + _dispvars->readjust_pending = false; } if (_dispvars->menu_active) @@ -898,40 +883,43 @@ static void sunxi_set_texture_enable(void *data, bool state, bool full_screen) static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - uint16_t src_pix; - uint32_t R, G, B, dst_pix; - unsigned int i, j; struct sunxi_video *_dispvars = (struct sunxi_video*)data; - - /* We have to go on a pixel format conversion adventure for now, until we can - * convince RGUI to output in an 8888 format. */ - unsigned int src_pitch = width * 2; - unsigned int dst_pitch = _dispvars->sunxi_disp->xres * 4; - unsigned int dst_width = _dispvars->sunxi_disp->xres; - uint32_t line[dst_width]; + + if (_dispvars->menu_active) { + uint16_t src_pix; + uint32_t R, G, B, dst_pix; + unsigned int i, j; + + /* We have to go on a pixel format conversion adventure for now, until we can + * convince RGUI to output in an 8888 format. */ + unsigned int src_pitch = width * 2; + unsigned int dst_pitch = _dispvars->sunxi_disp->xres * 4; + unsigned int dst_width = _dispvars->sunxi_disp->xres; + uint32_t line[dst_width]; - /* Remember, memcpy() works with 8bits pointers for increments. */ - char *dst_base_addr = (char*)(_dispvars->pages[0].address); - char *src_base_addr = (char*)frame; + /* Remember, memcpy() works with 8bits pointers for increments. */ + char *dst_base_addr = (char*)(_dispvars->pages[0].address); + char *src_base_addr = (char*)frame; - for (i = 0; i < height; i++) - { - for (j = 0; j < src_pitch / 2; j++) + for (i = 0; i < height; i++) { - src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); - /* The hex AND is for keeping only the part we need for each component. */ - R = (src_pix << 8) & 0x00FF0000; - G = (src_pix << 4) & 0x0000FF00; - B = (src_pix << 0) & 0x000000FF; - line[j] = (0 | R | G | B); + for (j = 0; j < src_pitch / 2; j++) + { + src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); + /* The hex AND is for keeping only the part we need for each component. */ + R = (src_pix << 8) & 0x00FF0000; + G = (src_pix << 4) & 0x0000FF00; + B = (src_pix << 0) & 0x000000FF; + line[j] = (0 | R | G | B); + } + memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch); } - memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch); - } - /* Issue pageflip. Will flip on next vsync. */ - sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, - _dispvars->sunxi_disp->bits_per_pixel, - _dispvars->pages[0].offset, width, height, _dispvars->sunxi_disp->xres); + /* Issue pageflip. Will flip on next vsync. */ + sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, + _dispvars->sunxi_disp->bits_per_pixel, + _dispvars->pages[0].offset, width, height, _dispvars->sunxi_disp->xres); + } } static uint64_t sunxi_get_frame_count(void *data) @@ -942,6 +930,18 @@ static uint64_t sunxi_get_frame_count(void *data) return _dispvars->frame_count; } +static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +{ + struct sunxi_video *_dispvars = (struct sunxi_video*)data; + /* Here we obtain the new aspect ratio. */ + float new_aspect = aspectratio_lut[aspect_ratio_idx].value; + if (new_aspect != _dispvars->aspect_ratio) { + _dispvars->aspect_ratio = new_aspect; + /* So we setup scale again on the next gfx_frame. */ + _dispvars->readjust_pending = true; + } +} + static const video_poke_interface_t sunxi_poke_interface = { sunxi_get_frame_count, NULL, /* set_video_mode */ @@ -951,7 +951,7 @@ static const video_poke_interface_t sunxi_poke_interface = { NULL, /* get_video_output_next */ NULL, /* get_current_framebuffer */ NULL, /* get_proc_address */ - NULL, /* sunxi_set_aspect_ratio */ + sunxi_set_aspect_ratio, NULL, /* sunxi_apply_state_changes */ #ifdef HAVE_MENU sunxi_set_texture_frame, From eb7bf55d90654a0dbbab935c2de756cf4caffaa4 Mon Sep 17 00:00:00 2001 From: vanfanel Date: Tue, 21 Jul 2015 14:33:02 +0200 Subject: [PATCH 6/6] VIDEO/SUNXI: Reworked where aspect ratio is changed in order to avoid variable. --- gfx/drivers/sunxi_gfx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index 4c038c7fca..b3ec46706a 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -543,7 +543,6 @@ struct sunxi_video unsigned int menu_pitch; float aspect_ratio; - bool readjust_pending; }; static void sunxi_blank_console(struct sunxi_video *_dispvars) @@ -766,7 +765,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, { struct sunxi_video *_dispvars = (struct sunxi_video*)data; - if (_dispvars->src_width != width || _dispvars->src_height != height || _dispvars->readjust_pending) + if (_dispvars->src_width != width || _dispvars->src_height != height) { /* Sanity check on new dimensions */ if (width == 0 || height == 0) @@ -776,7 +775,6 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, _dispvars->src_width, _dispvars->src_height, width, height); sunxi_setup_scale(_dispvars, width, height, pitch); - _dispvars->readjust_pending = false; } if (_dispvars->menu_active) @@ -937,8 +935,7 @@ static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) float new_aspect = aspectratio_lut[aspect_ratio_idx].value; if (new_aspect != _dispvars->aspect_ratio) { _dispvars->aspect_ratio = new_aspect; - /* So we setup scale again on the next gfx_frame. */ - _dispvars->readjust_pending = true; + sunxi_setup_scale(_dispvars, _dispvars->src_width, _dispvars->src_height, _dispvars->src_pitch); } }