From 9bc0f382ab98c48b0609071277c810db0175cde7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 22 Oct 2012 06:12:12 +0200 Subject: [PATCH] (PS3/RMenu) refactored HAVE_CG_MENU out of existence - now replaced with HAVE_RMENU - menu code has been moved over to PS3 context file --- Makefile.ps3 | 2 +- Makefile.ps3.retroarch | 2 +- console/rmenu/context/rmenu_ctx_ps3.c | 4 +- gfx/context/ps3_ctx.c | 80 ++++++++++++++++++++++++--- gfx/gfx_context.h | 5 +- gfx/gl.c | 60 ++++++++------------ gfx/gl_common.h | 5 +- 7 files changed, 107 insertions(+), 51 deletions(-) diff --git a/Makefile.ps3 b/Makefile.ps3 index 284aacc587..703931f936 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -94,7 +94,7 @@ endif PPU_LDLIBS = $(FONT_LIBS) $(GL_LIBS) -lretroarch_ps3 -lretro_ps3 -lcgc -lgcm_cmd -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysutil_np_stub -lpngdec_stub -ljpgdec_stub -lsysmodule_stub -laudio_stub -lnet_stub -lnetctl_stub -lpthread -DEFINES += -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_THREAD -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_PSGL -DHAVE_HEADSET -DHAVE_VID_CONTEXT -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_CG_MENU -DHAVE_FILEBROWSER -DHAVE_HDD_CACHE_PARTITION -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RGL -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) +DEFINES += -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_THREAD -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_PSGL -DHAVE_HEADSET -DHAVE_VID_CONTEXT -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FILEBROWSER -DHAVE_HDD_CACHE_PARTITION -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RGL -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) ifeq ($(DEBUG), 1) PPU_OPTIMIZE_LV := -O0 -g diff --git a/Makefile.ps3.retroarch b/Makefile.ps3.retroarch index 92ff9fa598..572f29c25e 100644 --- a/Makefile.ps3.retroarch +++ b/Makefile.ps3.retroarch @@ -65,7 +65,7 @@ endif PPU_RANLIB = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ranlib.exe -DEFINES += -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_THREAD -DRARCH_CONSOLE -DHAVE_RMENU -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_PSGL -DHAVE_HEADSET -DHAVE_VID_CONTEXT -DHAVE_OPENGLES1 -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_CG_MENU -DHAVE_FILEBROWSER -DHAVE_HDD_CACHE_PARTITION -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RGL -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) +DEFINES += -DHAVE_DEFAULT_RETROPAD_INPUT -DHAVE_THREAD -DRARCH_CONSOLE -DHAVE_RMENU -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_PSGL -DHAVE_HEADSET -DHAVE_VID_CONTEXT -DHAVE_OPENGLES1 -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FILEBROWSER -DHAVE_HDD_CACHE_PARTITION -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RGL -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_OSKUTIL -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) ifeq ($(DEBUG), 1) PPU_OPTIMIZE_LV := -O0 -g diff --git a/console/rmenu/context/rmenu_ctx_ps3.c b/console/rmenu/context/rmenu_ctx_ps3.c index 91e843974a..ea580b0cda 100644 --- a/console/rmenu/context/rmenu_ctx_ps3.c +++ b/console/rmenu/context/rmenu_ctx_ps3.c @@ -75,7 +75,7 @@ static void rmenu_ctx_ps3_init_textures(void) static void rmenu_ctx_ps3_free_textures(void) { gl_t *gl = driver.video_data; - gl->menu_render = false; + gl->draw_rmenu = false; } static void rmenu_ctx_ps3_render_selection_panel(rmenu_position_t *position) @@ -134,7 +134,7 @@ static void rmenu_ctx_ps3_render_msg(float xpos, float ypos, float scale, unsign static void rmenu_ctx_ps3_render_menu_enable(bool enable) { gl_t *gl = driver.video_data; - gl->menu_render = enable; + gl->draw_rmenu = enable; } static void rmenu_ctx_ps3_screenshot_enable(bool enable) diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 5cffa2e5ec..69da65b96e 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -32,7 +32,8 @@ #include "../gfx_context.h" -#ifdef HAVE_CG_MENU +#if defined(HAVE_RMENU) +GLuint menu_texture_id; static struct texture_image menu_texture; #endif @@ -196,15 +197,15 @@ static void gfx_ctx_set_blend(bool enable) static void gfx_ctx_set_resize(unsigned width, unsigned height) { } -static bool gfx_ctx_menu_init(void) +static bool gfx_ctx_rmenu_init(void) { gl_t *gl = driver.video_data; if (!gl) return false; -#ifdef HAVE_CG_MENU - glGenTextures(1, &gl->menu_texture_id); +#ifdef HAVE_RMENU + glGenTextures(1, &menu_texture_id); RARCH_LOG("Loading texture image for menu...\n"); if (!texture_image_load(default_paths.menu_border_file, &menu_texture)) @@ -213,7 +214,7 @@ static bool gfx_ctx_menu_init(void) return false; } - glBindTexture(GL_TEXTURE_2D, gl->menu_texture_id); + glBindTexture(GL_TEXTURE_2D, menu_texture_id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -231,6 +232,68 @@ static bool gfx_ctx_menu_init(void) return true; } +#if defined(HAVE_CG) && defined(HAVE_RMENU) +static void gfx_ctx_rmenu_frame(void *data) +{ + gl_t *gl = (gl_t*)data; + + const GLfloat vertexes_flipped[] = { + 0, 1, + 1, 1, + 0, 0, + 1, 0 + }; + + gl_cg_use(RARCH_CG_MENU_SHADER_INDEX); + gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); + + gl_cg_set_params(gl->win_width, gl->win_height, + gl->win_width, gl->win_height, + gl->win_width, gl->win_height, + gl->frame_count, NULL, NULL, NULL, 0); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, menu_texture_id); + + gl->coords.vertex = vertexes_flipped; + + gl_shader_set_coords(&gl->coords, &gl->mvp); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); +} +#elif defined(HAVE_GLSL) && defined(HAVE_RMENU) +static void gfx_ctx_rmenu_frame(void *data) +{ + gl_t *gl = (gl_t*)data; + + const GLfloat vertexes_flipped[] = { + 0, 1, + 1, 1, + 0, 0, + 1, 0 + }; + + gl_glsl_use(RARCH_CG_MENU_SHADER_INDEX); + gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); + + gl_glsl_set_params(gl->win_width, gl->win_height, + gl->win_width, gl->win_height, + gl->win_width, gl->win_height, + gl->frame_count, NULL, NULL, NULL, 0); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, menu_texture_id); + + gl->coords.vertex = vertexes_flipped; + + gl_shader_set_coords(&gl->coords, &gl->mvp); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); +} +#endif + static void gfx_ctx_update_window_title(bool reset) { } static void gfx_ctx_get_video_size(unsigned *width, unsigned *height) @@ -412,13 +475,16 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { gfx_ctx_get_available_resolutions, gfx_ctx_check_resolution, -#ifdef HAVE_CG_MENU - gfx_ctx_menu_init, +#ifdef HAVE_RMENU + gfx_ctx_rmenu_init, #else NULL, #endif gfx_ctx_set_fbo, gfx_ctx_apply_fbo_state_changes, +#ifdef HAVE_RMENU + gfx_ctx_rmenu_frame +#endif }; diff --git a/gfx/gfx_context.h b/gfx/gfx_context.h index a6611bd3c0..ac44de7801 100644 --- a/gfx/gfx_context.h +++ b/gfx/gfx_context.h @@ -96,10 +96,13 @@ typedef struct gfx_ctx_driver void (*set_filtering)(unsigned index, bool set_smooth); void (*get_available_resolutions)(void); int (*check_resolution)(unsigned resolution_id); - bool (*menu_init)(void); + bool (*rmenu_init)(void); void (*set_fbo)(bool); void (*apply_fbo_state_changes)(unsigned); #endif +#ifdef HAVE_RMENU + void (*rmenu_frame)(void *data); +#endif } gfx_ctx_driver_t; extern const gfx_ctx_driver_t gfx_ctx_sdl_gl; diff --git a/gfx/gl.c b/gfx/gl.c index fa5ce2d7e3..f01651693c 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -43,9 +43,6 @@ #include "shader_glsl.h" #endif -extern const GLfloat vertexes_flipped[]; -extern const GLfloat white_color[]; - // Used for the last pass when rendering to the back buffer. const GLfloat vertexes_flipped[] = { 0, 1, @@ -1031,34 +1028,12 @@ static inline void gl_next_texture_index(gl_t *gl, const struct gl_tex_info *tex gl->tex_index = (gl->tex_index + 1) & TEXTURES_MASK; } -static void gl_set_shader_viewport(gl_t *gl, unsigned shader) +static inline void gl_set_shader_viewport(gl_t *gl, unsigned shader) { gl_shader_use(shader); gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); } -#ifdef HAVE_CG_MENU -static void gl_render_menu(gl_t *gl) -{ - gl_shader_use(RARCH_CG_MENU_SHADER_INDEX); - gl_set_shader_viewport(gl, RARCH_CG_MENU_SHADER_INDEX); - - gl_shader_set_params(gl->win_width, gl->win_height, gl->win_width, - gl->win_height, gl->win_width, gl->win_height, gl->frame_count, - NULL, NULL, NULL, 0); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, gl->menu_texture_id); - - gl->coords.vertex = default_vertex_ptr; - - gl_shader_set_coords(&gl->coords, &gl->mvp); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); -} -#endif - static bool gl_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { RARCH_PERFORMANCE_INIT(frame_run); @@ -1143,9 +1118,9 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei #endif gl->ctx_driver->swap_buffers(); -#ifdef HAVE_CG_MENU - if (gl->menu_render) - gl_render_menu(gl); +#ifdef HAVE_RMENU + if (gl->draw_rmenu) + gl->ctx_driver->rmenu_frame(gl); #endif return true; @@ -1311,7 +1286,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gl->full_y = gl->win_height; } -#if defined(HAVE_CG_MENU) +#if defined(HAVE_RMENU) && defined(HAVE_CG) RARCH_LOG("Initializing menu shader ...\n"); gl_cg_set_menu_shader(default_paths.menu_shader_file); #endif @@ -1520,6 +1495,19 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) } #endif +static void gl_init_menu(void *data) +{ + gl_t *gl = (gl_t*)data; + +#ifdef HAVE_RMENU + RARCH_LOG("Initializing menu shader...\n"); + if (gl->ctx_driver->rmenu_init) + gl->ctx_driver->rmenu_init(); +#else + (void)gl; +#endif +} + #ifdef RARCH_CONSOLE static void gl_start(void) { @@ -1542,8 +1530,8 @@ static void gl_start(void) gl->ctx_driver->set_fbo(g_settings.video.fbo.enable); gl->ctx_driver->get_available_resolutions(); - if (gl->ctx_driver->menu_init) - gl->ctx_driver->menu_init(); + + gl_init_menu(gl); #ifdef HAVE_FBO // FBO mode has to be enabled once even if FBO mode has to be @@ -1574,8 +1562,8 @@ static void gl_restart(void) #ifdef RARCH_CONSOLE bool should_block_swap = gl->block_swap; #endif -#ifdef HAVE_CG_MENU - bool should_menu_render = gl->menu_render; +#ifdef HAVE_RMENU + bool should_draw_rmenu = gl->draw_rmenu; #endif gl_stop(); @@ -1584,8 +1572,8 @@ static void gl_restart(void) #endif gl_start(); -#ifdef HAVE_CG_MENU - gl->menu_render = should_menu_render; +#ifdef HAVE_RMENU + gl->draw_rmenu = should_draw_rmenu; #endif gl->frame_count = 0; diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 1f2fa549b0..165bafac86 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -233,9 +233,8 @@ typedef struct gl #ifdef RARCH_CONSOLE bool block_swap; #endif -#ifdef HAVE_CG_MENU - bool menu_render; - GLuint menu_texture_id; +#ifdef HAVE_RMENU + bool draw_rmenu; #endif bool egl_images;