diff --git a/desmume/src/filter/deposterize.cpp b/desmume/src/filter/deposterize.cpp index eeb0a94bb..84ebebb34 100644 --- a/desmume/src/filter/deposterize.cpp +++ b/desmume/src/filter/deposterize.cpp @@ -18,7 +18,10 @@ #include "../types.h" #include "filter.h" -static u32 Deposterize_InterpLTE(const u32 pixA, const u32 pixB, const u32 threshold) +#define DEPOSTERIZE_THRESHOLD 23 // Possible values are [0-255], where lower a value prevents blending and a higher value allows for more blending + + +static u32 Deposterize_InterpLTE(const u32 pixA, const u32 pixB) { const u32 aB = (pixB & 0xFF000000) >> 24; if (aB == 0) @@ -35,10 +38,10 @@ static u32 Deposterize_InterpLTE(const u32 pixA, const u32 pixB, const u32 thres const u32 gB = (pixB & 0x0000FF00) >> 8; const u32 bB = (pixB & 0x00FF0000) >> 16; - const u32 rC = ( (rB - rA <= threshold) || (rA - rB <= threshold) ) ? ( ((rA+rB)>>1) ) : rA; - const u32 gC = ( (gB - gA <= threshold) || (gA - gB <= threshold) ) ? ( ((gA+gB)>>1) ) : gA; - const u32 bC = ( (bB - bA <= threshold) || (bA - bB <= threshold) ) ? ( ((bA+bB)>>1) ) : bA; - const u32 aC = ( (bB - aA <= threshold) || (aA - aB <= threshold) ) ? ( ((aA+aB)>>1) ) : aA; + const u32 rC = ( (rB - rA <= DEPOSTERIZE_THRESHOLD) || (rA - rB <= DEPOSTERIZE_THRESHOLD) ) ? ( ((rA+rB)>>1) ) : rA; + const u32 gC = ( (gB - gA <= DEPOSTERIZE_THRESHOLD) || (gA - gB <= DEPOSTERIZE_THRESHOLD) ) ? ( ((gA+gB)>>1) ) : gA; + const u32 bC = ( (bB - bA <= DEPOSTERIZE_THRESHOLD) || (bA - bB <= DEPOSTERIZE_THRESHOLD) ) ? ( ((bA+bB)>>1) ) : bA; + const u32 aC = ( (bB - aA <= DEPOSTERIZE_THRESHOLD) || (aA - aB <= DEPOSTERIZE_THRESHOLD) ) ? ( ((aA+aB)>>1) ) : aA; return (rC | (gC << 8) | (bC << 16) | (aC << 24)); } @@ -84,7 +87,6 @@ void RenderDeposterize(SSurface Src, SSurface Dst) u32 *src = (u32 *)Src.Surface; u32 *workingDst = (u32 *)Dst.workingSurface[0]; u32 *finalDst = (u32 *)Dst.Surface; - u32 threshold = *(u32 *)Dst.userData; int i = 0; for (int y = 0; y < h; y++) @@ -108,14 +110,14 @@ void RenderDeposterize(SSurface Src, SSurface Dst) color[8] = ((x < w-1) && (y > 0)) ? src[i-w+1] : src[i]; blend[0] = color[0]; - blend[1] = Deposterize_InterpLTE(color[0], color[1], threshold); - blend[2] = Deposterize_InterpLTE(color[0], color[2], threshold); - blend[3] = Deposterize_InterpLTE(color[0], color[3], threshold); - blend[4] = Deposterize_InterpLTE(color[0], color[4], threshold); - blend[5] = Deposterize_InterpLTE(color[0], color[5], threshold); - blend[6] = Deposterize_InterpLTE(color[0], color[6], threshold); - blend[7] = Deposterize_InterpLTE(color[0], color[7], threshold); - blend[8] = Deposterize_InterpLTE(color[0], color[8], threshold); + blend[1] = Deposterize_InterpLTE(color[0], color[1]); + blend[2] = Deposterize_InterpLTE(color[0], color[2]); + blend[3] = Deposterize_InterpLTE(color[0], color[3]); + blend[4] = Deposterize_InterpLTE(color[0], color[4]); + blend[5] = Deposterize_InterpLTE(color[0], color[5]); + blend[6] = Deposterize_InterpLTE(color[0], color[6]); + blend[7] = Deposterize_InterpLTE(color[0], color[7]); + blend[8] = Deposterize_InterpLTE(color[0], color[8]); workingDst[i] = Deposterize_Blend(Deposterize_Blend(Deposterize_Blend(Deposterize_Blend(blend[0], blend[5], 1, 7), Deposterize_Blend(blend[0], blend[1], 1, 7), @@ -157,14 +159,14 @@ void RenderDeposterize(SSurface Src, SSurface Dst) color[8] = ((x < w-1) && (y > 0)) ? workingDst[i-w+1] : workingDst[i]; blend[0] = color[0]; - blend[1] = Deposterize_InterpLTE(color[0], color[1], threshold); - blend[2] = Deposterize_InterpLTE(color[0], color[2], threshold); - blend[3] = Deposterize_InterpLTE(color[0], color[3], threshold); - blend[4] = Deposterize_InterpLTE(color[0], color[4], threshold); - blend[5] = Deposterize_InterpLTE(color[0], color[5], threshold); - blend[6] = Deposterize_InterpLTE(color[0], color[6], threshold); - blend[7] = Deposterize_InterpLTE(color[0], color[7], threshold); - blend[8] = Deposterize_InterpLTE(color[0], color[8], threshold); + blend[1] = Deposterize_InterpLTE(color[0], color[1]); + blend[2] = Deposterize_InterpLTE(color[0], color[2]); + blend[3] = Deposterize_InterpLTE(color[0], color[3]); + blend[4] = Deposterize_InterpLTE(color[0], color[4]); + blend[5] = Deposterize_InterpLTE(color[0], color[5]); + blend[6] = Deposterize_InterpLTE(color[0], color[6]); + blend[7] = Deposterize_InterpLTE(color[0], color[7]); + blend[8] = Deposterize_InterpLTE(color[0], color[8]); finalDst[i] = Deposterize_Blend(Deposterize_Blend(Deposterize_Blend(Deposterize_Blend(blend[0], blend[5], 1, 7), Deposterize_Blend(blend[0], blend[1], 1, 7), diff --git a/desmume/src/render3D.cpp b/desmume/src/render3D.cpp index c5360d660..23174307d 100644 --- a/desmume/src/render3D.cpp +++ b/desmume/src/render3D.cpp @@ -32,7 +32,6 @@ #include "./filter/filter.h" #include "./filter/xbrz.h" -#define TEXTURE_DEPOSTERIZE_THRESHOLD 21 // Possible values are [0-255], where lower a value prevents blending and a higher value allows for more blending int cur3DCore = GPU3D_NULL; @@ -238,7 +237,6 @@ Render3D::Render3D() _textureScalingFactor = 1; _textureSmooth = false; _textureUpscaleBuffer = NULL; - _textureDeposterizeThreshold = TEXTURE_DEPOSTERIZE_THRESHOLD; memset(&_textureDeposterizeSrcSurface, 0, sizeof(_textureDeposterizeSrcSurface)); memset(&_textureDeposterizeDstSurface, 0, sizeof(_textureDeposterizeDstSurface)); @@ -246,7 +244,6 @@ Render3D::Render3D() _textureDeposterizeSrcSurface.Width = _textureDeposterizeDstSurface.Width = 1; _textureDeposterizeSrcSurface.Height = _textureDeposterizeDstSurface.Height = 1; _textureDeposterizeSrcSurface.Pitch = _textureDeposterizeDstSurface.Pitch = 1; - _textureDeposterizeDstSurface.userData = &_textureDeposterizeThreshold; Reset(); } diff --git a/desmume/src/render3D.h b/desmume/src/render3D.h index a98225a4e..3ffd0df61 100644 --- a/desmume/src/render3D.h +++ b/desmume/src/render3D.h @@ -134,9 +134,7 @@ protected: SSurface _textureDeposterizeSrcSurface; SSurface _textureDeposterizeDstSurface; - u32 _textureDeposterizeThreshold; - //u32 *_textureDeposterizeBuffer; u32 *_textureUpscaleBuffer; CACHE_ALIGN u16 clearImageColor16Buffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT];