Merge pull request #12644 from jdgleaver/fpu-fix

(Menu+Widgets) Add workaround for FPU bug that breaks scale factor comparisons on certain platforms (fixes XMB thumbnails on 32bit Linux/Windows)
This commit is contained in:
Autechre 2021-07-12 16:49:28 +02:00 committed by GitHub
commit 7f4f1d82bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 6 deletions

View File

@ -1037,9 +1037,15 @@ void gfx_widgets_iterate(
{
size_t i;
dispgfx_widget_t *p_dispwidget = (dispgfx_widget_t*)data;
/* Check whether screen dimensions or menu scale
* factor have changed */
float scale_factor = 0.0f;
/* c.f. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
* On some platforms (e.g. 32-bit x86 without SSE),
* gcc can produce inconsistent floating point results
* depending upon optimisation level. This can break
* floating point variable comparisons. A workaround is
* to declare the affected variable as 'volatile', which
* disables optimisations and removes excess precision
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c87) */
volatile float scale_factor = 0.0f;
gfx_display_t *p_disp = (gfx_display_t*)data_disp;
settings_t *settings = (settings_t*)settings_data;
#ifdef HAVE_XMB
@ -1051,6 +1057,8 @@ void gfx_widgets_iterate(
scale_factor = gfx_display_get_widget_dpi_scale(p_disp,
settings, width, height, fullscreen);
/* Check whether screen dimensions or menu scale
* factor have changed */
if ((scale_factor != p_dispwidget->last_scale_factor) ||
(width != p_dispwidget->last_video_width) ||
(height != p_dispwidget->last_video_height))

View File

@ -3512,7 +3512,15 @@ static void materialui_render(void *data,
{
size_t i;
float bottom;
float scale_factor;
/* c.f. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
* On some platforms (e.g. 32-bit x86 without SSE),
* gcc can produce inconsistent floating point results
* depending upon optimisation level. This can break
* floating point variable comparisons. A workaround is
* to declare the affected variable as 'volatile', which
* disables optimisations and removes excess precision
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c87) */
volatile float scale_factor;
settings_t *settings = config_get_ptr();
materialui_handle_t *mui = (materialui_handle_t*)data;
gfx_display_t *p_disp = disp_get_ptr();

View File

@ -1750,7 +1750,15 @@ static void ozone_render(void *data,
bool is_idle)
{
size_t i;
float scale_factor;
/* c.f. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
* On some platforms (e.g. 32-bit x86 without SSE),
* gcc can produce inconsistent floating point results
* depending upon optimisation level. This can break
* floating point variable comparisons. A workaround is
* to declare the affected variable as 'volatile', which
* disables optimisations and removes excess precision
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c87) */
volatile float scale_factor;
unsigned entries_end = (unsigned)menu_entries_get_size();
bool pointer_enabled = false;
unsigned language = *msg_hash_get_uint(MSG_HASH_USER_LANGUAGE);

View File

@ -3971,7 +3971,15 @@ static void xmb_render(void *data,
/* 'i' must be of 'size_t', since it is passed
* by reference to menu_entries_ctl() */
size_t i;
float scale_factor;
/* c.f. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
* On some platforms (e.g. 32-bit x86 without SSE),
* gcc can produce inconsistent floating point results
* depending upon optimisation level. This can break
* floating point variable comparisons. A workaround is
* to declare the affected variable as 'volatile', which
* disables optimisations and removes excess precision
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323#c87) */
volatile float scale_factor;
xmb_handle_t *xmb = (xmb_handle_t*)data;
settings_t *settings = config_get_ptr();
size_t end = menu_entries_get_size();