Permalink
Browse files

Remove fixed shader index in set_shader.

  • Loading branch information...
Themaister committed Apr 7, 2013
1 parent 0d1c309 commit f88ea04c281628a2ad77b9d96c088ce850baaff7
Showing with 42 additions and 139 deletions.
  1. +1 −1 command.c
  2. +1 −8 driver.h
  3. +1 −1 driver_funcs.h
  4. +1 −5 gfx/d3d9/d3d9.cpp
  5. +34 −67 gfx/gl.c
  6. +0 −48 gfx/shader_cg.c
  7. +0 −1 gfx/shader_common.h
  8. +0 −1 gfx/shader_glsl.c
  9. +2 −5 gfx/thread_wrapper.c
  10. +1 −1 gx/gx_video.c
  11. +1 −1 retroarch.c
View
@@ -234,7 +234,7 @@ static bool cmd_set_shader(const char *arg)
msg_queue_push(g_extern.msg_queue, msg, 1, 120);
RARCH_LOG("Applying shader \"%s\".\n", arg);
- return video_set_shader_func(type, arg, RARCH_SHADER_INDEX_MULTIPASS);
+ return video_set_shader_func(type, arg);
}
static const struct cmd_action_map action_map[] = {
View
@@ -158,13 +158,6 @@ enum rarch_shader_type
#define DEFAULT_SHADER_TYPE RARCH_SHADER_NONE
#endif
-enum rarch_shader_index
-{
- RARCH_SHADER_INDEX_MULTIPASS = 0,
- RARCH_SHADER_INDEX_PASS0 = 1,
- RARCH_SHADER_INDEX_PASS1 = 2
-};
-
typedef struct video_info
{
unsigned width;
@@ -361,7 +354,7 @@ typedef struct video_driver
// Is the window still active?
bool (*alive)(void *data);
bool (*focus)(void *data); // Does the window have focus?
- bool (*set_shader)(void *data, enum rarch_shader_type type, const char *path, unsigned index); // Sets shader. Might not be implemented.
+ bool (*set_shader)(void *data, enum rarch_shader_type type, const char *path); // Sets shader. Might not be implemented. Will be moved to poke_interface later.
void (*free)(void *data);
const char *ident;
View
@@ -37,7 +37,7 @@
#define video_set_nonblock_state_func(state) driver.video->set_nonblock_state(driver.video_data, state)
#define video_alive_func() driver.video->alive(driver.video_data)
#define video_focus_func() driver.video->focus(driver.video_data)
-#define video_set_shader_func(type, path, mask) driver.video->set_shader(driver.video_data, type, path, mask)
+#define video_set_shader_func(type, path) driver.video->set_shader(driver.video_data, type, path)
#define video_set_rotation_func(rotate) driver.video->set_rotation(driver.video_data, rotate)
#define video_set_aspect_ratio_func(aspect_idx) driver.video->set_aspect_ratio(driver.video_data, aspect_idx)
#define video_viewport_info_func(info) driver.video->viewport_info(driver.video_data, info)
View
@@ -1165,12 +1165,8 @@ static bool d3d9_read_viewport(void *data, uint8_t *buffer)
return reinterpret_cast<D3DVideo*>(data)->read_viewport(buffer);
}
-static bool d3d9_set_shader(void *data, enum rarch_shader_type type, const char *path, unsigned index)
+static bool d3d9_set_shader(void *data, enum rarch_shader_type type, const char *path)
{
- // TODO: Add support for directly setting this param.
- if (index != RARCH_SHADER_INDEX_MULTIPASS)
- return false;
-
#ifdef HAVE_CG
if (type != RARCH_SHADER_CG)
{
View
101 gfx/gl.c
@@ -1982,96 +1982,63 @@ static bool gl_focus(void *data)
}
#if defined(HAVE_GLSL) || defined(HAVE_CG)
-static bool gl_set_shader(void *data, enum rarch_shader_type type, const char *path, unsigned index)
+static bool gl_set_shader(void *data, enum rarch_shader_type type, const char *path)
{
gl_t *gl = (gl_t*)data;
if (type == RARCH_SHADER_NONE)
return false;
- if (index == RARCH_SHADER_INDEX_MULTIPASS && !path)
- {
- RARCH_ERR("[GL]: Cannot set stock shader to multipass.\n");
- return false;
- }
-
- if (!gl->shader && index != RARCH_SHADER_INDEX_MULTIPASS)
- {
- RARCH_ERR("[GL]: No shader core is init. Cannot set shader %s to pass %u.\n", path, index);
- return false;
- }
-
- if (gl->shader && gl->shader->type != type)
- {
- RARCH_ERR("[GL]: Trying to set a specific shader pass %u, but that particular shader core is not initialized.\n", index);
- return false;
- }
+ gl_shader_deinit(gl);
- // Need full teardown for multipass.
- if (index == RARCH_SHADER_INDEX_MULTIPASS)
+ switch (type)
{
- gl_shader_deinit(gl);
-
- switch (type)
- {
#ifdef HAVE_GLSL
- case RARCH_SHADER_GLSL:
- gl->shader = &gl_glsl_backend;
- break;
+ case RARCH_SHADER_GLSL:
+ gl->shader = &gl_glsl_backend;
+ break;
#endif
+
#ifdef HAVE_CG
- case RARCH_SHADER_CG:
- gl->shader = &gl_cg_backend;
- break;
+ case RARCH_SHADER_CG:
+ gl->shader = &gl_cg_backend;
+ break;
#endif
- default:
- gl->shader = NULL;
- break;
- }
+ default:
+ gl->shader = NULL;
+ break;
+ }
- if (!gl->shader)
- {
- RARCH_ERR("[GL]: Cannot find shader core for path: %s.\n", path);
- return false;
- }
+ if (!gl->shader)
+ {
+ RARCH_ERR("[GL]: Cannot find shader core for path: %s.\n", path);
+ return false;
+ }
#ifdef HAVE_FBO
- gl_deinit_fbo(gl);
- glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
+ gl_deinit_fbo(gl);
+ glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
#endif
- bool ret = gl->shader->init(path);
+ if (!gl->shader->init(path))
+ {
+ RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n");
+ bool ret = gl->shader->init(NULL);
if (!ret)
- {
- RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n");
- bool ret = gl->shader->init(NULL);
- if (!ret)
- gl->shader = NULL;
- return ret;
- }
+ gl->shader = NULL;
+ return false;
+ }
#ifdef HAVE_FBO
- // Set up render to texture again.
- gl_init_fbo(gl, gl->tex_w, gl->tex_h);
+ // Set up render to texture again.
+ gl_init_fbo(gl, gl->tex_w, gl->tex_h);
#endif
- // Apparently need to set viewport for passes when we aren't using FBOs.
- gl_set_shader_viewport(gl, 0);
- gl_set_shader_viewport(gl, 1);
- return true;
- }
- else // Replace a currently loaded shader directly.
- {
- if (index > gl->shader->num_shaders())
- {
- RARCH_ERR("Can only load shader for passes that already exist. "
- "Attempted to set pass %u, but only %u passes exist.\n", index, gl->shader->num_shaders());
- return false;
- }
-
- return gl->shader->load_shader(index, path);
- }
+ // Apparently need to set viewport for passes when we aren't using FBOs.
+ gl_set_shader_viewport(gl, 0);
+ gl_set_shader_viewport(gl, 1);
+ return true;
}
#endif
View
@@ -933,53 +933,6 @@ void gl_cg_set_compiler_args(const char **argv)
cg_arguments = argv;
}
-bool gl_cg_load_shader(unsigned index, const char *path)
-{
- if (!cg_active)
- return false;
-
- if (index == 0)
- return false;
-
- if (prg[index].fprg)
- {
- cgGLUnbindProgram(cgFProf);
-
- if (prg[0].fprg != prg[index].fprg)
- cgDestroyProgram(prg[index].fprg);
- }
-
- if (prg[index].vprg)
- {
- cgGLUnbindProgram(cgVProf);
-
- if (prg[0].vprg != prg[index].vprg)
- cgDestroyProgram(prg[index].vprg);
- }
-
- memset(&prg[index], 0, sizeof(prg[index]));
-
- if (path)
- {
- if (load_program(index, path, true))
- {
- set_program_attributes(index);
- return true;
- }
- else
- {
- // Always make sure we have a valid shader.
- prg[index] = prg[0];
- return false;
- }
- }
- else
- {
- prg[index] = prg[0];
- return true;
- }
-}
-
void gl_cg_invalidate_context(void)
{
cgCtx = NULL;
@@ -996,7 +949,6 @@ const gl_shader_backend_t gl_cg_backend = {
gl_cg_set_coords,
gl_cg_set_mvp,
- gl_cg_load_shader,
RARCH_SHADER_CG,
};
View
@@ -41,7 +41,6 @@ struct gl_shader_backend
bool (*set_coords)(const struct gl_coords *coords);
bool (*set_mvp)(const math_matrix *mat);
- bool (*load_shader)(unsigned index, const char *path);
enum rarch_shader_type type;
};
View
@@ -993,7 +993,6 @@ const gl_shader_backend_t gl_glsl_backend = {
gl_glsl_set_coords,
gl_glsl_set_mvp,
- NULL,
RARCH_SHADER_GLSL,
};
View
@@ -93,7 +93,6 @@ typedef struct thread_video
{
enum rarch_shader_type type;
const char *path;
- unsigned index;
} set_shader;
struct
@@ -213,8 +212,7 @@ static void thread_loop(void *data)
{
bool ret = thr->driver->set_shader(thr->driver_data,
thr->cmd_data.set_shader.type,
- thr->cmd_data.set_shader.path,
- thr->cmd_data.set_shader.index);
+ thr->cmd_data.set_shader.path);
thr->cmd_data.b = ret;
thread_reply(thr, CMD_SET_SHADER);
break;
@@ -462,12 +460,11 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info, const inp
return thr->cmd_data.b;
}
-static bool thread_set_shader(void *data, enum rarch_shader_type type, const char *path, unsigned index)
+static bool thread_set_shader(void *data, enum rarch_shader_type type, const char *path)
{
thread_video_t *thr = (thread_video_t*)data;
thr->cmd_data.set_shader.type = type;
thr->cmd_data.set_shader.path = path;
- thr->cmd_data.set_shader.index = index;
thread_send_cmd(thr, CMD_SET_SHADER);
thread_wait_reply(thr, CMD_SET_SHADER);
return thr->cmd_data.b;
View
@@ -1008,7 +1008,7 @@ static void gx_set_rotation(void *data, unsigned orientation)
gx->should_resize = true;
}
-static bool gx_set_shader(void *data, enum rarch_shader_type type, const char *path, unsigned index)
+static bool gx_set_shader(void *data, enum rarch_shader_type type, const char *path)
{
(void)data;
(void)type;
View
@@ -2370,7 +2370,7 @@ static void check_shader_dir(void)
msg_queue_push(g_extern.msg_queue, msg, 1, 120);
RARCH_LOG("Applying shader \"%s\".\n", shader);
- if (!video_set_shader_func(type, shader, RARCH_SHADER_INDEX_MULTIPASS))
+ if (!video_set_shader_func(type, shader))
RARCH_WARN("Failed to apply shader.\n");
}

0 comments on commit f88ea04

Please sign in to comment.