Texture Handler:
- Rework TexCacheItem::GetTexture() so that instantiating a new object, dumping the packed data, and dumping the palette are performed as separate operations. - Invalid OpenGL textures are now updated instead of being completely replaced. - NDSTextureUnpack4x4() now uses the srcIndex pointer parameter instead of recalculating the palette address. - Delete the now obsolete MemSpan-based texture unpacking functions.
This commit is contained in:
parent
2c82d4b7b4
commit
df60214b26
|
@ -871,7 +871,6 @@ OpenGLRenderer::OpenGLRenderer()
|
|||
ref->fboPostprocessID = 0;
|
||||
ref->selectedRenderingFBO = 0;
|
||||
|
||||
currTexture = NULL;
|
||||
_mappedFramebuffer = NULL;
|
||||
_pixelReadNeedsFinish = false;
|
||||
_currentPolyIndex = 0;
|
||||
|
@ -2418,10 +2417,6 @@ Render3DError OpenGLRenderer_1_2::ReadBackPixels()
|
|||
Render3DError OpenGLRenderer_1_2::DeleteTexture(const TexCacheItem *item)
|
||||
{
|
||||
this->ref->freeTextureIDs.push((GLuint)item->texid);
|
||||
if(this->currTexture == item)
|
||||
{
|
||||
this->currTexture = NULL;
|
||||
}
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
@ -2956,125 +2951,149 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
TexCacheItem *theTexture = texCache.GetTexture(thePoly.texParam, thePoly.texPalette);
|
||||
|
||||
// Enable textures if they weren't already enabled
|
||||
if (this->isShaderSupported)
|
||||
{
|
||||
glUniform1i(OGLRef.uniformPolyEnableTexture, GL_TRUE);
|
||||
glUniform1i(OGLRef.uniformTexSingleBitAlpha, (params.texFormat != TEXMODE_A3I5 && params.texFormat != TEXMODE_A5I3) ? GL_TRUE : GL_FALSE);
|
||||
glUniform1i(OGLRef.uniformTexSingleBitAlpha, (theTexture->packFormat != TEXMODE_A3I5 && theTexture->packFormat != TEXMODE_A5I3) ? GL_TRUE : GL_FALSE);
|
||||
glUniform2f(OGLRef.uniformPolyTexScale, theTexture->invSizeX, theTexture->invSizeY);
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glScalef(theTexture->invSizeX, theTexture->invSizeY, 1.0f);
|
||||
}
|
||||
|
||||
TexCacheItem *newTexture = texCache.GetTexture(thePoly.texParam, thePoly.texPalette);
|
||||
if (newTexture->unpackFormat != TexFormat_32bpp)
|
||||
if (theTexture->unpackFormat != TexFormat_32bpp)
|
||||
{
|
||||
newTexture->Unpack<TexFormat_32bpp>();
|
||||
}
|
||||
|
||||
if (newTexture != this->currTexture)
|
||||
{
|
||||
this->currTexture = newTexture;
|
||||
theTexture->Unpack<TexFormat_32bpp>();
|
||||
|
||||
//has the ogl renderer initialized the texture?
|
||||
if (this->currTexture->GetDeleteCallback() == NULL)
|
||||
const bool isNewTexture = (theTexture->GetDeleteCallback() == NULL);
|
||||
if (isNewTexture)
|
||||
{
|
||||
this->currTexture->SetDeleteCallback(&texDeleteCallback, this, NULL);
|
||||
theTexture->SetDeleteCallback(&texDeleteCallback, this, NULL);
|
||||
|
||||
if (OGLRef.freeTextureIDs.empty())
|
||||
{
|
||||
this->ExpandFreeTextures();
|
||||
}
|
||||
|
||||
this->currTexture->texid = (u32)OGLRef.freeTextureIDs.front();
|
||||
theTexture->texid = (u32)OGLRef.freeTextureIDs.front();
|
||||
OGLRef.freeTextureIDs.pop();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)this->currTexture->texid);
|
||||
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));
|
||||
|
||||
const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = this->currTexture->unpackData;
|
||||
size_t texWidth = this->currTexture->sizeX;
|
||||
size_t texHeight = this->currTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeDstSurface.Surface != NULL)
|
||||
{
|
||||
this->TextureDeposterize(textureSrc, texWidth, texHeight);
|
||||
textureSrc = (u32 *)this->_textureDeposterizeDstSurface.Surface;
|
||||
}
|
||||
|
||||
switch (this->_textureScalingFactor)
|
||||
{
|
||||
case 1:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
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, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
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 = 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, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->_textureSmooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (this->_textureScalingFactor > 1) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->_deviceInfo.maxAnisotropy);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise, just bind it
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)this->currTexture->texid);
|
||||
}
|
||||
|
||||
if (this->isShaderSupported)
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)theTexture->texid);
|
||||
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));
|
||||
|
||||
const NDSTextureFormat texFormat = theTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = theTexture->unpackData;
|
||||
size_t texWidth = theTexture->sizeX;
|
||||
size_t texHeight = theTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeDstSurface.Surface != NULL)
|
||||
{
|
||||
glUniform2f(OGLRef.uniformPolyTexScale, this->currTexture->invSizeX, this->currTexture->invSizeY);
|
||||
this->TextureDeposterize(textureSrc, texWidth, texHeight);
|
||||
textureSrc = (u32 *)this->_textureDeposterizeDstSurface.Surface;
|
||||
}
|
||||
|
||||
switch (this->_textureScalingFactor)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, theTexture->sizeX, theTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, theTexture->sizeX, theTexture->sizeY, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
texWidth = theTexture->sizeX;
|
||||
texHeight = theTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, theTexture->sizeX, theTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
texWidth = theTexture->sizeX;
|
||||
texHeight = theTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, theTexture->sizeX, theTexture->sizeY, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->_textureSmooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (this->_textureScalingFactor > 1) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->_deviceInfo.maxAnisotropy);
|
||||
}
|
||||
else
|
||||
{
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glScalef(this->currTexture->invSizeX, this->currTexture->invSizeY, 1.0f);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise, just bind it
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)theTexture->texid);
|
||||
}
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
@ -3126,7 +3145,6 @@ Render3DError OpenGLRenderer_1_2::Reset()
|
|||
memset(OGLRef.vertIndexBuffer, 0, OGLRENDER_VERT_INDEX_BUFFER_COUNT * sizeof(GLushort));
|
||||
}
|
||||
|
||||
this->currTexture = NULL;
|
||||
this->_currentPolyIndex = 0;
|
||||
|
||||
OGLRef.vtxPtrPosition = (GLvoid *)offsetof(VERT, coord);
|
||||
|
@ -4620,107 +4638,135 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, bool enableT
|
|||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
TexCacheItem *theTexture = texCache.GetTexture(thePoly.texParam, thePoly.texPalette);
|
||||
|
||||
glUniform1i(OGLRef.uniformPolyEnableTexture, GL_TRUE);
|
||||
glUniform1i(OGLRef.uniformTexSingleBitAlpha, (params.texFormat != TEXMODE_A3I5 && params.texFormat != TEXMODE_A5I3) ? GL_TRUE : GL_FALSE);
|
||||
glUniform1i(OGLRef.uniformTexSingleBitAlpha, (theTexture->packFormat != TEXMODE_A3I5 && theTexture->packFormat != TEXMODE_A5I3) ? GL_TRUE : GL_FALSE);
|
||||
glUniform2f(OGLRef.uniformPolyTexScale, theTexture->invSizeX, theTexture->invSizeY);
|
||||
|
||||
TexCacheItem *newTexture = texCache.GetTexture(thePoly.texParam, thePoly.texPalette);
|
||||
if (newTexture->unpackFormat != TexFormat_32bpp)
|
||||
if (theTexture->unpackFormat != TexFormat_32bpp)
|
||||
{
|
||||
newTexture->Unpack<TexFormat_32bpp>();
|
||||
}
|
||||
|
||||
if (newTexture != this->currTexture)
|
||||
{
|
||||
this->currTexture = newTexture;
|
||||
theTexture->Unpack<TexFormat_32bpp>();
|
||||
|
||||
//has the ogl renderer initialized the texture?
|
||||
if (this->currTexture->GetDeleteCallback() == NULL)
|
||||
const bool isNewTexture = (theTexture->GetDeleteCallback() == NULL);
|
||||
if (isNewTexture)
|
||||
{
|
||||
this->currTexture->SetDeleteCallback(&texDeleteCallback, this, NULL);
|
||||
theTexture->SetDeleteCallback(&texDeleteCallback, this, NULL);
|
||||
|
||||
if (OGLRef.freeTextureIDs.empty())
|
||||
{
|
||||
this->ExpandFreeTextures();
|
||||
}
|
||||
|
||||
this->currTexture->texid = (u32)OGLRef.freeTextureIDs.front();
|
||||
theTexture->texid = (u32)OGLRef.freeTextureIDs.front();
|
||||
OGLRef.freeTextureIDs.pop();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)this->currTexture->texid);
|
||||
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));
|
||||
|
||||
const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = this->currTexture->unpackData;
|
||||
size_t texWidth = this->currTexture->sizeX;
|
||||
size_t texHeight = this->currTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeDstSurface.Surface != NULL)
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)theTexture->texid);
|
||||
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));
|
||||
|
||||
const NDSTextureFormat texFormat = theTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = theTexture->unpackData;
|
||||
size_t texWidth = theTexture->sizeX;
|
||||
size_t texHeight = theTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeDstSurface.Surface != NULL)
|
||||
{
|
||||
this->TextureDeposterize(textureSrc, texWidth, texHeight);
|
||||
textureSrc = (u32 *)this->_textureDeposterizeDstSurface.Surface;
|
||||
}
|
||||
|
||||
switch (this->_textureScalingFactor)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
this->TextureDeposterize(textureSrc, texWidth, texHeight);
|
||||
textureSrc = (u32 *)this->_textureDeposterizeDstSurface.Surface;
|
||||
}
|
||||
|
||||
switch (this->_textureScalingFactor)
|
||||
{
|
||||
case 1:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
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, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
|
||||
case 4:
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
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 = 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, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, theTexture->sizeX, theTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, theTexture->sizeX, theTexture->sizeY, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->_textureSmooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (this->_textureScalingFactor > 1) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->_deviceInfo.maxAnisotropy);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
texWidth = theTexture->sizeX;
|
||||
texHeight = theTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, theTexture->sizeX, theTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
texWidth = theTexture->sizeX;
|
||||
texHeight = theTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, theTexture->sizeX, theTexture->sizeY, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->_textureSmooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (this->_textureScalingFactor > 1) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->_deviceInfo.maxAnisotropy);
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise, just bind it
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)this->currTexture->texid);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
}
|
||||
|
||||
glUniform2f(OGLRef.uniformPolyTexScale, this->currTexture->invSizeX, this->currTexture->invSizeY);
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise, just bind it
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)theTexture->texid);
|
||||
}
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
|
|
|
@ -587,10 +587,7 @@ protected:
|
|||
bool isVAOSupported;
|
||||
bool willFlipFramebufferOnGPU;
|
||||
bool willConvertFramebufferOnGPU;
|
||||
|
||||
// Textures
|
||||
TexCacheItem *currTexture;
|
||||
|
||||
|
||||
FragmentColor *_mappedFramebuffer;
|
||||
bool _pixelReadNeedsFinish;
|
||||
size_t _currentPolyIndex;
|
||||
|
|
|
@ -1695,103 +1695,133 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, bool enableT
|
|||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
TexCacheItem *newTexture = texCache.GetTexture(thePoly.texParam, thePoly.texPalette);
|
||||
if (newTexture->unpackFormat != TexFormat_32bpp)
|
||||
TexCacheItem *theTexture = texCache.GetTexture(thePoly.texParam, thePoly.texPalette);
|
||||
if (theTexture->unpackFormat != TexFormat_32bpp)
|
||||
{
|
||||
newTexture->Unpack<TexFormat_32bpp>();
|
||||
}
|
||||
|
||||
if (newTexture != this->currTexture)
|
||||
{
|
||||
this->currTexture = newTexture;
|
||||
theTexture->Unpack<TexFormat_32bpp>();
|
||||
|
||||
//has the ogl renderer initialized the texture?
|
||||
if (this->currTexture->GetDeleteCallback() == NULL)
|
||||
const bool isNewTexture = (theTexture->GetDeleteCallback() == NULL);
|
||||
if (isNewTexture)
|
||||
{
|
||||
this->currTexture->SetDeleteCallback(&texDeleteCallback, this, NULL);
|
||||
theTexture->SetDeleteCallback(&texDeleteCallback, this, NULL);
|
||||
|
||||
if (OGLRef.freeTextureIDs.empty())
|
||||
{
|
||||
this->ExpandFreeTextures();
|
||||
}
|
||||
|
||||
this->currTexture->texid = (u32)OGLRef.freeTextureIDs.front();
|
||||
theTexture->texid = (u32)OGLRef.freeTextureIDs.front();
|
||||
OGLRef.freeTextureIDs.pop();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)this->currTexture->texid);
|
||||
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));
|
||||
|
||||
const NDSTextureFormat texFormat = this->currTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = this->currTexture->unpackData;
|
||||
size_t texWidth = this->currTexture->sizeX;
|
||||
size_t texHeight = this->currTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeDstSurface.Surface != NULL)
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)theTexture->texid);
|
||||
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));
|
||||
|
||||
const NDSTextureFormat texFormat = theTexture->GetTextureFormat();
|
||||
const u32 *textureSrc = theTexture->unpackData;
|
||||
size_t texWidth = theTexture->sizeX;
|
||||
size_t texHeight = theTexture->sizeY;
|
||||
|
||||
if (this->_textureDeposterizeDstSurface.Surface != NULL)
|
||||
{
|
||||
this->TextureDeposterize(textureSrc, texWidth, texHeight);
|
||||
textureSrc = (u32 *)this->_textureDeposterizeDstSurface.Surface;
|
||||
}
|
||||
|
||||
switch (this->_textureScalingFactor)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
this->TextureDeposterize(textureSrc, texWidth, texHeight);
|
||||
textureSrc = (u32 *)this->_textureDeposterizeDstSurface.Surface;
|
||||
}
|
||||
|
||||
switch (this->_textureScalingFactor)
|
||||
{
|
||||
case 1:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
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, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
|
||||
case 4:
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
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 = 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, this->currTexture->sizeX, this->currTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSrc);
|
||||
break;
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
|
||||
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, theTexture->sizeX, theTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, theTexture->sizeX, theTexture->sizeY, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 2);
|
||||
|
||||
this->TextureUpscale<4>(texFormat, textureSrc, texWidth, texHeight);
|
||||
|
||||
if (isNewTexture)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->_textureSmooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (this->_textureScalingFactor > 1) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->_deviceInfo.maxAnisotropy);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
texWidth = theTexture->sizeX;
|
||||
texHeight = theTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, theTexture->sizeX, theTexture->sizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
texWidth = theTexture->sizeX;
|
||||
texHeight = theTexture->sizeY;
|
||||
this->TextureUpscale<2>(texFormat, textureSrc, texWidth, texHeight);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 1, 0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, this->_textureUpscaleBuffer);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 2, 0, 0, theTexture->sizeX, theTexture->sizeY, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, textureSrc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->_textureSmooth)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (this->_textureScalingFactor > 1) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->_deviceInfo.maxAnisotropy);
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise, just bind it
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)this->currTexture->texid);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise, just bind it
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)theTexture->texid);
|
||||
}
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -78,34 +78,39 @@ private:
|
|||
|
||||
public:
|
||||
TexCacheItem();
|
||||
TexCacheItem(const u32 texAttributes, const u32 palAttributes);
|
||||
~TexCacheItem();
|
||||
|
||||
u32 textureAttributes;
|
||||
u32 paletteAttributes;
|
||||
|
||||
u32 sizeX;
|
||||
u32 sizeY;
|
||||
float invSizeX;
|
||||
float invSizeY;
|
||||
bool isPalZeroTransparent;
|
||||
|
||||
bool suspectedInvalid;
|
||||
bool assumedInvalid;
|
||||
|
||||
NDSTextureFormat packFormat;
|
||||
u32 packAddress;
|
||||
u32 packSize;
|
||||
u8 *packData;
|
||||
|
||||
u32 paletteAddress;
|
||||
u32 paletteSize;
|
||||
u16 *paletteColorTable;
|
||||
bool isPalZeroTransparent;
|
||||
|
||||
TexCache_TexFormat unpackFormat;
|
||||
u32 unpackSize;
|
||||
u32 *unpackData;
|
||||
|
||||
bool suspectedInvalid;
|
||||
bool assumedInvalid;
|
||||
|
||||
u32 textureAttributes;
|
||||
u32 paletteAttributes;
|
||||
u32 paletteAddress;
|
||||
u32 paletteSize;
|
||||
u32 sizeX;
|
||||
u32 sizeY;
|
||||
float invSizeX;
|
||||
float invSizeY;
|
||||
|
||||
// Only used by 4x4 formatted textures
|
||||
u32 packIndexAddress;
|
||||
u32 packIndexSize;
|
||||
u8 *packIndexData;
|
||||
u32 packSizeFirstSlot;
|
||||
u32 packIndexSize;
|
||||
|
||||
// Only used by the OpenGL renderer for the texture ID
|
||||
u32 texid;
|
||||
|
@ -114,30 +119,21 @@ public:
|
|||
void SetDeleteCallback(TexCacheItemDeleteCallback callbackFunc, void *inParam1, void *inParam2);
|
||||
|
||||
NDSTextureFormat GetTextureFormat() const;
|
||||
void SetTextureData(const u32 attr, const MemSpan &packedData, const MemSpan &packedIndexData);
|
||||
void SetTexturePalette(const u32 attr, const u16 *paletteBuffer);
|
||||
void SetTextureData(const MemSpan &packedData, const MemSpan &packedIndexData);
|
||||
void SetTexturePalette(const u16 *paletteBuffer);
|
||||
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void Unpack();
|
||||
|
||||
void DebugDump();
|
||||
};
|
||||
|
||||
// TODO: Delete these MemSpan based functions after testing confirms that using the dumped texture data works properly.
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackI2(const MemSpan &ms, const u16 *pal, const bool isPalZeroTransparent, u32 *dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackI4(const MemSpan &ms, const u16 *pal, const bool isPalZeroTransparent, u32 *dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackI8(const MemSpan &ms, const u16 *pal, const bool isPalZeroTransparent, u32 *dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackA3I5(const MemSpan &ms, const u16 *pal, u32 *dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackA5I3(const MemSpan &ms, const u16 *pal, u32 *dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpack4x4(const MemSpan &ms, const u32 palAddress, const u32 texAttributes, const u32 sizeX, const u32 sizeY, u32 *dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackDirect16Bit(const MemSpan &ms, u32 *dstBuffer);
|
||||
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackI2(const size_t srcSize, const u8 *__restrict srcData, const u16 *__restrict srcPal, const bool isPalZeroTransparent, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackI4(const size_t srcSize, const u8 *__restrict srcData, const u16 *__restrict srcPal, const bool isPalZeroTransparent, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackI8(const size_t srcSize, const u8 *__restrict srcData, const u16 *__restrict srcPal, const bool isPalZeroTransparent, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackA3I5(const size_t srcSize, const u8 *__restrict srcData, const u16 *__restrict srcPal, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackA5I3(const size_t srcSize, const u8 *__restrict srcData, const u16 *__restrict srcPal, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpack4x4(const size_t srcSize, const u8 *__restrict srcData, const u8 *__restrict srcIndex, const u32 palAddress, const u32 texAttributes, const u32 sizeX, const u32 sizeY, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackDirect16Bit(const size_t srcSize, const u8 *__restrict srcData, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, const u16 *__restrict srcIndex, const u32 palAddress, const u32 texAttributes, const u32 sizeX, const u32 sizeY, u32 *__restrict dstBuffer);
|
||||
template<TexCache_TexFormat TEXCACHEFORMAT> void NDSTextureUnpackDirect16Bit(const size_t srcSize, const u16 *__restrict srcData, u32 *__restrict dstBuffer);
|
||||
|
||||
extern TexCache texCache;
|
||||
|
||||
|
|
Loading…
Reference in New Issue