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.

This commit is contained in:
Sacha 2012-11-26 13:25:14 +10:00
parent a1a72b3f21
commit 3c903dda24
29 changed files with 53 additions and 135 deletions

View File

@ -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)

View File

@ -25,7 +25,7 @@
#include <stdio.h>
#include <string.h>
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(ARM)
#define _M_ARM32
#endif

View File

@ -36,7 +36,8 @@ template<> struct CompileTimeAssert<true> {};
#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 <emmintrin.h>
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 ) ; }

View File

@ -33,7 +33,8 @@
#define INFINITE 0xffffffff
#endif
#if !defined(ANDROID) && !defined(BLACKBERRY)
// Assume !ARM = x86
#if !defined(ARM)
#include <xmmintrin.h>
#endif

View File

@ -21,7 +21,7 @@
#include <map>
#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

View File

@ -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

View File

@ -17,7 +17,7 @@
#pragma once
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(ARM)
#include "../ARM/Jit.h"
#else
#include "../x86/Jit.h"

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include "../../Core/MemMap.h"
#include "../../Core/Host.h"
#include "../../Core/Config.h"

View File

@ -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

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#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);

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <map>
#include "math/lin/matrix4x4.h"

View File

@ -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,
};
};

View File

@ -1,4 +1,4 @@
#if defined(ANDROID) || defined(BLACKBERRY)
#if defined(USING_GLES2)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#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[];
extern const GLuint ztests[];

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include <map>
#include "../../Core/MemMap.h"

View File

@ -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();
int TextureCache_NumLoadedTextures();

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#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

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include "math/lin/matrix4x4.h"
#include "../../Core/MemMap.h"
#include "../ge_constants.h"
#include "../GPUState.h"
#include "VertexDecoder.h"

View File

@ -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"

View File

@ -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");

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include "ge_constants.h"
#include "GPUState.h"
#include "GLES/ShaderManager.h"

View File

@ -16,6 +16,17 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#if defined(USING_GLES2)
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#else
#include <GL/glew.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#endif
#include "../Globals.h"
#include "ge_constants.h"

View File

@ -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 <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#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

View File

@ -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);