From 2dec4d0a11aca1cb7b045f7c7475fd55c99cc6a9 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Fri, 7 Feb 2020 15:39:21 +0000 Subject: [PATCH] Limit max software scaler line limit to a 4k monitor. (relevant for people who use larger scalers) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4316 --- src/gui/render.cpp | 9 +++++++++ src/gui/render_scalers.cpp | 6 +++--- src/gui/render_scalers.h | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/gui/render.cpp b/src/gui/render.cpp index 6db94cfe..39596c70 100644 --- a/src/gui/render.cpp +++ b/src/gui/render.cpp @@ -281,6 +281,11 @@ static void RENDER_Reset( void ) { gfx_scalew = 1; gfx_scaleh = 1; } + + /* Don't do software scaler sizes larger than 4k */ + Bitu maxsize_current_input = SCALER_MAXLINE_WIDTH/width; + if (render.scale.size > maxsize_current_input) render.scale.size = maxsize_current_input; + if ((dblh && dblw) || (render.scale.forced && !dblh && !dblw)) { /* Initialize always working defaults */ if (render.scale.size == 2) @@ -348,6 +353,10 @@ static void RENDER_Reset( void ) { #endif } else if (dblw) { simpleBlock = &ScaleNormalDw; + if (width * simpleBlock->xscale > SCALER_MAXLINE_WIDTH) { + // This should only happen if you pick really bad values... but might be worth adding selecting a scaler that fits + simpleBlock = &ScaleNormal1x; + } } else if (dblh) { simpleBlock = &ScaleNormalDh; } else { diff --git a/src/gui/render_scalers.cpp b/src/gui/render_scalers.cpp index caa04c65..1abf56d4 100644 --- a/src/gui/render_scalers.cpp +++ b/src/gui/render_scalers.cpp @@ -31,9 +31,9 @@ Bitu Scaler_ChangedLineIndex; static union { //The +1 is a at least for the normal scalers not needed. (-1 is enough) - Bit32u b32 [SCALER_MAX_MUL_HEIGHT+1][SCALER_MAXWIDTH*SCALER_MAX_MUL_WIDTH]; - Bit16u b16 [SCALER_MAX_MUL_HEIGHT+1][SCALER_MAXWIDTH*SCALER_MAX_MUL_WIDTH]; - Bit8u b8 [SCALER_MAX_MUL_HEIGHT+1][SCALER_MAXWIDTH*SCALER_MAX_MUL_WIDTH]; + Bit32u b32 [SCALER_MAX_MUL_HEIGHT + 1][SCALER_MAXLINE_WIDTH]; + Bit16u b16 [SCALER_MAX_MUL_HEIGHT + 1][SCALER_MAXLINE_WIDTH]; + Bit8u b8 [SCALER_MAX_MUL_HEIGHT + 1][SCALER_MAXLINE_WIDTH]; } scalerWriteCache; //scalerFrameCache_t scalerFrameCache; scalerSourceCache_t scalerSourceCache; diff --git a/src/gui/render_scalers.h b/src/gui/render_scalers.h index 0fb6a0c0..d2efa2c8 100644 --- a/src/gui/render_scalers.h +++ b/src/gui/render_scalers.h @@ -26,16 +26,25 @@ #define SCALER_MAX_MUL_HEIGHT 3 #if RENDER_USE_ADVANCED_SCALERS>0 -#define SCALER_MAXWIDTH 1280 +#define SCALER_MAXWIDTH 1280 #define SCALER_MAXHEIGHT 1024 +#define SCALER_MAXX 4096 #else // reduced to save some memory -#define SCALER_MAXWIDTH 800 +#define SCALER_MAXWIDTH 800 #define SCALER_MAXHEIGHT 600 +#define SCALER_MAXX 2048 #endif +#if (SCALER_MAX_MUL_WIDTH * SCALER_MAXWIDTH) > SCALER_MAXX +#define SCALER_MAXLINE_WIDTH SCALER_MAXX +#else +#define SCALER_MAXLINE_WIDTH (SCALER_MAX_MUL_WIDTH * SCALER_MAXWIDTH) +#endif + + #if RENDER_USE_ADVANCED_SCALERS>1 -#define SCALER_COMPLEXWIDTH 800 +#define SCALER_COMPLEXWIDTH 800 #define SCALER_COMPLEXHEIGHT 600 #endif