Merge pull request #105 from Splendide-Imaginarius/mkxp-z-lanczos-enum

Fold `lanczos3Scaling` config into `smoothScaling`
This commit is contained in:
Splendide Imaginarius 2023-10-31 12:20:47 +00:00 committed by GitHub
commit 52c932b9a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 26 deletions

View file

@ -368,7 +368,7 @@ DEF_GRA_PROP_B(ShowCursor)
DEF_GRA_PROP_F(Scale)
DEF_GRA_PROP_B(Frameskip)
DEF_GRA_PROP_B(FixedAspectRatio)
DEF_GRA_PROP_B(SmoothScaling)
DEF_GRA_PROP_I(SmoothScaling)
DEF_GRA_PROP_B(IntegerScaling)
DEF_GRA_PROP_B(LastMileScaling)
DEF_GRA_PROP_B(Threadsafe)

View file

@ -77,18 +77,15 @@
// "fixedAspectRatio": true,
// Apply linear interpolation when game screen
// Apply smooth interpolation when game screen
// is upscaled
// (default: disabled)
// 0: Nearest-Neighbor
// 1: Bilinear
// 2: (Reserved)
// 3: Lanczos3
// (default: 0)
//
// "smoothScaling": false,
// Apply Lanczos3 interpolation when game screen
// is upscaled (typically higher quality than linear)
// (default: disabled)
//
// "lanczos3Scaling": false,
// "smoothScaling": 0,
// Replace the game's Bitmap files with external high-res files

View file

@ -134,8 +134,7 @@ void Config::read(int argc, char *argv[]) {
{"winResizable", true},
{"fullscreen", false},
{"fixedAspectRatio", true},
{"smoothScaling", false},
{"lanczos3Scaling", false},
{"smoothScaling", 0},
{"enableHires", false},
{"textureScalingFactor", 1.},
{"framebufferScalingFactor", 1.},
@ -263,8 +262,7 @@ try { exp } catch (...) {}
SET_OPT(printFPS, boolean);
SET_OPT(fullscreen, boolean);
SET_OPT(fixedAspectRatio, boolean);
SET_OPT(smoothScaling, boolean);
SET_OPT(lanczos3Scaling, boolean);
SET_OPT(smoothScaling, integer);
SET_OPT(enableHires, boolean);
SET_OPT(textureScalingFactor, number);
SET_OPT(framebufferScalingFactor, number);

View file

@ -43,8 +43,7 @@ struct Config {
bool winResizable;
bool fullscreen;
bool fixedAspectRatio;
bool smoothScaling;
bool lanczos3Scaling;
int smoothScaling;
bool enableHires;
double textureScalingFactor;
double framebufferScalingFactor;

View file

@ -25,6 +25,7 @@
#include "glstate.h"
#include "quad.h"
#include "config.h"
#include "etc.h"
namespace FBO
{
@ -151,7 +152,9 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
FBO::bind(fbo);
glState.viewport.pushSet(IntRect(0, 0, size.x, size.y));
if (shState->config().lanczos3Scaling)
switch (shState->config().smoothScaling)
{
case Lanczos3:
{
Lanczos3Shader &shader = shState->shaders().lanczos3;
shader.bind();
@ -159,7 +162,9 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
shader.setTranslation(Vec2i());
shader.setTexSize(Vec2i(size.x, size.y));
}
else
break;
default:
{
SimpleShader &shader = shState->shaders().simple;
shader.bind();
@ -167,6 +172,7 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
shader.setTranslation(Vec2i());
shader.setTexSize(Vec2i(size.x, size.y));
}
}
}
}
@ -226,18 +232,23 @@ void blitSource(TEXFBO &source)
}
else
{
if (shState->config().lanczos3Scaling)
switch (shState->config().smoothScaling)
{
case Lanczos3:
{
Lanczos3Shader &shader = shState->shaders().lanczos3;
shader.bind();
shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires));
}
else
break;
default:
{
SimpleShader &shader = shState->shaders().simple;
shader.bind();
shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires));
}
}
if (source.selfHires != nullptr) {
TEX::bind(source.selfHires->tex);
}

View file

@ -28,6 +28,7 @@
#include "config.h"
#include "debugwriter.h"
#include "disposable.h"
#include "etc.h"
#include "etc-internal.h"
#include "eventthread.h"
#include "filesystem.h"
@ -1020,13 +1021,13 @@ struct GraphicsPrivate {
(scSize.y + scOffset.y),
scSize.x,
-scSize.y),
threadData->config.smoothScaling);
threadData->config.smoothScaling == Bilinear);
}
void metaBlitBufferFlippedScaled(const Vec2i &sourceSize, bool forceNearestNeighbor=false) {
GLMeta::blitRectangle(IntRect(0, 0, sourceSize.x, sourceSize.y),
IntRect(scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y),
!forceNearestNeighbor && threadData->config.smoothScaling);
!forceNearestNeighbor && threadData->config.smoothScaling == Bilinear);
}
void redrawScreen() {
@ -1613,13 +1614,13 @@ void Graphics::setFixedAspectRatio(bool value)
p->updateScreenResoRatio(p->threadData);
}
bool Graphics::getSmoothScaling() const
int Graphics::getSmoothScaling() const
{
// Same deal as with fixed aspect ratio
return shState->config().smoothScaling;
}
void Graphics::setSmoothScaling(bool value)
void Graphics::setSmoothScaling(int value)
{
shState->config().smoothScaling = value;
}

View file

@ -81,7 +81,7 @@ public:
DECL_ATTR( Scale, double )
DECL_ATTR( Frameskip, bool )
DECL_ATTR( FixedAspectRatio, bool )
DECL_ATTR( SmoothScaling, bool )
DECL_ATTR( SmoothScaling, int )
DECL_ATTR( IntegerScaling, bool )
DECL_ATTR( LastMileScaling, bool )
DECL_ATTR( Threadsafe, bool )

View file

@ -200,6 +200,14 @@ struct Rect : public Serializable
sigslot::signal<> valueChanged;
};
enum InterpolationMethod
{
NearestNeighbor = 0,
Bilinear = 1,
// Reserving 2 for Bicubic
Lanczos3 = 3,
};
/* For internal use.
* All drawable classes have properties of one or more of the above
* types, which in an interpreted environment act as independent