diff --git a/video/out/gpu/user_shaders.c b/video/out/gpu/user_shaders.c index 708de87485..f2507b63f5 100644 --- a/video/out/gpu/user_shaders.c +++ b/video/out/gpu/user_shaders.c @@ -431,7 +431,7 @@ static bool parse_tex(struct mp_log *log, struct ra *ra, struct bstr *body, void parse_user_shader(struct mp_log *log, struct ra *ra, struct bstr shader, void *priv, - bool (*dohook)(void *p, struct gl_user_shader_hook hook), + bool (*dohook)(void *p, const struct gl_user_shader_hook *hook), bool (*dotex)(void *p, struct gl_user_shader_tex tex)) { if (!dohook || !dotex || !shader.len) @@ -457,7 +457,7 @@ void parse_user_shader(struct mp_log *log, struct ra *ra, struct bstr shader, } struct gl_user_shader_hook h; - if (!parse_hook(log, &shader, &h) || !dohook(priv, h)) + if (!parse_hook(log, &shader, &h) || !dohook(priv, &h)) return; } } diff --git a/video/out/gpu/user_shaders.h b/video/out/gpu/user_shaders.h index 4bb7c2250f..d3405a8c76 100644 --- a/video/out/gpu/user_shaders.h +++ b/video/out/gpu/user_shaders.h @@ -88,7 +88,7 @@ struct gl_user_shader_tex { // valid shader block parsed. void parse_user_shader(struct mp_log *log, struct ra *ra, struct bstr shader, void *priv, - bool (*dohook)(void *p, struct gl_user_shader_hook hook), + bool (*dohook)(void *p, const struct gl_user_shader_hook *hook), bool (*dotex)(void *p, struct gl_user_shader_tex tex)); // Evaluate a szexp, given a lookup function for named textures diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index fe679e662a..ab947c4452 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -2048,25 +2048,23 @@ static void user_hook(struct gl_video *p, struct image img, gl_transform_trans(shader->offset, trans); } -static bool add_user_hook(void *priv, struct gl_user_shader_hook hook) +static bool add_user_hook(void *priv, const struct gl_user_shader_hook *hook) { struct gl_video *p = priv; - struct gl_user_shader_hook *copy = talloc_ptrtype(p, copy); - *copy = hook; - + struct gl_user_shader_hook *copy = talloc_dup(p, (struct gl_user_shader_hook *)hook); struct tex_hook texhook = { - .save_tex = bstrdup0(copy, hook.save_tex), - .components = hook.components, - .align_offset = hook.align_offset, + .save_tex = bstrdup0(copy, copy->save_tex), + .components = copy->components, + .align_offset = copy->align_offset, .hook = user_hook, .cond = user_hook_cond, .priv = copy, }; for (int h = 0; h < SHADER_MAX_HOOKS; h++) - texhook.hook_tex[h] = bstrdup0(copy, hook.hook_tex[h]); + texhook.hook_tex[h] = bstrdup0(copy, copy->hook_tex[h]); for (int h = 0; h < SHADER_MAX_BINDS; h++) - texhook.bind_tex[h] = bstrdup0(copy, hook.bind_tex[h]); + texhook.bind_tex[h] = bstrdup0(copy, copy->bind_tex[h]); MP_TARRAY_APPEND(p, p->tex_hooks, p->num_tex_hooks, texhook); return true;