From 2d38e89194156d74f9ddfbeaef81ff062b907758 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut@gmail.com" Date: Tue, 25 Jan 2011 19:29:08 +0000 Subject: [PATCH] zzogl: align_16 array before sse2 instruction + minor stuff git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4263 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zzogl-pg/opengl/ZZClut.cpp | 6 +++--- plugins/zzogl-pg/opengl/ZZoglFlush.cpp | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/zzogl-pg/opengl/ZZClut.cpp b/plugins/zzogl-pg/opengl/ZZClut.cpp index d948952a81..3ac380c90b 100644 --- a/plugins/zzogl-pg/opengl/ZZClut.cpp +++ b/plugins/zzogl-pg/opengl/ZZClut.cpp @@ -502,8 +502,8 @@ template <> u16* clut = (u16*)GetClutBufferAddress(csa); // Keep aligned version for sse2 // which side to copy - u32 clutsize_right; - u32 clutsize_left; + s32 clutsize_right; + s32 clutsize_left; if (csa < 16) { clutsize_right = min(clutsize, (16-csa)*64); clutsize_left = clutsize - clutsize_right; @@ -582,7 +582,7 @@ template <> #else // Note +1 because we change higher 16 bits for(int i = 0; i < 16; ++i) - dst[i] = clut[2*i]; + dst[i] = clut[2*i+1]; #endif dst += 16; diff --git a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp index 0c7b888a5f..bbe3e2a007 100644 --- a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp @@ -722,27 +722,30 @@ inline void FlushDecodeClut(VB& curvb, GLuint& ptexclut) { glGenTextures(1, &ptexclut); glBindTexture(GL_TEXTURE_2D, ptexclut); - vector data(PSMT_ISHALF_STORAGE(curvb.tex0) ? 512 : 1024); if (ptexclut != 0) { int clutsize; int entries = PSMT_IS8CLUT(curvb.tex0.psm) ? 256 : 16; - if (curvb.tex0.csm && curvb.tex0.csa) - ZZLog::Debug_Log("ERROR, csm1."); + if (curvb.tex0.csm && curvb.tex0.csa) ZZLog::Debug_Log("ERROR, csm1."); if (PSMT_IS32BIT(curvb.tex0.cpsm)) { + __aligned16 u32 data[256]; clutsize = min(entries, 256 - curvb.tex0.csa * 16) * 4; - ClutBuffer_to_Array((u32*)&data[0], curvb.tex0.csa, clutsize); + + ClutBuffer_to_Array((u32*)data, curvb.tex0.csa, clutsize); + + Texture2D(4, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE, data); } else { + __aligned16 u16 data[256]; clutsize = min(entries, 512 - curvb.tex0.csa * 16) * 2; - ClutBuffer_to_Array((u16*)&data[0], curvb.tex0.csa, clutsize); + + ClutBuffer_to_Array((u16*)data, curvb.tex0.csa, clutsize); + + Texture2D(4, 256, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data); } - GLenum tempType = PSMT_ISHALF_STORAGE(curvb.tex0) ? GL_UNSIGNED_SHORT_5_5_5_1 : GL_UNSIGNED_BYTE; - Texture2D(4, 256, 1, GL_RGBA, tempType, &data[0]); - s_vecTempTextures.push_back(ptexclut); if (g_bSaveTex) SaveTexture("clut.tga", GL_TEXTURE_2D, ptexclut, 256, 1);