Skip to content
Permalink
Browse files

video: more porting

  • Loading branch information
fzurita committed Feb 7, 2016
1 parent 0d93424 commit a3206584d9a53ecb46d3dd1a7b19a81828b2fb77
Showing with 254 additions and 7,197 deletions.
  1. +7 −1 jni/mupen64plus-ui-console/src/plugin.c
  2. +0 −6 jni/mupen64plus-video-glide2gl.mk
  3. +1 −1 jni/mupen64plus-video-glide2gl/src/Glide64/Glide64_Ini.c
  4. +11 −6 jni/mupen64plus-video-glide2gl/src/Glide64/glide64_3dmath.c
  5. +6 −34 jni/mupen64plus-video-glide2gl/src/Glide64/glide64_rdp.c
  6. +37 −37 jni/mupen64plus-video-glide2gl/src/Glide64/glidemain.c
  7. +12 −8 jni/mupen64plus-video-glide2gl/src/Glitch64/geometry.c
  8. +5 −4 jni/mupen64plus-video-glide2gl/src/Glitch64/glitch64_combiner.c
  9. +4 −4 jni/mupen64plus-video-glide2gl/src/Glitch64/glitchmain.c
  10. +3 −0 jni/mupen64plus-video-glide2gl/src/Glitch64/glitchmain.h
  11. +0 −31 jni/mupen64plus-video-glide2gl/src/libretro/SDL.h
  12. 0 jni/mupen64plus-video-glide2gl/src/libretro/SDL_config.h
  13. +0 −9 jni/mupen64plus-video-glide2gl/src/libretro/SDL_mutex.h
  14. +0 −32 jni/mupen64plus-video-glide2gl/src/libretro/SDL_opengl.h
  15. +0 −32 jni/mupen64plus-video-glide2gl/src/libretro/SDL_opengles.h
  16. +0 −32 jni/mupen64plus-video-glide2gl/src/libretro/SDL_opengles2.h
  17. +5 −0 jni/mupen64plus-video-glide2gl/src/libretro/glext.h
  18. +0 −12 jni/mupen64plus-video-glide2gl/src/libretro/glsym/README.md
  19. +0 −139 jni/mupen64plus-video-glide2gl/src/libretro/glsym/glgen.py
  20. +0 −37 jni/mupen64plus-video-glide2gl/src/libretro/glsym/glsym.h
  21. +0 −87 jni/mupen64plus-video-glide2gl/src/libretro/glsym/glsym_es2.c
  22. +0 −145 jni/mupen64plus-video-glide2gl/src/libretro/glsym/glsym_es2.h
  23. +0 −2,083 jni/mupen64plus-video-glide2gl/src/libretro/glsym/glsym_gl.c
  24. +0 −3,140 jni/mupen64plus-video-glide2gl/src/libretro/glsym/glsym_gl.h
  25. +0 −43 jni/mupen64plus-video-glide2gl/src/libretro/glsym/rglgen.c
  26. +0 −49 jni/mupen64plus-video-glide2gl/src/libretro/glsym/rglgen.h
  27. +0 −132 jni/mupen64plus-video-glide2gl/src/libretro/glsym/rglgen.py
  28. +0 −80 jni/mupen64plus-video-glide2gl/src/libretro/glsym/rglgen_headers.h
  29. +161 −71 jni/mupen64plus-video-glide2gl/src/libretro/libretro.c
  30. +0 −738 jni/mupen64plus-video-glide2gl/src/libretro/opengl_state_machine.c
  31. +0 −203 jni/mupen64plus-video-glide2gl/src/libretro/opengl_state_machine.h
  32. +0 −1 src/paulscode/android/mupen64plusae/input/map/PlayerMap.java
  33. +2 −0 src/paulscode/android/mupen64plusae/jni/NativeConfigFiles.java
