From ec8b59ab06641030ddb1b44dba9c96153a0db2a4 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 28 Jan 2020 12:25:15 +0000 Subject: [PATCH] Make scalerwritecache sizes depend on the maximum scaler size. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4311 --- src/gui/render_scalers.cpp | 9 +++++---- src/gui/render_scalers.h | 4 ++++ src/gui/render_simple.h | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/gui/render_scalers.cpp b/src/gui/render_scalers.cpp index 6a0f3df2..ae238eec 100644 --- a/src/gui/render_scalers.cpp +++ b/src/gui/render_scalers.cpp @@ -29,10 +29,11 @@ Bit8u Scaler_Aspect[SCALER_MAXHEIGHT]; Bit16u Scaler_ChangedLines[SCALER_MAXHEIGHT]; Bitu Scaler_ChangedLineIndex; -static union { - Bit32u b32 [4][SCALER_MAXWIDTH*3]; - Bit16u b16 [4][SCALER_MAXWIDTH*3]; - Bit8u b8 [4][SCALER_MAXWIDTH*3]; +static struct { + //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]; } scalerWriteCache; //scalerFrameCache_t scalerFrameCache; scalerSourceCache_t scalerSourceCache; diff --git a/src/gui/render_scalers.h b/src/gui/render_scalers.h index f4351cb6..0fb6a0c0 100644 --- a/src/gui/render_scalers.h +++ b/src/gui/render_scalers.h @@ -21,6 +21,10 @@ //#include "render.h" #include "video.h" + +#define SCALER_MAX_MUL_WIDTH 3 +#define SCALER_MAX_MUL_HEIGHT 3 + #if RENDER_USE_ADVANCED_SCALERS>0 #define SCALER_MAXWIDTH 1280 #define SCALER_MAXHEIGHT 1024 diff --git a/src/gui/render_simple.h b/src/gui/render_simple.h index f6e587d7..fc689a3c 100644 --- a/src/gui/render_simple.h +++ b/src/gui/render_simple.h @@ -16,6 +16,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#if SCALER_MAX_MUL_HEIGHT < SCALERHEIGHT +#error "Scaler goes too high" +#endif + +#if SCALER_MAX_MUL_WIDTH < SCALERWIDTH +#error "Scaler goes too wide" +#endif #if defined (SCALERLINEAR) static void conc4d(SCALERNAME,SBPP,DBPP,L)(const void *s) { @@ -67,6 +74,9 @@ static void conc4d(SCALERNAME,SBPP,DBPP,R)(const void *s) { #if (SCALERHEIGHT > 2) PTYPE *line2 = WC[1]; #endif +#if (SCALERHEIGHT > 3) + PTYPE *line3 = WC[2]; +#endif #else #if (SCALERHEIGHT > 1) PTYPE *line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch); @@ -74,6 +84,9 @@ static void conc4d(SCALERNAME,SBPP,DBPP,R)(const void *s) { #if (SCALERHEIGHT > 2) PTYPE *line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2); #endif +#if (SCALERHEIGHT > 3) + PTYPE *line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3); +#endif #endif //defined(SCALERLINEAR) hadChange = 1; for (Bitu i = x > 32 ? 32 : x;i>0;i--,x--) { @@ -88,6 +101,9 @@ static void conc4d(SCALERNAME,SBPP,DBPP,R)(const void *s) { #endif #if (SCALERHEIGHT > 2) line2 += SCALERWIDTH; +#endif +#if (SCALERHEIGHT > 3) + line3 += SCALERWIDTH; #endif } #if defined(SCALERLINEAR) @@ -98,6 +114,9 @@ static void conc4d(SCALERNAME,SBPP,DBPP,R)(const void *s) { #if (SCALERHEIGHT > 2) BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*2,WC[1], copyLen ); #endif +#if (SCALERHEIGHT > 3) + BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*3,WC[2], copyLen ); +#endif #endif //defined(SCALERLINEAR) } }