From 69e482e3def6669a4fa921d07f9ba04883d7de34 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 30 Jan 2013 03:55:15 +0200 Subject: frontend: change how exit is done will no longer be done from recompiler callback that could cause still used data to be freed --- frontend/libpicofe | 2 +- frontend/main.c | 38 +++++++++++++++++++++----------------- frontend/main.h | 12 +++++++----- frontend/menu.c | 7 +++---- frontend/plat_sdl.c | 6 ++++++ frontend/plugin_lib.c | 2 +- 6 files changed, 39 insertions(+), 28 deletions(-) diff --git a/frontend/libpicofe b/frontend/libpicofe index 215e7ed..63f173a 160000 --- a/frontend/libpicofe +++ b/frontend/libpicofe @@ -1 +1 @@ -Subproject commit 215e7ed2510e191664b611a578ffb987cf4fdab3 +Subproject commit 63f173a2509a27f9ae156ad6ee798d76dec0ad6b diff --git a/frontend/main.c b/frontend/main.c index 0f0e641..df2af8f 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -50,7 +50,7 @@ extern int iUseInterpolation; extern int iXAPitch; extern int iVolume; -int ready_to_go, g_resetting; +int ready_to_go, g_emu_want_quit, g_emu_resetting; unsigned long gpuDisp; char cfgfile_basename[MAXPATHLEN]; int state_slot; @@ -437,6 +437,12 @@ int emu_core_init(void) return 0; } +void emu_core_ask_exit(void) +{ + stop = 1; + g_emu_want_quit = 1; +} + #ifndef NO_FRONTEND static void create_profile_dir(const char *directory) { char path[MAXPATHLEN]; @@ -622,7 +628,7 @@ int main(int argc, char *argv[]) pl_start_watchdog(); - while (1) + while (!g_emu_want_quit) { stop = 0; emu_action = SACTION_NONE; @@ -632,6 +638,12 @@ int main(int argc, char *argv[]) do_emu_action(); } + printf("Exit..\n"); + ClosePlugins(); + SysClose(); + menu_finish(); + plat_finish(); + return 0; } @@ -684,7 +696,7 @@ void SysReset() { // so we need to prevent updateLace() call.. void *real_lace = GPU_updateLace; GPU_updateLace = dummy_lace; - g_resetting = 1; + g_emu_resetting = 1; // reset can run code, timing must be set pl_timing_prepare(Config.PsxType); @@ -695,7 +707,7 @@ void SysReset() { CDR_stop(); GPU_updateLace = real_lace; - g_resetting = 0; + g_emu_resetting = 0; } void SysClose() { @@ -704,22 +716,15 @@ void SysClose() { StopDebugger(); - if (emuLog != NULL) fclose(emuLog); + if (emuLog != NULL && emuLog != stdout && emuLog != stderr) { + fclose(emuLog); + emuLog = NULL; + } } void SysUpdate() { } -void OnFile_Exit() { - printf("OnFile_Exit\n"); - SysClose(); -#ifndef NO_FRONTEND - menu_finish(); - plat_finish(); - exit(0); -#endif -} - int get_state_filename(char *buf, int size, int i) { return get_gameid_filename(buf, size, "." STATES_DIR "%.32s-%.9s.%3.3d", i); @@ -809,8 +814,7 @@ void SysMessage(const char *fmt, ...) { } static void SignalExit(int sig) { - ClosePlugins(); - OnFile_Exit(); + emu_core_ask_exit(); } #define PARSEPATH(dst, src) \ diff --git a/frontend/main.h b/frontend/main.h index d971890..7ce9e5d 100644 --- a/frontend/main.h +++ b/frontend/main.h @@ -16,8 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA */ -#ifndef __LINUX_H__ -#define __LINUX_H__ +#ifndef __FRONTEND_MAIN_H__ +#define __FRONTEND_MAIN_H__ #include "config.h" @@ -41,6 +41,8 @@ extern int state_slot; int emu_core_preinit(void); int emu_core_init(void); +void emu_core_ask_exit(void); + void emu_set_default_config(void); void emu_on_new_cd(int show_hud_msg); @@ -52,7 +54,7 @@ int emu_load_state(int slot); void set_cd_image(const char *fname); extern unsigned long gpuDisp; -extern int ready_to_go, g_resetting; +extern int ready_to_go, g_emu_want_quit, g_emu_resetting; extern char hud_msg[64]; extern int hud_new_msg; @@ -68,7 +70,7 @@ enum sched_action { SACTION_SWITCH_DISPMODE, SACTION_FAST_FORWARD, SACTION_SCREENSHOT, - SACTION_VOLUME_UP, + SACTION_VOLUME_UP, // 10 SACTION_VOLUME_DOWN, SACTION_MINIMIZE, SACTION_TOGGLE_FPS, @@ -93,4 +95,4 @@ static inline void emu_set_action(enum sched_action action_) emu_action = action_; } -#endif /* __LINUX_H__ */ +#endif /* __FRONTEND_MAIN_H__ */ diff --git a/frontend/menu.c b/frontend/menu.c index 8119505..b25e192 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -1832,7 +1832,6 @@ static void menu_bios_warn(void) // ------------ main menu ------------ static menu_entry e_menu_main[]; -void OnFile_Exit(); static void draw_frame_main(void) { @@ -2153,8 +2152,8 @@ static int main_menu_handler(int id, int keys) in_menu_wait(PBTN_MOK|PBTN_MBACK, NULL, 70); break; case MA_MAIN_EXIT: - OnFile_Exit(); - break; + emu_core_ask_exit(); + return 1; default: lprintf("%s: something unknown selected\n", __FUNCTION__); break; @@ -2240,7 +2239,7 @@ void menu_loop(void) do { me_loop_d(e_menu_main, &sel, NULL, draw_frame_main); - } while (!ready_to_go); + } while (!ready_to_go && !g_emu_want_quit); /* wait until menu, ok, back is released */ while (in_menu_wait_any(NULL, 50) & (PBTN_MENU|PBTN_MOK|PBTN_MBACK)) diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index 5b85375..e3d70f6 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -72,6 +72,11 @@ static int change_video_mode(void) return plat_sdl_change_video_mode(w, h, 0); } +static void quit_cb(void) +{ + emu_core_ask_exit(); +} + void plat_init(void) { int ret; @@ -95,6 +100,7 @@ void plat_init(void) pl_rearmed_cbs.only_16bpp = 1; bgr_to_uyvy_init(); + plat_sdl_quit_cb = quit_cb; } void plat_finish(void) diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index dfff868..fff8401 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -606,7 +606,7 @@ void pl_frame_limit(void) struct timeval now; int diff, usadj; - if (g_resetting) + if (g_emu_resetting) return; vsync_cnt++; -- cgit v1.2.3 From 468072a17a20bf584df17f14e329441eebf66776 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 5 Feb 2013 00:42:51 +0200 Subject: frontend: do all bpp handling in plugin_lib --- frontend/plugin_lib.c | 7 +++++-- plugins/gpulib/vout_pl.c | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index fff8401..180ee4a 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -240,9 +240,12 @@ static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp) psx_w = raw_w; psx_h = raw_h; + psx_bpp = bpp; vout_w = w; vout_h = h; - vout_bpp = psx_bpp = bpp; + vout_bpp = bpp; + if (pl_rearmed_cbs.only_16bpp) + vout_bpp = 16; // don't use very low heights if (vout_h < 192) { @@ -270,7 +273,7 @@ static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp) pl_vout_buf = plat_gvideo_set_mode(&vout_w, &vout_h, &vout_bpp); if (pl_vout_buf == NULL && pl_plat_blit == NULL) fprintf(stderr, "failed to set mode %dx%d@%d\n", - vout_w, vout_h, psx_bpp); + vout_w, vout_h, vout_bpp); else { pl_vout_w = vout_w; pl_vout_h = vout_h; diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 5af0762..7f031fe 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -50,8 +50,7 @@ static void check_mode_change(int force) old_status = gpu.status.reg; old_h = h; - cbs->pl_vout_set_mode(w_out, h_out, w, h, - (gpu.status.rgb24 && !cbs->only_16bpp) ? 24 : 16); + cbs->pl_vout_set_mode(w_out, h_out, w, h, gpu.status.rgb24 ? 24 : 16); } } -- cgit v1.2.3 From 418caf437ed1af2880b013462b603e1ca1f28fb5 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 6 Feb 2013 03:54:04 +0200 Subject: attempt to make gles plugin work under RPi --- frontend/libpicofe | 2 +- frontend/plat_sdl.c | 40 ++++++++++++++++++++++++++++++++++------ frontend/plugin_lib.h | 4 +++- plugins/gpu-gles/gpuDraw.c | 32 ++++++++++++++++++++++---------- plugins/gpu-gles/gpuDraw.h | 2 +- plugins/gpu-gles/gpuExternals.h | 4 ++++ plugins/gpu-gles/gpuPlugin.c | 6 +++--- plugins/gpu-gles/gpuPrim.c | 3 --- plugins/gpu-gles/gpuStdafx.h | 6 ------ plugins/gpu-gles/gpulib_if.c | 9 ++++++++- 10 files changed, 76 insertions(+), 32 deletions(-) diff --git a/frontend/libpicofe b/frontend/libpicofe index 63f173a..6fd0935 160000 --- a/frontend/libpicofe +++ b/frontend/libpicofe @@ -1 +1 @@ -Subproject commit 63f173a2509a27f9ae156ad6ee798d76dec0ad6b +Subproject commit 6fd09356f0d8c3d823f33c27b5e40041468b94b8 diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index e3d70f6..2aa199f 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -1,5 +1,5 @@ /* - * (C) Gražvydas "notaz" Ignotas, 2011,2012 + * (C) Gražvydas "notaz" Ignotas, 2011-2013 * * This work is licensed under the terms of any of these licenses * (at your option): @@ -19,6 +19,7 @@ #include "libpicofe/gl.h" #include "../plugins/gpulib/cspace.h" #include "plugin_lib.h" +#include "plugin.h" #include "main.h" #include "plat.h" #include "revision.h" @@ -56,7 +57,7 @@ static int psx_w, psx_h; static void *shadow_fb, *menubg_img; static int in_menu; -static int change_video_mode(void) +static int change_video_mode(int force) { int w, h; @@ -69,7 +70,17 @@ static int change_video_mode(void) h = psx_h; } - return plat_sdl_change_video_mode(w, h, 0); + return plat_sdl_change_video_mode(w, h, force); +} + +static void resize_cb(int w, int h) +{ + // used by some plugins.. + pl_rearmed_cbs.screen_w = w; + pl_rearmed_cbs.screen_h = h; + pl_rearmed_cbs.gles_display = gl_es_display; + pl_rearmed_cbs.gles_surface = gl_es_surface; + plugin_call_rearmed_cbs(); } static void quit_cb(void) @@ -77,10 +88,21 @@ static void quit_cb(void) emu_core_ask_exit(); } +static void get_layer_pos(int *x, int *y, int *w, int *h) +{ + // always fill entire SDL window + *x = *y = 0; + *w = pl_rearmed_cbs.screen_w; + *h = pl_rearmed_cbs.screen_h; +} + void plat_init(void) { int ret; + plat_sdl_quit_cb = quit_cb; + plat_sdl_resize_cb = resize_cb; + ret = plat_sdl_init(); if (ret != 0) exit(1); @@ -98,9 +120,9 @@ void plat_init(void) in_sdl_init(in_sdl_defbinds, plat_sdl_event_handler); in_probe(); pl_rearmed_cbs.only_16bpp = 1; + pl_rearmed_cbs.pl_get_layer_pos = get_layer_pos; bgr_to_uyvy_init(); - plat_sdl_quit_cb = quit_cb; } void plat_finish(void) @@ -168,7 +190,7 @@ void *plat_gvideo_set_mode(int *w, int *h, int *bpp) { psx_w = *w; psx_h = *h; - change_video_mode(); + change_video_mode(0); if (plat_sdl_overlay != NULL) { pl_plat_clear = plat_sdl_overlay_clear; pl_plat_blit = overlay_blit; @@ -210,6 +232,8 @@ void plat_gvideo_close(void) void plat_video_menu_enter(int is_rom_loaded) { + int force_mode_change = 0; + in_menu = 1; /* surface will be lost, must adjust pl_vout_buf for menu bg */ @@ -221,7 +245,11 @@ void plat_video_menu_enter(int is_rom_loaded) memcpy(menubg_img, plat_sdl_screen->pixels, psx_w * psx_h * 2); pl_vout_buf = menubg_img; - change_video_mode(); + /* gles plugin messes stuff up.. */ + if (pl_rearmed_cbs.gpu_caps & GPU_CAP_OWNS_DISPLAY) + force_mode_change = 1; + + change_video_mode(force_mode_change); } void plat_video_menu_begin(void) diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index a83d954..4a11002 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -51,13 +51,15 @@ struct rearmed_cbs { // some stats, for display by some plugins int flips_per_sec, cpu_usage; float vsps_cur; // currect vsync/s + // these are for gles plugin + unsigned int screen_w, screen_h; + void *gles_display, *gles_surface; // gpu options int frameskip; int fskip_advice; unsigned int *gpu_frame_count; unsigned int *gpu_hcnt; unsigned int flip_cnt; // increment manually if not using pl_vout_flip - unsigned int screen_w, screen_h; // gles plugin wants this unsigned int only_16bpp; // platform is 16bpp-only struct { int allow_interlace; // 0 off, 1 on, 2 guess diff --git a/plugins/gpu-gles/gpuDraw.c b/plugins/gpu-gles/gpuDraw.c index b619104..34d1c3b 100644 --- a/plugins/gpu-gles/gpuDraw.c +++ b/plugins/gpu-gles/gpuDraw.c @@ -248,9 +248,9 @@ void CreateScanLines(void) int use_fsaa = 0; EGLDisplay display; -EGLConfig config; -EGLContext context; EGLSurface surface; +static EGLConfig config; +static EGLContext context; #if defined(USE_X11) #include "X11/Xlib.h" @@ -435,10 +435,19 @@ static int initEGL(void) return 0; } -int GLinitialize() +static int created_gles_context; + +int GLinitialize(void *ext_gles_display, void *ext_gles_surface) { - if(initEGL()!=0) - return -1; + if(ext_gles_display != NULL && ext_gles_surface != NULL) { + display = (EGLDisplay)ext_gles_display; + surface = (EGLSurface)ext_gles_surface; + } + else { + if(initEGL()!=0) + return -1; + created_gles_context=1; + } //----------------------------------------------------// @@ -448,7 +457,7 @@ int GLinitialize() iResY-(rRatioRect.top+rRatioRect.bottom), rRatioRect.right, rRatioRect.bottom); glError(); - + glScissor(0, 0, iResX, iResY); glError(); // init clipping (fullscreen) glEnable(GL_SCISSOR_TEST); glError(); @@ -532,16 +541,19 @@ void GLcleanup() { CleanupTextureStore(); // bye textures - eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); - eglDestroySurface( display, surface ); - eglDestroyContext( display, context ); - eglTerminate( display ); + if(created_gles_context) { + eglMakeCurrent( display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); + eglDestroySurface( display, surface ); + eglDestroyContext( display, context ); + eglTerminate( display ); #if defined(USE_X11) if (x11Window) XDestroyWindow(x11Display, x11Window); if (x11Colormap) XFreeColormap( x11Display, x11Colormap ); if (x11Display) XCloseDisplay(x11Display); #endif + created_gles_context=0; + } } //////////////////////////////////////////////////////////////////////// diff --git a/plugins/gpu-gles/gpuDraw.h b/plugins/gpu-gles/gpuDraw.h index c59927d..a45bf46 100644 --- a/plugins/gpu-gles/gpuDraw.h +++ b/plugins/gpu-gles/gpuDraw.h @@ -49,7 +49,7 @@ extern "C" { BOOL bSetupPixelFormat(HDC hDC); #endif -int GLinitialize(); +int GLinitialize(void *ext_gles_display, void *ext_gles_surface); void GLcleanup(); #ifdef _WINDOWS BOOL offset2(void); diff --git a/plugins/gpu-gles/gpuExternals.h b/plugins/gpu-gles/gpuExternals.h index 897b446..1260167 100644 --- a/plugins/gpu-gles/gpuExternals.h +++ b/plugins/gpu-gles/gpuExternals.h @@ -41,6 +41,10 @@ extern "C" { #include #endif +#ifndef GL_BGRA_EXT +#define GL_BGRA_EXT GL_RGBA // ?? +#endif + #ifdef __NANOGL__ #define glTexParameteri(x,y,z) glTexParameterf(x,y,z) #define glAlphaFuncx(x,y) glAlphaFunc(x,y) diff --git a/plugins/gpu-gles/gpuPlugin.c b/plugins/gpu-gles/gpuPlugin.c index 9d749a5..60570ac 100644 --- a/plugins/gpu-gles/gpuPlugin.c +++ b/plugins/gpu-gles/gpuPlugin.c @@ -511,7 +511,7 @@ long CALLBACK GPUopen(int hwndGPU) // lGPUstatusRet = 0x74000000; // with some emus, we could do the OGL init right here... oh my - if(bIsFirstFrame) GLinitialize(); + if(bIsFirstFrame) GLinitialize(NULL, NULL); return 0; } @@ -1170,7 +1170,7 @@ void CALLBACK GPUwriteStatus(unsigned long gdata) { unsigned long lCommand=(gdata>>24)&0xff; -if(bIsFirstFrame) GLinitialize(); // real ogl startup (needed by some emus) +if(bIsFirstFrame) GLinitialize(NULL, NULL); // real ogl startup (needed by some emus) ulStatusControl[lCommand]=gdata; @@ -2183,7 +2183,7 @@ unsigned long dmaMem; unsigned char * baseAddrB; short count;unsigned int DMACommandCounter = 0; -if(bIsFirstFrame) GLinitialize(); +if(bIsFirstFrame) GLinitialize(NULL, NULL); GPUIsBusy; diff --git a/plugins/gpu-gles/gpuPrim.c b/plugins/gpu-gles/gpuPrim.c index 2f200eb..218ff66 100644 --- a/plugins/gpu-gles/gpuPrim.c +++ b/plugins/gpu-gles/gpuPrim.c @@ -44,9 +44,6 @@ // globals //////////////////////////////////////////////////////////////////////// -EGLSurface surface; -EGLDisplay display; - BOOL bDrawTextured; // current active drawing states BOOL bDrawSmoothShaded; diff --git a/plugins/gpu-gles/gpuStdafx.h b/plugins/gpu-gles/gpuStdafx.h index 69050b3..41051dc 100644 --- a/plugins/gpu-gles/gpuStdafx.h +++ b/plugins/gpu-gles/gpuStdafx.h @@ -82,12 +82,6 @@ extern "C" { #define SHADETEXBIT(x) ((x>>24) & 0x1) #define SEMITRANSBIT(x) ((x>>25) & 0x1) -#ifndef _WINDOWS -#ifndef GL_BGRA_EXT -#define GL_BGRA_EXT GL_RGBA -#endif -#endif - #if 0 #define glError() { \ GLenum err = glGetError(); \ diff --git a/plugins/gpu-gles/gpulib_if.c b/plugins/gpu-gles/gpulib_if.c index 2090553..1f4a23d 100644 --- a/plugins/gpu-gles/gpulib_if.c +++ b/plugins/gpu-gles/gpulib_if.c @@ -690,7 +690,7 @@ long GPUopen(void **dpy) InitializeTextureStore(); // init texture mem - ret = GLinitialize(); + ret = GLinitialize(cbs->gles_display, cbs->gles_surface); MakeDisplayLists(); is_opened = 1; @@ -726,9 +726,16 @@ void renderer_set_config(const struct rearmed_cbs *cbs_) bUseFastMdec = cbs->gpu_peopsgl.bUseFastMdec; iTexGarbageCollection = cbs->gpu_peopsgl.iTexGarbageCollection; iVRamSize = cbs->gpu_peopsgl.iVRamSize; + if (cbs->pl_set_gpu_caps) cbs->pl_set_gpu_caps(GPU_CAP_OWNS_DISPLAY); + if (is_opened && cbs->gles_display != NULL && cbs->gles_surface != NULL) { + // HACK.. + GPUclose(); + GPUopen(NULL); + } + set_vram(gpu.vram); } -- cgit v1.2.3 From e83c4fdcf2b4578bfd7196c89e55b01aebd4da04 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 6 Feb 2013 03:55:22 +0200 Subject: disable standalone pluign builds these were for testing mostly, not for general use. Also fix a typo along the way. --- plugins/dfxvideo/Makefile | 2 +- plugins/gpu-gles/Makefile | 2 +- plugins/gpu_unai/Makefile | 2 +- plugins/gpulib/gpulib.mak | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/dfxvideo/Makefile b/plugins/dfxvideo/Makefile index ee7c4dc..fb879f4 100644 --- a/plugins/dfxvideo/Makefile +++ b/plugins/dfxvideo/Makefile @@ -14,6 +14,6 @@ SRC_STANDALONE += draw_pl.c #LDLIBS_STANDALONE += -lX11 -lXv -lXext #endif -BIN_STANDLALONE = gpuPEOPS.so +#BIN_STANDALONE = gpuPEOPS.so BIN_GPULIB = gpu_peops.so include ../gpulib/gpulib.mak diff --git a/plugins/gpu-gles/Makefile b/plugins/gpu-gles/Makefile index 769a68b..e914764 100644 --- a/plugins/gpu-gles/Makefile +++ b/plugins/gpu-gles/Makefile @@ -16,6 +16,6 @@ CFLAGS += $(CFLAGS_GLES) LDLIBS += $(LDLIBS_GLES) endif -BIN_STANDLALONE = gpuGLES.so +#BIN_STANDALONE = gpuGLES.so BIN_GPULIB = gpu_gles.so include ../gpulib/gpulib.mak diff --git a/plugins/gpu_unai/Makefile b/plugins/gpu_unai/Makefile index 994997f..1075ee5 100644 --- a/plugins/gpu_unai/Makefile +++ b/plugins/gpu_unai/Makefile @@ -11,6 +11,6 @@ ifeq "$(ARCH)" "arm" SRC += gpu_arm.s endif -BIN_STANDLALONE = gpuPCSX4ALL.so +#BIN_STANDALONE = gpuPCSX4ALL.so BIN_GPULIB = gpu_unai.so include ../gpulib/gpulib.mak diff --git a/plugins/gpulib/gpulib.mak b/plugins/gpulib/gpulib.mak index ad6a8ad..035983c 100644 --- a/plugins/gpulib/gpulib.mak +++ b/plugins/gpulib/gpulib.mak @@ -16,8 +16,8 @@ endif GPULIB_A = ../gpulib/gpulib$(EXT).a -ifdef BIN_STANDLALONE -TARGETS += $(BIN_STANDLALONE) +ifdef BIN_STANDALONE +TARGETS += $(BIN_STANDALONE) endif ifdef BIN_GPULIB TARGETS += $(BIN_GPULIB) @@ -30,11 +30,11 @@ PLUGINDIR = $(shell basename $(WD)) all: ../../config.mak $(TARGETS) -ifdef BIN_STANDLALONE +ifdef BIN_STANDALONE ifneq ($(findstring .cpp,$(SRC_STANDALONE)),) CC_STANDLALONE = $(CXX) endif -$(BIN_STANDLALONE): $(SRC) $(SRC_STANDALONE) $(GPULIB_A) +$(BIN_STANDALONE): $(SRC) $(SRC_STANDALONE) $(GPULIB_A) $(CC_STANDLALONE) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) $(LDLIBS_STANDALONE) ln -fs $(PLUGINDIR)/$@ ../ endif -- cgit v1.2.3 From 955f9af0395a7fa2bba0d1c3a4e6ef5d3e111dae Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 8 Feb 2013 01:46:08 +0200 Subject: frontend: check for xlib when it's needed --- configure | 17 +++++++++++++++++ frontend/libpicofe | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 4d3bb5f..8b5cbda 100755 --- a/configure +++ b/configure @@ -49,6 +49,7 @@ have_tslib="" have_gles="" enable_dynarec="yes" need_sdl="no" +need_xlib="no" need_libpicofe="yes" need_warm="no" CFLAGS_GLES="" @@ -84,6 +85,7 @@ set_platform() drc_cache_base="yes" optimize_cortexa8="yes" have_arm_neon="yes" + need_xlib="yes" ;; maemo) ram_fixed="yes" @@ -360,6 +362,15 @@ EOF compile_binary "$@" } +check_xlib_headers() +{ + cat > $TMPC < + void *f() { return XOpenDisplay(0); } +EOF + compile_object "$@" +} + MAIN_LDLIBS="$MAIN_LDLIBS -lz" check_zlib || fail "please install zlib (libz-dev)" @@ -420,6 +431,7 @@ fi if [ -d /opt/vc/include -a -d /opt/vc/lib ]; then CFLAGS_GLES="$CFLAGS_GLES -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads" LDLIBS_GLES="$LDLIBS_GLES -L/opt/vc/lib" + need_xlib="yes" fi # check for GLES headers @@ -445,6 +457,11 @@ if [ "$have_arm_neon" = "yes" -a "$builtin_gpu" != "neon" ]; then plugins="$plugins plugins/gpu_neon/gpu_neon.so" fi +# check for xlib (only headers needed) +if [ "x$need_xlib" = "xyes" ]; then + check_xlib_headers || fail "please install libx11-dev" +fi + cat > $TMPC <> 10) | ((p & 0x03e003e0) << 1) + | ((p & 0x001f001f) << 11); + dst[x] = p; + } +} + +void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) +{ + const unsigned char *src = src_; + unsigned int *dst = dst_; + unsigned int r1, g1, b1, r2, g2, b2; + + for (; bytes >= 6; bytes -= 6, src += 6, dst++) { + r1 = src[0] & 0xf8; + g1 = src[1] & 0xfc; + b1 = src[2] & 0xf8; + r2 = src[3] & 0xf8; + g2 = src[4] & 0xfc; + b2 = src[5] & 0xf8; + *dst = (r2 << 24) | (g2 << 19) | (b2 << 13) | + (r1 << 8) | (g1 << 3) | (b1 >> 3); + } +} + +// TODO? +void rgb888_to_rgb565(void *dst, const void *src, int bytes) {} +void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} + +#endif // __ARM_NEON__ + +/* YUV stuff */ +static int yuv_ry[32], yuv_gy[32], yuv_by[32]; +static unsigned char yuv_u[32 * 2], yuv_v[32 * 2]; + +void bgr_to_uyvy_init(void) +{ + int i, v; + + /* init yuv converter: + y0 = (int)((0.299f * r0) + (0.587f * g0) + (0.114f * b0)); + y1 = (int)((0.299f * r1) + (0.587f * g1) + (0.114f * b1)); + u = (int)(8 * 0.565f * (b0 - y0)) + 128; + v = (int)(8 * 0.713f * (r0 - y0)) + 128; + */ + for (i = 0; i < 32; i++) { + yuv_ry[i] = (int)(0.299f * i * 65536.0f + 0.5f); + yuv_gy[i] = (int)(0.587f * i * 65536.0f + 0.5f); + yuv_by[i] = (int)(0.114f * i * 65536.0f + 0.5f); + } + for (i = -32; i < 32; i++) { + v = (int)(8 * 0.565f * i) + 128; + if (v < 0) + v = 0; + if (v > 255) + v = 255; + yuv_u[i + 32] = v; + v = (int)(8 * 0.713f * i) + 128; + if (v < 0) + v = 0; + if (v > 255) + v = 255; + yuv_v[i + 32] = v; + } +} + +void rgb565_to_uyvy(void *d, const void *s, int pixels) +{ + unsigned int *dst = d; + const unsigned short *src = s; + const unsigned char *yu = yuv_u + 32; + const unsigned char *yv = yuv_v + 32; + int r0, g0, b0, r1, g1, b1; + int y0, y1, u, v; + + for (; pixels > 0; src += 2, dst++, pixels -= 2) + { + r0 = (src[0] >> 11) & 0x1f; + g0 = (src[0] >> 6) & 0x1f; + b0 = src[0] & 0x1f; + r1 = (src[1] >> 11) & 0x1f; + g1 = (src[1] >> 6) & 0x1f; + b1 = src[1] & 0x1f; + y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; + y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; + u = yu[b0 - y0]; + v = yv[r0 - y0]; + // valid Y range seems to be 16..235 + y0 = 16 + 219 * y0 / 31; + y1 = 16 + 219 * y1 / 31; + + *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; + } +} + +void bgr555_to_uyvy(void *d, const void *s, int pixels) +{ + unsigned int *dst = d; + const unsigned short *src = s; + const unsigned char *yu = yuv_u + 32; + const unsigned char *yv = yuv_v + 32; + int r0, g0, b0, r1, g1, b1; + int y0, y1, u, v; + + for (; pixels > 0; src += 2, dst++, pixels -= 2) + { + b0 = (src[0] >> 10) & 0x1f; + g0 = (src[0] >> 5) & 0x1f; + r0 = src[0] & 0x1f; + b1 = (src[1] >> 10) & 0x1f; + g1 = (src[1] >> 5) & 0x1f; + r1 = src[1] & 0x1f; + y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; + y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; + u = yu[b0 - y0]; + v = yv[r0 - y0]; + y0 = 16 + 219 * y0 / 31; + y1 = 16 + 219 * y1 / 31; + + *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; + } +} + +void bgr888_to_uyvy(void *d, const void *s, int pixels) +{ + unsigned int *dst = d; + const unsigned char *src8 = s; + const unsigned char *yu = yuv_u + 32; + const unsigned char *yv = yuv_v + 32; + int r0, g0, b0, r1, g1, b1; + int y0, y1, u, v; + + for (; pixels > 0; src8 += 3*2, dst++, pixels -= 2) + { + r0 = src8[0], g0 = src8[1], b0 = src8[2]; + r1 = src8[3], g1 = src8[4], b1 = src8[5]; + y0 = (r0 * 19595 + g0 * 38470 + b0 * 7471) >> 16; + y1 = (r1 * 19595 + g1 * 38470 + b1 * 7471) >> 16; + u = yu[(b0 - y0) / 8]; + v = yv[(r0 - y0) / 8]; + y0 = 16 + 219 * y0 / 255; + y1 = 16 + 219 * y1 / 255; + + *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; + } +} diff --git a/frontend/cspace.h b/frontend/cspace.h new file mode 100644 index 0000000..1a9e339 --- /dev/null +++ b/frontend/cspace.h @@ -0,0 +1,18 @@ +#ifdef __cplusplus +extern "C" +{ +#endif + +void bgr555_to_rgb565(void *dst, const void *src, int bytes); +void bgr888_to_rgb888(void *dst, const void *src, int bytes); +void bgr888_to_rgb565(void *dst, const void *src, int bytes); +void rgb888_to_rgb565(void *dst, const void *src, int bytes); + +void bgr_to_uyvy_init(void); +void rgb565_to_uyvy(void *d, const void *s, int pixels); +void bgr555_to_uyvy(void *d, const void *s, int pixels); +void bgr888_to_uyvy(void *d, const void *s, int pixels); + +#ifdef __cplusplus +} +#endif diff --git a/frontend/cspace_neon.s b/frontend/cspace_neon.s new file mode 100644 index 0000000..b458f06 --- /dev/null +++ b/frontend/cspace_neon.s @@ -0,0 +1,165 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2010 + * + * This work is licensed under the terms of any of these licenses + * (at your option): + * - GNU GPL, version 2 or later. + * - GNU LGPL, version 2.1 or later. + * See the COPYING file in the top-level directory. + */ + +.text +.align 2 + +.global bgr555_to_rgb565 +bgr555_to_rgb565: + pld [r1] + mov r3, #0x07c0 + vdup.16 q15, r3 + subs r2, r2, #64 + blt btr16_end64 +0: + pld [r1, #64*2] + vldmia r1!, {q0-q3} + vshl.u16 q4, q0, #11 + vshl.u16 q5, q1, #11 + vshl.u16 q6, q2, #11 + vshl.u16 q7, q3, #11 + vsri.u16 q4, q0, #10 + vsri.u16 q5, q1, #10 + vsri.u16 q6, q2, #10 + vsri.u16 q7, q3, #10 + vshl.u16 q0, q0, #1 + vshl.u16 q1, q1, #1 + vshl.u16 q2, q2, #1 + vshl.u16 q3, q3, #1 + vbit q4, q0, q15 + vbit q5, q1, q15 + vbit q6, q2, q15 + vbit q7, q3, q15 + vstmia r0!, {q4-q7} + subs r2, r2, #64 + bge 0b + +btr16_end64: + adds r2, r2, #64 + bxeq lr + subs r2, r2, #16 + blt btr16_end16 + + @ handle the remainder (reasonably rare) +0: + vld1.16 {q0}, [r1]! + vshl.u16 q1, q0, #11 + vshl.u16 q2, q0, #1 + vsri.u16 q1, q0, #10 + vbit q1, q2, q15 + subs r2, r2, #16 + vst1.16 {q1}, [r0]! + bge 0b + +btr16_end16: + adds r2, r2, #16 + bxeq lr + subs r2, r2, #8 + bxlt lr + + @ very rare + vld1.16 d0, [r1]! + vshl.u16 d1, d0, #11 + vshl.u16 d2, d0, #1 + vsri.u16 d1, d0, #10 + vbit d1, d2, d30 + vst1.16 d1, [r0]! + bx lr + + +.global bgr888_to_rgb888 +bgr888_to_rgb888: + pld [r1] + @ r2 /= 48 + mov r2, r2, lsr #4 + movw r3, #0x5556 + movt r3, #0x5555 + umull r12,r2, r3, r2 +0: + pld [r1, #48*3] + vld3.8 {d0-d2}, [r1, :64]! + vld3.8 {d3-d5}, [r1, :64]! + vswp d0, d2 + vswp d3, d5 + vst3.8 {d0-d2}, [r0, :64]! + vst3.8 {d3-d5}, [r0, :64]! + subs r2, r2, #1 + bne 0b + + bx lr + + +.global bgr888_to_rgb565 +bgr888_to_rgb565: + pld [r1] + @ r2 /= 48 + mov r2, r2, lsr #4 + movw r3, #0x5556 + movt r3, #0x5555 + umull r12,r2, r3, r2 + + mov r3, #0x07e0 + vdup.16 q15, r3 +0: + pld [r1, #48*3] + vld3.8 {d1-d3}, [r1, :64]! + vld3.8 {d5-d7}, [r1, :64]! + + vshll.u8 q8, d2, #3 @ g + vshll.u8 q9, d6, #3 + vshr.u8 d0, d3, #3 @ b + vshr.u8 d4, d7, #3 + vzip.8 d0, d1 @ rb + vzip.8 d4, d5 + vbit q0, q8, q15 + vbit q2, q9, q15 + + vstmia r0!, {d0,d1} + vstmia r0!, {d4,d5} + subs r2, r2, #1 + bne 0b + + bx lr + + +.global rgb888_to_rgb565 +rgb888_to_rgb565: + pld [r1] + @ r2 /= 48 + mov r2, r2, lsr #4 + movw r3, #0x5556 + movt r3, #0x5555 + umull r12,r2, r3, r2 + + mov r3, #0x07e0 + vdup.16 q15, r3 +0: + pld [r1, #48*3] + vld3.8 {d1-d3}, [r1, :64]! + vld3.8 {d5-d7}, [r1, :64]! + + vshll.u8 q8, d2, #3 @ g + vshll.u8 q9, d6, #3 + vshr.u8 d2, d1, #3 @ b + vshr.u8 d6, d5, #3 + vzip.8 d2, d3 @ rb + vzip.8 d6, d7 + vbit q1, q8, q15 + vbit q3, q9, q15 + + vstmia r0!, {d2,d3} + vstmia r0!, {d6,d7} + subs r2, r2, #1 + bne 0b + + bx lr + + +@ vim:filetype=armasm diff --git a/frontend/libretro.c b/frontend/libretro.c index 4f6879e..c6d113f 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -15,7 +15,7 @@ #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../libpcsxcore/cheat.h" #include "../plugins/dfsound/out.h" -#include "../plugins/gpulib/cspace.h" +#include "cspace.h" #include "main.h" #include "plugin.h" #include "plugin_lib.h" diff --git a/frontend/menu.c b/frontend/menu.c index b25e192..46e4298 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -26,6 +26,7 @@ #include "plugin_lib.h" #include "plat.h" #include "pcnt.h" +#include "cspace.h" #include "libpicofe/plat.h" #include "libpicofe/input.h" #include "libpicofe/linux/in_evdev.h" @@ -36,7 +37,6 @@ #include "../libpcsxcore/cheat.h" #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../plugins/dfinput/externals.h" -#include "../plugins/gpulib/cspace.h" #include "psemu_plugin_defs.h" #include "revision.h" diff --git a/frontend/plat_pollux.c b/frontend/plat_pollux.c index c932261..252feba 100644 --- a/frontend/plat_pollux.c +++ b/frontend/plat_pollux.c @@ -46,8 +46,8 @@ #include "main.h" #include "menu.h" #include "plat.h" +#include "cspace.h" #include "../libpcsxcore/psxmem_map.h" -#include "../plugins/gpulib/cspace.h" static int fbdev = -1; diff --git a/frontend/plat_sdl.c b/frontend/plat_sdl.c index 2aa199f..dacf584 100644 --- a/frontend/plat_sdl.c +++ b/frontend/plat_sdl.c @@ -17,7 +17,7 @@ #include "libpicofe/fonts.h" #include "libpicofe/plat_sdl.h" #include "libpicofe/gl.h" -#include "../plugins/gpulib/cspace.h" +#include "cspace.h" #include "plugin_lib.h" #include "plugin.h" #include "main.h" diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 180ee4a..a3dcbab 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -28,10 +28,10 @@ #include "plat.h" #include "pcnt.h" #include "pl_gun_ts.h" +#include "cspace.h" #include "psemu_plugin_defs.h" #include "../libpcsxcore/new_dynarec/new_dynarec.h" #include "../libpcsxcore/psxmem_map.h" -#include "../plugins/gpulib/cspace.h" #include "../plugins/dfinput/externals.h" int in_type1, in_type2; diff --git a/jni/Android.mk b/jni/Android.mk index 06b4379..05a92d4 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -29,14 +29,16 @@ ifeq ($(TARGET_ARCH),arm) # spu LOCAL_SRC_FILES += ../plugins/dfsound/arm_utils.S + # misc + ifeq ($(NO_NEON_BUILD),1) # gpu LOCAL_CFLAGS += -DREARMED - LOCAL_SRC_FILES += ../plugins/gpulib/cspace.c ../plugins/gpu_unai/gpulib_if.cpp ../plugins/gpu_unai/gpu_arm.s + LOCAL_SRC_FILES += ../plugins/gpu_unai/gpulib_if.cpp ../plugins/gpu_unai/gpu_arm.s else LOCAL_ARM_NEON := true LOCAL_CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP - LOCAL_SRC_FILES += ../libpcsxcore/gte_neon.S ../plugins/gpulib/cspace_neon.s + LOCAL_SRC_FILES += ../libpcsxcore/gte_neon.S ../frontend/cspace_neon.s # gpu LOCAL_SRC_FILES += ../plugins/gpu_neon/psx_gpu_if.c ../plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S @@ -54,7 +56,7 @@ endif ifneq ($(TARGET_ARCH),arm) # gpu LOCAL_CFLAGS += -DREARMED - LOCAL_SRC_FILES += ../plugins/gpulib/cspace.c ../plugins/gpu_unai/gpulib_if.cpp + LOCAL_SRC_FILES += ../plugins/gpu_unai/gpulib_if.cpp endif $(shell cd "$(LOCAL_PATH)" && ((git describe || echo) | sed -e 's/.*/#define REV "\0"/' > ../frontend/revision.h_)) @@ -84,7 +86,7 @@ LOCAL_SRC_FILES += ../plugins/cdrcimg/cdrcimg.c LOCAL_SRC_FILES += ../plugins/dfinput/main.c ../plugins/dfinput/pad.c ../plugins/dfinput/guncon.c # misc -LOCAL_SRC_FILES += ../frontend/main.c ../frontend/plugin.c +LOCAL_SRC_FILES += ../frontend/main.c ../frontend/plugin.c ../frontend/cspace.c # libretro LOCAL_SRC_FILES += ../frontend/libretro.c diff --git a/plugins/dfxvideo/draw_pl.c b/plugins/dfxvideo/draw_pl.c index 61fb94c..37dbfff 100644 --- a/plugins/dfxvideo/draw_pl.c +++ b/plugins/dfxvideo/draw_pl.c @@ -9,7 +9,6 @@ #include "gpu.h" -#include "../gpulib/cspace.h" #include "../../frontend/plugin_lib.h" #include "pcnt.h" diff --git a/plugins/gpu_unai/gpu.cpp b/plugins/gpu_unai/gpu.cpp index df5e0cf..d509617 100644 --- a/plugins/gpu_unai/gpu.cpp +++ b/plugins/gpu_unai/gpu.cpp @@ -819,7 +819,6 @@ void GPU_updateLace(void) #else #include "../../frontend/plugin_lib.h" -#include "../gpulib/cspace.h" extern "C" { diff --git a/plugins/gpulib/Makefile b/plugins/gpulib/Makefile index 4a45aa2..cff6141 100644 --- a/plugins/gpulib/Makefile +++ b/plugins/gpulib/Makefile @@ -16,11 +16,6 @@ else OBJS += vout_pl.o EXT = $(ARCH).a endif -ifeq "$(HAVE_NEON)" "1" -OBJS += cspace_neon.o -else -OBJS += cspace.o -endif CFLAGS += $(PLUGIN_CFLAGS) # need to compile to another dir, same files are compiled diff --git a/plugins/gpulib/cspace.c b/plugins/gpulib/cspace.c deleted file mode 100644 index f0c4912..0000000 --- a/plugins/gpulib/cspace.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * (C) Gražvydas "notaz" Ignotas, 2011,2012 - * - * This work is licensed under the terms of any of these licenses - * (at your option): - * - GNU GPL, version 2 or later. - * - GNU LGPL, version 2.1 or later. - * See the COPYING file in the top-level directory. - */ - -#include "cspace.h" - -/* - * note: these are intended for testing and should be avoided - * in favor of NEON version or platform-specific conversion - */ - -#ifndef __ARM_NEON__ - -void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) -{ - const unsigned int *src = src_; - unsigned int *dst = dst_; - unsigned int p; - int x; - - for (x = 0; x < bytes / 4; x++) { - p = src[x]; - p = ((p & 0x7c007c00) >> 10) | ((p & 0x03e003e0) << 1) - | ((p & 0x001f001f) << 11); - dst[x] = p; - } -} - -void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) -{ - const unsigned char *src = src_; - unsigned int *dst = dst_; - unsigned int r1, g1, b1, r2, g2, b2; - - for (; bytes >= 6; bytes -= 6, src += 6, dst++) { - r1 = src[0] & 0xf8; - g1 = src[1] & 0xfc; - b1 = src[2] & 0xf8; - r2 = src[3] & 0xf8; - g2 = src[4] & 0xfc; - b2 = src[5] & 0xf8; - *dst = (r2 << 24) | (g2 << 19) | (b2 << 13) | - (r1 << 8) | (g1 << 3) | (b1 >> 3); - } -} - -// TODO? -void rgb888_to_rgb565(void *dst, const void *src, int bytes) {} -void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} - -#endif // __ARM_NEON__ - -/* YUV stuff */ -static int yuv_ry[32], yuv_gy[32], yuv_by[32]; -static unsigned char yuv_u[32 * 2], yuv_v[32 * 2]; - -void bgr_to_uyvy_init(void) -{ - int i, v; - - /* init yuv converter: - y0 = (int)((0.299f * r0) + (0.587f * g0) + (0.114f * b0)); - y1 = (int)((0.299f * r1) + (0.587f * g1) + (0.114f * b1)); - u = (int)(8 * 0.565f * (b0 - y0)) + 128; - v = (int)(8 * 0.713f * (r0 - y0)) + 128; - */ - for (i = 0; i < 32; i++) { - yuv_ry[i] = (int)(0.299f * i * 65536.0f + 0.5f); - yuv_gy[i] = (int)(0.587f * i * 65536.0f + 0.5f); - yuv_by[i] = (int)(0.114f * i * 65536.0f + 0.5f); - } - for (i = -32; i < 32; i++) { - v = (int)(8 * 0.565f * i) + 128; - if (v < 0) - v = 0; - if (v > 255) - v = 255; - yuv_u[i + 32] = v; - v = (int)(8 * 0.713f * i) + 128; - if (v < 0) - v = 0; - if (v > 255) - v = 255; - yuv_v[i + 32] = v; - } -} - -void rgb565_to_uyvy(void *d, const void *s, int pixels) -{ - unsigned int *dst = d; - const unsigned short *src = s; - const unsigned char *yu = yuv_u + 32; - const unsigned char *yv = yuv_v + 32; - int r0, g0, b0, r1, g1, b1; - int y0, y1, u, v; - - for (; pixels > 0; src += 2, dst++, pixels -= 2) - { - r0 = (src[0] >> 11) & 0x1f; - g0 = (src[0] >> 6) & 0x1f; - b0 = src[0] & 0x1f; - r1 = (src[1] >> 11) & 0x1f; - g1 = (src[1] >> 6) & 0x1f; - b1 = src[1] & 0x1f; - y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; - y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; - u = yu[b0 - y0]; - v = yv[r0 - y0]; - // valid Y range seems to be 16..235 - y0 = 16 + 219 * y0 / 31; - y1 = 16 + 219 * y1 / 31; - - *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; - } -} - -void bgr555_to_uyvy(void *d, const void *s, int pixels) -{ - unsigned int *dst = d; - const unsigned short *src = s; - const unsigned char *yu = yuv_u + 32; - const unsigned char *yv = yuv_v + 32; - int r0, g0, b0, r1, g1, b1; - int y0, y1, u, v; - - for (; pixels > 0; src += 2, dst++, pixels -= 2) - { - b0 = (src[0] >> 10) & 0x1f; - g0 = (src[0] >> 5) & 0x1f; - r0 = src[0] & 0x1f; - b1 = (src[1] >> 10) & 0x1f; - g1 = (src[1] >> 5) & 0x1f; - r1 = src[1] & 0x1f; - y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; - y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; - u = yu[b0 - y0]; - v = yv[r0 - y0]; - y0 = 16 + 219 * y0 / 31; - y1 = 16 + 219 * y1 / 31; - - *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; - } -} - -void bgr888_to_uyvy(void *d, const void *s, int pixels) -{ - unsigned int *dst = d; - const unsigned char *src8 = s; - const unsigned char *yu = yuv_u + 32; - const unsigned char *yv = yuv_v + 32; - int r0, g0, b0, r1, g1, b1; - int y0, y1, u, v; - - for (; pixels > 0; src8 += 3*2, dst++, pixels -= 2) - { - r0 = src8[0], g0 = src8[1], b0 = src8[2]; - r1 = src8[3], g1 = src8[4], b1 = src8[5]; - y0 = (r0 * 19595 + g0 * 38470 + b0 * 7471) >> 16; - y1 = (r1 * 19595 + g1 * 38470 + b1 * 7471) >> 16; - u = yu[(b0 - y0) / 8]; - v = yv[(r0 - y0) / 8]; - y0 = 16 + 219 * y0 / 255; - y1 = 16 + 219 * y1 / 255; - - *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; - } -} diff --git a/plugins/gpulib/cspace.h b/plugins/gpulib/cspace.h deleted file mode 100644 index 1a9e339..0000000 --- a/plugins/gpulib/cspace.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - -void bgr555_to_rgb565(void *dst, const void *src, int bytes); -void bgr888_to_rgb888(void *dst, const void *src, int bytes); -void bgr888_to_rgb565(void *dst, const void *src, int bytes); -void rgb888_to_rgb565(void *dst, const void *src, int bytes); - -void bgr_to_uyvy_init(void); -void rgb565_to_uyvy(void *d, const void *s, int pixels); -void bgr555_to_uyvy(void *d, const void *s, int pixels); -void bgr888_to_uyvy(void *d, const void *s, int pixels); - -#ifdef __cplusplus -} -#endif diff --git a/plugins/gpulib/cspace_neon.s b/plugins/gpulib/cspace_neon.s deleted file mode 100644 index b458f06..0000000 --- a/plugins/gpulib/cspace_neon.s +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (C) Gražvydas "notaz" Ignotas, 2010 - * - * This work is licensed under the terms of any of these licenses - * (at your option): - * - GNU GPL, version 2 or later. - * - GNU LGPL, version 2.1 or later. - * See the COPYING file in the top-level directory. - */ - -.text -.align 2 - -.global bgr555_to_rgb565 -bgr555_to_rgb565: - pld [r1] - mov r3, #0x07c0 - vdup.16 q15, r3 - subs r2, r2, #64 - blt btr16_end64 -0: - pld [r1, #64*2] - vldmia r1!, {q0-q3} - vshl.u16 q4, q0, #11 - vshl.u16 q5, q1, #11 - vshl.u16 q6, q2, #11 - vshl.u16 q7, q3, #11 - vsri.u16 q4, q0, #10 - vsri.u16 q5, q1, #10 - vsri.u16 q6, q2, #10 - vsri.u16 q7, q3, #10 - vshl.u16 q0, q0, #1 - vshl.u16 q1, q1, #1 - vshl.u16 q2, q2, #1 - vshl.u16 q3, q3, #1 - vbit q4, q0, q15 - vbit q5, q1, q15 - vbit q6, q2, q15 - vbit q7, q3, q15 - vstmia r0!, {q4-q7} - subs r2, r2, #64 - bge 0b - -btr16_end64: - adds r2, r2, #64 - bxeq lr - subs r2, r2, #16 - blt btr16_end16 - - @ handle the remainder (reasonably rare) -0: - vld1.16 {q0}, [r1]! - vshl.u16 q1, q0, #11 - vshl.u16 q2, q0, #1 - vsri.u16 q1, q0, #10 - vbit q1, q2, q15 - subs r2, r2, #16 - vst1.16 {q1}, [r0]! - bge 0b - -btr16_end16: - adds r2, r2, #16 - bxeq lr - subs r2, r2, #8 - bxlt lr - - @ very rare - vld1.16 d0, [r1]! - vshl.u16 d1, d0, #11 - vshl.u16 d2, d0, #1 - vsri.u16 d1, d0, #10 - vbit d1, d2, d30 - vst1.16 d1, [r0]! - bx lr - - -.global bgr888_to_rgb888 -bgr888_to_rgb888: - pld [r1] - @ r2 /= 48 - mov r2, r2, lsr #4 - movw r3, #0x5556 - movt r3, #0x5555 - umull r12,r2, r3, r2 -0: - pld [r1, #48*3] - vld3.8 {d0-d2}, [r1, :64]! - vld3.8 {d3-d5}, [r1, :64]! - vswp d0, d2 - vswp d3, d5 - vst3.8 {d0-d2}, [r0, :64]! - vst3.8 {d3-d5}, [r0, :64]! - subs r2, r2, #1 - bne 0b - - bx lr - - -.global bgr888_to_rgb565 -bgr888_to_rgb565: - pld [r1] - @ r2 /= 48 - mov r2, r2, lsr #4 - movw r3, #0x5556 - movt r3, #0x5555 - umull r12,r2, r3, r2 - - mov r3, #0x07e0 - vdup.16 q15, r3 -0: - pld [r1, #48*3] - vld3.8 {d1-d3}, [r1, :64]! - vld3.8 {d5-d7}, [r1, :64]! - - vshll.u8 q8, d2, #3 @ g - vshll.u8 q9, d6, #3 - vshr.u8 d0, d3, #3 @ b - vshr.u8 d4, d7, #3 - vzip.8 d0, d1 @ rb - vzip.8 d4, d5 - vbit q0, q8, q15 - vbit q2, q9, q15 - - vstmia r0!, {d0,d1} - vstmia r0!, {d4,d5} - subs r2, r2, #1 - bne 0b - - bx lr - - -.global rgb888_to_rgb565 -rgb888_to_rgb565: - pld [r1] - @ r2 /= 48 - mov r2, r2, lsr #4 - movw r3, #0x5556 - movt r3, #0x5555 - umull r12,r2, r3, r2 - - mov r3, #0x07e0 - vdup.16 q15, r3 -0: - pld [r1, #48*3] - vld3.8 {d1-d3}, [r1, :64]! - vld3.8 {d5-d7}, [r1, :64]! - - vshll.u8 q8, d2, #3 @ g - vshll.u8 q9, d6, #3 - vshr.u8 d2, d1, #3 @ b - vshr.u8 d6, d5, #3 - vzip.8 d2, d3 @ rb - vzip.8 d6, d7 - vbit q1, q8, q15 - vbit q3, q9, q15 - - vstmia r0!, {d2,d3} - vstmia r0!, {d6,d7} - subs r2, r2, #1 - bne 0b - - bx lr - - -@ vim:filetype=armasm diff --git a/plugins/gpulib/gpulib.mak b/plugins/gpulib/gpulib.mak index 035983c..6377274 100644 --- a/plugins/gpulib/gpulib.mak +++ b/plugins/gpulib/gpulib.mak @@ -1,5 +1,5 @@ # depends on ARCH definition -# always adding gpulib to deps in case cspace is needed +# always adding gpulib to deps (XXX might be no longer needed) # users must include ../../config.mak LDFLAGS += -shared -Wl,--no-undefined diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 7f031fe..541b5e0 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -11,7 +11,6 @@ #include #include "gpu.h" -#include "cspace.h" #include "../../frontend/plugin_lib.h" static const struct rearmed_cbs *cbs; -- cgit v1.2.3 From d57557c0644f9294e30657f0c7cf673cf2914695 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 8 Feb 2013 02:13:03 +0200 Subject: frontend: add armv6 color space converter --- Makefile | 4 ++++ frontend/cspace.c | 6 ++++- frontend/cspace_arm.S | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ jni/Android.mk | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 frontend/cspace_arm.S diff --git a/Makefile b/Makefile index b6f381c..9f8b777 100644 --- a/Makefile +++ b/Makefile @@ -129,6 +129,10 @@ OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o OBJS += frontend/cspace.o ifeq "$(HAVE_NEON)" "1" OBJS += frontend/cspace_neon.o +else +ifeq "$(ARCH)" "arm" +OBJS += frontend/cspace_arm.o +endif endif ifeq "$(PLATFORM)" "generic" diff --git a/frontend/cspace.c b/frontend/cspace.c index f0c4912..33a981d 100644 --- a/frontend/cspace.c +++ b/frontend/cspace.c @@ -15,7 +15,7 @@ * in favor of NEON version or platform-specific conversion */ -#ifndef __ARM_NEON__ +#ifndef __arm__ void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) { @@ -32,6 +32,10 @@ void bgr555_to_rgb565(void *dst_, const void *src_, int bytes) } } +#endif + +#ifndef __ARM_NEON__ + void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) { const unsigned char *src = src_; diff --git a/frontend/cspace_arm.S b/frontend/cspace_arm.S new file mode 100644 index 0000000..e9d15a5 --- /dev/null +++ b/frontend/cspace_arm.S @@ -0,0 +1,65 @@ +/* + * (C) Gražvydas "notaz" Ignotas, 2013 + * + * This work is licensed under the terms of GNU GPL version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "arm_features.h" + +.text +.align 2 + +@ lr=0x001f001f +@ trashes r11, r12 +.macro bgr555_to_rgb565_one rn + and r11, lr, \rn + and r12, lr, \rn, lsr #5 + and \rn, lr, \rn, lsr #10 + orr r12, r11, lsl #5 + orr \rn, r12, lsl #6 +.endm + +.macro pld_ reg offs=#0 +#ifdef HAVE_ARMV6 + pld [\reg, \offs] +#endif +.endm + +.global bgr555_to_rgb565 @ void *dst, const void *src, int bytes +bgr555_to_rgb565: + pld_ r1 + push {r4-r11,lr} + mov lr, #0x001f + subs r2, #4*8 + orr lr, lr, lsl #16 + blt 1f + +0: + ldmia r1!, {r3-r10} + subs r2, #4*8 + bgr555_to_rgb565_one r3 + + pld_ r1, #32*2 + bgr555_to_rgb565_one r4 + bgr555_to_rgb565_one r5 + bgr555_to_rgb565_one r6 + bgr555_to_rgb565_one r7 + bgr555_to_rgb565_one r8 + bgr555_to_rgb565_one r9 + bgr555_to_rgb565_one r10 + stmia r0!, {r3-r10} + bge 0b + +1: + adds r2, #4*8 + popeq {r4-r11,pc} + +2: + ldr r3, [r1], #4 + subs r2, #4 + bgr555_to_rgb565_one r3 + str r3, [r0], #4 + bgt 2b + + pop {r4-r11,pc} diff --git a/jni/Android.mk b/jni/Android.mk index 05a92d4..81962e0 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -35,6 +35,7 @@ ifeq ($(TARGET_ARCH),arm) # gpu LOCAL_CFLAGS += -DREARMED LOCAL_SRC_FILES += ../plugins/gpu_unai/gpulib_if.cpp ../plugins/gpu_unai/gpu_arm.s + LOCAL_SRC_FILES += ../frontend/cspace_arm.S else LOCAL_ARM_NEON := true LOCAL_CFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP -- cgit v1.2.3