cache bound texture

This commit is contained in:
Ian Curtis 2016-06-10 11:29:20 +00:00
parent 48a79a8f14
commit d799c63b1a
3 changed files with 21 additions and 4 deletions

View file

@ -92,6 +92,8 @@ void CNew3D::RenderScene(int priority, bool alpha)
continue;
}
std::shared_ptr<Texture> tex1;
glViewport (n.viewport.x, n.viewport.y, n.viewport.width, n.viewport.height);
glMatrixMode (GL_PROJECTION);
glLoadMatrixf (n.viewport.projectionMatrix);
@ -132,10 +134,15 @@ void CNew3D::RenderScene(int priority, bool alpha)
int x, y;
CalcTexOffset(m.textureOffsetX, m.textureOffsetY, m.page, mesh.x, mesh.y, x, y);
auto tex1 = m_texSheet.BindTexture(m_textureRAM, mesh.format, mesh.mirrorU, mesh.mirrorV, x, y, mesh.width, mesh.height);
if (tex1) {
tex1->BindTexture();
tex1->SetWrapMode(mesh.mirrorU, mesh.mirrorV);
if (tex1 && tex1->Compare(x, y, mesh.width, mesh.height, mesh.format)) {
tex1->SetWrapMode(mesh.mirrorU, mesh.mirrorV);
}
else {
tex1 = m_texSheet.BindTexture(m_textureRAM, mesh.format, mesh.mirrorU, mesh.mirrorV, x, y, mesh.width, mesh.height);
if (tex1) {
tex1->BindTexture();
tex1->SetWrapMode(mesh.mirrorU, mesh.mirrorV);
}
}
if (mesh.microTexture) {

View file

@ -325,4 +325,13 @@ void Texture::GetDetails(int& x, int&y, int& width, int& height, int& format)
format = m_format;
}
bool Texture::Compare(int x, int y, int width, int height, int format)
{
if (m_x == x && m_y == y && m_width == width && m_height == height && m_format == format) {
return true;
}
return false;
}
} // New3D

View file

@ -19,6 +19,7 @@ public:
void GetCoordinates (UINT16 uIn, UINT16 vIn, float uvScale, float& uOut, float& vOut);
void GetDetails (int& x, int&y, int& width, int& height, int& format);
void SetWrapMode (bool mirrorU, bool mirrorV);
bool Compare (int x, int y, int width, int height, int format);
static void GetCoordinates(int width, int height, UINT16 uIn, UINT16 vIn, float uvScale, float& uOut, float& vOut);