From 8cf5799ab1e1cb2de22636eadf3119a319161aec Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 27 Aug 2017 09:15:50 +0200 Subject: vo_opengl: refactor scaler LUT weight packing/loading This is mostly done so we can support using textures with more components than the scaler LUTs have entries. But while we're at it, also change the way the weights are packed so that they're always sequential with no gaps. This allows us to simplify pass_sample_separated_get_weights as well. --- video/out/opengl/video.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'video/out/opengl/video.c') diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index f0a8635c56..09b05fd688 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -1597,23 +1597,18 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler, scaler->insufficient = !mp_init_filter(scaler->kernel, sizes, scale_factor); int size = scaler->kernel->size; - int elems_per_pixel = 4; - if (size == 1) { - elems_per_pixel = 1; - } else if (size == 2) { - elems_per_pixel = 2; - } else if (size == 6) { - elems_per_pixel = 3; - } - int width = size / elems_per_pixel; - assert(size == width * elems_per_pixel); - const struct ra_format *fmt = ra_find_float16_format(p->ra, elems_per_pixel); + int num_components = size > 2 ? 4 : size; + const struct ra_format *fmt = ra_find_float16_format(p->ra, num_components); assert(fmt); + int width = (size + num_components - 1) / num_components; // round up + int stride = width * num_components; + assert(size <= stride); + scaler->lut_size = 1 << p->opts.scaler_lut_size; - float *weights = talloc_array(NULL, float, scaler->lut_size * size); - mp_compute_lut(scaler->kernel, scaler->lut_size, weights); + float *weights = talloc_array(NULL, float, scaler->lut_size * stride); + mp_compute_lut(scaler->kernel, scaler->lut_size, stride, weights); bool use_1d = scaler->kernel->polar && (p->ra->caps & RA_CAP_TEX_1D); -- cgit v1.2.3