mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-24 19:56:06 +00:00
Merge branch 'master' of github.com:Themaister/SSNES
This commit is contained in:
commit
cc979581eb
@ -290,16 +290,37 @@ void gl_cg_set_params(unsigned width, unsigned height,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_cg_deinit(void)
|
static void gl_cg_deinit_progs(void)
|
||||||
{
|
{
|
||||||
if (!cg_active)
|
cgGLUnbindProgram(cgFProf);
|
||||||
return;
|
cgGLUnbindProgram(cgVProf);
|
||||||
|
|
||||||
|
// Programs may alias [0].
|
||||||
|
for (unsigned i = 1; i < SSNES_CG_MAX_SHADERS; i++)
|
||||||
|
{
|
||||||
|
if (prg[i].fprg != prg[0].fprg)
|
||||||
|
cgDestroyProgram(prg[i].fprg);
|
||||||
|
if (prg[i].vprg != prg[0].vprg)
|
||||||
|
cgDestroyProgram(prg[i].vprg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prg[0].fprg)
|
||||||
|
cgDestroyProgram(prg[0].fprg);
|
||||||
|
if (prg[0].vprg)
|
||||||
|
cgDestroyProgram(prg[0].vprg);
|
||||||
|
|
||||||
|
memset(prg, 0, sizeof(prg));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gl_cg_deinit_state(void)
|
||||||
|
{
|
||||||
gl_cg_reset_attrib();
|
gl_cg_reset_attrib();
|
||||||
|
|
||||||
cg_active = false;
|
cg_active = false;
|
||||||
cg_shader_num = 0;
|
cg_shader_num = 0;
|
||||||
memset(prg, 0, sizeof(prg));
|
|
||||||
|
gl_cg_deinit_progs();
|
||||||
|
|
||||||
memset(cg_scale, 0, sizeof(cg_scale));
|
memset(cg_scale, 0, sizeof(cg_scale));
|
||||||
memset(fbo_smooth, 0, sizeof(fbo_smooth));
|
memset(fbo_smooth, 0, sizeof(fbo_smooth));
|
||||||
|
|
||||||
@ -313,19 +334,48 @@ void gl_cg_deinit(void)
|
|||||||
snes_tracker = NULL;
|
snes_tracker = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Final deinit.
|
||||||
|
static void gl_cg_deinit_context_state(void)
|
||||||
|
{
|
||||||
if (menu_cg_program)
|
if (menu_cg_program)
|
||||||
{
|
{
|
||||||
free(menu_cg_program);
|
free(menu_cg_program);
|
||||||
menu_cg_program = NULL;
|
menu_cg_program = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destroying context breaks on PS3 for some unknown reason.
|
||||||
#ifndef __CELLOS_LV2__
|
#ifndef __CELLOS_LV2__
|
||||||
cgDestroyContext(cgCtx);
|
if (cgCtx)
|
||||||
cgCtx = NULL;
|
{
|
||||||
|
cgDestroyContext(cgCtx);
|
||||||
|
cgCtx = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Full deinit.
|
||||||
|
void gl_cg_deinit(void)
|
||||||
|
{
|
||||||
|
if (!cg_active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gl_cg_deinit_state();
|
||||||
|
gl_cg_deinit_context_state();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deinit as much as possible without resetting context (broken on PS3),
|
||||||
|
// and reinit cleanly.
|
||||||
|
// If this fails, we're kinda screwed without resetting everything on PS3.
|
||||||
|
bool gl_cg_reinit(const char *path)
|
||||||
|
{
|
||||||
|
if (cg_active)
|
||||||
|
gl_cg_deinit_state();
|
||||||
|
|
||||||
|
return gl_cg_init(path);
|
||||||
|
}
|
||||||
|
|
||||||
#define SET_LISTING(type) \
|
#define SET_LISTING(type) \
|
||||||
{ \
|
{ \
|
||||||
const char *list = cgGetLastListing(cgCtx); \
|
const char *list = cgGetLastListing(cgCtx); \
|
||||||
@ -1066,7 +1116,9 @@ bool gl_cg_init(const char *path)
|
|||||||
cgRTCgcInit();
|
cgRTCgcInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cgCtx = cgCreateContext();
|
if (!cgCtx)
|
||||||
|
cgCtx = cgCreateContext();
|
||||||
|
|
||||||
if (cgCtx == NULL)
|
if (cgCtx == NULL)
|
||||||
{
|
{
|
||||||
SSNES_ERR("Failed to create Cg context\n");
|
SSNES_ERR("Failed to create Cg context\n");
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
bool gl_cg_init(const char *path);
|
bool gl_cg_init(const char *path);
|
||||||
|
bool gl_cg_reinit(const char *path);
|
||||||
|
|
||||||
void gl_cg_deinit(void);
|
void gl_cg_deinit(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user