diff --git a/gfx/fonts/gl_raster_font.c b/gfx/fonts/gl_raster_font.c index 7f0f970dd9..04e5415fd3 100644 --- a/gfx/fonts/gl_raster_font.c +++ b/gfx/fonts/gl_raster_font.c @@ -259,7 +259,7 @@ static void setup_font(void *data, const char *msg, GLfloat scale, GLfloat pos_x return; if (gl->shader) - gl->shader->use(GL_SHADER_STOCK_BLEND); + gl->shader->use(gl, GL_SHADER_STOCK_BLEND); gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); diff --git a/gfx/gl.c b/gfx/gl.c index 8b5912b259..d3bc8d130f 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -330,7 +330,7 @@ void gl_shader_set_coords(void *data, const struct gl_coords *coords, const math if (gl->shader) ret_coords = gl->shader->set_coords(coords); if (gl->shader) - ret_mvp = gl->shader->set_mvp(mat); + ret_mvp = gl->shader->set_mvp(gl, mat); // Fall back to FF-style if needed and possible. #ifndef NO_GL_FF_VERTEX @@ -932,7 +932,7 @@ static void gl_frame_fbo(void *data, const struct gl_tex_info *tex_info) glBindFramebuffer(GL_FRAMEBUFFER, gl->fbo[i]); if (gl->shader) - gl->shader->use(i + 1); + gl->shader->use(gl, i + 1); glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]); glClear(GL_COLOR_BUFFER_BIT); @@ -940,7 +940,7 @@ static void gl_frame_fbo(void *data, const struct gl_tex_info *tex_info) // Render to FBO with certain size. gl_set_viewport(gl, rect->img_width, rect->img_height, true, false); if (gl->shader) - gl->shader->set_params(prev_rect->img_width, prev_rect->img_height, + gl->shader->set_params(gl, prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp.width, gl->vp.height, g_extern.frame_count, tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); @@ -961,7 +961,7 @@ static void gl_frame_fbo(void *data, const struct gl_tex_info *tex_info) // Render our FBO texture to back buffer. gl_bind_backbuffer(); if (gl->shader) - gl->shader->use(gl->fbo_pass + 1); + gl->shader->use(gl, gl->fbo_pass + 1); glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]); @@ -969,7 +969,7 @@ static void gl_frame_fbo(void *data, const struct gl_tex_info *tex_info) gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); if (gl->shader) - gl->shader->set_params(prev_rect->img_width, prev_rect->img_height, + gl->shader->set_params(gl, prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp.width, gl->vp.height, g_extern.frame_count, tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); @@ -1305,7 +1305,7 @@ static inline void gl_set_shader_viewport(void *data, unsigned shader) { gl_t *gl = (gl_t*)data; if (gl->shader) - gl->shader->use(shader); + gl->shader->use(gl, shader); gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); } @@ -1356,7 +1356,7 @@ static inline void gl_draw_texture(void *data) glBindTexture(GL_TEXTURE_2D, gl->rgui_texture); if (gl->shader) - gl->shader->use(GL_SHADER_STOCK_BLEND); + gl->shader->use(gl, GL_SHADER_STOCK_BLEND); gl_shader_set_coords(gl, &gl->coords, &gl->mvp_no_rot); glEnable(GL_BLEND); @@ -1391,7 +1391,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei #endif if (gl->shader) - gl->shader->use(1); + gl->shader->use(gl, 1); #ifdef IOS // Apparently the viewport is lost each frame, thanks apple. gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); @@ -1478,7 +1478,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei } if (gl->shader) - gl->shader->set_params(width, height, + gl->shader->set_params(gl, width, height, gl->tex_w, gl->tex_h, gl->vp.width, gl->vp.height, g_extern.frame_count, @@ -1516,7 +1516,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei if (gl->hw_render_fbo_init) { if (gl->shader) - gl->shader->use(0); + gl->shader->use(gl, 0); glBindTexture(GL_TEXTURE_2D, 0); #ifndef NO_GL_FF_VERTEX gl_disable_client_arrays(gl); @@ -2574,7 +2574,7 @@ static void gl_render_overlay(void *data) { // Ensure that we reset the attrib array. if (gl->shader) - gl->shader->use(GL_SHADER_STOCK_BLEND); + gl->shader->use(gl, GL_SHADER_STOCK_BLEND); glBindTexture(GL_TEXTURE_2D, gl->overlay[i].tex); for (j = 0; j < 4; j++) diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index 2a1f8323c8..16e2cb3a47 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -155,8 +155,9 @@ static void gl_cg_reset_attrib(void) cg_attrib_index = 0; } -static bool gl_cg_set_mvp(const math_matrix *mat) +static bool gl_cg_set_mvp(void *data, const math_matrix *mat) { + (void)data; if (cg_active && prg[active_index].mvp) { cgGLSetMatrixParameterfc(prg[active_index].mvp, mat->data); @@ -193,7 +194,7 @@ static bool gl_cg_set_coords(const struct gl_coords *coords) #define set_param_1f(param, x) \ if (param) cgGLSetParameter1f(param, x) -static void gl_cg_set_params(unsigned width, unsigned height, +static void gl_cg_set_params(void *data, unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, @@ -202,6 +203,7 @@ static void gl_cg_set_params(unsigned width, unsigned height, const struct gl_tex_info *fbo_info, unsigned fbo_info_cnt) { + (void)data; unsigned i; if (!cg_active || (active_index == 0) || (active_index == GL_SHADER_STOCK_BLEND)) return; @@ -871,8 +873,10 @@ error: return false; } -static void gl_cg_use(unsigned index) +static void gl_cg_use(void *data, unsigned index) { + (void)data; + if (cg_active && prg[index].vprg && prg[index].fprg) { gl_cg_reset_attrib(); diff --git a/gfx/shader_common.h b/gfx/shader_common.h index d5621286b5..1edf331fbe 100644 --- a/gfx/shader_common.h +++ b/gfx/shader_common.h @@ -36,7 +36,7 @@ struct gl_shader_backend { bool (*init)(void *data, const char *path); void (*deinit)(void); - void (*set_params)(unsigned width, unsigned height, + void (*set_params)(void *data, unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_counter, @@ -44,13 +44,13 @@ struct gl_shader_backend const struct gl_tex_info *prev_info, const struct gl_tex_info *fbo_info, unsigned fbo_info_cnt); - void (*use)(unsigned index); + void (*use)(void *data, unsigned index); unsigned (*num_shaders)(void); bool (*filter_type)(unsigned index, bool *smooth); enum gfx_wrap_type (*wrap_type)(unsigned index); void (*shader_scale)(unsigned index, struct gfx_fbo_scale *scale); bool (*set_coords)(const struct gl_coords *coords); - bool (*set_mvp)(const math_matrix *mat); + bool (*set_mvp)(void *data, const math_matrix *mat); unsigned (*get_prev_textures)(void); enum rarch_shader_type type; diff --git a/gfx/shader_glsl.c b/gfx/shader_glsl.c index b246fe580f..3013745500 100644 --- a/gfx/shader_glsl.c +++ b/gfx/shader_glsl.c @@ -871,7 +871,7 @@ error: return false; } -static void gl_glsl_set_params(unsigned width, unsigned height, +static void gl_glsl_set_params(void *data, unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, @@ -879,6 +879,7 @@ static void gl_glsl_set_params(unsigned width, unsigned height, const struct gl_tex_info *prev_info, const struct gl_tex_info *fbo_info, unsigned fbo_info_cnt) { + (void)data; // We enforce a certain layout for our various texture types in the texunits. // - Regular frame (Texture) (always bound). // - LUT textures (always bound). @@ -1077,8 +1078,9 @@ static void gl_glsl_set_params(unsigned width, unsigned height, } } -static bool gl_glsl_set_mvp(const math_matrix *mat) +static bool gl_glsl_set_mvp(void *data, const math_matrix *mat) { + (void)data; if (!glsl_enable || !glsl_shader->modern) return false; @@ -1162,8 +1164,9 @@ static bool gl_glsl_set_coords(const struct gl_coords *coords) return true; } -static void gl_glsl_use(unsigned index) +static void gl_glsl_use(void *data, unsigned index) { + (void)data; if (glsl_enable) { gl_glsl_reset_attrib(); diff --git a/gfx/shader_hlsl.c b/gfx/shader_hlsl.c index 5988e79c45..a7313990ab 100644 --- a/gfx/shader_hlsl.c +++ b/gfx/shader_hlsl.c @@ -100,7 +100,7 @@ void hlsl_set_proj_matrix(XMMATRIX rotation_value) #define set_param_1f(param, x, constanttable) \ if (param) constanttable->SetFloat(d3d_device_ptr, param, x) -static void hlsl_set_params(unsigned width, unsigned height, +static void hlsl_set_params(void *data, unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_counter, @@ -108,7 +108,7 @@ static void hlsl_set_params(unsigned width, unsigned height, const struct gl_tex_info *prev_info, const struct gl_tex_info *fbo_info, unsigned fbo_info_cnt) { - xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev; if (!hlsl_active) return; @@ -137,9 +137,9 @@ static void hlsl_set_params(unsigned width, unsigned height, /* TODO - set lookup textures/FBO textures/state parameters/etc */ } -static bool load_program(unsigned index, const char *prog, bool path_is_file) +static bool load_program(void *data, unsigned index, const char *prog, bool path_is_file) { - xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev; HRESULT ret, ret_fp, ret_vp; ID3DXBuffer *listing_f = NULL; @@ -188,9 +188,9 @@ end: return ret; } -static bool load_stock(void) +static bool load_stock(void *data) { - if (!load_program(0, stock_hlsl_program, false)) + if (!load_program(data, 0, stock_hlsl_program, false)) { RARCH_ERR("Failed to compile passthrough shader, is something wrong with your environment?\n"); return false; @@ -215,7 +215,7 @@ static void set_program_attributes(unsigned i) prg[i].mvp_val = XMMatrixIdentity(); } -static bool load_shader(const char *cgp_path, unsigned i) +static bool load_shader(void *data, const char *cgp_path, unsigned i) { char path_buf[PATH_MAX]; fill_pathname_resolve_relative(path_buf, cgp_path, @@ -223,15 +223,15 @@ static bool load_shader(const char *cgp_path, unsigned i) RARCH_LOG("Loading Cg/HLSL shader: \"%s\".\n", path_buf); - if (!load_program(i + 1, path_buf, true)) + if (!load_program(data, i + 1, path_buf, true)) return false; return true; } -static bool load_plain(const char *path) +static bool load_plain(void *data, const char *path) { - if (!load_stock()) + if (!load_stock(data)) return false; cg_shader = (struct gfx_shader*)calloc(1, sizeof(*cg_shader)); @@ -288,9 +288,9 @@ static void hlsl_deinit_state(void) cg_shader = NULL; } -static bool load_preset(const char *path) +static bool load_preset(void *data, const char *path) { - if (!load_stock()) + if (!load_stock(data)) return false; RARCH_LOG("Loading Cg meta-shader: %s\n", path); @@ -323,7 +323,7 @@ static bool load_preset(const char *path) } for (unsigned i = 0; i < cg_shader->passes; i++) { - if (!load_shader(path, i)) + if (!load_shader(data, path, i)) { RARCH_ERR("Failed to load shaders ...\n"); return false; @@ -341,12 +341,12 @@ static bool hlsl_init(void *data, const char *path) if (path && strcmp(path_get_extension(path), ".cgp") == 0) { - if (!load_preset(path)) + if (!load_preset(d3d, path)) return false; } else { - if (!load_plain(path)) + if (!load_plain(d3d, path)) return false; } @@ -369,9 +369,9 @@ static void hlsl_deinit(void) hlsl_deinit_state(); } -static void hlsl_use(unsigned index) +static void hlsl_use(void *data, unsigned index) { - xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; if (hlsl_active && prg[index].vprg && prg[index].fprg) { @@ -415,9 +415,9 @@ static void hlsl_shader_scale(unsigned index, struct gfx_fbo_scale *scale) scale->valid = false; } -static bool hlsl_set_mvp(const math_matrix *mat) +static bool hlsl_set_mvp(void *data, const math_matrix *mat) { - xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev; if(hlsl_active && prg[active_index].mvp) diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index a8df9cda9d..a227f94956 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -778,9 +778,9 @@ static void set_vertices(void *data, unsigned pass, unsigned width, unsigned hei { set_mvp(d3d, d3d->screen_width, d3d->screen_height, d3d->dev_rotation); if (d3d->shader->use) - d3d->shader->use(pass); + d3d->shader->use(d3d, pass); if (d3d->shader->set_params) - d3d->shader->set_params(width, height, d3d->tex_w, d3d->tex_h, d3d->screen_width, + d3d->shader->set_params(d3d, width, height, d3d->tex_w, d3d->tex_h, d3d->screen_width, d3d->screen_height, g_extern.frame_count, NULL, NULL, NULL, 0); }