(PS3) Proper FBO scales now

This commit is contained in:
TwinAphex51224 2012-02-20 22:34:11 +01:00
parent 0023b4b2ce
commit be3839a9df
7 changed files with 79 additions and 85 deletions

View File

@ -198,6 +198,7 @@ struct console_settings
uint32_t mode_switch;
uint32_t *supported_resolutions;
uint32_t supported_resolutions_count;
uint32_t control_timer_expiration_frame_count;
uint32_t timer_expiration_frame_count;
#ifdef _XBOX
DWORD volume_device_type;

View File

@ -45,8 +45,6 @@
#define EMULATOR_CONTENT_DIR "SSNE10000"
char special_action_msg[256]; /* message which should be overlaid on top of the screen*/
char contentInfoPath[MAX_PATH_LENGTH];
char usrDirPath[MAX_PATH_LENGTH];
char DEFAULT_PRESET_FILE[MAX_PATH_LENGTH];
@ -69,12 +67,6 @@ SYS_PROCESS_PARAM(1001, 0x100000)
#undef main
void set_text_message(const char * message, uint32_t speed)
{
snprintf(special_action_msg, sizeof(special_action_msg), message);
SET_TIMER_EXPIRATION(speed);
}
static void set_default_settings(void)
{
// g_settings

View File

@ -44,6 +44,8 @@
menu menuStack[25];
int menuStackindex = 0;
static bool set_initial_dir_tmpbrowser;
char special_action_msg[256]; /* message which should be overlaid on top of the screen */
filebrowser_t browser; /* main file browser->for rom browser*/
filebrowser_t tmpBrowser; /* tmp file browser->for everything else*/
uint32_t set_shader = 0;
@ -155,6 +157,12 @@ static void display_menubar(uint32_t menu_enum)
cellDbgFontDraw();
}
static void set_text_message(const char * message, unsigned speed)
{
strlcpy(special_action_msg, message, sizeof(special_action_msg));
SET_TIMER_EXPIRATION(g_console.control_timer_expiration_frame_count, speed);
}
static void browser_update(filebrowser_t * b)
{
static uint64_t old_state = 0;
@ -164,7 +172,7 @@ static void browser_update(filebrowser_t * b)
diff_state = old_state ^ state;
button_was_pressed = old_state & diff_state;
if(IS_TIMER_EXPIRED())
if(IS_TIMER_EXPIRED(g_console.control_timer_expiration_frame_count))
{
if (CTRL_LSTICK_DOWN(state))
{
@ -678,6 +686,8 @@ static void menu_reinit_settings (void)
menu_init_settings_pages(&menu_controlssettings);
}
#define INPUT_SCALE 2
static void apply_scaling (unsigned init_mode)
{
switch(init_mode)
@ -686,13 +696,13 @@ static void apply_scaling (unsigned init_mode)
gl_deinit_fbo(g_gl);
break;
case FBO_INIT:
gl_init_fbo(g_gl, SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_x),
SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_y));
gl_init_fbo(g_gl, SSNES_SCALE_BASE * INPUT_SCALE,
SSNES_SCALE_BASE * INPUT_SCALE);
break;
case FBO_REINIT:
gl_deinit_fbo(g_gl);
gl_init_fbo(g_gl, SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_x),
SSNES_SCALE_BASE * (unsigned)(g_settings.video.fbo_scale_y));
gl_init_fbo(g_gl, SSNES_SCALE_BASE * INPUT_SCALE,
SSNES_SCALE_BASE * INPUT_SCALE);
break;
}
}
@ -1444,7 +1454,7 @@ static void select_setting(menu * menu_obj)
button_was_pressed = old_state & diff_state;
if(IS_TIMER_EXPIRED())
if(IS_TIMER_EXPIRED(g_console.control_timer_expiration_frame_count))
{
/* back to ROM menu if CIRCLE is pressed */
if (CTRL_L1(button_was_pressed) || CTRL_CIRCLE(button_was_pressed))
@ -1670,7 +1680,7 @@ static void ingame_menu(uint32_t menu_id)
uint64_t stuck_in_loop = 1;
static uint64_t blocking = 0;
if(IS_TIMER_EXPIRED() && blocking == false)
if(IS_TIMER_EXPIRED(g_console.control_timer_expiration_frame_count) && blocking == false)
{
if(CTRL_CIRCLE(state))
return_to_game();
@ -2005,11 +2015,8 @@ static void ingame_menu(uint32_t menu_id)
cellDbgFontPrintf (0.3f, 0.05f, 0.82f, WHITE, "Libsnes core: %s", snes_library_id());
cellDbgFontPrintf (0.7f, 0.05f, 0.82f, WHITE, "%s v%s", EMULATOR_NAME, EMULATOR_VERSION);
cellDbgFontDraw();
if(IS_TIMER_NOT_EXPIRED())
{
cellDbgFontPrintf (0.05f, 0.90f, 1.10f, WHITE, special_action_msg);
cellDbgFontDraw();
}
cellDbgFontPrintf (0.05f, 0.90f, 1.10f, WHITE, special_action_msg);
cellDbgFontDraw();
cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, comment);
cellDbgFontDraw();
}
@ -2084,7 +2091,7 @@ void menu_loop(void)
if(g_console.mode_switch == MODE_EMULATION && !g_console.frame_advance_enable)
{
SET_TIMER_EXPIRATION(30);
SET_TIMER_EXPIRATION(g_console.timer_expiration_frame_count, 30);
}
video_gl.swap(NULL);

