Configurable FBO support.
This commit is contained in:
parent
e484e22e2f
commit
6c85e6e702
4
Makefile
4
Makefile
|
@ -77,6 +77,10 @@ else
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HAVE_FBO), 1)
|
||||||
|
DEFINES += -DHAVE_FBO
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_XVIDEO), 1)
|
ifeq ($(HAVE_XVIDEO), 1)
|
||||||
OBJ += gfx/xvideo.o input/x11_input.o
|
OBJ += gfx/xvideo.o input/x11_input.o
|
||||||
LIBS += -lXv -lX11
|
LIBS += -lXv -lX11
|
||||||
|
|
|
@ -14,6 +14,7 @@ HAVE_XAUDIO = 1
|
||||||
HAVE_RSOUND = 1
|
HAVE_RSOUND = 1
|
||||||
HAVE_FILTER = 1
|
HAVE_FILTER = 1
|
||||||
HAVE_NETPLAY = 1
|
HAVE_NETPLAY = 1
|
||||||
|
HAVE_FBO = 1
|
||||||
libsnes ?= -lsnes
|
libsnes ?= -lsnes
|
||||||
|
|
||||||
LIBS = -lm
|
LIBS = -lm
|
||||||
|
@ -76,6 +77,10 @@ else
|
||||||
LIBS += $(libsnes)
|
LIBS += $(libsnes)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HAVE_FBO), 1)
|
||||||
|
DEFINES += -DHAVE_FBO
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(V),1)
|
ifneq ($(V),1)
|
||||||
Q := @
|
Q := @
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -80,6 +80,12 @@ static const bool _xml_supp = true;
|
||||||
static const bool _xml_supp = false;
|
static const bool _xml_supp = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
|
static const bool _fbo_supp = true;
|
||||||
|
#else
|
||||||
|
static const bool _fbo_supp = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DYNAMIC
|
#ifdef HAVE_DYNAMIC
|
||||||
static const bool _dynamic_supp = true;
|
static const bool _dynamic_supp = true;
|
||||||
#else
|
#else
|
||||||
|
|
23
gfx/gl.c
23
gfx/gl.c
|
@ -73,6 +73,7 @@ static const GLfloat fbo_tex_coords[] = {
|
||||||
1, 0
|
1, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static PFNGLGENFRAMEBUFFERSPROC pglGenFramebuffers = NULL;
|
static PFNGLGENFRAMEBUFFERSPROC pglGenFramebuffers = NULL;
|
||||||
static PFNGLBINDFRAMEBUFFERPROC pglBindFramebuffer = NULL;
|
static PFNGLBINDFRAMEBUFFERPROC pglBindFramebuffer = NULL;
|
||||||
|
@ -100,6 +101,7 @@ static bool load_fbo_proc(void)
|
||||||
#define pglDeleteFramebuffers glDeleteFramebuffers
|
#define pglDeleteFramebuffers glDeleteFramebuffers
|
||||||
static bool load_fbo_proc(void) { return true; }
|
static bool load_fbo_proc(void) { return true; }
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_SHADERS 16
|
#define MAX_SHADERS 16
|
||||||
|
|
||||||
|
@ -109,6 +111,7 @@ typedef struct gl
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
GLuint tex_filter;
|
GLuint tex_filter;
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
// Render-to-texture, multipass shaders
|
// Render-to-texture, multipass shaders
|
||||||
GLuint fbo[MAX_SHADERS];
|
GLuint fbo[MAX_SHADERS];
|
||||||
GLuint fbo_texture[MAX_SHADERS];
|
GLuint fbo_texture[MAX_SHADERS];
|
||||||
|
@ -117,6 +120,7 @@ typedef struct gl
|
||||||
bool render_to_tex;
|
bool render_to_tex;
|
||||||
int fbo_pass;
|
int fbo_pass;
|
||||||
bool fbo_inited;
|
bool fbo_inited;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool should_resize;
|
bool should_resize;
|
||||||
bool quitting;
|
bool quitting;
|
||||||
|
@ -132,7 +136,9 @@ typedef struct gl
|
||||||
unsigned last_height;
|
unsigned last_height;
|
||||||
unsigned tex_w, tex_h;
|
unsigned tex_w, tex_h;
|
||||||
GLfloat tex_coords[8];
|
GLfloat tex_coords[8];
|
||||||
|
#ifdef HAVE_FBO
|
||||||
GLfloat fbo_tex_coords[8];
|
GLfloat fbo_tex_coords[8];
|
||||||
|
#endif
|
||||||
|
|
||||||
GLenum texture_type; // XBGR1555 or RGBA
|
GLenum texture_type; // XBGR1555 or RGBA
|
||||||
GLenum texture_fmt;
|
GLenum texture_fmt;
|
||||||
|
@ -270,6 +276,7 @@ static bool gl_shader_filter_type(unsigned index, bool *smooth)
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
static void gl_shader_scale(unsigned index, struct gl_fbo_scale *scale)
|
static void gl_shader_scale(unsigned index, struct gl_fbo_scale *scale)
|
||||||
{
|
{
|
||||||
scale->valid = false;
|
scale->valid = false;
|
||||||
|
@ -283,6 +290,7 @@ static void gl_shader_scale(unsigned index, struct gl_fbo_scale *scale)
|
||||||
gl_glsl_shader_scale(index, scale);
|
gl_glsl_shader_scale(index, scale);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
//////////////// Message rendering
|
//////////////// Message rendering
|
||||||
|
@ -310,6 +318,7 @@ static inline void gl_init_font(gl_t *gl, const char *font_path, unsigned font_s
|
||||||
|
|
||||||
static void gl_init_fbo(gl_t *gl, unsigned width, unsigned height)
|
static void gl_init_fbo(gl_t *gl, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_FBO
|
||||||
if (!g_settings.video.render_to_texture && gl_shader_num() <= 1)
|
if (!g_settings.video.render_to_texture && gl_shader_num() <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -404,6 +413,11 @@ error:
|
||||||
glDeleteTextures(gl->fbo_pass, gl->fbo_texture);
|
glDeleteTextures(gl->fbo_pass, gl->fbo_texture);
|
||||||
pglDeleteFramebuffers(gl->fbo_pass, gl->fbo);
|
pglDeleteFramebuffers(gl->fbo_pass, gl->fbo);
|
||||||
SSNES_WARN("Failed to set up FBO. Two-pass shading will not work.\n");
|
SSNES_WARN("Failed to set up FBO. Two-pass shading will not work.\n");
|
||||||
|
#else
|
||||||
|
(void)gl;
|
||||||
|
(void)width;
|
||||||
|
(void)height;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gl_deinit_font(gl_t *gl)
|
static inline void gl_deinit_font(gl_t *gl)
|
||||||
|
@ -537,6 +551,7 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
|
||||||
|
|
||||||
gl_shader_use(1);
|
gl_shader_use(1);
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
// Render to texture in first pass.
|
// Render to texture in first pass.
|
||||||
if (gl->fbo_inited)
|
if (gl->fbo_inited)
|
||||||
{
|
{
|
||||||
|
@ -552,13 +567,16 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
|
||||||
gl->render_to_tex = true;
|
gl->render_to_tex = true;
|
||||||
set_viewport(gl, gl->fbo_rect[0].img_width, gl->fbo_rect[0].img_height, true);
|
set_viewport(gl, gl->fbo_rect[0].img_width, gl->fbo_rect[0].img_height, true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (gl->should_resize)
|
if (gl->should_resize)
|
||||||
{
|
{
|
||||||
gl->should_resize = false;
|
gl->should_resize = false;
|
||||||
SDL_SetVideoMode(gl->win_width, gl->win_height, 0, SDL_OPENGL | SDL_RESIZABLE | (g_settings.video.fullscreen ? SDL_FULLSCREEN : 0));
|
SDL_SetVideoMode(gl->win_width, gl->win_height, 0, SDL_OPENGL | SDL_RESIZABLE | (g_settings.video.fullscreen ? SDL_FULLSCREEN : 0));
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
if (!gl->render_to_tex)
|
if (!gl->render_to_tex)
|
||||||
|
#endif
|
||||||
set_viewport(gl, gl->win_width, gl->win_height, false);
|
set_viewport(gl, gl->win_width, gl->win_height, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,6 +615,7 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
|
||||||
|
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
if (gl->fbo_inited)
|
if (gl->fbo_inited)
|
||||||
{
|
{
|
||||||
// Render the rest of our passes.
|
// Render the rest of our passes.
|
||||||
|
@ -655,6 +674,7 @@ static bool gl_frame(void *data, const void* frame, unsigned width, unsigned hei
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), gl->tex_coords);
|
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), gl->tex_coords);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
gl_render_msg(gl, msg);
|
gl_render_msg(gl, msg);
|
||||||
|
@ -676,11 +696,14 @@ static void gl_free(void *data)
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glDeleteTextures(1, &gl->texture);
|
glDeleteTextures(1, &gl->texture);
|
||||||
|
|
||||||
|
#ifdef HAVE_FBO
|
||||||
if (gl->fbo_inited)
|
if (gl->fbo_inited)
|
||||||
{
|
{
|
||||||
glDeleteTextures(gl->fbo_pass, gl->fbo_texture);
|
glDeleteTextures(gl->fbo_pass, gl->fbo_texture);
|
||||||
pglDeleteFramebuffers(gl->fbo_pass, gl->fbo);
|
pglDeleteFramebuffers(gl->fbo_pass, gl->fbo);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
free(gl);
|
free(gl);
|
||||||
|
|
|
@ -27,6 +27,12 @@ else
|
||||||
check_lib AL -lopenal alcOpenDevice
|
check_lib AL -lopenal alcOpenDevice
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$OS" = "Darwin" ]; then
|
||||||
|
check_lib FBO "-framework OpenGL" glFramebufferTexture2D
|
||||||
|
else
|
||||||
|
check_lib FBO -lGL glFramebufferTexture2D
|
||||||
|
fi
|
||||||
|
|
||||||
check_pkgconf RSOUND rsound 1.1
|
check_pkgconf RSOUND rsound 1.1
|
||||||
check_lib ROAR -lroar roar_vs_new
|
check_lib ROAR -lroar roar_vs_new
|
||||||
check_pkgconf JACK jack 0.120.1
|
check_pkgconf JACK jack 0.120.1
|
||||||
|
@ -56,7 +62,7 @@ check_pkgconf FREETYPE freetype2
|
||||||
check_lib XVIDEO -lXv XvShmCreateImage
|
check_lib XVIDEO -lXv XvShmCreateImage
|
||||||
|
|
||||||
# Creates config.mk and config.h.
|
# Creates config.mk and config.h.
|
||||||
VARS="ALSA OSS AL RSOUND ROAR JACK PULSE SDL FILTER CG XML DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO NETPLAY"
|
VARS="ALSA OSS AL RSOUND ROAR JACK PULSE SDL FILTER CG XML DYNAMIC FFMPEG AVCODEC AVFORMAT AVCORE AVUTIL SWSCALE SRC CONFIGFILE FREETYPE XVIDEO NETPLAY FBO"
|
||||||
create_config_make config.mk $VARS
|
create_config_make config.mk $VARS
|
||||||
create_config_header config.h $VARS
|
create_config_header config.h $VARS
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ add_command_line_enable SRC "Enable libsamplerate support" no
|
||||||
add_command_line_enable CONFIGFILE "Disable support for config file" yes
|
add_command_line_enable CONFIGFILE "Disable support for config file" yes
|
||||||
add_command_line_enable CG "Enable Cg shader support" auto
|
add_command_line_enable CG "Enable Cg shader support" auto
|
||||||
add_command_line_enable XML "Enable bSNES-style XML shader support" auto
|
add_command_line_enable XML "Enable bSNES-style XML shader support" auto
|
||||||
|
add_command_line_enable FBO "Enable render-to-texture (FBO) support" auto
|
||||||
add_command_line_enable ALSA "Enable ALSA support" auto
|
add_command_line_enable ALSA "Enable ALSA support" auto
|
||||||
add_command_line_enable OSS "Enable OSS support" auto
|
add_command_line_enable OSS "Enable OSS support" auto
|
||||||
add_command_line_enable RSOUND "Enable RSound support" auto
|
add_command_line_enable RSOUND "Enable RSound support" auto
|
||||||
|
|
1
ssnes.c
1
ssnes.c
|
@ -263,6 +263,7 @@ static void print_features(void)
|
||||||
_PSUPP(filter, "Filter", "CPU based video filters");
|
_PSUPP(filter, "Filter", "CPU based video filters");
|
||||||
_PSUPP(cg, "Cg", "Cg pixel shaders");
|
_PSUPP(cg, "Cg", "Cg pixel shaders");
|
||||||
_PSUPP(xml, "XML", "bSNES XML pixel shaders");
|
_PSUPP(xml, "XML", "bSNES XML pixel shaders");
|
||||||
|
_PSUPP(fbo, "FBO", "OpenGL render-to-texture (multi-pass shaders)");
|
||||||
_PSUPP(dynamic, "Dynamic", "Dynamic run-time loading of libsnes library");
|
_PSUPP(dynamic, "Dynamic", "Dynamic run-time loading of libsnes library");
|
||||||
_PSUPP(ffmpeg, "FFmpeg", "On-the-fly recording of gameplay with libavcodec");
|
_PSUPP(ffmpeg, "FFmpeg", "On-the-fly recording of gameplay with libavcodec");
|
||||||
_PSUPP(src, "SRC", "libsamplerate audio resampling");
|
_PSUPP(src, "SRC", "libsamplerate audio resampling");
|
||||||
|
|
Loading…
Reference in New Issue