@@ -58,6 +58,8 @@ static m64p_error PluginLoadTry(const char *filepath, int MapIndex)
ptr_PluginGetVersion PluginGetVersion = (ptr_PluginGetVersion) osal_dynlib_getproc(handle, "PluginGetVersion");
if (PluginGetVersion == NULL)
{
DebugMessage(M64MSG_ERROR,"library '%s' is not a Mupen64Plus library.", filepath);

if (g_Verbose)
DebugMessage(M64MSG_ERROR, "library '%s' is not a Mupen64Plus library.", filepath);
osal_dynlib_close(handle);
@@ -182,13 +184,17 @@ m64p_error PluginSearchLoad(m64p_handle ConfigUI)
}
else /* otherwise search for a plugin specified in the config file */
{
DebugMessage(M64MSG_ERROR, "Searching for plugin in config file");

const char *config_path = (*ConfigGetParamString)(ConfigUI, config_var);
if (config_path != NULL && strlen(config_path) > 0)
{
/* if full path was given, try loading exactly this file */
if (strchr(config_path, OSAL_DIR_SEPARATOR) != NULL)
{
PluginLoadTry(config_path, i);
int lnReturn = PluginLoadTry(config_path, i);

DebugMessage(M64MSG_ERROR, "Trying this plugin: %s, return=%i", config_path, lnReturn);
}
else if (strcmp(config_path, "dummy") == 0)
{
@@ -37,14 +37,8 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/Glide64/TexCache.c \
$(SRCDIR)/Glide64/TexLoad.c \
$(SRCDIR)/libretro/gdp.c \
$(SRCDIR)/libretro/opengl_state_machine.c \
$(SRCDIR)/libretro/libretro.c \
$(SRCDIR)/libretro/libretro_crc.c \
$(SRCDIR)/libretro/glsym/rglgen.c \
$(SRCDIR)/libretro/glsym/glsym_es2.c \




LOCAL_CFLAGS := \
$(COMMON_CFLAGS) \
@@ -5,7 +5,7 @@
#include "DepthBufferRender.h"

#include "libretro/libretro.h"
#include "libretro/SDL.h"
#include <SDL.h>

extern bool no_audio;
extern uint8_t microcode[4096];
@@ -38,10 +38,15 @@
//****************************************************************

#include "Gfx_1.3.h"
#include "libretro/SDL.h"
#include <SDL.h>

#include <math.h>
#include "3dmath.h"
#include "libretro/libretro.h"

extern retro_log_printf_t log_cb;
extern retro_get_cpu_features_t perf_get_cpu_features_cb;


float DotProductC(float *v0, float *v1)
{
@@ -208,17 +213,17 @@ void math_init(void)
{
unsigned cpu = 0;

//if (perf_get_cpu_features_cb)
// cpu = perf_get_cpu_features_cb();
if (perf_get_cpu_features_cb)
cpu = perf_get_cpu_features_cb();

#if defined(__ARM_NEON__)
if (/*cpu & */RETRO_SIMD_NEON)
//if (cpu & RETRO_SIMD_NEON)
{
glide64NormalizeVector = NormalizeVectorNeon;
glide64MulMatrices = MulMatricesNeon;
glide64DotProduct = DotProductNeon;
//if (log_cb)
// log_cb(RETRO_LOG_INFO, "NEON detected, using (some) optimized math functions.\n");
if (log_cb)
log_cb(RETRO_LOG_INFO, "NEON detected, using (some) optimized math functions.\n");
}
#endif
}
@@ -47,38 +47,10 @@
#include "CRC.h"
#include "GBI.h"
#include "Glide64_UCode.h"
#include "libretro/SDL.h"

#ifdef __LIBRETRO__ // Prefix API
#define VIDEO_TAG(X) glide64##X

#define ReadScreen2 VIDEO_TAG(ReadScreen2)
#define PluginStartup VIDEO_TAG(PluginStartup)
#define PluginShutdown VIDEO_TAG(PluginShutdown)
#define PluginGetVersion VIDEO_TAG(PluginGetVersion)
#define CaptureScreen VIDEO_TAG(CaptureScreen)
#define ChangeWindow VIDEO_TAG(ChangeWindow)
#define CloseDLL VIDEO_TAG(CloseDLL)
#define DllTest VIDEO_TAG(DllTest)
#define DrawScreen VIDEO_TAG(DrawScreen)
#define GetDllInfo VIDEO_TAG(GetDllInfo)
#define InitiateGFX VIDEO_TAG(InitiateGFX)
#define MoveScreen VIDEO_TAG(MoveScreen)
#define RomClosed VIDEO_TAG(RomClosed)
#define RomOpen VIDEO_TAG(RomOpen)
#define ShowCFB VIDEO_TAG(ShowCFB)
#define SetRenderingCallback VIDEO_TAG(SetRenderingCallback)
#define UpdateScreen VIDEO_TAG(UpdateScreen)
#define ViStatusChanged VIDEO_TAG(ViStatusChanged)
#define ViWidthChanged VIDEO_TAG(ViWidthChanged)
#define ReadScreen VIDEO_TAG(ReadScreen)
#define FBGetFrameBufferInfo VIDEO_TAG(FBGetFrameBufferInfo)
#define FBRead VIDEO_TAG(FBRead)
#define FBWrite VIDEO_TAG(FBWrite)
#define ProcessDList VIDEO_TAG(ProcessDList)
#define ProcessRDPList VIDEO_TAG(ProcessRDPList)
#define ResizeVideoOutput VIDEO_TAG(ResizeVideoOutput)
#endif
#include <SDL.h>
#include "libretro/libretro.h"

extern retro_log_printf_t log_cb;

//angrylion's macro, helps to cut overflowed values.
#define SIGN16(x) (int16_t)(x)
@@ -236,8 +208,8 @@ void rdp_setfuncs(void)
{
if (settings.hacks & hack_Makers)
{
//if (log_cb)
// log_cb(RETRO_LOG_INFO, "Applying Mischief Makers function pointer table tweak...\n");
if (log_cb)
log_cb(RETRO_LOG_INFO, "Applying Mischief Makers function pointer table tweak...\n");
gfx_instruction[0][191] = uc0_tri1_mischief;
}
}
@@ -47,10 +47,11 @@
#include "DepthBufferRender.h"
#include "Glide64_Ini.h"
#include "libretro/libretro.h"
#include <android/log.h>
#include "m64p.h"

extern void CRC_BuildTable();
extern uint32_t screen_aspectmodehint;
extern retro_log_printf_t log_cb;

#if defined(__GNUC__)
#include <sys/time.h>
@@ -62,38 +63,6 @@ extern uint32_t screen_aspectmodehint;
#define G64_VERSION "G64 Mk2"
#define RELTIME "Date: " __DATE__// " Time: " __TIME__

#ifdef __LIBRETRO__ // Prefix API
#define VIDEO_TAG(X) glide64##X

#define ReadScreen2 VIDEO_TAG(ReadScreen2)
#define PluginStartup VIDEO_TAG(PluginStartup)
#define PluginShutdown VIDEO_TAG(PluginShutdown)
#define PluginGetVersion VIDEO_TAG(PluginGetVersion)
#define CaptureScreen VIDEO_TAG(CaptureScreen)
#define ChangeWindow VIDEO_TAG(ChangeWindow)
#define CloseDLL VIDEO_TAG(CloseDLL)
#define DllTest VIDEO_TAG(DllTest)
#define DrawScreen VIDEO_TAG(DrawScreen)
#define GetDllInfo VIDEO_TAG(GetDllInfo)
#define InitiateGFX VIDEO_TAG(InitiateGFX)
#define MoveScreen VIDEO_TAG(MoveScreen)
#define RomClosed VIDEO_TAG(RomClosed)
#define RomOpen VIDEO_TAG(RomOpen)
#define ShowCFB VIDEO_TAG(ShowCFB)
#define SetRenderingCallback VIDEO_TAG(SetRenderingCallback)
#define UpdateScreen VIDEO_TAG(UpdateScreen)
#define ViStatusChanged VIDEO_TAG(ViStatusChanged)
#define ViWidthChanged VIDEO_TAG(ViWidthChanged)
#define ReadScreen VIDEO_TAG(ReadScreen)
#define FBGetFrameBufferInfo VIDEO_TAG(FBGetFrameBufferInfo)
#define FBRead VIDEO_TAG(FBRead)
#define FBWrite VIDEO_TAG(FBWrite)
#define ProcessDList VIDEO_TAG(ProcessDList)
#define ProcessRDPList VIDEO_TAG(ProcessRDPList)
#define ResizeVideoOutput VIDEO_TAG(ResizeVideoOutput)
#define InitGfx VIDEO_TAG(InitGfx)
#endif

void (*_gSPVertex)(uint32_t addr, uint32_t n, uint32_t v0);

GFX_INFO gfx_info;
@@ -363,9 +332,40 @@ EXPORT void CALL ReadScreen2(void *dest, int *width, int *height, int front)
}
}

/* definitions of pointers to Core video extension functions */
ptr_VidExt_Init CoreVideo_Init = NULL;
ptr_VidExt_Quit CoreVideo_Quit = NULL;
ptr_VidExt_ListFullscreenModes CoreVideo_ListFullscreenModes = NULL;
ptr_VidExt_SetVideoMode CoreVideo_SetVideoMode = NULL;
ptr_VidExt_SetCaption CoreVideo_SetCaption = NULL;
ptr_VidExt_ToggleFullScreen CoreVideo_ToggleFullScreen = NULL;
ptr_VidExt_ResizeWindow CoreVideo_ResizeWindow = NULL;
ptr_VidExt_GL_GetProcAddress CoreVideo_GL_GetProcAddress = NULL;
ptr_VidExt_GL_SetAttribute CoreVideo_GL_SetAttribute = NULL;
ptr_VidExt_GL_GetAttribute CoreVideo_GL_GetAttribute = NULL;
ptr_VidExt_GL_SwapBuffers CoreVideo_GL_SwapBuffers = NULL;

void(*renderCallback)(int) = NULL;

EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
void (*DebugCallback)(void *, int, const char *))
{
/* Get the core Video Extension function pointers from the library handle */
CoreVideo_Init = (ptr_VidExt_Init) dlsym(CoreLibHandle, "VidExt_Init");
CoreVideo_Quit = (ptr_VidExt_Quit) dlsym(CoreLibHandle, "VidExt_Quit");
CoreVideo_ListFullscreenModes = (ptr_VidExt_ListFullscreenModes) dlsym(CoreLibHandle, "VidExt_ListFullscreenModes");
CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) dlsym(CoreLibHandle, "VidExt_SetVideoMode");
CoreVideo_SetCaption = (ptr_VidExt_SetCaption) dlsym(CoreLibHandle, "VidExt_SetCaption");
CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) dlsym(CoreLibHandle, "VidExt_ToggleFullScreen");
CoreVideo_ResizeWindow = (ptr_VidExt_ResizeWindow) dlsym(CoreLibHandle, "VidExt_ResizeWindow");
CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) dlsym(CoreLibHandle, "VidExt_GL_GetProcAddress");
CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) dlsym(CoreLibHandle, "VidExt_GL_SetAttribute");
CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) dlsym(CoreLibHandle, "VidExt_GL_GetAttribute");
CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) dlsym(CoreLibHandle, "VidExt_GL_SwapBuffers");