View File

@ -106,18 +106,18 @@ static bool ps3_key_pressed(void *data, int key)
case SSNES_REWIND:
return CTRL_RSTICK_UP(state[0]) && CTRL_R2(~state[0]);
case SSNES_QUIT_KEY:
if(IS_TIMER_EXPIRED())
if(IS_TIMER_EXPIRED(g_console.timer_expiration_frame_count))
{
uint32_t r3_pressed = CTRL_R3(state[0]);
uint32_t l3_pressed = CTRL_L3(state[0]);
bool retval = false;
g_console.menu_enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED());
g_console.menu_enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED(g_console.timer_expiration_frame_count));
g_console.ingame_menu_enable = r3_pressed && !l3_pressed;
if(g_console.menu_enable || (g_console.ingame_menu_enable && !g_console.menu_enable))
{
g_console.mode_switch = MODE_MENU;
SET_TIMER_EXPIRATION(30);
SET_TIMER_EXPIRATION(g_console.control_timer_expiration_frame_count, 30);
retval = g_console.menu_enable;
}

View File

@ -629,79 +629,76 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
if (gl->fbo_inited)
{
if (gl->fbo_inited)
// Render the rest of our passes.
glTexCoordPointer(2, GL_FLOAT, 0, gl->fbo_tex_coords);
// It's kinda handy ... :)
const struct gl_fbo_rect *prev_rect;
const struct gl_fbo_rect *rect;
struct gl_tex_info *fbo_info;
// Calculate viewports, texture coordinates etc, and render all passes from FBOs, to another FBO.
for (int i = 1; i < gl->fbo_pass; i++)
{
// Render the rest of our passes.
glTexCoordPointer(2, GL_FLOAT, 0, gl->fbo_tex_coords);
prev_rect = &gl->fbo_rect[i - 1];
rect = &gl->fbo_rect[i];
fbo_info = &fbo_tex_info[i - 1];
// It's kinda handy ... :)
const struct gl_fbo_rect *prev_rect;
const struct gl_fbo_rect *rect;
struct gl_tex_info *fbo_info;
// Calculate viewports, texture coordinates etc, and render all passes from FBOs, to another FBO.
for (int i = 1; i < gl->fbo_pass; i++)
{
prev_rect = &gl->fbo_rect[i - 1];
rect = &gl->fbo_rect[i];
fbo_info = &fbo_tex_info[i - 1];
GLfloat xamt = (GLfloat)prev_rect->img_width / prev_rect->width;
GLfloat yamt = (GLfloat)prev_rect->img_height / prev_rect->height;
set_texture_coords(gl->fbo_tex_coords, xamt, yamt);
fbo_info->tex = gl->fbo_texture[i - 1];
fbo_info->input_size[0] = prev_rect->img_width;
fbo_info->input_size[1] = prev_rect->img_height;
fbo_info->tex_size[0] = prev_rect->width;
fbo_info->tex_size[1] = prev_rect->height;
memcpy(fbo_info->coord, gl->fbo_tex_coords, sizeof(gl->fbo_tex_coords));
glBindFramebufferOES(GL_FRAMEBUFFER_OES, gl->fbo[i]);
gl_cg_use(i + 1);
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]);
glClear(GL_COLOR_BUFFER_BIT);
// Render to FBO with certain size.
set_viewport(gl, rect->img_width, rect->img_height, true);
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height,
prev_rect->width, prev_rect->height,
gl->vp_width, gl->vp_height, g_frame_count,
&tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
glDrawArrays(GL_QUADS, 0, 4);
fbo_tex_info_cnt++;
}
// Render our last FBO texture directly to screen.
prev_rect = &gl->fbo_rect[gl->fbo_pass - 1];
GLfloat xamt = (GLfloat)prev_rect->img_width / prev_rect->width;
GLfloat yamt = (GLfloat)prev_rect->img_height / prev_rect->height;
set_texture_coords(gl->fbo_tex_coords, xamt, yamt);
// Render our FBO texture to back buffer.
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
gl_cg_use(gl->fbo_pass + 1);
fbo_info->tex = gl->fbo_texture[i - 1];
fbo_info->input_size[0] = prev_rect->img_width;
fbo_info->input_size[1] = prev_rect->img_height;
fbo_info->tex_size[0] = prev_rect->width;
fbo_info->tex_size[1] = prev_rect->height;
memcpy(fbo_info->coord, gl->fbo_tex_coords, sizeof(gl->fbo_tex_coords));
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, gl->fbo[i]);
gl_cg_use(i + 1);
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]);
glClear(GL_COLOR_BUFFER_BIT);
gl->render_to_tex = false;
set_viewport(gl, gl->win_width, gl->win_height, false);
// Render to FBO with certain size.
set_viewport(gl, rect->img_width, rect->img_height, true);
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height,
prev_rect->width, prev_rect->height,
gl->vp_width, gl->vp_height, g_frame_count,
&tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
glDrawArrays(GL_QUADS, 0, 4);
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
fbo_tex_info_cnt++;
}
// Render our last FBO texture directly to screen.
prev_rect = &gl->fbo_rect[gl->fbo_pass - 1];
GLfloat xamt = (GLfloat)prev_rect->img_width / prev_rect->width;
GLfloat yamt = (GLfloat)prev_rect->img_height / prev_rect->height;
set_texture_coords(gl->fbo_tex_coords, xamt, yamt);
// Render our FBO texture to back buffer.
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
gl_cg_use(gl->fbo_pass + 1);
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]);
glClear(GL_COLOR_BUFFER_BIT);
gl->render_to_tex = false;
set_viewport(gl, gl->win_width, gl->win_height, false);
gl_shader_set_params(prev_rect->img_width, prev_rect->img_height,
prev_rect->width, prev_rect->height,
gl->vp_width, gl->vp_height, g_frame_count,
&tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt);
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
glDrawArrays(GL_QUADS, 0, 4);
glTexCoordPointer(2, GL_FLOAT, 0, gl->tex_coords);
}
memmove(gl->prev_info + 1, gl->prev_info, sizeof(tex_info) * (TEXTURES - 1));

View File

@ -37,9 +37,9 @@
#define MIN_SCALING_FACTOR (1.0f)
#define MAX_SCALING_FACTOR (4.0f)
#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;
#define IS_TIMER_NOT_EXPIRED(getter) (g_frame_count < getter)
#define IS_TIMER_EXPIRED(getter) (!(IS_TIMER_NOT_EXPIRED(getter)))
#define SET_TIMER_EXPIRATION(setter, value) setter = g_frame_count + value;
enum
{

View File

@ -57,7 +57,6 @@ enum {
#define MENU_ITEM_LAST MENU_ITEM_RETURN_TO_XMB+1
extern char special_action_msg[256];
extern unsigned g_frame_count;
extern bool g_quitting;
@ -75,5 +74,3 @@ extern char DEFAULT_SHADER_FILE[MAX_PATH_LENGTH];
extern char DEFAULT_MENU_SHADER_FILE[MAX_PATH_LENGTH];
extern char SYS_CONFIG_FILE[MAX_PATH_LENGTH];
extern char MULTIMAN_GAME_TO_BOOT[MAX_PATH_LENGTH];
extern void set_text_message(const char * message, uint32_t speed);