vo_gpu: add support for DEFINE parameters
This commit is contained in:
1 parent
0d655fe665
commit
a0b6233318
4 files changed
+11
-2
No files matched your search
@@ -6445,8 +6445,10 @@ them.
|
||||
Parameters are global across the entire shader file, all hooks in the
|
||||
file can reference them, regardless of declaration order.
|
||||
|
||||
TYPE <type> (required)
|
||||
TYPE <DEFINE | <type>> (required)
|
||||
The parameter type. Supported types are ``float`` and ``int``.
|
||||
The special type ``DEFINE`` emits a preprocessor define which can be
|
||||
used inside ``#if`` directives.
|
||||
|
||||
MINIMUM <value>
|
||||
Minimum allowed value for this parameter.
|
||||
@@ -6464,7 +6466,7 @@ them.
|
||||
``vo=gpu`` supports only a subset of the parameter features available in
|
||||
``vo=gpu-next``. See libplacebo documentation for more detailed
|
||||
information about PARAM features supported in ``vo=gpu-next``. Notably
|
||||
``uint``, ``ENUM``, ``DEFINE``, ``DYNAMIC``, and ``CONSTANT`` types are
|
||||
``uint``, ``ENUM``, ``DYNAMIC``, and ``CONSTANT`` types are
|
||||
not available, and parameters cannot be referenced in ``WHEN``
|
||||
expression.
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ bool parse_shader_param_value(struct mp_log *log, struct gl_user_shader_param *p
|
||||
mp_err(log, "Missing type for param '%.*s'\n", BSTR_P(param->name));
|
||||
return false;
|
||||
case GL_USER_SHADER_PARAM_INT:
|
||||
case GL_USER_SHADER_PARAM_DEFINE:
|
||||
v = bstrtoll(val, &rest, 10);
|
||||
range[0] = INT_MIN;
|
||||
range[1] = INT_MAX;
|
||||
@@ -136,6 +137,8 @@ static bool parse_param(struct mp_log *log, struct bstr *body,
|
||||
param->type = GL_USER_SHADER_PARAM_FLOAT;
|
||||
} else if (bstr_equals0(line, "int")) {
|
||||
param->type = GL_USER_SHADER_PARAM_INT;
|
||||
} else if (bstr_equals0(line, "DEFINE")) {
|
||||
param->type = GL_USER_SHADER_PARAM_DEFINE;
|
||||
} else {
|
||||
mp_err(log, "Unrecognized PARAM TYPE: '%.*s'!\n", BSTR_P(line));
|
||||
return false;
|
||||
|
||||
@@ -67,6 +67,7 @@ enum gl_user_shader_param_type {
|
||||
GL_USER_SHADER_PARAM_UNKNOWN,
|
||||
GL_USER_SHADER_PARAM_FLOAT,
|
||||
GL_USER_SHADER_PARAM_INT,
|
||||
GL_USER_SHADER_PARAM_DEFINE,
|
||||
};
|
||||
|
||||
struct gl_user_shader_param {
|
||||
|
||||
@@ -2211,6 +2211,9 @@ static void user_hook(struct gl_video *p, struct image img,
|
||||
case GL_USER_SHADER_PARAM_INT:
|
||||
gl_sc_uniform_i_bstr(p->sc, param->name, lrint(value));
|
||||
break;
|
||||
case GL_USER_SHADER_PARAM_DEFINE:
|
||||
GLSLHF("#define %.*s %d\n", BSTR_P(param->name), (int)lrint(value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user