retro_init();

l_DebugCallback = DebugCallback;
l_DebugCallContext = Context;

@@ -548,8 +548,8 @@ static void CheckDRAMSize(void)
else
BMASK = 0x3FFFFF;


__android_log_print(ANDROID_LOG_ERROR, "glide2gl","Detected RDRAM size: %08lx\n", BMASK);
if (log_cb)
log_cb(RETRO_LOG_INFO, "Detected RDRAM size: %08lx\n", BMASK);
}

/******************************************************************
@@ -736,8 +736,8 @@ EXPORT void CALL UpdateScreen (void)
if (settings.swapmode == 0 || forced_update)
newSwapBuffers ();

if (settings.swapmode_retro && BUFFERSWAP)
retro_return(true);
//if (settings.swapmode_retro && BUFFERSWAP)
// retro_return(true);
}

static void DrawWholeFrameBufferToScreen(void)
@@ -23,8 +23,8 @@
#include <stddef.h>
#include "glide.h"
#include "glitchmain.h"
#include "libretro/libretro.h"
#include "../Glide64/rdp.h"
#include <android/log.h>

/* TODO: get rid of glitch_vbo */
/* TODO: try glDrawElements */
@@ -59,7 +59,8 @@ static GLuint vbuf_vbo = 0;
static size_t vbuf_vbo_size = 0;
static bool vbuf_drawing = false;

