Skip to content

Commit e82667e

Browse files
committed
vo_gpu: add support for DEFINE parameters
1 parent 741c5a7 commit e82667e

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

DOCS/man/options.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6434,8 +6434,10 @@ them.
64346434
Parameters are global across the entire shader file, all hooks in the
64356435
file can reference them, regardless of declaration order.
64366436

6437-
TYPE <type> (required)
6437+
TYPE <DEFINE | <type>> (required)
64386438
The parameter type. Supported types are ``float`` and ``int``.
6439+
The special type ``DEFINE`` emits a preprocessor define which can be
6440+
used inside ``#if`` directives.
64396441

64406442
MINIMUM <value>
64416443
Minimum allowed value for this parameter.
@@ -6453,7 +6455,7 @@ them.
64536455
``vo=gpu`` supports only a subset of the parameter features available in
64546456
``vo=gpu-next``. See libplacebo documentation for more detailed
64556457
information about PARAM features supported in ``vo=gpu-next``. Notably
6456-
``uint``, ``ENUM``, ``DEFINE``, ``DYNAMIC``, and ``CONSTANT`` types are
6458+
``uint``, ``ENUM``, ``DYNAMIC``, and ``CONSTANT`` types are
64576459
not available, and parameters cannot be referenced in ``WHEN``
64586460
expression.
64596461

video/out/gpu/user_shaders.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ bool parse_shader_param_value(struct mp_log *log, struct gl_user_shader_param *p
3636
mp_err(log, "Missing type for param '%.*s'\n", BSTR_P(param->name));
3737
return false;
3838
case GL_USER_SHADER_PARAM_INT:
39+
case GL_USER_SHADER_PARAM_DEFINE:
3940
v = bstrtoll(val, &rest, 10);
4041
range[0] = INT_MIN;
4142
range[1] = INT_MAX;
@@ -136,6 +137,8 @@ static bool parse_param(struct mp_log *log, struct bstr *body,
136137
param->type = GL_USER_SHADER_PARAM_FLOAT;
137138
} else if (bstr_equals0(line, "int")) {
138139
param->type = GL_USER_SHADER_PARAM_INT;
140+
} else if (bstr_equals0(line, "DEFINE")) {
141+
param->type = GL_USER_SHADER_PARAM_DEFINE;
139142
} else {
140143
mp_err(log, "Unrecognized PARAM TYPE: '%.*s'!\n", BSTR_P(line));
141144
return false;

video/out/gpu/user_shaders.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum gl_user_shader_param_type {
6767
GL_USER_SHADER_PARAM_UNKNOWN,
6868
GL_USER_SHADER_PARAM_FLOAT,
6969
GL_USER_SHADER_PARAM_INT,
70+
GL_USER_SHADER_PARAM_DEFINE,
7071
};
7172

7273
struct gl_user_shader_param {

video/out/gpu/video.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,9 @@ static void user_hook(struct gl_video *p, struct image img,
22032203
case GL_USER_SHADER_PARAM_INT:
22042204
gl_sc_uniform_i_bstr(p->sc, param->name, lrint(value));
22052205
break;
2206+
case GL_USER_SHADER_PARAM_DEFINE:
2207+
GLSLHF("#define %.*s %d\n", BSTR_P(param->name), (int)lrint(value));
2208+
break;
22062209
}
22072210
}
22082211

0 commit comments

Comments
 (0)