Render3D:
- Improve texture upscaling smoothness for A3I5 and A5I3 textures.
This commit is contained in:
parent
8be7dccdda
commit
8e08a92b9d
|
@ -2987,9 +2987,10 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (params.enableRepeatS ? (params.enableMirroredRepeatS ? OGLRef.stateTexMirroredRepeat : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (params.enableRepeatT ? (params.enableMirroredRepeatT ? OGLRef.stateTexMirroredRepeat : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
||||
|
||||
u32 *textureSrc = (u32 *)currTexture->decoded;
|
||||
size_t texWidth = currTexture->sizeX;
|
||||
size_t texHeight = currTexture->sizeY;
|
||||
const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = (u32 *)this->currTexture->decoded;
|
||||
size_t texWidth = this->currTexture->sizeX;
|
||||
size_t texHeight = this->currTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeBuffer != NULL)
|
||||
{
|
||||
|
@ -3010,10 +3011,10 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
this->TextureUpscale<2>(textureSrc, texWidth, texHeight);
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3022,15 +3023,15 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
this->TextureUpscale<4>(textureSrc, texWidth, texHeight);
|
||||
this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
texWidth = currTexture->sizeX;
|
||||
texHeight = currTexture->sizeY;
|
||||
this->TextureUpscale<2>(textureSrc, texWidth, texHeight);
|
||||
texWidth = this->currTexture->sizeX;
|
||||
texHeight = this->currTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4637,9 +4638,10 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (params.enableRepeatS ? (params.enableMirroredRepeatS ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (params.enableRepeatT ? (params.enableMirroredRepeatT ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
||||
|
||||
u32 *textureSrc = (u32 *)currTexture->decoded;
|
||||
size_t texWidth = currTexture->sizeX;
|
||||
size_t texHeight = currTexture->sizeY;
|
||||
const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = (u32 *)this->currTexture->decoded;
|
||||
size_t texWidth = this->currTexture->sizeX;
|
||||
size_t texHeight = this->currTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeBuffer != NULL)
|
||||
{
|
||||
|
@ -4660,10 +4662,10 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
this->TextureUpscale<2>(textureSrc, texWidth, texHeight);
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4672,15 +4674,15 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
this->TextureUpscale<4>(textureSrc, texWidth, texHeight);
|
||||
this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
texWidth = currTexture->sizeX;
|
||||
texHeight = currTexture->sizeY;
|
||||
this->TextureUpscale<2>(textureSrc, texWidth, texHeight);
|
||||
texWidth = this->currTexture->sizeX;
|
||||
texHeight = this->currTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1716,9 +1716,10 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (params.enableRepeatS ? (params.enableMirroredRepeatS ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (params.enableRepeatT ? (params.enableMirroredRepeatT ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
|
||||
|
||||
u32 *textureSrc = (u32 *)currTexture->decoded;
|
||||
size_t texWidth = currTexture->sizeX;
|
||||
size_t texHeight = currTexture->sizeY;
|
||||
const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = (u32 *)this->currTexture->decoded;
|
||||
size_t texWidth = this->currTexture->sizeX;
|
||||
size_t texHeight = this->currTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeBuffer != NULL)
|
||||
{
|
||||
|
@ -1739,10 +1740,10 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
this->TextureUpscale<2>(textureSrc, texWidth, texHeight);
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1751,15 +1752,15 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
this->TextureUpscale<4>(textureSrc, texWidth, texHeight);
|
||||
this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
texWidth = currTexture->sizeX;
|
||||
texHeight = currTexture->sizeY;
|
||||
this->TextureUpscale<2>(textureSrc, texWidth, texHeight);
|
||||
texWidth = this->currTexture->sizeX;
|
||||
texHeight = this->currTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, currTexture->sizeX, currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@
|
|||
#define COLOR_MASK_G 0x0000FF00
|
||||
#define COLOR_MASK_B 0x000000FF
|
||||
|
||||
#define USE_DESMUME_TEXTURE_UPSCALE_ALPHA_BLEND
|
||||
|
||||
namespace
|
||||
{
|
||||
template <uint32_t N> inline
|
||||
|
@ -80,7 +78,6 @@ uint32_t gradientRGB(uint32_t pixFront, uint32_t pixBack) //blend front color wi
|
|||
gradientRGB_calcColor<M, N>(getBlue (pixFront), getBlue (pixBack)));
|
||||
}
|
||||
|
||||
|
||||
template <unsigned int M, unsigned int N> inline
|
||||
uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate color between two colors with alpha channels (=> NO alpha blending!!!)
|
||||
{
|
||||
|
@ -90,25 +87,10 @@ uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate c
|
|||
const unsigned int weightBack = getAlpha(pixBack) * (N - M);
|
||||
const unsigned int weightSum = weightFront + weightBack;
|
||||
|
||||
#ifdef USE_DESMUME_TEXTURE_UPSCALE_ALPHA_BLEND
|
||||
if (weightSum == 0)
|
||||
{
|
||||
return (pixFront & 0x00FFFFFF);
|
||||
}
|
||||
else if (weightFront == 0)
|
||||
{
|
||||
return pixBack;
|
||||
}
|
||||
else if (weightBack == 0)
|
||||
{
|
||||
return pixFront;
|
||||
}
|
||||
#else
|
||||
if (weightSum == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
auto calcColor = [=](unsigned char colFront, unsigned char colBack)
|
||||
|
@ -122,6 +104,39 @@ uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate c
|
|||
gradientARGB_calcColor(getBlue (pixFront), getBlue (pixBack), weightFront, weightBack, weightSum));
|
||||
}
|
||||
|
||||
template <unsigned int M, unsigned int N> inline
|
||||
uint32_t gradientARGB_1bitAlpha(uint32_t pixFront, uint32_t pixBack) //find intermediate color between two colors with alpha channels (=> NO alpha blending!!!)
|
||||
{
|
||||
//static_assert(0 < M && M < N && N <= 1000, "");
|
||||
|
||||
const unsigned int weightFront = getAlpha(pixFront) * M;
|
||||
const unsigned int weightBack = getAlpha(pixBack) * (N - M);
|
||||
const unsigned int weightSum = weightFront + weightBack;
|
||||
|
||||
if (weightSum == 0)
|
||||
{
|
||||
return (pixFront & 0x00FFFFFF);
|
||||
}
|
||||
else if (weightFront == 0)
|
||||
{
|
||||
return pixBack;
|
||||
}
|
||||
else if (weightBack == 0)
|
||||
{
|
||||
return pixFront;
|
||||
}
|
||||
|
||||
/*
|
||||
auto calcColor = [=](unsigned char colFront, unsigned char colBack)
|
||||
{
|
||||
return static_cast<unsigned char>((colFront * weightFront + colBack * weightBack) / weightSum);
|
||||
};
|
||||
*/
|
||||
return makePixel(static_cast<unsigned char>(weightSum / N),
|
||||
gradientARGB_calcColor(getRed (pixFront), getRed (pixBack), weightFront, weightBack, weightSum),
|
||||
gradientARGB_calcColor(getGreen(pixFront), getGreen(pixBack), weightFront, weightBack, weightSum),
|
||||
gradientARGB_calcColor(getBlue (pixFront), getBlue (pixBack), weightFront, weightBack, weightSum));
|
||||
}
|
||||
|
||||
//inline
|
||||
//double fastSqrt(double n)
|
||||
|
@ -1184,6 +1199,15 @@ struct ColorGradientARGB
|
|||
pixBack = gradientARGB<M, N>(pixFront, pixBack);
|
||||
}
|
||||
};
|
||||
|
||||
struct ColorGradientARGB_1bitAlpha
|
||||
{
|
||||
template <unsigned int M, unsigned int N>
|
||||
static void alphaGrad(uint32_t& pixBack, uint32_t pixFront)
|
||||
{
|
||||
pixBack = gradientARGB_1bitAlpha<M, N>(pixFront, pixBack);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <size_t SCALEFACTOR, xbrz::ColorFormat FORMAT>
|
||||
|
@ -1191,6 +1215,22 @@ void xbrz::scale(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight
|
|||
{
|
||||
switch (FORMAT)
|
||||
{
|
||||
case ColorFormatARGB_1bitAlpha:
|
||||
switch (SCALEFACTOR)
|
||||
{
|
||||
case 2:
|
||||
return scaleImage<Scaler2x<ColorGradientARGB_1bitAlpha>, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast);
|
||||
case 3:
|
||||
return scaleImage<Scaler3x<ColorGradientARGB_1bitAlpha>, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast);
|
||||
case 4:
|
||||
return scaleImage<Scaler4x<ColorGradientARGB_1bitAlpha>, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast);
|
||||
case 5:
|
||||
return scaleImage<Scaler5x<ColorGradientARGB_1bitAlpha>, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast);
|
||||
case 6:
|
||||
return scaleImage<Scaler6x<ColorGradientARGB_1bitAlpha>, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast);
|
||||
}
|
||||
break;
|
||||
|
||||
case ColorFormatARGB:
|
||||
switch (SCALEFACTOR)
|
||||
{
|
||||
|
@ -1340,3 +1380,5 @@ void Render6xBRZ(SSurface Src, SSurface Dst)
|
|||
|
||||
template void xbrz::scale<2, xbrz::ColorFormatARGB>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast);
|
||||
template void xbrz::scale<4, xbrz::ColorFormatARGB>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast);
|
||||
template void xbrz::scale<2, xbrz::ColorFormatARGB_1bitAlpha>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast);
|
||||
template void xbrz::scale<4, xbrz::ColorFormatARGB_1bitAlpha>(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast);
|
||||
|
|
|
@ -54,6 +54,7 @@ enum ColorFormat //from high bits -> low bits, 8 bit per channel
|
|||
{
|
||||
ColorFormatRGB, //8 bit for each red, green, blue, upper 8 bits unused
|
||||
ColorFormatARGB, //including alpha channel, BGRA byte order on little-endian machines
|
||||
ColorFormatARGB_1bitAlpha // special alpha blending mode for NDS 1-bit alpha textures
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -185,7 +185,7 @@ enum
|
|||
};
|
||||
|
||||
// TEXTURE PARAMETERS - FORMAT ID
|
||||
enum
|
||||
enum NDSTextureFormat
|
||||
{
|
||||
TEXMODE_NONE = 0,
|
||||
TEXMODE_A3I5 = 1,
|
||||
|
|
|
@ -546,14 +546,21 @@ Render3DError Render3D::TextureDeposterize(const u32 *src, const size_t srcTexWi
|
|||
}
|
||||
|
||||
template <size_t SCALEFACTOR>
|
||||
Render3DError Render3D::TextureUpscale(const u32 *src, size_t &outTexWidth, size_t &outTexHeight)
|
||||
Render3DError Render3D::TextureUpscale(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight)
|
||||
{
|
||||
if ( (SCALEFACTOR != 2) && (SCALEFACTOR != 4) )
|
||||
{
|
||||
return RENDER3DERROR_NOERR;
|
||||
}
|
||||
|
||||
xbrz::scale<SCALEFACTOR, xbrz::ColorFormatARGB>(src, this->_textureUpscaleBuffer, outTexWidth, outTexHeight);
|
||||
if (texFormat == TEXMODE_A3I5 || texFormat == TEXMODE_A5I3)
|
||||
{
|
||||
xbrz::scale<SCALEFACTOR, xbrz::ColorFormatARGB>(src, this->_textureUpscaleBuffer, outTexWidth, outTexHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
xbrz::scale<SCALEFACTOR, xbrz::ColorFormatARGB_1bitAlpha>(src, this->_textureUpscaleBuffer, outTexWidth, outTexHeight);
|
||||
}
|
||||
|
||||
outTexWidth *= SCALEFACTOR;
|
||||
outTexHeight *= SCALEFACTOR;
|
||||
|
@ -984,5 +991,5 @@ Render3DError Render3D_SSE2::ClearFramebuffer(const GFX3D_State &renderState)
|
|||
|
||||
#endif // ENABLE_SSE2
|
||||
|
||||
template Render3DError Render3D::TextureUpscale<2>(const u32 *src, size_t &outTexWidth, size_t &outTexHeight);
|
||||
template Render3DError Render3D::TextureUpscale<4>(const u32 *src, size_t &outTexWidth, size_t &outTexHeight);
|
||||
template Render3DError Render3D::TextureUpscale<2>(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight);
|
||||
template Render3DError Render3D::TextureUpscale<4>(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight);
|
||||
|
|
|
@ -139,7 +139,7 @@ protected:
|
|||
CACHE_ALIGN u8 clearImagePolyIDBuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT];
|
||||
|
||||
Render3DError TextureDeposterize(const u32 *src, const size_t srcTexWidth, const size_t srcTexHeight);
|
||||
template<size_t SCALEFACTOR> Render3DError TextureUpscale(const u32 *src, size_t &outTexWidth, size_t &outTexHeight);
|
||||
template<size_t SCALEFACTOR> Render3DError TextureUpscale(const NDSTextureFormat texFormat, const u32 *src, size_t &outTexWidth, size_t &outTexHeight);
|
||||
|
||||
virtual Render3DError BeginRender(const GFX3D &engine);
|
||||
virtual Render3DError RenderGeometry(const GFX3D_State &renderState, const POLYLIST *polyList, const INDEXLIST *indexList);
|
||||
|
|
|
@ -245,7 +245,7 @@ public:
|
|||
//used to hold a copy of the palette specified for this texture
|
||||
CACHE_ALIGN u16 pal[256];
|
||||
|
||||
u32 textureMode = (unsigned short)((format>>26)&0x07);
|
||||
NDSTextureFormat textureMode = (NDSTextureFormat)((format>>26)&0x07);
|
||||
u32 sizeX=(8 << ((format>>20)&0x07));
|
||||
u32 sizeY=(8 << ((format>>23)&0x07));
|
||||
u32 imageSize = sizeX*sizeY;
|
||||
|
@ -256,18 +256,19 @@ public:
|
|||
|
||||
switch (textureMode)
|
||||
{
|
||||
case TEXMODE_I2:
|
||||
paletteAddress = texpal<<3;
|
||||
break;
|
||||
case TEXMODE_A3I5: //a3i5
|
||||
case TEXMODE_I4: //i4
|
||||
case TEXMODE_I8: //i8
|
||||
case TEXMODE_A5I3: //a5i3
|
||||
case TEXMODE_16BPP: //16bpp
|
||||
case TEXMODE_4X4: //4x4
|
||||
default:
|
||||
paletteAddress = texpal<<4;
|
||||
break;
|
||||
case TEXMODE_I2:
|
||||
paletteAddress = texpal<<3;
|
||||
break;
|
||||
|
||||
case TEXMODE_A3I5:
|
||||
case TEXMODE_I4:
|
||||
case TEXMODE_I8:
|
||||
case TEXMODE_A5I3:
|
||||
case TEXMODE_16BPP:
|
||||
case TEXMODE_4X4:
|
||||
default:
|
||||
paletteAddress = texpal<<4;
|
||||
break;
|
||||
}
|
||||
|
||||
//analyze the texture memory mapping and the specifications of this texture
|
||||
|
@ -373,7 +374,7 @@ public:
|
|||
newitem->invSizeX=1.0f/((float)(sizeX));
|
||||
newitem->invSizeY=1.0f/((float)(sizeY));
|
||||
newitem->decode_len = sizeX*sizeY*4;
|
||||
newitem->mode = textureMode;
|
||||
newitem->format = textureMode;
|
||||
newitem->decoded = (u8 *)malloc_alignedCacheLine(newitem->decode_len);
|
||||
list_push_front(newitem);
|
||||
//printf("allocating: up to %d with %d items\n",cache_size,index.size());
|
||||
|
@ -405,7 +406,7 @@ public:
|
|||
|
||||
const bool isPalZeroTransparent = ( ((format >> 29) & 1) != 0 );
|
||||
|
||||
switch (newitem->mode)
|
||||
switch (newitem->format)
|
||||
{
|
||||
case TEXMODE_A3I5:
|
||||
{
|
||||
|
@ -934,6 +935,9 @@ public:
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
} //switch(texture format)
|
||||
|
||||
#ifdef DO_DEBUG_DUMP_TEXTURE
|
||||
|
@ -953,19 +957,19 @@ public:
|
|||
//but this will work for now
|
||||
MemSpan mspal = MemSpan_TexPalette(0,PALETTE_DUMP_SIZE,true);
|
||||
bool paletteDirty = mspal.memcmp(paletteDump);
|
||||
if(paletteDirty)
|
||||
if (paletteDirty)
|
||||
{
|
||||
mspal.dump(paletteDump);
|
||||
}
|
||||
|
||||
for(TTexCacheItemMultimap::iterator it(index.begin()); it != index.end(); ++it)
|
||||
for (TTexCacheItemMultimap::iterator it(index.begin()); it != index.end(); ++it)
|
||||
{
|
||||
it->second->suspectedInvalid = true;
|
||||
|
||||
//when the palette changes, we assume all 4x4 textures are dirty.
|
||||
//this is because each 4x4 item doesnt carry along with it a copy of the entire palette, for verification
|
||||
//instead, we just use the one paletteDump for verifying of all 4x4 textures; and if paletteDirty is set, verification has failed
|
||||
if(it->second->getTextureMode() == TEXMODE_4X4 && paletteDirty)
|
||||
if( (it->second->GetTextureFormat() == TEXMODE_4X4) && paletteDirty )
|
||||
{
|
||||
it->second->assumedInvalid = true;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "types.h"
|
||||
#include "common.h"
|
||||
#include "gfx3d.h"
|
||||
|
||||
enum TexCache_TexFormat
|
||||
{
|
||||
|
@ -62,13 +63,13 @@ public:
|
|||
if (this->_deleteCallback != NULL) this->_deleteCallback(this, this->_deleteCallbackParam1, this->_deleteCallbackParam2);
|
||||
}
|
||||
u32 decode_len;
|
||||
u32 mode;
|
||||
NDSTextureFormat format;
|
||||
u8* decoded; //decoded texture data
|
||||
bool suspectedInvalid;
|
||||
bool assumedInvalid;
|
||||
TTexCacheItemMultimap::iterator iterator;
|
||||
|
||||
int getTextureMode() const { return (int)((texformat>>26)&0x07); }
|
||||
NDSTextureFormat GetTextureFormat() const { return this->format; }
|
||||
|
||||
u32 texformat, texpal;
|
||||
u32 sizeX, sizeY;
|
||||
|
|
Loading…
Reference in New Issue