From 3c903dda240395006fbc0fa5604ade40a708384d Mon Sep 17 00:00:00 2001 From: Sacha Date: Mon, 26 Nov 2012 13:25:14 +1000 Subject: [PATCH] Improve portability to future platforms. Make use of new USING_GLES2 define throughout PPSSPP. Also use ARM definition where suitable. Remove some redundancy with includes. --- CMakeLists.txt | 9 +++++---- Common/Common.h | 2 +- Common/CommonFuncs.h | 6 ++++-- Common/Thread.h | 3 ++- Common/Thunk.h | 4 ++-- Core/MIPS/ARM/Jit.h | 4 ++-- Core/MIPS/JitCommon/JitCommon.h | 2 +- Core/MIPS/MIPS.cpp | 2 +- Core/MIPS/MIPSDis.cpp | 6 +----- Core/MIPS/MIPSInt.cpp | 2 +- Core/MIPS/MIPSTables.cpp | 5 ----- Core/MIPS/x86/Jit.h | 4 ++-- Core/System.cpp | 6 +----- GPU/GLES/DisplayListInterpreter.cpp | 13 ------------- GPU/GLES/FragmentShaderGenerator.cpp | 2 +- GPU/GLES/Framebuffer.cpp | 14 +------------- GPU/GLES/ShaderManager.cpp | 12 ------------ GPU/GLES/StateMapping.cpp | 4 ++-- GPU/GLES/StateMapping.h | 4 ++-- GPU/GLES/TextureCache.cpp | 12 ------------ GPU/GLES/TextureCache.h | 3 ++- GPU/GLES/TransformPipeline.cpp | 16 ++-------------- GPU/GLES/VertexDecoder.cpp | 13 ------------- GPU/GLES/VertexDecoder.h | 2 ++ GPU/GLES/VertexShaderGenerator.cpp | 2 +- GPU/GPUState.cpp | 12 ------------ GPU/GPUState.h | 11 +++++++++++ GPU/Null/NullDisplayListInterpreter.cpp | 4 ++-- android/jni/EmuScreen.cpp | 9 ++++----- 29 files changed, 53 insertions(+), 135 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bcf2f5053..b4393d18e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,9 +34,9 @@ option(HEADLESS "Set to OFF to not generate the PPSSPPHeadless target" ${HEADLES if(ANDROID) if(NOT ANDROID_ABI) message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE was not set!\n" - "Delete the CMakeCache.txt file and CMakeFiles directory." - "Rerun ${CMAKE_COMMAND} with \"-DCMAKE_TOOLCHAIN_FILE" - "=${CMAKE_SOURCE_DIR}/android/android.toolchain.cmake\"") + "Delete the CMakeCache.txt file and CMakeFiles directory." + "Rerun ${CMAKE_COMMAND} with \"-DCMAKE_TOOLCHAIN_FILE" + "=${CMAKE_SOURCE_DIR}/android/android.toolchain.cmake\"") endif() set(CoreLibName ppsspp_jni) set(CoreLinkType SHARED) @@ -76,8 +76,9 @@ if (USING_GLES2) endif() if(NOT MSVC) - # Disable warnings about va_list mangling + # Disable some warnings add_definitions(-Wno-psabi) + add_definitions(-Wno-multichar) add_definitions(-fno-strict-aliasing) if(NOT APPLE) add_definitions(-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1) diff --git a/Common/Common.h b/Common/Common.h index 696a6bbcc2..bd1dd334b9 100644 --- a/Common/Common.h +++ b/Common/Common.h @@ -25,7 +25,7 @@ #include #include -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(ARM) #define _M_ARM32 #endif diff --git a/Common/CommonFuncs.h b/Common/CommonFuncs.h index 832256a083..ce47931175 100644 --- a/Common/CommonFuncs.h +++ b/Common/CommonFuncs.h @@ -36,7 +36,8 @@ template<> struct CompileTimeAssert {}; #define ROUND_UP_POW2(x) (b32(x - 1) + 1) #if defined __GNUC__ && !defined __SSSE3__ -#if !defined(ANDROID) && !defined(BLACKBERRY) +// Assume !ARM = x86 +#if !defined(ARM) #include static __inline __m128i __attribute__((__always_inline__)) _mm_shuffle_epi8(__m128i a, __m128i mask) @@ -63,7 +64,8 @@ _mm_shuffle_epi8(__m128i a, __m128i mask) #ifdef GEKKO #define Crash() #else -#if !defined(ANDROID) && !defined(BLACKBERRY) +// Assume !ARM = x86 +#if !defined(ARM) #define Crash() {asm ("int $3");} #else #define Crash() {kill( getpid(), SIGINT ) ; } diff --git a/Common/Thread.h b/Common/Thread.h index 65395db065..76251acd31 100644 --- a/Common/Thread.h +++ b/Common/Thread.h @@ -33,7 +33,8 @@ #define INFINITE 0xffffffff #endif -#if !defined(ANDROID) && !defined(BLACKBERRY) +// Assume !ARM = x86 +#if !defined(ARM) #include #endif diff --git a/Common/Thunk.h b/Common/Thunk.h index 66fe703943..f841897bd6 100644 --- a/Common/Thunk.h +++ b/Common/Thunk.h @@ -21,7 +21,7 @@ #include #include "Common.h" -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(ARM) #include "ArmEmitter.h" #else #include "x64Emitter.h" @@ -38,7 +38,7 @@ // we don't want to pollute the stack, so we store away regs somewhere global. // NOT THREAD SAFE. This may only be used from the CPU thread. // Any other thread using this stuff will be FATAL. -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(ARM) class ThunkManager : public ArmGen::ARMXCodeBlock #else class ThunkManager : public Gen::XCodeBlock diff --git a/Core/MIPS/ARM/Jit.h b/Core/MIPS/ARM/Jit.h index fe81735e41..d3c9cade66 100644 --- a/Core/MIPS/ARM/Jit.h +++ b/Core/MIPS/ARM/Jit.h @@ -20,8 +20,8 @@ #include "../../../Globals.h" #include "Asm.h" -#if !defined(ANDROID) && !defined(BLACKBERRY) -#error DO NOT BUILD ARM JIT ON x86 +#if !defined(ARM) +#error DO NOT BUILD ARM JIT ON NON-ARM #endif diff --git a/Core/MIPS/JitCommon/JitCommon.h b/Core/MIPS/JitCommon/JitCommon.h index 81834be6f2..a7b4673484 100644 --- a/Core/MIPS/JitCommon/JitCommon.h +++ b/Core/MIPS/JitCommon/JitCommon.h @@ -17,7 +17,7 @@ #pragma once -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(ARM) #include "../ARM/Jit.h" #else #include "../x86/Jit.h" diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 4ec868aed9..73dc9e129b 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -23,7 +23,7 @@ #include "../System.h" #include "../HLE/sceDisplay.h" -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(ARM) #include "ARM/JitCache.h" #include "ARM/Jit.h" #else diff --git a/Core/MIPS/MIPSDis.cpp b/Core/MIPS/MIPSDis.cpp index 33a585d570..d4437ec347 100644 --- a/Core/MIPS/MIPSDis.cpp +++ b/Core/MIPS/MIPSDis.cpp @@ -21,11 +21,7 @@ #include "MIPSTables.h" #include "MIPSDebugInterface.h" -#if defined(ANDROID) || defined(BLACKBERRY) -#include "ARM/Jit.h" -#else -#include "x86/Jit.h" -#endif +#include "JitCommon/JitCommon.h" #define _RS ((op>>21) & 0x1F) #define _RT ((op>>16) & 0x1F) diff --git a/Core/MIPS/MIPSInt.cpp b/Core/MIPS/MIPSInt.cpp index 9f42a31fa2..b0437faf95 100644 --- a/Core/MIPS/MIPSInt.cpp +++ b/Core/MIPS/MIPSInt.cpp @@ -75,7 +75,7 @@ static inline void DelayBranchTo(u32 where) int MIPS_SingleStep() { -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(ARM) u32 op = Memory::ReadUnchecked_U32(mipsr4k.pc); #else u32 op = Memory::Read_Opcode_JIT(mipsr4k.pc); diff --git a/Core/MIPS/MIPSTables.cpp b/Core/MIPS/MIPSTables.cpp index 9b117e023f..758856ca27 100644 --- a/Core/MIPS/MIPSTables.cpp +++ b/Core/MIPS/MIPSTables.cpp @@ -26,11 +26,6 @@ #include "../../Core/CoreTiming.h" #include "../Debugger/Breakpoints.h" -#if defined(ANDROID) || defined(BLACKBERRY) -#include "ARM/Jit.h" -#else -#include "x86/Jit.h" -#endif #include "JitCommon/JitCommon.h" enum MipsEncoding diff --git a/Core/MIPS/x86/Jit.h b/Core/MIPS/x86/Jit.h index eac06d027c..23abe06467 100644 --- a/Core/MIPS/x86/Jit.h +++ b/Core/MIPS/x86/Jit.h @@ -20,8 +20,8 @@ #include "../../../Globals.h" #include "Asm.h" -#if defined(ANDROID) || defined(BLACKBERRY) -#error DO NOT BUILD X86 JIT ON ANDROID +#if defined(ARM) +#error DO NOT BUILD X86 JIT ON ARM #endif #include "x64Emitter.h" diff --git a/Core/System.cpp b/Core/System.cpp index 0a6f1c8f9c..d5b6522a28 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -19,11 +19,7 @@ #include "MIPS/MIPS.h" -#if defined(ANDROID) || defined(BLACKBERRY) -#include "MIPS/ARM/Jit.h" -#else -#include "MIPS/x86/Jit.h" -#endif +#include "MIPS/JitCommon/JitCommon.h" #include "System.h" // Bad dependency diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index db402a6393..64d0ce8d99 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -15,19 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) -#include -#include -#else -#include -#if defined(__APPLE__) -#include -#else -#include -#endif -#endif - - #include "../../Core/MemMap.h" #include "../../Core/Host.h" #include "../../Core/Config.h" diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index f304e4e39b..7b4bca105a 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -15,7 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) #define GLSL_ES_1_0 #else #define GLSL_1_3 diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index a66a87f885..b4e52ec029 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -15,18 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) -#include -#include -#else -#include -#if defined(__APPLE__) -#include -#else -#include -#endif -#endif - #include "gfx_es2/glsl_program.h" #include "gfx_es2/gl_state.h" #include "math/lin/matrix4x4.h" @@ -73,7 +61,7 @@ const char basic_vs[] = void DisplayDrawer_Init() { -#if !defined(ANDROID) && !defined(BLACKBERRY) +#if !defined(USING_GLES2) // Old OpenGL stuff that probably has no effect glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); //GL_FILL); diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index 020e176596..01a0917bdf 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -15,18 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) -#include -#include -#else -#include -#if defined(__APPLE__) -#include -#else -#include -#endif -#endif - #include #include "math/lin/matrix4x4.h" diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 0734c77fba..dd4b58b6f2 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -31,7 +31,7 @@ const GLint eqLookup[] = { GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) GL_FUNC_ADD, GL_FUNC_ADD, #else @@ -50,4 +50,4 @@ const GLuint ztests[] = { GL_NEVER, GL_ALWAYS, GL_EQUAL, GL_NOTEQUAL, GL_LESS, GL_LEQUAL, GL_GREATER, GL_GEQUAL, -}; \ No newline at end of file +}; diff --git a/GPU/GLES/StateMapping.h b/GPU/GLES/StateMapping.h index 39977d7d8c..3d4fc4bcca 100644 --- a/GPU/GLES/StateMapping.h +++ b/GPU/GLES/StateMapping.h @@ -1,4 +1,4 @@ -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) #include #include #else @@ -14,4 +14,4 @@ extern const GLint aLookup[]; extern const GLint bLookup[]; extern const GLint eqLookup[]; extern const GLint cullingMode[]; -extern const GLuint ztests[]; \ No newline at end of file +extern const GLuint ztests[]; diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index e9e2720e8d..fe6fa45d29 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -15,18 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) -#include -#include -#else -#include -#if defined(__APPLE__) -#include -#else -#include -#endif -#endif - #include #include "../../Core/MemMap.h" diff --git a/GPU/GLES/TextureCache.h b/GPU/GLES/TextureCache.h index 97c2cb9bda..199798fdbd 100644 --- a/GPU/GLES/TextureCache.h +++ b/GPU/GLES/TextureCache.h @@ -16,10 +16,11 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #pragma once + #include "../Globals.h" void PSPSetTexture(); void TextureCache_Clear(bool delete_them); void TextureCache_Decimate(); // Run this once per frame to get rid of old textures. -int TextureCache_NumLoadedTextures(); \ No newline at end of file +int TextureCache_NumLoadedTextures(); diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index 1a5bf8997a..fc9a38f3bb 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -15,18 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) -#include -#include -#else -#include -#if defined(__APPLE__) -#include -#else -#include -#endif -#endif - #include "../../Core/MemMap.h" #include "../../Core/Host.h" #include "../../Core/System.h" @@ -248,9 +236,9 @@ void TransformAndDrawPrim(void *verts, void *inds, int prim, int vertexCount, Li // TODO: Could use glDrawElements in some cases, see below. - // TODO: Split up into multiple draw calls for Android where you can't guarantee support for more than 0x10000 verts. + // TODO: Split up into multiple draw calls for GLES 2.0 where you can't guarantee support for more than 0x10000 verts. -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) if (vertexCount > 0x10000/3) vertexCount = 0x10000/3; #endif diff --git a/GPU/GLES/VertexDecoder.cpp b/GPU/GLES/VertexDecoder.cpp index 380567b1f5..7e2a0e30db 100644 --- a/GPU/GLES/VertexDecoder.cpp +++ b/GPU/GLES/VertexDecoder.cpp @@ -15,23 +15,10 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) -#include -#include -#else -#include -#if defined(__APPLE__) -#include -#else -#include -#endif -#endif - #include "math/lin/matrix4x4.h" #include "../../Core/MemMap.h" #include "../ge_constants.h" -#include "../GPUState.h" #include "VertexDecoder.h" diff --git a/GPU/GLES/VertexDecoder.h b/GPU/GLES/VertexDecoder.h index e0d256c515..f3f7c8280b 100644 --- a/GPU/GLES/VertexDecoder.h +++ b/GPU/GLES/VertexDecoder.h @@ -16,6 +16,8 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #pragma once + +#include "../GPUState.h" #include "../Globals.h" #include "base/basictypes.h" diff --git a/GPU/GLES/VertexShaderGenerator.cpp b/GPU/GLES/VertexShaderGenerator.cpp index d48536f6a6..e95aae3a52 100644 --- a/GPU/GLES/VertexShaderGenerator.cpp +++ b/GPU/GLES/VertexShaderGenerator.cpp @@ -53,7 +53,7 @@ void WriteLight(char *p, int l) { char *GenerateVertexShader() { char *p = buffer; -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) WRITE("precision highp float;"); #elif !defined(FORCE_OPENGL_2_0) WRITE("#version 130"); diff --git a/GPU/GPUState.cpp b/GPU/GPUState.cpp index 71ea830d28..ff4e868b27 100644 --- a/GPU/GPUState.cpp +++ b/GPU/GPUState.cpp @@ -15,18 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) -#include -#include -#else -#include -#if defined(__APPLE__) -#include -#else -#include -#endif -#endif - #include "ge_constants.h" #include "GPUState.h" #include "GLES/ShaderManager.h" diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 481515d910..b85f6ac633 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -16,6 +16,17 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #pragma once +#if defined(USING_GLES2) +#include +#include +#else +#include +#if defined(__APPLE__) +#include +#else +#include +#endif +#endif #include "../Globals.h" #include "ge_constants.h" diff --git a/GPU/Null/NullDisplayListInterpreter.cpp b/GPU/Null/NullDisplayListInterpreter.cpp index fa8bead636..bd15ea9896 100644 --- a/GPU/Null/NullDisplayListInterpreter.cpp +++ b/GPU/Null/NullDisplayListInterpreter.cpp @@ -15,7 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) #include #include #else @@ -224,7 +224,7 @@ void SetBlendModePSP(u32 data) GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) GL_FUNC_ADD, GL_FUNC_ADD, #else diff --git a/android/jni/EmuScreen.cpp b/android/jni/EmuScreen.cpp index 617d2a15d8..23a1dd541a 100644 --- a/android/jni/EmuScreen.cpp +++ b/android/jni/EmuScreen.cpp @@ -49,7 +49,7 @@ EmuScreen::EmuScreen(const std::string &filename) : invalid_(true) CoreParameter coreParam; coreParam.cpuCore = (CPUCore)g_Config.iCpuCore; -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(ARM) if (coreParam.cpuCore == CPU_JIT) coreParam.cpuCore = CPU_FASTINTERPRETER; #endif @@ -185,10 +185,9 @@ void EmuScreen::render() ui_draw2d.Begin(DBMODE_NORMAL); - // Don't want the gamepad on MacOSX and Linux -// #ifdef ANDROID + // Make this configurable. +// if (coreParam.useTouchControls) DrawGamepad(ui_draw2d); -// #endif DrawWatermark(); @@ -198,7 +197,7 @@ void EmuScreen::render() // Tiled renderers like PowerVR should benefit greatly from this. However - seems I can't call it? -#if defined(ANDROID) || defined(BLACKBERRY) +#if defined(USING_GLES2) bool hasDiscard = false; // TODO if (hasDiscard) { //glDiscardFramebuffer(GL_COLOR_EXT | GL_DEPTH_EXT | GL_STENCIL_EXT);