From 72cb7739b67b819fd1ea135e22e709e4537e362f Mon Sep 17 00:00:00 2001 From: Ced2911 Date: Sat, 17 Aug 2013 15:11:27 +0200 Subject: [PATCH] update gpu Conflicts: GPU/GPUState.cpp --- GPU/Directx9/Framebuffer.cpp | 32 +-- GPU/Directx9/TextureCache.cpp | 48 ++-- GPU/Directx9/TransformPipeline.cpp | 2 +- GPU/Directx9/TransformPipeline.h | 2 +- GPU/GPUState.cpp | 12 +- GPU/GPUXbox.vcxproj | 428 +++++++++++++++-------------- GPU/GPUXbox.vcxproj.filters | 3 - 7 files changed, 273 insertions(+), 254 deletions(-) diff --git a/GPU/Directx9/Framebuffer.cpp b/GPU/Directx9/Framebuffer.cpp index acf2334caa..bf3a676525 100644 --- a/GPU/Directx9/Framebuffer.cpp +++ b/GPU/Directx9/Framebuffer.cpp @@ -16,7 +16,6 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include "math/lin/matrix4x4.h" - #include "Core/Host.h" #include "Core/MemMap.h" #include "Core/Config.h" @@ -31,6 +30,7 @@ #include "GPU/Directx9/TextureCache.h" #include "GPU/Directx9/ShaderManager.h" + // Aggressively delete unused FBO:s to save gpu memory. enum { FBO_OLD_AGE = 5, @@ -169,7 +169,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, GEBufferFormat pixelForm const u16 *src = (const u16 *)framebuf + linesize * y; u32 *dst = (u32*)(convBuf + rect.Pitch * y); for (int x = 0; x < 480; x++) { - u16 col0 = LE_16(src[x+0]); + u16_le col0 = src[x+0]; ARGB8From565(col0, &dst[x + 0]); } } @@ -180,7 +180,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, GEBufferFormat pixelForm const u16 *src = (const u16 *)framebuf + linesize * y; u32 *dst = (u32*)(convBuf + rect.Pitch * y); for (int x = 0; x < 480; x++) { - u16 col0 = LE_16(src[x+0]); + u16_le col0 = src[x+0]; ARGB8From5551(col0, &dst[x + 0]); } } @@ -192,7 +192,7 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, GEBufferFormat pixelForm u32 *dst = (u32*)(convBuf + rect.Pitch * y); for (int x = 0; x < 480; x++) { - u16 col = LE_16(src[x]); + u16_le col = src[x]; dst[x * 4 + 0] = (col >> 12) << 4; dst[x * 4 + 1] = ((col >> 8) & 0xf) << 4; dst[x * 4 + 2] = ((col >> 4) & 0xf) << 4; @@ -333,7 +333,7 @@ void FramebufferManager::DestroyFramebuf(VirtualFramebuffer *v) { void FramebufferManager::SetRenderFrameBuffer() { if (!gstate_c.framebufChanged && currentRenderVfb_) { - currentRenderVfb_->last_frame_used = gpuStats.numFrames; + currentRenderVfb_->last_frame_used = gpuStats.numFlips; return; } gstate_c.framebufChanged = false; @@ -440,8 +440,8 @@ void FramebufferManager::SetRenderFrameBuffer() { textureCache_->NotifyFramebuffer(vfb->fb_address, vfb); - vfb->last_frame_used = gpuStats.numFrames; - frameLastFramebufUsed = gpuStats.numFrames; + vfb->last_frame_used = gpuStats.numFlips; + frameLastFramebufUsed = gpuStats.numFlips; vfbs_.push_back(vfb); dxstate.depthWrite.set(true); @@ -458,8 +458,8 @@ void FramebufferManager::SetRenderFrameBuffer() { DEBUG_LOG(HLE, "Switching render target to FBO for %08x: %i x %i x %i ", vfb->fb_address, vfb->width, vfb->height, vfb->format); vfb->usageFlags |= FB_USAGE_RENDERTARGET; gstate_c.textureChanged = true; - vfb->last_frame_used = gpuStats.numFrames; - frameLastFramebufUsed = gpuStats.numFrames; + vfb->last_frame_used = gpuStats.numFlips; + frameLastFramebufUsed = gpuStats.numFlips; vfb->dirtyAfterDisplay = true; if (useBufferedRendering_) { @@ -499,7 +499,7 @@ void FramebufferManager::SetRenderFrameBuffer() { // to it. This broke stuff before, so now it only clears on the first use of an // FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs // performance-crushing framebuffer reloads from RAM, but we'll have to live with that. - if (vfb->last_frame_used != gpuStats.numFrames) { + if (vfb->last_frame_used != gpuStats.numFlips) { dxstate.depthWrite.set(true); dxstate.colorMask.set(true, true, true, true); pD3Ddevice->Clear(0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_TARGET |D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 0, 0); @@ -507,8 +507,8 @@ void FramebufferManager::SetRenderFrameBuffer() { #endif currentRenderVfb_ = vfb; } else { - vfb->last_frame_used = gpuStats.numFrames; - frameLastFramebufUsed = gpuStats.numFrames; + vfb->last_frame_used = gpuStats.numFlips; + frameLastFramebufUsed = gpuStats.numFlips; } // ugly... @@ -657,7 +657,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb) { } } - nvfb->last_frame_used = gpuStats.numFrames; + nvfb->last_frame_used = gpuStats.numFlips; bvfbs_.push_back(nvfb); dxstate.depthWrite.set(true); @@ -667,7 +667,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb) { } else { nvfb->usageFlags |= FB_USAGE_RENDERTARGET; - nvfb->last_frame_used = gpuStats.numFrames; + nvfb->last_frame_used = gpuStats.numFlips; nvfb->dirtyAfterDisplay = true; if (useBufferedRendering_) { @@ -678,7 +678,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb) { // to it. This broke stuff before, so now it only clears on the first use of an // FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs // performance-crushing framebuffer reloads from RAM, but we'll have to live with that. - if (nvfb->last_frame_used != gpuStats.numFrames) { + if (nvfb->last_frame_used != gpuStats.numFlips) { dxstate.depthWrite.set(true); dxstate.colorMask.set(true, true, true, true); pD3Ddevice->Clear(0, NULL, D3DCLEAR_STENCIL|D3DCLEAR_TARGET |D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 0, 0); @@ -876,7 +876,7 @@ void FramebufferManager::DecimateFBOs() { fbo_unbind(); currentRenderVfb_ = 0; int num = g_Config.iFrameSkip > 0 && g_Config.iFrameSkip != 9 ? g_Config.iFrameSkip : 3; - bool skipFrame = (gpuStats.numFrames % num == 0); + bool skipFrame = (gpuStats.numFlips % num == 0); bool useFramebufferToMem = g_Config.iRenderingMode != FB_BUFFERED_MODE ? 1 : 0; for (size_t i = 0; i < vfbs_.size(); ++i) { diff --git a/GPU/Directx9/TextureCache.cpp b/GPU/Directx9/TextureCache.cpp index aa4b1434b2..be48610d58 100644 --- a/GPU/Directx9/TextureCache.cpp +++ b/GPU/Directx9/TextureCache.cpp @@ -102,7 +102,7 @@ void TextureCache::Decimate() { lastBoundTexture = NULL; int killAge = lowMemoryMode_ ? TEXTURE_KILL_AGE_LOWMEM : TEXTURE_KILL_AGE; for (TexCache::iterator iter = cache.begin(); iter != cache.end(); ) { - if (iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFrames) { + if (iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFlips) { iter->second.texture->Release(); cache.erase(iter++); } @@ -110,7 +110,7 @@ void TextureCache::Decimate() { ++iter; } for (TexCache::iterator iter = secondCache.begin(); iter != secondCache.end(); ) { - if (lowMemoryMode_ || iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFrames) { + if (lowMemoryMode_ || iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFlips) { iter->second.texture->Release(); secondCache.erase(iter++); } @@ -621,19 +621,19 @@ void TextureCache::UpdateSamplingParams(TexCacheEntry &entry, bool force) { struct DXT1Block { u8 lines[4]; - u16 color1; - u16 color2; + u16_le color1; + u16_le color2; }; struct DXT3Block { DXT1Block color; - u16 alphaLines[4]; + u16_le alphaLines[4]; }; struct DXT5Block { DXT1Block color; - u32 alphadata2; - u16 alphadata1; + u32_le alphadata2; + u16_le alphadata1; u8 alpha1; u8 alpha2; }; @@ -645,8 +645,8 @@ static inline u32 makecol(int r, int g, int b, int a) { static void decodeDXT1Block(u32 *dst, const DXT1Block *src, int pitch, bool ignore1bitAlpha = false) { // S3TC Decoder // Needs more speed and debugging. - u16 c1 = LE_16(src->color1); - u16 c2 = LE_16(src->color2); + u16 c1 = src->color1; + u16 c2 = src->color2; int red1 = Convert5To8(c1 & 0x1F); int red2 = Convert5To8(c2 & 0x1F); int green1 = Convert6To8((c1 >> 5) & 0x3F); @@ -728,7 +728,9 @@ static void decodeDXT5Block(u32 *dst, const DXT5Block *src, int pitch) { alpha[7] = 255; } - u64 data = ((u64)LE_16(src->alphadata1) << 32) | LE_32(src->alphadata2); + u32 a1 = src->alphadata1; + u32 a2 = src->alphadata2; + u64 data = ((u64)a1 << 32) | a2; for (int y = 0; y < 4; y++) { for (int x = 0; x < 4; x++) { @@ -752,7 +754,7 @@ static void ClutConvertColors(void *dstBuf, const void *srcBuf, u32 dstFmt, int u16 *dst = (u16 *)dstBuf; for (int i = 0; i < numPixels; i++) { // dst[i] = LE_16(src[i]); - unsigned short rgb = LE_16(src[i]); + u16_le rgb = (src[i]); ((uint16_t *)dst)[i] = (rgb & 0x83E0) | ((rgb & 0x1F) << 10) | ((rgb & 0x7C00) >> 10); } } @@ -760,11 +762,11 @@ static void ClutConvertColors(void *dstBuf, const void *srcBuf, u32 dstFmt, int case D3DFMT_A4R4G4B4: { const u16 *src = (const u16 *)srcBuf; - u16 *dst = (u16 *)dstBuf; + u16_le *dst = (u16_le *)dstBuf; for (int i = 0; i < numPixels; i++) { // Already good format - unsigned short rgb = LE_16(src[i]); - dst[i] = LE_16((rgb & 0xF) | (rgb & 0xF0)<<8 | ( rgb & 0xF00) | ((rgb & 0xF000)>>8)) ; + u16_le rgb = src[i]; + dst[i] = (rgb & 0xF) | (rgb & 0xF0)<<8 | ( rgb & 0xF00) | ((rgb & 0xF000)>>8); } } break; @@ -773,7 +775,7 @@ static void ClutConvertColors(void *dstBuf, const void *srcBuf, u32 dstFmt, int const u16 *src = (const u16 *)srcBuf; u16 *dst = (u16 *)dstBuf; for (int i = 0; i < numPixels; i++) { - unsigned short rgb = LE_16(src[i]); + u16_le rgb = src[i]; dst[i] = ((rgb & 0x1f) << 11) | ( rgb & 0x7e0) | ((rgb & 0xF800) >>11 ); } } @@ -983,16 +985,16 @@ void TextureCache::UpdateCurrentClut() { clutAlphaLinear_ = false; clutAlphaLinearColor_ = 0; if (gstate.getClutPaletteFormat() == GE_CMODE_16BIT_ABGR4444 && gstate.isClutIndexSimple()) { - const u16 *clut = GetCurrentClut(); + const u16_le *clut = (const u16_le*)GetCurrentClut(); clutAlphaLinear_ = true; - clutAlphaLinearColor_ = LE_16(clut[15]) & 0xFFF0; + clutAlphaLinearColor_ = clut[15] & 0xFFF0; for (int i = 0; i < 16; ++i) { if ((clut[i] & 0xf) != i) { clutAlphaLinear_ = false; break; } // Alpha 0 doesn't matter. - if (i != 0 && (LE_16(clut[i]) & 0xFFF0) != clutAlphaLinearColor_) { + if (i != 0 && (clut[i] & 0xFFF0) != clutAlphaLinearColor_) { clutAlphaLinear_ = false; break; } @@ -1126,13 +1128,13 @@ void TextureCache::SetTexture() { gstate_c.curTextureHeight = entry->framebuffer->height; gstate_c.flipTexture = true; gstate_c.textureFullAlpha = entry->framebuffer->format == GE_FORMAT_565; - entry->lastFrame = gpuStats.numFrames; + entry->lastFrame = gpuStats.numFlips; } else { if (entry->framebuffer->fbo) entry->framebuffer->fbo = 0; pD3Ddevice->SetTexture(0, NULL); lastBoundTexture = NULL; - entry->lastFrame = gpuStats.numFrames; + entry->lastFrame = gpuStats.numFlips; } return; } @@ -1144,7 +1146,7 @@ void TextureCache::SetTexture() { bool doDelete = true; if (match) { - if (entry->lastFrame != gpuStats.numFrames) { + if (entry->lastFrame != gpuStats.numFlips) { entry->numFrames++; } if (entry->framesUntilNextFullHash == 0) { @@ -1210,7 +1212,7 @@ void TextureCache::SetTexture() { if (match) { // TODO: Mark the entry reliable if it's been safe for long enough? //got one! - entry->lastFrame = gpuStats.numFrames; + entry->lastFrame = gpuStats.numFlips; if (entry->texture != lastBoundTexture) { pD3Ddevice->SetTexture(0, entry->texture); lastBoundTexture = entry->texture; @@ -1256,7 +1258,7 @@ void TextureCache::SetTexture() { entry->addr = texaddr; entry->hash = texhash; entry->format = format; - entry->lastFrame = gpuStats.numFrames; + entry->lastFrame = gpuStats.numFlips; entry->framebuffer = 0; entry->maxLevel = maxLevel; entry->lodBias = 0.0f; diff --git a/GPU/Directx9/TransformPipeline.cpp b/GPU/Directx9/TransformPipeline.cpp index d649e5213b..e30395837a 100644 --- a/GPU/Directx9/TransformPipeline.cpp +++ b/GPU/Directx9/TransformPipeline.cpp @@ -1051,7 +1051,7 @@ void TransformDrawEngine::ClearTrackedVertexArrays() { } void TransformDrawEngine::DecimateTrackedVertexArrays() { - int threshold = gpuStats.numFrames - VAI_KILL_AGE; + int threshold = gpuStats.numFlips - VAI_KILL_AGE; for (auto iter = vai_.begin(); iter != vai_.end(); ) { if (iter->second->lastFrame < threshold) { delete iter->second; diff --git a/GPU/Directx9/TransformPipeline.h b/GPU/Directx9/TransformPipeline.h index cc17184308..167e17af8d 100644 --- a/GPU/Directx9/TransformPipeline.h +++ b/GPU/Directx9/TransformPipeline.h @@ -57,7 +57,7 @@ public: prim = -1; numDraws = 0; numFrames = 0; - lastFrame = gpuStats.numFrames; + lastFrame = gpuStats.numFlips; numVerts = 0; drawsUntilNextFullHash = 0; } diff --git a/GPU/GPUState.cpp b/GPU/GPUState.cpp index 525d100631..f158cdb567 100644 --- a/GPU/GPUState.cpp +++ b/GPU/GPUState.cpp @@ -17,10 +17,16 @@ #include "GPU/ge_constants.h" #include "GPU/GPUState.h" +#ifndef _XBOX #include "GPU/GLES/ShaderManager.h" #include "GPU/GLES/GLES_GPU.h" +#endif +#ifdef USE_DIRECTX #include "GPU/Null/NullGpu.h" #include "GPU/Software/SoftGpu.h" +#ifdef USE_DIRECTX +#include "Directx9/DisplayListInterpreter.h" +#endif #include "Core/CoreParameter.h" #include "Core/System.h" @@ -34,16 +40,18 @@ bool GPU_Init() { case GPU_NULL: gpu = new NullGPU(); break; +#ifndef _XBOX case GPU_GLES: gpu = new GLES_GPU(); break; +#endif case GPU_SOFTWARE: -#ifndef __SYMBIAN32__ +#if !(defined(__SYMBIAN32__) || defined(_XBOX)) gpu = new SoftGPU(); #endif break; case GPU_DIRECTX9: - // TODO + gpu = new DIRECTX9_GPU(); break; } diff --git a/GPU/GPUXbox.vcxproj b/GPU/GPUXbox.vcxproj index 16aeada0c0..f37da47cdf 100644 --- a/GPU/GPUXbox.vcxproj +++ b/GPU/GPUXbox.vcxproj @@ -1,269 +1,199 @@  - - Debug_Optimised - Win32 - - - Debug_Optimised - x64 - - - Debug_Optimised + + CodeAnalysis Xbox 360 - - Debug - Win32 - - - Debug - x64 - Debug Xbox 360 - - Release - Win32 + + Profile + Xbox 360 - - Release - x64 + + Profile_FastCap + Xbox 360 Release Xbox 360 + + Release_LTCG + Xbox 360 + {DCC4F772-A6E5-4F54-9ACA-BD090CC971C5} - GPU + Xbox360Proj - + StaticLibrary - true MultiByte - false - - - StaticLibrary - true - MultiByte - false StaticLibrary - true MultiByte - false - + StaticLibrary - true MultiByte - false - + StaticLibrary - true - MultiByte - false - - - StaticLibrary - true - MultiByte - false - - - StaticLibrary - false - false MultiByte StaticLibrary - false - false MultiByte - + StaticLibrary - false - false + true MultiByte - + - + - + - + - + - - - - - - - - - - + - $(OutDir)GPU$(TargetExt) + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib + + + $(OutDir)$(ProjectName).lib - - - Level3 - Disabled - ../common;..;../native;../native/ext/glew; - _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - StreamingSIMDExtensions2 - Fast - true - false - false - - - true - - - - - Level3 - Disabled - ../common;..;../native;../native/ext/glew; - _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - StreamingSIMDExtensions2 - Fast - true - false - false - - - true - - + NotUsing Level3 + ProgramDatabase Disabled - ../common;..;../native;../native/ext/glew; - USE_DIRECTX;BIG_ENDIAN;PPC;_XBOX;_MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - true - false - false - MultiThreadedDebug - core/x360_compat.h - - - true - - - - - Level3 - Full - ../common;..;../native;../native/ext/glew; - USE_DIRECTX;BIG_ENDIAN;PPC;_XBOX;_MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - true - false - false - MultiThreadedDebug - core/x360_compat.h - Default - - - true - - - - - Level3 - Disabled - ../common;..;../native;../native/ext/glew; - StreamingSIMDExtensions2 - Fast - false - true - false - false - - - true - - - - - Level3 - Disabled - ../common;..;../native;../native/ext/glew; - StreamingSIMDExtensions2 - Fast - false - true - false - false - - - true - - - - - Level3 - MaxSpeed - true - true - ../common;..;../native;../native/ext/glew; + false + true false - StreamingSIMDExtensions2 - Fast - _MBCS;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - Speed - true - false + $(OutDir)$(ProjectName).pch + MultiThreadedDebug + USE_DIRECTX;WIN32;_XBOX;PPC;BIG_ENDIAN;_DEBUG;_XBOX;_LIB + Callcap + ../common;..;../native;../native/ext/glew; + core/x360_compat.h true - true + + + + + NotUsing + Level4 + ProgramDatabase + Disabled + false + true + AnalyzeOnly + false + $(OutDir)$(ProjectName).pch + MultiThreadedDebug + _DEBUG;_XBOX;_LIB + Callcap + + + true + + + + + Level3 + NotUsing + Full + true + false + true + ProgramDatabase + Size + false + $(OutDir)$(ProjectName).pch + MultiThreaded + NDEBUG;_XBOX;PROFILE;_LIB + Callcap + + + true + false + xapilib.lib + true + + + + + Level3 + NotUsing + Full + true + false + true + ProgramDatabase + Fastcap + Size + false + $(OutDir)$(ProjectName).pch + MultiThreaded + NDEBUG;_XBOX;PROFILE;FASTCAP;_LIB + + + true + false true Level3 + NotUsing Full true - true - ../common;..;../native;../native/ext/glew; + true + ProgramDatabase + Size + false false - Fast - USE_DIRECTX;WIN32;_XBOX;PPC;BIG_ENDIAN;NO_JIT;;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - Speed - true - false + $(OutDir)$(ProjectName).pch MultiThreaded - core/x360_compat.h + NDEBUG;_XBOX;_LIB true @@ -271,20 +201,22 @@ true - + Level3 - MaxSpeed + NotUsing + Full true - true - ../common;..;../native;../native/ext/glew; + true + ProgramDatabase + Size + false false - StreamingSIMDExtensions2 - Fast - Speed - false - true - false + $(OutDir)$(ProjectName).pch + MultiThreaded + USE_DIRECTX;WIN32;_XBOX;PPC;BIG_ENDIAN;NDEBUG;_XBOX;LTCG;_LIB + ../common;..;../native;../native/ext/glew; + core/x360_compat.h true @@ -313,56 +245,100 @@ true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true @@ -391,46 +367,82 @@ true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true true true true + true + true + true + true AssemblyAndSourceCode @@ -438,11 +450,19 @@ true true true + true + true + true + true true true true + true + true + true + true @@ -450,14 +470,6 @@ - - - {3fcdbae2-5103-4350-9a8e-848ce9c73195} - - - - - diff --git a/GPU/GPUXbox.vcxproj.filters b/GPU/GPUXbox.vcxproj.filters index 599b9e5e05..d6726e8a2d 100644 --- a/GPU/GPUXbox.vcxproj.filters +++ b/GPU/GPUXbox.vcxproj.filters @@ -208,7 +208,4 @@ Directx9\helper - - - \ No newline at end of file