(PS3) Small rewrite of ps3_video_psgl.c
This commit is contained in:
parent
f3d9588e37
commit
30d229c30b
10
general.h
10
general.h
|
@ -173,14 +173,16 @@ struct settings
|
||||||
struct console_settings
|
struct console_settings
|
||||||
{
|
{
|
||||||
bool block_config_read;
|
bool block_config_read;
|
||||||
|
bool in_game_menu;
|
||||||
bool return_to_multiman_enable;
|
bool return_to_multiman_enable;
|
||||||
uint32_t *supported_resolutions;
|
bool screenshots_enable;
|
||||||
uint32_t supported_resolutions_count;
|
bool throttle;
|
||||||
|
bool triple_buffering_enabled;
|
||||||
uint32_t current_resolution_index;
|
uint32_t current_resolution_index;
|
||||||
uint32_t current_resolution_id;
|
uint32_t current_resolution_id;
|
||||||
uint32_t initial_resolution_id;
|
uint32_t initial_resolution_id;
|
||||||
bool screenshots_enable;
|
uint32_t *supported_resolutions;
|
||||||
bool in_game_menu;
|
uint32_t supported_resolutions_count;
|
||||||
char rom_path[PATH_MAX];
|
char rom_path[PATH_MAX];
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
26
ps3/menu.c
26
ps3/menu.c
|
@ -640,8 +640,28 @@ static void set_setting_label(menu * menu_obj, int currentsetting)
|
||||||
case SETTING_HW_OVERSCAN_AMOUNT:
|
case SETTING_HW_OVERSCAN_AMOUNT:
|
||||||
break;
|
break;
|
||||||
case SETTING_THROTTLE_MODE:
|
case SETTING_THROTTLE_MODE:
|
||||||
|
if(g_console.throttle)
|
||||||
|
{
|
||||||
|
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "ON");
|
||||||
|
menu_obj->items[currentsetting].text_color = GREEN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "OFF");
|
||||||
|
menu_obj->items[currentsetting].text_color = ORANGE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SETTING_TRIPLE_BUFFERING:
|
case SETTING_TRIPLE_BUFFERING:
|
||||||
|
if(g_console.triple_buffering_enabled)
|
||||||
|
{
|
||||||
|
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "ON");
|
||||||
|
menu_obj->items[currentsetting].text_color = GREEN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), "OFF");
|
||||||
|
menu_obj->items[currentsetting].text_color = ORANGE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SETTING_ENABLE_SCREENSHOTS:
|
case SETTING_ENABLE_SCREENSHOTS:
|
||||||
if(g_console.screenshots_enable)
|
if(g_console.screenshots_enable)
|
||||||
|
@ -992,6 +1012,12 @@ static void producesettingentry(menu * menu_obj, uint64_t switchvalue)
|
||||||
case SETTING_HW_OVERSCAN_AMOUNT:
|
case SETTING_HW_OVERSCAN_AMOUNT:
|
||||||
break;
|
break;
|
||||||
case SETTING_THROTTLE_MODE:
|
case SETTING_THROTTLE_MODE:
|
||||||
|
if(g_console.throttle)
|
||||||
|
ps3_unblock_swap();
|
||||||
|
else
|
||||||
|
ps3_block_swap();
|
||||||
|
g_console.throttle = !g_console.throttle;
|
||||||
|
set_text_message("", 7);
|
||||||
break;
|
break;
|
||||||
case SETTING_TRIPLE_BUFFERING:
|
case SETTING_TRIPLE_BUFFERING:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -86,50 +86,46 @@ bool g_quitting;
|
||||||
unsigned g_frame_count;
|
unsigned g_frame_count;
|
||||||
void *g_gl;
|
void *g_gl;
|
||||||
|
|
||||||
static CellVideoOutState g_video_state;
|
|
||||||
|
|
||||||
typedef struct gl
|
typedef struct gl
|
||||||
{
|
{
|
||||||
GLuint pbo;
|
|
||||||
PSGLdevice* gl_device;
|
|
||||||
PSGLcontext* gl_context;
|
|
||||||
bool vsync;
|
|
||||||
bool block_swap;
|
bool block_swap;
|
||||||
GLuint texture[TEXTURES];
|
|
||||||
unsigned tex_index; // For use with PREV.
|
|
||||||
struct gl_tex_info prev_info[TEXTURES];
|
|
||||||
GLuint tex_filter;
|
|
||||||
void *empty_buf;
|
|
||||||
|
|
||||||
// Render-to-texture, multipass shaders
|
|
||||||
GLuint fbo[MAX_SHADERS];
|
|
||||||
GLuint fbo_texture[MAX_SHADERS];
|
|
||||||
struct gl_fbo_rect fbo_rect[MAX_SHADERS];
|
|
||||||
struct gl_fbo_scale fbo_scale[MAX_SHADERS];
|
|
||||||
bool render_to_tex;
|
|
||||||
int fbo_pass;
|
|
||||||
bool fbo_inited;
|
bool fbo_inited;
|
||||||
|
|
||||||
bool should_resize;
|
|
||||||
bool keep_aspect;
|
bool keep_aspect;
|
||||||
|
bool render_to_tex;
|
||||||
unsigned win_width;
|
bool should_resize;
|
||||||
unsigned win_height;
|
bool vsync;
|
||||||
unsigned vp_width, vp_out_width;
|
int fbo_pass;
|
||||||
unsigned vp_height, vp_out_height;
|
unsigned base_size; /* 2 or 4*/
|
||||||
unsigned last_width[TEXTURES];
|
unsigned last_width[TEXTURES];
|
||||||
unsigned last_height[TEXTURES];
|
unsigned last_height[TEXTURES];
|
||||||
|
unsigned tex_index; /* For use with PREV. */
|
||||||
unsigned tex_w, tex_h;
|
unsigned tex_w, tex_h;
|
||||||
|
unsigned vp_width, vp_out_width;
|
||||||
|
unsigned vp_height, vp_out_height;
|
||||||
|
unsigned win_width;
|
||||||
|
unsigned win_height;
|
||||||
GLfloat tex_coords[8];
|
GLfloat tex_coords[8];
|
||||||
GLfloat fbo_tex_coords[8];
|
GLfloat fbo_tex_coords[8];
|
||||||
|
GLenum texture_type; /* XBGR1555 or ARGB*/
|
||||||
GLenum texture_type; // XBGR1555 or ARGB
|
|
||||||
GLenum texture_fmt;
|
GLenum texture_fmt;
|
||||||
unsigned base_size; // 2 or 4
|
/* 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;
|
} gl_t;
|
||||||
|
|
||||||
static struct texture_image menu_texture;
|
|
||||||
static GLuint menu_texture_id;
|
|
||||||
|
|
||||||
static bool gl_shader_init(void)
|
static bool gl_shader_init(void)
|
||||||
{
|
{
|
||||||
|
@ -159,21 +155,6 @@ static bool gl_shader_init(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_shader_use(unsigned index)
|
|
||||||
{
|
|
||||||
gl_cg_use(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gl_shader_deinit(void)
|
|
||||||
{
|
|
||||||
gl_cg_deinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gl_shader_set_proj_matrix(void)
|
|
||||||
{
|
|
||||||
gl_cg_set_proj_matrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gl_shader_set_params(unsigned width, unsigned height,
|
static void gl_shader_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
unsigned out_width, unsigned out_height,
|
unsigned out_width, unsigned out_height,
|
||||||
|
@ -436,7 +417,7 @@ static void set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_f
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
gl_shader_set_proj_matrix();
|
gl_cg_set_proj_matrix();
|
||||||
|
|
||||||
gl->vp_width = width;
|
gl->vp_width = width;
|
||||||
gl->vp_height = height;
|
gl->vp_height = height;
|
||||||
|
@ -447,8 +428,6 @@ static void set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_f
|
||||||
gl->vp_out_width = width;
|
gl->vp_out_width = width;
|
||||||
gl->vp_out_height = height;
|
gl->vp_out_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
//SSNES_LOG("Setting viewport @ %ux%u\n", width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void set_lut_texture_coords(const GLfloat *coords)
|
static inline void set_lut_texture_coords(const GLfloat *coords)
|
||||||
|
@ -478,7 +457,7 @@ void gl_frame_menu (void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
gl_shader_use(SSNES_CG_MENU_SHADER_INDEX);
|
gl_cg_use(SSNES_CG_MENU_SHADER_INDEX);
|
||||||
|
|
||||||
gl_cg_set_params(gl->win_width, gl->win_height, gl->win_width,
|
gl_cg_set_params(gl->win_width, gl->win_height, gl->win_width,
|
||||||
gl->win_height, gl->win_width, gl->win_height, g_frame_count,
|
gl->win_height, gl->win_width, gl->win_height, g_frame_count,
|
||||||
|
@ -487,7 +466,7 @@ void gl_frame_menu (void)
|
||||||
set_viewport(gl, gl->win_width, gl->win_height, false);
|
set_viewport(gl, gl->win_width, gl->win_height, false);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, menu_texture_id);
|
glBindTexture(GL_TEXTURE_2D, gl->menu_texture_id);
|
||||||
|
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
|
||||||
|
@ -498,7 +477,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||||
{
|
{
|
||||||
gl_t *gl = data;
|
gl_t *gl = data;
|
||||||
|
|
||||||
gl_shader_use(1);
|
gl_cg_use(1);
|
||||||
g_frame_count++;
|
g_frame_count++;
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
||||||
|
@ -567,8 +546,6 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||||
{
|
{
|
||||||
gl->should_resize = false;
|
gl->should_resize = false;
|
||||||
|
|
||||||
//sdlwrap_set_resize(gl->win_width, gl->win_height);
|
|
||||||
|
|
||||||
if (!gl->render_to_tex)
|
if (!gl->render_to_tex)
|
||||||
set_viewport(gl, gl->win_width, gl->win_height, false);
|
set_viewport(gl, gl->win_width, gl->win_height, false);
|
||||||
else
|
else
|
||||||
|
@ -699,7 +676,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||||
memcpy(fbo_info->coord, gl->fbo_tex_coords, sizeof(gl->fbo_tex_coords));
|
memcpy(fbo_info->coord, gl->fbo_tex_coords, sizeof(gl->fbo_tex_coords));
|
||||||
|
|
||||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, gl->fbo[i]);
|
glBindFramebufferOES(GL_FRAMEBUFFER_OES, gl->fbo[i]);
|
||||||
gl_shader_use(i + 1);
|
gl_cg_use(i + 1);
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]);
|
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
@ -725,7 +702,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||||
|
|
||||||
// Render our FBO texture to back buffer.
|
// Render our FBO texture to back buffer.
|
||||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
|
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
|
||||||
gl_shader_use(gl->fbo_pass + 1);
|
gl_cg_use(gl->fbo_pass + 1);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]);
|
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]);
|
||||||
|
|
||||||
|
@ -786,7 +763,8 @@ static void gl_free(void *data)
|
||||||
|
|
||||||
gl_t *gl = data;
|
gl_t *gl = data;
|
||||||
|
|
||||||
gl_shader_deinit();
|
gl_cg_deinit();
|
||||||
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
@ -814,7 +792,10 @@ static void gl_set_nonblock_state(void *data, bool state)
|
||||||
if (gl->vsync)
|
if (gl->vsync)
|
||||||
{
|
{
|
||||||
SSNES_LOG("GL VSync => %s\n", state ? "off" : "on");
|
SSNES_LOG("GL VSync => %s\n", state ? "off" : "on");
|
||||||
state ? glDisable(GL_VSYNC_SCE) : glEnable(GL_VSYNC_SCE);
|
if(state)
|
||||||
|
glDisable(GL_VSYNC_SCE);
|
||||||
|
else
|
||||||
|
glEnable(GL_VSYNC_SCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -909,9 +890,9 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||||
gl->keep_aspect = video->force_aspect;
|
gl->keep_aspect = video->force_aspect;
|
||||||
|
|
||||||
// Apparently need to set viewport for passes when we aren't using FBOs.
|
// Apparently need to set viewport for passes when we aren't using FBOs.
|
||||||
gl_shader_use(0);
|
gl_cg_use(0);
|
||||||
set_viewport(gl, gl->win_width, gl->win_height, false);
|
set_viewport(gl, gl->win_width, gl->win_height, false);
|
||||||
gl_shader_use(1);
|
gl_cg_use(1);
|
||||||
set_viewport(gl, gl->win_width, gl->win_height, false);
|
set_viewport(gl, gl->win_width, gl->win_height, false);
|
||||||
|
|
||||||
bool force_smooth;
|
bool force_smooth;
|
||||||
|
@ -1070,15 +1051,16 @@ static void get_all_available_resolutions (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In case we didn't specify a resolution - make the last resolution*/
|
/* In case we didn't specify a resolution - make the last resolution
|
||||||
/* that was added to the list (the highest resolution) the default resolution*/
|
that was added to the list (the highest resolution) the default resolution*/
|
||||||
if (g_console.current_resolution_id > num_videomodes || defaultresolution)
|
if (g_console.current_resolution_id > num_videomodes || defaultresolution)
|
||||||
g_console.current_resolution_index = g_console.supported_resolutions_count-1;
|
g_console.current_resolution_index = g_console.supported_resolutions_count-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ps3_set_resolution (void)
|
void ps3_set_resolution (void)
|
||||||
{
|
{
|
||||||
cellVideoOutGetState(CELL_VIDEO_OUT_PRIMARY, 0, &g_video_state);
|
gl_t *gl = g_gl;
|
||||||
|
cellVideoOutGetState(CELL_VIDEO_OUT_PRIMARY, 0, &gl->g_video_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ps3_next_resolution (void)
|
void ps3_next_resolution (void)
|
||||||
|
@ -1092,7 +1074,7 @@ void ps3_next_resolution (void)
|
||||||
|
|
||||||
void ps3_previous_resolution (void)
|
void ps3_previous_resolution (void)
|
||||||
{
|
{
|
||||||
if(g_console.current_resolution_index > 0)
|
if(g_console.current_resolution_index)
|
||||||
{
|
{
|
||||||
g_console.current_resolution_index--;
|
g_console.current_resolution_index--;
|
||||||
g_console.current_resolution_id = g_console.supported_resolutions[g_console.current_resolution_index];
|
g_console.current_resolution_id = g_console.supported_resolutions[g_console.current_resolution_index];
|
||||||
|
@ -1151,38 +1133,41 @@ bool ps3_setup_texture(void)
|
||||||
if (!gl)
|
if (!gl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
glGenTextures(1, &menu_texture_id);
|
glGenTextures(1, &gl->menu_texture_id);
|
||||||
|
|
||||||
SSNES_LOG("Loading texture image for menu...\n");
|
SSNES_LOG("Loading texture image for menu...\n");
|
||||||
menu_texture.pixels = memalign(128, 2048 * 2048 * 4);
|
gl->menu_texture.pixels = memalign(128, 2048 * 2048 * 4);
|
||||||
memset(menu_texture.pixels, 0, (2048 * 2048 * 4));
|
memset(gl->menu_texture.pixels, 0, (2048 * 2048 * 4));
|
||||||
if(!texture_image_load(DEFAULT_MENU_BORDER_FILE, &menu_texture))
|
if(!texture_image_load(DEFAULT_MENU_BORDER_FILE, &gl->menu_texture))
|
||||||
{
|
{
|
||||||
SSNES_ERR("Failed to load texture image for menu\n");
|
SSNES_ERR("Failed to load texture image for menu\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, menu_texture_id);
|
glBindTexture(GL_TEXTURE_2D, gl->menu_texture_id);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
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_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ARGB_SCE, menu_texture.width, menu_texture.height, 0,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_ARGB_SCE, gl->menu_texture.width, gl->menu_texture.height, 0,
|
||||||
GL_ARGB_SCE, GL_UNSIGNED_INT_8_8_8_8, menu_texture.pixels);
|
GL_ARGB_SCE, GL_UNSIGNED_INT_8_8_8_8, gl->menu_texture.pixels);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
||||||
|
|
||||||
free(menu_texture.pixels);
|
free(gl->menu_texture.pixels);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PS3 needs a working graphics stack before SSNES even starts.
|
/* PS3 needs a working graphics stack before SSNES even starts.
|
||||||
// To deal with this main.c,
|
|
||||||
// the top level module owns the instance, and is created beforehand.
|
To deal with this main.c, the top level module owns the instance,
|
||||||
// When SSNES gets around to init it, it is already allocated.
|
and is created beforehand. When SSNES gets around to init it, it
|
||||||
// When SSNES wants to free it, it is ignored.
|
is already allocated.
|
||||||
|
|
||||||
|
When SSNES wants to free it, it is ignored. */
|
||||||
|
|
||||||
void ps3_video_init(void)
|
void ps3_video_init(void)
|
||||||
{
|
{
|
||||||
video_info_t video_info = {0};
|
video_info_t video_info = {0};
|
||||||
|
|
Loading…
Reference in New Issue