From a03dd57166ca6414910f99940dc2d17eac2521c7 Mon Sep 17 00:00:00 2001 From: TwinAphex51224 Date: Mon, 13 Feb 2012 22:07:19 +0100 Subject: [PATCH] (PS3) Use new set swap block callback --- ps3/menu.c | 6 ++-- ps3/ps3_video_psgl.c | 86 ++++++++------------------------------------ ps3/ps3_video_psgl.h | 49 +++++++++++++++++++++++-- 3 files changed, 65 insertions(+), 76 deletions(-) diff --git a/ps3/menu.c b/ps3/menu.c index 0c7a2cb941..8798b5ab0f 100644 --- a/ps3/menu.c +++ b/ps3/menu.c @@ -1994,6 +1994,8 @@ void menu_loop(void) g_console.menu_enable = true; + gl_t * gl = g_gl; + menu_reinit_settings(); if(g_console.ingame_menu_enable) @@ -2001,7 +2003,7 @@ void menu_loop(void) menuStackindex++; menuStack[menuStackindex] = menu_filebrowser; menuStack[menuStackindex].enum_id = INGAME_MENU; - ps3graphics_block_swap(); + video_gl.set_swap_block_state(NULL, true); } do @@ -2059,7 +2061,7 @@ void menu_loop(void) if(g_console.ingame_menu_enable) { menuStackindex--; // pop ingame menu from stack - ps3graphics_unblock_swap(); + video_gl.set_swap_block_state(NULL, false); } g_console.ingame_menu_enable = false; diff --git a/ps3/ps3_video_psgl.c b/ps3/ps3_video_psgl.c index 339f205da6..d1a9186b3f 100644 --- a/ps3/ps3_video_psgl.c +++ b/ps3/ps3_video_psgl.c @@ -37,7 +37,6 @@ #include "../strl.h" -#include "../gfx/image.h" #include "../gfx/shader_cg.h" #define BLUE 0xffff0000u @@ -98,61 +97,10 @@ static const GLfloat white_color[] = { 1, 1, 1, 1, }; - -static bool load_fbo_proc(void) { return true; } - -#define MAX_SHADERS 16 - -#define TEXTURES 8 -#define TEXTURES_MASK (TEXTURES - 1) - bool g_quitting; unsigned g_frame_count; void *g_gl; - -typedef struct gl -{ - bool block_swap; - bool fbo_inited; - bool keep_aspect; - bool render_to_tex; - bool should_resize; - bool vsync; - bool overscan_enable; - int fbo_pass; - unsigned base_size; /* 2 or 4*/ - unsigned last_width[TEXTURES]; - unsigned last_height[TEXTURES]; - unsigned tex_index; /* For use with PREV. */ - unsigned tex_w, tex_h; - unsigned vp_width, vp_out_width; - unsigned vp_height, vp_out_height; - unsigned win_width; - unsigned win_height; - GLfloat overscan_amount; - GLfloat tex_coords[8]; - GLfloat fbo_tex_coords[8]; - GLenum texture_type; /* XBGR1555 or ARGB*/ - GLenum texture_fmt; - /* Render-to-texture, multipass shaders */ - GLuint fbo[MAX_SHADERS]; - GLuint fbo_texture[MAX_SHADERS]; - GLuint menu_texture_id; - GLuint pbo; - GLuint texture[TEXTURES]; - GLuint tex_filter; - CellVideoOutState g_video_state; - PSGLdevice* gl_device; - PSGLcontext* gl_context; - struct gl_fbo_rect fbo_rect[MAX_SHADERS]; - struct gl_fbo_scale fbo_scale[MAX_SHADERS]; - struct gl_tex_info prev_info[TEXTURES]; - struct texture_image menu_texture; - void *empty_buf; -} gl_t; - - static bool gl_shader_init(void) { switch (g_settings.video.shader_type) @@ -276,12 +224,6 @@ static void gl_init_fbo(gl_t *gl, unsigned width, unsigned height) if (gl_shader_num() == 1 && !scale.valid && !g_settings.video.render_to_texture) return; - if (!load_fbo_proc()) - { - SSNES_ERR("Failed to locate FBO functions. Won't be able to use render-to-texture.\n"); - return; - } - gl->fbo_pass = gl_shader_num() - 1; if (scale_last.valid) gl->fbo_pass++; @@ -1117,6 +1059,18 @@ static bool gl_focus(void *data) return true; } +static void ps3graphics_set_swap_block_swap(void * data, bool toggle) +{ + (void)data; + gl_t *gl = g_gl; + gl->block_swap = toggle; + + if(toggle) + SSNES_LOG("Swap is set to blocked\n"); + else + SSNES_LOG("Swap is set to non-blocked\n"); +} + const video_driver_t video_gl = { .init = gl_init, .frame = gl_frame, @@ -1124,7 +1078,8 @@ const video_driver_t video_gl = { .set_nonblock_state = gl_set_nonblock_state, .focus = gl_focus, .free = gl_free, - .ident = "gl" + .ident = "gl", + .set_swap_block_state = ps3graphics_set_swap_block_swap }; static void get_all_available_resolutions (void) @@ -1227,19 +1182,6 @@ const char * ps3_get_resolution_label(uint32_t resolution) } } -void ps3graphics_block_swap (void) -{ - gl_t *gl = g_gl; - gl->block_swap = true; - SSNES_LOG("Swap is set to blocked\n"); -} - -void ps3graphics_unblock_swap (void) -{ - gl_t *gl = g_gl; - gl->block_swap = false; - SSNES_LOG("Swap is set to non-blocked\n"); -} void ps3graphics_set_vsync(uint32_t vsync) { diff --git a/ps3/ps3_video_psgl.h b/ps3/ps3_video_psgl.h index 15ce950cf6..77bd1aa509 100644 --- a/ps3/ps3_video_psgl.h +++ b/ps3/ps3_video_psgl.h @@ -21,8 +21,14 @@ #include "../gfx/gl_common.h" #include "../gfx/gfx_common.h" +#include "../gfx/image.h" #include +#define MAX_SHADERS 16 + +#define TEXTURES 8 +#define TEXTURES_MASK (TEXTURES - 1) + enum { ASPECT_RATIO_4_3, @@ -41,6 +47,47 @@ enum LAST_ASPECT_RATIO }; +typedef struct gl +{ + bool block_swap; + bool fbo_inited; + bool keep_aspect; + bool render_to_tex; + bool should_resize; + bool vsync; + bool overscan_enable; + int fbo_pass; + unsigned base_size; /* 2 or 4*/ + unsigned last_width[TEXTURES]; + unsigned last_height[TEXTURES]; + unsigned tex_index; /* For use with PREV. */ + unsigned tex_w, tex_h; + unsigned vp_width, vp_out_width; + unsigned vp_height, vp_out_height; + unsigned win_width; + unsigned win_height; + GLfloat overscan_amount; + GLfloat tex_coords[8]; + GLfloat fbo_tex_coords[8]; + GLenum texture_type; /* XBGR1555 or ARGB*/ + GLenum texture_fmt; + /* Render-to-texture, multipass shaders */ + GLuint fbo[MAX_SHADERS]; + GLuint fbo_texture[MAX_SHADERS]; + GLuint menu_texture_id; + GLuint pbo; + GLuint texture[TEXTURES]; + GLuint tex_filter; + CellVideoOutState g_video_state; + PSGLdevice* gl_device; + PSGLcontext* gl_context; + struct gl_fbo_rect fbo_rect[MAX_SHADERS]; + struct gl_fbo_scale fbo_scale[MAX_SHADERS]; + struct gl_tex_info prev_info[TEXTURES]; + struct texture_image menu_texture; + void *empty_buf; +} gl_t; + #define IS_TIMER_NOT_EXPIRED() (g_frame_count < g_console.timer_expiration_frame_count) #define IS_TIMER_EXPIRED() (!(IS_TIMER_NOT_EXPIRED())) #define SET_TIMER_EXPIRATION(value) g_console.timer_expiration_frame_count = g_frame_count + value; @@ -53,13 +100,11 @@ void ps3_previous_resolution (void); void ps3_next_resolution (void); void ps3_set_filtering(unsigned index, bool set_smooth); void ps3_video_deinit(void); -void ps3graphics_block_swap (void); void ps3graphics_reinit_fbos (void); void ps3graphics_set_aspect_ratio(uint32_t aspectratio_index); void ps3graphics_set_overscan(bool overscan_enable, float amount, bool recalculate_viewport); void ps3graphics_set_orientation(uint32_t orientation); void ps3graphics_set_vsync(uint32_t vsync); -void ps3graphics_unblock_swap (void); void ps3graphics_video_init(bool get_all_resolutions); void ps3graphics_video_reinit(void);