vo_gpu: don't pass gl_user_shader_hook by value

This commit is contained in:
Kacper Michajłow 2023-11-24 01:07:00 +01:00 committed by sfan5
parent 3b1cb5d6aa
commit c78f0237ef
3 changed files with 10 additions and 12 deletions

View File

@ -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;
}
}

View File

@ -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

View File

@ -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;