//extern retro_environment_t environ_cb;
extern retro_environment_t environ_cb;
extern retro_log_printf_t log_cb;

#ifdef EMSCRIPTEN
static struct draw_buffer *gli_vbo;
@@ -71,25 +72,25 @@ void vbo_init(void)
#ifdef EMSCRIPTEN
struct retro_variable var = { "mupen64-vcache-vbo", "on" };
#else
//struct retro_variable var = { "mupen64-vcache-vbo", 0 };
struct retro_variable var = { "mupen64-vcache-vbo", 0 };
#endif
vbuf_use_vbo = true;
vbuf_length = 0;

/*if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
vbuf_use_vbo = (strcmp(var.value, "on") == 0);*/
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
vbuf_use_vbo = (strcmp(var.value, "on") == 0);

if (vbuf_use_vbo)
{
glGenBuffers(1, &vbuf_vbo);

if (!vbuf_vbo)
{
__android_log_print(ANDROID_LOG_ERROR, "glide2gl", "Failed to create the VBO.\n");
log_cb(RETRO_LOG_ERROR, "Failed to create the VBO.");
vbuf_use_vbo = false;
}
else
__android_log_print(ANDROID_LOG_ERROR, "glide2gl", "Vertex cache VBO enabled.\n");
log_cb(RETRO_LOG_INFO, "Vertex cache VBO enabled.\n");
}
}

@@ -127,7 +128,7 @@ void vbo_buffer_data(void *data, size_t size)
glBufferData(GL_ARRAY_BUFFER, size, data, GL_DYNAMIC_DRAW);

if (size > VERTEX_BUFFER_SIZE)
__android_log_print(ANDROID_LOG_INFO, "glide2gl", "Extending vertex cache VBO.\n");
log_cb(RETRO_LOG_INFO, "Extending vertex cache VBO.\n");

vbuf_vbo_size = size;
}
@@ -267,6 +268,9 @@ void FindBestDepthBias(void)

renderer = (const char*)glGetString(GL_RENDERER);

if (log_cb)
log_cb(RETRO_LOG_INFO, "GL_RENDERER: %s\n", renderer);

biasFound = true;
#else
#if 0
@@ -28,8 +28,7 @@
#include <math.h>
#include "glide.h"
#include "glitchmain.h"
#include "SDL.h"
#include <android/log.h>
#include <SDL.h>

float glide64_pow(float a, float b);

@@ -266,7 +265,8 @@ void check_compile(GLuint shader)
{
char log[1024];
glGetShaderInfoLog(shader,1024,NULL,log);
__android_log_print(ANDROID_LOG_ERROR, "glide2gl", "%s", log);
if (log_cb)
log_cb(RETRO_LOG_ERROR, log);
}
}

@@ -279,7 +279,8 @@ void check_link(GLuint program)
{
char log[1024];
glGetProgramInfoLog(program,1024,NULL,log);
__android_log_print(ANDROID_LOG_ERROR, "glide2gl", "%s", log);
if (log_cb)
log_cb(RETRO_LOG_ERROR, log);
}
}

@@ -27,7 +27,7 @@
#include "glide.h"
#include "glitchmain.h"
#include "../Glide64/rdp.h"
#include "../libretro/SDL.h"
#include "SDL.h"

extern retro_environment_t environ_cb;

@@ -337,8 +337,8 @@ grLfbWriteRegion( int32_t dst_buffer,
void grBufferSwap(uint32_t swap_interval)
{
bool swapmode = settings.swapmode_retro && BUFFERSWAP;
if (!swapmode)
retro_return(true);
//if (!swapmode)
// retro_return(true);
}

void grClipWindow(uint32_t minx, uint32_t miny, uint32_t maxx, uint32_t maxy)
@@ -353,7 +353,7 @@ void grBufferClear(uint32_t color, uint32_t alpha, uint32_t depth)
((color >> 16) & 0xFF) / 255.0f,
(color & 0xFF) / 255.0f,
alpha / 255.0f);
glClearDepth(depth / 65535.0f);
glClearDepthf(depth / 65535.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

0 comments on commit a320658

Please sign in to comment.
You can’t perform that action at this time.