From e98a273b5472af8b8d4a1d1e055c03856356c289 Mon Sep 17 00:00:00 2001 From: Rodolfo Osvaldo Bogado Date: Wed, 3 Feb 2010 14:13:03 +0000 Subject: [PATCH] fixes for my last commit: chage the global format of the screenshots to bmp, is correctly supported by both plugins and is faster. reverted the changes in safe texture cache, will try to make them more stable then commit them, this should fix compilation in linux and macand error introduced in MP games corrected all the issues commented by ector, thanks for the comments alway is good that the code is revised by others to find missed spots. please report any remaining issue to solve them. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5001 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 4 +-- .../Core/VideoCommon/Src/TextureDecoder.cpp | 32 ++++++++++++++++++- Source/Core/VideoCommon/Src/VideoConfig.cpp | 2 +- .../Plugin_VideoDX9/Src/D3DTexture.cpp | 5 ++- .../Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp | 4 --- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 2 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 2 +- 7 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index e6f0cdfe38..00446ca8c9 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -539,9 +539,9 @@ static inline std::string GenerateScreenshotName() //append gameId, tempname only contains the folder here. tempname += gameId; - name = StringFromFormat("%s-%d.png", tempname.c_str(), index); + name = StringFromFormat("%s-%d.bmp", tempname.c_str(), index); while(File::Exists(name.c_str())) - name = StringFromFormat("%s-%d.png", tempname.c_str(), ++index); + name = StringFromFormat("%s-%d.bmp", tempname.c_str(), ++index); return name; } diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index d49633609c..c6db5582bb 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -88,7 +88,7 @@ int TexDecoder_GetTextureSizeInBytes(int width, int height, int format) return (width * height * TexDecoder_GetTexelSizeInNibbles(format)) / 2; } -u64 TexDecoder_GetTlutHash(const u8* src, int len) +/*u64 TexDecoder_GetTlutHash(const u8* src, int len) { //char str[40000], st[20]; str[0]='\0';for (int i=0;ileft = XOffset; rc->top = flip ? (int)(YOffset + iHeight) : YOffset; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp index fb1ababed1..dd26739cbb 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp @@ -17,7 +17,6 @@ #include "D3DBase.h" #include "D3DTexture.h" -#include "Math.h" namespace D3D { @@ -121,7 +120,7 @@ LPDIRECT3DTEXTURE9 CreateTexture2D(const u8* buffer, const int width, const int } break; case D3DFMT_DXT1: - memcpy(Lock.pBits,buffer,(size_t)(ceilf(((float)width)/4.0f) * ceilf(((float)height)/4.0f) * 8)); + memcpy(Lock.pBits,buffer,((width+3)/4)*((height+3)/4)*8); break; default: PanicAlert("D3D: Invalid texture format %i", fmt); @@ -240,7 +239,7 @@ void ReplaceTexture2D(LPDIRECT3DTEXTURE9 pTexture, const u8* buffer, const int w } break; case D3DFMT_DXT1: - memcpy(Lock.pBits, buffer, (size_t)(ceilf(((float)width)/4.0f) * ceilf(((float)height)/4.0f) * 8)); + memcpy(Lock.pBits,buffer,((width+3)/4)*((height+3)/4)*8); break; } pTexture->UnlockRect(level); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 440492615d..8b73e8923f 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -380,7 +380,6 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture, dev->SetVertexShader(Vshader); dev->SetPixelShader(PShader); D3D::SetTexture(0, texture); - dev->SetVertexDeclaration(NULL); dev->SetFVF(D3DFVF_XYZW | D3DFVF_TEX2); dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex)); RestoreShaders(); @@ -415,7 +414,6 @@ void drawFSAATexQuad(IDirect3DTexture9 *texture, dev->SetPixelShader(PShader); D3D::SetTexture(0, texture); D3D::SetTexture(1, Depthtexture); - dev->SetVertexDeclaration(NULL); dev->SetFVF(D3DFVF_XYZW | D3DFVF_TEX3); dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex)); RestoreShaders(); @@ -431,8 +429,6 @@ void drawClearQuad(u32 Color,float z,IDirect3DPixelShader9 *PShader,IDirect3DVer }; dev->SetVertexShader(Vshader); dev->SetPixelShader(PShader); - D3D::SetTexture(0, 0); - dev->SetVertexDeclaration(NULL); dev->SetFVF(D3DFVF_XYZW | D3DFVF_DIFFUSE); dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex)); RestoreShaders(); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 46e5450141..1aca76d7c8 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -590,7 +590,7 @@ static void EFBTextureToD3DBackBuffer(const EFBRectangle& sourceRc) if(s_bScreenshot) { s_criticalScreenshot.Enter(); - D3DXSaveSurfaceToFileA(s_sScreenshotName, D3DXIFF_JPG, D3D::GetBackBufferSurface(), NULL, &destinationrect); + D3DXSaveSurfaceToFileA(s_sScreenshotName, D3DXIFF_BMP, D3D::GetBackBufferSurface(), NULL, &destinationrect); s_bScreenshot = false; s_criticalScreenshot.Leave(); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 58168a19dd..e0de796645 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1301,7 +1301,7 @@ THREAD_RETURN TakeScreenshot(void *pArgs) // Save the screenshot and finally kill the wxImage object // This is really expensive when saving to PNG, but not at all when using BMP - threadStruct->img->SaveFile(wxString::FromAscii(threadStruct->filename.c_str()), wxBITMAP_TYPE_PNG); + threadStruct->img->SaveFile(wxString::FromAscii(threadStruct->filename.c_str()), wxBITMAP_TYPE_BMP); threadStruct->img->Destroy(); // Show success messages