From 75c9ce249868abd8408effedd96f938bf02dc7bd Mon Sep 17 00:00:00 2001 From: raven02 Date: Tue, 30 Jul 2013 23:09:22 +0800 Subject: [PATCH] GPUstate :Add getTextureWidth() & getTextureHeight() and --- GPU/GLES/DisplayListInterpreter.cpp | 4 ++-- GPU/GLES/ShaderManager.cpp | 4 ++-- GPU/GLES/TextureCache.cpp | 8 ++++---- GPU/GLES/TransformPipeline.cpp | 4 ++-- GPU/GPUState.h | 2 ++ 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index f52fd97579..58ced4240a 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -633,8 +633,8 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff) { } case GE_CMD_TEXSIZE0: - gstate_c.curTextureWidth = 1 << (gstate.texsize[0] & 0xf); - gstate_c.curTextureHeight = 1 << ((gstate.texsize[0] >> 8) & 0xf); + gstate_c.curTextureWidth = gstate.getTextureWidth(); + gstate_c.curTextureHeight = gstate.getTextureHeight(); shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET); //fall thru - ignoring the mipmap sizes for now case GE_CMD_TEXSIZE1: diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index 3e3e5695bc..9bf18088d4 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -331,8 +331,8 @@ void LinkedShader::updateUniforms() { uvscaleoff[3] = gstate_c.uv.vOff / gstate_c.curTextureHeight; glUniform4fv(u_uvscaleoffset, 1, uvscaleoff); } else { - int w = 1 << (gstate.texsize[0] & 0xf); - int h = 1 << ((gstate.texsize[0] >> 8) & 0xf); + int w = gstate.getTextureWidth(); + int h = gstate.getTextureHeight(); float widthFactor = (float)w / (float)gstate_c.curTextureWidth; float heightFactor = (float)h / (float)gstate_c.curTextureHeight; if ((gstate.texmapmode & 3) == 0) { diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 8d2753680e..5c575d7628 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -392,8 +392,8 @@ inline void DeIndexTexture4Optimal(ClutT *dest, const u32 texaddr, int length, C void *TextureCache::readIndexedTex(int level, u32 texaddr, int bytesPerIndex, GLuint dstFmt) { int bufw = GetLevelBufw(level, texaddr); - int w = 1 << (gstate.texsize[0] & 0xf); - int h = 1 << ((gstate.texsize[0] >> 8) & 0xf); + int w = gstate.getTextureWidth(); + int h = gstate.getTextureHeight(); int length = bufw * h; void *buf = NULL; switch (gstate.getClutPaletteFormat()) { @@ -996,8 +996,8 @@ void TextureCache::SetTexture() { cluthash = 0; } - int w = 1 << (gstate.texsize[0] & 0xf); - int h = 1 << ((gstate.texsize[0] >> 8) & 0xf); + int w = gstate.getTextureWidth(); + int h = gstate.getTextureHeight(); int bufw = GetLevelBufw(0, texaddr); int maxLevel = ((gstate.texmode >> 16) & 0x7); diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index 5c0948db86..44e81c1a43 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -524,8 +524,8 @@ void TransformDrawEngine::SoftwareTransformAndDraw( vscale /= gstate_c.curTextureHeight; } - int w = 1 << (gstate.texsize[0] & 0xf); - int h = 1 << ((gstate.texsize[0] >> 8) & 0xf); + int w = gstate.getTextureWidth(); + int h = gstate.getTextureHeight(); float widthFactor = (float) w / (float) gstate_c.curTextureWidth; float heightFactor = (float) h / (float) gstate_c.curTextureHeight; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index a09d5d6694..ad6288acd7 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -246,6 +246,8 @@ struct GPUgstate u32 getColorTestMask() const { return colormask & 0xFFFFFF; } // Texturing + int getTextureWidth() const { return 1 << (texsize[0] & 0xf);} + int getTextureHeight() const { return 1 << ((texsize[0] >> 8) & 0xf);} bool isTextureMapEnabled() const { return textureMapEnable & 1; } GETexFunc getTextureFunction() const { return static_cast(texfunc & 0x7); } bool isColorDoublingEnabled() const { return (texfunc & 0x10000) != 0; }