Commit 6e60a030 authored by Niklas Haas's avatar Niklas Haas
Browse files

shaders/colorspace: micro-optimize for no-op decode

Optimizes for RGB content, especially overlays.
parent 2440a902
...@@ -45,17 +45,19 @@ void pl_shader_decode_color(struct pl_shader *sh, struct pl_color_repr *repr, ...@@ -45,17 +45,19 @@ void pl_shader_decode_color(struct pl_shader *sh, struct pl_color_repr *repr,
enum pl_color_system orig_sys = repr->sys; enum pl_color_system orig_sys = repr->sys;
struct pl_transform3x3 tr = pl_color_repr_decode(repr, params); struct pl_transform3x3 tr = pl_color_repr_decode(repr, params);
ident_t cmat = sh_var(sh, (struct pl_shader_var) { if (memcmp(&tr, &pl_transform3x3_identity, sizeof(tr))) {
.var = pl_var_mat3("cmat"), ident_t cmat = sh_var(sh, (struct pl_shader_var) {
.data = PL_TRANSPOSE_3X3(tr.mat.m), .var = pl_var_mat3("cmat"),
}); .data = PL_TRANSPOSE_3X3(tr.mat.m),
});
ident_t cmat_c = sh_var(sh, (struct pl_shader_var) { ident_t cmat_c = sh_var(sh, (struct pl_shader_var) {
.var = pl_var_vec3("cmat_c"), .var = pl_var_vec3("cmat_c"),
.data = tr.c, .data = tr.c,
}); });
GLSL("color.rgb = %s * color.rgb + %s;\n", cmat, cmat_c); GLSL("color.rgb = %s * color.rgb + %s;\n", cmat, cmat_c);
}
switch (orig_sys) { switch (orig_sys) {
case PL_COLOR_SYSTEM_BT_2020_C: case PL_COLOR_SYSTEM_BT_2020_C:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment