From f4584d3c9cdb37ae18166ce57bebca14778678b5 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut@gmail.com" Date: Tue, 19 Oct 2010 17:53:36 +0000 Subject: [PATCH] GregMiscellaneous: zzogl-pg: * 16 bits aligned the local clut array to allow sse2 operations git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3947 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zzogl-pg/opengl/targets.cpp | 27 ++++++++++++++++----------- plugins/zzogl-pg/opengl/targets.h | 7 ++++++- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/plugins/zzogl-pg/opengl/targets.cpp b/plugins/zzogl-pg/opengl/targets.cpp index a8fa377429..bdda9078f3 100644 --- a/plugins/zzogl-pg/opengl/targets.cpp +++ b/plugins/zzogl-pg/opengl/targets.cpp @@ -1737,9 +1737,7 @@ int CMemoryTargetMngr::CompareTarget(list::iterator& it, const te return 1; if (PSMT_ISCLUT(tex0.psm)) { - assert(it->clut.size() > 0); - - if (it->psm != tex0.psm || it->cpsm != tex0.cpsm || it->clut.size() != clutsize) + if (it->psm != tex0.psm || it->cpsm != tex0.cpsm || it->clutsize != clutsize) return 1; if (PSMT_IS32BIT(tex0.cpsm)) { @@ -1986,8 +1984,17 @@ CMemoryTarget* CMemoryTargetMngr::GetMemoryTarget(const tex0Info& tex0, int forc // Local clut parameter targ->cpsm = tex0.cpsm; - targ->clut.reserve(256*4); // no matter what - targ->clut.resize(clutsize); + + // Allocate a local clut array + targ->clutsize = clutsize; + if(targ->clut == NULL) + targ->clut = (u8*)_aligned_malloc(clutsize, 16); + else { + // In case it could occured + // realloc would be better but you need to get it from libutilies first + _aligned_free(targ->clut); + targ->clut = (u8*)_aligned_malloc(clutsize, 16); + } // texture parameter ptexdata = (u8*)_aligned_malloc(CLUT_PIXEL_SIZE(tex0.cpsm) * targ->texH * targ->texW, 16); @@ -1998,15 +2005,13 @@ CMemoryTarget* CMemoryTargetMngr::GetMemoryTarget(const tex0Info& tex0, int forc // Fill a local clut then build the real texture if (PSMT_IS32BIT(tex0.cpsm)) { - u32* pclut = (u32*) & targ->clut[0]; - ClutBuffer_to_Array(pclut, tex0.csa, clutsize); - Build_Clut_Texture(tex0.psm, targ->height, pclut, psrc, (u32*)ptexdata); + ClutBuffer_to_Array((u32*)targ->clut, tex0.csa, clutsize); + Build_Clut_Texture(tex0.psm, targ->height, (u32*)targ->clut, psrc, (u32*)ptexdata); } else { - u16* pclut = (u16*) & targ->clut[0]; - ClutBuffer_to_Array(pclut, tex0.csa, clutsize); - Build_Clut_Texture(tex0.psm, targ->height, pclut, psrc, (u16*)ptexdata); + ClutBuffer_to_Array((u16*)targ->clut, tex0.csa, clutsize); + Build_Clut_Texture(tex0.psm, targ->height, (u16*)targ->clut, psrc, (u16*)ptexdata); } assert(targ->clut.size() > 0); diff --git a/plugins/zzogl-pg/opengl/targets.h b/plugins/zzogl-pg/opengl/targets.h index 7b2fc4dd11..dbdb08b831 100644 --- a/plugins/zzogl-pg/opengl/targets.h +++ b/plugins/zzogl-pg/opengl/targets.h @@ -186,6 +186,10 @@ class CMemoryTarget } ptex = NULL; + + _aligned_free(clut); + clut = NULL; + clutsize = 0; } // returns true if clut data is synced @@ -218,7 +222,8 @@ class CMemoryTarget int validatecount; // count how many times has been validated, if too many, destroy - vector clut; // if nonzero, texture uses CLUT + u8* clut; // Clut texture data. Null otherwise + int clutsize; // size of the clut array. 0 otherwise };